blob: 1ca58f21a3d661f794568e4f46123e95ae545154 [file] [log] [blame]
developera20cdc22024-05-31 18:57:31 +08001From 95297b6768f36fbe3a9d7c6c8bef138e4f3c3fdb Mon Sep 17 00:00:00 2001
developer7c3a5082022-06-24 13:40:42 +08002From: Shayne Chen <shayne.chen@mediatek.com>
3Date: Wed, 22 Jun 2022 10:39:47 +0800
developera20cdc22024-05-31 18:57:31 +08004Subject: [PATCH 1000/1051] wifi: mt76: mt7915: add mtk internal debug tools
5 for mt76
developer73e5a572022-04-19 10:21:20 +08006
7---
developer60a3d662023-02-07 15:24:34 +08008 mt76_connac_mcu.h | 6 +
developer28b11e22022-09-05 19:09:45 +08009 mt7915/Makefile | 2 +-
developerf552fec2023-03-27 11:22:06 +080010 mt7915/debugfs.c | 89 +-
developer28b11e22022-09-05 19:09:45 +080011 mt7915/mac.c | 14 +
developer3e11ee32023-09-27 12:24:47 +080012 mt7915/main.c | 5 +
developer60a3d662023-02-07 15:24:34 +080013 mt7915/mcu.c | 48 +-
developer28b11e22022-09-05 19:09:45 +080014 mt7915/mcu.h | 4 +
developera46f6132024-03-26 14:09:54 +080015 mt7915/mt7915.h | 56 +
developer1a173672023-12-21 14:49:33 +080016 mt7915/mt7915_debug.h | 1442 ++++++++++++++++
developera46f6132024-03-26 14:09:54 +080017 mt7915/mtk_debugfs.c | 3750 +++++++++++++++++++++++++++++++++++++++++
developer28b11e22022-09-05 19:09:45 +080018 mt7915/mtk_mcu.c | 51 +
developera46f6132024-03-26 14:09:54 +080019 mt7915/soc.c | 7 +
developer28b11e22022-09-05 19:09:45 +080020 tools/fwlog.c | 44 +-
developera46f6132024-03-26 14:09:54 +080021 13 files changed, 5499 insertions(+), 19 deletions(-)
developer28b11e22022-09-05 19:09:45 +080022 create mode 100644 mt7915/mt7915_debug.h
23 create mode 100644 mt7915/mtk_debugfs.c
24 create mode 100644 mt7915/mtk_mcu.c
developer73e5a572022-04-19 10:21:20 +080025
26diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h
developerdad89a32024-04-29 14:17:17 +080027index 99cdd1b..a8690cd 100644
developer73e5a572022-04-19 10:21:20 +080028--- a/mt76_connac_mcu.h
29+++ b/mt76_connac_mcu.h
developerdc9eeae2024-04-08 14:36:46 +080030@@ -1195,6 +1195,7 @@ enum {
developerb1654ad2022-09-27 10:30:15 +080031 MCU_EXT_CMD_SET_TX_POWER_CTRL = 0x11,
32 MCU_EXT_CMD_FW_LOG_2_HOST = 0x13,
33 MCU_EXT_CMD_TXBF_ACTION = 0x1e,
34+ MCU_EXT_CMD_MEC_CTRL = 0x1f,
35 MCU_EXT_CMD_EFUSE_BUFFER_MODE = 0x21,
36 MCU_EXT_CMD_THERMAL_PROT = 0x23,
37 MCU_EXT_CMD_STA_REC_UPDATE = 0x25,
developerdc9eeae2024-04-08 14:36:46 +080038@@ -1218,6 +1219,11 @@ enum {
developer73e5a572022-04-19 10:21:20 +080039 MCU_EXT_CMD_TX_POWER_FEATURE_CTRL = 0x58,
40 MCU_EXT_CMD_RXDCOC_CAL = 0x59,
41 MCU_EXT_CMD_GET_MIB_INFO = 0x5a,
42+#ifdef MTK_DEBUG
developer73e5a572022-04-19 10:21:20 +080043+ MCU_EXT_CMD_RED_SHOW_STA = 0x69,
44+ MCU_EXT_CMD_RED_TARGET_DELAY = 0x6A,
45+ MCU_EXT_CMD_RED_TX_RPT = 0x6B,
46+#endif
47 MCU_EXT_CMD_TXDPD_CAL = 0x60,
48 MCU_EXT_CMD_CAL_CACHE = 0x67,
developer60a3d662023-02-07 15:24:34 +080049 MCU_EXT_CMD_RED_ENABLE = 0x68,
developer73e5a572022-04-19 10:21:20 +080050diff --git a/mt7915/Makefile b/mt7915/Makefile
developerdc9eeae2024-04-08 14:36:46 +080051index c4dca9c..fd71141 100644
developer73e5a572022-04-19 10:21:20 +080052--- a/mt7915/Makefile
53+++ b/mt7915/Makefile
developer60a3d662023-02-07 15:24:34 +080054@@ -4,7 +4,7 @@ EXTRA_CFLAGS += -DCONFIG_MT76_LEDS
developer73e5a572022-04-19 10:21:20 +080055 obj-$(CONFIG_MT7915E) += mt7915e.o
56
57 mt7915e-y := pci.o init.o dma.o eeprom.o main.o mcu.o mac.o \
58- debugfs.o mmio.o
59+ debugfs.o mmio.o mtk_debugfs.o mtk_mcu.o
60
61 mt7915e-$(CONFIG_NL80211_TESTMODE) += testmode.o
developer7af0f762023-05-22 15:16:16 +080062 mt7915e-$(CONFIG_MT798X_WMAC) += soc.o
developer73e5a572022-04-19 10:21:20 +080063diff --git a/mt7915/debugfs.c b/mt7915/debugfs.c
developerdc9eeae2024-04-08 14:36:46 +080064index 894e2cd..2661386 100644
developer73e5a572022-04-19 10:21:20 +080065--- a/mt7915/debugfs.c
66+++ b/mt7915/debugfs.c
67@@ -8,6 +8,9 @@
68 #include "mac.h"
69
70 #define FW_BIN_LOG_MAGIC 0x44e98caf
71+#ifdef MTK_DEBUG
72+#define FW_BIN_LOG_MAGIC_V2 0x44d9c99a
73+#endif
74
75 /** global debugfs **/
76
developer47efbdb2023-06-29 20:33:22 +080077@@ -496,6 +499,9 @@ mt7915_fw_debug_wm_set(void *data, u64 val)
developer73e5a572022-04-19 10:21:20 +080078 int ret;
79
developer6caa5e22022-06-16 13:33:13 +080080 dev->fw.debug_wm = val ? MCU_FW_LOG_TO_HOST : 0;
developer73e5a572022-04-19 10:21:20 +080081+#ifdef MTK_DEBUG
developer6caa5e22022-06-16 13:33:13 +080082+ dev->fw.debug_wm = val;
developer73e5a572022-04-19 10:21:20 +080083+#endif
84
developer6caa5e22022-06-16 13:33:13 +080085 if (dev->fw.debug_bin)
developer73e5a572022-04-19 10:21:20 +080086 val = 16;
developer47efbdb2023-06-29 20:33:22 +080087@@ -520,6 +526,9 @@ mt7915_fw_debug_wm_set(void *data, u64 val)
developer73e5a572022-04-19 10:21:20 +080088 if (ret)
developer6caa5e22022-06-16 13:33:13 +080089 goto out;
developer73e5a572022-04-19 10:21:20 +080090 }
91+#ifdef MTK_DEBUG
92+ mt7915_mcu_fw_dbg_ctrl(dev, 68, !!val);
93+#endif
94
95 /* WM CPU info record control */
96 mt76_clear(dev, MT_CPU_UTIL_CTRL, BIT(0));
developerdc9eeae2024-04-08 14:36:46 +080097@@ -528,6 +537,12 @@ mt7915_fw_debug_wm_set(void *data, u64 val)
developer73e5a572022-04-19 10:21:20 +080098 mt76_wr(dev, MT_MCU_WM_CIRQ_IRQ_MASK_CLR_ADDR, BIT(5));
99 mt76_wr(dev, MT_MCU_WM_CIRQ_IRQ_SOFT_ADDR, BIT(5));
100
101+#ifdef MTK_DEBUG
developer6caa5e22022-06-16 13:33:13 +0800102+ if (dev->fw.debug_bin & BIT(3))
developer73e5a572022-04-19 10:21:20 +0800103+ /* use bit 7 to indicate v2 magic number */
developer6caa5e22022-06-16 13:33:13 +0800104+ dev->fw.debug_wm |= BIT(7);
developer73e5a572022-04-19 10:21:20 +0800105+#endif
106+
developer6caa5e22022-06-16 13:33:13 +0800107 out:
108 if (ret)
109 dev->fw.debug_wm = 0;
developerdc9eeae2024-04-08 14:36:46 +0800110@@ -540,7 +555,11 @@ mt7915_fw_debug_wm_get(void *data, u64 *val)
developer73e5a572022-04-19 10:21:20 +0800111 {
112 struct mt7915_dev *dev = data;
113
developer6caa5e22022-06-16 13:33:13 +0800114- *val = dev->fw.debug_wm;
developer73e5a572022-04-19 10:21:20 +0800115+#ifdef MTK_DEBUG
developer6caa5e22022-06-16 13:33:13 +0800116+ *val = dev->fw.debug_wm & ~BIT(7);
developer73e5a572022-04-19 10:21:20 +0800117+#else
developer6caa5e22022-06-16 13:33:13 +0800118+ val = dev->fw.debug_wm;
developer73e5a572022-04-19 10:21:20 +0800119+#endif
120
121 return 0;
122 }
developerdc9eeae2024-04-08 14:36:46 +0800123@@ -615,16 +634,30 @@ mt7915_fw_debug_bin_set(void *data, u64 val)
developerf552fec2023-03-27 11:22:06 +0800124 };
125 struct mt7915_dev *dev = data;
126
127- if (!dev->relay_fwlog)
128+ if (!dev->relay_fwlog && val) {
129 dev->relay_fwlog = relay_open("fwlog_data", dev->debugfs_dir,
130 1500, 512, &relay_cb, NULL);
131- if (!dev->relay_fwlog)
132- return -ENOMEM;
133+ if (!dev->relay_fwlog)
134+ return -ENOMEM;
135+ }
136
137 dev->fw.debug_bin = val;
developer73e5a572022-04-19 10:21:20 +0800138
139 relay_reset(dev->relay_fwlog);
140
141+#ifdef MTK_DEBUG
142+ dev->dbg.dump_mcu_pkt = val & BIT(4) ? true : false;
143+ dev->dbg.dump_txd = val & BIT(5) ? true : false;
144+ dev->dbg.dump_tx_pkt = val & BIT(6) ? true : false;
145+ dev->dbg.dump_rx_pkt = val & BIT(7) ? true : false;
146+ dev->dbg.dump_rx_raw = val & BIT(8) ? true : false;
developer73e5a572022-04-19 10:21:20 +0800147+#endif
148+
developerf552fec2023-03-27 11:22:06 +0800149+ if (dev->relay_fwlog && !val) {
150+ relay_close(dev->relay_fwlog);
151+ dev->relay_fwlog = NULL;
152+ }
developer6caa5e22022-06-16 13:33:13 +0800153+
154 return mt7915_fw_debug_wm_set(dev, dev->fw.debug_wm);
developer73e5a572022-04-19 10:21:20 +0800155 }
156
developerdc9eeae2024-04-08 14:36:46 +0800157@@ -1254,6 +1287,11 @@ int mt7915_init_debugfs(struct mt7915_phy *phy)
developer73e5a572022-04-19 10:21:20 +0800158 if (!ext_phy)
159 dev->debugfs_dir = dir;
160
161+#ifdef MTK_DEBUG
162+ debugfs_create_u16("wlan_idx", 0600, dir, &dev->wlan_idx);
163+ mt7915_mtk_init_debugfs(phy, dir);
164+#endif
165+
166 return 0;
167 }
168
developerdc9eeae2024-04-08 14:36:46 +0800169@@ -1266,6 +1304,12 @@ mt7915_debugfs_write_fwlog(struct mt7915_dev *dev, const void *hdr, int hdrlen,
developerf552fec2023-03-27 11:22:06 +0800170 void *dest;
171
172 spin_lock_irqsave(&lock, flags);
173+
174+ if (!dev->relay_fwlog) {
175+ spin_unlock_irqrestore(&lock, flags);
176+ return;
177+ }
178+
179 dest = relay_reserve(dev->relay_fwlog, hdrlen + len + 4);
180 if (dest) {
181 *(u32 *)dest = hdrlen + len;
developerdc9eeae2024-04-08 14:36:46 +0800182@@ -1294,17 +1338,50 @@ void mt7915_debugfs_rx_fw_monitor(struct mt7915_dev *dev, const void *data, int
developer73e5a572022-04-19 10:21:20 +0800183 .msg_type = cpu_to_le16(PKT_TYPE_RX_FW_MONITOR),
184 };
185
developerf552fec2023-03-27 11:22:06 +0800186- if (!dev->relay_fwlog)
187- return;
developer73e5a572022-04-19 10:21:20 +0800188+#ifdef MTK_DEBUG
189+ struct {
190+ __le32 magic;
191+ u8 version;
192+ u8 _rsv;
193+ __le16 serial_id;
194+ __le32 timestamp;
195+ __le16 msg_type;
196+ __le16 len;
197+ } hdr2 = {
198+ .version = 0x1,
199+ .magic = cpu_to_le32(FW_BIN_LOG_MAGIC_V2),
200+ .msg_type = PKT_TYPE_RX_FW_MONITOR,
201+ };
202+#endif
developer73e5a572022-04-19 10:21:20 +0800203
204+#ifdef MTK_DEBUG
205+ /* old magic num */
developer6caa5e22022-06-16 13:33:13 +0800206+ if (!(dev->fw.debug_wm & BIT(7))) {
developer73e5a572022-04-19 10:21:20 +0800207+ hdr.timestamp = mt76_rr(dev, MT_LPON_FRCR(0));
208+ hdr.len = *(__le16 *)data;
209+ mt7915_debugfs_write_fwlog(dev, &hdr, sizeof(hdr), data, len);
210+ } else {
211+ hdr2.serial_id = dev->dbg.fwlog_seq++;
212+ hdr2.timestamp = mt76_rr(dev, MT_LPON_FRCR(0));
213+ hdr2.len = *(__le16 *)data;
214+ mt7915_debugfs_write_fwlog(dev, &hdr2, sizeof(hdr2), data, len);
215+ }
216+#else
217 hdr.timestamp = cpu_to_le32(mt76_rr(dev, MT_LPON_FRCR(0)));
218 hdr.len = *(__le16 *)data;
219 mt7915_debugfs_write_fwlog(dev, &hdr, sizeof(hdr), data, len);
220+#endif
221 }
222
223 bool mt7915_debugfs_rx_log(struct mt7915_dev *dev, const void *data, int len)
224 {
225+#ifdef MTK_DEBUG
226+ if (get_unaligned_le32(data) != FW_BIN_LOG_MAGIC &&
227+ get_unaligned_le32(data) != FW_BIN_LOG_MAGIC_V2 &&
228+ get_unaligned_le32(data) != PKT_BIN_DEBUG_MAGIC)
229+#else
230 if (get_unaligned_le32(data) != FW_BIN_LOG_MAGIC)
231+#endif
232 return false;
233
234 if (dev->relay_fwlog)
235diff --git a/mt7915/mac.c b/mt7915/mac.c
developera20cdc22024-05-31 18:57:31 +0800236index 1c5ab41..8268c19 100644
developer73e5a572022-04-19 10:21:20 +0800237--- a/mt7915/mac.c
238+++ b/mt7915/mac.c
developera46f6132024-03-26 14:09:54 +0800239@@ -282,6 +282,10 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb,
developer73e5a572022-04-19 10:21:20 +0800240 __le16 fc = 0;
241 int idx;
242
243+#ifdef MTK_DEBUG
244+ if (dev->dbg.dump_rx_raw)
245+ mt7915_packet_log_to_host(dev, skb->data, skb->len, PKT_BIN_DEBUG_RX_RAW, 0);
246+#endif
247 memset(status, 0, sizeof(*status));
248
developer17bb0a82022-12-13 15:52:04 +0800249 if ((rxd1 & MT_RXD1_NORMAL_BAND_IDX) && !phy->mt76->band_idx) {
developera46f6132024-03-26 14:09:54 +0800250@@ -466,6 +470,10 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb,
developer73e5a572022-04-19 10:21:20 +0800251 }
252
253 hdr_gap = (u8 *)rxd - skb->data + 2 * remove_pad;
254+#ifdef MTK_DEBUG
255+ if (dev->dbg.dump_rx_pkt)
256+ mt7915_packet_log_to_host(dev, skb->data, skb->len, PKT_BIN_DEBUG_RX, hdr_gap);
257+#endif
258 if (hdr_trans && ieee80211_has_morefrags(fc)) {
developer7c3a5082022-06-24 13:40:42 +0800259 struct ieee80211_vif *vif;
260 int err;
developera46f6132024-03-26 14:09:54 +0800261@@ -804,6 +812,12 @@ int mt7915_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
developer73e5a572022-04-19 10:21:20 +0800262 tx_info->buf[1].skip_unmap = true;
263 tx_info->nbuf = MT_CT_DMA_BUF_NUM;
264
265+#ifdef MTK_DEBUG
266+ if (dev->dbg.dump_txd)
267+ mt7915_packet_log_to_host(dev, txwi, MT_TXD_SIZE, PKT_BIN_DEBUG_TXD, 0);
268+ if (dev->dbg.dump_tx_pkt)
269+ mt7915_packet_log_to_host(dev, t->skb->data, t->skb->len, PKT_BIN_DEBUG_TX, 0);
270+#endif
271 return 0;
272 }
273
developer7c3a5082022-06-24 13:40:42 +0800274diff --git a/mt7915/main.c b/mt7915/main.c
developera20cdc22024-05-31 18:57:31 +0800275index 1da1d32..5523031 100644
developer7c3a5082022-06-24 13:40:42 +0800276--- a/mt7915/main.c
277+++ b/mt7915/main.c
developerc5ce7502022-12-19 11:33:22 +0800278@@ -73,7 +73,11 @@ int mt7915_run(struct ieee80211_hw *hw)
developer7c3a5082022-06-24 13:40:42 +0800279 if (ret)
280 goto out;
281
282+#ifdef MTK_DEBUG
283+ ret = mt7915_mcu_set_sku_en(phy, !dev->dbg.sku_disable);
284+#else
285 ret = mt7915_mcu_set_sku_en(phy, true);
286+#endif
287 if (ret)
288 goto out;
289
developerbd9fa1e2023-10-16 11:04:00 +0800290@@ -254,6 +258,7 @@ static int mt7915_add_interface(struct ieee80211_hw *hw,
developer3e11ee32023-09-27 12:24:47 +0800291 mvif->sta.wcid.hw_key_idx = -1;
292 mvif->sta.wcid.tx_info |= MT_WCID_TX_INFO_SET;
developerbd9fa1e2023-10-16 11:04:00 +0800293 mt76_wcid_init(&mvif->sta.wcid);
developer3e11ee32023-09-27 12:24:47 +0800294+ mvif->sta.vif = mvif;
developer3e11ee32023-09-27 12:24:47 +0800295
296 mt7915_mac_wtbl_update(dev, idx,
developerbd9fa1e2023-10-16 11:04:00 +0800297 MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
developer73e5a572022-04-19 10:21:20 +0800298diff --git a/mt7915/mcu.c b/mt7915/mcu.c
developera20cdc22024-05-31 18:57:31 +0800299index 91a1031..37b1505 100644
developer73e5a572022-04-19 10:21:20 +0800300--- a/mt7915/mcu.c
301+++ b/mt7915/mcu.c
developer47efbdb2023-06-29 20:33:22 +0800302@@ -205,6 +205,11 @@ mt7915_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb,
developer7c3a5082022-06-24 13:40:42 +0800303 else
304 qid = MT_MCUQ_WM;
developer73e5a572022-04-19 10:21:20 +0800305
developer73e5a572022-04-19 10:21:20 +0800306+#ifdef MTK_DEBUG
307+ if (dev->dbg.dump_mcu_pkt)
308+ mt7915_packet_log_to_host(dev, skb->data, skb->len, PKT_BIN_DEBUG_MCU, 0);
309+#endif
developer7c3a5082022-06-24 13:40:42 +0800310+
311 return mt76_tx_queue_skb_raw(dev, mdev->q_mcu[qid], skb, 0);
312 }
313
developera46f6132024-03-26 14:09:54 +0800314@@ -2385,7 +2390,10 @@ static int mt7915_red_set_watermark(struct mt7915_dev *dev)
developer60a3d662023-02-07 15:24:34 +0800315 sizeof(req), false);
316 }
317
318-static int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled)
319+#ifndef MTK_DEBUG
320+static
321+#endif
322+int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled)
323 {
324 #define RED_DISABLE 0
325 #define RED_BY_WA_ENABLE 2
developera46f6132024-03-26 14:09:54 +0800326@@ -3519,6 +3527,8 @@ int mt7915_mcu_set_sku_en(struct mt7915_phy *phy, bool enable)
developer7c3a5082022-06-24 13:40:42 +0800327 .sku_enable = enable,
328 };
developer73e5a572022-04-19 10:21:20 +0800329
developer7c3a5082022-06-24 13:40:42 +0800330+ pr_info("%s: enable = %d\n", __func__, enable);
331+
332 return mt76_mcu_send_msg(&dev->mt76,
333 MCU_EXT_CMD(TX_POWER_FEATURE_CTRL), &req,
334 sizeof(req), true);
developera46f6132024-03-26 14:09:54 +0800335@@ -4185,6 +4195,23 @@ out:
developer47efbdb2023-06-29 20:33:22 +0800336 return ret;
developer73e5a572022-04-19 10:21:20 +0800337 }
developerbb8219b2022-05-03 14:10:10 +0800338
developer73e5a572022-04-19 10:21:20 +0800339+#ifdef MTK_DEBUG
340+int mt7915_dbg_mcu_wa_cmd(struct mt7915_dev *dev, int cmd, u32 a1, u32 a2, u32 a3, bool wait_resp)
341+{
342+ struct {
343+ __le32 args[3];
344+ } req = {
345+ .args = {
346+ cpu_to_le32(a1),
347+ cpu_to_le32(a2),
348+ cpu_to_le32(a3),
349+ },
350+ };
351+
352+ return mt76_mcu_send_msg(&dev->mt76, cmd, &req, sizeof(req), wait_resp);
353+}
developer73e5a572022-04-19 10:21:20 +0800354+#endif
developerbb8219b2022-05-03 14:10:10 +0800355+
356 int mt7915_mcu_rf_regval(struct mt7915_dev *dev, u32 regidx, u32 *val, bool set)
357 {
358 struct {
developerdad89a32024-04-29 14:17:17 +0800359@@ -4214,6 +4241,25 @@ int mt7915_mcu_rf_regval(struct mt7915_dev *dev, u32 regidx, u32 *val, bool set)
developerb1654ad2022-09-27 10:30:15 +0800360 return 0;
361 }
developerdad89a32024-04-29 14:17:17 +0800362
developerb1654ad2022-09-27 10:30:15 +0800363+#ifdef MTK_DEBUG
364+int mt7915_mcu_set_amsdu_algo(struct mt7915_dev *dev, u16 wcid, u8 enable)
365+{
366+ struct {
367+ u16 action;
368+ u8 _rsv1[2];
369+ u16 wcid;
370+ u8 enable;
371+ u8 _rsv2[5];
372+ } __packed req = {
373+ .action = cpu_to_le16(1),
374+ .wcid = cpu_to_le16(wcid),
375+ .enable = enable,
376+ };
377+
378+ return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(MEC_CTRL), &req, sizeof(req), true);
379+}
380+#endif
developerdad89a32024-04-29 14:17:17 +0800381+
382 int mt7915_mcu_set_qos_map(struct mt7915_dev *dev, struct ieee80211_vif *vif)
383 {
384 #define IP_DSCP_NUM 64
developer73e5a572022-04-19 10:21:20 +0800385diff --git a/mt7915/mcu.h b/mt7915/mcu.h
developerdc9eeae2024-04-08 14:36:46 +0800386index fa0847d..9ae0f07 100644
developer73e5a572022-04-19 10:21:20 +0800387--- a/mt7915/mcu.h
388+++ b/mt7915/mcu.h
developer753619c2024-02-22 13:42:45 +0800389@@ -347,6 +347,10 @@ enum {
developer73e5a572022-04-19 10:21:20 +0800390 MCU_WA_PARAM_PDMA_RX = 0x04,
391 MCU_WA_PARAM_CPU_UTIL = 0x0b,
392 MCU_WA_PARAM_RED = 0x0e,
393+#ifdef MTK_DEBUG
394+ MCU_WA_PARAM_RED_SHOW_STA = 0xf,
395+ MCU_WA_PARAM_RED_TARGET_DELAY = 0x10,
396+#endif
developer753619c2024-02-22 13:42:45 +0800397 MCU_WA_PARAM_BSS_ACQ_PKT_CNT = 0x12,
developer60a3d662023-02-07 15:24:34 +0800398 MCU_WA_PARAM_RED_SETTING = 0x40,
developer73e5a572022-04-19 10:21:20 +0800399 };
developer73e5a572022-04-19 10:21:20 +0800400diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
developera20cdc22024-05-31 18:57:31 +0800401index c813433..d2224dc 100644
developer73e5a572022-04-19 10:21:20 +0800402--- a/mt7915/mt7915.h
403+++ b/mt7915/mt7915.h
404@@ -9,6 +9,7 @@
405 #include "../mt76_connac.h"
406 #include "regs.h"
407
408+#define MTK_DEBUG 1
409 #define MT7915_MAX_INTERFACES 19
developer73e5a572022-04-19 10:21:20 +0800410 #define MT7915_WTBL_SIZE 288
developer7c3a5082022-06-24 13:40:42 +0800411 #define MT7916_WTBL_SIZE 544
developera20cdc22024-05-31 18:57:31 +0800412@@ -246,6 +247,14 @@ struct mt7915_phy {
developera46f6132024-03-26 14:09:54 +0800413 #endif
414 };
415
416+#ifdef MTK_DEBUG
417+enum {
418+ ADIE0,
419+ ADIE1,
420+ ADIE_MAX_CNT,
421+};
422+#endif
423+
424 struct mt7915_dev {
425 union { /* must be first */
426 struct mt76_dev mt76;
developera20cdc22024-05-31 18:57:31 +0800427@@ -329,6 +338,33 @@ struct mt7915_dev {
developer73e5a572022-04-19 10:21:20 +0800428 void __iomem *dcm;
429 void __iomem *sku;
developer753619c2024-02-22 13:42:45 +0800430
developer73e5a572022-04-19 10:21:20 +0800431+#ifdef MTK_DEBUG
432+ u16 wlan_idx;
433+ struct {
434+ u32 fixed_rate;
435+ u32 l1debugfs_reg;
436+ u32 l2debugfs_reg;
437+ u32 mac_reg;
438+ u32 fw_dbg_module;
439+ u8 fw_dbg_lv;
440+ u32 bcn_total_cnt[2];
441+ u16 fwlog_seq;
442+ bool dump_mcu_pkt;
443+ bool dump_txd;
444+ bool dump_tx_pkt;
445+ bool dump_rx_pkt;
446+ bool dump_rx_raw;
447+ u32 token_idx;
developer7c3a5082022-06-24 13:40:42 +0800448+ u8 sku_disable;
developer73e5a572022-04-19 10:21:20 +0800449+ } dbg;
450+ const struct mt7915_dbg_reg_desc *dbg_reg;
developera46f6132024-03-26 14:09:54 +0800451+
452+ struct {
453+ u16 id;
454+ u16 version;
455+ } adie[ADIE_MAX_CNT];
developer73e5a572022-04-19 10:21:20 +0800456+#endif
developer753619c2024-02-22 13:42:45 +0800457+
458 bool wmm_pbc_enable;
459 struct work_struct wmm_pbc_work;
developera46f6132024-03-26 14:09:54 +0800460 u32 adie_type;
developera20cdc22024-05-31 18:57:31 +0800461@@ -613,4 +649,24 @@ void mt7915_sta_add_debugfs(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
developerec567112022-10-11 11:02:55 +0800462 int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr,
463 bool pci, int *irq);
developer73e5a572022-04-19 10:21:20 +0800464
465+#ifdef MTK_DEBUG
466+int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir);
467+int mt7915_dbg_mcu_wa_cmd(struct mt7915_dev *dev, int cmd, u32 a1, u32 a2, u32 a3, bool wait_resp);
468+int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled);
469+void mt7915_dump_tmac_info(u8 *tmac_info);
470+int mt7915_mcu_set_txpower_level(struct mt7915_phy *phy, u8 drop_level);
471+void mt7915_packet_log_to_host(struct mt7915_dev *dev, const void *data, int len, int type, int des_len);
developerb1654ad2022-09-27 10:30:15 +0800472+int mt7915_mcu_set_amsdu_algo(struct mt7915_dev *dev, u16 wcid, u8 enable);
developer73e5a572022-04-19 10:21:20 +0800473+
474+#define PKT_BIN_DEBUG_MAGIC 0xc8763123
475+enum {
476+ PKT_BIN_DEBUG_MCU,
477+ PKT_BIN_DEBUG_TXD,
478+ PKT_BIN_DEBUG_TX,
479+ PKT_BIN_DEBUG_RX,
480+ PKT_BIN_DEBUG_RX_RAW,
481+};
482+
483+#endif
484+
485 #endif
486diff --git a/mt7915/mt7915_debug.h b/mt7915/mt7915_debug.h
487new file mode 100644
developerdc9eeae2024-04-08 14:36:46 +0800488index 0000000..1ec8de9
developer73e5a572022-04-19 10:21:20 +0800489--- /dev/null
490+++ b/mt7915/mt7915_debug.h
developer1a173672023-12-21 14:49:33 +0800491@@ -0,0 +1,1442 @@
developer73e5a572022-04-19 10:21:20 +0800492+#ifndef __MT7915_DEBUG_H
493+#define __MT7915_DEBUG_H
494+
495+#ifdef MTK_DEBUG
496+
497+#define DBG_INVALID_BASE 0xffffffff
498+#define DBG_INVALID_OFFSET 0x0
499+
500+struct __dbg_map {
501+ u32 phys;
502+ u32 maps;
503+ u32 size;
504+};
505+
506+struct __dbg_reg {
507+ u32 base;
508+ u32 offs;
509+};
510+
511+struct __dbg_mask {
512+ u32 end;
513+ u32 start;
514+};
515+
516+enum dbg_base_rev {
517+ MT_DBG_WFDMA0_BASE,
518+ MT_DBG_WFDMA1_BASE,
519+ MT_DBG_WFDMA0_PCIE1_BASE,
520+ MT_DBG_WFDMA1_PCIE1_BASE,
521+ MT_DBG_WFDMA_EXT_CSR_BASE,
522+ MT_DBG_SWDEF_BASE,
523+ __MT_DBG_BASE_REV_MAX,
524+};
525+
526+enum dbg_reg_rev {
527+ DBG_INT_SOURCE_CSR,
528+ DBG_INT_MASK_CSR,
529+ DBG_INT1_SOURCE_CSR,
530+ DBG_INT1_MASK_CSR,
531+ DBG_TX_RING_BASE,
532+ DBG_RX_EVENT_RING_BASE,
533+ DBG_RX_STS_RING_BASE,
534+ DBG_RX_DATA_RING_BASE,
535+ DBG_DMA_ICSC_FR0,
536+ DBG_DMA_ICSC_FR1,
537+ DBG_TMAC_ICSCR0,
538+ DBG_RMAC_RXICSRPT,
539+ DBG_MIB_M0SDR0,
540+ DBG_MIB_M0SDR3,
541+ DBG_MIB_M0SDR4,
542+ DBG_MIB_M0SDR5,
543+ DBG_MIB_M0SDR7,
544+ DBG_MIB_M0SDR8,
545+ DBG_MIB_M0SDR9,
546+ DBG_MIB_M0SDR10,
547+ DBG_MIB_M0SDR11,
548+ DBG_MIB_M0SDR12,
549+ DBG_MIB_M0SDR14,
550+ DBG_MIB_M0SDR15,
551+ DBG_MIB_M0SDR16,
552+ DBG_MIB_M0SDR17,
553+ DBG_MIB_M0SDR18,
554+ DBG_MIB_M0SDR19,
555+ DBG_MIB_M0SDR20,
556+ DBG_MIB_M0SDR21,
557+ DBG_MIB_M0SDR22,
558+ DBG_MIB_M0SDR23,
559+ DBG_MIB_M0DR0,
560+ DBG_MIB_M0DR1,
561+ DBG_MIB_MUBF,
562+ DBG_MIB_M0DR6,
563+ DBG_MIB_M0DR7,
564+ DBG_MIB_M0DR8,
565+ DBG_MIB_M0DR9,
566+ DBG_MIB_M0DR10,
567+ DBG_MIB_M0DR11,
568+ DBG_MIB_M0DR12,
569+ DBG_WTBLON_WDUCR,
570+ DBG_UWTBL_WDUCR,
571+ DBG_PLE_DRR_TABLE_CTRL,
572+ DBG_PLE_DRR_TABLE_RDATA,
573+ DBG_PLE_PBUF_CTRL,
574+ DBG_PLE_QUEUE_EMPTY,
575+ DBG_PLE_FREEPG_CNT,
576+ DBG_PLE_FREEPG_HEAD_TAIL,
577+ DBG_PLE_PG_HIF_GROUP,
578+ DBG_PLE_HIF_PG_INFO,
579+ DBG_PLE_PG_HIF_TXCMD_GROUP,
580+ DBG_PLE_HIF_TXCMD_PG_INFO,
581+ DBG_PLE_PG_CPU_GROUP,
582+ DBG_PLE_CPU_PG_INFO,
583+ DBG_PLE_FL_QUE_CTRL,
584+ DBG_PLE_NATIVE_TXCMD_Q_EMPTY,
585+ DBG_PLE_TXCMD_Q_EMPTY,
586+ DBG_PLE_AC_QEMPTY,
587+ DBG_PLE_AC_OFFSET,
588+ DBG_PLE_STATION_PAUSE,
589+ DBG_PLE_DIS_STA_MAP,
590+ DBG_PSE_PBUF_CTRL,
591+ DBG_PSE_FREEPG_CNT,
592+ DBG_PSE_FREEPG_HEAD_TAIL,
593+ DBG_PSE_HIF0_PG_INFO,
594+ DBG_PSE_PG_HIF1_GROUP,
595+ DBG_PSE_HIF1_PG_INFO,
596+ DBG_PSE_PG_CPU_GROUP,
597+ DBG_PSE_CPU_PG_INFO,
598+ DBG_PSE_PG_PLE_GROUP,
599+ DBG_PSE_PLE_PG_INFO,
600+ DBG_PSE_PG_LMAC0_GROUP,
601+ DBG_PSE_LMAC0_PG_INFO,
602+ DBG_PSE_PG_LMAC1_GROUP,
603+ DBG_PSE_LMAC1_PG_INFO,
604+ DBG_PSE_PG_LMAC2_GROUP,
605+ DBG_PSE_LMAC2_PG_INFO,
606+ DBG_PSE_PG_LMAC3_GROUP,
607+ DBG_PSE_LMAC3_PG_INFO,
608+ DBG_PSE_PG_MDP_GROUP,
609+ DBG_PSE_MDP_PG_INFO,
610+ DBG_PSE_PG_PLE1_GROUP,
611+ DBG_PSE_PLE1_PG_INFO,
612+ DBG_AGG_AALCR0,
613+ DBG_AGG_AALCR1,
614+ DBG_AGG_AALCR2,
615+ DBG_AGG_AALCR3,
616+ DBG_AGG_AALCR4,
617+ DBG_AGG_B0BRR0,
618+ DBG_AGG_B1BRR0,
619+ DBG_AGG_B2BRR0,
620+ DBG_AGG_B3BRR0,
621+ DBG_AGG_AWSCR0,
622+ DBG_AGG_PCR0,
623+ DBG_AGG_TTCR0,
624+ DBG_MIB_M0ARNG0,
625+ DBG_MIB_M0DR2,
626+ DBG_MIB_M0DR13,
developer23c22342023-01-09 13:57:39 +0800627+ DBG_WFDMA_WED_TX_CTRL,
628+ DBG_WFDMA_WED_RX_CTRL,
developer73e5a572022-04-19 10:21:20 +0800629+ __MT_DBG_REG_REV_MAX,
630+};
631+
632+enum dbg_mask_rev {
633+ DBG_MIB_M0SDR10_RX_MDRDY_COUNT,
634+ DBG_MIB_M0SDR14_AMPDU,
635+ DBG_MIB_M0SDR15_AMPDU_ACKED,
636+ DBG_MIB_RX_FCS_ERROR_COUNT,
637+ __MT_DBG_MASK_REV_MAX,
638+};
639+
640+enum dbg_bit_rev {
641+ __MT_DBG_BIT_REV_MAX,
642+};
643+
644+static const u32 mt7915_dbg_base[] = {
645+ [MT_DBG_WFDMA0_BASE] = 0xd4000,
646+ [MT_DBG_WFDMA1_BASE] = 0xd5000,
647+ [MT_DBG_WFDMA0_PCIE1_BASE] = 0xd8000,
648+ [MT_DBG_WFDMA1_PCIE1_BASE] = 0xd9000,
649+ [MT_DBG_WFDMA_EXT_CSR_BASE] = 0xd7000,
650+ [MT_DBG_SWDEF_BASE] = 0x41f200,
651+};
652+
653+static const u32 mt7916_dbg_base[] = {
654+ [MT_DBG_WFDMA0_BASE] = 0xd4000,
655+ [MT_DBG_WFDMA1_BASE] = 0xd5000,
656+ [MT_DBG_WFDMA0_PCIE1_BASE] = 0xd8000,
657+ [MT_DBG_WFDMA1_PCIE1_BASE] = 0xd9000,
658+ [MT_DBG_WFDMA_EXT_CSR_BASE] = 0xd7000,
659+ [MT_DBG_SWDEF_BASE] = 0x411400,
660+};
661+
developer70180b02023-11-14 17:01:47 +0800662+static const u32 mt7981_dbg_base[] = {
663+ [MT_DBG_WFDMA0_BASE] = 0x24000,
664+ [MT_DBG_WFDMA1_BASE] = 0x25000,
665+ [MT_DBG_WFDMA0_PCIE1_BASE] = 0x28000,
666+ [MT_DBG_WFDMA1_PCIE1_BASE] = 0x29000,
667+ [MT_DBG_WFDMA_EXT_CSR_BASE] = 0x27000,
668+ [MT_DBG_SWDEF_BASE] = 0x411400,
669+};
670+
developer73e5a572022-04-19 10:21:20 +0800671+static const u32 mt7986_dbg_base[] = {
672+ [MT_DBG_WFDMA0_BASE] = 0x24000,
673+ [MT_DBG_WFDMA1_BASE] = 0x25000,
674+ [MT_DBG_WFDMA0_PCIE1_BASE] = 0x28000,
675+ [MT_DBG_WFDMA1_PCIE1_BASE] = 0x29000,
676+ [MT_DBG_WFDMA_EXT_CSR_BASE] = 0x27000,
677+ [MT_DBG_SWDEF_BASE] = 0x411400,
678+};
679+
680+/* mt7915 regs with different base and offset */
681+static const struct __dbg_reg mt7915_dbg_reg[] = {
developer23c22342023-01-09 13:57:39 +0800682+ [DBG_WFDMA_WED_TX_CTRL] = { MT_DBG_WFDMA_EXT_CSR_BASE, 0x300 },
683+ [DBG_WFDMA_WED_RX_CTRL] = { MT_DBG_WFDMA_EXT_CSR_BASE, 0x400 },
developer73e5a572022-04-19 10:21:20 +0800684+ [DBG_INT_SOURCE_CSR] = { MT_DBG_WFDMA_EXT_CSR_BASE, 0x10 },
685+ [DBG_INT_MASK_CSR] = { MT_DBG_WFDMA_EXT_CSR_BASE, 0x14 },
686+ [DBG_INT1_SOURCE_CSR] = { MT_DBG_WFDMA_EXT_CSR_BASE, 0x88 },
687+ [DBG_INT1_MASK_CSR] = { MT_DBG_WFDMA_EXT_CSR_BASE, 0x8c },
688+ [DBG_TX_RING_BASE] = { MT_DBG_WFDMA1_BASE, 0x400 },
689+ [DBG_RX_EVENT_RING_BASE] = { MT_DBG_WFDMA1_BASE, 0x500 },
690+ [DBG_RX_STS_RING_BASE] = { MT_DBG_WFDMA1_BASE, 0x510 },
691+ [DBG_RX_DATA_RING_BASE] = { MT_DBG_WFDMA0_BASE, 0x500 },
692+ [DBG_DMA_ICSC_FR0] = { DBG_INVALID_BASE, 0x0f0 },
693+ [DBG_DMA_ICSC_FR1] = { DBG_INVALID_BASE, 0x0f4 },
694+ [DBG_TMAC_ICSCR0] = { DBG_INVALID_BASE, 0x200 },
695+ [DBG_RMAC_RXICSRPT] = { DBG_INVALID_BASE, 0x618},
696+ [DBG_MIB_M0SDR0] = { DBG_INVALID_BASE, 0x010},
697+ [DBG_MIB_M0SDR3] = { DBG_INVALID_BASE, 0x014},
698+ [DBG_MIB_M0SDR4] = { DBG_INVALID_BASE, 0x018},
699+ [DBG_MIB_M0SDR5] = { DBG_INVALID_BASE, 0x01c},
700+ [DBG_MIB_M0SDR7] = { DBG_INVALID_BASE, 0x024},
701+ [DBG_MIB_M0SDR8] = { DBG_INVALID_BASE, 0x028},
702+ [DBG_MIB_M0SDR9] = { DBG_INVALID_BASE, 0x02C},
703+ [DBG_MIB_M0SDR10] = { DBG_INVALID_BASE, 0x030},
704+ [DBG_MIB_M0SDR11] = { DBG_INVALID_BASE, 0x034},
705+ [DBG_MIB_M0SDR12] = { DBG_INVALID_BASE, 0x038},
706+ [DBG_MIB_M0SDR14] = { DBG_INVALID_BASE, 0x040},
707+ [DBG_MIB_M0SDR15] = { DBG_INVALID_BASE, 0x044},
708+ [DBG_MIB_M0SDR16] = { DBG_INVALID_BASE, 0x048},
709+ [DBG_MIB_M0SDR17] = { DBG_INVALID_BASE, 0x04c},
710+ [DBG_MIB_M0SDR18] = { DBG_INVALID_BASE, 0x050},
711+ [DBG_MIB_M0SDR19] = { DBG_INVALID_BASE, 0x054},
712+ [DBG_MIB_M0SDR20] = { DBG_INVALID_BASE, 0x058},
713+ [DBG_MIB_M0SDR21] = { DBG_INVALID_BASE, 0x05c},
714+ [DBG_MIB_M0SDR22] = { DBG_INVALID_BASE, 0x060},
715+ [DBG_MIB_M0SDR23] = { DBG_INVALID_BASE, 0x064},
716+ [DBG_MIB_M0DR0] = { DBG_INVALID_BASE, 0x0a0},
717+ [DBG_MIB_M0DR1] = { DBG_INVALID_BASE, 0x0a4},
718+ [DBG_MIB_MUBF] = { DBG_INVALID_BASE, 0x090},
719+ [DBG_MIB_M0DR6] = { DBG_INVALID_BASE, 0x0b8},
720+ [DBG_MIB_M0DR7] = { DBG_INVALID_BASE, 0x0bc},
721+ [DBG_MIB_M0DR8] = { DBG_INVALID_BASE, 0x0c0},
722+ [DBG_MIB_M0DR9] = { DBG_INVALID_BASE, 0x0c4},
723+ [DBG_MIB_M0DR10] = { DBG_INVALID_BASE, 0x0c8},
724+ [DBG_MIB_M0DR11] = { DBG_INVALID_BASE, 0x0cc},
725+ [DBG_MIB_M0DR12] = { DBG_INVALID_BASE, 0x160},
726+ [DBG_WTBLON_WDUCR] = { DBG_INVALID_BASE, 0x0},
727+ [DBG_UWTBL_WDUCR] = { DBG_INVALID_BASE, 0x0},
728+ [DBG_PLE_DRR_TABLE_CTRL] = { DBG_INVALID_BASE, 0x388},
729+ [DBG_PLE_DRR_TABLE_RDATA] = { DBG_INVALID_BASE, 0x350},
730+ [DBG_PLE_PBUF_CTRL] = { DBG_INVALID_BASE, 0x014},
731+ [DBG_PLE_QUEUE_EMPTY] = { DBG_INVALID_BASE, 0x0b0},
732+ [DBG_PLE_FREEPG_CNT] = { DBG_INVALID_BASE, 0x100},
733+ [DBG_PLE_FREEPG_HEAD_TAIL] = { DBG_INVALID_BASE, 0x104},
734+ [DBG_PLE_PG_HIF_GROUP] = { DBG_INVALID_BASE, 0x110},
735+ [DBG_PLE_HIF_PG_INFO] = { DBG_INVALID_BASE, 0x114},
736+ [DBG_PLE_PG_HIF_TXCMD_GROUP] = { DBG_INVALID_BASE, 0x120},
737+ [DBG_PLE_HIF_TXCMD_PG_INFO] = { DBG_INVALID_BASE, 0x124},
738+ [DBG_PLE_PG_CPU_GROUP] = { DBG_INVALID_BASE, 0x150},
739+ [DBG_PLE_CPU_PG_INFO] = { DBG_INVALID_BASE, 0x154},
740+ [DBG_PLE_FL_QUE_CTRL] = { DBG_INVALID_BASE, 0x1b0},
741+ [DBG_PLE_NATIVE_TXCMD_Q_EMPTY] = { DBG_INVALID_BASE, 0x22c},
742+ [DBG_PLE_TXCMD_Q_EMPTY] = { DBG_INVALID_BASE, 0x230},
743+ [DBG_PLE_AC_QEMPTY] = { DBG_INVALID_BASE, 0x500},
744+ [DBG_PLE_AC_OFFSET] = { DBG_INVALID_BASE, 0x040},
745+ [DBG_PLE_STATION_PAUSE] = { DBG_INVALID_BASE, 0x400},
746+ [DBG_PLE_DIS_STA_MAP] = { DBG_INVALID_BASE, 0x440},
developerd68e00e2022-06-01 10:59:24 +0800747+ [DBG_PSE_PBUF_CTRL] = { DBG_INVALID_BASE, 0x014},
developer73e5a572022-04-19 10:21:20 +0800748+ [DBG_PSE_FREEPG_CNT] = { DBG_INVALID_BASE, 0x100},
749+ [DBG_PSE_FREEPG_HEAD_TAIL] = { DBG_INVALID_BASE, 0x104},
750+ [DBG_PSE_HIF0_PG_INFO] = { DBG_INVALID_BASE, 0x114},
751+ [DBG_PSE_PG_HIF1_GROUP] = { DBG_INVALID_BASE, 0x118},
752+ [DBG_PSE_HIF1_PG_INFO] = { DBG_INVALID_BASE, 0x11c},
753+ [DBG_PSE_PG_CPU_GROUP] = { DBG_INVALID_BASE, 0x150},
754+ [DBG_PSE_CPU_PG_INFO] = { DBG_INVALID_BASE, 0x154},
755+ [DBG_PSE_PG_PLE_GROUP] = { DBG_INVALID_BASE, 0x160},
756+ [DBG_PSE_PLE_PG_INFO] = { DBG_INVALID_BASE, 0x164},
757+ [DBG_PSE_PG_LMAC0_GROUP] = { DBG_INVALID_BASE, 0x170},
758+ [DBG_PSE_LMAC0_PG_INFO] = { DBG_INVALID_BASE, 0x174},
759+ [DBG_PSE_PG_LMAC1_GROUP] = { DBG_INVALID_BASE, 0x178},
760+ [DBG_PSE_LMAC1_PG_INFO] = { DBG_INVALID_BASE, 0x17c},
761+ [DBG_PSE_PG_LMAC2_GROUP] = { DBG_INVALID_BASE, 0x180},
762+ [DBG_PSE_LMAC2_PG_INFO] = { DBG_INVALID_BASE, 0x184},
763+ [DBG_PSE_PG_LMAC3_GROUP] = { DBG_INVALID_BASE, 0x188},
764+ [DBG_PSE_LMAC3_PG_INFO] = { DBG_INVALID_BASE, 0x18c},
765+ [DBG_PSE_PG_MDP_GROUP] = { DBG_INVALID_BASE, 0x198},
766+ [DBG_PSE_MDP_PG_INFO] = { DBG_INVALID_BASE, 0x19c},
767+ [DBG_PSE_PG_PLE1_GROUP] = { DBG_INVALID_BASE, 0x168},
768+ [DBG_PSE_PLE1_PG_INFO] = { DBG_INVALID_BASE, 0x16c},
769+ [DBG_AGG_AALCR0] = { DBG_INVALID_BASE, 0x048},
770+ [DBG_AGG_AALCR1] = { DBG_INVALID_BASE, 0x04c},
771+ [DBG_AGG_AALCR2] = { DBG_INVALID_BASE, 0x050},
772+ [DBG_AGG_AALCR3] = { DBG_INVALID_BASE, 0x054},
773+ [DBG_AGG_AALCR4] = { DBG_INVALID_BASE, 0x058},
774+ [DBG_AGG_B0BRR0] = { DBG_INVALID_BASE, 0x100},
775+ [DBG_AGG_B1BRR0] = { DBG_INVALID_BASE, 0x104},
776+ [DBG_AGG_B2BRR0] = { DBG_INVALID_BASE, 0x108},
777+ [DBG_AGG_B3BRR0] = { DBG_INVALID_BASE, 0x10c},
778+ [DBG_AGG_AWSCR0] = { DBG_INVALID_BASE, 0x030},
779+ [DBG_AGG_PCR0] = { DBG_INVALID_BASE, 0x040},
780+ [DBG_AGG_TTCR0] = { DBG_INVALID_BASE, 0x04c},
781+ [DBG_MIB_M0ARNG0] = { DBG_INVALID_BASE, 0x4b8},
782+ [DBG_MIB_M0DR2] = { DBG_INVALID_BASE, 0x0a8},
783+ [DBG_MIB_M0DR13] = { DBG_INVALID_BASE, 0x164},
784+};
785+
786+/* mt7986/mt7916 regs with different base and offset */
787+static const struct __dbg_reg mt7916_dbg_reg[] = {
developer23c22342023-01-09 13:57:39 +0800788+ [DBG_WFDMA_WED_TX_CTRL] = { MT_DBG_WFDMA_EXT_CSR_BASE, 0x300 },
789+ [DBG_WFDMA_WED_RX_CTRL] = { MT_DBG_WFDMA_EXT_CSR_BASE, 0x400 },
developer73e5a572022-04-19 10:21:20 +0800790+ [DBG_INT_SOURCE_CSR] = { MT_DBG_WFDMA0_BASE, 0x200 },
791+ [DBG_INT_MASK_CSR] = { MT_DBG_WFDMA0_BASE, 0x204 },
792+ [DBG_INT1_SOURCE_CSR] = { MT_DBG_WFDMA0_PCIE1_BASE, 0x200 },
793+ [DBG_INT1_MASK_CSR] = { MT_DBG_WFDMA0_PCIE1_BASE, 0x204 },
794+ [DBG_TX_RING_BASE] = { MT_DBG_WFDMA0_BASE, 0x400 },
795+ [DBG_RX_EVENT_RING_BASE] = { MT_DBG_WFDMA0_BASE, 0x500 },
796+ [DBG_RX_STS_RING_BASE] = { MT_DBG_WFDMA0_BASE, 0x520 },
797+ [DBG_RX_DATA_RING_BASE] = { MT_DBG_WFDMA0_BASE, 0x540 },
798+ [DBG_DMA_ICSC_FR0] = { DBG_INVALID_BASE, 0x05c },
799+ [DBG_DMA_ICSC_FR1] = { DBG_INVALID_BASE, 0x060 },
800+ [DBG_TMAC_ICSCR0] = { DBG_INVALID_BASE, 0x120 },
801+ [DBG_RMAC_RXICSRPT] = { DBG_INVALID_BASE, 0xd0 },
802+ [DBG_MIB_M0SDR0] = { DBG_INVALID_BASE, 0x7d8},
803+ [DBG_MIB_M0SDR3] = { DBG_INVALID_BASE, 0x698},
804+ [DBG_MIB_M0SDR4] = { DBG_INVALID_BASE, 0x788},
805+ [DBG_MIB_M0SDR5] = { DBG_INVALID_BASE, 0x780},
806+ [DBG_MIB_M0SDR7] = { DBG_INVALID_BASE, 0x5a8},
807+ [DBG_MIB_M0SDR8] = { DBG_INVALID_BASE, 0x78c},
808+ [DBG_MIB_M0SDR9] = { DBG_INVALID_BASE, 0x024},
809+ [DBG_MIB_M0SDR10] = { DBG_INVALID_BASE, 0x76c},
810+ [DBG_MIB_M0SDR11] = { DBG_INVALID_BASE, 0x790},
811+ [DBG_MIB_M0SDR12] = { DBG_INVALID_BASE, 0x558},
812+ [DBG_MIB_M0SDR14] = { DBG_INVALID_BASE, 0x564},
813+ [DBG_MIB_M0SDR15] = { DBG_INVALID_BASE, 0x564},
814+ [DBG_MIB_M0SDR16] = { DBG_INVALID_BASE, 0x7fc},
815+ [DBG_MIB_M0SDR17] = { DBG_INVALID_BASE, 0x800},
816+ [DBG_MIB_M0SDR18] = { DBG_INVALID_BASE, 0x030},
817+ [DBG_MIB_M0SDR19] = { DBG_INVALID_BASE, 0x5ac},
818+ [DBG_MIB_M0SDR20] = { DBG_INVALID_BASE, 0x5b0},
819+ [DBG_MIB_M0SDR21] = { DBG_INVALID_BASE, 0x5b4},
820+ [DBG_MIB_M0SDR22] = { DBG_INVALID_BASE, 0x770},
821+ [DBG_MIB_M0SDR23] = { DBG_INVALID_BASE, 0x774},
822+ [DBG_MIB_M0DR0] = { DBG_INVALID_BASE, 0x594},
823+ [DBG_MIB_M0DR1] = { DBG_INVALID_BASE, 0x598},
824+ [DBG_MIB_MUBF] = { DBG_INVALID_BASE, 0x7ac},
825+ [DBG_MIB_M0DR6] = { DBG_INVALID_BASE, 0x658},
826+ [DBG_MIB_M0DR7] = { DBG_INVALID_BASE, 0x65c},
827+ [DBG_MIB_M0DR8] = { DBG_INVALID_BASE, 0x56c},
828+ [DBG_MIB_M0DR9] = { DBG_INVALID_BASE, 0x570},
829+ [DBG_MIB_M0DR10] = { DBG_INVALID_BASE, 0x578},
830+ [DBG_MIB_M0DR11] = { DBG_INVALID_BASE, 0x574},
831+ [DBG_MIB_M0DR12] = { DBG_INVALID_BASE, 0x654},
832+ [DBG_WTBLON_WDUCR] = { DBG_INVALID_BASE, 0x200},
833+ [DBG_UWTBL_WDUCR] = { DBG_INVALID_BASE, 0x094},
834+ [DBG_PLE_DRR_TABLE_CTRL] = { DBG_INVALID_BASE, 0x490},
835+ [DBG_PLE_DRR_TABLE_RDATA] = { DBG_INVALID_BASE, 0x470},
836+ [DBG_PLE_PBUF_CTRL] = { DBG_INVALID_BASE, 0x004},
837+ [DBG_PLE_QUEUE_EMPTY] = { DBG_INVALID_BASE, 0x360},
838+ [DBG_PLE_FREEPG_CNT] = { DBG_INVALID_BASE, 0x380},
839+ [DBG_PLE_FREEPG_HEAD_TAIL] = { DBG_INVALID_BASE, 0x384},
840+ [DBG_PLE_PG_HIF_GROUP] = { DBG_INVALID_BASE, 0x00c},
841+ [DBG_PLE_HIF_PG_INFO] = { DBG_INVALID_BASE, 0x388},
842+ [DBG_PLE_PG_HIF_TXCMD_GROUP] = { DBG_INVALID_BASE, 0x014},
843+ [DBG_PLE_HIF_TXCMD_PG_INFO] = { DBG_INVALID_BASE, 0x390},
844+ [DBG_PLE_PG_CPU_GROUP] = { DBG_INVALID_BASE, 0x018},
845+ [DBG_PLE_CPU_PG_INFO] = { DBG_INVALID_BASE, 0x394},
846+ [DBG_PLE_FL_QUE_CTRL] = { DBG_INVALID_BASE, 0x3e0},
847+ [DBG_PLE_NATIVE_TXCMD_Q_EMPTY] = { DBG_INVALID_BASE, 0x370},
developerd68e00e2022-06-01 10:59:24 +0800848+ [DBG_PLE_TXCMD_Q_EMPTY] = { DBG_INVALID_BASE, 0x36c},
developer73e5a572022-04-19 10:21:20 +0800849+ [DBG_PLE_AC_QEMPTY] = { DBG_INVALID_BASE, 0x600},
850+ [DBG_PLE_AC_OFFSET] = { DBG_INVALID_BASE, 0x080},
851+ [DBG_PLE_STATION_PAUSE] = { DBG_INVALID_BASE, 0x100},
852+ [DBG_PLE_DIS_STA_MAP] = { DBG_INVALID_BASE, 0x180},
853+ [DBG_PSE_PBUF_CTRL] = { DBG_INVALID_BASE, 0x004},
854+ [DBG_PSE_FREEPG_CNT] = { DBG_INVALID_BASE, 0x380},
855+ [DBG_PSE_FREEPG_HEAD_TAIL] = { DBG_INVALID_BASE, 0x384},
856+ [DBG_PSE_HIF0_PG_INFO] = { DBG_INVALID_BASE, 0x150},
857+ [DBG_PSE_PG_HIF1_GROUP] = { DBG_INVALID_BASE, 0x154},
858+ [DBG_PSE_HIF1_PG_INFO] = { DBG_INVALID_BASE, 0x160},
859+ [DBG_PSE_PG_CPU_GROUP] = { DBG_INVALID_BASE, 0x118},
860+ [DBG_PSE_CPU_PG_INFO] = { DBG_INVALID_BASE, 0x158},
861+ [DBG_PSE_PG_PLE_GROUP] = { DBG_INVALID_BASE, 0x11c},
862+ [DBG_PSE_PLE_PG_INFO] = { DBG_INVALID_BASE, 0x15c},
863+ [DBG_PSE_PG_LMAC0_GROUP] = { DBG_INVALID_BASE, 0x124},
864+ [DBG_PSE_LMAC0_PG_INFO] = { DBG_INVALID_BASE, 0x164},
865+ [DBG_PSE_PG_LMAC1_GROUP] = { DBG_INVALID_BASE, 0x128},
866+ [DBG_PSE_LMAC1_PG_INFO] = { DBG_INVALID_BASE, 0x168},
867+ [DBG_PSE_PG_LMAC2_GROUP] = { DBG_INVALID_BASE, 0x12c},
868+ [DBG_PSE_LMAC2_PG_INFO] = { DBG_INVALID_BASE, 0x16c},
869+ [DBG_PSE_PG_LMAC3_GROUP] = { DBG_INVALID_BASE, 0x130},
870+ [DBG_PSE_LMAC3_PG_INFO] = { DBG_INVALID_BASE, 0x17c},
871+ [DBG_PSE_PG_MDP_GROUP] = { DBG_INVALID_BASE, 0x134},
872+ [DBG_PSE_MDP_PG_INFO] = { DBG_INVALID_BASE, 0x174},
873+ [DBG_PSE_PG_PLE1_GROUP] = { DBG_INVALID_BASE, 0x120},
874+ [DBG_PSE_PLE1_PG_INFO] = { DBG_INVALID_BASE, 0x160},
875+ [DBG_AGG_AALCR0] = { DBG_INVALID_BASE, 0x028},
876+ [DBG_AGG_AALCR1] = { DBG_INVALID_BASE, 0x144},
877+ [DBG_AGG_AALCR2] = { DBG_INVALID_BASE, 0x14c},
878+ [DBG_AGG_AALCR3] = { DBG_INVALID_BASE, 0x154},
879+ [DBG_AGG_AALCR4] = { DBG_INVALID_BASE, 0x02c},
880+ [DBG_AGG_B0BRR0] = { DBG_INVALID_BASE, 0x08c},
881+ [DBG_AGG_B1BRR0] = { DBG_INVALID_BASE, 0x148},
882+ [DBG_AGG_B2BRR0] = { DBG_INVALID_BASE, 0x150},
883+ [DBG_AGG_B3BRR0] = { DBG_INVALID_BASE, 0x158},
884+ [DBG_AGG_AWSCR0] = { DBG_INVALID_BASE, 0x05c},
885+ [DBG_AGG_PCR0] = { DBG_INVALID_BASE, 0x06c},
886+ [DBG_AGG_TTCR0] = { DBG_INVALID_BASE, 0x07c},
887+ [DBG_MIB_M0ARNG0] = { DBG_INVALID_BASE, 0x0b0},
888+ [DBG_MIB_M0DR2] = { DBG_INVALID_BASE, 0x7dc},
889+ [DBG_MIB_M0DR13] = { DBG_INVALID_BASE, 0x7ec},
890+};
891+
892+static const struct __dbg_mask mt7915_dbg_mask[] = {
893+ [DBG_MIB_M0SDR10_RX_MDRDY_COUNT]= {25, 0},
894+ [DBG_MIB_M0SDR14_AMPDU] = {23, 0},
895+ [DBG_MIB_M0SDR15_AMPDU_ACKED] = {23, 0},
896+ [DBG_MIB_RX_FCS_ERROR_COUNT] = {15, 0},
897+};
898+
899+static const struct __dbg_mask mt7916_dbg_mask[] = {
900+ [DBG_MIB_M0SDR10_RX_MDRDY_COUNT]= {31, 0},
901+ [DBG_MIB_M0SDR14_AMPDU] = {31, 0},
902+ [DBG_MIB_M0SDR15_AMPDU_ACKED] = {31, 0},
903+ [DBG_MIB_RX_FCS_ERROR_COUNT] = {31, 16},
904+};
905+
906+/* used to differentiate between generations */
907+struct mt7915_dbg_reg_desc {
908+ const u32 id;
909+ const u32 *base_rev;
910+ const struct __dbg_reg *reg_rev;
911+ const struct __dbg_mask *mask_rev;
912+};
913+
914+static const struct mt7915_dbg_reg_desc dbg_reg_s[] = {
915+ { 0x7915,
916+ mt7915_dbg_base,
917+ mt7915_dbg_reg,
918+ mt7915_dbg_mask
919+ },
920+ { 0x7906,
921+ mt7916_dbg_base,
922+ mt7916_dbg_reg,
923+ mt7916_dbg_mask
924+ },
developer70180b02023-11-14 17:01:47 +0800925+ { 0x7981,
926+ mt7981_dbg_base,
927+ mt7916_dbg_reg,
928+ mt7916_dbg_mask
929+ },
developer73e5a572022-04-19 10:21:20 +0800930+ { 0x7986,
931+ mt7986_dbg_base,
932+ mt7916_dbg_reg,
933+ mt7916_dbg_mask
934+ },
935+};
936+
937+struct bin_debug_hdr {
938+ __le32 magic_num;
939+ __le16 serial_id;
940+ __le16 msg_type;
941+ __le16 len;
942+ __le16 des_len; /* descriptor len for rxd */
943+} __packed;
944+
developer8effbd32023-04-17 15:57:28 +0800945+/* fw wm info related strcture */
946+struct cos_msg_trace_t {
947+ u32 dest_id;
948+ u8 msg_id;
949+ u32 pcount;
950+ u32 qread;
951+ u32 ts_enq;
952+ u32 ts_deq;
953+ u32 ts_finshq;
954+};
955+
956+struct cos_task_info_struct {
957+ u32 task_name_ptr;
958+ u32 task_qname_ptr;
959+ u32 task_priority;
960+ u16 task_stack_size;
961+ u8 task_ext_qsize;
962+ u32 task_id;
963+ u32 task_ext_qid;
964+ u32 task_main_func;
965+ u32 task_init_func;
966+};
967+
968+struct cos_program_trace_t{
developer1a173672023-12-21 14:49:33 +0800969+ u32 _dest_id;
970+ u32 _msg_id;
971+ u32 _msg_sn;
972+ u32 _ts_gpt2;
973+ u32 _LP;
974+ char _name[12];
developer8effbd32023-04-17 15:57:28 +0800975+} ;
976+
developer1a173672023-12-21 14:49:33 +0800977+struct mt7915_cos_program_trace_t{
978+ u32 _dest_id;
979+ u32 _msg_id;
980+ u32 _msg_sn;
981+ u32 _ts_gpt2;
982+ u32 _ts_gpt4;
983+ u32 _LP;
984+ char _name[12];
985+} ;
986+
developer8effbd32023-04-17 15:57:28 +0800987+struct cos_msg_type {
988+ u32 finish_cnt;
989+ u32 exe_time;
990+ u32 exe_peak;
991+};
992+
993+struct cos_task_type{
994+ u32 tc_stack_start;
995+ u32 tc_stack_end;
996+ u32 tc_stack_pointer;
997+ u32 tc_stack_size;
998+ u32 tc_schedule_count;
999+ u8 tc_status;
1000+ u8 tc_priority;
1001+ u8 tc_weight;
1002+ u8 RSVD[28];
1003+ u32 tc_entry_func;
1004+ u32 tc_exe_start;
1005+ u32 tc_exe_time;
1006+ u32 tc_exe_peak;
1007+ u32 tc_pcount;
1008+};
1009+
developer73e5a572022-04-19 10:21:20 +08001010+#define __DBG_REG_MAP(_dev, id, ofs) ((_dev)->dbg_reg->base_rev[(id)] + (ofs))
1011+#define __DBG_REG_BASE(_dev, id) ((_dev)->dbg_reg->reg_rev[(id)].base)
1012+#define __DBG_REG_OFFS(_dev, id) ((_dev)->dbg_reg->reg_rev[(id)].offs)
1013+
1014+#define __DBG_MASK(_dev, id) GENMASK((_dev)->dbg_reg->mask_rev[(id)].end, \
1015+ (_dev)->dbg_reg->mask_rev[(id)].start)
1016+#define __DBG_REG(_dev, id) __DBG_REG_MAP((_dev), __DBG_REG_BASE((_dev), (id)), \
1017+ __DBG_REG_OFFS((_dev), (id)))
1018+
1019+#define __DBG_FIELD_GET(id, _reg) (((_reg) & __DBG_MASK(dev, (id))) >> \
1020+ dev->dbg_reg->mask_rev[(id)].start)
1021+#define __DBG_FIELD_PREP(id, _reg) (((_reg) << dev->dbg_reg->mask_rev[(id)].start) & \
1022+ __DBG_MASK(dev, (id)))
1023+
1024+
1025+#define MT_DBG_TX_RING_BASE __DBG_REG(dev, DBG_TX_RING_BASE)
1026+#define MT_DBG_RX_EVENT_RING_BASE __DBG_REG(dev, DBG_RX_EVENT_RING_BASE)
1027+#define MT_DBG_RX_STS_RING_BASE __DBG_REG(dev, DBG_RX_STS_RING_BASE)
1028+#define MT_DBG_RX_DATA_RING_BASE __DBG_REG(dev, DBG_RX_DATA_RING_BASE)
developer23c22342023-01-09 13:57:39 +08001029+#define MT_DBG_WFDMA_WED_TX_CTRL_BASE __DBG_REG(dev, DBG_WFDMA_WED_TX_CTRL)
1030+#define MT_DBG_WFDMA_WED_RX_CTRL_BASE __DBG_REG(dev, DBG_WFDMA_WED_RX_CTRL)
developer73e5a572022-04-19 10:21:20 +08001031+
1032+#define MT_DBG_TX_RING_CTRL(n) (MT_DBG_TX_RING_BASE + (0x10 * (n)))
1033+#define MT_DBG_RX_DATA_RING_CTRL(n) (MT_DBG_RX_DATA_RING_BASE + (0x10 * (n)))
1034+#define MT_DBG_RX_EVENT_RING_CTRL(n) (MT_DBG_RX_EVENT_RING_BASE + (0x10 * (n)))
1035+
developer23c22342023-01-09 13:57:39 +08001036+#define MT_DBG_WFDMA_WED_TX_CTRL(n) (MT_DBG_WFDMA_WED_TX_CTRL_BASE + (0x10 * (n)))
1037+#define MT_DBG_WFDMA_WED_RX_CTRL(n) (MT_DBG_WFDMA_WED_RX_CTRL_BASE + (0x10 * (n)))
developer73e5a572022-04-19 10:21:20 +08001038+/* WFDMA COMMON */
1039+#define MT_DBG_INT_SOURCE_CSR __DBG_REG(dev, DBG_INT_SOURCE_CSR)
1040+#define MT_DBG_INT_MASK_CSR __DBG_REG(dev, DBG_INT_MASK_CSR)
1041+#define MT_DBG_INT1_SOURCE_CSR __DBG_REG(dev, DBG_INT1_SOURCE_CSR)
1042+#define MT_DBG_INT1_MASK_CSR __DBG_REG(dev, DBG_INT1_MASK_CSR)
1043+
1044+/* WFDMA0 */
1045+#define MT_DBG_WFDMA0(_ofs) __DBG_REG_MAP(dev, MT_DBG_WFDMA0_BASE, (_ofs))
1046+
1047+#define MT_DBG_WFDMA0_INT_SOURCE_CSR MT_DBG_WFDMA0(0x200)
1048+#define MT_DBG_WFDMA0_INT_MASK_CSR MT_DBG_WFDMA0(0x204)
1049+
1050+#define MT_DBG_WFDMA0_GLO_CFG MT_DBG_WFDMA0(0x208)
1051+#define MT_DBG_WFDMA0_GLO_CFG_TX_DMA_EN BIT(0)
1052+#define MT_DBG_WFDMA0_GLO_CFG_RX_DMA_EN BIT(2)
1053+#define MT_DBG_WFDMA0_GLO_CFG_TX_BUSY_MASK BIT(1)
1054+#define MT_DBG_WFDMA0_GLO_CFG_RX_BUSY_MASK BIT(3)
1055+
1056+
1057+/* WFDMA1 */
1058+#define MT_DBG_WFDMA1(_ofs) __DBG_REG_MAP(dev, MT_DBG_WFDMA1_BASE, (_ofs))
1059+#define MT_DBG_WFDMA1_INT_SOURCE_CSR MT_DBG_WFDMA1(0x200)
1060+#define MT_DBG_WFDMA1_INT_MASK_CSR MT_DBG_WFDMA1(0x204)
1061+
1062+#define MT_DBG_WFDMA1_GLO_CFG MT_DBG_WFDMA1(0x208)
1063+
1064+#define MT_DBG_WFDMA1_GLO_CFG_TX_DMA_EN BIT(0)
1065+#define MT_DBG_WFDMA1_GLO_CFG_RX_DMA_EN BIT(2)
1066+#define MT_DBG_WFDMA1_GLO_CFG_TX_BUSY_MASK BIT(1)
1067+#define MT_DBG_WFDMA1_GLO_CFG_RX_BUSY_MASK BIT(3)
1068+
1069+/* WFDMA0 PCIE1 */
1070+#define MT_DBG_WFDMA0_PCIE1(_ofs) __DBG_REG_MAP(dev, MT_DBG_WFDMA0_PCIE1_BASE, (_ofs))
1071+
1072+#define MT_DBG_WFDMA0_PCIE1_INT_SOURCE_CSR MT_DBG_WFDMA0_PCIE1(0x200)
1073+#define MT_DBG_WFDMA0_PCIE1_INT_MASK_CSR MT_DBG_WFDMA0_PCIE1(0x204)
1074+#define MT_DBG_WFDMA0_PCIE1_GLO_CFG MT_DBG_WFDMA0_PCIE1(0x208)
1075+#define MT_DBG_WFDMA0_PCIE1_RX1_CTRL0 MT_DBG_WFDMA1_PCIE1(0x510)
1076+
1077+#define MT_DBG_WFDMA0_PCIE1_GLO_CFG_TX_DMA_EN BIT(0)
1078+#define MT_DBG_WFDMA0_PCIE1_GLO_CFG_TX_BUSY_MASK BIT(1)
1079+#define MT_DBG_WFDMA0_PCIE1_GLO_CFG_RX_DMA_EN BIT(2)
1080+#define MT_DBG_WFDMA0_PCIE1_GLO_CFG_RX_BUSY_MASK BIT(3)
1081+
1082+/* WFDMA1 PCIE1 */
1083+#define MT_DBG_WFDMA1_PCIE1(_ofs) __DBG_REG_MAP(dev, MT_DBG_WFDMA1_PCIE1_BASE, (_ofs))
1084+#define MT_DBG_WFDMA1_PCIE1_INT_SOURCE_CSR MT_DBG_WFDMA1_PCIE1(0x200)
1085+#define MT_DBG_WFDMA1_PCIE1_INT_MASK_CSR MT_DBG_WFDMA1_PCIE1(0x204)
1086+#define MT_DBG_WFDMA1_PCIE1_GLO_CFG MT_DBG_WFDMA1_PCIE1(0x208)
1087+#define MT_DBG_WFDMA1_PCIE1_TX19_CTRL0 MT_DBG_WFDMA1_PCIE1(0x330)
1088+#define MT_DBG_WFDMA1_PCIE1_RX2_CTRL0 MT_DBG_WFDMA1_PCIE1(0x520)
1089+
1090+#define MT_DBG_WFDMA1_PCIE1_GLO_CFG_TX_DMA_EN BIT(0)
1091+#define MT_DBG_WFDMA1_PCIE1_GLO_CFG_TX_BUSY_MASK BIT(1)
1092+#define MT_DBG_WFDMA1_PCIE1_GLO_CFG_RX_DMA_EN BIT(2)
1093+#define MT_DBG_WFDMA1_PCIE1_GLO_CFG_RX_BUSY_MASK BIT(3)
1094+
1095+#define MT_DBG_WFDMA_HOST_DMA0_GLO_CFG_RX_DMA_EN_MASK BIT(2)
1096+#define MT_DBG_WFDMA_HOST_DMA0_GLO_CFG_TX_DMA_EN_MASK BIT(0)
1097+#define MT_DBG_WFDMA_HOST_DMA0_GLO_CFG_RX_DMA_BUSY_MASK BIT(3)
1098+#define MT_DBG_WFDMA_HOST_DMA0_GLO_CFG_TX_DMA_BUSY_MASK BIT(1)
1099+
1100+
1101+/* WF DMA TOP: band 0(0x820E7000),band 1(0x820F7000) */
1102+#define MT_DBG_WF_DMA_BASE(_band) ((_band) ? 0x820F7000 : 0x820E7000)
1103+#define MT_DBG_WF_DMA(_band, ofs) (MT_WF_DMA_BASE(_band) + (ofs))
1104+
1105+#define MT_DBG_DMA_DCR0(_band) MT_DBG_WF_DMA((_band), 0x000)
1106+#define MT_DBG_DMA_DCR0_MAX_RX_LEN GENMASK(15, 3)
1107+#define MT_DBG_DMA_DCR0_RXD_G5_EN BIT(23)
1108+
1109+#define MT_DBG_DMA_ICSC_FR0(_band) MT_DBG_WF_DMA((_band), __DBG_REG_OFFS(dev, DBG_DMA_ICSC_FR0))
1110+#define MT_DBG_DMA_ICSC_FR0_RXBF_EN BIT(25)
1111+#define MT_DBG_DMA_ICSC_FR0_EN BIT(24)
1112+#define MT_DBG_DMA_ICSC_FR0_TOUT_MASK GENMASK(23, 16)
1113+#define MT_DBG_DMA_ICSC_FR0_PID_MASK GENMASK(9, 8)
1114+#define MT_DBG_DMA_ICSC_FR0_QID_MASK GENMASK(6, 0)
1115+
1116+#define MT_DBG_DMA_ICSC_FR1(_band) MT_DBG_WF_DMA((_band), __DBG_REG_OFFS(dev, DBG_DMA_ICSC_FR1))
1117+#define MT_DBG_DMA_ICSC_FR1_AGG_SIZE_MASK GENMASK(26, 16)
1118+#define MT_DBG_DMA_ICSC_FR1_MAX_FRAME_SIZE_MASK GENMASK(10, 0)
1119+
1120+/* TMAC: band 0(0x820e4000), band 1(0x820f4000) */
1121+#define MT_DBG_WF_TMAC_BASE(_band) ((_band) ? 0x820f4000 : 0x820e4000)
1122+#define MT_DBG_WF_TMAC(_band, ofs) (MT_DBG_WF_TMAC_BASE(_band) + (ofs))
1123+
1124+#define MT_DBG_TMAC_ICSCR0(_band) MT_DBG_WF_TMAC((_band), __DBG_REG_OFFS(dev, DBG_TMAC_ICSCR0))
1125+#define MT_DBG_TMAC_ICSCR0_ICSRPT_EN BIT(0)
1126+
1127+/* RMAC: band 0(0x820E5000), band 1(0x820f5000) */
1128+#define MT_DBG_WF_RMAC_BASE(_band) ((_band) ? 0x820f5000 : 0x820E5000)
1129+#define MT_DBG_WF_RMAC(_band, ofs) (MT_DBG_WF_RMAC_BASE(_band) + (ofs))
1130+
1131+#define MT_DBG_RMAC_RXICSRPT(_band) MT_DBG_WF_RMAC((_band), __DBG_REG_OFFS(dev, DBG_RMAC_RXICSRPT))
1132+#define MT_DBG_RMAC_RXICSRPT_ICSRPT_EN BIT(0)
1133+
1134+/* MIB: band 0(0x820ed000), band 1(0x820fd000) */
1135+#define MT_DBG_MIB_BASE(_band) ((_band) ? 0x820fd000 : 0x820ed000)
1136+#define MT_DBG_MIB(_band, ofs) (MT_DBG_MIB_BASE(_band) + (ofs))
1137+
1138+
1139+#define MT_DBG_MIB_M0SCR0(_band) MT_DBG_MIB((_band), 0x00)
1140+#define MT_DBG_MIB_M0PBSCR(_band) MT_DBG_MIB((_band), 0x04)
1141+
1142+#define MT_DBG_MIB_M0SDR0(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR0))
1143+#define MT_DBG_MIB_M0SDR3(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR3))
1144+#define MT_DBG_MIB_RX_FCS_ERROR_COUNT_MASK __DBG_MASK(dev, DBG_MIB_RX_FCS_ERROR_COUNT)
1145+#define MT_DBG_MIB_M0SDR4(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR4))
1146+#define MT_DBG_MIB_M0SDR5(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR5))
1147+#define MT_DBG_MIB_M0SDR6(_band) MT_DBG_MIB((_band), 0x20)
1148+#define MT_DBG_MIB_M0SDR7(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR7))
1149+#define MT_DBG_MIB_M0SDR8(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR8))
1150+#define MT_DBG_MIB_M0SDR9(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR9))
1151+#define MT_DBG_MIB_M0SDR10(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR10))
1152+#define MT_DBG_MIB_M0SDR10_RX_MDRDY_COUNT_MASK __DBG_MASK(dev, DBG_MIB_M0SDR10_RX_MDRDY_COUNT)
1153+#define MT_DBG_MIB_M0SDR11(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR11))
1154+
1155+#define MT_DBG_MIB_M0SDR12(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR12))
1156+
1157+#define MT_DBG_MIB_M0SDR14(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR14))
1158+#define MT_DBG_MIB_M0SDR14_AMPDU_MASK __DBG_MASK(dev, DBG_MIB_M0SDR14_AMPDU)
1159+#define MT_DBG_MIB_M0SDR15(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR15))
1160+#define MT_DBG_MIB_M0SDR15_AMPDU_ACKED_MASK __DBG_MASK(dev, DBG_MIB_M0SDR15_AMPDU_ACKED)
1161+#define MT_DBG_MIB_M0SDR16(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR16))
1162+#define MT_DBG_MIB_M0SDR17(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR17))
1163+#define MT_DBG_MIB_M0SDR18(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR18))
1164+#define MT_DBG_MIB_M0SDR19(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR19))
1165+#define MT_DBG_MIB_M0SDR20(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR20))
1166+#define MT_DBG_MIB_M0SDR21(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR21))
1167+#define MT_DBG_MIB_M0SDR22(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR22))
1168+#define MT_DBG_MIB_M0SDR23(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR23))
1169+#define MT_DBG_MIB_M0DR0(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0DR0))
1170+#define MT_DBG_MIB_M0DR1(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0DR1))
1171+
1172+#define MT_DBG_MIB_MUBF(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_MUBF))
1173+#define MT_DBG_MIB_M0DR6(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0DR6))
1174+#define MT_DBG_MIB_M0DR7(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0DR7))
1175+#define MT_DBG_MIB_M0DR8(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0DR8))
1176+#define MT_DBG_MIB_M0DR9(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0DR9))
1177+#define MT_DBG_MIB_M0DR10(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0DR10))
1178+#define MT_DBG_MIB_M0DR11(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0DR11))
1179+ #define MT_DBG_MIB_M0DR12(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0DR12))
1180+
1181+/* WTBLON TOP: 0x820D4000/pcie(0x34000) rbus(0x434000) */
1182+#define MT_DBG_WTBLON_TOP_BASE 0x820D4000
1183+#define MT_DBG_WTBLON_TOP(ofs) (MT_WTBLON_TOP_BASE + (ofs))
1184+#define MT_DBG_WTBLON_TOP_WDUCR MT_DBG_WTBLON_TOP(__DBG_REG_OFFS(dev, DBG_WTBLON_WDUCR))
1185+#define MT_DBG_WTBLON_TOP_WDUCR_GROUP GENMASK(2, 0)
1186+
1187+#define WF_WTBLON_TOP_B0BTCRn_ADDR (MT_DBG_WTBLON_TOP_BASE + 0x1000) // 5000
1188+#define WF_WTBLON_TOP_B0BTBCRn_ADDR (MT_DBG_WTBLON_TOP_BASE + 0x1010) // 5010
1189+#define WF_WTBLON_TOP_B0BRCRn_ADDR (MT_DBG_WTBLON_TOP_BASE + 0x1020) // 5020
1190+#define WF_WTBLON_TOP_B0BRBCRn_ADDR (MT_DBG_WTBLON_TOP_BASE + 0x1030) // 5030
1191+#define WF_WTBLON_TOP_B0BTDCRn_ADDR (MT_DBG_WTBLON_TOP_BASE + 0x1040) // 5040
1192+#define WF_WTBLON_TOP_B0BRDCRn_ADDR (MT_DBG_WTBLON_TOP_BASE + 0x1050) // 5050
1193+#define WF_WTBLON_TOP_B0MBTCRn_ADDR (MT_DBG_WTBLON_TOP_BASE + 0x1100) // 5100
1194+#define WF_WTBLON_TOP_B0MBTBCRn_ADDR (MT_DBG_WTBLON_TOP_BASE + 0x1140) // 5140
1195+#define WF_WTBLON_TOP_B0MBRCRn_ADDR (MT_DBG_WTBLON_TOP_BASE + 0x1180) // 5180
1196+#define WF_WTBLON_TOP_B0MBRBCRn_ADDR (MT_DBG_WTBLON_TOP_BASE + 0x11C0) // 51C0
1197+
1198+#define WF_WTBLON_TOP_B1BTCRn_ADDR (MT_DBG_WTBLON_TOP_BASE + 0x1800) // 5800
1199+
1200+/* WTBLON TOP: 0x820C4000/pcie(0xa8000) rbus(0x4a8000) */
1201+#define MT_DBG_UWTBL_TOP_BASE 0x820C4000
1202+#define MT_DBG_UWTBL_TOP(ofs) (MT_DBG_UWTBL_TOP_BASE + (ofs))
1203+
developerec567112022-10-11 11:02:55 +08001204+#define MT_DBG_UWTBL_TOP_WDUCR MT_DBG_UWTBL_TOP(__DBG_REG_OFFS(dev, DBG_UWTBL_WDUCR))
developer73e5a572022-04-19 10:21:20 +08001205+
1206+#define MT_UWTBL_TOP_WDUCR_TARGET BIT(31)
1207+#define MT_UWTBL_TOP_WDUCR_GROUP GENMASK(3, 0)
1208+
1209+
1210+/* WTBL : 0x820D8000/pcie(0x38000) rbus(0x438000) */
1211+#define MT_DBG_WTBL_BASE 0x820D8000
1212+
1213+/* PLE related CRs. */
1214+#define MT_DBG_PLE_BASE 0x820C0000
1215+#define MT_DBG_PLE(ofs) (MT_DBG_PLE_BASE + (ofs))
1216+
1217+#define MT_DBG_PLE_DRR_TAB_CTRL MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_DRR_TABLE_CTRL))
1218+#define MT_DBG_PLE_DRR_TAB_RD_OFS __DBG_REG_OFFS(dev, DBG_PLE_DRR_TABLE_RDATA)
1219+
1220+#define MT_DBG_PLE_DRR_TABLE_RDATA0 MT_DBG_PLE(MT_DBG_PLE_DRR_TAB_RD_OFS + 0x0)
1221+#define MT_DBG_PLE_DRR_TABLE_RDATA1 MT_DBG_PLE(MT_DBG_PLE_DRR_TAB_RD_OFS + 0x4)
1222+#define MT_DBG_PLE_DRR_TABLE_RDATA2 MT_DBG_PLE(MT_DBG_PLE_DRR_TAB_RD_OFS + 0x8)
1223+#define MT_DBG_PLE_DRR_TABLE_RDATA3 MT_DBG_PLE(MT_DBG_PLE_DRR_TAB_RD_OFS + 0xc)
1224+#define MT_DBG_PLE_DRR_TABLE_RDATA4 MT_DBG_PLE(MT_DBG_PLE_DRR_TAB_RD_OFS + 0x10)
1225+#define MT_DBG_PLE_DRR_TABLE_RDATA5 MT_DBG_PLE(MT_DBG_PLE_DRR_TAB_RD_OFS + 0x14)
1226+#define MT_DBG_PLE_DRR_TABLE_RDATA6 MT_DBG_PLE(MT_DBG_PLE_DRR_TAB_RD_OFS + 0x18)
1227+#define MT_DBG_PLE_DRR_TABLE_RDATA7 MT_DBG_PLE(MT_DBG_PLE_DRR_TAB_RD_OFS+ 0x1c)
1228+
1229+#define MT_DBG_PLE_PBUF_CTRL_ADDR MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_PBUF_CTRL))
1230+#define MT_DBG_PLE_QUEUE_EMPTY MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_QUEUE_EMPTY))
1231+#define MT_DBG_PLE_FREEPG_CNT MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_FREEPG_CNT))
1232+#define MT_DBG_PLE_FREEPG_HEAD_TAIL MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_FREEPG_HEAD_TAIL))
1233+#define MT_DBG_PLE_PG_HIF_GROUP MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_PG_HIF_GROUP))
1234+#define MT_DBG_PLE_HIF_PG_INFO MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_HIF_PG_INFO))
1235+#define MT_DBG_PLE_PG_HIF_TXCMD_GROUP MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_PG_HIF_TXCMD_GROUP))
1236+#define MT_DBG_PLE_HIF_TXCMD_PG_INFO MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_HIF_TXCMD_PG_INFO))
1237+#define MT_DBG_PLE_PG_CPU_GROUP MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_PG_CPU_GROUP))
1238+#define MT_DBG_PLE_CPU_PG_INFO MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_CPU_PG_INFO))
1239+#define PLE_FL_QUE_CTRL_OFFSET __DBG_REG_OFFS(dev, DBG_PLE_FL_QUE_CTRL)
1240+#define MT_DBG_PLE_FL_QUE_CTRL0 MT_DBG_PLE(PLE_FL_QUE_CTRL_OFFSET + 0x0)
1241+#define MT_DBG_PLE_FL_QUE_CTRL1 MT_DBG_PLE(PLE_FL_QUE_CTRL_OFFSET + 0x4)
1242+#define MT_DBG_PLE_FL_QUE_CTRL2 MT_DBG_PLE(PLE_FL_QUE_CTRL_OFFSET + 0x8)
1243+#define MT_DBG_PLE_FL_QUE_CTRL3 MT_DBG_PLE(PLE_FL_QUE_CTRL_OFFSET + 0xc)
1244+#define MT_DBG_PLE_NATIVE_TXCMD_Q_EMPTY MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_NATIVE_TXCMD_Q_EMPTY))
1245+#define MT_DBG_PLE_TXCMD_Q_EMPTY MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_TXCMD_Q_EMPTY))
1246+
1247+#define MT_DBG_PLE_PBUF_CTRL_PAGE_SIZE_MASK BIT(31)
1248+#define MT_DBG_PLE_PBUF_CTRL_OFFSET_MASK GENMASK(25, 17)
1249+#define MT_DBG_PLE_PBUF_CTRL_TOTAL_PAGE_NUM_MASK GENMASK(11, 0)
1250+
1251+#define MT_DBG_PLE_FREEPG_CNT_FREEPG_CNT_MASK GENMASK(11, 0)
1252+#define MT_DBG_PLE_FREEPG_CNT_FFA_CNT_MASK GENMASK(27, 16)
1253+#define MT_DBG_PLE_FREEPG_HEAD_TAIL_FREEPG_TAIL_MASK GENMASK(27, 16)
1254+#define MT_DBG_PLE_FREEPG_HEAD_TAIL_FREEPG_HEAD_MASK GENMASK(11, 0)
1255+#define MT_DBG_PLE_PG_HIF_GROUP_HIF_MAX_QUOTA_MASK GENMASK(27, 16)
1256+#define MT_DBG_PLE_PG_HIF_GROUP_HIF_MIN_QUOTA_MASK GENMASK(11, 0)
1257+
1258+#define MT_DBG_PLE_HIF_PG_INFO_HIF_SRC_CNT_MASK GENMASK(27, 16)
1259+#define MT_DBG_PLE_HIF_PG_INFO_HIF_RSV_CNT_MASK GENMASK(11, 0)
1260+
1261+#define MT_DBG_PLE_PG_HIF_TXCMD_GROUP_HIF_TXCMD_MAX_QUOTA_MASK GENMASK(27, 16)
1262+#define MT_DBG_PLE_PG_HIF_TXCMD_GROUP_HIF_TXCMD_MIN_QUOTA_MASK GENMASK(11, 0)
1263+
1264+#define MT_DBG_PLE_HIF_TXCMD_PG_INFO_HIF_TXCMD_SRC_CNT_MASK GENMASK(27, 16)
1265+#define MT_DBG_PLE_HIF_TXCMD_PG_INFO_HIF_TXCMD_RSV_CNT_MASK GENMASK(11, 0)
1266+
1267+#define MT_DBG_PLE_TXCMD_PG_INFO_HIF_TXCMD_SRC_CNT_MASK GENMASK(27, 16)
1268+#define MT_DBG_PLE_TXCMD_PG_INFO_HIF_TXCMD_RSV_CNT_MASK GENMASK(11, 0)
1269+
1270+#define MT_DBG_PLE_PG_CPU_GROUP_CPU_MAX_QUOTA_MASK GENMASK(27, 16)
1271+#define MT_DBG_PLE_PG_CPU_GROUP_CPU_MIN_QUOTA_MASK GENMASK(11, 0)
1272+
1273+#define MT_DBG_PLE_CPU_PG_INFO_CPU_SRC_CNT_MASK GENMASK(27, 16)
1274+#define MT_DBG_PLE_CPU_PG_INFO_CPU_RSV_CNT_MASK GENMASK(11, 0)
1275+
1276+#define MT_DBG_PLE_Q_EMPTY_ALL_AC_EMPTY_MASK BIT(24)
1277+#define MT_DBG_PLE_FL_QUE_CTRL0_EXECUTE_MASK BIT(31)
1278+#define MT_DBG_PLE_FL_QUE_CTRL0_Q_BUF_QID_MASK GENMASK(30, 24)
1279+
1280+#define MT_PLE_FL_QUE_CTRL0_Q_BUF_QID_SHFT 24
1281+#define MT_PLE_FL_QUE_CTRL0_Q_BUF_PID_SHFT 10
1282+
1283+#define MT_DBG_PLE_FL_QUE_CTRL2_Q_TAIL_FID_MASK GENMASK(27, 16)
1284+#define MT_DBG_PLE_FL_QUE_CTRL2_Q_HEAD_FID_MASK GENMASK(11, 0)
1285+#define MT_DBG_PLE_FL_QUE_CTRL3_Q_PKT_NUM_MASK GENMASK(11, 0)
1286+
1287+#define MT_DBG_PLE_STATION_PAUSE(n) MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_STATION_PAUSE) + ((n) << 2))
1288+#define MT_DBG_PLE_DIS_STA_MAP(n) MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_DIS_STA_MAP) + ((n) << 2))
1289+#define MT_DBG_PLE_AC_QEMPTY(ac, n) MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_AC_QEMPTY) + \
1290+ __DBG_REG_OFFS(dev, DBG_PLE_AC_OFFSET) * (ac) + ((n) << 2))
1291+
1292+#define MT_DBG_PLE_AMSDU_PACK_MSDU_CNT(n) MT_DBG_PLE(0x10e0 + ((n) << 2))
1293+
1294+/* pseinfo related CRs. */
1295+#define MT_DBG_PSE_BASE 0x820C8000
1296+#define MT_DBG_PSE(ofs) (MT_DBG_PSE_BASE + (ofs))
1297+
developerd68e00e2022-06-01 10:59:24 +08001298+#define MT_DBG_PSE_PBUF_CTRL MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_PBUF_CTRL))
1299+#define MT_DBG_PSE_QUEUE_EMPTY MT_DBG_PSE(0x0b0)
1300+#define MT_DBG_PSE_FREEPG_CNT MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_FREEPG_CNT))
1301+#define MT_DBG_PSE_FREEPG_HEAD_TAIL MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_FREEPG_HEAD_TAIL))
1302+#define MT_DBG_PSE_PG_HIF0_GROUP MT_DBG_PSE(0x110)
1303+#define MT_DBG_PSE_HIF0_PG_INFO MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_HIF0_PG_INFO))
1304+#define MT_DBG_PSE_PG_HIF1_GROUP MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_PG_HIF1_GROUP))
1305+#define MT_DBG_PSE_HIF1_PG_INFO MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_HIF1_PG_INFO))
1306+#define MT_DBG_PSE_PG_CPU_GROUP MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_PG_CPU_GROUP))
1307+#define MT_DBG_PSE_CPU_PG_INFO MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_CPU_PG_INFO))
1308+#define MT_DBG_PSE_PG_LMAC0_GROUP MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_PG_LMAC0_GROUP))
1309+#define MT_DBG_PSE_LMAC0_PG_INFO MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_LMAC0_PG_INFO))
1310+#define MT_DBG_PSE_PG_LMAC1_GROUP MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_PG_LMAC1_GROUP))
1311+#define MT_DBG_PSE_LMAC1_PG_INFO MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_LMAC1_PG_INFO))
1312+#define MT_DBG_PSE_PG_LMAC2_GROUP MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_PG_LMAC2_GROUP))
1313+#define MT_DBG_PSE_LMAC2_PG_INFO MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_LMAC2_PG_INFO))
1314+#define MT_DBG_PSE_PG_PLE_GROUP MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_PG_PLE_GROUP))
1315+#define MT_DBG_PSE_PLE_PG_INFO MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_PLE_PG_INFO))
1316+#define MT_DBG_PSE_PG_LMAC3_GROUP MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_PG_LMAC3_GROUP))
1317+#define MT_DBG_PSE_LMAC3_PG_INFO MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_LMAC3_PG_INFO))
1318+#define MT_DBG_PSE_PG_MDP_GROUP MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_PG_MDP_GROUP))
1319+#define MT_DBG_PSE_MDP_PG_INFO MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_MDP_PG_INFO))
1320+#define MT_DBG_PSE_PG_PLE1_GROUP MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_PG_PLE1_GROUP))
1321+#define MT_DBG_PSE_PLE1_PG_INFO MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_PLE1_PG_INFO))
developer73e5a572022-04-19 10:21:20 +08001322+
1323+#define MT_DBG_PSE_PBUF_CTRL_PAGE_SIZE_CFG_MASK BIT(31)
1324+#define MT_DBG_PSE_PBUF_CTRL_PBUF_OFFSET_MASK GENMASK(25, 17)
1325+#define MT_DBG_PSE_PBUF_CTRL_TOTAL_PAGE_NUM_MASK GENMASK(11, 0)
1326+#define MT_DBG_PSE_QUEUE_EMPTY_RLS_Q_EMTPY_MASK BIT(31)
1327+#define MT_DBG_PSE_QUEUE_EMPTY_MDP_RXIOC_QUEUE_EMPTY_MASK BIT(23)
1328+#define MT_DBG_PSE_QUEUE_EMPTY_MDP_TXIOC_QUEUE_EMPTY_MASK BIT(22)
1329+#define MT_DBG_PSE_QUEUE_EMPTY_SFD_PARK_QUEUE_EMPTY_MASK BIT(21)
1330+#define MT_DBG_PSE_QUEUE_EMPTY_SEC_RX_QUEUE_EMPTY_SHFT BIT(20)
1331+#define MT_DBG_PSE_QUEUE_EMPTY_SEC_TX_QUEUE_EMPTY_MASK BIT(19)
1332+#define MT_DBG_PSE_QUEUE_EMPTY_MDP_RX_QUEUE_EMPTY_MASK BIT(18)
1333+#define MT_DBG_PSE_QUEUE_EMPTY_MDP_TX_QUEUE_EMPTY_MASK BIT(17)
1334+#define MT_DBG_PSE_QUEUE_EMPTY_LMAC_TX_QUEUE_EMPTY_MASK BIT(16)
1335+#define MT_DBG_PSE_QUEUE_EMPTY_HIF_5_EMPTY_MASK BIT(13)
1336+#define MT_DBG_PSE_QUEUE_EMPTY_HIF_4_EMPTY_MASK BIT(12)
1337+#define MT_DBG_PSE_QUEUE_EMPTY_HIF_3_EMPTY_MASK BIT(11)
1338+#define MT_DBG_PSE_QUEUE_EMPTY_HIF_2_EMPTY_MASK BIT(10)
1339+#define MT_DBG_PSE_QUEUE_EMPTY_HIF_1_EMPTY_MASK BIT(9)
1340+#define MT_DBG_PSE_QUEUE_EMPTY_HIF_0_EMPTY_MASK BIT(8)
1341+#define MT_DBG_PSE_QUEUE_EMPTY_CPU_Q3_EMPTY_MASK BIT(3)
1342+#define MT_DBG_PSE_QUEUE_EMPTY_CPU_Q2_EMPTY_MASK BIT(2)
1343+#define MT_DBG_PSE_QUEUE_EMPTY_CPU_Q1_EMPTY_MASK BIT(1)
1344+#define MT_DBG_PSE_QUEUE_EMPTY_CPU_Q0_EMPTY_MASK BIT(0)
1345+#define MT_DBG_PSE_FREEPG_CNT_FFA_CNT_MASK GENMASK(27, 16)
1346+#define MT_DBG_PSE_FREEPG_CNT_FREEPG_CNT_MASK GENMASK(11, 0)
1347+#define MT_DBG_PSE_FREEPG_HEAD_TAIL_FREEPG_TAIL_MASK GENMASK(27, 16)
1348+#define MT_DBG_PSE_FREEPG_HEAD_TAIL_FREEPG_HEAD_MASK GENMASK(11, 0)
1349+#define MT_DBG_PSE_PG_HIF0_GROUP_HIF0_MAX_QUOTA_MASK GENMASK(27, 16)
1350+#define MT_DBG_PSE_PG_HIF0_GROUP_HIF0_MIN_QUOTA_MASK GENMASK(11, 0)
1351+#define MT_DBG_PSE_PG_HIF0_GROUP_HIF0_MAX_QUOTA_MASK GENMASK(27, 16)
1352+#define MT_DBG_PSE_PG_HIF0_GROUP_HIF0_MIN_QUOTA_MASK GENMASK(11, 0)
1353+#define MT_DBG_PSE_HIF0_PG_INFO_HIF0_SRC_CNT_MASK GENMASK(27, 16)
1354+#define MT_DBG_PSE_HIF0_PG_INFO_HIF0_RSV_CNT_MASK GENMASK(11, 0)
1355+#define MT_DBG_PSE_PG_HIF1_GROUP_HIF1_MAX_QUOTA_MASK GENMASK(27, 16)
1356+#define MT_DBG_PSE_PG_HIF1_GROUP_HIF1_MIN_QUOTA_MASK GENMASK(11, 0)
1357+#define MT_DBG_PSE_HIF1_PG_INFO_HIF1_SRC_CNT_MASK GENMASK(27, 16)
1358+#define MT_DBG_PSE_HIF1_PG_INFO_HIF1_RSV_CNT_MASK GENMASK(11, 0)
1359+#define MT_DBG_PSE_CPU_PG_INFO_CPU_SRC_CNT_MASK GENMASK(27, 16)
1360+#define MT_DBG_PSE_CPU_PG_INFO_CPU_RSV_CNT_MASK GENMASK(11, 0)
1361+#define MT_DBG_PSE_PG_PLE_GROUP_PLE_MAX_QUOTA_MASK GENMASK(27, 16)
1362+#define MT_DBG_PSE_PG_PLE_GROUP_PLE_MIN_QUOTA_MASK GENMASK(11, 0)
1363+#define MT_DBG_PSE_PG_CPU_GROUP_CPU_MAX_QUOTA_MASK GENMASK(27, 16)
1364+#define MT_DBG_PSE_PG_CPU_GROUP_CPU_MIN_QUOTA_MASK GENMASK(11, 0)
1365+#define MT_DBG_PSE_PLE_PG_INFO_PLE_SRC_CNT_MASK GENMASK(27, 16)
1366+#define MT_DBG_PSE_PLE_PG_INFO_PLE_RSV_CNT_MASK GENMASK(11, 0)
1367+#define MT_DBG_PSE_PG_LMAC0_GROUP_LMAC0_MAX_QUOTA_MASK GENMASK(27, 16)
1368+#define MT_DBG_PSE_PG_LMAC0_GROUP_LMAC0_MIN_QUOTA_MASK GENMASK(11, 0)
1369+#define MT_DBG_PSE_LMAC0_PG_INFO_LMAC0_SRC_CNT_MASK GENMASK(27, 16)
1370+#define MT_DBG_PSE_LMAC0_PG_INFO_LMAC0_RSV_CNT_MASK GENMASK(11, 0)
1371+#define MT_DBG_PSE_PG_LMAC1_GROUP_LMAC1_MAX_QUOTA_MASK GENMASK(27, 16)
1372+#define MT_DBG_TOP_PG_LMAC1_GROUP_LMAC1_MIN_QUOTA_MASK GENMASK(11, 0)
1373+#define MT_DBG_PSE_LMAC1_PG_INFO_LMAC1_SRC_CNT_MASK GENMASK(27, 16)
1374+#define MT_DBG_PSE_LMAC1_PG_INFO_LMAC1_RSV_CNT_MASK GENMASK(11, 0)
1375+#define MT_DBG_PSE_PG_LMAC2_GROUP_LMAC2_MAX_QUOTA_MASK GENMASK(27, 16)
1376+#define MT_DBG_PSE_PG_LMAC2_GROUP_LMAC2_MIN_QUOTA_MASK GENMASK(11, 0)
1377+#define MT_DBG_PSE_LMAC2_PG_INFO_LMAC2_SRC_CNT_MASK GENMASK(27, 16)
1378+#define MT_DBG_PSE_LMAC2_PG_INFO_LMAC2_RSV_CNT_MASK GENMASK(11, 0)
1379+#define MT_DBG_PSE_PG_LMAC3_GROUP_LMAC3_MAX_QUOTA_MASK GENMASK(27, 16)
1380+#define MT_DBG_TOP_PG_LMAC3_GROUP_LMAC3_MIN_QUOTA_MASK GENMASK(11, 0)
1381+#define MT_DBG_PSE_LMAC3_PG_INFO_LMAC3_SRC_CNT_MASK GENMASK(27, 16)
1382+#define MT_DBG_PSE_LMAC3_PG_INFO_LMAC3_RSV_CNT_MASK GENMASK(11, 0)
1383+#define MT_DBG_PSE_PG_LMAC3_GROUP_LMAC3_MAX_QUOTA_MASK GENMASK(27, 16)
1384+#define MT_DBG_TOP_PG_LMAC3_GROUP_LMAC3_MIN_QUOTA_MASK GENMASK(11, 0)
1385+#define MT_DBG_PSE_PG_MDP_GROUP_MDP_MAX_QUOTA_MASK GENMASK(27, 16)
1386+#define MT_DBG_PSE_PG_MDP_GROUP_MDP_MIN_QUOTA_MASK GENMASK(11, 0)
1387+#define MT_DBG_PSE_MDP_PG_INFO_MDP_SRC_CNT_MASK GENMASK(27, 16)
1388+#define MT_DBG_PSE_MDP_PG_INFO_MDP_RSV_CNT_MASK GENMASK(11, 0)
1389+
1390+#define MT_DBG_PSE_FL_QUE_CTRL_0_ADDR MT_DBG_PLE(0x1b0)
1391+#define MT_DBG_PSE_FL_QUE_CTRL_0_EXECUTE_MASK BIT(31)
1392+#define MT_DBG_PSE_FL_QUE_CTRL_0_Q_BUF_QID_SHFT 24
1393+#define MT_DBG_PSE_FL_QUE_CTRL_0_Q_BUF_PID_SHFT 10
1394+#define MT_DBG_PSE_FL_QUE_CTRL_0_Q_BUF_WLANID_MASK GENMASK(9, 0)
1395+
1396+#define MT_DBG_PSE_FL_QUE_CTRL_2_ADDR MT_DBG_PLE(0x1b8)
1397+#define MT_DBG_PSE_FL_QUE_CTRL_2_QUEUE_TAIL_FID_MASK GENMASK(27, 16)
1398+#define MT_DBG_PSE_FL_QUE_CTRL_2_QUEUE_HEAD_FID_MASK GENMASK(11, 0)
1399+
1400+#define MT_DBG_PSE_FL_QUE_CTRL_3_ADDR MT_DBG_PLE(0x1bc)
1401+#define MT_DBG_PSE_FL_QUE_CTRL_3_QUEUE_PKT_NUM_MASK GENMASK(11, 0)
1402+
1403+
1404+/* AGG */
1405+#define MT_DBG_AGG_BASE(_band) ((_band) ? 0x820f2000 : 0x820e2000)
1406+#define MT_DBG_AGG(_band, ofs) (MT_DBG_AGG_BASE(_band) + (ofs))
1407+
1408+#define MT_DBG_AGG_AALCR0(_band) MT_DBG_AGG((_band), __DBG_REG_OFFS(dev, DBG_AGG_AALCR0))
1409+#define MT_DBG_AGG_AALCR1(_band) MT_DBG_AGG((_band), __DBG_REG_OFFS(dev, DBG_AGG_AALCR1))
1410+#define MT_DBG_AGG_AALCR2(_band) MT_DBG_AGG((_band), __DBG_REG_OFFS(dev, DBG_AGG_AALCR2))
1411+#define MT_DBG_AGG_AALCR3(_band) MT_DBG_AGG((_band), __DBG_REG_OFFS(dev, DBG_AGG_AALCR3))
1412+#define MT_DBG_AGG_AALCR4(_band) MT_DBG_AGG((_band), __DBG_REG_OFFS(dev, DBG_AGG_AALCR4))
1413+#define MT_DBG_AGG_B0BRR0(_band) MT_DBG_AGG((_band), __DBG_REG_OFFS(dev, DBG_AGG_B0BRR0))
1414+#define MT_DBG_AGG_B1BRR0(_band) MT_DBG_AGG((_band), __DBG_REG_OFFS(dev, DBG_AGG_B1BRR0))
1415+#define MT_DBG_AGG_B2BRR0(_band) MT_DBG_AGG((_band), __DBG_REG_OFFS(dev, DBG_AGG_B2BRR0))
1416+#define MT_DBG_AGG_B3BRR0(_band) MT_DBG_AGG((_band), __DBG_REG_OFFS(dev, DBG_AGG_B3BRR0))
1417+#define MT_DBG_AGG_AWSCR(_band, n) MT_DBG_AGG((_band), __DBG_REG_OFFS(dev, DBG_AGG_AWSCR0) + ((n) << 2))
1418+#define MT_DBG_AGG_PCR(_band, n) MT_DBG_AGG((_band), __DBG_REG_OFFS(dev, DBG_AGG_PCR0) + ((n) << 2))
1419+#define MT_DBG_AGG_TTCR(_band, n) MT_DBG_AGG((_band), __DBG_REG_OFFS(dev, DBG_AGG_TTCR0) + ((n) << 2))
1420+#define MT_DBG_MIB_M0ARNG(_band, n) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0ARNG0) + ((n) << 2))
1421+#define MT_DBG_MIB_M0DR2(_band, n) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0DR2) + ((n) << 2))
1422+#define MT_DBG_MIB_M0DR13(_band, n) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0DR13) + ((n) << 2))
1423+
1424+#define MT_DBG_AGG_AALCR_ACx3_AGG_LIMIT_MASK GENMASK(31, 24)
1425+#define MT_DBG_AGG_AALCR_ACx2_AGG_LIMIT_MASK GENMASK(23, 16)
1426+#define MT_DBG_AGG_AALCR_ACx1_AGG_LIMIT_MASK GENMASK(15, 8)
1427+#define MT_DBG_AGG_AALCR_ACx0_AGG_LIMIT_MASK GENMASK(7, 0)
1428+#define MT_DBG_AGG_AALCR4_ALTX0_AGG_LIMIT_MASK GENMASK(7, 0)
1429+
1430+#define MT_DBG_AGG_AWSCR0_WINSIZE3_MASK GENMASK(31, 24)
1431+#define MT_DBG_AGG_AWSCR0_WINSIZE2_MASK GENMASK(23, 16)
1432+#define MT_DBG_AGG_AWSCR0_WINSIZE1_MASK GENMASK(15, 8)
1433+#define MT_DBG_AGG_AWSCR0_WINSIZE0_MASK GENMASK(7, 0)
1434+
1435+#define MT_DBG_AGG_AWSCR1_WINSIZE7_MASK GENMASK(31, 24)
1436+#define MT_DBG_AGG_AWSCR1_WINSIZE6_MASK GENMASK(23, 16)
1437+#define MT_DBG_AGG_AWSCR1_WINSIZE5_MASK GENMASK(15, 8)
1438+#define MT_DBG_AGG_AWSCR1_WINSIZE4_MASK GENMASK(7, 0)
1439+
1440+#define MT_DBG_AGG_AWSCR2_WINSIZEB_MASK GENMASK(31, 24)
1441+#define MT_DBG_AGG_AWSCR2_WINSIZEA_MASK GENMASK(23, 16)
1442+#define MT_DBG_AGG_AWSCR2_WINSIZE9_MASK GENMASK(15, 8)
1443+#define MT_DBG_AGG_AWSCR2_WINSIZE8_MASK GENMASK(7, 0)
1444+
1445+#define MT_DBG_AGG_AWSCR3_WINSIZEE_MASK GENMASK(23, 16)
1446+#define MT_DBG_AGG_AWSCR3_WINSIZED_MASK GENMASK(15, 8)
1447+#define MT_DBG_AGG_AWSCR3_WINSIZEC_MASK GENMASK(7, 0)
1448+
1449+#define MT_DBG_MIB_M0ARNG0_AGG_RANG_SEL3_MASK GENMASK(31, 24)
1450+#define MT_DBG_MIB_M0ARNG0_AGG_RANG_SEL2_MASK GENMASK(23, 16)
1451+#define MT_DBG_MIB_M0ARNG0_AGG_RANG_SEL1_MASK GENMASK(15, 8)
1452+#define MT_DBG_MIB_M0ARNG0_AGG_RANG_SEL0_MASK GENMASK(7, 0)
1453+
1454+#define MT_DBG_MIB_M0ARNG1_AGG_RANG_SEL7_MASK GENMASK(31, 24)
1455+#define MT_DBG_MIB_M0ARNG1_AGG_RANG_SEL6_MASK GENMASK(23, 16)
1456+#define MT_DBG_MIB_M0ARNG1_AGG_RANG_SEL5_MASK GENMASK(15, 8)
1457+#define MT_DBG_MIB_M0ARNG1_AGG_RANG_SEL4_MASK GENMASK(7, 0)
1458+
1459+#define MT_DBG_MIB_M0ARNG2_AGG_RANG_SEL11_MASK GENMASK(31, 24)
1460+#define MT_DBG_MIB_M0ARNG2_AGG_RANG_SEL10_MASK GENMASK(23, 16)
1461+#define MT_DBG_MIB_M0ARNG2_AGG_RANG_SEL9_MASK GENMASK(15, 8)
1462+#define MT_DBG_MIB_M0ARNG2_AGG_RANG_SEL8_MASK GENMASK(7, 0)
1463+
1464+#define MT_DBG_MIB_M0ARNG3_AGG_RANG_SEL14_MASK GENMASK(23, 16)
1465+#define MT_DBG_MIB_M0ARNG3_AGG_RANG_SEL13_MASK GENMASK(15, 8)
1466+#define MT_DBG_MIB_M0ARNG3_AGG_RANG_SEL12_MASK GENMASK(7, 0)
1467+
1468+#define MT_DBG_MIB_M0DR2_TRX_AGG_RANGE1_CNT_MASK GENMASK(31, 16)
1469+#define MT_DBG_MIB_M0DR2_TRX_AGG_RANGE0_CNT_MASK GENMASK(15, 0)
1470+#define MT_DBG_MIB_M0DR3_TRX_AGG_RANGE3_CNT_MASK GENMASK(31, 16)
1471+#define MT_DBG_MIB_M0DR3_TRX_AGG_RANGE2_CNT_MASK GENMASK(15, 0)
1472+#define MT_DBG_MIB_M0DR4_TRX_AGG_RANGE5_CNT_MASK GENMASK(31, 16)
1473+#define MT_DBG_MIB_M0DR4_TRX_AGG_RANGE4_CNT_MASK GENMASK(15, 0)
1474+#define MT_DBG_MIB_M0DR5_TRX_AGG_RANGE7_CNT_MASK GENMASK(31, 16)
1475+#define MT_DBG_MIB_M0DR5_TRX_AGG_RANGE6_CNT_MASK GENMASK(15, 0)
1476+#define MT_DBG_MIB_M0DR13_TRX_AGG_RANGE9_CNT_MASK GENMASK(31, 16)
1477+#define MT_DBG_MIB_M0DR13_TRX_AGG_RANGE8_CNT_MASK GENMASK(15, 0)
1478+#define MT_DBG_MIB_M0DR14_TRX_AGG_RANGE11_CNT_MASK GENMASK(31, 16)
1479+#define MT_DBG_MIB_M0DR14_TRX_AGG_RANGE10_CNT_MASK GENMASK(15, 0)
1480+#define MT_DBG_MIB_M0DR15_TRX_AGG_RANGE13_CNT_MASK GENMASK(31, 16)
1481+#define MT_DBG_MIB_M0DR15_TRX_AGG_RANGE12_CNT_MASK GENMASK(15, 0)
1482+#define MT_DBG_MIB_M0DR16_TRX_AGG_RANGE15_CNT_MASK GENMASK(31, 16)
1483+#define MT_DBG_MIB_M0DR16_TRX_AGG_RANGE14_CNT_MASK GENMASK(15, 0)
1484+
1485+/* mt7915 host DMA*/
1486+#define MT_DBG_INT_DMA1_R0_DONE BIT(0)
1487+#define MT_DBG_INT_DMA1_R1_DONE BIT(1)
1488+#define MT_DBG_INT_DMA1_R2_DONE BIT(2)
1489+
1490+#define MT_DBG_INT_DMA1_T16_DONE BIT(26)
1491+#define MT_DBG_INT_DMA1_T17_DONE BIT(27)
1492+#define MT_DBG_INT_DMA1_T18_DONE BIT(30)
1493+#define MT_DBG_INT_DMA1_T19_DONE BIT(31)
1494+#define MT_DBG_INT_DMA1_T20_DONE BIT(15)
1495+
1496+#define MT_DBG_EXT_WRAP_INT_DMA0_R0_DONE BIT(16)
1497+#define MT_DBG_EXT_WRAP_INT_DMA0_R1_DONE BIT(17)
1498+
1499+/* mt7986 host DMA */
1500+#define MT_DBG_INT_DMA0_R0_DONE BIT(0)
1501+#define MT_DBG_INT_DMA0_R1_DONE BIT(1)
1502+#define MT_DBG_INT_DMA0_R2_DONE BIT(2)
1503+#define MT_DBG_INT_DMA0_R3_DONE BIT(3)
1504+#define MT_DBG_INT_DMA0_R4_DONE BIT(22)
1505+#define MT_DBG_INT_DMA0_R5_DONE BIT(23)
1506+
1507+#define MT_DBG_INT_DMA0_T16_DONE BIT(26)
1508+#define MT_DBG_INT_DMA0_T17_DONE BIT(27)
1509+#define MT_DBG_INT_DMA0_T18_DONE BIT(30)
1510+#define MT_DBG_INT_DMA0_T19_DONE BIT(31)
1511+#define MT_DBG_INT_DMA0_T20_DONE BIT(25)
1512+
1513+/* MCU DMA */
1514+#define WF_WFDMA_MCU_DMA0_BASE 0x54000000
1515+#define WF_WFDMA_MCU_DMA0_HOST_INT_STA_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x200) // 0200
1516+#define WF_WFDMA_MCU_DMA0_HOST_INT_ENA_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0X204) // 0204
1517+#define WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x208) // 0208
1518+#define WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_RX_DMA_BUSY_MASK 0x00000008 // RX_DMA_BUSY[3]
1519+#define WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_RX_DMA_BUSY_SHFT 3
1520+#define WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_RX_DMA_EN_MASK 0x00000004 // RX_DMA_EN[2]
1521+#define WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_RX_DMA_EN_SHFT 2
1522+#define WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_TX_DMA_BUSY_MASK 0x00000002 // TX_DMA_BUSY[1]
1523+#define WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_TX_DMA_BUSY_SHFT 1
1524+#define WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_TX_DMA_EN_MASK 0x00000001 // TX_DMA_EN[0]
1525+#define WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_TX_DMA_EN_SHFT 0
1526+
1527+#define WF_WFDMA_MCU_DMA1_BASE 0x55000000
1528+#define WF_WFDMA_MCU_DMA1_HOST_INT_STA_ADDR (WF_WFDMA_MCU_DMA1_BASE + 0x200) // 0200
1529+#define WF_WFDMA_MCU_DMA1_HOST_INT_ENA_ADDR (WF_WFDMA_MCU_DMA1_BASE + 0X204) // 0204
1530+#define WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_ADDR (WF_WFDMA_MCU_DMA1_BASE + 0x208) // 0208
1531+#define WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_RX_DMA_BUSY_MASK 0x00000008 // RX_DMA_BUSY[3]
1532+#define WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_RX_DMA_BUSY_SHFT 3
1533+#define WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_RX_DMA_EN_MASK 0x00000004 // RX_DMA_EN[2]
1534+#define WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_RX_DMA_EN_SHFT 2
1535+#define WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_TX_DMA_BUSY_MASK 0x00000002 // TX_DMA_BUSY[1]
1536+#define WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_TX_DMA_BUSY_SHFT 1
1537+#define WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_TX_DMA_EN_MASK 0x00000001 // TX_DMA_EN[0]
1538+#define WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_TX_DMA_EN_SHFT 0
1539+#define WF_WFDMA_MCU_DMA1_WPDMA_TX_RING0_CTRL0_ADDR (WF_WFDMA_MCU_DMA1_BASE + 0x300) // 0300
1540+#define WF_WFDMA_MCU_DMA1_WPDMA_TX_RING1_CTRL0_ADDR (WF_WFDMA_MCU_DMA1_BASE + 0x310) // 0310
1541+#define WF_WFDMA_MCU_DMA1_WPDMA_TX_RING2_CTRL0_ADDR (WF_WFDMA_MCU_DMA1_BASE + 0x320) // 0320
1542+#define WF_WFDMA_MCU_DMA1_WPDMA_RX_RING0_CTRL0_ADDR (WF_WFDMA_MCU_DMA1_BASE + 0x500) // 0500
1543+#define WF_WFDMA_MCU_DMA1_WPDMA_RX_RING1_CTRL0_ADDR (WF_WFDMA_MCU_DMA1_BASE + 0x510) // 0510
1544+#define WF_WFDMA_MCU_DMA1_WPDMA_RX_RING2_CTRL0_ADDR (WF_WFDMA_MCU_DMA1_BASE + 0x520) // 0520
1545+#define WF_WFDMA_MCU_DMA1_WPDMA_RX_RING3_CTRL0_ADDR (WF_WFDMA_MCU_DMA1_BASE + 0x530) // 0530
1546+#define WF_WFDMA_MCU_DMA1_WPDMA_RX_RING4_CTRL0_ADDR (WF_WFDMA_MCU_DMA1_BASE + 0x540) // 0540
1547+
1548+#define WF_WFDMA_MCU_DMA1_PCIE1_BASE 0x59000000
1549+#define WF_WFDMA_MCU_DMA1_PCIE1_HOST_INT_STA_ADDR (WF_WFDMA_MCU_DMA1_PCIE1_BASE + 0x200) // 0200
1550+#define WF_WFDMA_MCU_DMA1_PCIE1_HOST_INT_ENA_ADDR (WF_WFDMA_MCU_DMA1_PCIE1_BASE + 0X204) // 0204
1551+#define WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_ADDR (WF_WFDMA_MCU_DMA1_PCIE1_BASE + 0x208) // 0208
1552+#define WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_RX_DMA_BUSY_MASK 0x00000008 // RX_DMA_BUSY[3]
1553+#define WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_RX_DMA_BUSY_SHFT 3
1554+#define WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_RX_DMA_EN_MASK 0x00000004 // RX_DMA_EN[2]
1555+#define WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_RX_DMA_EN_SHFT 2
1556+#define WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_TX_DMA_BUSY_MASK 0x00000002 // TX_DMA_BUSY[1]
1557+#define WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_TX_DMA_BUSY_SHFT 1
1558+#define WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_TX_DMA_EN_MASK 0x00000001 // TX_DMA_EN[0]
1559+#define WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_TX_DMA_EN_SHFT 0
1560+#define WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_TX_RING2_CTRL0_ADDR (WF_WFDMA_MCU_DMA1_PCIE1_BASE + 0x320) // 0320
1561+#define WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_RX_RING3_CTRL0_ADDR (WF_WFDMA_MCU_DMA1_PCIE1_BASE + 0x530) // 0530
1562+
1563+#define WF_WFDMA_MCU_DMA0_WPDMA_TX_RING0_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x300) // 0300
1564+#define WF_WFDMA_MCU_DMA0_WPDMA_TX_RING1_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x310) // 0310
1565+#define WF_WFDMA_MCU_DMA0_WPDMA_TX_RING2_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x320) // 0320
1566+/* mt7986 add */
1567+#define WF_WFDMA_MCU_DMA0_WPDMA_TX_RING3_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x330) // 0330
1568+#define WF_WFDMA_MCU_DMA0_WPDMA_TX_RING4_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x340) // 0340
1569+#define WF_WFDMA_MCU_DMA0_WPDMA_TX_RING5_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x350) // 0350
1570+#define WF_WFDMA_MCU_DMA0_WPDMA_TX_RING6_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x360) // 0360
1571+
1572+
1573+#define WF_WFDMA_MCU_DMA0_WPDMA_RX_RING0_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x500) // 0500
1574+#define WF_WFDMA_MCU_DMA0_WPDMA_RX_RING1_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x510) // 0510
1575+#define WF_WFDMA_MCU_DMA0_WPDMA_RX_RING2_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x520) // 0520
1576+#define WF_WFDMA_MCU_DMA0_WPDMA_RX_RING3_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x530) // 0530
1577+#define WF_WFDMA_MCU_DMA0_WPDMA_RX_RING4_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x540) // 0540
1578+
1579+/* mt7986 add */
1580+#define WF_WFDMA_MCU_DMA0_WPDMA_RX_RING5_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x550) // 0550
1581+#define WF_WFDMA_MCU_DMA0_WPDMA_RX_RING6_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x560) // 0560
1582+#define WF_WFDMA_MCU_DMA0_WPDMA_RX_RING7_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x570) // 0570
1583+#define WF_WFDMA_MCU_DMA0_WPDMA_RX_RING8_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x580) // 0580
1584+#define WF_WFDMA_MCU_DMA0_WPDMA_RX_RING9_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x590) // 0590
1585+
1586+/* MEM DMA */
1587+#define WF_WFDMA_MEM_DMA_BASE 0x58000000
1588+#define WF_WFDMA_MEM_DMA_HOST_INT_STA_ADDR (WF_WFDMA_MEM_DMA_BASE + 0x200) // 0200
1589+#define WF_WFDMA_MEM_DMA_HOST_INT_ENA_ADDR (WF_WFDMA_MEM_DMA_BASE + 0X204) // 0204
1590+#define WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_ADDR (WF_WFDMA_MEM_DMA_BASE + 0x208) // 0208
1591+#define WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_RX_DMA_BUSY_MASK 0x00000008 // RX_DMA_BUSY[3]
1592+#define WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_RX_DMA_BUSY_SHFT 3
1593+#define WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_RX_DMA_EN_MASK 0x00000004 // RX_DMA_EN[2]
1594+#define WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_RX_DMA_EN_SHFT 2
1595+#define WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_TX_DMA_BUSY_MASK 0x00000002 // TX_DMA_BUSY[1]
1596+#define WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_TX_DMA_BUSY_SHFT 1
1597+#define WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_TX_DMA_EN_MASK 0x00000001 // TX_DMA_EN[0]
1598+#define WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_TX_DMA_EN_SHFT 0
1599+#define WF_WFDMA_MEM_DMA_WPDMA_TX_RING0_CTRL0_ADDR (WF_WFDMA_MEM_DMA_BASE + 0x300) // 0300
1600+#define WF_WFDMA_MEM_DMA_WPDMA_TX_RING1_CTRL0_ADDR (WF_WFDMA_MEM_DMA_BASE + 0x310) // 0310
1601+#define WF_WFDMA_MEM_DMA_WPDMA_RX_RING0_CTRL0_ADDR (WF_WFDMA_MEM_DMA_BASE + 0x500) // 0500
1602+#define WF_WFDMA_MEM_DMA_WPDMA_RX_RING1_CTRL0_ADDR (WF_WFDMA_MEM_DMA_BASE + 0x510) // 0510
1603+
1604+enum resource_attr {
1605+ HIF_TX_DATA,
1606+ HIF_TX_CMD,
1607+ HIF_TX_CMD_WM, /* direct path to WMCPU, only exist for WFDMA arch with 2 CPU */
1608+ HIF_TX_FWDL,
1609+ HIF_RX_DATA,
1610+ HIF_RX_EVENT,
1611+ RING_ATTR_NUM
1612+};
1613+
1614+struct hif_pci_tx_ring_desc {
1615+ u32 hw_int_mask;
1616+ u16 ring_size;
1617+ enum resource_attr ring_attr;
1618+ u8 band_idx;
1619+ char *const ring_info;
1620+};
1621+
1622+struct hif_pci_rx_ring_desc {
1623+ u32 hw_desc_base;
1624+ u32 hw_int_mask;
1625+ u16 ring_size;
1626+ enum resource_attr ring_attr;
1627+ u16 max_rx_process_cnt;
1628+ u16 max_sw_read_idx_inc;
1629+ char *const ring_info;
developer23c22342023-01-09 13:57:39 +08001630+ bool flags;
developer73e5a572022-04-19 10:21:20 +08001631+};
1632+
1633+const struct hif_pci_tx_ring_desc mt7915_tx_ring_layout[] = {
1634+ {
1635+ .hw_int_mask = MT_DBG_INT_DMA1_T16_DONE,
1636+ .ring_size = 128,
1637+ .ring_attr = HIF_TX_FWDL,
1638+ .ring_info = "FWDL"
1639+ },
1640+ {
1641+ .hw_int_mask = MT_DBG_INT_DMA1_T17_DONE,
1642+ .ring_size = 256,
1643+ .ring_attr = HIF_TX_CMD_WM,
1644+ .ring_info = "cmd to WM"
1645+ },
1646+ {
1647+ .hw_int_mask = MT_DBG_INT_DMA1_T18_DONE,
1648+ .ring_size = 2048,
1649+ .ring_attr = HIF_TX_DATA,
1650+ .ring_info = "band0 TXD"
1651+ },
1652+ {
1653+ .hw_int_mask = MT_DBG_INT_DMA1_T19_DONE,
1654+ .ring_size = 2048,
1655+ .ring_attr = HIF_TX_DATA,
1656+ .ring_info = "band1 TXD"
1657+ },
1658+ {
1659+ .hw_int_mask = MT_DBG_INT_DMA1_T20_DONE,
1660+ .ring_size = 256,
1661+ .ring_attr = HIF_TX_CMD,
1662+ .ring_info = "cmd to WA"
1663+ }
1664+};
1665+
1666+const struct hif_pci_rx_ring_desc mt7915_rx_ring_layout[] = {
1667+ {
1668+ .hw_int_mask = MT_DBG_EXT_WRAP_INT_DMA0_R0_DONE,
1669+ .ring_size = 1536,
1670+ .ring_attr = HIF_RX_DATA,
1671+ .ring_info = "band0 RX data"
1672+ },
1673+ {
1674+ .hw_int_mask = MT_DBG_EXT_WRAP_INT_DMA0_R1_DONE,
1675+ .ring_size = 1536,
1676+ .ring_attr = HIF_RX_DATA,
1677+ .ring_info = "band1 RX data"
1678+ },
1679+ {
1680+ .hw_int_mask = MT_DBG_INT_DMA1_R0_DONE,
1681+ .ring_size = 512,
1682+ .ring_attr = HIF_RX_EVENT,
1683+ .ring_info = "event from WM"
1684+ },
1685+ {
1686+ .hw_int_mask = MT_DBG_INT_DMA1_R1_DONE,
1687+ .ring_size = 1024,
1688+ .ring_attr = HIF_RX_EVENT,
developer23c22342023-01-09 13:57:39 +08001689+ .ring_info = "event from WA band0",
1690+ .flags = true
developer73e5a572022-04-19 10:21:20 +08001691+ },
1692+ {
1693+ .hw_int_mask = MT_DBG_INT_DMA1_R2_DONE,
1694+ .ring_size = 512,
1695+ .ring_attr = HIF_RX_EVENT,
1696+ .ring_info = "event from WA band1"
1697+ }
1698+};
1699+
1700+const struct hif_pci_tx_ring_desc mt7986_tx_ring_layout[] = {
1701+ {
1702+ .hw_int_mask = MT_DBG_INT_DMA0_T16_DONE,
1703+ .ring_size = 128,
1704+ .ring_attr = HIF_TX_FWDL,
1705+ .ring_info = "FWDL"
1706+ },
1707+ {
1708+ .hw_int_mask = MT_DBG_INT_DMA0_T17_DONE,
1709+ .ring_size = 256,
1710+ .ring_attr = HIF_TX_CMD_WM,
1711+ .ring_info = "cmd to WM"
1712+ },
1713+ {
1714+ .hw_int_mask = MT_DBG_INT_DMA0_T18_DONE,
1715+ .ring_size = 2048,
1716+ .ring_attr = HIF_TX_DATA,
1717+ .ring_info = "band0 TXD"
1718+ },
1719+ {
1720+ .hw_int_mask = MT_DBG_INT_DMA0_T19_DONE,
1721+ .ring_size = 2048,
1722+ .ring_attr = HIF_TX_DATA,
1723+ .ring_info = "band1 TXD"
1724+ },
1725+ {
1726+ .hw_int_mask = MT_DBG_INT_DMA0_T20_DONE,
1727+ .ring_size = 256,
1728+ .ring_attr = HIF_TX_CMD,
1729+ .ring_info = "cmd to WA"
1730+ }
1731+};
1732+
1733+const struct hif_pci_rx_ring_desc mt7986_rx_ring_layout[] = {
1734+ {
1735+ .hw_int_mask = MT_DBG_INT_DMA0_R4_DONE,
1736+ .ring_size = 1536,
1737+ .ring_attr = HIF_RX_DATA,
1738+ .ring_info = "band0 RX data"
1739+ },
1740+ {
1741+ .hw_int_mask = MT_DBG_INT_DMA0_R5_DONE,
1742+ .ring_size = 1536,
1743+ .ring_attr = HIF_RX_DATA,
1744+ .ring_info = "band1 RX data"
1745+ },
1746+ {
1747+ .hw_int_mask = MT_DBG_INT_DMA0_R0_DONE,
1748+ .ring_size = 512,
1749+ .ring_attr = HIF_RX_EVENT,
1750+ .ring_info = "event from WM"
1751+ },
1752+ {
1753+ .hw_int_mask = MT_DBG_INT_DMA0_R1_DONE,
1754+ .ring_size = 512,
1755+ .ring_attr = HIF_RX_EVENT,
1756+ .ring_info = "event from WA"
1757+ },
1758+ {
1759+ .hw_int_mask = MT_DBG_INT_DMA0_R2_DONE,
1760+ .ring_size = 1024,
1761+ .ring_attr = HIF_RX_EVENT,
developer23c22342023-01-09 13:57:39 +08001762+ .ring_info = "STS WA band0",
1763+ .flags = true
developer73e5a572022-04-19 10:21:20 +08001764+ },
1765+ {
1766+ .hw_int_mask = MT_DBG_INT_DMA0_R3_DONE,
1767+ .ring_size = 512,
1768+ .ring_attr = HIF_RX_EVENT,
1769+ .ring_info = "STS WA band1"
1770+ },
1771+};
1772+
1773+/* mibinfo related CRs. */
1774+#define BN0_WF_MIB_TOP_BASE 0x820ed000
1775+#define BN1_WF_MIB_TOP_BASE 0x820fd000
1776+
1777+#define BN0_WF_MIB_TOP_BTOCR_ADDR (BN0_WF_MIB_TOP_BASE + 0x400) // D400
1778+#define BN0_WF_MIB_TOP_BTBCR_ADDR (BN0_WF_MIB_TOP_BASE + 0x428) // D428
1779+#define BN0_WF_MIB_TOP_BTDCR_ADDR (BN0_WF_MIB_TOP_BASE + 0x4F0) // D4F0
1780+
1781+#define BN0_WF_MIB_TOP_BSDR0_ADDR (BN0_WF_MIB_TOP_BASE + 0x688) // D688
1782+#define BN0_WF_MIB_TOP_BSDR1_ADDR (BN0_WF_MIB_TOP_BASE + 0x690) // D690
1783+
1784+#define BN0_WF_MIB_TOP_BSDR2_ADDR (BN0_WF_MIB_TOP_BASE + 0x518) // D518
1785+#define BN0_WF_MIB_TOP_BSDR3_ADDR (BN0_WF_MIB_TOP_BASE + 0x520) // D520
1786+#define BN0_WF_MIB_TOP_BSDR4_ADDR (BN0_WF_MIB_TOP_BASE + 0x528) // D528
1787+#define BN0_WF_MIB_TOP_BSDR5_ADDR (BN0_WF_MIB_TOP_BASE + 0x530) // D530
1788+#define BN0_WF_MIB_TOP_BSDR6_ADDR (BN0_WF_MIB_TOP_BASE + 0x538) // D538
1789+
1790+#define BN0_WF_MIB_TOP_BROCR_ADDR (BN0_WF_MIB_TOP_BASE + 0x5B8) // D5B8
1791+#define BN0_WF_MIB_TOP_BRBCR_ADDR (BN0_WF_MIB_TOP_BASE + 0x5E0) // D5E0
1792+#define BN0_WF_MIB_TOP_BRDCR_ADDR (BN0_WF_MIB_TOP_BASE + 0x630) // D630
1793+
1794+#define BN0_WF_MIB_TOP_M0SDR0_BEACONTXCOUNT_MASK 0x0000FFFF // BEACONTXCOUNT[15..0]
1795+
1796+#define BN0_WF_MIB_TOP_M0SDR4_RX_FIFO_FULL_COUNT_MASK 0x0000FFFF // RX_FIFO_FULL_COUNT[15..0]
1797+
1798+#define BN0_WF_MIB_TOP_M0SDR5_RX_MPDU_COUNT_MASK 0xFFFFFFFF // RX_MPDU_COUNT[31..0]
1799+
1800+#define BN0_WF_MIB_TOP_M0SDR6_CHANNEL_IDLE_COUNT_MASK 0x0000FFFF // CHANNEL_IDLE_COUNT[15..0]
1801+
1802+#define BN1_WF_MIB_TOP_BTOCR_ADDR (BN1_WF_MIB_TOP_BASE + 0x400) // D400
1803+
1804+#define BN0_WF_MIB_TOP_M0SDR7_VEC_MISS_COUNT_MASK 0x0000FFFF // VEC_MISS_COUNT[15..0]
1805+#define BN0_WF_MIB_TOP_M0SDR8_DELIMITER_FAIL_COUNT_MASK 0x0000FFFF // DELIMITER_FAIL_COUNT[15..0]
1806+#define BN0_WF_MIB_TOP_M0SDR9_CCA_NAV_TX_TIME_MASK 0x00FFFFFF // CCA_NAV_TX_TIME[23..0]
1807+
1808+#define BN0_WF_MIB_TOP_M0SDR11_RX_LEN_MISMATCH_MASK 0x0000FFFF // RX_LEN_MISMATCH[15..0]
1809+
1810+#define BN0_WF_MIB_TOP_M0SDR16_P_CCA_TIME_MASK 0x00FFFFFF // P_CCA_TIME[23..0]
1811+#define BN0_WF_MIB_TOP_M0SDR17_S_CCA_TIME_MASK 0x00FFFFFF // S_CCA_TIME[23..0]
1812+#define BN0_WF_MIB_TOP_M0SDR18_P_ED_TIME_MASK 0x00FFFFFF // P_ED_TIME[23..0]
1813+#define BN0_WF_MIB_TOP_M0SDR19_CCK_MDRDY_TIME_MASK 0x00FFFFFF // CCK_MDRDY_TIME[23..0]
1814+#define BN0_WF_MIB_TOP_M0SDR20_OFDM_LG_MIXED_VHT_MDRDY_TIME_MASK 0x00FFFFFF // OFDM_LG_MIXED_VHT_MDRDY_TIME[23..0]
1815+#define BN0_WF_MIB_TOP_M0SDR21_OFDM_GREEN_MDRDY_TIME_MASK 0x00FFFFFF // OFDM_GREEN_MDRDY_TIME[23..0]
1816+
1817+#define BN0_WF_MIB_TOP_M0SDR22_ADDR (BN0_WF_MIB_TOP_BASE + 0x60) // D060
1818+#define BN0_WF_MIB_TOP_M0SDR23_ADDR (BN0_WF_MIB_TOP_BASE + 0x64) // D064
1819+
1820+#define BN0_WF_MIB_TOP_M0SDR34_MUBF_TX_COUNT_MASK 0x0000FFFF // MUBF_TX_COUNT[15..0]
1821+
1822+#define BN0_WF_MIB_TOP_M0DR0_TX_40MHZ_CNT_MASK 0xFFFF0000 // TX_40MHZ_CNT[31..16]
1823+#define BN0_WF_MIB_TOP_M0DR0_TX_40MHZ_CNT_SHFT 16
1824+#define BN0_WF_MIB_TOP_M0DR0_TX_20MHZ_CNT_MASK 0x0000FFFF // TX_20MHZ_CNT[15..0]
1825+#define BN0_WF_MIB_TOP_M0DR0_TX_20MHZ_CNT_SHFT 0
1826+
1827+#define BN0_WF_MIB_TOP_M0DR1_TX_160MHZ_CNT_MASK 0xFFFF0000 // TX_160MHZ_CNT[31..16]
1828+#define BN0_WF_MIB_TOP_M0DR1_TX_160MHZ_CNT_SHFT 16
1829+#define BN0_WF_MIB_TOP_M0DR1_TX_80MHZ_CNT_MASK 0x0000FFFF // TX_80MHZ_CNT[15..0]
1830+#define BN0_WF_MIB_TOP_M0DR1_TX_80MHZ_CNT_SHFT 0
1831+
1832+#define BN0_WF_MIB_TOP_M0DR6_TX_DDLMT_RNG2_CNT_MASK 0xFFFF0000 // TX_DDLMT_RNG2_CNT[31..16]
1833+#define BN0_WF_MIB_TOP_M0DR6_TX_DDLMT_RNG2_CNT_SHFT 16
1834+#define BN0_WF_MIB_TOP_M0DR6_TX_DDLMT_RNG1_CNT_MASK 0x0000FFFF // TX_DDLMT_RNG1_CNT[15..0]
1835+#define BN0_WF_MIB_TOP_M0DR6_TX_DDLMT_RNG1_CNT_SHFT 0
1836+
1837+#define BN0_WF_MIB_TOP_M0DR7_TX_DDLMT_RNG4_CNT_MASK 0xFFFF0000 // TX_DDLMT_RNG4_CNT[31..16]
1838+#define BN0_WF_MIB_TOP_M0DR7_TX_DDLMT_RNG4_CNT_SHFT 16
1839+#define BN0_WF_MIB_TOP_M0DR7_TX_DDLMT_RNG3_CNT_MASK 0x0000FFFF // TX_DDLMT_RNG3_CNT[15..0]
1840+#define BN0_WF_MIB_TOP_M0DR7_TX_DDLMT_RNG3_CNT_SHFT 0
1841+
1842+#define BN0_WF_MIB_TOP_M0DR10_MU_FAIL_PPDU_CNT_MASK 0x0000FFFF // MU_FAIL_PPDU_CNT[15..0]
1843+
1844+#define BN0_WF_MIB_TOP_M0B0SDR0_ADDR (BN0_WF_MIB_TOP_BASE + 0x100) // D100
1845+#define BN0_WF_MIB_TOP_M0B0SDR0_RTSRETRYCOUNT_MASK 0xFFFF0000 // RTSRETRYCOUNT[31..16]
1846+#define BN0_WF_MIB_TOP_M0B0SDR0_RTSRETRYCOUNT_SHFT 16
1847+#define BN0_WF_MIB_TOP_M0B0SDR0_RTSTXCOUNT_MASK 0x0000FFFF // RTSTXCOUNT[15..0]
1848+#define BN0_WF_MIB_TOP_M0B0SDR0_RTSTXCOUNT_SHFT 0
1849+#define BN0_WF_MIB_TOP_M0B0SDR1_ADDR (BN0_WF_MIB_TOP_BASE + 0x104) // D104
1850+#define BN0_WF_MIB_TOP_M0B0SDR1_ACKFAILCOUNT_MASK 0xFFFF0000 // ACKFAILCOUNT[31..16]
1851+#define BN0_WF_MIB_TOP_M0B0SDR1_ACKFAILCOUNT_SHFT 16
1852+#define BN0_WF_MIB_TOP_M0B0SDR1_BAMISSCOUNT_MASK 0x0000FFFF // BAMISSCOUNT[15..0]
1853+#define BN0_WF_MIB_TOP_M0B0SDR1_BAMISSCOUNT_SHFT 0
1854+#define BN0_WF_MIB_TOP_M0B0SDR2_ADDR (BN0_WF_MIB_TOP_BASE + 0x108) // D108
1855+#define BN0_WF_MIB_TOP_M0B0SDR2_FRAMERETRY2COUNT_MASK 0xFFFF0000 // FRAMERETRY2COUNT[31..16]
1856+#define BN0_WF_MIB_TOP_M0B0SDR2_FRAMERETRY2COUNT_SHFT 16
1857+#define BN0_WF_MIB_TOP_M0B0SDR2_FRAMERETRYCOUNT_MASK 0x0000FFFF // FRAMERETRYCOUNT[15..0]
1858+#define BN0_WF_MIB_TOP_M0B0SDR2_FRAMERETRYCOUNT_SHFT 0
1859+#define BN0_WF_MIB_TOP_M0B0SDR3_ADDR (BN0_WF_MIB_TOP_BASE + 0x10C) // D10C
1860+#define BN0_WF_MIB_TOP_M0B0SDR3_FRAMERETRY3COUNT_MASK 0x0000FFFF // FRAMERETRY3COUNT[15..0]
1861+#define BN0_WF_MIB_TOP_M0B0SDR3_FRAMERETRY3COUNT_SHFT 0
1862+#define BN0_WF_MIB_TOP_M0DR12_TX_DDLMT_RNG0_CNT_MASK 0x0000FFFF // TX_DDLMT_RNG0_CNT[15..0]
1863+
1864+
1865+#define BN0_WF_MIB_TOP_BTOCR_TX_OK_COUNT2np1_MASK 0xFFFF0000 // TX_OK_COUNT2np1[31..16]
1866+#define BN0_WF_MIB_TOP_BTOCR_TX_OK_COUNT2np1_SHFT 16
1867+#define BN0_WF_MIB_TOP_BTOCR_TX_OK_COUNT2n_MASK 0x0000FFFF // TX_OK_COUNT2n[15..0]
1868+#define BN0_WF_MIB_TOP_BTOCR_TX_OK_COUNT2n_SHFT 0
1869+
1870+#define BN0_WF_MIB_TOP_BTDCR_TX_DATA_COUNT2np1_MASK 0xFFFF0000 // TX_DATA_COUNT2np1[31..16]
1871+#define BN0_WF_MIB_TOP_BTDCR_TX_DATA_COUNT2np1_SHFT 16
1872+#define BN0_WF_MIB_TOP_BTDCR_TX_DATA_COUNT2n_MASK 0x0000FFFF // TX_DATA_COUNT2n[15..0]
1873+#define BN0_WF_MIB_TOP_BTDCR_TX_DATA_COUNT2n_SHFT 0
1874+
1875+#define BN0_WF_MIB_TOP_BROCR_RX_OK_COUNT2np1_MASK 0xFFFF0000 // RX_OK_COUNT2np1[31..16]
1876+#define BN0_WF_MIB_TOP_BROCR_RX_OK_COUNT2np1_SHFT 16
1877+#define BN0_WF_MIB_TOP_BROCR_RX_OK_COUNT2n_MASK 0x0000FFFF // RX_OK_COUNT2n[15..0]
1878+#define BN0_WF_MIB_TOP_BROCR_RX_OK_COUNT2n_SHFT 0
1879+
1880+#define BN0_WF_MIB_TOP_BRDCR_RX_DATA_COUNT2np1_MASK 0xFFFF0000 // RX_DATA_COUNT2np1[31..16]
1881+#define BN0_WF_MIB_TOP_BRDCR_RX_DATA_COUNT2np1_SHFT 16
1882+#define BN0_WF_MIB_TOP_BRDCR_RX_DATA_COUNT2n_MASK 0x0000FFFF // RX_DATA_COUNT2n[15..0]
1883+#define BN0_WF_MIB_TOP_BRDCR_RX_DATA_COUNT2n_SHFT 0
1884+
1885+#define BN0_WF_MIB_TOP_BSDR0_RTSTXCOUNT2np1_MASK 0xFFFF0000 // RTSTXCOUNT2np1[31..16]
1886+#define BN0_WF_MIB_TOP_BSDR0_RTSTXCOUNT2np1_SHFT 16
1887+#define BN0_WF_MIB_TOP_BSDR0_RTSTXCOUNT2n_MASK 0x0000FFFF // RTSTXCOUNT2n[15..0]
1888+#define BN0_WF_MIB_TOP_BSDR0_RTSTXCOUNT2n_SHFT 0
1889+
1890+#define BN0_WF_MIB_TOP_BSDR1_RTSRETRYCOUNT2np1_MASK 0xFFFF0000 // RTSRETRYCOUNT2np1[31..16]
1891+#define BN0_WF_MIB_TOP_BSDR1_RTSRETRYCOUNT2np1_SHFT 16
1892+#define BN0_WF_MIB_TOP_BSDR1_RTSRETRYCOUNT2n_MASK 0x0000FFFF // RTSRETRYCOUNT2n[15..0]
1893+#define BN0_WF_MIB_TOP_BSDR1_RTSRETRYCOUNT2n_SHFT 0
1894+
1895+#define BN0_WF_MIB_TOP_BSDR2_BAMISSCOUNT2np1_MASK 0xFFFF0000 // BAMISSCOUNT2np1[31..16]
1896+#define BN0_WF_MIB_TOP_BSDR2_BAMISSCOUNT2np1_SHFT 16
1897+#define BN0_WF_MIB_TOP_BSDR2_BAMISSCOUNT2n_MASK 0x0000FFFF // BAMISSCOUNT2n[15..0]
1898+#define BN0_WF_MIB_TOP_BSDR2_BAMISSCOUNT2n_SHFT 0
1899+
1900+#define BN0_WF_MIB_TOP_BSDR3_ACKFAILCOUNT2np1_MASK 0xFFFF0000 // ACKFAILCOUNT2np1[31..16]
1901+#define BN0_WF_MIB_TOP_BSDR3_ACKFAILCOUNT2np1_SHFT 16
1902+#define BN0_WF_MIB_TOP_BSDR3_ACKFAILCOUNT2n_MASK 0x0000FFFF // ACKFAILCOUNT2n[15..0]
1903+#define BN0_WF_MIB_TOP_BSDR3_ACKFAILCOUNT2n_SHFT 0
1904+
1905+#define BN0_WF_MIB_TOP_BSDR4_FRAMERETRYCOUNT2np1_MASK 0xFFFF0000 // FRAMERETRYCOUNT2np1[31..16]
1906+#define BN0_WF_MIB_TOP_BSDR4_FRAMERETRYCOUNT2np1_SHFT 16
1907+#define BN0_WF_MIB_TOP_BSDR4_FRAMERETRYCOUNT2n_MASK 0x0000FFFF // FRAMERETRYCOUNT2n[15..0]
1908+#define BN0_WF_MIB_TOP_BSDR4_FRAMERETRYCOUNT2n_SHFT 0
1909+
1910+#define BN0_WF_MIB_TOP_BSDR5_FRAMERETRY2COUNT2np1_MASK 0xFFFF0000 // FRAMERETRY2COUNT2np1[31..16]
1911+#define BN0_WF_MIB_TOP_BSDR5_FRAMERETRY2COUNT2np1_SHFT 16
1912+#define BN0_WF_MIB_TOP_BSDR5_FRAMERETRY2COUNT2n_MASK 0x0000FFFF // FRAMERETRY2COUNT2n[15..0]
1913+#define BN0_WF_MIB_TOP_BSDR5_FRAMERETRY2COUNT2n_SHFT 0
1914+
1915+#define BN0_WF_MIB_TOP_BSDR6_FRAMERETRY3COUNT2np1_MASK 0xFFFF0000 // FRAMERETRY3COUNT2np1[31..16]
1916+#define BN0_WF_MIB_TOP_BSDR6_FRAMERETRY3COUNT2np1_SHFT 16
1917+#define BN0_WF_MIB_TOP_BSDR6_FRAMERETRY3COUNT2n_MASK 0x0000FFFF // FRAMERETRY3COUNT2n[15..0]
1918+#define BN0_WF_MIB_TOP_BSDR6_FRAMERETRY3COUNT2n_SHFT 0
1919+/* TXD */
1920+
1921+#define MT_TXD1_ETYP BIT(15)
1922+#define MT_TXD1_VLAN BIT(14)
1923+#define MT_TXD1_RMVL BIT(13)
1924+#define MT_TXD1_AMS BIT(13)
1925+#define MT_TXD1_EOSP BIT(12)
1926+#define MT_TXD1_MRD BIT(11)
1927+
1928+#define MT_TXD7_CTXD BIT(26)
1929+#define MT_TXD7_CTXD_CNT GENMASK(25, 23)
1930+#define MT_TXD7_TAT GENMASK(9, 0)
1931+
1932+#endif
1933+#endif
1934diff --git a/mt7915/mtk_debugfs.c b/mt7915/mtk_debugfs.c
1935new file mode 100644
developerdad89a32024-04-29 14:17:17 +08001936index 0000000..62d3a99
developer73e5a572022-04-19 10:21:20 +08001937--- /dev/null
1938+++ b/mt7915/mtk_debugfs.c
developera46f6132024-03-26 14:09:54 +08001939@@ -0,0 +1,3750 @@
developer73e5a572022-04-19 10:21:20 +08001940+#include<linux/inet.h>
1941+#include "mt7915.h"
1942+#include "mt7915_debug.h"
1943+#include "mac.h"
1944+#include "mcu.h"
1945+
1946+#ifdef MTK_DEBUG
1947+#define LWTBL_IDX2BASE_ID GENMASK(14, 8)
1948+#define LWTBL_IDX2BASE_DW GENMASK(7, 2)
1949+#define LWTBL_IDX2BASE(_id, _dw) (MT_DBG_WTBL_BASE | \
1950+ FIELD_PREP(LWTBL_IDX2BASE_ID, _id) | \
1951+ FIELD_PREP(LWTBL_IDX2BASE_DW, _dw))
1952+
1953+#define UWTBL_IDX2BASE_ID GENMASK(12, 6)
1954+#define UWTBL_IDX2BASE_DW GENMASK(5, 2)
1955+#define UWTBL_IDX2BASE(_id, _dw) (MT_DBG_UWTBL_TOP_BASE | 0x2000 | \
1956+ FIELD_PREP(UWTBL_IDX2BASE_ID, _id) | \
1957+ FIELD_PREP(UWTBL_IDX2BASE_DW, _dw))
1958+
1959+#define KEYTBL_IDX2BASE_KEY GENMASK(12, 6)
1960+#define KEYTBL_IDX2BASE_DW GENMASK(5, 2)
1961+#define KEYTBL_IDX2BASE(_key, _dw) (MT_DBG_UWTBL_TOP_BASE | 0x2000 | \
1962+ FIELD_PREP(KEYTBL_IDX2BASE_KEY, _key) | \
1963+ FIELD_PREP(KEYTBL_IDX2BASE_DW, _dw))
1964+
1965+enum mt7915_wtbl_type {
1966+ WTBL_TYPE_LMAC, /* WTBL in LMAC */
1967+ WTBL_TYPE_UMAC, /* WTBL in UMAC */
1968+ WTBL_TYPE_KEY, /* Key Table */
1969+ MAX_NUM_WTBL_TYPE
1970+};
1971+
1972+static int mt7915_wtbl_read_raw(struct mt7915_dev *dev, u16 idx,
1973+ enum mt7915_wtbl_type type, u16 start_dw,
1974+ u16 len, void *buf)
1975+{
1976+ u32 *dest_cpy = (u32 *)buf;
1977+ u32 size_dw = len;
1978+ u32 src = 0;
1979+
1980+ if (!buf)
1981+ return 0xFF;
1982+
1983+ if (type == WTBL_TYPE_LMAC) {
1984+ mt76_wr(dev, MT_DBG_WTBLON_TOP_WDUCR,
1985+ FIELD_PREP(MT_DBG_WTBLON_TOP_WDUCR_GROUP, (idx >> 7)));
1986+ src = LWTBL_IDX2BASE(idx, start_dw);
1987+ } else if (type == WTBL_TYPE_UMAC) {
1988+ mt76_wr(dev, MT_DBG_UWTBL_TOP_WDUCR,
1989+ FIELD_PREP(MT_UWTBL_TOP_WDUCR_GROUP, (idx >> 7)));
1990+ src = UWTBL_IDX2BASE(idx, start_dw);
1991+ } else if (type == WTBL_TYPE_KEY) {
1992+ mt76_wr(dev, MT_DBG_UWTBL_TOP_WDUCR,
1993+ MT_UWTBL_TOP_WDUCR_TARGET |
1994+ FIELD_PREP(MT_UWTBL_TOP_WDUCR_GROUP, (idx >> 7)));
1995+ src = KEYTBL_IDX2BASE(idx, start_dw);
1996+ }
1997+
1998+ while (size_dw--) {
1999+ *dest_cpy++ = mt76_rr(dev, src);
2000+ src += 4;
2001+ };
2002+
2003+ return 0;
2004+}
2005+
2006+static int mt7915_wtbl_write_raw(struct mt7915_dev *dev, u16 idx,
2007+ enum mt7915_wtbl_type type, u16 start_dw,
2008+ u32 val)
2009+{
2010+ u32 addr = 0;
2011+
2012+ if (type == WTBL_TYPE_LMAC) {
2013+ mt76_wr(dev, MT_DBG_WTBLON_TOP_WDUCR,
2014+ FIELD_PREP(MT_WTBLON_TOP_WDUCR_GROUP, (idx >> 7)));
2015+ addr = LWTBL_IDX2BASE(idx, start_dw);
2016+ } else if (type == WTBL_TYPE_UMAC) {
2017+ mt76_wr(dev, MT_DBG_UWTBL_TOP_WDUCR,
2018+ FIELD_PREP(MT_UWTBL_TOP_WDUCR_GROUP, (idx >> 7)));
2019+ addr = UWTBL_IDX2BASE(idx, start_dw);
2020+ } else if (type == WTBL_TYPE_KEY) {
2021+ mt76_wr(dev, MT_DBG_UWTBL_TOP_WDUCR,
2022+ MT_UWTBL_TOP_WDUCR_TARGET |
2023+ FIELD_PREP(MT_UWTBL_TOP_WDUCR_GROUP, (idx >> 7)));
2024+ addr = KEYTBL_IDX2BASE(idx, start_dw);
2025+ }
2026+
2027+ mt76_wr(dev, addr, val);
2028+
2029+ return 0;
2030+}
2031+
2032+void mt7915_packet_log_to_host(struct mt7915_dev *dev, const void *data, int len, int type, int des_len)
2033+{
2034+ struct bin_debug_hdr *hdr;
2035+ char *buf;
2036+
2037+ if (len > 1500 - sizeof(*hdr))
2038+ len = 1500 - sizeof(*hdr);
2039+
2040+ buf = kzalloc(sizeof(*hdr) + len, GFP_KERNEL);
2041+ if (!buf)
2042+ return;
2043+
2044+ hdr = (struct bin_debug_hdr *)buf;
2045+ hdr->magic_num = cpu_to_le32(PKT_BIN_DEBUG_MAGIC);
2046+ hdr->serial_id = cpu_to_le16(dev->dbg.fwlog_seq++);
2047+ hdr->msg_type = cpu_to_le16(type);
2048+ hdr->len = cpu_to_le16(len);
2049+ hdr->des_len = cpu_to_le16(des_len);
2050+
2051+ memcpy(buf + sizeof(*hdr), data, len);
2052+
2053+ mt7915_debugfs_rx_log(dev, buf, sizeof(*hdr) + len);
2054+}
2055+
2056+static int
2057+mt7915_fw_debug_module_set(void *data, u64 module)
2058+{
2059+ struct mt7915_dev *dev = data;
2060+
2061+ dev->dbg.fw_dbg_module = module;
2062+ return 0;
2063+}
2064+
2065+static int
2066+mt7915_fw_debug_module_get(void *data, u64 *module)
2067+{
2068+ struct mt7915_dev *dev = data;
2069+
2070+ *module = dev->dbg.fw_dbg_module;
2071+ return 0;
2072+}
2073+
2074+DEFINE_DEBUGFS_ATTRIBUTE(fops_fw_debug_module, mt7915_fw_debug_module_get,
2075+ mt7915_fw_debug_module_set, "%lld\n");
2076+
2077+static int
2078+mt7915_fw_debug_level_set(void *data, u64 level)
2079+{
2080+ struct mt7915_dev *dev = data;
2081+
2082+ dev->dbg.fw_dbg_lv = level;
2083+ mt7915_mcu_fw_dbg_ctrl(dev, dev->dbg.fw_dbg_module, dev->dbg.fw_dbg_lv);
2084+ return 0;
2085+}
2086+
2087+static int
2088+mt7915_fw_debug_level_get(void *data, u64 *level)
2089+{
2090+ struct mt7915_dev *dev = data;
2091+
2092+ *level = dev->dbg.fw_dbg_lv;
2093+ return 0;
2094+}
2095+
2096+DEFINE_DEBUGFS_ATTRIBUTE(fops_fw_debug_level, mt7915_fw_debug_level_get,
2097+ mt7915_fw_debug_level_set, "%lld\n");
2098+
2099+#define MAX_TX_MODE 12
2100+static char *HW_TX_MODE_STR[] = {"CCK", "OFDM", "HT-Mix", "HT-GF", "VHT",
2101+ "N/A", "N/A", "N/A", "HE_SU", "HE_EXT_SU",
2102+ "HE_TRIG", "HE_MU", "N/A"};
2103+static char *HW_TX_RATE_CCK_STR[] = {"1M", "2Mlong", "5.5Mlong", "11Mlong",
2104+ "N/A", "2Mshort", "5.5Mshort", "11Mshort",
2105+ "N/A"};
2106+static char *HW_TX_RATE_OFDM_STR[] = {"6M", "9M", "12M", "18M", "24M", "36M",
2107+ "48M", "54M", "N/A"};
2108+static char *fcap_str[] = {"20MHz", "20/40MHz", "20/40/80MHz",
2109+ "20/40/80/160/80+80MHz"};
2110+
2111+static char *hw_rate_ofdm_str(u16 ofdm_idx)
2112+{
2113+ switch (ofdm_idx) {
2114+ case 11: /* 6M */
2115+ return HW_TX_RATE_OFDM_STR[0];
2116+
2117+ case 15: /* 9M */
2118+ return HW_TX_RATE_OFDM_STR[1];
2119+
2120+ case 10: /* 12M */
2121+ return HW_TX_RATE_OFDM_STR[2];
2122+
2123+ case 14: /* 18M */
2124+ return HW_TX_RATE_OFDM_STR[3];
2125+
2126+ case 9: /* 24M */
2127+ return HW_TX_RATE_OFDM_STR[4];
2128+
2129+ case 13: /* 36M */
2130+ return HW_TX_RATE_OFDM_STR[5];
2131+
2132+ case 8: /* 48M */
2133+ return HW_TX_RATE_OFDM_STR[6];
2134+
2135+ case 12: /* 54M */
2136+ return HW_TX_RATE_OFDM_STR[7];
2137+
2138+ default:
2139+ return HW_TX_RATE_OFDM_STR[8];
2140+ }
2141+}
2142+
2143+static char *hw_rate_str(u8 mode, u16 rate_idx)
2144+{
2145+ if (mode == 0)
2146+ return rate_idx < 8 ? HW_TX_RATE_CCK_STR[rate_idx] : HW_TX_RATE_CCK_STR[8];
2147+ else if (mode == 1)
2148+ return hw_rate_ofdm_str(rate_idx);
2149+ else
2150+ return "MCS";
2151+}
2152+
2153+static void parse_rate(struct seq_file *s, u16 rate_idx, u16 txrate)
2154+{
2155+ u16 txmode, mcs, nss, stbc;
2156+
2157+ txmode = FIELD_GET(GENMASK(9, 6), txrate);
2158+ mcs = FIELD_GET(GENMASK(5, 0), txrate);
2159+ nss = FIELD_GET(GENMASK(12, 10), txrate);
2160+ stbc = FIELD_GET(BIT(13), txrate);
2161+
2162+ seq_printf(s, "\tRate%d(0x%x):TxMode=%d(%s), TxRate=%d(%s), Nsts=%d, STBC=%d\n",
2163+ rate_idx + 1, txrate,
2164+ txmode, (txmode < MAX_TX_MODE ? HW_TX_MODE_STR[txmode] : HW_TX_MODE_STR[MAX_TX_MODE]),
2165+ mcs, hw_rate_str(txmode, mcs), nss, stbc);
2166+}
2167+
2168+#define LWTBL_LEN_IN_DW 32
2169+#define UWTBL_LEN_IN_DW 8
2170+#define ONE_KEY_ENTRY_LEN_IN_DW 8
developerd68e00e2022-06-01 10:59:24 +08002171+static int mt7915_sta_info(struct seq_file *s, void *data)
2172+{
2173+ struct mt7915_dev *dev = dev_get_drvdata(s->private);
2174+ u8 lwtbl[LWTBL_LEN_IN_DW*4] = {0};
2175+ u16 i = 0;
2176+
2177+ for (i=0; i < mt7915_wtbl_size(dev); i++) {
2178+ mt7915_wtbl_read_raw(dev, i, WTBL_TYPE_LMAC, 0,
2179+ LWTBL_LEN_IN_DW, lwtbl);
2180+ if (lwtbl[4] || lwtbl[5] || lwtbl[6] || lwtbl[7] || lwtbl[0] || lwtbl[1])
2181+ seq_printf(s, "wcid:%d\tAddr: %02x:%02x:%02x:%02x:%02x:%02x\n",
2182+ i, lwtbl[4], lwtbl[5], lwtbl[6], lwtbl[7], lwtbl[0], lwtbl[1]);
2183+ }
2184+
2185+ return 0;
2186+}
2187+
developer73e5a572022-04-19 10:21:20 +08002188+static int mt7915_wtbl_read(struct seq_file *s, void *data)
2189+{
2190+ struct mt7915_dev *dev = dev_get_drvdata(s->private);
2191+ u8 lwtbl[LWTBL_LEN_IN_DW*4] = {0};
2192+ int x;
2193+ u32 *addr = 0;
2194+ u32 dw_value = 0;
2195+
2196+ mt7915_wtbl_read_raw(dev, dev->wlan_idx, WTBL_TYPE_LMAC, 0,
2197+ LWTBL_LEN_IN_DW, lwtbl);
2198+ seq_printf(s, "Dump WTBL info of WLAN_IDX:%d\n", dev->wlan_idx);
2199+ seq_printf(s, "LMAC WTBL Addr: group:0x%x=0x%x addr: 0x%lx\n",
2200+ MT_DBG_WTBLON_TOP_WDUCR,
2201+ mt76_rr(dev, MT_DBG_WTBLON_TOP_WDUCR),
2202+ LWTBL_IDX2BASE(dev->wlan_idx, 0));
2203+ for (x = 0; x < LWTBL_LEN_IN_DW; x++) {
2204+ seq_printf(s, "DW%02d: %02x %02x %02x %02x\n",
2205+ x,
2206+ lwtbl[x * 4 + 3],
2207+ lwtbl[x * 4 + 2],
2208+ lwtbl[x * 4 + 1],
2209+ lwtbl[x * 4]);
2210+ }
2211+
2212+ seq_printf(s, "\n\tAddr: %02x:%02x:%02x:%02x:%02x:%02x(D0[B0~15], D1[B0~31])\n",
2213+ lwtbl[4], lwtbl[5], lwtbl[6], lwtbl[7], lwtbl[0], lwtbl[1]);
2214+
2215+ // DW0, DW1
2216+ seq_printf(s, "LWTBL DW 0/1\n\t");
2217+ addr = (u32 *)&(lwtbl[0]);
2218+ dw_value = *addr;
2219+ seq_printf(s, "MUAR_IDX:%lu/ ", FIELD_GET(GENMASK(21, 16), dw_value));
2220+ seq_printf(s, "RCA1:%ld/ ", FIELD_GET(BIT(22), dw_value));
2221+ seq_printf(s, "KID:%lu/ ", FIELD_GET(GENMASK(24, 23), dw_value));
2222+ seq_printf(s, "RCID:%ld/ ", FIELD_GET(BIT(25), dw_value));
2223+ seq_printf(s, "FROM_DS:%ld\n\t", FIELD_GET(BIT(26), dw_value));
2224+ seq_printf(s, "TO_DS:%ld/ ", FIELD_GET(BIT(27), dw_value));
2225+ seq_printf(s, "RV:%ld/ ", FIELD_GET(BIT(28), dw_value));
2226+ seq_printf(s, "RCA2:%ld/ ", FIELD_GET(BIT(29), dw_value));
2227+ seq_printf(s, "WPI_FLAG:%ld\n", FIELD_GET(BIT(30), dw_value));
2228+
2229+ // DW2
2230+ seq_printf(s, "LWTBL DW 2\n\t");
2231+ addr = (u32 *)&(lwtbl[2*4]);
2232+ dw_value = *addr;
2233+ seq_printf(s, "AID12:%lu/ ", FIELD_GET(GENMASK(11, 0), dw_value));
2234+ seq_printf(s, "SU:%ld/ ", FIELD_GET(BIT(12), dw_value));
2235+ seq_printf(s, "SPP_EN:%ld/ ", FIELD_GET(BIT(13), dw_value));
2236+ seq_printf(s, "WPI_EVEN:%ld\n\t",FIELD_GET(BIT(14), dw_value));
2237+ seq_printf(s, "CIPHER:%lu/ ", FIELD_GET(GENMASK(20, 16), dw_value));
2238+ seq_printf(s, "CIPHER_IGTK:%lu/ ",FIELD_GET(GENMASK(22, 21), dw_value));
2239+ seq_printf(s, "AAD_OM:%ld\n\t", FIELD_GET(BIT(15), dw_value));
2240+ seq_printf(s, "SW:%ld/ ", FIELD_GET(BIT(24), dw_value));
2241+ seq_printf(s, "UL:%ld/ ", FIELD_GET(BIT(25), dw_value));
2242+ seq_printf(s, "TX_POWER_SAVE:%ld\n\t", FIELD_GET(BIT(26), dw_value));
2243+ seq_printf(s, "QOS:%ld/ ", FIELD_GET(BIT(27), dw_value));
2244+ seq_printf(s, "HT:%ld/ ", FIELD_GET(BIT(28), dw_value));
2245+ seq_printf(s, "VHT:%ld/ ", FIELD_GET(BIT(29), dw_value));
2246+ seq_printf(s, "HE:%ld/ ", FIELD_GET(BIT(30), dw_value));
2247+ seq_printf(s, "MESH:%ld\n", FIELD_GET(BIT(31), dw_value));
2248+
2249+ // DW3
2250+ seq_printf(s, "LWTBL DW 3\n\t");
2251+ addr = (u32 *)&(lwtbl[3*4]);
2252+ dw_value = *addr;
2253+ seq_printf(s, "WMM_Q:%lu/ ", FIELD_GET(GENMASK(1, 0), dw_value));
2254+ seq_printf(s, "RXD_DUP_MODE:%lu\n\t", FIELD_GET(GENMASK(3, 2), dw_value));
2255+ seq_printf(s, "VLAN2ETH:%ld/ ", FIELD_GET(BIT(4), dw_value));
2256+ seq_printf(s, "BEAM_CHG:%ld/ ", FIELD_GET(BIT(5), dw_value));
2257+ seq_printf(s, "DIS_BA256:%ld\n\t", FIELD_GET(BIT(6), dw_value));
2258+ seq_printf(s, "PFMU_IDX:%lu/ ", FIELD_GET(GENMASK(15, 8), dw_value));
2259+ seq_printf(s, "ULPF_IDX:%lu\n\t", FIELD_GET(GENMASK(23, 16), dw_value));
2260+ seq_printf(s, "RIBF:%ld/ ", FIELD_GET(BIT(24), dw_value));
2261+ seq_printf(s, "ULPF:%ld\n\t", FIELD_GET(BIT(25), dw_value));
2262+ seq_printf(s, "IGN_FBK:%ld/ ", FIELD_GET(BIT(26), dw_value));
2263+ seq_printf(s, "TBF:%ld/ ", FIELD_GET(BIT(29), dw_value));
2264+ seq_printf(s, "TBF_VHT:%ld/ ", FIELD_GET(BIT(30), dw_value));
2265+ seq_printf(s, "TBF_HE:%ld\n", FIELD_GET(BIT(31), dw_value));
2266+
2267+ // DW4
2268+ seq_printf(s, "LWTBL DW 4\n\t");
2269+ addr = (u32 *)&(lwtbl[4*4]);
2270+ dw_value = *addr;
2271+ seq_printf(s, "ANT_ID_STS0:%lu/ ", FIELD_GET(GENMASK(2, 0), dw_value));
2272+ seq_printf(s, "STS1:%lu/ ", FIELD_GET(GENMASK(5, 3), dw_value));
2273+ seq_printf(s, "STS2:%lu/ ", FIELD_GET(GENMASK(8, 6), dw_value));
2274+ seq_printf(s, "STS3:%lu\n\t", FIELD_GET(GENMASK(11, 9), dw_value));
2275+ seq_printf(s, "ANT_ID_STS4:%lu/ ", FIELD_GET(GENMASK(14, 12), dw_value));
2276+ seq_printf(s, "STS5:%lu/ ", FIELD_GET(GENMASK(17, 15), dw_value));
2277+ seq_printf(s, "STS6:%ld/ ", FIELD_GET(GENMASK(20, 18), dw_value));
2278+ seq_printf(s, "STS7:%lu\n\t", FIELD_GET(GENMASK(23, 21), dw_value));
2279+ seq_printf(s, "CASCAD:%ld/ ", FIELD_GET(BIT(24), dw_value));
2280+ seq_printf(s, "LDPC_HT:%ld/ ", FIELD_GET(BIT(25), dw_value));
2281+ seq_printf(s, "LDPC_VHT:%ld/ ", FIELD_GET(BIT(26), dw_value));
2282+ seq_printf(s, "LDPC_HE:%ld\n\t", FIELD_GET(BIT(27), dw_value));
2283+ seq_printf(s, "DIS_RHTR:%ld/ ", FIELD_GET(BIT(28), dw_value));
2284+ seq_printf(s, "ALL_ACK:%ld/ ", FIELD_GET(BIT(29), dw_value));
2285+ seq_printf(s, "DROP:%ld/ ", FIELD_GET(BIT(30), dw_value));
2286+ seq_printf(s, "ACK_EN:%ld\n", FIELD_GET(BIT(31), dw_value));
2287+
2288+ // DW5
2289+ seq_printf(s, "LWTBL DW 5\n\t");
2290+ addr = (u32 *)&(lwtbl[5*4]);
2291+ dw_value = *addr;
2292+ seq_printf(s, "AF:%lu/ ", FIELD_GET(GENMASK(2, 0), dw_value));
2293+ seq_printf(s, "AF_HE:%lu/ ", FIELD_GET(GENMASK(4, 3), dw_value));
2294+ seq_printf(s, "RTS:%ld/ ", FIELD_GET(BIT(5), dw_value));
2295+ seq_printf(s, "SMPS:%ld/ ", FIELD_GET(BIT(6), dw_value));
2296+ seq_printf(s, "DYN_BW:%ld\n\t", FIELD_GET(BIT(7), dw_value));
2297+ seq_printf(s, "MMSS:%lu/ ", FIELD_GET(GENMASK(10, 8), dw_value));
2298+ seq_printf(s, "USR:%ld/ ", FIELD_GET(BIT(11), dw_value));
2299+ seq_printf(s, "SR_RATE:%lu/ ", FIELD_GET(GENMASK(14, 12), dw_value));
2300+ seq_printf(s, "SR_ABORT:%ld\n\t", FIELD_GET(BIT(15), dw_value));
2301+ seq_printf(s, "TX_POWER_OFFSET:%lu/ ", FIELD_GET(GENMASK(21, 16), dw_value));
2302+ seq_printf(s, "WTBL_MPDU_SIZE:%lu\n\t", FIELD_GET(GENMASK(23, 22), dw_value));
2303+ seq_printf(s, "PE:%lu/ ", FIELD_GET(GENMASK(25, 24), dw_value));
2304+ seq_printf(s, "DOPPL:%ld/ ", FIELD_GET(BIT(26), dw_value));
2305+ seq_printf(s, "TXOP_PS_CAP:%ld/ ", FIELD_GET(BIT(27), dw_value));
2306+ seq_printf(s, "DONOT_UPDATE_I_PSM:%ld\n\t", FIELD_GET(BIT(28), dw_value));
2307+ seq_printf(s, "I_PSM:%ld/ ", FIELD_GET(BIT(29), dw_value));
2308+ seq_printf(s, "PSM:%ld/ ", FIELD_GET(BIT(30), dw_value));
2309+ seq_printf(s, "SKIP_TX:%ld\n", FIELD_GET(BIT(31), dw_value));
2310+
2311+ // DW6
2312+ seq_printf(s, "LWTBL DW 6\n\t");
2313+ seq_printf(s, "TID 0/1/2/3/4/5/6/7 BA_WIN_SIZE:");
2314+ addr = (u32 *)&(lwtbl[6*4]);
2315+ dw_value = *addr;
2316+ seq_printf(s, "%lu/ ", FIELD_GET(GENMASK(3, 0), dw_value));
2317+ seq_printf(s, "%lu/ ", FIELD_GET(GENMASK(7, 4), dw_value));
2318+ seq_printf(s, "%lu/ ", FIELD_GET(GENMASK(11, 8), dw_value));
2319+ seq_printf(s, "%lu/ ", FIELD_GET(GENMASK(15, 12), dw_value));
2320+ seq_printf(s, "%lu/ ", FIELD_GET(GENMASK(19, 16), dw_value));
2321+ seq_printf(s, "%lu/ ", FIELD_GET(GENMASK(23, 20), dw_value));
2322+ seq_printf(s, "%lu/ ", FIELD_GET(GENMASK(27, 24), dw_value));
2323+ seq_printf(s, "%lu\n", FIELD_GET(GENMASK(31, 28), dw_value));
2324+
2325+ // DW7
2326+ seq_printf(s, "LWTBL DW 7\n\t");
2327+ addr = (u32 *)&(lwtbl[7*4]);
2328+ dw_value = *addr;
2329+ seq_printf(s, "CBRN:%lu/ ", FIELD_GET(GENMASK(2, 0), dw_value));
2330+ seq_printf(s, "DBNSS_EN:%ld/ ", FIELD_GET(BIT(3), dw_value));
2331+ seq_printf(s, "BAF_EN:%ld/ ", FIELD_GET(BIT(4), dw_value));
2332+ seq_printf(s, "RDGBA:%ld\n\t", FIELD_GET(BIT(5), dw_value));
2333+ seq_printf(s, "RDG:%ld/ ", FIELD_GET(BIT(6), dw_value));
2334+ seq_printf(s, "SPE_IDX:%lu/ ", FIELD_GET(GENMASK(11, 7), dw_value));
2335+ seq_printf(s, "G2:%ld/ ", FIELD_GET(BIT(12), dw_value));
2336+ seq_printf(s, "G4:%ld/ ", FIELD_GET(BIT(13), dw_value));
2337+ seq_printf(s, "G8:%ld/ ", FIELD_GET(BIT(14), dw_value));
2338+ seq_printf(s, "G16:%ld\n\t", FIELD_GET(BIT(15), dw_value));
2339+ seq_printf(s, "G2_LTF:%lu/ ", FIELD_GET(GENMASK(17, 16), dw_value));
2340+ seq_printf(s, "G4_LTF:%lu/ ", FIELD_GET(GENMASK(19, 18), dw_value));
2341+ seq_printf(s, "G8_LTF:%lu/ ", FIELD_GET(GENMASK(21, 20), dw_value));
2342+ seq_printf(s, "G16_LTF:%lu\n\t", FIELD_GET(GENMASK(23, 22), dw_value));
2343+ seq_printf(s, "G2_HE:%lu/ ", FIELD_GET(GENMASK(25, 24), dw_value));
2344+ seq_printf(s, "G4_HE:%lu/ ", FIELD_GET(GENMASK(27, 27), dw_value));
2345+ seq_printf(s, "G8_HE:%lu/ ", FIELD_GET(GENMASK(29, 28), dw_value));
2346+ seq_printf(s, "G16_HE:%lu\n", FIELD_GET(GENMASK(31, 30), dw_value));
2347+
2348+ // DW8
2349+ seq_printf(s, "LWTBL DW 8\n\t");
2350+ addr = (u32 *)&(lwtbl[8*4]);
2351+ dw_value = *addr;
2352+ seq_printf(s, "FAIL_CNT_AC0:%lu/ ", FIELD_GET(GENMASK(4, 0), dw_value));
2353+ seq_printf(s, "AC1:%lu/ ", FIELD_GET(GENMASK(9, 5), dw_value));
2354+ seq_printf(s, "AC2:%lu/ ", FIELD_GET(GENMASK(14, 10), dw_value));
2355+ seq_printf(s, "AC3:%lu\n\t", FIELD_GET(GENMASK(19, 15), dw_value));
2356+ seq_printf(s, "PARTIAL_AID:%lu/ ", FIELD_GET(GENMASK(28, 20), dw_value));
2357+ seq_printf(s, "CHK_PER:%lu\n", FIELD_GET(BIT(31), dw_value));
2358+
2359+ // DW9
2360+ seq_printf(s, "LWTBL DW 9\n\t");
2361+ addr = (u32 *)&(lwtbl[9*4]);
2362+ dw_value = *addr;
2363+ seq_printf(s, "RX_AVG_MPDU:%lu/ ", FIELD_GET(GENMASK(13, 0), dw_value));
2364+ seq_printf(s, "PRITX_SW_MODE:%ld/ ", FIELD_GET(BIT(16), dw_value));
2365+ seq_printf(s, "PRITX_PLR:%ld\n\t", FIELD_GET(BIT(17), dw_value));
2366+ seq_printf(s, "PRITX_DCM:%ld/ ", FIELD_GET(BIT(18), dw_value));
2367+ seq_printf(s, "PRITX_ER160:%ld/ ", FIELD_GET(BIT(19), dw_value));
2368+ seq_printf(s, "PRITX_ERSU:%lu\n\t", FIELD_GET(BIT(20), dw_value));
2369+ seq_printf(s, "MPDU_FAIL_CNT:%lu/ ", FIELD_GET(GENMASK(25, 23), dw_value));
2370+ seq_printf(s, "MPDU_OK_CNT:%lu/ ", FIELD_GET(GENMASK(28, 26), dw_value));
2371+ seq_printf(s, "RATE_IDX:%lu\n\t", FIELD_GET(GENMASK(31, 29), dw_value));
2372+ seq_printf(s, "FCAP:%s\n", fcap_str[FIELD_GET(GENMASK(22, 21), dw_value)]);
2373+
2374+ // DW10
2375+ seq_printf(s, "LWTBL DW 10\n");
2376+ addr = (u32 *)&(lwtbl[10*4]);
2377+ dw_value = *addr;
2378+ parse_rate(s, 0, FIELD_GET(GENMASK(13, 0), dw_value));
2379+ parse_rate(s, 1, FIELD_GET(GENMASK(29, 16), dw_value));
2380+ // DW11
2381+ seq_printf(s, "LWTBL DW 11\n");
2382+ addr = (u32 *)&(lwtbl[11*4]);
2383+ dw_value = *addr;
2384+ parse_rate(s, 2, FIELD_GET(GENMASK(13, 0), dw_value));
2385+ parse_rate(s, 3, FIELD_GET(GENMASK(29, 16), dw_value));
2386+ // DW12
2387+ seq_printf(s, "LWTBL DW 12\n");
2388+ addr = (u32 *)&(lwtbl[12*4]);
2389+ dw_value = *addr;
2390+ parse_rate(s, 4, FIELD_GET(GENMASK(13, 0), dw_value));
2391+ parse_rate(s, 5, FIELD_GET(GENMASK(29, 16), dw_value));
2392+ // DW13
2393+ seq_printf(s, "LWTBL DW 13\n");
2394+ addr = (u32 *)&(lwtbl[13*4]);
2395+ dw_value = *addr;
2396+ parse_rate(s, 6, FIELD_GET(GENMASK(13, 0), dw_value));
2397+ parse_rate(s, 7, FIELD_GET(GENMASK(29, 16), dw_value));
2398+
2399+ //DW28
2400+ seq_printf(s, "LWTBL DW 28\n\t");
2401+ addr = (u32 *)&(lwtbl[28*4]);
2402+ dw_value = *addr;
2403+ seq_printf(s, "OM_INFO:%lu/ ", FIELD_GET(GENMASK(11, 0), dw_value));
2404+ seq_printf(s, "OM_RXD_DUP_MODE:%u\n\t", !!(dw_value & BIT(12)) );
2405+
2406+ //DW29
2407+ seq_printf(s, "LWTBL DW 29\n");
2408+ addr = (u32 *)&(lwtbl[29*4]);
2409+ dw_value = *addr;
2410+ seq_printf(s, "USER_RSSI:%lu/ ", FIELD_GET(GENMASK(8, 0), dw_value));
2411+ seq_printf(s, "USER_SNR:%lu/ ", FIELD_GET(GENMASK(14, 9), dw_value));
2412+ seq_printf(s, "RAPID_REACTION_RATE:%lu/ ", FIELD_GET(GENMASK(26, 16), dw_value));
2413+ seq_printf(s, "HT_AMSDU(Read Only):%u/ ", !!(dw_value & BIT(30)) );
2414+ seq_printf(s, "AMSDU_CROSS_LG(Read Only):%u\n\t ", !!(dw_value & BIT(31)));
2415+
2416+ //DW30
2417+ seq_printf(s, "LWTBL DW 30\n\t");
2418+ addr = (u32 *)&(lwtbl[30*4]);
2419+ dw_value = *addr;
2420+ seq_printf(s, "RCPI 0:%lu/ ", FIELD_GET(GENMASK(7, 0), dw_value));
2421+ seq_printf(s, "RCPI 1:%lu/ ", FIELD_GET(GENMASK(15, 8), dw_value));
2422+ seq_printf(s, "RCPI 2:%lu/ ", FIELD_GET(GENMASK(23, 16), dw_value));
2423+ seq_printf(s, "RCPI 3:%lu\n\t", FIELD_GET(GENMASK(31, 24), dw_value));
2424+
2425+ //DW31
2426+ seq_printf(s, "LWTBL DW 31\n\t");
2427+ addr = (u32 *)&(lwtbl[31*4]);
2428+ dw_value = *addr;
2429+ seq_printf(s, "RCPI 4:%lu/ ", FIELD_GET(GENMASK(7, 0), dw_value));
2430+ seq_printf(s, "RCPI 5:%lu/ ", FIELD_GET(GENMASK(15, 8), dw_value));
2431+ seq_printf(s, "RCPI 6:%lu/ ", FIELD_GET(GENMASK(23, 16), dw_value));
2432+ seq_printf(s, "RCPI 7:%lu\n\t", FIELD_GET(GENMASK(31, 24), dw_value));
2433+
2434+ return 0;
2435+}
2436+
2437+static int mt7915_uwtbl_read(struct seq_file *s, void *data)
2438+{
2439+ struct mt7915_dev *dev = dev_get_drvdata(s->private);
2440+ u8 uwtbl[UWTBL_LEN_IN_DW * 4] = {0};
2441+ u8 keytbl[ONE_KEY_ENTRY_LEN_IN_DW*4] = {0};
2442+ int x;
2443+ u32 *addr = 0;
2444+ u32 dw_value = 0;
2445+ u32 amsdu_len = 0;
2446+ u32 u2SN = 0;
2447+ u16 keyloc0, keyloc1;
2448+
2449+ mt7915_wtbl_read_raw(dev, dev->wlan_idx, WTBL_TYPE_UMAC, 0,
2450+ UWTBL_LEN_IN_DW, uwtbl);
2451+ seq_printf(s, "Dump WTBL info of WLAN_IDX:%d\n", dev->wlan_idx);
2452+ seq_printf(s, "UMAC WTBL Addr: group:0x%x=0x%x addr: 0x%lx\n",
developerd8126d12023-02-17 11:50:45 +08002453+ MT_DBG_UWTBL_TOP_WDUCR,
2454+ mt76_rr(dev, MT_DBG_UWTBL_TOP_BASE),
developer73e5a572022-04-19 10:21:20 +08002455+ UWTBL_IDX2BASE(dev->wlan_idx, 0));
2456+ for (x = 0; x < UWTBL_LEN_IN_DW; x++) {
2457+ seq_printf(s, "DW%02d: %02x %02x %02x %02x\n",
2458+ x,
2459+ uwtbl[x * 4 + 3],
2460+ uwtbl[x * 4 + 2],
2461+ uwtbl[x * 4 + 1],
2462+ uwtbl[x * 4]);
2463+ }
2464+
2465+ /* UMAC WTBL DW 0 */
2466+ seq_printf(s, "\nUWTBL PN\n\t");
2467+ addr = (u32 *)&(uwtbl[0]);
2468+ dw_value = *addr;
2469+ seq_printf(s, "PN0:%lu/ ", FIELD_GET(GENMASK(7, 0), dw_value));
2470+ seq_printf(s, "PN1:%lu/ ", FIELD_GET(GENMASK(15, 8), dw_value));
2471+ seq_printf(s, "PN2:%lu\n\t", FIELD_GET(GENMASK(23, 16), dw_value));
2472+ seq_printf(s, "PN3:%lu/ ", FIELD_GET(GENMASK(31, 24), dw_value));
2473+
2474+ addr = (u32 *)&(uwtbl[1 * 4]);
2475+ dw_value = *addr;
2476+ seq_printf(s, "PN4:%lu/ ", FIELD_GET(GENMASK(7, 0), dw_value));
2477+ seq_printf(s, "PN5:%lu\n", FIELD_GET(GENMASK(15, 8), dw_value));
2478+
2479+ /* UMAC WTBL DW SN part */
2480+ seq_printf(s, "\nUWTBL SN\n");
2481+ addr = (u32 *)&(uwtbl[2 * 4]);
2482+ dw_value = *addr;
2483+ seq_printf(s, "TID0_AC0_SN:%lu\n", FIELD_GET(GENMASK(11, 0), dw_value));
2484+ seq_printf(s, "TID1_AC1_SN:%lu\n", FIELD_GET(GENMASK(23, 12), dw_value));
2485+
2486+ u2SN = FIELD_GET(GENMASK(31, 24), dw_value);
2487+ addr = (u32 *)&(uwtbl[3 * 4]);
2488+ dw_value = *addr;
2489+ u2SN |= FIELD_GET(GENMASK(3, 0), dw_value);
2490+ seq_printf(s, "TID2_AC2_SN:%u\n", u2SN);
2491+ seq_printf(s, "TID3_AC3_SN:%lu\n", FIELD_GET(GENMASK(15, 4), dw_value));
2492+ seq_printf(s, "TID4_SN:%lu\n", FIELD_GET(GENMASK(27, 16), dw_value));
2493+
2494+ u2SN = FIELD_GET(GENMASK(31, 28), dw_value);
2495+ addr = (u32 *)&(uwtbl[4 * 4]);
2496+ dw_value = *addr;
2497+ u2SN |= FIELD_GET(GENMASK(7, 0), dw_value);
2498+ seq_printf(s, "TID5_SN:%u\n", u2SN);
2499+ seq_printf(s, "TID6_SN:%lu\n", FIELD_GET(GENMASK(19, 8), dw_value));
2500+ seq_printf(s, "TID7_SN:%lu\n", FIELD_GET(GENMASK(31, 20), dw_value));
2501+
2502+ addr = (u32 *)&(uwtbl[1 * 4]);
2503+ dw_value = *addr;
2504+ seq_printf(s, "COM_SN:%lu\n", FIELD_GET(GENMASK(27, 16), dw_value));
2505+
2506+ /* UMAC WTBL DW 0 */
2507+ seq_printf(s, "\nUWTBL others\n");
2508+
2509+ addr = (u32 *)&(uwtbl[5 * 4]);
2510+ dw_value = *addr;
2511+ keyloc0 = FIELD_GET(GENMASK(10, 0), dw_value);
2512+ keyloc1 = FIELD_GET(GENMASK(26, 16), dw_value);
2513+ seq_printf(s, "\tKey Loc 1/2:%lu/%lu\n",
2514+ FIELD_GET(GENMASK(10, 0), dw_value),
2515+ FIELD_GET(GENMASK(26, 16), dw_value));
2516+ seq_printf(s, "\tUWTBL_QOS:%lu\n", FIELD_GET(BIT(27), dw_value));
2517+ seq_printf(s, "\tUWTBL_HT_VHT_HE:%lu\n", FIELD_GET(BIT(28), dw_value));
2518+
2519+ addr = (u32 *)&(uwtbl[6*4]);
2520+ dw_value = *addr;
2521+ seq_printf(s, "\tHW AMSDU Enable:%lu\n", FIELD_GET(BIT(9), dw_value));
2522+
2523+ amsdu_len = FIELD_GET(GENMASK(5, 0), dw_value);
2524+ if (amsdu_len == 0)
2525+ seq_printf(s, "\tHW AMSDU Len:invalid (WTBL value=0x%x)\n", amsdu_len);
2526+ else if (amsdu_len == 1)
2527+ seq_printf(s, "\tHW AMSDU Len:%d~%d (WTBL value=0x%x)\n",
2528+ 1,
2529+ 255,
2530+ amsdu_len);
2531+ else
2532+ seq_printf(s, "\tHW AMSDU Len:%d~%d (WTBL value=0x%x)\n",
2533+ 256 * (amsdu_len - 1),
2534+ 256 * (amsdu_len - 1) + 255,
2535+ amsdu_len
2536+ );
2537+ seq_printf(s, "\tHW AMSDU Num:%lu (WTBL value=0x%lx)\n",
2538+ FIELD_GET(GENMASK(8, 6), dw_value) + 1,
2539+ FIELD_GET(GENMASK(8, 6), dw_value));
2540+
2541+ /* Parse KEY link */
2542+ seq_printf(s, "\n\tkeyloc0:%d\n", keyloc0);
2543+ if(keyloc0 != GENMASK(10, 0)) {
2544+ mt7915_wtbl_read_raw(dev, keyloc0, WTBL_TYPE_KEY,
2545+ 0, ONE_KEY_ENTRY_LEN_IN_DW, keytbl);
2546+ seq_printf(s, "KEY WTBL Addr: group:0x%x=0x%x addr: 0x%lx\n",
developerd8126d12023-02-17 11:50:45 +08002547+ MT_DBG_UWTBL_TOP_WDUCR,
2548+ mt76_rr(dev, MT_DBG_UWTBL_TOP_BASE),
developer73e5a572022-04-19 10:21:20 +08002549+ KEYTBL_IDX2BASE(keyloc0, 0));
2550+
2551+ for (x = 0; x < ONE_KEY_ENTRY_LEN_IN_DW; x++) {
2552+ seq_printf(s, "DW%02d: %02x %02x %02x %02x\n",
2553+ x,
2554+ keytbl[x * 4 + 3],
2555+ keytbl[x * 4 + 2],
2556+ keytbl[x * 4 + 1],
2557+ keytbl[x * 4]);
2558+ }
2559+ }
2560+
2561+ seq_printf(s, "\n\tkeyloc1:%d\n", keyloc1);
2562+ if(keyloc1 != GENMASK(26, 16)) {
2563+ mt7915_wtbl_read_raw(dev, keyloc1, WTBL_TYPE_KEY,
2564+ 0, ONE_KEY_ENTRY_LEN_IN_DW, keytbl);
2565+ seq_printf(s, "KEY WTBL Addr: group:0x%x=0x%x addr: 0x%lx\n",
developerd8126d12023-02-17 11:50:45 +08002566+ MT_DBG_UWTBL_TOP_WDUCR,
2567+ mt76_rr(dev, MT_DBG_UWTBL_TOP_BASE),
developer73e5a572022-04-19 10:21:20 +08002568+ KEYTBL_IDX2BASE(keyloc1, 0));
2569+
2570+ for (x = 0; x < ONE_KEY_ENTRY_LEN_IN_DW; x++) {
2571+ seq_printf(s, "DW%02d: %02x %02x %02x %02x\n",
2572+ x,
2573+ keytbl[x * 4 + 3],
2574+ keytbl[x * 4 + 2],
2575+ keytbl[x * 4 + 1],
2576+ keytbl[x * 4]);
2577+ }
2578+ }
2579+ return 0;
2580+}
2581+
2582+static void
2583+dump_dma_tx_ring_info(struct seq_file *s, struct mt7915_dev *dev, char *str, u32 ring_base)
2584+{
2585+ u32 base, cnt, cidx, didx, queue_cnt;
2586+
2587+ base= mt76_rr(dev, ring_base);
2588+ cnt = mt76_rr(dev, ring_base + 4);
2589+ cidx = mt76_rr(dev, ring_base + 8);
2590+ didx = mt76_rr(dev, ring_base + 12);
2591+ queue_cnt = (cidx >= didx) ? (cidx - didx) : (cidx - didx + cnt);
2592+
2593+ seq_printf(s, "%20s %10x %10x %10x %10x %10x\n", str, base, cnt, cidx, didx, queue_cnt);
2594+}
2595+
2596+static void
2597+dump_dma_rx_ring_info(struct seq_file *s, struct mt7915_dev *dev, char *str, u32 ring_base)
2598+{
2599+ u32 base, cnt, cidx, didx, queue_cnt;
2600+
2601+ base= mt76_rr(dev, ring_base);
2602+ cnt = mt76_rr(dev, ring_base + 4);
2603+ cidx = mt76_rr(dev, ring_base + 8);
2604+ didx = mt76_rr(dev, ring_base + 12);
2605+ queue_cnt = (didx > cidx) ? (didx - cidx - 1) : (didx - cidx + cnt - 1);
2606+
2607+ seq_printf(s, "%20s %10x %10x %10x %10x %10x\n", str, base, cnt, cidx, didx, queue_cnt);
2608+}
2609+
2610+static void
2611+mt7915_show_host_dma_info(struct seq_file *s, struct mt7915_dev *dev)
2612+{
2613+ u32 sys_ctrl[10] = {};
2614+
2615+ /* HOST DMA */
2616+ sys_ctrl[0] = mt76_rr(dev, MT_DBG_INT_SOURCE_CSR);
2617+ sys_ctrl[1] = mt76_rr(dev, MT_DBG_INT_MASK_CSR);
2618+ sys_ctrl[2] = mt76_rr(dev, MT_DBG_WFDMA0_INT_SOURCE_CSR);
2619+ sys_ctrl[3] = mt76_rr(dev, MT_DBG_WFDMA0_INT_MASK_CSR);
2620+ sys_ctrl[4] = mt76_rr(dev, MT_DBG_WFDMA1_INT_SOURCE_CSR);
2621+ sys_ctrl[5] = mt76_rr(dev, MT_DBG_WFDMA1_INT_MASK_CSR);
2622+ sys_ctrl[6] = mt76_rr(dev, MT_DBG_WFDMA0_GLO_CFG);
2623+ sys_ctrl[7] = mt76_rr(dev, MT_DBG_WFDMA1_GLO_CFG);
2624+ seq_printf(s, "HOST_DMA Configuration\n");
2625+ seq_printf(s, "%10s %10s %10s %10s %10s %10s\n",
2626+ "DMA", "IntCSR", "IntMask", "Glocfg", "Tx/RxEn", "Tx/RxBusy");
2627+ seq_printf(s, "%10s %10x %10x\n",
2628+ "Merge", sys_ctrl[0], sys_ctrl[1]);
2629+ seq_printf(s, "%10s %10x %10x %10x %4lx/%5lx %4lx/%5lx\n",
2630+ "DMA0", sys_ctrl[2], sys_ctrl[3], sys_ctrl[6],
2631+ FIELD_GET(MT_DBG_WFDMA0_GLO_CFG_TX_DMA_EN, sys_ctrl[6]),
2632+ FIELD_GET(MT_DBG_WFDMA0_GLO_CFG_RX_DMA_EN, sys_ctrl[6]),
2633+ FIELD_GET(MT_DBG_WFDMA0_GLO_CFG_TX_BUSY_MASK, sys_ctrl[6]),
2634+ FIELD_GET(MT_DBG_WFDMA0_GLO_CFG_RX_BUSY_MASK, sys_ctrl[6]));
2635+
2636+ seq_printf(s, "%10s %10x %10x %10x %4lx/%5lx %4lx/%5lx\n",
2637+ "DMA1", sys_ctrl[4], sys_ctrl[5], sys_ctrl[7],
2638+ FIELD_GET(MT_DBG_WFDMA1_GLO_CFG_TX_DMA_EN, sys_ctrl[7]),
2639+ FIELD_GET(MT_DBG_WFDMA1_GLO_CFG_RX_DMA_EN, sys_ctrl[7]),
2640+ FIELD_GET(MT_DBG_WFDMA1_GLO_CFG_TX_BUSY_MASK, sys_ctrl[7]),
2641+ FIELD_GET(MT_DBG_WFDMA1_GLO_CFG_RX_BUSY_MASK, sys_ctrl[7]));
2642+
2643+ sys_ctrl[0] = mt76_rr(dev, MT_DBG_INT1_SOURCE_CSR);
2644+ sys_ctrl[1] = mt76_rr(dev, MT_DBG_INT1_MASK_CSR);
2645+ sys_ctrl[2] = mt76_rr(dev, MT_DBG_WFDMA0_PCIE1_INT_SOURCE_CSR);
2646+ sys_ctrl[3] = mt76_rr(dev, MT_DBG_WFDMA0_PCIE1_INT_MASK_CSR);
2647+ sys_ctrl[4] = mt76_rr(dev, MT_DBG_WFDMA1_PCIE1_INT_SOURCE_CSR);
2648+ sys_ctrl[5] = mt76_rr(dev, MT_DBG_WFDMA1_PCIE1_INT_MASK_CSR);
2649+ sys_ctrl[6] = mt76_rr(dev, MT_DBG_WFDMA0_PCIE1_GLO_CFG);
2650+ sys_ctrl[7] = mt76_rr(dev, MT_DBG_WFDMA1_PCIE1_GLO_CFG);
2651+ seq_printf(s, "%10s %10x %10x\n",
2652+ "MergeP1", sys_ctrl[0], sys_ctrl[1]);
2653+ seq_printf(s, "%10s %10x %10x %10x %4lx/%5lx %4lx/%5lx\n",
2654+ "DMA0P1", sys_ctrl[2], sys_ctrl[3], sys_ctrl[6],
2655+ FIELD_GET(MT_DBG_WFDMA0_PCIE1_GLO_CFG_TX_DMA_EN, sys_ctrl[6]),
2656+ FIELD_GET(MT_DBG_WFDMA0_PCIE1_GLO_CFG_RX_DMA_EN, sys_ctrl[6]),
2657+ FIELD_GET(MT_DBG_WFDMA0_PCIE1_GLO_CFG_TX_BUSY_MASK, sys_ctrl[6]),
2658+ FIELD_GET(MT_DBG_WFDMA0_PCIE1_GLO_CFG_RX_BUSY_MASK, sys_ctrl[6]));
2659+ seq_printf(s, "%10s %10x %10x %10x %4lx/%5lx %4lx/%5lx\n",
2660+ "DMA1P1", sys_ctrl[4], sys_ctrl[5], sys_ctrl[7],
2661+ FIELD_GET(MT_DBG_WFDMA0_PCIE1_GLO_CFG_TX_DMA_EN, sys_ctrl[7]),
2662+ FIELD_GET(MT_DBG_WFDMA0_PCIE1_GLO_CFG_RX_DMA_EN, sys_ctrl[7]),
2663+ FIELD_GET(MT_DBG_WFDMA0_PCIE1_GLO_CFG_TX_BUSY_MASK, sys_ctrl[7]),
2664+ FIELD_GET(MT_DBG_WFDMA0_PCIE1_GLO_CFG_RX_BUSY_MASK, sys_ctrl[7]));
2665+
2666+ seq_printf(s, "HOST_DMA0 Ring Configuration\n");
2667+ seq_printf(s, "%20s %10s %10s %10s %10s %10s\n",
2668+ "Name", "Base", "Cnt", "CIDX", "DIDX", "QCnt");
2669+ dump_dma_rx_ring_info(s, dev, "R0:Data0(MAC2H)", MT_DBG_RX_DATA_RING_CTRL(0));
2670+ dump_dma_rx_ring_info(s, dev, "R1:Data1(MAC2H)", MT_DBG_RX_DATA_RING_CTRL(1));
2671+
2672+ seq_printf(s, "HOST_DMA0 PCIe 1 Ring Configuration\n");
2673+ seq_printf(s, "%20s %10s %10s %10s %10s %10s\n",
2674+ "Name", "Base", "Cnt", "CIDX", "DIDX", "QCnt");
2675+ dump_dma_rx_ring_info(s, dev, "R1:Data1(MAC2H)", MT_DBG_WFDMA0_PCIE1_RX1_CTRL0);
2676+
2677+ seq_printf(s, "HOST_DMA1 Ring Configuration\n");
2678+ seq_printf(s, "%20s %10s %10s %10s %10s %10s\n",
2679+ "Name", "Base", "Cnt", "CIDX", "DIDX", "QCnt");
2680+ dump_dma_tx_ring_info(s, dev, "T16:FWDL", MT_DBG_TX_RING_CTRL(0));
2681+ dump_dma_tx_ring_info(s, dev, "T17:Cmd(H2WM)", MT_DBG_TX_RING_CTRL(1));
developer23c22342023-01-09 13:57:39 +08002682+ if (mtk_wed_device_active(&dev->mt76.mmio.wed)) {
2683+ dump_dma_tx_ring_info(s, dev, "T18:TXD0(H2WA)", MT_DBG_WFDMA_WED_TX_CTRL(0));
2684+ dump_dma_tx_ring_info(s, dev, "T19:TXD1(H2WA)", MT_DBG_WFDMA_WED_TX_CTRL(1));
2685+ } else {
2686+ dump_dma_tx_ring_info(s, dev, "T18:TXD0(H2WA)", MT_DBG_TX_RING_CTRL(2));
2687+ dump_dma_tx_ring_info(s, dev, "T19:TXD1(H2WA)", MT_DBG_TX_RING_CTRL(3));
2688+ }
developer73e5a572022-04-19 10:21:20 +08002689+ dump_dma_tx_ring_info(s, dev, "T20:Cmd(H2WA)", MT_DBG_TX_RING_CTRL(4));
2690+ dump_dma_rx_ring_info(s, dev, "R0:Event(WM2H)", MT_DBG_RX_EVENT_RING_CTRL(0));
developer23c22342023-01-09 13:57:39 +08002691+ if (mtk_wed_device_active(&dev->mt76.mmio.wed))
2692+ dump_dma_rx_ring_info(s, dev, "R1:TxDone(WA2H)", MT_DBG_WFDMA_WED_RX_CTRL(1));
2693+ else
2694+ dump_dma_rx_ring_info(s, dev, "R1:Event0(WA2H)", MT_DBG_RX_EVENT_RING_CTRL(1));
developer73e5a572022-04-19 10:21:20 +08002695+ dump_dma_rx_ring_info(s, dev, "R2:Event1(WA2H)", MT_DBG_RX_EVENT_RING_CTRL(2));
2696+
2697+ seq_printf(s, "HOST_DMA1 PCIe 1 Ring Configuration\n");
2698+ seq_printf(s, "%20s %10s %10s %10s %10s %10s\n",
2699+ "Name", "Base", "Cnt", "CIDX", "DIDX", "QCnt");
2700+ dump_dma_tx_ring_info(s, dev, "T19:TXD1(H2WA)", MT_DBG_WFDMA1_PCIE1_TX19_CTRL0);
2701+ dump_dma_rx_ring_info(s, dev, "R2:Event1(WA2H)", MT_DBG_WFDMA1_PCIE1_RX2_CTRL0);
2702+}
2703+
2704+static void
2705+mt7915_show_mcu_dma_info(struct seq_file *s, struct mt7915_dev *dev)
2706+{
2707+ u32 sys_ctrl[9] = {};
2708+
2709+ /* MCU DMA information */
2710+ sys_ctrl[0] = mt76_rr(dev, WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_ADDR);
2711+ sys_ctrl[1] = mt76_rr(dev, WF_WFDMA_MCU_DMA0_HOST_INT_STA_ADDR);
2712+ sys_ctrl[2] = mt76_rr(dev, WF_WFDMA_MCU_DMA0_HOST_INT_ENA_ADDR);
2713+
2714+ sys_ctrl[3] = mt76_rr(dev, WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_ADDR);
2715+ sys_ctrl[4] = mt76_rr(dev, WF_WFDMA_MCU_DMA1_HOST_INT_STA_ADDR);
2716+ sys_ctrl[5] = mt76_rr(dev, WF_WFDMA_MCU_DMA1_HOST_INT_ENA_ADDR);
2717+ sys_ctrl[6] = mt76_rr(dev, WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_ADDR);
2718+ sys_ctrl[7] = mt76_rr(dev, WF_WFDMA_MCU_DMA1_PCIE1_HOST_INT_STA_ADDR);
2719+ sys_ctrl[8] = mt76_rr(dev, WF_WFDMA_MCU_DMA1_PCIE1_HOST_INT_ENA_ADDR);
2720+
2721+ seq_printf(s, "MCU_DMA Configuration\n");
2722+ seq_printf(s, "%10s %10s %10s %10s %10s %10s\n",
2723+ "DMA", "IntCSR", "IntMask", "Glocfg", "Tx/RxEn", "Tx/RxBusy");
2724+ seq_printf(s, "%10s %10x %10x %10x %4x/%5x %4x/%5x\n",
2725+ "DMA0", sys_ctrl[1], sys_ctrl[2], sys_ctrl[0],
2726+ (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,
2727+ (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,
2728+ (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,
2729+ (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);
2730+
2731+ seq_printf(s, "%10s %10x %10x %10x %4x/%5x %4x/%5x\n",
2732+ "DMA1", sys_ctrl[4], sys_ctrl[5], sys_ctrl[3],
2733+ (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,
2734+ (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,
2735+ (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,
2736+ (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);
2737+ seq_printf(s, "%10s %10x %10x %10x %4x/%5x %4x/%5x\n",
2738+ "DMA1P1", sys_ctrl[7], sys_ctrl[8], sys_ctrl[6],
2739+ (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,
2740+ (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,
2741+ (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,
2742+ (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);
2743+
2744+ seq_printf(s, "MCU_DMA0 Ring Configuration\n");
2745+ seq_printf(s, "%20s %10s %10s %10s %10s %10s\n",
2746+ "Name", "Base", "Cnt", "CIDX", "DIDX", "QCnt");
2747+ dump_dma_tx_ring_info(s, dev, "T0:TXD(WM2MAC)", WF_WFDMA_MCU_DMA0_WPDMA_TX_RING0_CTRL0_ADDR);
2748+ dump_dma_tx_ring_info(s, dev, "T1:TXCMD(WM2MAC)", WF_WFDMA_MCU_DMA0_WPDMA_TX_RING1_CTRL0_ADDR);
2749+ dump_dma_tx_ring_info(s, dev, "T2:TXD(WA2MAC)", WF_WFDMA_MCU_DMA0_WPDMA_TX_RING2_CTRL0_ADDR);
2750+ dump_dma_rx_ring_info(s, dev, "R0:Data(MAC2WM)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING0_CTRL0_ADDR);
2751+ dump_dma_rx_ring_info(s, dev, "R1:TxDone(MAC2WM)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING1_CTRL0_ADDR);
2752+ dump_dma_rx_ring_info(s, dev, "R2:SPL(MAC2WM)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING2_CTRL0_ADDR);
2753+ dump_dma_rx_ring_info(s, dev, "R3:TxDone(MAC2WA)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING3_CTRL0_ADDR);
2754+ dump_dma_rx_ring_info(s, dev, "R4:TXS(MAC2WA)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING4_CTRL0_ADDR);
2755+
2756+ seq_printf(s, "MCU_DMA1 Ring Configuration\n");
2757+ seq_printf(s, "%20s %10s %10s %10s %10s %10s\n",
2758+ "Name", "Base", "Cnt", "CIDX", "DIDX", "QCnt");
2759+ dump_dma_tx_ring_info(s, dev, "T0:Event(WM2H)", WF_WFDMA_MCU_DMA1_WPDMA_TX_RING0_CTRL0_ADDR);
2760+ dump_dma_tx_ring_info(s, dev, "T1:Event0(WA2H)", WF_WFDMA_MCU_DMA1_WPDMA_TX_RING1_CTRL0_ADDR);
2761+ dump_dma_tx_ring_info(s, dev, "T2:Event1(WA2H)", WF_WFDMA_MCU_DMA1_WPDMA_TX_RING2_CTRL0_ADDR);
2762+ dump_dma_rx_ring_info(s, dev, "R0:FWDL", WF_WFDMA_MCU_DMA1_WPDMA_RX_RING0_CTRL0_ADDR);
2763+ dump_dma_rx_ring_info(s, dev, "R1:Cmd(H2WM)", WF_WFDMA_MCU_DMA1_WPDMA_RX_RING1_CTRL0_ADDR);
2764+ dump_dma_rx_ring_info(s, dev, "R2:TXD0(H2WA)", WF_WFDMA_MCU_DMA1_WPDMA_RX_RING2_CTRL0_ADDR);
2765+ dump_dma_rx_ring_info(s, dev, "R3:TXD1(H2WA)", WF_WFDMA_MCU_DMA1_WPDMA_RX_RING3_CTRL0_ADDR);
2766+ dump_dma_rx_ring_info(s, dev, "R4:Cmd(H2WA)", WF_WFDMA_MCU_DMA1_WPDMA_RX_RING4_CTRL0_ADDR);
2767+
2768+ seq_printf(s, "MCU_DMA1 PCIe 1 Ring Configuration\n");
2769+ seq_printf(s, "%20s %10s %10s %10s %10s %10s\n",
2770+ "Name", "Base", "Cnt", "CIDX", "DIDX", "QCnt");
2771+ dump_dma_tx_ring_info(s, dev, "T2:Event1(WA2H)", WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_TX_RING2_CTRL0_ADDR);
2772+ dump_dma_rx_ring_info(s, dev, "R3:TXD1(H2WA)", WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_RX_RING3_CTRL0_ADDR);
2773+}
2774+
2775+static void
2776+mt7986_show_host_dma_info(struct seq_file *s, struct mt7915_dev *dev)
2777+{
2778+ u32 sys_ctrl[5] = {};
2779+
2780+ /* HOST DMA */
2781+ sys_ctrl[0] = mt76_rr(dev, MT_DBG_INT_SOURCE_CSR);
2782+ sys_ctrl[1] = mt76_rr(dev, MT_DBG_INT_MASK_CSR);
2783+ sys_ctrl[2] = mt76_rr(dev, MT_DBG_WFDMA0_INT_SOURCE_CSR);
2784+ sys_ctrl[3] = mt76_rr(dev, MT_DBG_WFDMA0_INT_MASK_CSR);
2785+ sys_ctrl[4] = mt76_rr(dev, MT_DBG_WFDMA0_GLO_CFG);
2786+
2787+ seq_printf(s, "HOST_DMA Configuration\n");
2788+ seq_printf(s, "%10s %10s %10s %10s %10s %10s\n",
2789+ "DMA", "IntCSR", "IntMask", "Glocfg", "Tx/RxEn", "Tx/RxBusy");
2790+ seq_printf(s, "%10s %10x %10x\n",
2791+ "Merge", sys_ctrl[0], sys_ctrl[1]);
2792+ seq_printf(s, "%10s %10x %10x %10x %4lx/%5lx %4lx/%5lx\n",
2793+ "DMA0", sys_ctrl[2], sys_ctrl[3], sys_ctrl[4],
2794+ FIELD_GET(MT_DBG_WFDMA_HOST_DMA0_GLO_CFG_TX_DMA_EN_MASK, sys_ctrl[4]),
2795+ FIELD_GET(MT_DBG_WFDMA_HOST_DMA0_GLO_CFG_RX_DMA_EN_MASK, sys_ctrl[4]),
2796+ FIELD_GET(MT_DBG_WFDMA_HOST_DMA0_GLO_CFG_TX_DMA_BUSY_MASK, sys_ctrl[4]),
2797+ FIELD_GET(MT_DBG_WFDMA_HOST_DMA0_GLO_CFG_RX_DMA_BUSY_MASK, sys_ctrl[4]));
2798+
2799+
2800+ seq_printf(s, "HOST_DMA0 Ring Configuration\n");
2801+ seq_printf(s, "%20s %10s %10s %10s %10s %10s\n",
2802+ "Name", "Base", "Cnt", "CIDX", "DIDX", "QCnt");
2803+ dump_dma_tx_ring_info(s, dev, "T16:FWDL", MT_DBG_TX_RING_CTRL(0));
2804+ dump_dma_tx_ring_info(s, dev, "T17:Cmd(H2WM)", MT_DBG_TX_RING_CTRL(1));
developer23c22342023-01-09 13:57:39 +08002805+
2806+ if (is_mt7916(&dev->mt76) && mtk_wed_device_active(&dev->mt76.mmio.wed)) {
2807+ dump_dma_tx_ring_info(s, dev, "T18:TXD0(H2WA)", MT_DBG_WFDMA_WED_TX_CTRL(0));
2808+ dump_dma_tx_ring_info(s, dev, "T19:TXD1(H2WA)", MT_DBG_WFDMA_WED_TX_CTRL(1));
2809+ } else {
2810+ dump_dma_tx_ring_info(s, dev, "T18:TXD0(H2WA)", MT_DBG_TX_RING_CTRL(2));
2811+ dump_dma_tx_ring_info(s, dev, "T19:TXD1(H2WA)", MT_DBG_TX_RING_CTRL(3));
2812+ }
2813+
developer73e5a572022-04-19 10:21:20 +08002814+ dump_dma_tx_ring_info(s, dev, "T20:Cmd(H2WA)", MT_DBG_TX_RING_CTRL(4));
2815+ dump_dma_rx_ring_info(s, dev, "R0:Event(WM2H)", MT_DBG_RX_DATA_RING_CTRL(0));
2816+ dump_dma_rx_ring_info(s, dev, "R1:Event(WA2H)", MT_DBG_RX_EVENT_RING_CTRL(1));
developer23c22342023-01-09 13:57:39 +08002817+ if (is_mt7916(&dev->mt76) && mtk_wed_device_active(&dev->mt76.mmio.wed))
2818+ dump_dma_rx_ring_info(s, dev, "R2:TxDone(WA2H)", MT_DBG_WFDMA_WED_RX_CTRL(1));
2819+ else
2820+ dump_dma_rx_ring_info(s, dev, "R2:TxDone(WA2H)", MT_DBG_RX_EVENT_RING_CTRL(2));
developer73e5a572022-04-19 10:21:20 +08002821+ dump_dma_rx_ring_info(s, dev, "R3:TxDone1(WA2H)", MT_DBG_RX_EVENT_RING_CTRL(3));
2822+ dump_dma_rx_ring_info(s, dev, "R4:Data0(MAC2H)", MT_DBG_RX_DATA_RING_CTRL(0));
2823+ dump_dma_rx_ring_info(s, dev, "R5:Data1(MAC2H)", MT_DBG_RX_DATA_RING_CTRL(1));
2824+}
2825+
2826+static void
2827+mt7986_show_mcu_dma_info(struct seq_file *s, struct mt7915_dev *dev)
2828+{
2829+ u32 sys_ctrl[3] = {};
2830+
2831+ /* MCU DMA information */
2832+ sys_ctrl[0] = mt76_rr(dev, WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_ADDR);
2833+ sys_ctrl[1] = mt76_rr(dev, WF_WFDMA_MCU_DMA0_HOST_INT_STA_ADDR);
2834+ sys_ctrl[2] = mt76_rr(dev, WF_WFDMA_MCU_DMA0_HOST_INT_ENA_ADDR);
2835+
2836+ seq_printf(s, "MCU_DMA Configuration\n");
2837+ seq_printf(s, "%10s %10s %10s %10s %10s %10s\n",
2838+ "DMA", "IntCSR", "IntMask", "Glocfg", "Tx/RxEn", "Tx/RxBusy");
2839+ seq_printf(s, "%10s %10x %10x %10x %4x/%5x %4x/%5x\n",
2840+ "DMA0", sys_ctrl[1], sys_ctrl[2], sys_ctrl[0],
2841+ (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,
2842+ (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,
2843+ (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,
2844+ (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);
2845+
2846+ seq_printf(s, "MCU_DMA0 Ring Configuration\n");
2847+ seq_printf(s, "%22s %10s %10s %10s %10s %10s\n",
2848+ "Name", "Base", "Cnt", "CIDX", "DIDX", "QCnt");
2849+ dump_dma_tx_ring_info(s, dev, "T0:Event (WM2H)", WF_WFDMA_MCU_DMA0_WPDMA_TX_RING0_CTRL0_ADDR);
2850+ dump_dma_tx_ring_info(s, dev, "T1:Event (WA2H)", WF_WFDMA_MCU_DMA0_WPDMA_TX_RING1_CTRL0_ADDR);
2851+ dump_dma_tx_ring_info(s, dev, "T2:TxDone (WA2H)", WF_WFDMA_MCU_DMA0_WPDMA_TX_RING2_CTRL0_ADDR);
2852+ dump_dma_tx_ring_info(s, dev, "T3:TxDone1 (WA2H)", WF_WFDMA_MCU_DMA0_WPDMA_TX_RING3_CTRL0_ADDR);
2853+ dump_dma_tx_ring_info(s, dev, "T4:TXD (WM2MAC)", WF_WFDMA_MCU_DMA0_WPDMA_TX_RING4_CTRL0_ADDR);
2854+ dump_dma_tx_ring_info(s, dev, "T5:TXCMD (WM2MAC)", WF_WFDMA_MCU_DMA0_WPDMA_TX_RING5_CTRL0_ADDR);
2855+ dump_dma_tx_ring_info(s, dev, "T6:TXD (WA2MAC)", WF_WFDMA_MCU_DMA0_WPDMA_TX_RING6_CTRL0_ADDR);
2856+ dump_dma_rx_ring_info(s, dev, "R0:FWDL", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING0_CTRL0_ADDR);
2857+ dump_dma_rx_ring_info(s, dev, "R1:Cmd (H2WM)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING1_CTRL0_ADDR);
2858+ dump_dma_rx_ring_info(s, dev, "R2:TXD (H2WA)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING2_CTRL0_ADDR);
2859+ dump_dma_rx_ring_info(s, dev, "R3:TXD1 (H2WA)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING3_CTRL0_ADDR);
2860+ dump_dma_rx_ring_info(s, dev, "R4:Cmd (H2WA)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING4_CTRL0_ADDR);
2861+ dump_dma_rx_ring_info(s, dev, "R5:Data (MAC2WM)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING5_CTRL0_ADDR);
2862+ dump_dma_rx_ring_info(s, dev, "R6:TxDone/STS (MAC2WM)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING6_CTRL0_ADDR);
2863+ dump_dma_rx_ring_info(s, dev, "R7:RPT (MAC2WM)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING7_CTRL0_ADDR);
2864+ dump_dma_rx_ring_info(s, dev, "R8:TxDone/STS (MAC2WA)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING8_CTRL0_ADDR);
2865+ dump_dma_rx_ring_info(s, dev, "R9:Data1 (MAC2WM)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING9_CTRL0_ADDR);
2866+
2867+}
2868+
2869+static void
2870+mt7915_show_dma_info(struct seq_file *s, struct mt7915_dev *dev)
2871+{
2872+ u32 sys_ctrl[10] = {};
2873+
2874+ if(is_mt7915(&dev->mt76)) {
2875+ mt7915_show_host_dma_info(s, dev);
2876+ mt7915_show_mcu_dma_info(s, dev);
2877+ } else {
2878+ mt7986_show_host_dma_info(s, dev);
2879+ mt7986_show_mcu_dma_info(s, dev);
2880+ }
2881+
2882+ /* MEM DMA information */
2883+ sys_ctrl[0] = mt76_rr(dev, WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_ADDR);
2884+ sys_ctrl[1] = mt76_rr(dev, WF_WFDMA_MEM_DMA_HOST_INT_STA_ADDR);
2885+ sys_ctrl[2] = mt76_rr(dev, WF_WFDMA_MEM_DMA_HOST_INT_ENA_ADDR);
2886+
2887+ seq_printf(s, "MEM_DMA Configuration\n");
2888+ seq_printf(s, "%10s %10s %10s %10s %10s %10s\n",
2889+ "DMA", "IntCSR", "IntMask", "Glocfg", "Tx/RxEn", "Tx/RxBusy");
2890+ seq_printf(s, "%10s %10x %10x %10x %4x/%5x %4x/%5x\n",
2891+ "MEM", sys_ctrl[1], sys_ctrl[2], sys_ctrl[0],
2892+ (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,
2893+ (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,
2894+ (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,
2895+ (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);
2896+
2897+ seq_printf(s, "MEM_DMA Ring Configuration\n");
2898+ seq_printf(s, "%20s %10s %10s %10s %10s %10s\n",
2899+ "Name", "Base", "Cnt", "CIDX", "DIDX", "QCnt");
2900+ dump_dma_tx_ring_info(s, dev, "T0:CmdEvent(WM2WA)", WF_WFDMA_MEM_DMA_WPDMA_TX_RING0_CTRL0_ADDR);
2901+ dump_dma_tx_ring_info(s, dev, "T1:CmdEvent(WA2WM)", WF_WFDMA_MEM_DMA_WPDMA_TX_RING1_CTRL0_ADDR);
2902+ dump_dma_rx_ring_info(s, dev, "R0:CmdEvent(WM2WA)", WF_WFDMA_MEM_DMA_WPDMA_RX_RING0_CTRL0_ADDR);
2903+ dump_dma_rx_ring_info(s, dev, "R1:CmdEvent(WA2WM)", WF_WFDMA_MEM_DMA_WPDMA_RX_RING1_CTRL0_ADDR);
2904+}
2905+
2906+static int mt7915_trinfo_read(struct seq_file *s, void *data)
2907+{
2908+ struct mt7915_dev *dev = dev_get_drvdata(s->private);
2909+ const struct hif_pci_tx_ring_desc *tx_ring_layout;
2910+ const struct hif_pci_rx_ring_desc *rx_ring_layout;
developer23c22342023-01-09 13:57:39 +08002911+ struct mtk_wed_device *wed = &dev->mt76.mmio.wed;
developer73e5a572022-04-19 10:21:20 +08002912+ u32 tx_ring_num, rx_ring_num;
2913+ u32 tbase[5], tcnt[5];
2914+ u32 tcidx[5], tdidx[5];
2915+ u32 rbase[6], rcnt[6];
2916+ u32 rcidx[6], rdidx[6];
2917+ int idx;
developer23c22342023-01-09 13:57:39 +08002918+ bool flags = false;
developer73e5a572022-04-19 10:21:20 +08002919+
2920+ if(is_mt7915(&dev->mt76)) {
2921+ tx_ring_layout = &mt7915_tx_ring_layout[0];
2922+ rx_ring_layout = &mt7915_rx_ring_layout[0];
2923+ tx_ring_num = ARRAY_SIZE(mt7915_tx_ring_layout);
2924+ rx_ring_num = ARRAY_SIZE(mt7915_rx_ring_layout);
2925+ } else {
2926+ tx_ring_layout = &mt7986_tx_ring_layout[0];
2927+ rx_ring_layout = &mt7986_rx_ring_layout[0];
2928+ tx_ring_num = ARRAY_SIZE(mt7986_tx_ring_layout);
2929+ rx_ring_num = ARRAY_SIZE(mt7986_rx_ring_layout);
2930+ }
2931+
2932+ for (idx = 0; idx < tx_ring_num; idx++) {
developer23c22342023-01-09 13:57:39 +08002933+ if (mtk_wed_device_active(wed) &&
2934+ (tx_ring_layout[idx].ring_attr == HIF_TX_DATA)) {
2935+ struct mt76_phy *phy = dev->mt76.phys[MT_BAND0];
2936+ struct mt76_phy *ext_phy = dev->mt76.phys[MT_BAND1];
2937+ struct mt76_queue *q;
2938+
2939+ tbase[idx] = tcnt[idx] = tcidx[idx] = tdidx[idx] = 0;
2940+
2941+ if (!phy)
2942+ continue;
2943+
2944+ if (flags && !ext_phy)
2945+ continue;
2946+
2947+ if (flags && ext_phy)
2948+ phy = ext_phy;
2949+
2950+ q = phy->q_tx[0];
2951+
2952+ if (q->wed_regs) {
2953+ tbase[idx] = mtk_wed_device_reg_read(wed, q->wed_regs);
2954+ tcnt[idx] = mtk_wed_device_reg_read(wed, q->wed_regs + 0x04);
2955+ tcidx[idx] = mtk_wed_device_reg_read(wed, q->wed_regs + 0x08);
2956+ tdidx[idx] = mtk_wed_device_reg_read(wed, q->wed_regs + 0x0c);
2957+ }
2958+
2959+ flags = true;
2960+ } else {
2961+ tbase[idx] = mt76_rr(dev, MT_DBG_TX_RING_CTRL(idx));
2962+ tcnt[idx] = mt76_rr(dev, MT_DBG_TX_RING_CTRL(idx) + 0x04);
2963+ tcidx[idx] = mt76_rr(dev, MT_DBG_TX_RING_CTRL(idx) + 0x08);
2964+ tdidx[idx] = mt76_rr(dev, MT_DBG_TX_RING_CTRL(idx) + 0x0c);}
developer73e5a572022-04-19 10:21:20 +08002965+ }
2966+
2967+ for (idx = 0; idx < rx_ring_num; idx++) {
developer23c22342023-01-09 13:57:39 +08002968+ if (rx_ring_layout[idx].ring_attr == HIF_RX_DATA) {
2969+ if (mtk_wed_device_active(wed) && mtk_wed_get_rx_capa(wed)) {
2970+ struct mt76_queue *q = &dev->mt76.q_rx[MT_RXQ_MAIN];
2971+
2972+ rbase[idx] = rcnt[idx] = rcidx[idx] = rdidx[idx] = 0;
2973+
2974+ if (idx == 1)
2975+ q = &dev->mt76.q_rx[MT_RXQ_BAND1];
2976+
2977+ if (q->wed_regs) {
2978+ rbase[idx] = mtk_wed_device_reg_read(wed, q->wed_regs);
2979+ rcnt[idx] = mtk_wed_device_reg_read(wed, q->wed_regs + 0x04);
2980+ rcidx[idx] = mtk_wed_device_reg_read(wed, q->wed_regs + 0x08);
2981+ rdidx[idx] = mtk_wed_device_reg_read(wed, q->wed_regs + 0x0c);
2982+ }
2983+ } else {
2984+ rbase[idx] = mt76_rr(dev, MT_DBG_RX_DATA_RING_CTRL(idx));
2985+ rcnt[idx] = mt76_rr(dev, MT_DBG_RX_DATA_RING_CTRL(idx) + 0x04);
2986+ rcidx[idx] = mt76_rr(dev, MT_DBG_RX_DATA_RING_CTRL(idx) + 0x08);
2987+ rdidx[idx] = mt76_rr(dev, MT_DBG_RX_DATA_RING_CTRL(idx) + 0x0c);
2988+ }
developer73e5a572022-04-19 10:21:20 +08002989+ } else {
developer23c22342023-01-09 13:57:39 +08002990+ if (mtk_wed_device_active(wed) && rx_ring_layout[idx].flags) {
2991+ struct mt76_queue *q = &dev->mt76.q_rx[MT_RXQ_MAIN_WA];
2992+
2993+ if (is_mt7915(&dev->mt76))
2994+ q = &dev->mt76.q_rx[MT_RXQ_MCU_WA];
2995+
2996+ rbase[idx] = mtk_wed_device_reg_read(wed, q->wed_regs);
2997+ rcnt[idx] = mtk_wed_device_reg_read(wed, q->wed_regs + 0x04);
2998+ rcidx[idx] = mtk_wed_device_reg_read(wed, q->wed_regs + 0x08);
2999+ rdidx[idx] = mtk_wed_device_reg_read(wed, q->wed_regs + 0x0c);
3000+
3001+ } else {
3002+ rbase[idx] = mt76_rr(dev, MT_DBG_RX_EVENT_RING_CTRL(idx - 2));
3003+ rcnt[idx] = mt76_rr(dev, MT_DBG_RX_EVENT_RING_CTRL(idx - 2) + 0x04);
3004+ rcidx[idx] = mt76_rr(dev, MT_DBG_RX_EVENT_RING_CTRL(idx - 2) + 0x08);
3005+ rdidx[idx] = mt76_rr(dev, MT_DBG_RX_EVENT_RING_CTRL(idx - 2) + 0x0c);
3006+ }
developer73e5a572022-04-19 10:21:20 +08003007+ }
3008+ }
3009+
3010+ seq_printf(s, "=================================================\n");
3011+ seq_printf(s, "TxRing Configuration\n");
3012+ seq_printf(s, "%4s %10s %8s %1s %6s %6s %6s %6s\n",
3013+ "Idx", "Attr", "Reg", "Base", "Cnt", "CIDX", "DIDX",
3014+ "QCnt");
3015+ for (idx = 0; idx < tx_ring_num; idx++) {
3016+ u32 queue_cnt;
3017+
3018+ queue_cnt = (tcidx[idx] >= tdidx[idx]) ?
3019+ (tcidx[idx] - tdidx[idx]) :
3020+ (tcidx[idx] - tdidx[idx] + tcnt[idx]);
3021+ seq_printf(s, "%4d %8s %8x %10x %6x %6x %6x %6x\n",
3022+ idx, tx_ring_layout[idx].ring_info,
3023+ MT_DBG_TX_RING_CTRL(idx), tbase[idx],
3024+ tcnt[idx], tcidx[idx], tdidx[idx], queue_cnt);
3025+ }
3026+
3027+ seq_printf(s, "RxRing Configuration\n");
3028+ seq_printf(s, "%4s %10s %8s %10s %6s %6s %6s %6s\n",
3029+ "Idx", "Attr", "Reg", "Base", "Cnt", "CIDX", "DIDX",
3030+ "QCnt");
3031+
3032+ for (idx = 0; idx < rx_ring_num; idx++) {
3033+ u32 queue_cnt;
3034+
3035+ queue_cnt = (rdidx[idx] > rcidx[idx]) ?
3036+ (rdidx[idx] - rcidx[idx] - 1) :
3037+ (rdidx[idx] - rcidx[idx] + rcnt[idx] - 1);
3038+ seq_printf(s, "%4d %8s %8x %10x %6x %6x %6x %6x\n",
3039+ idx, rx_ring_layout[idx].ring_info,
3040+ (idx < 2) ? MT_DBG_RX_DATA_RING_CTRL(idx): MT_DBG_RX_EVENT_RING_CTRL(idx - 2),
3041+ rbase[idx], rcnt[idx], rcidx[idx], rdidx[idx], queue_cnt);
3042+ }
3043+
3044+ mt7915_show_dma_info(s, dev);
3045+ return 0;
3046+}
3047+
3048+static int mt7915_drr_info(struct seq_file *s, void *data)
3049+{
3050+#define DL_AC_START 0x00
3051+#define DL_AC_END 0x0F
3052+#define UL_AC_START 0x10
3053+#define UL_AC_END 0x1F
3054+
3055+ struct mt7915_dev *dev = dev_get_drvdata(s->private);
3056+ u32 drr_sta_status[16];
3057+ u32 drr_ctrl_def_val = 0x80220000, drr_ctrl_val = 0;
3058+ bool is_show = false;
3059+ int idx, sta_line = 0, sta_no = 0, max_sta_line = (mt7915_wtbl_size(dev) + 31) / 32;
3060+ seq_printf(s, "DRR Table STA Info:\n");
3061+
3062+ for (idx = DL_AC_START; idx <= DL_AC_END; idx++) {
3063+ is_show = true;
3064+ drr_ctrl_val = (drr_ctrl_def_val | idx);
3065+ mt76_wr(dev, MT_DBG_PLE_DRR_TAB_CTRL, drr_ctrl_val);
3066+ drr_sta_status[0] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA0);
3067+ drr_sta_status[1] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA1);
3068+ drr_sta_status[2] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA2);
3069+ drr_sta_status[3] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA3);
3070+ drr_sta_status[4] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA4);
3071+ drr_sta_status[5] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA5);
3072+ drr_sta_status[6] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA6);
3073+ drr_sta_status[7] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA7);
3074+
3075+ if (is_mt7915(&dev->mt76) && max_sta_line > 8) {
3076+ drr_ctrl_val = (drr_ctrl_def_val | idx | 1 << 10);
3077+ mt76_wr(dev, MT_DBG_PLE_DRR_TAB_CTRL, drr_ctrl_val);
3078+ drr_sta_status[8] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA0);
3079+ drr_sta_status[9] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA1);
3080+ drr_sta_status[10] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA2);
3081+ drr_sta_status[11] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA3);
3082+ drr_sta_status[12] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA4);
3083+ drr_sta_status[13] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA5);
3084+ drr_sta_status[14] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA6);
3085+ drr_sta_status[15] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA7);
3086+ }
3087+ if (!is_mt7915(&dev->mt76))
3088+ max_sta_line = 8;
3089+
3090+ for (sta_line = 0; sta_line < max_sta_line; sta_line++) {
3091+ if (drr_sta_status[sta_line] > 0) {
3092+ for (sta_no = 0; sta_no < 32; sta_no++) {
3093+ if (((drr_sta_status[sta_line] & (0x1 << sta_no)) >> sta_no)) {
3094+ if (is_show) {
3095+ seq_printf(s, "\n DL AC%02d Queue Non-Empty STA:\n", idx);
3096+ is_show = false;
3097+ }
3098+ seq_printf(s, "%d ", sta_no + (sta_line * 32));
3099+ }
3100+ }
3101+ }
3102+ }
3103+ }
3104+
3105+ for (idx = UL_AC_START; idx <= UL_AC_END; idx++) {
3106+ is_show = true;
3107+ drr_ctrl_val = (drr_ctrl_def_val | idx);
3108+ mt76_wr(dev, MT_DBG_PLE_DRR_TAB_CTRL, drr_ctrl_val);
3109+ drr_sta_status[0] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA0);
3110+ drr_sta_status[1] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA1);
3111+ drr_sta_status[2] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA2);
3112+ drr_sta_status[3] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA3);
3113+ drr_sta_status[4] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA4);
3114+ drr_sta_status[5] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA5);
3115+ drr_sta_status[6] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA6);
3116+ drr_sta_status[7] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA7);
3117+
3118+ if (is_mt7915(&dev->mt76) && max_sta_line > 8) {
3119+ drr_ctrl_val = (drr_ctrl_def_val | idx | 1 << 10);
3120+ mt76_wr(dev, MT_DBG_PLE_DRR_TAB_CTRL, drr_ctrl_val);
3121+ drr_sta_status[8] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA0);
3122+ drr_sta_status[9] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA1);
3123+ drr_sta_status[10] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA2);
3124+ drr_sta_status[11] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA3);
3125+ drr_sta_status[12] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA4);
3126+ drr_sta_status[13] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA5);
3127+ drr_sta_status[14] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA6);
3128+ drr_sta_status[15] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA7);
3129+ }
3130+
3131+ if (!is_mt7915(&dev->mt76))
3132+ max_sta_line = 8;
3133+
3134+ for (sta_line = 0; sta_line < max_sta_line; sta_line++) {
3135+ if (drr_sta_status[sta_line] > 0) {
3136+ for (sta_no = 0; sta_no < 32; sta_no++) {
3137+ if (((drr_sta_status[sta_line] & (0x1 << sta_no)) >> sta_no)) {
3138+ if (is_show) {
3139+ seq_printf(s, "\n UL AC%02d Queue Non-Empty STA:\n", idx);
3140+ is_show = false;
3141+ }
3142+ seq_printf(s, "%d ", sta_no + (sta_line * 32));
3143+ }
3144+ }
3145+ }
3146+ }
3147+ }
3148+
3149+ for (idx = DL_AC_START; idx <= DL_AC_END; idx++) {
3150+ drr_ctrl_def_val = 0x80420000;
3151+ drr_ctrl_val = (drr_ctrl_def_val | idx);
3152+ mt76_wr(dev, MT_DBG_PLE_DRR_TAB_CTRL, drr_ctrl_val);
3153+ drr_sta_status[0] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA0);
3154+ drr_sta_status[1] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA1);
3155+ drr_sta_status[2] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA2);
3156+ drr_sta_status[3] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA3);
3157+ drr_sta_status[4] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA4);
3158+ drr_sta_status[5] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA5);
3159+ drr_sta_status[6] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA6);
3160+ drr_sta_status[7] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA7);
3161+
3162+ if (is_mt7915(&dev->mt76) && max_sta_line > 8) {
3163+ drr_ctrl_val = (drr_ctrl_def_val | idx | 1<<10);
3164+ mt76_wr(dev, MT_DBG_PLE_DRR_TAB_CTRL, drr_ctrl_val);
3165+ drr_sta_status[8] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA0);
3166+ drr_sta_status[9] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA1);
3167+ drr_sta_status[10] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA2);
3168+ drr_sta_status[11] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA3);
3169+ drr_sta_status[12] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA4);
3170+ drr_sta_status[13] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA5);
3171+ drr_sta_status[14] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA6);
3172+ drr_sta_status[15] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA7);
3173+ }
3174+
3175+ seq_printf(s, "\nBSSGrp[%d]:\n", idx);
3176+ if (!is_mt7915(&dev->mt76))
3177+ max_sta_line = 8;
3178+
3179+ for (sta_line = 0; sta_line < max_sta_line; sta_line++) {
3180+ seq_printf(s, "0x%08x ", drr_sta_status[sta_line]);
3181+
3182+ if ((sta_line % 4) == 3)
3183+ seq_printf(s, "\n");
3184+ }
3185+ }
3186+
3187+ return 0;
3188+}
3189+
developerd68e00e2022-06-01 10:59:24 +08003190+#define CR_NUM_OF_AC 17
developer73e5a572022-04-19 10:21:20 +08003191+
3192+typedef enum _ENUM_UMAC_PORT_T {
3193+ ENUM_UMAC_HIF_PORT_0 = 0,
3194+ ENUM_UMAC_CPU_PORT_1 = 1,
3195+ ENUM_UMAC_LMAC_PORT_2 = 2,
3196+ ENUM_PLE_CTRL_PSE_PORT_3 = 3,
3197+ ENUM_UMAC_PSE_PLE_PORT_TOTAL_NUM = 4
3198+} ENUM_UMAC_PORT_T, *P_ENUM_UMAC_PORT_T;
3199+
3200+/* N9 MCU QUEUE LIST */
3201+typedef enum _ENUM_UMAC_CPU_P_QUEUE_T {
3202+ ENUM_UMAC_CTX_Q_0 = 0,
3203+ ENUM_UMAC_CTX_Q_1 = 1,
3204+ ENUM_UMAC_CTX_Q_2 = 2,
3205+ ENUM_UMAC_CTX_Q_3 = 3,
3206+ ENUM_UMAC_CRX = 0,
3207+ ENUM_UMAC_CIF_QUEUE_TOTAL_NUM = 4
3208+} ENUM_UMAC_CPU_P_QUEUE_T, *P_ENUM_UMAC_CPU_P_QUEUE_T;
3209+
3210+/* LMAC PLE TX QUEUE LIST */
3211+typedef enum _ENUM_UMAC_LMAC_PLE_TX_P_QUEUE_T {
3212+ ENUM_UMAC_LMAC_PLE_TX_Q_00 = 0x00,
3213+ ENUM_UMAC_LMAC_PLE_TX_Q_01 = 0x01,
3214+ ENUM_UMAC_LMAC_PLE_TX_Q_02 = 0x02,
3215+ ENUM_UMAC_LMAC_PLE_TX_Q_03 = 0x03,
3216+
3217+ ENUM_UMAC_LMAC_PLE_TX_Q_10 = 0x04,
3218+ ENUM_UMAC_LMAC_PLE_TX_Q_11 = 0x05,
3219+ ENUM_UMAC_LMAC_PLE_TX_Q_12 = 0x06,
3220+ ENUM_UMAC_LMAC_PLE_TX_Q_13 = 0x07,
3221+
3222+ ENUM_UMAC_LMAC_PLE_TX_Q_20 = 0x08,
3223+ ENUM_UMAC_LMAC_PLE_TX_Q_21 = 0x09,
3224+ ENUM_UMAC_LMAC_PLE_TX_Q_22 = 0x0a,
3225+ ENUM_UMAC_LMAC_PLE_TX_Q_23 = 0x0b,
3226+
3227+ ENUM_UMAC_LMAC_PLE_TX_Q_30 = 0x0c,
3228+ ENUM_UMAC_LMAC_PLE_TX_Q_31 = 0x0d,
3229+ ENUM_UMAC_LMAC_PLE_TX_Q_32 = 0x0e,
3230+ ENUM_UMAC_LMAC_PLE_TX_Q_33 = 0x0f,
3231+
3232+ ENUM_UMAC_LMAC_PLE_TX_Q_ALTX_0 = 0x10,
3233+ ENUM_UMAC_LMAC_PLE_TX_Q_BMC_0 = 0x11,
3234+ ENUM_UMAC_LMAC_PLE_TX_Q_BNC_0 = 0x12,
3235+ ENUM_UMAC_LMAC_PLE_TX_Q_PSMP_0 = 0x13,
3236+
3237+ ENUM_UMAC_LMAC_PLE_TX_Q_ALTX_1 = 0x14,
3238+ ENUM_UMAC_LMAC_PLE_TX_Q_BMC_1 = 0x15,
3239+ ENUM_UMAC_LMAC_PLE_TX_Q_BNC_1 = 0x16,
3240+ ENUM_UMAC_LMAC_PLE_TX_Q_PSMP_1 = 0x17,
3241+ ENUM_UMAC_LMAC_PLE_TX_Q_NAF = 0x18,
3242+ ENUM_UMAC_LMAC_PLE_TX_Q_NBCN = 0x19,
3243+ ENUM_UMAC_LMAC_PLE_TX_Q_RELEASE = 0x1f, /* DE suggests not to use 0x1f, it's only for hw free queue */
3244+ ENUM_UMAC_LMAC_QUEUE_TOTAL_NUM = 24,
3245+
3246+} ENUM_UMAC_LMAC_TX_P_QUEUE_T, *P_ENUM_UMAC_LMAC_TX_P_QUEUE_T;
3247+
3248+typedef struct _EMPTY_QUEUE_INFO_T {
3249+ char *QueueName;
3250+ u32 Portid;
3251+ u32 Queueid;
3252+} EMPTY_QUEUE_INFO_T, *P_EMPTY_QUEUE_INFO_T;
3253+
3254+static EMPTY_QUEUE_INFO_T ple_queue_empty_info[] = {
3255+ {"CPU Q0", ENUM_UMAC_CPU_PORT_1, ENUM_UMAC_CTX_Q_0},
3256+ {"CPU Q1", ENUM_UMAC_CPU_PORT_1, ENUM_UMAC_CTX_Q_1},
3257+ {"CPU Q2", ENUM_UMAC_CPU_PORT_1, ENUM_UMAC_CTX_Q_2},
3258+ {"CPU Q3", ENUM_UMAC_CPU_PORT_1, ENUM_UMAC_CTX_Q_3},
3259+ {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, /* 4~7 not defined */
3260+ {"ALTX Q0", ENUM_UMAC_LMAC_PORT_2, ENUM_UMAC_LMAC_PLE_TX_Q_ALTX_0}, /* Q16 */
3261+ {"BMC Q0", ENUM_UMAC_LMAC_PORT_2, ENUM_UMAC_LMAC_PLE_TX_Q_BMC_0},
3262+ {"BCN Q0", ENUM_UMAC_LMAC_PORT_2, ENUM_UMAC_LMAC_PLE_TX_Q_BNC_0},
3263+ {"PSMP Q0", ENUM_UMAC_LMAC_PORT_2, ENUM_UMAC_LMAC_PLE_TX_Q_PSMP_0},
3264+ {"ALTX Q1", ENUM_UMAC_LMAC_PORT_2, ENUM_UMAC_LMAC_PLE_TX_Q_ALTX_1},
3265+ {"BMC Q1", ENUM_UMAC_LMAC_PORT_2, ENUM_UMAC_LMAC_PLE_TX_Q_BMC_1},
3266+ {"BCN Q1", ENUM_UMAC_LMAC_PORT_2, ENUM_UMAC_LMAC_PLE_TX_Q_BNC_1},
3267+ {"PSMP Q1", ENUM_UMAC_LMAC_PORT_2, ENUM_UMAC_LMAC_PLE_TX_Q_PSMP_1},
3268+ {"NAF Q", ENUM_UMAC_LMAC_PORT_2, ENUM_UMAC_LMAC_PLE_TX_Q_NAF},
3269+ {"NBCN Q", ENUM_UMAC_LMAC_PORT_2, ENUM_UMAC_LMAC_PLE_TX_Q_NBCN},
3270+ {NULL, 0, 0}, {NULL, 0, 0}, /* 18, 19 not defined */
3271+ {"FIXFID Q", ENUM_UMAC_LMAC_PORT_2, 0x1a},
3272+ {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0},
3273+ {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, /* 21~29 not defined */
3274+ {"RLS Q", ENUM_PLE_CTRL_PSE_PORT_3, 0x7e},
3275+ {"RLS2 Q", ENUM_PLE_CTRL_PSE_PORT_3, 0x7f}
3276+};
3277+
3278+static EMPTY_QUEUE_INFO_T ple_txcmd_queue_empty_info[] = {
3279+ {"AC00Q", ENUM_UMAC_LMAC_PORT_2, 0x40},
3280+ {"AC01Q", ENUM_UMAC_LMAC_PORT_2, 0x41},
3281+ {"AC02Q", ENUM_UMAC_LMAC_PORT_2, 0x42},
3282+ {"AC03Q", ENUM_UMAC_LMAC_PORT_2, 0x43},
3283+ {"AC10Q", ENUM_UMAC_LMAC_PORT_2, 0x44},
3284+ {"AC11Q", ENUM_UMAC_LMAC_PORT_2, 0x45},
3285+ {"AC12Q", ENUM_UMAC_LMAC_PORT_2, 0x46},
3286+ {"AC13Q", ENUM_UMAC_LMAC_PORT_2, 0x47},
3287+ {"AC20Q", ENUM_UMAC_LMAC_PORT_2, 0x48},
3288+ {"AC21Q", ENUM_UMAC_LMAC_PORT_2, 0x49},
3289+ {"AC22Q", ENUM_UMAC_LMAC_PORT_2, 0x4a},
3290+ {"AC23Q", ENUM_UMAC_LMAC_PORT_2, 0x4b},
3291+ {"AC30Q", ENUM_UMAC_LMAC_PORT_2, 0x4c},
3292+ {"AC31Q", ENUM_UMAC_LMAC_PORT_2, 0x4d},
3293+ {"AC32Q", ENUM_UMAC_LMAC_PORT_2, 0x4e},
3294+ {"AC33Q", ENUM_UMAC_LMAC_PORT_2, 0x4f},
3295+ {"ALTX Q0", ENUM_UMAC_LMAC_PORT_2, 0x50},
3296+ {"TF Q0", ENUM_UMAC_LMAC_PORT_2, 0x51},
3297+ {"TWT TSF-TF Q0", ENUM_UMAC_LMAC_PORT_2, 0x52},
3298+ {"TWT DL Q0", ENUM_UMAC_LMAC_PORT_2, 0x53},
3299+ {"TWT UL Q0", ENUM_UMAC_LMAC_PORT_2, 0x54},
3300+ {"ALTX Q1", ENUM_UMAC_LMAC_PORT_2, 0x55},
3301+ {"TF Q1", ENUM_UMAC_LMAC_PORT_2, 0x56},
3302+ {"TWT TSF-TF Q1", ENUM_UMAC_LMAC_PORT_2, 0x57},
3303+ {"TWT DL Q1", ENUM_UMAC_LMAC_PORT_2, 0x58},
3304+ {"TWT UL Q1", ENUM_UMAC_LMAC_PORT_2, 0x59},
3305+ {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0},
3306+};
3307+
developer73e5a572022-04-19 10:21:20 +08003308+static char* sta_ctrl_reg[] = {"ENABLE", "DISABLE", "PAUSE"};
3309+static u32 chip_show_sta_acq_info(struct seq_file *s, struct mt7915_dev *dev, u32 *ple_stat,
3310+ u32 *sta_pause, u32 *dis_sta_map,
3311+ u32 dumptxd)
3312+{
3313+ int i, j;
3314+ u32 total_nonempty_cnt = 0;
3315+ u32 ac_num = 9, all_ac_num;
3316+
3317+ /* TDO: ac_num = 16 for mt7986 */
developerd68e00e2022-06-01 10:59:24 +08003318+ if (!is_mt7915(&dev->mt76))
3319+ ac_num = 17;
developer73e5a572022-04-19 10:21:20 +08003320+
3321+ all_ac_num = ac_num * 4;
3322+
3323+ for (j = 0; j < all_ac_num; j++) { /* show AC Q info */
3324+ for (i = 0; i < 32; i++) {
3325+ if (((ple_stat[j + 1] & (0x1 << i)) >> i) == 0) {
developerd68e00e2022-06-01 10:59:24 +08003326+ u32 hfid, tfid, pktcnt, ac_n = j / ac_num, ctrl = 0;
developer73e5a572022-04-19 10:21:20 +08003327+ u32 sta_num = i + (j % ac_num) * 32, fl_que_ctrl[3] = {0};
3328+ //struct wifi_dev *wdev = wdev_search_by_wcid(pAd, sta_num);
3329+ u32 wmmidx = 0;
3330+ struct mt7915_sta *msta;
3331+ struct mt76_wcid *wcid;
developer73e5a572022-04-19 10:21:20 +08003332+
3333+ wcid = rcu_dereference(dev->mt76.wcid[sta_num]);
developerbddc9db2023-09-11 13:34:36 +08003334+ if (!wcid) {
developer73e5a572022-04-19 10:21:20 +08003335+ printk("ERROR!! no found STA wcid=%d\n", sta_num);
developerd68e00e2022-06-01 10:59:24 +08003336+ continue;
developer73e5a572022-04-19 10:21:20 +08003337+ }
3338+ msta = container_of(wcid, struct mt7915_sta, wcid);
3339+ wmmidx = msta->vif->mt76.wmm_idx;
3340+
developerd68e00e2022-06-01 10:59:24 +08003341+ seq_printf(s, "\tSTA%d AC%d: ", sta_num, ac_n);
developer73e5a572022-04-19 10:21:20 +08003342+
3343+ fl_que_ctrl[0] |= MT_DBG_PLE_FL_QUE_CTRL0_EXECUTE_MASK;
3344+ fl_que_ctrl[0] |= (ENUM_UMAC_LMAC_PORT_2 << MT_PLE_FL_QUE_CTRL0_Q_BUF_PID_SHFT);
developerd68e00e2022-06-01 10:59:24 +08003345+ fl_que_ctrl[0] |= (ac_n << MT_PLE_FL_QUE_CTRL0_Q_BUF_QID_SHFT);
developer73e5a572022-04-19 10:21:20 +08003346+ fl_que_ctrl[0] |= sta_num;
3347+ mt76_wr(dev, MT_DBG_PLE_FL_QUE_CTRL0, fl_que_ctrl[0]);
3348+ fl_que_ctrl[1] = mt76_rr(dev, MT_DBG_PLE_FL_QUE_CTRL2);
3349+ fl_que_ctrl[2] = mt76_rr(dev, MT_DBG_PLE_FL_QUE_CTRL3);
3350+ hfid = FIELD_GET(MT_DBG_PLE_FL_QUE_CTRL2_Q_HEAD_FID_MASK, fl_que_ctrl[1]);
3351+ tfid = FIELD_GET(MT_DBG_PLE_FL_QUE_CTRL2_Q_TAIL_FID_MASK, fl_que_ctrl[1]);
3352+ pktcnt = FIELD_GET(MT_DBG_PLE_FL_QUE_CTRL3_Q_PKT_NUM_MASK, fl_que_ctrl[2]);
3353+ seq_printf(s, "tail/head fid = 0x%03x/0x%03x, pkt cnt = 0x%03x",
3354+ tfid, hfid, pktcnt);
3355+
developer2299de92023-10-27 15:40:47 +08003356+ if (((sta_pause[j % ac_num] & 0x1 << i) >> i) == 1)
developer73e5a572022-04-19 10:21:20 +08003357+ ctrl = 2;
3358+
developer2299de92023-10-27 15:40:47 +08003359+ if (((dis_sta_map[j % ac_num] & 0x1 << i) >> i) == 1)
developer73e5a572022-04-19 10:21:20 +08003360+ ctrl = 1;
3361+
3362+ seq_printf(s, " ctrl = %s", sta_ctrl_reg[ctrl]);
3363+ seq_printf(s, " (wmmidx=%d)\n", wmmidx);
3364+
3365+ total_nonempty_cnt++;
3366+
3367+ // TODO
3368+ //if (pktcnt > 0 && dumptxd > 0)
3369+ // ShowTXDInfo(pAd, hfid);
3370+ }
3371+ }
3372+ }
3373+
3374+ return total_nonempty_cnt;
3375+}
3376+
3377+static void chip_show_txcmdq_info(struct seq_file *s, struct mt7915_dev *dev, u32 ple_txcmd_stat)
3378+{
3379+ int i;
3380+
3381+ seq_printf(s, "Nonempty TXCMD Q info:\n");
developerd68e00e2022-06-01 10:59:24 +08003382+ for (i = 0; i < 32; i++) {
developer73e5a572022-04-19 10:21:20 +08003383+ if (((ple_txcmd_stat & (0x1 << i)) >> i) == 0) {
3384+ u32 hfid, tfid, pktcnt, fl_que_ctrl[3] = {0};
3385+
3386+ if (ple_txcmd_queue_empty_info[i].QueueName != NULL) {
3387+ seq_printf(s, "\t%s: ", ple_txcmd_queue_empty_info[i].QueueName);
3388+ fl_que_ctrl[0] |= MT_DBG_PLE_FL_QUE_CTRL0_EXECUTE_MASK;
3389+ fl_que_ctrl[0] |= (ple_txcmd_queue_empty_info[i].Portid <<
3390+ MT_PLE_FL_QUE_CTRL0_Q_BUF_PID_SHFT);
3391+ fl_que_ctrl[0] |= (ple_txcmd_queue_empty_info[i].Queueid <<
3392+ MT_PLE_FL_QUE_CTRL0_Q_BUF_QID_SHFT);
3393+ } else
3394+ continue;
3395+
3396+ mt76_wr(dev, MT_DBG_PLE_FL_QUE_CTRL0, fl_que_ctrl[0]);
3397+ fl_que_ctrl[1] = mt76_rr(dev, MT_DBG_PLE_FL_QUE_CTRL2);
3398+ fl_que_ctrl[2] = mt76_rr(dev, MT_DBG_PLE_FL_QUE_CTRL3);
3399+ hfid = FIELD_GET(MT_DBG_PLE_FL_QUE_CTRL2_Q_HEAD_FID_MASK, fl_que_ctrl[1]);
3400+ tfid = FIELD_GET(MT_DBG_PLE_FL_QUE_CTRL2_Q_TAIL_FID_MASK, fl_que_ctrl[1]);
3401+ pktcnt = FIELD_GET(MT_DBG_PLE_FL_QUE_CTRL3_Q_PKT_NUM_MASK, fl_que_ctrl[2]);
3402+ seq_printf(s, "tail/head fid = 0x%03x/0x%03x, pkt cnt = 0x%03x\n",
3403+ tfid, hfid, pktcnt);
3404+ }
3405+ }
3406+}
3407+
3408+static void chip_get_ple_acq_stat(struct mt7915_dev *dev, u32 *ple_stat)
3409+{
3410+ int i;
3411+ int cr_num = 9, all_cr_num;
3412+ u32 ac , index;
3413+
3414+ /* TDO: cr_num = 16 for mt7986 */
developer73e5a572022-04-19 10:21:20 +08003415+ if(!is_mt7915(&dev->mt76))
developerd68e00e2022-06-01 10:59:24 +08003416+ cr_num = 17;
3417+
developer73e5a572022-04-19 10:21:20 +08003418+ all_cr_num = cr_num * 4;
3419+
3420+ ple_stat[0] = mt76_rr(dev, MT_DBG_PLE_QUEUE_EMPTY);
3421+
3422+ for(i = 0; i < all_cr_num; i++) {
3423+ ac = i / cr_num;
3424+ index = i % cr_num;
3425+ ple_stat[i + 1] =
3426+ mt76_rr(dev, MT_DBG_PLE_AC_QEMPTY(ac, index));
3427+
3428+ }
3429+}
3430+
3431+static void chip_get_dis_sta_map(struct mt7915_dev *dev, u32 *dis_sta_map)
3432+{
3433+ int i;
developerd68e00e2022-06-01 10:59:24 +08003434+ u32 ac_num = 9;
3435+
3436+ /* TDO: ac_num = 16 for mt7986 */
3437+ if (!is_mt7915(&dev->mt76))
3438+ ac_num = 17;
developer73e5a572022-04-19 10:21:20 +08003439+
developerd68e00e2022-06-01 10:59:24 +08003440+ for(i = 0; i < ac_num; i++) {
developer73e5a572022-04-19 10:21:20 +08003441+ dis_sta_map[i] = mt76_rr(dev, MT_DBG_PLE_DIS_STA_MAP(i));
3442+ }
3443+}
3444+
3445+static void chip_get_sta_pause(struct mt7915_dev *dev, u32 *sta_pause)
3446+{
3447+ int i;
developerd68e00e2022-06-01 10:59:24 +08003448+ u32 ac_num = 9;
developer73e5a572022-04-19 10:21:20 +08003449+
developerd68e00e2022-06-01 10:59:24 +08003450+ /* TDO: ac_num = 16 for mt7986 */
3451+ if (!is_mt7915(&dev->mt76))
3452+ ac_num = 17;
3453+
3454+ for(i = 0; i < ac_num; i++) {
developer73e5a572022-04-19 10:21:20 +08003455+ sta_pause[i] = mt76_rr(dev, MT_DBG_PLE_STATION_PAUSE(i));
3456+ }
3457+}
3458+
3459+static int mt7915_pleinfo_read(struct seq_file *s, void *data)
3460+{
3461+ struct mt7915_dev *dev = dev_get_drvdata(s->private);
3462+ u32 ple_buf_ctrl, pg_sz, pg_num;
developerd68e00e2022-06-01 10:59:24 +08003463+ u32 ple_stat[70] = {0}, pg_flow_ctrl[8] = {0};
developer73e5a572022-04-19 10:21:20 +08003464+ u32 ple_native_txcmd_stat;
3465+ u32 ple_txcmd_stat;
3466+ u32 sta_pause[CR_NUM_OF_AC] = {0}, dis_sta_map[CR_NUM_OF_AC] = {0};
3467+ u32 fpg_cnt, ffa_cnt, fpg_head, fpg_tail, hif_max_q, hif_min_q;
3468+ u32 rpg_hif, upg_hif, cpu_max_q, cpu_min_q, rpg_cpu, upg_cpu;
3469+ int i, j;
3470+ u32 ac_num = 9, all_ac_num;
3471+
3472+ /* TDO: ac_num = 16 for mt7986 */
developerd68e00e2022-06-01 10:59:24 +08003473+ if (!is_mt7915(&dev->mt76))
3474+ ac_num = 17;
developer73e5a572022-04-19 10:21:20 +08003475+
3476+ all_ac_num = ac_num * 4;
3477+
3478+ ple_buf_ctrl = mt76_rr(dev, MT_DBG_PLE_PBUF_CTRL_ADDR);
3479+ chip_get_ple_acq_stat(dev, ple_stat);
3480+ ple_txcmd_stat = mt76_rr(dev, MT_DBG_PLE_TXCMD_Q_EMPTY);
3481+ ple_native_txcmd_stat = mt76_rr(dev, MT_DBG_PLE_NATIVE_TXCMD_Q_EMPTY);
3482+ pg_flow_ctrl[0] = mt76_rr(dev, MT_DBG_PLE_FREEPG_CNT);
3483+ pg_flow_ctrl[1] = mt76_rr(dev, MT_DBG_PLE_FREEPG_HEAD_TAIL);
3484+ pg_flow_ctrl[2] = mt76_rr(dev, MT_DBG_PLE_PG_HIF_GROUP);
3485+ pg_flow_ctrl[3] = mt76_rr(dev, MT_DBG_PLE_HIF_PG_INFO);
3486+ pg_flow_ctrl[4] = mt76_rr(dev, MT_DBG_PLE_PG_CPU_GROUP);
3487+ pg_flow_ctrl[5] = mt76_rr(dev, MT_DBG_PLE_CPU_PG_INFO);
3488+ pg_flow_ctrl[6] = mt76_rr(dev, MT_DBG_PLE_PG_HIF_TXCMD_GROUP);
3489+ pg_flow_ctrl[7] = mt76_rr(dev, MT_DBG_PLE_HIF_TXCMD_PG_INFO);
3490+ chip_get_dis_sta_map(dev, dis_sta_map);
3491+ chip_get_sta_pause(dev, sta_pause);
3492+
3493+ seq_printf(s, "PLE Configuration Info:\n");
3494+ seq_printf(s, "\tPacket Buffer Control(0x%x): 0x%08x\n",
3495+ MT_DBG_PLE_PBUF_CTRL_ADDR, ple_buf_ctrl);
3496+
3497+ pg_sz = FIELD_GET(MT_DBG_PLE_PBUF_CTRL_PAGE_SIZE_MASK, ple_buf_ctrl);
3498+ seq_printf(s, "\t\tPage Size=%d(%d bytes per page)\n",
3499+ pg_sz, (pg_sz == 1 ? 128 : 64));
3500+ seq_printf(s, "\t\tPage Offset=%ld(in unit of 2KB)\n",
3501+ FIELD_GET(MT_DBG_PLE_PBUF_CTRL_OFFSET_MASK, ple_buf_ctrl));
3502+
3503+ pg_num = FIELD_GET(MT_DBG_PLE_PBUF_CTRL_TOTAL_PAGE_NUM_MASK, ple_buf_ctrl);
3504+ seq_printf(s, "\t\tTotal Page=%d pages\n", pg_num);
3505+
3506+ /* Page Flow Control */
3507+ seq_printf(s, "PLE Page Flow Control:\n");
3508+ seq_printf(s, "\tFree page counter(0x%x): 0x%08x\n",
3509+ MT_DBG_PLE_FREEPG_CNT, pg_flow_ctrl[0]);
3510+ fpg_cnt = FIELD_GET(MT_DBG_PLE_FREEPG_CNT_FREEPG_CNT_MASK, pg_flow_ctrl[0]);
3511+
3512+ seq_printf(s, "\t\tThe toal page number of free=0x%03x\n", fpg_cnt);
3513+ ffa_cnt = FIELD_GET(MT_DBG_PLE_FREEPG_CNT_FFA_CNT_MASK, pg_flow_ctrl[0]);
3514+
3515+ seq_printf(s, "\t\tThe free page numbers of free for all=0x%03x\n", ffa_cnt);
3516+ seq_printf(s, "\tFree page head and tail(0x%x): 0x%08x\n",
3517+ MT_DBG_PLE_FREEPG_HEAD_TAIL, pg_flow_ctrl[1]);
3518+
3519+ fpg_head = FIELD_GET(MT_DBG_PLE_FREEPG_HEAD_TAIL_FREEPG_HEAD_MASK, pg_flow_ctrl[1]);
3520+ fpg_tail = FIELD_GET(MT_DBG_PLE_FREEPG_HEAD_TAIL_FREEPG_TAIL_MASK, pg_flow_ctrl[1]);
3521+ seq_printf(s, "\t\tThe tail/head page of free page list=0x%03x/0x%03x\n", fpg_tail, fpg_head);
3522+ seq_printf(s, "\tReserved page counter of HIF group(0x%x): 0x%08x\n",
3523+ MT_DBG_PLE_PG_HIF_GROUP, pg_flow_ctrl[2]);
3524+ seq_printf(s, "\tHIF group page status(0x%x): 0x%08x\n",
3525+ MT_DBG_PLE_HIF_PG_INFO, pg_flow_ctrl[3]);
3526+
3527+ hif_min_q = FIELD_GET(MT_DBG_PLE_PG_HIF_GROUP_HIF_MIN_QUOTA_MASK, pg_flow_ctrl[2]);
3528+ hif_max_q = FIELD_GET(MT_DBG_PLE_PG_HIF_GROUP_HIF_MAX_QUOTA_MASK, pg_flow_ctrl[2]);
3529+ seq_printf(s, "\t\tThe max/min quota pages of HIF group=0x%03x/0x%03x\n", hif_max_q, hif_min_q);
3530+
3531+ rpg_hif = FIELD_GET(MT_DBG_PLE_HIF_PG_INFO_HIF_RSV_CNT_MASK, pg_flow_ctrl[3]);
3532+ upg_hif = FIELD_GET(MT_DBG_PLE_HIF_PG_INFO_HIF_SRC_CNT_MASK, pg_flow_ctrl[3]);
3533+ seq_printf(s, "\t\tThe used/reserved pages of HIF group=0x%03x/0x%03x\n", upg_hif, rpg_hif);
3534+
3535+ seq_printf(s, "\tReserved page counter of HIF_TXCMD group(0x%x): 0x%08x\n",
3536+ MT_DBG_PLE_PG_HIF_TXCMD_GROUP, pg_flow_ctrl[6]);
3537+ seq_printf(s, "\tHIF_TXCMD group page status(0x%x): 0x%08x\n",
3538+ MT_DBG_PLE_HIF_TXCMD_PG_INFO, pg_flow_ctrl[7]);
3539+ cpu_min_q = FIELD_GET(MT_DBG_PLE_PG_HIF_TXCMD_GROUP_HIF_TXCMD_MIN_QUOTA_MASK, pg_flow_ctrl[6]);
developerd68e00e2022-06-01 10:59:24 +08003540+ cpu_max_q = FIELD_GET(MT_DBG_PLE_PG_HIF_TXCMD_GROUP_HIF_TXCMD_MAX_QUOTA_MASK, pg_flow_ctrl[6]);
developer73e5a572022-04-19 10:21:20 +08003541+ seq_printf(s, "\t\tThe max/min quota pages of HIF_TXCMD group=0x%03x/0x%03x\n", cpu_max_q, cpu_min_q);
3542+
3543+ rpg_cpu = FIELD_GET(MT_DBG_PLE_TXCMD_PG_INFO_HIF_TXCMD_RSV_CNT_MASK, pg_flow_ctrl[7]);
3544+ upg_cpu = FIELD_GET(MT_DBG_PLE_TXCMD_PG_INFO_HIF_TXCMD_SRC_CNT_MASK, pg_flow_ctrl[7]);
3545+ seq_printf(s, "\t\tThe used/reserved pages of HIF_TXCMD group=0x%03x/0x%03x\n", upg_cpu, rpg_cpu);
3546+
developerd68e00e2022-06-01 10:59:24 +08003547+ seq_printf(s, "\tReserved page counter of CPU group(0x%x): 0x%08x\n",
3548+ MT_DBG_PLE_PG_CPU_GROUP, pg_flow_ctrl[4]);
3549+ seq_printf(s, "\tCPU group page status(0x%x): 0x%08x\n",
3550+ MT_DBG_PLE_CPU_PG_INFO, pg_flow_ctrl[5]);
developer73e5a572022-04-19 10:21:20 +08003551+ cpu_min_q = FIELD_GET(MT_DBG_PLE_PG_CPU_GROUP_CPU_MIN_QUOTA_MASK, pg_flow_ctrl[4]);
3552+ cpu_max_q = FIELD_GET(MT_DBG_PLE_PG_CPU_GROUP_CPU_MAX_QUOTA_MASK, pg_flow_ctrl[4]);
3553+ seq_printf(s, "\t\tThe max/min quota pages of CPU group=0x%03x/0x%03x\n", cpu_max_q, cpu_min_q);
3554+
3555+ rpg_cpu = FIELD_GET(MT_DBG_PLE_CPU_PG_INFO_CPU_RSV_CNT_MASK, pg_flow_ctrl[5]);
3556+ upg_cpu = FIELD_GET(MT_DBG_PLE_CPU_PG_INFO_CPU_SRC_CNT_MASK, pg_flow_ctrl[5]);
3557+ seq_printf(s, "\t\tThe used/reserved pages of CPU group=0x%03x/0x%03x\n", upg_cpu, rpg_cpu);
3558+
3559+ if ((ple_stat[0] & MT_DBG_PLE_Q_EMPTY_ALL_AC_EMPTY_MASK) == 0) {
3560+ for (j = 0; j < all_ac_num; j++) {
3561+ if (j % ac_num == 0) {
3562+ seq_printf(s, "\n\tNonempty AC%d Q of STA#: ", j / ac_num);
3563+ }
3564+
developerd68e00e2022-06-01 10:59:24 +08003565+ for (i = 0; i < 32; i++) {
developer73e5a572022-04-19 10:21:20 +08003566+ if (((ple_stat[j + 1] & (0x1 << i)) >> i) == 0) {
3567+ seq_printf(s, "%d ", i + (j % ac_num) * 32);
3568+ }
3569+ }
3570+ }
3571+
3572+ seq_printf(s, "\n");
3573+ }
3574+
3575+ seq_printf(s, "non-native/native txcmd queue empty = %d/%d\n", ple_txcmd_stat, ple_native_txcmd_stat);
3576+
3577+ seq_printf(s, "Nonempty Q info:\n");
3578+
developerd68e00e2022-06-01 10:59:24 +08003579+ for (i = 0; i < 32; i++) {
developer73e5a572022-04-19 10:21:20 +08003580+ if (((ple_stat[0] & (0x1 << i)) >> i) == 0) {
3581+ u32 hfid, tfid, pktcnt, fl_que_ctrl[3] = {0};
3582+
3583+ if (ple_queue_empty_info[i].QueueName != NULL) {
3584+ seq_printf(s, "\t%s: ", ple_queue_empty_info[i].QueueName);
3585+ fl_que_ctrl[0] |= MT_DBG_PLE_FL_QUE_CTRL0_EXECUTE_MASK;
3586+ fl_que_ctrl[0] |= (ple_queue_empty_info[i].Portid << MT_PLE_FL_QUE_CTRL0_Q_BUF_PID_SHFT);
3587+ fl_que_ctrl[0] |= (ple_queue_empty_info[i].Queueid << MT_PLE_FL_QUE_CTRL0_Q_BUF_QID_SHFT);
3588+ } else
3589+ continue;
3590+
3591+ if (ple_queue_empty_info[i].Queueid >= ENUM_UMAC_LMAC_PLE_TX_Q_ALTX_0 &&
3592+ ple_queue_empty_info[i].Queueid <= ENUM_UMAC_LMAC_PLE_TX_Q_PSMP_0)
3593+ /* band0 set TGID 0, bit31 = 0 */
3594+ mt76_wr(dev, MT_DBG_PLE_FL_QUE_CTRL1, 0x0);
3595+ else if (ple_queue_empty_info[i].Queueid >= ENUM_UMAC_LMAC_PLE_TX_Q_ALTX_1 &&
3596+ ple_queue_empty_info[i].Queueid <= ENUM_UMAC_LMAC_PLE_TX_Q_PSMP_1)
3597+ /* band1 set TGID 1, bit31 = 1 */
3598+ mt76_wr(dev, MT_DBG_PLE_FL_QUE_CTRL1, 0x80000000);
3599+
3600+ mt76_wr(dev, MT_DBG_PLE_FL_QUE_CTRL0, fl_que_ctrl[0]);
3601+ fl_que_ctrl[1] = mt76_rr(dev, MT_DBG_PLE_FL_QUE_CTRL2);
3602+ fl_que_ctrl[2] = mt76_rr(dev, MT_DBG_PLE_FL_QUE_CTRL3);
3603+ hfid = FIELD_GET(MT_DBG_PLE_FL_QUE_CTRL2_Q_HEAD_FID_MASK, fl_que_ctrl[1]);
3604+ tfid = FIELD_GET(MT_DBG_PLE_FL_QUE_CTRL2_Q_TAIL_FID_MASK, fl_que_ctrl[1]);
3605+ pktcnt = FIELD_GET(MT_DBG_PLE_FL_QUE_CTRL3_Q_PKT_NUM_MASK, fl_que_ctrl[2]);
3606+ seq_printf(s, "tail/head fid = 0x%03x/0x%03x, pkt cnt = 0x%03x\n",
3607+ tfid, hfid, pktcnt);
3608+
3609+ /* TODO */
3610+ //if (pktcnt > 0 && dumptxd > 0)
3611+ // ShowTXDInfo(pAd, hfid);
3612+ }
3613+ }
3614+
3615+ chip_show_sta_acq_info(s, dev, ple_stat, sta_pause, dis_sta_map, 0/*dumptxd*/);
3616+ chip_show_txcmdq_info(s, dev, ple_native_txcmd_stat);
3617+
3618+ return 0;
3619+}
3620+
3621+typedef enum _ENUM_UMAC_PLE_CTRL_P3_QUEUE_T {
3622+ ENUM_UMAC_PLE_CTRL_P3_Q_0X1E = 0x1e,
3623+ ENUM_UMAC_PLE_CTRL_P3_Q_0X1F = 0x1f,
3624+ ENUM_UMAC_PLE_CTRL_P3_TOTAL_NUM = 2
3625+} ENUM_UMAC_PLE_CTRL_P3_QUEUE_T, *P_ENUM_UMAC_PLE_CTRL_P3_QUEUE_T;
3626+
3627+static EMPTY_QUEUE_INFO_T pse_queue_empty_info[] = {
3628+ {"CPU Q0", ENUM_UMAC_CPU_PORT_1, ENUM_UMAC_CTX_Q_0},
3629+ {"CPU Q1", ENUM_UMAC_CPU_PORT_1, ENUM_UMAC_CTX_Q_1},
3630+ {"CPU Q2", ENUM_UMAC_CPU_PORT_1, ENUM_UMAC_CTX_Q_2},
3631+ {"CPU Q3", ENUM_UMAC_CPU_PORT_1, ENUM_UMAC_CTX_Q_3},
3632+ {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, /* 4~7 not defined */
3633+ {"HIF Q0", ENUM_UMAC_HIF_PORT_0, 0}, /* Q8 */
3634+ {"HIF Q1", ENUM_UMAC_HIF_PORT_0, 1},
3635+ {"HIF Q2", ENUM_UMAC_HIF_PORT_0, 2},
3636+ {"HIF Q3", ENUM_UMAC_HIF_PORT_0, 3},
3637+ {"HIF Q4", ENUM_UMAC_HIF_PORT_0, 4},
3638+ {"HIF Q5", ENUM_UMAC_HIF_PORT_0, 5},
3639+ {NULL, 0, 0}, {NULL, 0, 0}, /* 14~15 not defined */
3640+ {"LMAC Q", ENUM_UMAC_LMAC_PORT_2, 0},
3641+ {"MDP TX Q", ENUM_UMAC_LMAC_PORT_2, 1},
3642+ {"MDP RX Q", ENUM_UMAC_LMAC_PORT_2, 2},
3643+ {"SEC TX Q", ENUM_UMAC_LMAC_PORT_2, 3},
3644+ {"SEC RX Q", ENUM_UMAC_LMAC_PORT_2, 4},
3645+ {"SFD_PARK Q", ENUM_UMAC_LMAC_PORT_2, 5},
3646+ {"MDP_TXIOC Q", ENUM_UMAC_LMAC_PORT_2, 6},
3647+ {"MDP_RXIOC Q", ENUM_UMAC_LMAC_PORT_2, 7},
3648+ {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 */
3649+ {"RLS Q", ENUM_PLE_CTRL_PSE_PORT_3, ENUM_UMAC_PLE_CTRL_P3_Q_0X1F}
3650+};
3651+
3652+static int mt7915_pseinfo_read(struct seq_file *s, void *data)
3653+{
3654+ struct mt7915_dev *dev = dev_get_drvdata(s->private);
3655+ u32 pse_buf_ctrl, pg_sz, pg_num;
3656+ u32 pse_stat, pg_flow_ctrl[22] = {0};
3657+ u32 fpg_cnt, ffa_cnt, fpg_head, fpg_tail;
3658+ u32 max_q, min_q, rsv_pg, used_pg;
3659+ int i;
3660+
3661+ pse_buf_ctrl = mt76_rr(dev, MT_DBG_PSE_PBUF_CTRL);
3662+ pse_stat = mt76_rr(dev, MT_DBG_PSE_QUEUE_EMPTY);
3663+ pg_flow_ctrl[0] = mt76_rr(dev, MT_DBG_PSE_FREEPG_CNT);
3664+ pg_flow_ctrl[1] = mt76_rr(dev, MT_DBG_PSE_FREEPG_HEAD_TAIL);
3665+ pg_flow_ctrl[2] = mt76_rr(dev, MT_DBG_PSE_PG_HIF0_GROUP);
3666+ pg_flow_ctrl[3] = mt76_rr(dev, MT_DBG_PSE_HIF0_PG_INFO);
3667+ pg_flow_ctrl[4] = mt76_rr(dev, MT_DBG_PSE_PG_HIF1_GROUP);
3668+ pg_flow_ctrl[5] = mt76_rr(dev, MT_DBG_PSE_HIF1_PG_INFO);
3669+ pg_flow_ctrl[6] = mt76_rr(dev, MT_DBG_PSE_PG_CPU_GROUP);
3670+ pg_flow_ctrl[7] = mt76_rr(dev, MT_DBG_PSE_CPU_PG_INFO);
3671+ pg_flow_ctrl[8] = mt76_rr(dev, MT_DBG_PSE_PG_LMAC0_GROUP);
3672+ pg_flow_ctrl[9] = mt76_rr(dev, MT_DBG_PSE_LMAC0_PG_INFO);
3673+ pg_flow_ctrl[10] = mt76_rr(dev, MT_DBG_PSE_PG_LMAC1_GROUP);
3674+ pg_flow_ctrl[11] = mt76_rr(dev, MT_DBG_PSE_LMAC1_PG_INFO);
3675+ pg_flow_ctrl[12] = mt76_rr(dev, MT_DBG_PSE_PG_LMAC2_GROUP);
3676+ pg_flow_ctrl[13] = mt76_rr(dev, MT_DBG_PSE_LMAC2_PG_INFO);
3677+ pg_flow_ctrl[14] = mt76_rr(dev, MT_DBG_PSE_PG_PLE_GROUP);
3678+ pg_flow_ctrl[15] = mt76_rr(dev, MT_DBG_PSE_PLE_PG_INFO);
3679+ pg_flow_ctrl[16] = mt76_rr(dev, MT_DBG_PSE_PG_LMAC3_GROUP);
3680+ pg_flow_ctrl[17] = mt76_rr(dev, MT_DBG_PSE_LMAC3_PG_INFO);
3681+ pg_flow_ctrl[18] = mt76_rr(dev, MT_DBG_PSE_PG_MDP_GROUP);
3682+ pg_flow_ctrl[19] = mt76_rr(dev, MT_DBG_PSE_MDP_PG_INFO);
3683+ pg_flow_ctrl[20] = mt76_rr(dev, MT_DBG_PSE_PG_PLE1_GROUP);
3684+ pg_flow_ctrl[21] = mt76_rr(dev,MT_DBG_PSE_PLE1_PG_INFO);
3685+
3686+ /* Configuration Info */
3687+ seq_printf(s, "PSE Configuration Info:\n");
3688+ seq_printf(s, "\tPacket Buffer Control(0x82068014): 0x%08x\n", pse_buf_ctrl);
3689+ pg_sz = FIELD_GET(MT_DBG_PSE_PBUF_CTRL_PAGE_SIZE_CFG_MASK, pse_buf_ctrl);
3690+
3691+ seq_printf(s, "\t\tPage Size=%d(%d bytes per page)\n", pg_sz, (pg_sz == 1 ? 256 : 128));
3692+ seq_printf(s, "\t\tPage Offset=%ld(in unit of 64KB)\n",
3693+ FIELD_GET(MT_DBG_PSE_PBUF_CTRL_PBUF_OFFSET_MASK, pse_buf_ctrl));
3694+ pg_num = FIELD_GET(MT_DBG_PSE_PBUF_CTRL_TOTAL_PAGE_NUM_MASK, pse_buf_ctrl);
3695+
3696+ seq_printf(s, "\t\tTotal page numbers=%d pages\n", pg_num);
3697+
3698+ /* Page Flow Control */
3699+ seq_printf(s, "PSE Page Flow Control:\n");
3700+ seq_printf(s, "\tFree page counter(0x82068100): 0x%08x\n", pg_flow_ctrl[0]);
3701+ fpg_cnt = FIELD_GET(MT_DBG_PSE_FREEPG_CNT_FREEPG_CNT_MASK, pg_flow_ctrl[0]);
3702+ seq_printf(s, "\t\tThe toal page number of free=0x%03x\n", fpg_cnt);
3703+
3704+ ffa_cnt = FIELD_GET(MT_DBG_PSE_FREEPG_CNT_FFA_CNT_MASK, pg_flow_ctrl[0]);
3705+ seq_printf(s, "\t\tThe free page numbers of free for all=0x%03x\n", ffa_cnt);
3706+
3707+ seq_printf(s, "\tFree page head and tail(0x82068104): 0x%08x\n", pg_flow_ctrl[1]);
3708+ fpg_head = FIELD_GET(MT_DBG_PSE_FREEPG_HEAD_TAIL_FREEPG_HEAD_MASK, pg_flow_ctrl[1]);
3709+
3710+ fpg_tail = FIELD_GET(MT_DBG_PSE_FREEPG_HEAD_TAIL_FREEPG_TAIL_MASK, pg_flow_ctrl[1]);
3711+ seq_printf(s, "\t\tThe tail/head page of free page list=0x%03x/0x%03x\n", fpg_tail, fpg_head);
3712+ seq_printf(s, "\tReserved page counter of HIF0 group(0x82068110): 0x%08x\n", pg_flow_ctrl[2]);
3713+ seq_printf(s, "\tHIF0 group page status(0x82068114): 0x%08x\n", pg_flow_ctrl[3]);
3714+ min_q = FIELD_GET(MT_DBG_PSE_PG_HIF0_GROUP_HIF0_MIN_QUOTA_MASK, pg_flow_ctrl[2]);
3715+ max_q = FIELD_GET(MT_DBG_PSE_PG_HIF0_GROUP_HIF0_MAX_QUOTA_MASK, pg_flow_ctrl[2]);
3716+ seq_printf(s, "\t\tThe max/min quota pages of HIF0 group=0x%03x/0x%03x\n", max_q, min_q);
3717+ rsv_pg = FIELD_GET(MT_DBG_PSE_HIF0_PG_INFO_HIF0_RSV_CNT_MASK, pg_flow_ctrl[3]);;
3718+ used_pg = FIELD_GET(MT_DBG_PSE_HIF0_PG_INFO_HIF0_SRC_CNT_MASK, pg_flow_ctrl[3]);
3719+ seq_printf(s, "\t\tThe used/reserved pages of HIF0 group=0x%03x/0x%03x\n", used_pg, rsv_pg);
3720+ seq_printf(s, "\tReserved page counter of HIF1 group(0x82068118): 0x%08x\n", pg_flow_ctrl[4]);
3721+ seq_printf(s, "\tHIF1 group page status(0x8206811c): 0x%08x\n", pg_flow_ctrl[5]);
3722+ min_q = FIELD_GET(MT_DBG_PSE_PG_HIF1_GROUP_HIF1_MIN_QUOTA_MASK, pg_flow_ctrl[4]);
3723+ max_q = FIELD_GET(MT_DBG_PSE_PG_HIF1_GROUP_HIF1_MAX_QUOTA_MASK, pg_flow_ctrl[4]);
3724+ seq_printf(s, "\t\tThe max/min quota pages of HIF1 group=0x%03x/0x%03x\n", max_q, min_q);
3725+ rsv_pg = FIELD_GET(MT_DBG_PSE_HIF1_PG_INFO_HIF1_RSV_CNT_MASK, pg_flow_ctrl[5]);
3726+ used_pg = FIELD_GET(MT_DBG_PSE_HIF1_PG_INFO_HIF1_SRC_CNT_MASK, pg_flow_ctrl[5]);
3727+
3728+ seq_printf(s, "\t\tThe used/reserved pages of HIF1 group=0x%03x/0x%03x\n", used_pg, rsv_pg);
3729+ seq_printf(s, "\tReserved page counter of CPU group(0x82068150): 0x%08x\n", pg_flow_ctrl[6]);
3730+ seq_printf(s, "\tCPU group page status(0x82068154): 0x%08x\n", pg_flow_ctrl[7]);
3731+ min_q = FIELD_GET(MT_DBG_PSE_PG_CPU_GROUP_CPU_MIN_QUOTA_MASK, pg_flow_ctrl[6]);
3732+ max_q = FIELD_GET(MT_DBG_PSE_PG_CPU_GROUP_CPU_MAX_QUOTA_MASK, pg_flow_ctrl[6]);
3733+ seq_printf(s, "\t\tThe max/min quota pages of CPU group=0x%03x/0x%03x\n", max_q, min_q);
3734+ rsv_pg = FIELD_GET(MT_DBG_PSE_CPU_PG_INFO_CPU_RSV_CNT_MASK, pg_flow_ctrl[7]);
3735+ used_pg = FIELD_GET(MT_DBG_PSE_CPU_PG_INFO_CPU_SRC_CNT_MASK, pg_flow_ctrl[7]);
3736+ seq_printf(s, "\t\tThe used/reserved pages of CPU group=0x%03x/0x%03x\n", used_pg, rsv_pg);
3737+ seq_printf(s, "\tReserved page counter of LMAC0 group(0x82068170): 0x%08x\n", pg_flow_ctrl[8]);
3738+ seq_printf(s, "\tLMAC0 group page status(0x82068174): 0x%08x\n", pg_flow_ctrl[9]);
3739+ min_q = FIELD_GET(MT_DBG_PSE_PG_LMAC0_GROUP_LMAC0_MIN_QUOTA_MASK, pg_flow_ctrl[8]);
3740+ max_q = FIELD_GET(MT_DBG_PSE_PG_LMAC0_GROUP_LMAC0_MAX_QUOTA_MASK, pg_flow_ctrl[8]);
3741+ seq_printf(s, "\t\tThe max/min quota pages of LMAC0 group=0x%03x/0x%03x\n", max_q, min_q);
3742+ rsv_pg = FIELD_GET(MT_DBG_PSE_LMAC0_PG_INFO_LMAC0_RSV_CNT_MASK, pg_flow_ctrl[9]);
3743+ used_pg = FIELD_GET(MT_DBG_PSE_LMAC0_PG_INFO_LMAC0_SRC_CNT_MASK, pg_flow_ctrl[9]);
3744+ seq_printf(s, "\t\tThe used/reserved pages of LMAC0 group=0x%03x/0x%03x\n", used_pg, rsv_pg);
3745+ seq_printf(s, "\tReserved page counter of LMAC1 group(0x82068178): 0x%08x\n", pg_flow_ctrl[10]);
3746+ seq_printf(s, "\tLMAC1 group page status(0x8206817c): 0x%08x\n", pg_flow_ctrl[11]);
3747+ min_q = FIELD_GET(MT_DBG_TOP_PG_LMAC1_GROUP_LMAC1_MIN_QUOTA_MASK, pg_flow_ctrl[10]);
3748+ max_q = FIELD_GET(MT_DBG_PSE_PG_LMAC1_GROUP_LMAC1_MAX_QUOTA_MASK, pg_flow_ctrl[10]);
3749+ seq_printf(s, "\t\tThe max/min quota pages of LMAC1 group=0x%03x/0x%03x\n", max_q, min_q);
3750+ rsv_pg = FIELD_GET(MT_DBG_PSE_LMAC1_PG_INFO_LMAC1_RSV_CNT_MASK, pg_flow_ctrl[11]);
3751+ used_pg = FIELD_GET(MT_DBG_PSE_LMAC1_PG_INFO_LMAC1_SRC_CNT_MASK, pg_flow_ctrl[11]);
3752+ seq_printf(s, "\t\tThe used/reserved pages of LMAC1 group=0x%03x/0x%03x\n", used_pg, rsv_pg);
3753+ seq_printf(s, "\tReserved page counter of LMAC2 group(0x82068180): 0x%08x\n", pg_flow_ctrl[11]);
3754+ seq_printf(s, "\tLMAC2 group page status(0x82068184): 0x%08x\n", pg_flow_ctrl[12]);
3755+ min_q = FIELD_GET(MT_DBG_PSE_PG_LMAC2_GROUP_LMAC2_MIN_QUOTA_MASK, pg_flow_ctrl[12]);
3756+ max_q = FIELD_GET(MT_DBG_PSE_PG_LMAC2_GROUP_LMAC2_MAX_QUOTA_MASK, pg_flow_ctrl[12]);
3757+ seq_printf(s, "\t\tThe max/min quota pages of LMAC2 group=0x%03x/0x%03x\n", max_q, min_q);
3758+ rsv_pg = FIELD_GET(MT_DBG_PSE_LMAC2_PG_INFO_LMAC2_RSV_CNT_MASK, pg_flow_ctrl[13]);
3759+ used_pg = FIELD_GET(MT_DBG_PSE_LMAC2_PG_INFO_LMAC2_SRC_CNT_MASK, pg_flow_ctrl[13]);
3760+ seq_printf(s, "\t\tThe used/reserved pages of LMAC2 group=0x%03x/0x%03x\n", used_pg, rsv_pg);
3761+
3762+ seq_printf(s, "\tReserved page counter of LMAC3 group(0x82068188): 0x%08x\n", pg_flow_ctrl[16]);
3763+ seq_printf(s, "\tLMAC3 group page status(0x8206818c): 0x%08x\n", pg_flow_ctrl[17]);
3764+ min_q = FIELD_GET(MT_DBG_TOP_PG_LMAC3_GROUP_LMAC3_MIN_QUOTA_MASK, pg_flow_ctrl[16]);
3765+ max_q = FIELD_GET(MT_DBG_PSE_PG_LMAC3_GROUP_LMAC3_MAX_QUOTA_MASK, pg_flow_ctrl[16]);
3766+ seq_printf(s, "\t\tThe max/min quota pages of LMAC3 group=0x%03x/0x%03x\n", max_q, min_q);
3767+ rsv_pg = FIELD_GET(MT_DBG_PSE_LMAC3_PG_INFO_LMAC3_RSV_CNT_MASK, pg_flow_ctrl[17]);
3768+ used_pg = FIELD_GET(MT_DBG_PSE_LMAC3_PG_INFO_LMAC3_SRC_CNT_MASK, pg_flow_ctrl[17]);
3769+ seq_printf(s, "\t\tThe used/reserved pages of LMAC3 group=0x%03x/0x%03x\n", used_pg, rsv_pg);
3770+
3771+ seq_printf(s, "\tReserved page counter of PLE group(0x82068160): 0x%08x\n", pg_flow_ctrl[14]);
3772+ seq_printf(s, "\tPLE group page status(0x82068164): 0x%08x\n", pg_flow_ctrl[15]);
3773+ min_q = FIELD_GET(MT_DBG_PSE_PG_PLE_GROUP_PLE_MIN_QUOTA_MASK, pg_flow_ctrl[14]);
3774+ max_q = FIELD_GET(MT_DBG_PSE_PG_PLE_GROUP_PLE_MAX_QUOTA_MASK, pg_flow_ctrl[14]);
3775+ seq_printf(s, "\t\tThe max/min quota pages of PLE group=0x%03x/0x%03x\n", max_q, min_q);
3776+ rsv_pg = FIELD_GET(MT_DBG_PSE_PLE_PG_INFO_PLE_RSV_CNT_MASK, pg_flow_ctrl[15]);
3777+ used_pg = FIELD_GET(MT_DBG_PSE_PLE_PG_INFO_PLE_SRC_CNT_MASK, pg_flow_ctrl[15]);
3778+ seq_printf(s, "\t\tThe used/reserved pages of PLE group=0x%03x/0x%03x\n", used_pg, rsv_pg);
3779+
3780+ seq_printf(s, "\tReserved page counter of PLE1 group(0x82068168): 0x%08x\n", pg_flow_ctrl[14]);
3781+ seq_printf(s, "\tPLE1 group page status(0x8206816c): 0x%08x\n", pg_flow_ctrl[15]);
3782+ min_q = FIELD_GET(MT_DBG_PSE_PG_PLE_GROUP_PLE_MIN_QUOTA_MASK, pg_flow_ctrl[20]);
3783+ max_q = FIELD_GET(MT_DBG_PSE_PG_PLE_GROUP_PLE_MAX_QUOTA_MASK, pg_flow_ctrl[20]);
3784+ seq_printf(s, "\t\tThe max/min quota pages of PLE1 group=0x%03x/0x%03x\n", max_q, min_q);
3785+ rsv_pg = FIELD_GET(MT_DBG_PSE_PLE_PG_INFO_PLE_RSV_CNT_MASK, pg_flow_ctrl[21]);
3786+ used_pg = FIELD_GET(MT_DBG_PSE_PLE_PG_INFO_PLE_SRC_CNT_MASK, pg_flow_ctrl[21]);
3787+ seq_printf(s, "\t\tThe used/reserved pages of PLE1 group=0x%03x/0x%03x\n", used_pg, rsv_pg);
3788+
3789+ seq_printf(s, "\tReserved page counter of MDP group(0x82068198): 0x%08x\n", pg_flow_ctrl[18]);
3790+ seq_printf(s, "\tMDP group page status(0x8206819c): 0x%08x\n", pg_flow_ctrl[19]);
3791+ min_q = FIELD_GET(MT_DBG_PSE_PG_MDP_GROUP_MDP_MIN_QUOTA_MASK, pg_flow_ctrl[18]);
3792+ max_q = FIELD_GET(MT_DBG_PSE_PG_MDP_GROUP_MDP_MAX_QUOTA_MASK, pg_flow_ctrl[18]);
3793+ seq_printf(s, "\t\tThe max/min quota pages of MDP group=0x%03x/0x%03x\n", max_q, min_q);
3794+ rsv_pg = FIELD_GET(MT_DBG_PSE_MDP_PG_INFO_MDP_RSV_CNT_MASK, pg_flow_ctrl[19]);
3795+ used_pg = FIELD_GET(MT_DBG_PSE_MDP_PG_INFO_MDP_SRC_CNT_MASK, pg_flow_ctrl[19]);
3796+ seq_printf(s, "\t\tThe used/reserved pages of MDP group=0x%03x/0x%03x\n", used_pg, rsv_pg);
3797+
3798+ /* Queue Empty Status */
3799+ seq_printf(s, "PSE Queue Empty Status:\n");
3800+ seq_printf(s, "\tQUEUE_EMPTY(0x820680b0): 0x%08x\n", pse_stat);
3801+ seq_printf(s, "\t\tCPU Q0/1/2/3 empty=%ld/%ld/%ld/%ld\n",
3802+ FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_CPU_Q0_EMPTY_MASK, pse_stat),
3803+ FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_CPU_Q1_EMPTY_MASK, pse_stat),
3804+ FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_CPU_Q2_EMPTY_MASK, pse_stat),
3805+ FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_CPU_Q3_EMPTY_MASK, pse_stat));
3806+
3807+ seq_printf(s, "\t\tHIF Q0/1/2/3/4/5 empty=%ld/%ld/%ld/%ld/%ld/%ld\n",
3808+ FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_HIF_0_EMPTY_MASK, pse_stat),
3809+ FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_HIF_1_EMPTY_MASK, pse_stat),
3810+ FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_HIF_2_EMPTY_MASK, pse_stat),
3811+ FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_HIF_3_EMPTY_MASK, pse_stat),
3812+ FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_HIF_4_EMPTY_MASK, pse_stat),
3813+ FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_HIF_5_EMPTY_MASK, pse_stat));
3814+
3815+ seq_printf(s, "\t\tLMAC TX Q empty=%ld\n",
3816+ FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_LMAC_TX_QUEUE_EMPTY_MASK, pse_stat));
3817+ seq_printf(s, "\t\tMDP TX Q/RX Q empty=%ld/%ld\n",
3818+ FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_MDP_TX_QUEUE_EMPTY_MASK, pse_stat),
3819+ FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_MDP_RX_QUEUE_EMPTY_MASK, pse_stat));
3820+ seq_printf(s, "\t\tSEC TX Q/RX Q empty=%ld/%ld\n",
3821+ FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_SEC_TX_QUEUE_EMPTY_MASK, pse_stat),
3822+ FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_SEC_RX_QUEUE_EMPTY_SHFT, pse_stat));
3823+ seq_printf(s, "\t\tSFD PARK Q empty=%ld\n",
3824+ FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_SFD_PARK_QUEUE_EMPTY_MASK, pse_stat));
3825+ seq_printf(s, "\t\tMDP TXIOC Q/RXIOC Q empty=%ld/%ld\n",
3826+ FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_MDP_TXIOC_QUEUE_EMPTY_MASK, pse_stat),
3827+ FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_MDP_RXIOC_QUEUE_EMPTY_MASK, pse_stat));
3828+ seq_printf(s, "\t\tRLS Q empty=%ld\n",
3829+ FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_RLS_Q_EMTPY_MASK, pse_stat));
3830+ seq_printf(s, "Nonempty Q info:\n");
3831+
3832+ for (i = 0; i < 31; i++) {
3833+ if (((pse_stat & (0x1 << i)) >> i) == 0) {
3834+ u32 hfid, tfid, pktcnt, fl_que_ctrl[3] = {0};
3835+
3836+ if (pse_queue_empty_info[i].QueueName != NULL) {
3837+ seq_printf(s, "\t%s: ", pse_queue_empty_info[i].QueueName);
3838+ fl_que_ctrl[0] |= MT_DBG_PSE_FL_QUE_CTRL_0_EXECUTE_MASK;
3839+ fl_que_ctrl[0] |= (pse_queue_empty_info[i].Portid << MT_DBG_PSE_FL_QUE_CTRL_0_Q_BUF_PID_SHFT);
3840+ fl_que_ctrl[0] |= (pse_queue_empty_info[i].Queueid << MT_DBG_PSE_FL_QUE_CTRL_0_Q_BUF_QID_SHFT);
3841+ } else
3842+ continue;
3843+
3844+ fl_que_ctrl[0] |= (0x1 << 31);
3845+
3846+ mt76_wr(dev, MT_DBG_PSE_FL_QUE_CTRL_0_ADDR, fl_que_ctrl[0]);
3847+ fl_que_ctrl[1] = mt76_rr(dev, MT_DBG_PSE_FL_QUE_CTRL_2_ADDR);
3848+ fl_que_ctrl[2] = mt76_rr(dev, MT_DBG_PSE_FL_QUE_CTRL_3_ADDR);
3849+
3850+ hfid = FIELD_GET(MT_DBG_PSE_FL_QUE_CTRL_2_QUEUE_HEAD_FID_MASK, fl_que_ctrl[1]);
3851+ tfid = FIELD_GET(MT_DBG_PSE_FL_QUE_CTRL_2_QUEUE_TAIL_FID_MASK, fl_que_ctrl[1]);
3852+ pktcnt = FIELD_GET(MT_DBG_PSE_FL_QUE_CTRL_3_QUEUE_PKT_NUM_MASK, fl_que_ctrl[2]);
3853+ seq_printf(s, "tail/head fid = 0x%03x/0x%03x, pkt cnt = 0x%03x\n",
3854+ tfid, hfid, pktcnt);
3855+ }
3856+ }
3857+
3858+ return 0;
3859+}
3860+
3861+static int mt7915_mibinfo_read_per_band(struct seq_file *s, int band_idx)
3862+{
3863+#define BSS_NUM 4
3864+ struct mt7915_dev *dev = dev_get_drvdata(s->private);
3865+ u32 mac_val0, mac_val, mac_val1, idx, band_offset = 0;
3866+ u32 msdr6, msdr7, msdr8, msdr9, msdr10, msdr16, msdr17, msdr18, msdr19, msdr20, msdr21;
3867+ u32 mbxsdr[BSS_NUM][7];
3868+ u32 mbtcr[16], mbtbcr[16], mbrcr[16], mbrbcr[16];
3869+ u32 btcr[BSS_NUM], btbcr[BSS_NUM], brcr[BSS_NUM], brbcr[BSS_NUM], btdcr[BSS_NUM], brdcr[BSS_NUM];
3870+ u32 mu_cnt[5];
3871+ u32 ampdu_cnt[3];
3872+ unsigned long per;
3873+
3874+ seq_printf(s, "Band %d MIB Status\n", band_idx);
3875+ seq_printf(s, "===============================\n");
3876+ mac_val = mt76_rr(dev, MT_DBG_MIB_M0SCR0(band_idx));
3877+ seq_printf(s, "MIB Status Control=0x%x\n", mac_val);
3878+ if (is_mt7915(&dev->mt76)) {
3879+ mac_val = mt76_rr(dev, MT_DBG_MIB_M0PBSCR(band_idx));
3880+ seq_printf(s, "MIB Per-BSS Status Control=0x%x\n", mac_val);
3881+ }
3882+
3883+ msdr6 = mt76_rr(dev, MT_DBG_MIB_M0SDR6(band_idx));
3884+ msdr7 = mt76_rr(dev, MT_DBG_MIB_M0SDR7(band_idx));
3885+ msdr8 = mt76_rr(dev, MT_DBG_MIB_M0SDR8(band_idx));
3886+ msdr9 = mt76_rr(dev, MT_DBG_MIB_M0SDR9(band_idx));
3887+ msdr10 = mt76_rr(dev, MT_DBG_MIB_M0SDR10(band_idx));
3888+ msdr16 = mt76_rr(dev, MT_DBG_MIB_M0SDR16(band_idx));
3889+ msdr17 = mt76_rr(dev, MT_DBG_MIB_M0SDR17(band_idx));
3890+ msdr18 = mt76_rr(dev, MT_DBG_MIB_M0SDR18(band_idx));
3891+ msdr19 = mt76_rr(dev, MT_DBG_MIB_M0SDR19(band_idx));
3892+ msdr20 = mt76_rr(dev, MT_DBG_MIB_M0SDR20(band_idx));
3893+ msdr21 = mt76_rr(dev, MT_DBG_MIB_M0SDR21(band_idx));
3894+ ampdu_cnt[0] = mt76_rr(dev, MT_DBG_MIB_M0SDR12(band_idx));
3895+ ampdu_cnt[1] = mt76_rr(dev, MT_DBG_MIB_M0SDR14(band_idx));
3896+ ampdu_cnt[2] = mt76_rr(dev, MT_DBG_MIB_M0SDR15(band_idx));
3897+ ampdu_cnt[1] &= MT_DBG_MIB_M0SDR14_AMPDU_MASK;
3898+ ampdu_cnt[2] &= MT_DBG_MIB_M0SDR15_AMPDU_ACKED_MASK;
3899+
3900+ seq_printf(s, "===Phy/Timing Related Counters===\n");
3901+ seq_printf(s, "\tChannelIdleCnt=0x%x\n", msdr6 & BN0_WF_MIB_TOP_M0SDR6_CHANNEL_IDLE_COUNT_MASK);
3902+ seq_printf(s, "\tCCA_NAV_Tx_Time=0x%x\n", msdr9 & BN0_WF_MIB_TOP_M0SDR9_CCA_NAV_TX_TIME_MASK);
3903+ seq_printf(s, "\tRx_MDRDY_CNT=0x%lx\n", msdr10 & MT_DBG_MIB_M0SDR10_RX_MDRDY_COUNT_MASK);
3904+ seq_printf(s, "\tCCK_MDRDY_TIME=0x%x, OFDM_MDRDY_TIME=0x%x, OFDM_GREEN_MDRDY_TIME=0x%x\n",
3905+ msdr19 & BN0_WF_MIB_TOP_M0SDR19_CCK_MDRDY_TIME_MASK,
3906+ msdr20 & BN0_WF_MIB_TOP_M0SDR20_OFDM_LG_MIXED_VHT_MDRDY_TIME_MASK,
3907+ msdr21 & BN0_WF_MIB_TOP_M0SDR21_OFDM_GREEN_MDRDY_TIME_MASK);
3908+ seq_printf(s, "\tPrim CCA Time=0x%x\n", msdr16 & BN0_WF_MIB_TOP_M0SDR16_P_CCA_TIME_MASK);
3909+ seq_printf(s, "\tSec CCA Time=0x%x\n", msdr17 & BN0_WF_MIB_TOP_M0SDR17_S_CCA_TIME_MASK);
3910+ seq_printf(s, "\tPrim ED Time=0x%x\n", msdr18 & BN0_WF_MIB_TOP_M0SDR18_P_ED_TIME_MASK);
3911+
3912+ seq_printf(s, "===Tx Related Counters(Generic)===\n");
3913+ mac_val = mt76_rr(dev, MT_DBG_MIB_M0SDR0(band_idx));
3914+ dev->dbg.bcn_total_cnt[band_idx] += (mac_val & BN0_WF_MIB_TOP_M0SDR0_BEACONTXCOUNT_MASK);
3915+ seq_printf(s, "\tBeaconTxCnt=0x%x\n",dev->dbg.bcn_total_cnt[band_idx]);
3916+ dev->dbg.bcn_total_cnt[band_idx] = 0;
3917+ mac_val = mt76_rr(dev, MT_DBG_MIB_M0DR0(band_idx));
3918+ seq_printf(s, "\tTx 20MHz Cnt=0x%x\n", mac_val & BN0_WF_MIB_TOP_M0DR0_TX_20MHZ_CNT_MASK);
3919+ 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);
3920+ mac_val = mt76_rr(dev, MT_DBG_MIB_M0DR1(band_idx));
3921+ seq_printf(s, "\tTx 80MHz Cnt=0x%x\n", mac_val & BN0_WF_MIB_TOP_M0DR1_TX_80MHZ_CNT_MASK);
3922+ 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);
3923+ seq_printf(s, "\tAMPDU Cnt=0x%x\n", ampdu_cnt[0]);
3924+ seq_printf(s, "\tAMPDU MPDU Cnt=0x%x\n", ampdu_cnt[1]);
3925+ seq_printf(s, "\tAMPDU MPDU Ack Cnt=0x%x\n", ampdu_cnt[2]);
3926+ per = (ampdu_cnt[2] == 0 ? 0 : 1000 * (ampdu_cnt[1] - ampdu_cnt[2]) / ampdu_cnt[1]);
3927+ seq_printf(s, "\tAMPDU MPDU PER=%ld.%1ld%%\n", per / 10, per % 10);
3928+
3929+ seq_printf(s, "===MU Related Counters===\n");
3930+ mu_cnt[0] = mt76_rr(dev, MT_DBG_MIB_MUBF(band_idx));
3931+ mu_cnt[1] = mt76_rr(dev, MT_DBG_MIB_M0DR8(band_idx));
3932+ mu_cnt[2] = mt76_rr(dev, MT_DBG_MIB_M0DR9(band_idx));
3933+ mu_cnt[3] = mt76_rr(dev, MT_DBG_MIB_M0DR10(band_idx));
3934+ mu_cnt[4] = mt76_rr(dev, MT_DBG_MIB_M0DR11(band_idx));
3935+ seq_printf(s, "\tMUBF_TX_COUNT=0x%x\n", mu_cnt[0] & BN0_WF_MIB_TOP_M0SDR34_MUBF_TX_COUNT_MASK);
3936+ seq_printf(s, "\tMU_TX_MPDU_COUNT(Ok+Fail)=0x%x\n", mu_cnt[1]);
3937+ seq_printf(s, "\tMU_TX_OK_MPDU_COUNT=0x%x\n", mu_cnt[2]);
3938+ seq_printf(s, "\tMU_TO_SU_PPDU_COUNT=0x%x\n", mu_cnt[3] & BN0_WF_MIB_TOP_M0DR10_MU_FAIL_PPDU_CNT_MASK);
3939+ seq_printf(s, "\tSU_TX_OK_MPDU_COUNT=0x%x\n", mu_cnt[4]);
3940+
3941+ seq_printf(s, "===Rx Related Counters(Generic)===\n");
3942+ seq_printf(s, "\tVector Mismacth Cnt=0x%x\n", msdr7 & BN0_WF_MIB_TOP_M0SDR7_VEC_MISS_COUNT_MASK);
3943+ seq_printf(s, "\tDelimiter Fail Cnt=0x%x\n", msdr8 & BN0_WF_MIB_TOP_M0SDR8_DELIMITER_FAIL_COUNT_MASK);
3944+
3945+ mac_val = mt76_rr(dev, MT_DBG_MIB_M0SDR3(band_idx));
3946+ seq_printf(s, "\tRxFCSErrCnt=0x%lx\n", __DBG_FIELD_GET(DBG_MIB_RX_FCS_ERROR_COUNT, mac_val));
3947+ mac_val = mt76_rr(dev, MT_DBG_MIB_M0SDR4(band_idx));
3948+ seq_printf(s, "\tRxFifoFullCnt=0x%x\n", (mac_val & BN0_WF_MIB_TOP_M0SDR4_RX_FIFO_FULL_COUNT_MASK));
3949+ mac_val = mt76_rr(dev, MT_DBG_MIB_M0SDR11(band_idx));
3950+ seq_printf(s, "\tRxLenMismatch=0x%x\n", (mac_val & BN0_WF_MIB_TOP_M0SDR11_RX_LEN_MISMATCH_MASK));
3951+ mac_val = mt76_rr(dev, MT_DBG_MIB_M0SDR5(band_idx));
3952+ seq_printf(s, "\tRxMPDUCnt=0x%x\n", (mac_val & BN0_WF_MIB_TOP_M0SDR5_RX_MPDU_COUNT_MASK));
3953+ mac_val = mt76_rr(dev, MT_DBG_MIB_M0SDR22(band_idx));
3954+ seq_printf(s, "\tRx AMPDU Cnt=0x%x\n", mac_val);
3955+ /* TODO: shiang-MT7615, is MIB_M0SDR23 used for Rx total byte count for all or just AMPDU only??? */
3956+ mac_val = mt76_rr(dev, MT_DBG_MIB_M0SDR23(band_idx));
3957+ seq_printf(s, "\tRx Total ByteCnt=0x%x\n", mac_val);
3958+
3959+ if (is_mt7915(&dev->mt76)) {
3960+ band_offset = WF_WTBLON_TOP_B1BTCRn_ADDR - WF_WTBLON_TOP_B0BTCRn_ADDR;//check
3961+ seq_printf(s, "===Per-BSS Related Tx/Rx Counters===\n");
3962+ seq_printf(s, "BSS Idx TxCnt/DataCnt TxByteCnt RxCnt/DataCnt RxByteCnt\n");
3963+
3964+ for (idx = 0; idx < BSS_NUM; idx++) {
3965+ btcr[idx] = mt76_rr(dev, WF_WTBLON_TOP_B0BTCRn_ADDR + band_offset + idx * 4);
3966+ btbcr[idx] = mt76_rr(dev, WF_WTBLON_TOP_B0BTBCRn_ADDR + band_offset + idx * 4);
3967+ brcr[idx] = mt76_rr(dev, WF_WTBLON_TOP_B0BRCRn_ADDR + band_offset + idx * 4);
3968+ brbcr[idx] = mt76_rr(dev, WF_WTBLON_TOP_B0BRBCRn_ADDR + band_offset + idx * 4);
3969+ btdcr[idx] = mt76_rr(dev, WF_WTBLON_TOP_B0BTDCRn_ADDR + band_offset + idx * 4);
3970+ brdcr[idx] = mt76_rr(dev, WF_WTBLON_TOP_B0BRDCRn_ADDR + band_offset + idx * 4);
3971+ }
3972+
3973+ for (idx = 0; idx < BSS_NUM; idx++) {
3974+ seq_printf(s, "%d\t 0x%x/0x%x\t 0x%x \t 0x%x/0x%x \t 0x%x\n",
3975+ idx, btcr[idx], btdcr[idx], btbcr[idx],
3976+ brcr[idx], brdcr[idx], brbcr[idx]);
3977+ }
3978+
3979+ band_offset = (BN1_WF_MIB_TOP_BASE - BN0_WF_MIB_TOP_BASE) * band_idx;
3980+ seq_printf(s, "===Per-MBSS Related MIB Counters===\n");
3981+ seq_printf(s, "BSS Idx RTSTx/RetryCnt BAMissCnt AckFailCnt FrmRetry1/2/3Cnt\n");
3982+
3983+ for (idx = 0; idx < BSS_NUM; idx++) {
3984+ mbxsdr[idx][0] = mt76_rr(dev, BN0_WF_MIB_TOP_M0B0SDR0_ADDR + band_offset + idx * 0x10);
3985+ mbxsdr[idx][1] = mt76_rr(dev, BN0_WF_MIB_TOP_M0B0SDR1_ADDR + band_offset + idx * 0x10);
3986+ mbxsdr[idx][2] = mt76_rr(dev, BN0_WF_MIB_TOP_M0B0SDR2_ADDR + band_offset + idx * 0x10);
3987+ mbxsdr[idx][3] = mt76_rr(dev, BN0_WF_MIB_TOP_M0B0SDR3_ADDR + band_offset + idx * 0x10);
3988+ }
3989+
3990+ for (idx = 0; idx < BSS_NUM; idx++) {
3991+ seq_printf(s, "%d:\t0x%08x/0x%08x 0x%08x \t 0x%08x \t 0x%08x/0x%08x/0x%08x\n",
3992+ idx, (mbxsdr[idx][0] & BN0_WF_MIB_TOP_M0B0SDR0_RTSTXCOUNT_MASK),
3993+ (mbxsdr[idx][0] & BN0_WF_MIB_TOP_M0B0SDR0_RTSRETRYCOUNT_MASK) >> BN0_WF_MIB_TOP_M0B0SDR0_RTSRETRYCOUNT_SHFT,
3994+ (mbxsdr[idx][1] & BN0_WF_MIB_TOP_M0B0SDR1_BAMISSCOUNT_MASK),
3995+ (mbxsdr[idx][1] & BN0_WF_MIB_TOP_M0B0SDR1_ACKFAILCOUNT_MASK) >> BN0_WF_MIB_TOP_M0B0SDR1_ACKFAILCOUNT_SHFT,
3996+ (mbxsdr[idx][2] & BN0_WF_MIB_TOP_M0B0SDR2_FRAMERETRYCOUNT_MASK),
3997+ (mbxsdr[idx][2] & BN0_WF_MIB_TOP_M0B0SDR2_FRAMERETRY2COUNT_MASK) >> BN0_WF_MIB_TOP_M0B0SDR2_FRAMERETRY2COUNT_SHFT,
3998+ (mbxsdr[idx][3] & BN0_WF_MIB_TOP_M0B0SDR3_FRAMERETRY3COUNT_MASK));
3999+ }
4000+
4001+ band_offset = WF_WTBLON_TOP_B1BTCRn_ADDR - WF_WTBLON_TOP_B0BTCRn_ADDR;
4002+ seq_printf(s, "===Per-MBSS Related Tx/Rx Counters===\n");
4003+ seq_printf(s, "MBSSIdx TxCnt TxByteCnt RxCnt RxByteCnt\n");
4004+
4005+ for (idx = 0; idx < 16; idx++) {
4006+ mbtcr[idx] = mt76_rr(dev, WF_WTBLON_TOP_B0MBTCRn_ADDR + band_offset + idx * 4);
4007+ mbtbcr[idx] = mt76_rr(dev, WF_WTBLON_TOP_B0MBTBCRn_ADDR + band_offset + idx * 4);
4008+ mbrcr[idx] = mt76_rr(dev, WF_WTBLON_TOP_B0MBRCRn_ADDR + band_offset + idx * 4);
4009+ mbrbcr[idx] = mt76_rr(dev, WF_WTBLON_TOP_B0MBRBCRn_ADDR + band_offset + idx * 4);
4010+ }
4011+
4012+ for (idx = 0; idx < 16; idx++) {
4013+ seq_printf(s, "%d\t 0x%08x\t 0x%08x \t 0x%08x \t 0x%08x\n",
4014+ idx, mbtcr[idx], mbtbcr[idx], mbrcr[idx], mbrbcr[idx]);
4015+ }
4016+ return 0;
4017+ } else {
4018+ u32 btocr[BSS_NUM], mbtocr[16],mbrocr[16], brocr[BSS_NUM];
4019+ u8 bss_nums = BSS_NUM;
4020+
4021+ band_offset = (BN1_WF_MIB_TOP_BTOCR_ADDR - BN0_WF_MIB_TOP_BTOCR_ADDR) * band_idx;
4022+ seq_printf(s, "===Per-BSS Related Tx/Rx Counters===\n");
4023+ seq_printf(s, "BSS Idx TxCnt/DataCnt TxByteCnt RxCnt/DataCnt RxByteCnt\n");
4024+
4025+ for (idx = 0; idx < BSS_NUM; idx++) {
4026+ btocr[idx] = mt76_rr(dev, (BN0_WF_MIB_TOP_BTOCR_ADDR + band_offset + (idx >> 1) * 4));
4027+ btdcr[idx] = mt76_rr(dev, (BN0_WF_MIB_TOP_BTDCR_ADDR + band_offset + (idx >> 1) * 4));
4028+ btbcr[idx] = mt76_rr(dev, (BN0_WF_MIB_TOP_BTBCR_ADDR + band_offset + (idx * 4)));
4029+ brocr[idx] = mt76_rr(dev, (BN0_WF_MIB_TOP_BROCR_ADDR + band_offset + (idx >> 1) * 4));
4030+ brdcr[idx] = mt76_rr(dev, (BN0_WF_MIB_TOP_BRDCR_ADDR + band_offset + (idx >> 1) * 4));
4031+ brbcr[idx] = mt76_rr(dev, (BN0_WF_MIB_TOP_BRBCR_ADDR + band_offset + (idx * 4)));
4032+
4033+ if ((idx % 2) == 0) {
4034+ btocr[idx] = ((btocr[idx] & BN0_WF_MIB_TOP_BTOCR_TX_OK_COUNT2n_MASK) >> BN0_WF_MIB_TOP_BTOCR_TX_OK_COUNT2n_SHFT);
4035+ btdcr[idx] = ((btdcr[idx] & BN0_WF_MIB_TOP_BTDCR_TX_DATA_COUNT2n_MASK) >> BN0_WF_MIB_TOP_BTDCR_TX_DATA_COUNT2n_SHFT);
4036+ brocr[idx] = ((brocr[idx] & BN0_WF_MIB_TOP_BROCR_RX_OK_COUNT2n_MASK) >> BN0_WF_MIB_TOP_BROCR_RX_OK_COUNT2n_SHFT);
4037+ brdcr[idx] = ((brdcr[idx] & BN0_WF_MIB_TOP_BRDCR_RX_DATA_COUNT2n_MASK) >> BN0_WF_MIB_TOP_BRDCR_RX_DATA_COUNT2n_SHFT);
4038+ } else {
4039+ btocr[idx] = ((btocr[idx] & BN0_WF_MIB_TOP_BTOCR_TX_OK_COUNT2np1_MASK) >> BN0_WF_MIB_TOP_BTOCR_TX_OK_COUNT2np1_SHFT);
4040+ btdcr[idx] = ((btdcr[idx] & BN0_WF_MIB_TOP_BTDCR_TX_DATA_COUNT2np1_MASK) >> BN0_WF_MIB_TOP_BTDCR_TX_DATA_COUNT2np1_SHFT);
4041+ brocr[idx] = ((brocr[idx] & BN0_WF_MIB_TOP_BROCR_RX_OK_COUNT2np1_MASK) >> BN0_WF_MIB_TOP_BROCR_RX_OK_COUNT2np1_SHFT);
4042+ brdcr[idx] = ((brdcr[idx] & BN0_WF_MIB_TOP_BRDCR_RX_DATA_COUNT2np1_MASK) >> BN0_WF_MIB_TOP_BRDCR_RX_DATA_COUNT2np1_SHFT);
4043+ }
4044+ }
4045+
4046+ for (idx = 0; idx < BSS_NUM; idx++) {
4047+ seq_printf(s, "%d\t 0x%x/0x%x\t 0x%x \t 0x%x/0x%x \t 0x%x\n",
4048+ idx, btocr[idx], btdcr[idx], btbcr[idx], brocr[idx], brdcr[idx], brbcr[idx]);
4049+ }
4050+
4051+ band_offset = (BN1_WF_MIB_TOP_BASE - BN0_WF_MIB_TOP_BASE) * band_idx;
4052+ seq_printf(s, "===Per-MBSS Related MIB Counters===\n");
4053+ seq_printf(s, "BSS Idx RTSTx/RetryCnt BAMissCnt AckFailCnt FrmRetry1/2/3Cnt\n");
4054+
4055+ for (idx = 0; idx < BSS_NUM; idx++) {
4056+ mbxsdr[idx][0] = mt76_rr(dev, BN0_WF_MIB_TOP_BSDR0_ADDR + band_offset + ((idx >> 1) * 4));
4057+ mbxsdr[idx][1] = mt76_rr(dev, BN0_WF_MIB_TOP_BSDR1_ADDR + band_offset + ((idx >> 1) * 4));
4058+ mbxsdr[idx][2] = mt76_rr(dev, BN0_WF_MIB_TOP_BSDR2_ADDR + band_offset + ((idx >> 1) * 4));
4059+ mbxsdr[idx][3] = mt76_rr(dev, BN0_WF_MIB_TOP_BSDR3_ADDR + band_offset + ((idx >> 1) * 4));
4060+ mbxsdr[idx][4] = mt76_rr(dev, BN0_WF_MIB_TOP_BSDR4_ADDR + band_offset + ((idx >> 1) * 4));
4061+ mbxsdr[idx][5] = mt76_rr(dev, BN0_WF_MIB_TOP_BSDR5_ADDR + band_offset + ((idx >> 1) * 4));
4062+ mbxsdr[idx][6] = mt76_rr(dev, BN0_WF_MIB_TOP_BSDR6_ADDR + band_offset + ((idx >> 1) * 4));
4063+
4064+ if ((idx % 2) == 0) {
4065+ mbxsdr[idx][0] = ((mbxsdr[idx][0] & BN0_WF_MIB_TOP_BSDR0_RTSTXCOUNT2n_MASK) >> BN0_WF_MIB_TOP_BSDR0_RTSTXCOUNT2n_SHFT);
4066+ mbxsdr[idx][1] = ((mbxsdr[idx][1] & BN0_WF_MIB_TOP_BSDR1_RTSRETRYCOUNT2n_MASK) >> BN0_WF_MIB_TOP_BSDR1_RTSRETRYCOUNT2n_SHFT);
4067+ mbxsdr[idx][2] = ((mbxsdr[idx][2] & BN0_WF_MIB_TOP_BSDR2_BAMISSCOUNT2n_MASK) >> BN0_WF_MIB_TOP_BSDR2_BAMISSCOUNT2n_SHFT);
4068+ mbxsdr[idx][3] = ((mbxsdr[idx][3] & BN0_WF_MIB_TOP_BSDR3_ACKFAILCOUNT2n_MASK) >> BN0_WF_MIB_TOP_BSDR3_ACKFAILCOUNT2n_SHFT);
4069+ mbxsdr[idx][4] = ((mbxsdr[idx][4] & BN0_WF_MIB_TOP_BSDR4_FRAMERETRYCOUNT2n_MASK) >> BN0_WF_MIB_TOP_BSDR4_FRAMERETRYCOUNT2n_SHFT);
4070+ mbxsdr[idx][5] = ((mbxsdr[idx][5] & BN0_WF_MIB_TOP_BSDR5_FRAMERETRY2COUNT2n_MASK) >> BN0_WF_MIB_TOP_BSDR5_FRAMERETRY2COUNT2n_SHFT);
4071+ mbxsdr[idx][6] = ((mbxsdr[idx][6] & BN0_WF_MIB_TOP_BSDR6_FRAMERETRY3COUNT2n_MASK) >> BN0_WF_MIB_TOP_BSDR6_FRAMERETRY3COUNT2n_SHFT);
4072+ } else {
4073+ mbxsdr[idx][0] = ((mbxsdr[idx][0] & BN0_WF_MIB_TOP_BSDR0_RTSTXCOUNT2np1_MASK) >> BN0_WF_MIB_TOP_BSDR0_RTSTXCOUNT2np1_SHFT);
4074+ mbxsdr[idx][1] = ((mbxsdr[idx][1] & BN0_WF_MIB_TOP_BSDR1_RTSRETRYCOUNT2np1_MASK) >> BN0_WF_MIB_TOP_BSDR1_RTSRETRYCOUNT2np1_SHFT);
4075+ mbxsdr[idx][2] = ((mbxsdr[idx][2] & BN0_WF_MIB_TOP_BSDR2_BAMISSCOUNT2np1_MASK) >> BN0_WF_MIB_TOP_BSDR2_BAMISSCOUNT2np1_SHFT);
4076+ mbxsdr[idx][3] = ((mbxsdr[idx][3] & BN0_WF_MIB_TOP_BSDR3_ACKFAILCOUNT2np1_MASK) >> BN0_WF_MIB_TOP_BSDR3_ACKFAILCOUNT2np1_SHFT);
4077+ mbxsdr[idx][4] = ((mbxsdr[idx][4] & BN0_WF_MIB_TOP_BSDR4_FRAMERETRYCOUNT2np1_MASK) >> BN0_WF_MIB_TOP_BSDR4_FRAMERETRYCOUNT2np1_SHFT);
4078+ mbxsdr[idx][5] = ((mbxsdr[idx][5] & BN0_WF_MIB_TOP_BSDR5_FRAMERETRY2COUNT2np1_MASK) >> BN0_WF_MIB_TOP_BSDR5_FRAMERETRY2COUNT2np1_SHFT);
4079+ mbxsdr[idx][6] = ((mbxsdr[idx][6] & BN0_WF_MIB_TOP_BSDR6_FRAMERETRY3COUNT2np1_MASK) >> BN0_WF_MIB_TOP_BSDR6_FRAMERETRY3COUNT2np1_SHFT);
4080+ }
4081+ }
4082+
4083+ for (idx = 0; idx < BSS_NUM; idx++) {
4084+ seq_printf(s, "%d:\t0x%x/0x%x 0x%x \t 0x%x \t 0x%x/0x%x/0x%x\n",
4085+ idx,
4086+ mbxsdr[idx][0], mbxsdr[idx][1], mbxsdr[idx][2], mbxsdr[idx][3],
4087+ mbxsdr[idx][4], mbxsdr[idx][5], mbxsdr[idx][6]);
4088+ }
4089+
4090+ band_offset = (BN1_WF_MIB_TOP_BTOCR_ADDR - BN0_WF_MIB_TOP_BTOCR_ADDR) * band_idx;
4091+ seq_printf(s, "===Per-MBSS Related Tx/Rx Counters===\n");
4092+ seq_printf(s, "MBSSIdx TxCnt TxByteCnt RxCnt RxByteCnt\n");
4093+
4094+ for (idx = 0; idx < 16; idx++) {
4095+ mbtocr[idx] = mt76_rr(dev, BN0_WF_MIB_TOP_BTOCR_ADDR + band_offset + (((bss_nums >> 1) * 4) + ((idx >> 1) * 4)));
4096+ mbtbcr[idx] = mt76_rr(dev, BN0_WF_MIB_TOP_BTBCR_ADDR + band_offset + (((bss_nums >> 1) * 4) + (idx * 4)));
4097+ mbrocr[idx] = mt76_rr(dev, BN0_WF_MIB_TOP_BROCR_ADDR + band_offset + (((bss_nums >> 1) * 4) + ((idx >> 1) * 4)));
4098+ mbrbcr[idx] = mt76_rr(dev, BN0_WF_MIB_TOP_BRBCR_ADDR + band_offset + (((bss_nums >> 1) * 4) + (idx * 4)));
4099+
4100+ if ((idx % 2) == 0) {
4101+ mbtocr[idx] = ((mbtocr[idx] & BN0_WF_MIB_TOP_BTOCR_TX_OK_COUNT2n_MASK) >> BN0_WF_MIB_TOP_BTOCR_TX_OK_COUNT2n_SHFT);
4102+ mbrocr[idx] = ((mbrocr[idx] & BN0_WF_MIB_TOP_BROCR_RX_OK_COUNT2n_MASK) >> BN0_WF_MIB_TOP_BROCR_RX_OK_COUNT2n_SHFT);
4103+ } else {
4104+ mbtocr[idx] = ((mbtocr[idx] & BN0_WF_MIB_TOP_BTOCR_TX_OK_COUNT2np1_MASK) >> BN0_WF_MIB_TOP_BTOCR_TX_OK_COUNT2np1_SHFT);
4105+ mbrocr[idx] = ((mbrocr[idx] & BN0_WF_MIB_TOP_BROCR_RX_OK_COUNT2np1_MASK) >> BN0_WF_MIB_TOP_BROCR_RX_OK_COUNT2np1_SHFT);
4106+ }
4107+ }
4108+
4109+ for (idx = 0; idx < 16; idx++) {
4110+ seq_printf(s, "%d\t 0x%08x\t 0x%08x \t 0x%08x \t 0x%08x\n",
4111+ idx, mbtocr[idx], mbtbcr[idx], mbrocr[idx], mbrbcr[idx]);
4112+ }
4113+ }
4114+
4115+ seq_printf(s, "===Dummy delimiter insertion result===\n");
4116+ mac_val0 = mt76_rr(dev, MT_DBG_MIB_M0DR11(band_idx));
4117+ mac_val = mt76_rr(dev, MT_DBG_MIB_M0DR6(band_idx));
4118+ mac_val1 = mt76_rr(dev, MT_DBG_MIB_M0DR7(band_idx));
4119+ seq_printf(s, "Range0 = %d\t Range1 = %d\t Range2 = %d\t Range3 = %d\t Range4 = %d\n",
4120+ (mac_val0 & BN0_WF_MIB_TOP_M0DR12_TX_DDLMT_RNG0_CNT_MASK),
4121+ (mac_val & BN0_WF_MIB_TOP_M0DR6_TX_DDLMT_RNG1_CNT_MASK),
4122+ (mac_val & BN0_WF_MIB_TOP_M0DR6_TX_DDLMT_RNG2_CNT_MASK) >> BN0_WF_MIB_TOP_M0DR6_TX_DDLMT_RNG2_CNT_SHFT,
4123+ (mac_val1 & BN0_WF_MIB_TOP_M0DR7_TX_DDLMT_RNG3_CNT_MASK),
4124+ (mac_val1 & BN0_WF_MIB_TOP_M0DR7_TX_DDLMT_RNG4_CNT_MASK) >> BN0_WF_MIB_TOP_M0DR7_TX_DDLMT_RNG4_CNT_SHFT);
4125+
4126+ return 0;
4127+}
4128+
4129+static int mt7915_mibinfo_band0(struct seq_file *s, void *data)
4130+{
4131+ mt7915_mibinfo_read_per_band(s, 0);
4132+ return 0;
4133+}
4134+
4135+static int mt7915_mibinfo_band1(struct seq_file *s, void *data)
4136+{
4137+ mt7915_mibinfo_read_per_band(s, 1);
4138+ return 0;
4139+}
4140+
4141+static int mt7915_token_read(struct seq_file *s, void *data)
4142+{
4143+ struct mt7915_dev *dev = dev_get_drvdata(s->private);
4144+ int id, count = 0;
4145+ struct mt76_txwi_cache *txwi;
4146+
4147+ seq_printf(s, "Cut through token:\n");
4148+ spin_lock_bh(&dev->mt76.token_lock);
4149+ idr_for_each_entry(&dev->mt76.token, txwi, id) {
4150+ seq_printf(s, "%4d ", id);
4151+ count++;
4152+ if (count % 8 == 0)
4153+ seq_printf(s, "\n");
4154+ }
4155+ spin_unlock_bh(&dev->mt76.token_lock);
4156+ seq_printf(s, "\n");
4157+
4158+ return 0;
4159+}
4160+
4161+struct txd_l {
4162+ u32 txd_0;
4163+ u32 txd_1;
4164+ u32 txd_2;
4165+ u32 txd_3;
4166+ u32 txd_4;
4167+ u32 txd_5;
4168+ u32 txd_6;
4169+ u32 txd_7;
4170+} __packed;
4171+
4172+char *pkt_ft_str[] = {"cut_through", "store_forward", "cmd", "PDA_FW_Download"};
4173+char *hdr_fmt_str[] = {
4174+ "Non-80211-Frame",
4175+ "Command-Frame",
4176+ "Normal-80211-Frame",
4177+ "enhanced-80211-Frame",
4178+};
4179+/* TMAC_TXD_1.hdr_format */
4180+#define TMI_HDR_FT_NON_80211 0x0
4181+#define TMI_HDR_FT_CMD 0x1
4182+#define TMI_HDR_FT_NOR_80211 0x2
4183+#define TMI_HDR_FT_ENH_80211 0x3
4184+
4185+void mt7915_dump_tmac_info(u8 *tmac_info)
4186+{
4187+ struct txd_l *txd = (struct txd_l *)tmac_info;
4188+
4189+ printk("txd raw data: size=%d\n", MT_TXD_SIZE);
4190+ print_hex_dump(KERN_ERR , "", DUMP_PREFIX_OFFSET, 16, 1, tmac_info, MT_TXD_SIZE, false);
4191+
4192+ printk("TMAC_TXD Fields:\n");
4193+ printk("\tTMAC_TXD_0:\n");
4194+
4195+ /* DW0 */
4196+ /* TX Byte Count [15:0] */
4197+ printk("\t\tTxByteCnt = %ld\n", FIELD_GET(MT_TXD0_TX_BYTES, txd->txd_0));
4198+
4199+ /* PKT_FT: Packet Format [24:23] */
4200+ printk("\t\tpkt_ft = %ld(%s)\n",
4201+ FIELD_GET(MT_TXD0_PKT_FMT, txd->txd_0),
4202+ pkt_ft_str[FIELD_GET(MT_TXD0_PKT_FMT, txd->txd_0)]);
4203+
4204+ /* Q_IDX [31:25] */
4205+ printk("\t\tQueID =0x%lx\n", FIELD_GET(MT_TXD0_Q_IDX, txd->txd_0));
4206+
4207+ printk("\tTMAC_TXD_1:\n");
4208+
4209+ /* DW1 */
4210+ /* WLAN Indec [9:0] */
4211+ printk("\t\tWlan Index = %ld\n", FIELD_GET(MT_TXD1_WLAN_IDX, txd->txd_1));
4212+
4213+ /* VTA [10] */
4214+ printk("\t\tVTA = %d\n", ((txd->txd_1 & MT_TXD1_VTA) ? 1 : 0));
4215+
4216+ /* HF: Header Format [17:16] */
4217+ printk("\t\tHdrFmt = %ld(%s)\n",
4218+ FIELD_GET(MT_TXD1_HDR_FORMAT, txd->txd_1),
4219+ FIELD_GET(MT_TXD1_HDR_FORMAT, txd->txd_1) < 4 ?
4220+ hdr_fmt_str[FIELD_GET(MT_TXD1_HDR_FORMAT, txd->txd_1)] : "N/A");
4221+
4222+ switch (FIELD_GET(MT_TXD1_HDR_FORMAT, txd->txd_1)) {
4223+ case TMI_HDR_FT_NON_80211:
4224+ /* MRD [11], EOSP [12], RMVL [13], VLAN [14], ETYPE [15] */
4225+ printk("\t\t\tMRD = %d, EOSP = %d,\
4226+ RMVL = %d, VLAN = %d, ETYP = %d\n",
4227+ (txd->txd_1 & MT_TXD1_MRD) ? 1 : 0,
4228+ (txd->txd_1 & MT_TXD1_EOSP) ? 1 : 0,
4229+ (txd->txd_1 & MT_TXD1_RMVL) ? 1 : 0,
4230+ (txd->txd_1 & MT_TXD1_VLAN) ? 1 : 0,
4231+ (txd->txd_1 & MT_TXD1_ETYP) ? 1 : 0);
4232+ break;
4233+ case TMI_HDR_FT_NOR_80211:
4234+ /* HEADER_LENGTH [15:11] */
4235+ printk("\t\t\tHeader Len = %ld(WORD)\n", FIELD_GET(MT_TXD1_HDR_INFO, txd->txd_1));
4236+ break;
4237+
4238+ case TMI_HDR_FT_ENH_80211:
4239+ /* EOSP [12], AMS [13] */
4240+ printk("\t\t\tEOSP = %d, AMS = %d\n",
4241+ (txd->txd_1 & MT_TXD1_EOSP) ? 1 : 0,
4242+ (txd->txd_1 & MT_TXD1_AMS) ? 1 : 0);
4243+ break;
4244+ }
4245+
4246+ /* Header Padding [19:18] */
4247+ printk("\t\tHdrPad = %ld\n", FIELD_GET(MT_TXD1_HDR_PAD, txd->txd_1));
4248+
4249+ /* TID [22:20] */
4250+ printk("\t\tTID = %ld\n", FIELD_GET(MT_TXD1_TID, txd->txd_1));
4251+
4252+
4253+ /* UtxB/AMSDU_C/AMSDU [23] */
4254+ printk("\t\tamsdu = %d\n", ((txd->txd_1 & MT_TXD1_AMSDU) ? 1 : 0));
4255+
4256+ /* OM [29:24] */
4257+ printk("\t\town_mac = %ld\n", FIELD_GET(MT_TXD1_OWN_MAC, txd->txd_1));
4258+
4259+
4260+ /* TGID [30] */
4261+ printk("\t\tTGID = %d\n", ((txd->txd_1 & MT_TXD1_TGID) ? 1 : 0));
4262+
4263+
4264+ /* FT [31] */
4265+ printk("\t\tTxDFormatType = %d\n", (txd->txd_1 & MT_TXD1_LONG_FORMAT) ? 1 : 0);
4266+
4267+ printk("\tTMAC_TXD_2:\n");
4268+ /* DW2 */
4269+ /* Subtype [3:0] */
4270+ printk("\t\tsub_type = %ld\n", FIELD_GET(MT_TXD2_SUB_TYPE, txd->txd_2));
4271+
4272+ /* Type[5:4] */
4273+ printk("\t\tfrm_type = %ld\n", FIELD_GET(MT_TXD2_FRAME_TYPE, txd->txd_2));
4274+
4275+ /* NDP [6] */
4276+ printk("\t\tNDP = %d\n", ((txd->txd_2 & MT_TXD2_NDP) ? 1 : 0));
4277+
4278+ /* NDPA [7] */
4279+ printk("\t\tNDPA = %d\n", ((txd->txd_2 & MT_TXD2_NDPA) ? 1 : 0));
4280+
4281+ /* SD [8] */
4282+ printk("\t\tSounding = %d\n", ((txd->txd_2 & MT_TXD2_SOUNDING) ? 1 : 0));
4283+
4284+ /* RTS [9] */
4285+ printk("\t\tRTS = %d\n", ((txd->txd_2 & MT_TXD2_RTS) ? 1 : 0));
4286+
4287+ /* BM [10] */
4288+ printk("\t\tbc_mc_pkt = %d\n", ((txd->txd_2 & MT_TXD2_MULTICAST) ? 1 : 0));
4289+
4290+ /* B [11] */
4291+ printk("\t\tBIP = %d\n", ((txd->txd_2 & MT_TXD2_BIP) ? 1 : 0));
4292+
4293+ /* DU [12] */
4294+ printk("\t\tDuration = %d\n", ((txd->txd_2 & MT_TXD2_DURATION) ? 1 : 0));
4295+
4296+ /* HE [13] */
4297+ printk("\t\tHE(HTC Exist) = %d\n", ((txd->txd_2 & MT_TXD2_HTC_VLD) ? 1 : 0));
4298+
4299+ /* FRAG [15:14] */
4300+ printk("\t\tFRAG = %ld\n", FIELD_GET(MT_TXD2_FRAG, txd->txd_2));
4301+
4302+
4303+ /* Remaining Life Time [23:16]*/
4304+ printk("\t\tReamingLife/MaxTx time = %ld (unit: 64TU)\n",
4305+ FIELD_GET(MT_TXD2_MAX_TX_TIME, txd->txd_2));
4306+
4307+ /* Power Offset [29:24] */
4308+ printk("\t\tpwr_offset = %ld\n", FIELD_GET(MT_TXD2_POWER_OFFSET, txd->txd_2));
4309+
4310+ /* FRM [30] */
4311+ printk("\t\tfix rate mode = %d\n", (txd->txd_2 & MT_TXD2_FIXED_RATE) ? 1 : 0);
4312+
4313+ /* FR[31] */
4314+ printk("\t\tfix rate = %d\n", (txd->txd_2 & MT_TXD2_FIX_RATE) ? 1 : 0);
4315+
4316+
4317+ printk("\tTMAC_TXD_3:\n");
4318+
4319+ /* DW3 */
4320+ /* NA [0] */
4321+ printk("\t\tNoAck = %d\n", (txd->txd_3 & MT_TXD3_NO_ACK) ? 1 : 0);
4322+
4323+ /* PF [1] */
4324+ printk("\t\tPF = %d\n", (txd->txd_3 & MT_TXD3_PROTECT_FRAME) ? 1 : 0);
4325+
4326+ /* EMRD [2] */
4327+ printk("\t\tEMRD = %d\n", (txd->txd_3 & MT_TXD3_EMRD) ? 1 : 0);
4328+
4329+ /* EEOSP [3] */
4330+ printk("\t\tEEOSP = %d\n", (txd->txd_3 & MT_TXD3_EEOSP) ? 1 : 0);
4331+
4332+ /* DAS [4] */
4333+ printk("\t\tda_select = %d\n", (txd->txd_3 & MT_TXD3_DAS) ? 1 : 0);
4334+
4335+ /* TM [5] */
4336+ printk("\t\ttm = %d\n", (txd->txd_3 & MT_TXD3_TIMING_MEASURE) ? 1 : 0);
4337+
4338+ /* TX Count [10:6] */
4339+ printk("\t\ttx_cnt = %ld\n", FIELD_GET(MT_TXD3_TX_COUNT, txd->txd_3));
4340+
4341+ /* Remaining TX Count [15:11] */
4342+ printk("\t\tremain_tx_cnt = %ld\n", FIELD_GET(MT_TXD3_REM_TX_COUNT, txd->txd_3));
4343+
4344+ /* SN [27:16] */
4345+ printk("\t\tsn = %ld\n", FIELD_GET(MT_TXD3_SEQ, txd->txd_3));
4346+
4347+ /* BA_DIS [28] */
4348+ printk("\t\tba dis = %d\n", (txd->txd_3 & MT_TXD3_BA_DISABLE) ? 1 : 0);
4349+
4350+ /* Power Management [29] */
4351+ printk("\t\tpwr_mgmt = 0x%x\n", (txd->txd_3 & MT_TXD3_SW_POWER_MGMT) ? 1 : 0);
4352+
4353+ /* PN_VLD [30] */
4354+ printk("\t\tpn_vld = %d\n", (txd->txd_3 & MT_TXD3_PN_VALID) ? 1 : 0);
4355+
4356+ /* SN_VLD [31] */
4357+ printk("\t\tsn_vld = %d\n", (txd->txd_3 & MT_TXD3_SN_VALID) ? 1 : 0);
4358+
4359+
4360+ /* DW4 */
4361+ printk("\tTMAC_TXD_4:\n");
4362+
4363+ /* PN_LOW [31:0] */
4364+ printk("\t\tpn_low = 0x%lx\n", FIELD_GET(MT_TXD4_PN_LOW, txd->txd_4));
4365+
4366+
4367+ /* DW5 */
4368+ printk("\tTMAC_TXD_5:\n");
4369+
4370+ /* PID [7:0] */
4371+ printk("\t\tpid = %ld\n", FIELD_GET(MT_TXD5_PID, txd->txd_5));
4372+
4373+ /* TXSFM [8] */
4374+ printk("\t\ttx_status_fmt = %d\n", (txd->txd_5 & MT_TXD5_TX_STATUS_FMT) ? 1 : 0);
4375+
4376+ /* TXS2M [9] */
4377+ printk("\t\ttx_status_2_mcu = %d\n", (txd->txd_5 & MT_TXD5_TX_STATUS_MCU) ? 1 : 0);
4378+
4379+ /* TXS2H [10] */
4380+ printk("\t\ttx_status_2_host = %d\n", (txd->txd_5 & MT_TXD5_TX_STATUS_HOST) ? 1 : 0);
4381+
4382+ /* ADD_BA [14] */
4383+ printk("\t\tADD_BA = %d\n", (txd->txd_5 & MT_TXD5_ADD_BA) ? 1 : 0);
4384+
4385+ /* MD [15] */
4386+ printk("\t\tMD = %d\n", (txd->txd_5 & MT_TXD5_MD) ? 1 : 0);
4387+
4388+ /* PN_HIGH [31:16] */
4389+ printk("\t\tpn_high = 0x%lx\n", FIELD_GET(MT_TXD5_PN_HIGH, txd->txd_5));
4390+
4391+ /* DW6 */
4392+ printk("\tTMAC_TXD_6:\n");
4393+
4394+ if (txd->txd_2 & MT_TXD2_FIX_RATE) {
4395+ /* Fixed BandWidth mode [2:0] */
developerc5ce7502022-12-19 11:33:22 +08004396+ printk("\t\tbw = %ld\n",
4397+ FIELD_GET(MT_TXD6_BW, txd->txd_6) | (txd->txd_6 & MT_TXD6_FIXED_BW));
developer73e5a572022-04-19 10:21:20 +08004398+
4399+ /* DYN_BW [3] */
4400+ printk("\t\tdyn_bw = %d\n", (txd->txd_6 & MT_TXD6_DYN_BW) ? 1 : 0);
4401+
4402+ /* ANT_ID [7:4] */
4403+ printk("\t\tant_id = %ld\n", FIELD_GET(MT_TXD6_ANT_ID, txd->txd_6));
4404+
4405+ /* SPE_IDX_SEL [10] */
4406+ printk("\t\tspe_idx_sel = %d\n", (txd->txd_6 & MT_TXD6_SPE_ID_IDX) ? 1 : 0);
4407+
4408+ /* LDPC [11] */
4409+ printk("\t\tldpc = %d\n", (txd->txd_6 & MT_TXD6_LDPC) ? 1 : 0);
4410+
4411+ /* HELTF Type[13:12] */
4412+ printk("\t\tHELTF Type = %ld\n", FIELD_GET(MT_TXD6_HELTF, txd->txd_6));
4413+
4414+ /* GI Type [15:14] */
4415+ printk("\t\tGI = %ld\n", FIELD_GET(MT_TXD6_SGI, txd->txd_6));
4416+
4417+ /* Rate to be Fixed [29:16] */
4418+ printk("\t\ttx_rate = 0x%lx\n", FIELD_GET(MT_TXD6_TX_RATE, txd->txd_6));
4419+ }
4420+
4421+ /* TXEBF [30] */
4422+ printk("\t\ttxebf = %d\n", (txd->txd_6 & MT_TXD6_TX_EBF) ? 1 : 0);
4423+
4424+ /* TXIBF [31] */
4425+ printk("\t\ttxibf = %d\n", (txd->txd_6 & MT_TXD6_TX_IBF) ? 1 : 0);
4426+
4427+ /* DW7 */
4428+ printk("\tTMAC_TXD_7:\n");
4429+
4430+ if ((txd->txd_1 & MT_TXD1_VTA) == 0) {
4431+ /* SW Tx Time [9:0] */
4432+ printk("\t\tsw_tx_time = %ld\n", FIELD_GET(MT_TXD7_TX_TIME, txd->txd_7));
4433+ } else {
4434+ /* TXD Arrival Time [9:0] */
4435+ printk("\t\tat = %ld\n", FIELD_GET(MT_TXD7_TAT, txd->txd_7));
4436+ }
4437+
4438+ /* HW_AMSDU_CAP [10] */
4439+ printk("\t\thw amsdu cap = %d\n",(txd->txd_7 & MT_TXD7_HW_AMSDU) ? 1 : 0);
4440+
4441+ /* SPE_IDX [15:11] */
4442+ if (txd->txd_2 & MT_TXD2_FIX_RATE) {
4443+ printk("\t\tspe_idx = 0x%lx\n", FIELD_GET(MT_TXD7_SPE_IDX, txd->txd_7));
4444+ }
4445+
4446+ /* PSE_FID [27:16] */
4447+ printk("\t\tpse_fid = 0x%lx\n", FIELD_GET(MT_TXD7_PSE_FID, txd->txd_7));
4448+
4449+ /* Subtype [19:16] */
4450+ printk("\t\tpp_sub_type=%ld\n", FIELD_GET(MT_TXD7_SUB_TYPE, txd->txd_7));
4451+
4452+ /* Type [21:20] */
4453+ printk("\t\tpp_type=%ld\n", FIELD_GET(MT_TXD7_TYPE, txd->txd_7));
4454+
4455+ /* CTXD_CNT [25:23] */
4456+ printk("\t\tctxd cnt=0x%lx\n", FIELD_GET(MT_TXD7_CTXD_CNT, txd->txd_7));
4457+
4458+ /* CTXD [26] */
4459+ printk("\t\tctxd = %d\n", (txd->txd_7 & MT_TXD7_CTXD) ? 1 : 0);
4460+
4461+ /* I [28] */
4462+ printk("\t\ti = %d\n", (txd->txd_7 & MT_TXD7_IP_SUM) ? 1 : 0);
4463+
4464+ /* UT [29] */
4465+ printk("\t\tUT = %d\n", (txd->txd_7 & MT_TXD7_UDP_TCP_SUM) ? 1 : 0);
4466+
4467+ /* TXDLEN [31:30] */
4468+ printk("\t\t txd len= %ld\n", FIELD_GET(MT_TXD7_TXD_LEN, txd->txd_7));
4469+}
4470+
4471+
4472+static int mt7915_token_txd_read(struct seq_file *s, void *data)
4473+{
4474+ struct mt7915_dev *dev = dev_get_drvdata(s->private);
4475+ struct mt76_txwi_cache *t;
4476+ u8* txwi;
4477+
4478+ seq_printf(s, "\n");
4479+ spin_lock_bh(&dev->mt76.token_lock);
4480+
4481+ t = idr_find(&dev->mt76.token, dev->dbg.token_idx);
4482+
developer73e5a572022-04-19 10:21:20 +08004483+ if (t != NULL) {
4484+ struct mt76_dev *mdev = &dev->mt76;
4485+ txwi = ((u8*)(t)) - (mdev->drv->txwi_size);
4486+ mt7915_dump_tmac_info((u8*) txwi);
4487+ seq_printf(s, "\n");
4488+ printk("[SKB]\n");
4489+ print_hex_dump(KERN_ERR , "", DUMP_PREFIX_OFFSET, 16, 1, (u8 *)t->skb->data, t->skb->len, false);
4490+ seq_printf(s, "\n");
4491+ }
developerbddc9db2023-09-11 13:34:36 +08004492+ spin_unlock_bh(&dev->mt76.token_lock);
developer73e5a572022-04-19 10:21:20 +08004493+ return 0;
4494+}
4495+
4496+static int mt7915_amsduinfo_read(struct seq_file *s, void *data)
4497+{
4498+ struct mt7915_dev *dev = dev_get_drvdata(s->private);
4499+ u32 ple_stat[8] = {0}, total_amsdu = 0;
4500+ u8 i;
4501+
4502+ for (i = 0; i < 8; i++)
4503+ ple_stat[i] = mt76_rr(dev, MT_DBG_PLE_AMSDU_PACK_MSDU_CNT(i));
4504+
4505+ seq_printf(s, "TXD counter status of MSDU:\n");
4506+
4507+ for (i = 0; i < 8; i++)
4508+ total_amsdu += ple_stat[i];
4509+
4510+ for (i = 0; i < 8; i++) {
4511+ seq_printf(s, "AMSDU pack count of %d MSDU in TXD: 0x%x ", i + 1, ple_stat[i]);
4512+ if (total_amsdu != 0)
4513+ seq_printf(s, "(%d%%)\n", ple_stat[i] * 100 / total_amsdu);
4514+ else
4515+ seq_printf(s, "\n");
4516+ }
4517+
4518+ return 0;
4519+
4520+}
4521+
4522+static int mt7915_agginfo_read_per_band(struct seq_file *s, int band_idx)
4523+{
4524+ struct mt7915_dev *dev = dev_get_drvdata(s->private);
4525+ u32 value, idx, agg_rang_sel[15], ampdu_cnt[11], total_ampdu = 0;
4526+
4527+ seq_printf(s, "Band %d AGG Status\n", band_idx);
4528+ seq_printf(s, "===============================\n");
4529+ value = mt76_rr(dev, MT_DBG_AGG_AALCR0(band_idx));
4530+ seq_printf(s, "AC00 Agg limit = %ld\t", FIELD_GET(MT_DBG_AGG_AALCR_ACx0_AGG_LIMIT_MASK, value));
4531+ seq_printf(s, "AC01 Agg limit = %ld\t", FIELD_GET(MT_DBG_AGG_AALCR_ACx1_AGG_LIMIT_MASK, value));
4532+ seq_printf(s, "AC02 Agg limit = %ld\t", FIELD_GET(MT_DBG_AGG_AALCR_ACx2_AGG_LIMIT_MASK, value));
4533+ seq_printf(s, "AC03 Agg limit = %ld\n", FIELD_GET(MT_DBG_AGG_AALCR_ACx3_AGG_LIMIT_MASK, value));
4534+
4535+ value = mt76_rr(dev, MT_DBG_AGG_AALCR1(band_idx));
4536+ seq_printf(s, "AC10 Agg limit = %ld\t", FIELD_GET(MT_DBG_AGG_AALCR_ACx0_AGG_LIMIT_MASK, value));
4537+ seq_printf(s, "AC11 Agg limit = %ld\t", FIELD_GET(MT_DBG_AGG_AALCR_ACx1_AGG_LIMIT_MASK, value));
4538+ seq_printf(s, "AC12 Agg limit = %ld\t", FIELD_GET(MT_DBG_AGG_AALCR_ACx2_AGG_LIMIT_MASK, value));
4539+ seq_printf(s, "AC13 Agg limit = %ld\n", FIELD_GET(MT_DBG_AGG_AALCR_ACx3_AGG_LIMIT_MASK, value));
4540+
4541+ value = mt76_rr(dev, MT_DBG_AGG_AALCR2(band_idx));
4542+ seq_printf(s, "AC20 Agg limit = %ld\t", FIELD_GET(MT_DBG_AGG_AALCR_ACx0_AGG_LIMIT_MASK, value));
4543+ seq_printf(s, "AC21 Agg limit = %ld\t", FIELD_GET(MT_DBG_AGG_AALCR_ACx1_AGG_LIMIT_MASK, value));
4544+ seq_printf(s, "AC22 Agg limit = %ld\t", FIELD_GET(MT_DBG_AGG_AALCR_ACx2_AGG_LIMIT_MASK, value));
4545+ seq_printf(s, "AC23 Agg limit = %ld\n", FIELD_GET(MT_DBG_AGG_AALCR_ACx3_AGG_LIMIT_MASK, value));
4546+
4547+ value = mt76_rr(dev, MT_DBG_AGG_AALCR3(band_idx));
4548+ seq_printf(s, "AC30 Agg limit = %ld\t", FIELD_GET(MT_DBG_AGG_AALCR_ACx0_AGG_LIMIT_MASK, value));
4549+ seq_printf(s, "AC31 Agg limit = %ld\t", FIELD_GET(MT_DBG_AGG_AALCR_ACx1_AGG_LIMIT_MASK, value));
4550+ seq_printf(s, "AC32 Agg limit = %ld\t", FIELD_GET(MT_DBG_AGG_AALCR_ACx2_AGG_LIMIT_MASK, value));
4551+ seq_printf(s, "AC33 Agg limit = %ld\n", FIELD_GET(MT_DBG_AGG_AALCR_ACx3_AGG_LIMIT_MASK, value));
4552+
4553+ value = mt76_rr(dev, MT_DBG_AGG_AALCR4(band_idx));
4554+ seq_printf(s, "ALTX Agg limit = %ld\n", FIELD_GET(MT_DBG_AGG_AALCR4_ALTX0_AGG_LIMIT_MASK, value));
4555+
4556+ value = mt76_rr(dev, MT_DBG_AGG_AWSCR(band_idx, 0));
4557+ seq_printf(s, "Winsize0 limit = %ld\t", FIELD_GET(MT_DBG_AGG_AWSCR0_WINSIZE0_MASK, value));
4558+ seq_printf(s, "Winsize1 limit = %ld\t", FIELD_GET(MT_DBG_AGG_AWSCR0_WINSIZE1_MASK, value));
4559+ seq_printf(s, "Winsize2 limit = %ld\t", FIELD_GET(MT_DBG_AGG_AWSCR0_WINSIZE2_MASK, value));
4560+ seq_printf(s, "Winsize3 limit = %ld\n", FIELD_GET(MT_DBG_AGG_AWSCR0_WINSIZE3_MASK, value));
4561+
4562+ value = mt76_rr(dev, MT_DBG_AGG_AWSCR(band_idx, 1));
4563+ seq_printf(s, "Winsize4 limit = %ld\t", FIELD_GET(MT_DBG_AGG_AWSCR1_WINSIZE4_MASK, value));
4564+ seq_printf(s, "Winsize5 limit = %ld\t", FIELD_GET(MT_DBG_AGG_AWSCR1_WINSIZE5_MASK, value));
4565+ seq_printf(s, "Winsize6 limit = %ld\t", FIELD_GET(MT_DBG_AGG_AWSCR1_WINSIZE6_MASK, value));
4566+ seq_printf(s, "Winsize7 limit = %ld\n", FIELD_GET(MT_DBG_AGG_AWSCR1_WINSIZE7_MASK, value));
4567+
4568+ value = mt76_rr(dev, MT_DBG_AGG_AWSCR(band_idx, 2));
4569+ seq_printf(s, "Winsize8 limit = %ld\t", FIELD_GET(MT_DBG_AGG_AWSCR2_WINSIZE8_MASK, value));
4570+ seq_printf(s, "Winsize9 limit = %ld\t", FIELD_GET(MT_DBG_AGG_AWSCR2_WINSIZE9_MASK, value));
4571+ seq_printf(s, "WinsizeA limit = %ld\t", FIELD_GET(MT_DBG_AGG_AWSCR2_WINSIZEA_MASK, value));
4572+ seq_printf(s, "WinsizeB limit = %ld\n", FIELD_GET(MT_DBG_AGG_AWSCR2_WINSIZEB_MASK, value));
4573+
4574+
4575+ value = mt76_rr(dev, MT_DBG_AGG_AWSCR(band_idx, 3));
4576+ seq_printf(s, "WinsizeC limit = %ld\t", FIELD_GET(MT_DBG_AGG_AWSCR3_WINSIZEC_MASK, value));
4577+ seq_printf(s, "WinsizeD limit = %ld\t", FIELD_GET(MT_DBG_AGG_AWSCR3_WINSIZED_MASK, value));
4578+ seq_printf(s, "WinsizeE limit = %ld\n", FIELD_GET(MT_DBG_AGG_AWSCR3_WINSIZEE_MASK, value));
4579+
4580+ seq_printf(s, "===AMPDU Related Counters===\n");
4581+
4582+ value = mt76_rr(dev, MT_DBG_MIB_M0ARNG(band_idx, 0));
4583+ agg_rang_sel[0] = FIELD_GET(MT_DBG_MIB_M0ARNG0_AGG_RANG_SEL0_MASK, value);
4584+ agg_rang_sel[1] = FIELD_GET(MT_DBG_MIB_M0ARNG0_AGG_RANG_SEL1_MASK, value);
4585+ agg_rang_sel[2] = FIELD_GET(MT_DBG_MIB_M0ARNG0_AGG_RANG_SEL2_MASK, value);
4586+ agg_rang_sel[3] = FIELD_GET(MT_DBG_MIB_M0ARNG0_AGG_RANG_SEL3_MASK, value);
4587+
4588+ value = mt76_rr(dev, MT_DBG_MIB_M0ARNG(band_idx, 1));
4589+ agg_rang_sel[4] = FIELD_GET(MT_DBG_MIB_M0ARNG1_AGG_RANG_SEL4_MASK, value);
4590+ agg_rang_sel[5] = FIELD_GET(MT_DBG_MIB_M0ARNG1_AGG_RANG_SEL5_MASK, value);
4591+ agg_rang_sel[6] = FIELD_GET(MT_DBG_MIB_M0ARNG1_AGG_RANG_SEL6_MASK, value);
4592+ agg_rang_sel[7] = FIELD_GET(MT_DBG_MIB_M0ARNG1_AGG_RANG_SEL7_MASK, value);
4593+
4594+ value = mt76_rr(dev, MT_DBG_MIB_M0ARNG(band_idx, 2));
4595+ agg_rang_sel[8] = FIELD_GET(MT_DBG_MIB_M0ARNG2_AGG_RANG_SEL8_MASK, value);
4596+ agg_rang_sel[9] = FIELD_GET(MT_DBG_MIB_M0ARNG2_AGG_RANG_SEL9_MASK, value);
4597+ agg_rang_sel[10] = FIELD_GET(MT_DBG_MIB_M0ARNG2_AGG_RANG_SEL10_MASK, value);
4598+ agg_rang_sel[11] = FIELD_GET(MT_DBG_MIB_M0ARNG2_AGG_RANG_SEL11_MASK, value);
4599+
4600+ value = mt76_rr(dev, MT_DBG_MIB_M0ARNG(band_idx, 3));
4601+ agg_rang_sel[12] = FIELD_GET(MT_DBG_MIB_M0ARNG3_AGG_RANG_SEL12_MASK, value);
4602+ agg_rang_sel[13] = FIELD_GET(MT_DBG_MIB_M0ARNG3_AGG_RANG_SEL13_MASK, value);
4603+ agg_rang_sel[14] = FIELD_GET(MT_DBG_MIB_M0ARNG3_AGG_RANG_SEL14_MASK, value);
4604+
4605+ /* Need to add 1 after read from AGG_RANG_SEL CR */
4606+ for (idx = 0; idx < 15; idx++)
4607+ agg_rang_sel[idx]++;
4608+
4609+ ampdu_cnt[3] = mt76_rr(dev, MT_DBG_MIB_M0DR2(band_idx, 0));
4610+ ampdu_cnt[4] = mt76_rr(dev, MT_DBG_MIB_M0DR2(band_idx, 1));
4611+ ampdu_cnt[5] = mt76_rr(dev, MT_DBG_MIB_M0DR2(band_idx, 2));
4612+ ampdu_cnt[6] = mt76_rr(dev, MT_DBG_MIB_M0DR2(band_idx, 3));
4613+ ampdu_cnt[7] = mt76_rr(dev, MT_DBG_MIB_M0DR13(band_idx, 0));
4614+ ampdu_cnt[8] = mt76_rr(dev, MT_DBG_MIB_M0DR13(band_idx, 1));
4615+ ampdu_cnt[9] = mt76_rr(dev, MT_DBG_MIB_M0DR13(band_idx, 2));
4616+ ampdu_cnt[10] = mt76_rr(dev, MT_DBG_MIB_M0DR13(band_idx, 3));
4617+
4618+ 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",
4619+ agg_rang_sel[0],
4620+ agg_rang_sel[0] + 1, agg_rang_sel[1],
4621+ agg_rang_sel[1] + 1, agg_rang_sel[2],
4622+ agg_rang_sel[2] + 1, agg_rang_sel[3],
4623+ agg_rang_sel[3] + 1, agg_rang_sel[4],
4624+ agg_rang_sel[4] + 1, agg_rang_sel[5],
4625+ agg_rang_sel[5] + 1, agg_rang_sel[6],
4626+ agg_rang_sel[6] + 1, agg_rang_sel[7]);
4627+
4628+#define BIT_0_to_15_MASK 0x0000FFFF
4629+#define BIT_15_to_31_MASK 0xFFFF0000
4630+#define SHFIT_16_BIT 16
4631+
4632+ for (idx = 3; idx < 11; idx++)
4633+ total_ampdu = total_ampdu + (ampdu_cnt[idx] & BIT_0_to_15_MASK) + ((ampdu_cnt[idx] & BIT_15_to_31_MASK) >> SHFIT_16_BIT);
4634+
4635+ seq_printf(s, "\t\t\t0x%lx \t0x%lx \t0x%lx \t0x%lx \t0x%lx \t0x%lx \t0x%lx \t0x%lx\n",
4636+ (ampdu_cnt[3]) & MT_DBG_MIB_M0DR2_TRX_AGG_RANGE0_CNT_MASK,
4637+ FIELD_GET(MT_DBG_MIB_M0DR2_TRX_AGG_RANGE1_CNT_MASK, ampdu_cnt[3]),
4638+ (ampdu_cnt[4]) & MT_DBG_MIB_M0DR3_TRX_AGG_RANGE2_CNT_MASK,
4639+ FIELD_GET(MT_DBG_MIB_M0DR3_TRX_AGG_RANGE3_CNT_MASK, ampdu_cnt[4]),
4640+ (ampdu_cnt[5]) & MT_DBG_MIB_M0DR4_TRX_AGG_RANGE4_CNT_MASK,
4641+ FIELD_GET(MT_DBG_MIB_M0DR4_TRX_AGG_RANGE5_CNT_MASK, ampdu_cnt[5]),
4642+ (ampdu_cnt[6]) & MT_DBG_MIB_M0DR5_TRX_AGG_RANGE6_CNT_MASK,
4643+ FIELD_GET(MT_DBG_MIB_M0DR5_TRX_AGG_RANGE7_CNT_MASK, ampdu_cnt[6]));
4644+
4645+ if (total_ampdu != 0) {
4646+ seq_printf(s, "\t\t\t(%ld%%) \t(%ld%%) \t(%ld%%) \t(%ld%%) \t(%ld%%) \t(%ld%%) \t(%ld%%) \t(%ld%%)\n",
4647+ ((ampdu_cnt[3]) & MT_DBG_MIB_M0DR2_TRX_AGG_RANGE0_CNT_MASK) * 100 / total_ampdu,
4648+ FIELD_GET(MT_DBG_MIB_M0DR2_TRX_AGG_RANGE1_CNT_MASK, ampdu_cnt[3]) * 100 / total_ampdu,
4649+ ((ampdu_cnt[4]) & MT_DBG_MIB_M0DR3_TRX_AGG_RANGE2_CNT_MASK) * 100 / total_ampdu,
4650+ FIELD_GET(MT_DBG_MIB_M0DR3_TRX_AGG_RANGE3_CNT_MASK, ampdu_cnt[4]) * 100 / total_ampdu,
4651+ ((ampdu_cnt[5]) & MT_DBG_MIB_M0DR4_TRX_AGG_RANGE4_CNT_MASK) * 100 / total_ampdu,
4652+ FIELD_GET(MT_DBG_MIB_M0DR4_TRX_AGG_RANGE5_CNT_MASK, ampdu_cnt[5]) * 100 / total_ampdu,
4653+ ((ampdu_cnt[6]) & MT_DBG_MIB_M0DR5_TRX_AGG_RANGE6_CNT_MASK) * 100 / total_ampdu,
4654+ FIELD_GET(MT_DBG_MIB_M0DR5_TRX_AGG_RANGE7_CNT_MASK, ampdu_cnt[6]) * 100 / total_ampdu);
4655+ }
4656+
4657+ 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",
4658+ agg_rang_sel[7] + 1, agg_rang_sel[8],
4659+ agg_rang_sel[8] + 1, agg_rang_sel[9],
4660+ agg_rang_sel[9] + 1, agg_rang_sel[10],
4661+ agg_rang_sel[10] + 1, agg_rang_sel[11],
4662+ agg_rang_sel[11] + 1, agg_rang_sel[12],
4663+ agg_rang_sel[12] + 1, agg_rang_sel[13],
4664+ agg_rang_sel[13] + 1, agg_rang_sel[14],
4665+ agg_rang_sel[14] + 1);
4666+
4667+ seq_printf(s, "\t\t\t0x%lx \t0x%lx \t0x%lx \t0x%lx \t0x%lx \t0x%lx \t0x%lx \t0x%lx\n",
4668+ (ampdu_cnt[7]) & MT_DBG_MIB_M0DR13_TRX_AGG_RANGE8_CNT_MASK,
4669+ FIELD_GET(MT_DBG_MIB_M0DR13_TRX_AGG_RANGE9_CNT_MASK, ampdu_cnt[7]),
4670+ (ampdu_cnt[8]) & MT_DBG_MIB_M0DR14_TRX_AGG_RANGE10_CNT_MASK,
4671+ FIELD_GET(MT_DBG_MIB_M0DR14_TRX_AGG_RANGE11_CNT_MASK, ampdu_cnt[8]),
4672+ (ampdu_cnt[9]) & MT_DBG_MIB_M0DR15_TRX_AGG_RANGE12_CNT_MASK,
4673+ FIELD_GET(MT_DBG_MIB_M0DR15_TRX_AGG_RANGE13_CNT_MASK, ampdu_cnt[9]),
4674+ (ampdu_cnt[10]) & MT_DBG_MIB_M0DR16_TRX_AGG_RANGE14_CNT_MASK,
4675+ FIELD_GET(MT_DBG_MIB_M0DR16_TRX_AGG_RANGE15_CNT_MASK, ampdu_cnt[10]));
4676+
4677+ if (total_ampdu != 0) {
4678+ seq_printf(s, "\t\t\t(%ld%%) \t(%ld%%) \t(%ld%%) \t(%ld%%) \t(%ld%%) \t(%ld%%) \t(%ld%%) \t(%ld%%)\n",
4679+ ((ampdu_cnt[7]) & MT_DBG_MIB_M0DR2_TRX_AGG_RANGE0_CNT_MASK) * 100 / total_ampdu,
4680+ FIELD_GET(MT_DBG_MIB_M0DR2_TRX_AGG_RANGE1_CNT_MASK, ampdu_cnt[7]) * 100 / total_ampdu,
4681+ ((ampdu_cnt[8]) & MT_DBG_MIB_M0DR3_TRX_AGG_RANGE2_CNT_MASK) * 100 / total_ampdu,
4682+ FIELD_GET(MT_DBG_MIB_M0DR3_TRX_AGG_RANGE3_CNT_MASK, ampdu_cnt[8]) * 100 / total_ampdu,
4683+ ((ampdu_cnt[9]) & MT_DBG_MIB_M0DR4_TRX_AGG_RANGE4_CNT_MASK) * 100 / total_ampdu,
4684+ FIELD_GET(MT_DBG_MIB_M0DR4_TRX_AGG_RANGE5_CNT_MASK, ampdu_cnt[9]) * 100 / total_ampdu,
4685+ ((ampdu_cnt[10]) & MT_DBG_MIB_M0DR5_TRX_AGG_RANGE6_CNT_MASK) * 100 / total_ampdu,
4686+ FIELD_GET(MT_DBG_MIB_M0DR5_TRX_AGG_RANGE7_CNT_MASK, ampdu_cnt[10]) * 100 / total_ampdu);
4687+ }
4688+
4689+ return 0;
4690+}
4691+
4692+static int mt7915_agginfo_read_band0(struct seq_file *s, void *data)
4693+{
4694+ mt7915_agginfo_read_per_band(s, 0);
4695+ return 0;
4696+}
4697+
4698+static int mt7915_agginfo_read_band1(struct seq_file *s, void *data)
4699+{
4700+ mt7915_agginfo_read_per_band(s, 1);
4701+ return 0;
4702+}
4703+
4704+/*usage: <en> <num> <len>
4705+ en: BIT(16) 0: sw amsdu 1: hw amsdu
4706+ num: GENMASK(15, 8) range 1-8
4707+ len: GENMASK(7, 0) unit: 256 bytes */
4708+static int mt7915_sta_tx_amsdu_set(void *data, u64 tx_amsdu)
4709+{
4710+/* UWTBL DW 6 */
4711+#define WTBL_AMSDU_LEN_MASK GENMASK(5, 0)
4712+#define WTBL_AMSDU_NUM_MASK GENMASK(8, 6)
4713+#define WTBL_AMSDU_EN_MASK BIT(9)
4714+#define UWTBL_HW_AMSDU_DW 6
4715+
4716+ struct mt7915_dev *dev = data;
4717+ u32 len = FIELD_GET(GENMASK(7, 0), tx_amsdu);
4718+ u32 num = FIELD_GET(GENMASK(15, 8), tx_amsdu);
4719+ u32 uwtbl;
4720+
developerb1654ad2022-09-27 10:30:15 +08004721+ mt7915_mcu_set_amsdu_algo(dev, dev->wlan_idx, 0);
4722+
developer73e5a572022-04-19 10:21:20 +08004723+ mt7915_wtbl_read_raw(dev, dev->wlan_idx, WTBL_TYPE_UMAC,
4724+ UWTBL_HW_AMSDU_DW, 1, &uwtbl);
4725+
4726+ if (len) {
4727+ uwtbl &= ~WTBL_AMSDU_LEN_MASK;
4728+ uwtbl |= FIELD_PREP(WTBL_AMSDU_LEN_MASK, len);
4729+ }
4730+
4731+ uwtbl &= ~WTBL_AMSDU_NUM_MASK;
4732+ uwtbl |= FIELD_PREP(WTBL_AMSDU_NUM_MASK, num);
4733+
4734+ if (tx_amsdu & BIT(16))
4735+ uwtbl |= WTBL_AMSDU_EN_MASK;
4736+
4737+ mt7915_wtbl_write_raw(dev, dev->wlan_idx, WTBL_TYPE_UMAC,
4738+ UWTBL_HW_AMSDU_DW, uwtbl);
4739+
4740+ return 0;
4741+}
4742+
4743+DEFINE_DEBUGFS_ATTRIBUTE(fops_tx_amsdu, NULL,
4744+ mt7915_sta_tx_amsdu_set, "%llx\n");
4745+
4746+static int mt7915_red_enable_set(void *data, u64 en)
4747+{
4748+ struct mt7915_dev *dev = data;
4749+
4750+ return mt7915_mcu_set_red(dev, en);
4751+}
4752+DEFINE_DEBUGFS_ATTRIBUTE(fops_red_en, NULL,
4753+ mt7915_red_enable_set, "%llx\n");
4754+
4755+static int mt7915_red_show_sta_set(void *data, u64 wlan_idx)
4756+{
4757+ struct mt7915_dev *dev = data;
4758+
4759+ mt7915_dbg_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
4760+ MCU_WA_PARAM_RED_SHOW_STA,
4761+ wlan_idx, 0, true);
4762+
4763+ return 0;
4764+}
4765+DEFINE_DEBUGFS_ATTRIBUTE(fops_red_show_sta, NULL,
4766+ mt7915_red_show_sta_set, "%llx\n");
4767+
4768+static int mt7915_red_target_dly_set(void *data, u64 delay)
4769+{
4770+ struct mt7915_dev *dev = data;
4771+
4772+ if (delay > 0 && delay <= 32767)
4773+ mt7915_dbg_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
4774+ MCU_WA_PARAM_RED_TARGET_DELAY,
4775+ delay, 0, true);
4776+
4777+ return 0;
4778+}
4779+DEFINE_DEBUGFS_ATTRIBUTE(fops_red_target_dly, NULL,
4780+ mt7915_red_target_dly_set, "%llx\n");
4781+
4782+static int
4783+mt7915_txpower_level_set(void *data, u64 val)
4784+{
4785+ struct mt7915_dev *dev = data;
4786+ struct mt7915_phy *ext_phy = mt7915_ext_phy(dev);
4787+ mt7915_mcu_set_txpower_level(&dev->phy, val);
4788+ if (ext_phy)
4789+ mt7915_mcu_set_txpower_level(ext_phy, val);
4790+
4791+ return 0;
4792+}
4793+
4794+DEFINE_DEBUGFS_ATTRIBUTE(fops_txpower_level, NULL,
4795+ mt7915_txpower_level_set, "%lld\n");
4796+
4797+/* usage: echo 0x[arg3][arg2][arg1] > fw_wa_set */
4798+static int
4799+mt7915_wa_set(void *data, u64 val)
4800+{
4801+ struct mt7915_dev *dev = data;
4802+ u32 arg1, arg2, arg3;
4803+
4804+ arg1 = FIELD_GET(GENMASK_ULL(7, 0), val);
4805+ arg2 = FIELD_GET(GENMASK_ULL(15, 8), val);
4806+ arg3 = FIELD_GET(GENMASK_ULL(23, 16), val);
4807+
4808+ mt7915_dbg_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET), arg1, arg2, arg3, false);
4809+
4810+ return 0;
4811+}
4812+
4813+DEFINE_DEBUGFS_ATTRIBUTE(fops_wa_set, NULL, mt7915_wa_set,
4814+ "0x%llx\n");
4815+/* usage: echo 0x[arg3][arg2][arg1] > fw_wa_query */
4816+static int
4817+mt7915_wa_query(void *data, u64 val)
4818+{
4819+ struct mt7915_dev *dev = data;
4820+ u32 arg1, arg2, arg3;
4821+
4822+ arg1 = FIELD_GET(GENMASK_ULL(7, 0), val);
4823+ arg2 = FIELD_GET(GENMASK_ULL(15, 8), val);
4824+ arg3 = FIELD_GET(GENMASK_ULL(23, 16), val);
4825+
4826+ mt7915_dbg_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(QUERY), arg1, arg2, arg3, false);
4827+
4828+ return 0;
4829+}
4830+
4831+DEFINE_DEBUGFS_ATTRIBUTE(fops_wa_query, NULL, mt7915_wa_query,
4832+ "0x%llx\n");
4833+/* set wa debug level
4834+ usage:
4835+ echo 0x[arg] > fw_wa_debug
4836+ bit0 : DEBUG_WIFI_TX
4837+ bit1 : DEBUG_CMD_EVENT
4838+ bit2 : DEBUG_RED
4839+ bit3 : DEBUG_WARN
4840+ bit4 : DEBUG_WIFI_RX
4841+ bit5 : DEBUG_TIME_STAMP
4842+ bit6 : DEBUG_TX_FREE_DONE_EVENT
4843+ bit12 : DEBUG_WIFI_TXD */
4844+static int
4845+mt7915_wa_debug(void *data, u64 val)
4846+{
4847+ struct mt7915_dev *dev = data;
4848+ u32 arg;
4849+
4850+ arg = FIELD_GET(GENMASK_ULL(15, 0), val);
4851+
4852+ mt7915_dbg_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(DEBUG), arg, 0, 0, false);
4853+
4854+ return 0;
4855+}
4856+
4857+DEFINE_DEBUGFS_ATTRIBUTE(fops_wa_debug, NULL, mt7915_wa_debug,
4858+ "0x%llx\n");
4859+
developer67705712023-05-30 11:58:00 +08004860+static int mt7915_dump_version(struct seq_file *s, void *data)
4861+{
4862+ struct mt7915_dev *dev = dev_get_drvdata(s->private);
4863+ struct mt76_dev *mdev = NULL;
developera46f6132024-03-26 14:09:54 +08004864+ int i;
4865+
developera20cdc22024-05-31 18:57:31 +08004866+ seq_printf(s, "Version: 2.2.24.5\n");
developer67705712023-05-30 11:58:00 +08004867+
4868+ if (!test_bit(MT76_STATE_MCU_RUNNING, &dev->mphy.state))
4869+ return 0;
4870+
4871+ mdev = &dev->mt76;
4872+ seq_printf(s, "Rom Patch Build Time: %.16s\n", mdev->patch_hdr->build_date);
4873+ seq_printf(s, "WM Patch Build Time: %.16s\n", mdev->wm_hdr->build_date);
4874+ seq_printf(s, "WA Patch Build Time: %.16s\n", mdev->wa_hdr->build_date);
developera46f6132024-03-26 14:09:54 +08004875+
4876+ for (i = 0; i < ADIE_MAX_CNT; i++) {
4877+ seq_printf(s, "adie[%d]: id=0x%04x version=0x%04x\n",
4878+ i, dev->adie[i].id, dev->adie[i].version);
4879+ }
developer67705712023-05-30 11:58:00 +08004880+ return 0;
4881+}
4882+
developer8effbd32023-04-17 15:57:28 +08004883+static void mt7915_show_lp_history(struct seq_file *s, bool fgIsExp)
4884+{
4885+ struct mt7915_dev *dev = dev_get_drvdata(s->private);
developer1a173672023-12-21 14:49:33 +08004886+ u32 macVal, gpr_log_idx, oldest_idx;
4887+ u32 idx, i;
developer8effbd32023-04-17 15:57:28 +08004888+
4889+ if (!fgIsExp) {
4890+ /* disable LP recored */
4891+ macVal = mt76_rr(dev, 0x89050200);
4892+ macVal &= (~0x1);
4893+ mt76_wr(dev, 0x89050200, macVal);
4894+ udelay(100);
4895+ }
4896+
developer8effbd32023-04-17 15:57:28 +08004897+ macVal = mt76_rr(dev, 0x89050200);
4898+ gpr_log_idx = ((macVal >> 16) & 0x1f);
4899+ oldest_idx = gpr_log_idx + 2;
4900+
4901+ seq_printf(s, " lp history (from old to new):\n");
4902+ for (i = 0; i < 16; i++) {
4903+ idx = ((oldest_idx + 2*i + 1)%32);
4904+ macVal = mt76_rr(dev, (0x89050204 + idx*4));
4905+ seq_printf(s, " %d: 0x%x\n", i, macVal);
4906+ }
4907+
4908+ if (!fgIsExp) {
4909+ /* enable LP recored */
4910+ macVal = mt76_rr(dev, 0x89050200);
4911+ macVal |= 0x1;
4912+ mt76_wr(dev, 0x89050200, macVal);
4913+ }
4914+}
4915+
4916+static void mt7915_show_irq_history(struct seq_file *s)
4917+{
4918+#define SYSIRQ_INTERRUPT_HISTORY_NUM 10
4919+ struct mt7915_dev *dev = dev_get_drvdata(s->private);
developer1a173672023-12-21 14:49:33 +08004920+ u32 macVal, i, start, idx;
4921+ u8 ucIrqDisIdx, ucIrqResIdx;
4922+ u32 irq_dis_time[SYSIRQ_INTERRUPT_HISTORY_NUM], irq_dis_lp[SYSIRQ_INTERRUPT_HISTORY_NUM];
4923+ u32 irq_res_time[SYSIRQ_INTERRUPT_HISTORY_NUM], irq_res_lp[SYSIRQ_INTERRUPT_HISTORY_NUM];
4924+ u32 irq_idx_addr, irq_dis_addr, irq_res_addr;
developer8effbd32023-04-17 15:57:28 +08004925+
developer1a173672023-12-21 14:49:33 +08004926+ switch (mt76_chip(&dev->mt76)) {
4927+ case 0x7915:
4928+ irq_idx_addr = 0x2170BC;
4929+ irq_dis_addr = 0x2170B8;
4930+ irq_res_addr = 0x2170B4;
4931+ break;
4932+ case 0x7981:
4933+ irq_idx_addr = 0x02205138;
4934+ irq_dis_addr = 0x02205140;
4935+ irq_res_addr = 0x0220513C;
4936+ break;
4937+ case 0x7906:
4938+ irq_idx_addr = 0x02205288;
4939+ irq_dis_addr = 0x02205290;
4940+ irq_res_addr = 0x0220528C;
4941+ break;
4942+ case 0x7986:
4943+ default:
4944+ irq_idx_addr = 0x022051C0;
4945+ irq_dis_addr = 0x022051C8;
4946+ irq_res_addr = 0x022051C4;
4947+ break;
4948+ }
4949+
4950+ macVal = mt76_rr(dev, irq_idx_addr);
developer8effbd32023-04-17 15:57:28 +08004951+ ucIrqResIdx = (macVal & 0xff);
4952+ ucIrqDisIdx = ((macVal >> 8) & 0xff);
4953+
4954+ seq_printf(s, "\n\n\n Irq Idx (Dis=%d Res=%d):\n",
4955+ ucIrqDisIdx, ucIrqResIdx);
4956+
developer1a173672023-12-21 14:49:33 +08004957+ start = mt76_rr(dev, irq_dis_addr);
developer8effbd32023-04-17 15:57:28 +08004958+ for (i = 0; i < SYSIRQ_INTERRUPT_HISTORY_NUM; i++) {
4959+ macVal = mt76_rr(dev, (start + (i * 8)));
4960+ irq_dis_time[i] = macVal;
4961+ macVal = mt76_rr(dev, (start + (i * 8) + 4));
4962+ irq_dis_lp[i] = macVal;
4963+ }
4964+
developer1a173672023-12-21 14:49:33 +08004965+ start = mt76_rr(dev, irq_res_addr);
developer8effbd32023-04-17 15:57:28 +08004966+ for (i = 0; i < SYSIRQ_INTERRUPT_HISTORY_NUM; i++) {
4967+ macVal = mt76_rr(dev, (start + (i * 8)));
4968+ irq_res_time[i] = macVal;
4969+ macVal = mt76_rr(dev, (start + (i * 8) + 4));
4970+ irq_res_lp[i] = macVal;
4971+ }
4972+
4973+ seq_printf(s, "\n Dis Irq history (from old to new):\n");
4974+ for (i = 0; i < SYSIRQ_INTERRUPT_HISTORY_NUM; i++) {
4975+ idx = (i + ucIrqDisIdx) % SYSIRQ_INTERRUPT_HISTORY_NUM;
4976+ seq_printf(s, " [%d].LP = 0x%x time=%u\n",
4977+ idx, irq_dis_lp[idx], irq_dis_time[idx]);
4978+ }
4979+
4980+ seq_printf(s, "\n Restore Irq history (from old to new):\n");
4981+ for (i = 0; i < SYSIRQ_INTERRUPT_HISTORY_NUM; i++) {
4982+ idx = (i + ucIrqResIdx) % SYSIRQ_INTERRUPT_HISTORY_NUM;
4983+ seq_printf(s, " [%d].LP = 0x%x time=%u\n",
4984+ idx, irq_res_lp[idx], irq_res_time[idx]);
4985+ }
4986+}
4987+
4988+static void MemSectionRead(struct mt7915_dev *dev, char *buf, u32 length, u32 addr)
4989+{
4990+ int idx = 0;
4991+ u32 *ptr =(u32 *)buf;
4992+
4993+ while (idx < length) {
4994+ *ptr = mt76_rr(dev, (addr + idx));
4995+ idx += 4;
4996+ ptr++;
4997+ }
4998+}
4999+
developer1a173672023-12-21 14:49:33 +08005000+static int MemReadOneByte(struct mt7915_dev *dev, u32 addr)
5001+{
5002+ u32 val, tmpval;
5003+
5004+ val = mt76_rr(dev, (addr & ~(0x3)));
5005+ tmpval = (val >> (8 * (addr & (0x3)))) & 0xff;
5006+ return tmpval;
5007+}
5008+
developer8effbd32023-04-17 15:57:28 +08005009+static void mt7915_show_msg_trace(struct seq_file *s)
5010+{
developer8effbd32023-04-17 15:57:28 +08005011+ struct mt7915_dev *dev = dev_get_drvdata(s->private);
5012+ struct cos_msg_trace_t *msg_trace = NULL;
developer1a173672023-12-21 14:49:33 +08005013+ u32 ptr_addr, length;
5014+ u32 idx = 0, cnt = 0;
5015+ u32 msg_history_num, num_addr;
5016+ u32 trace_ptr_addr, trace_num_addr;
developer8effbd32023-04-17 15:57:28 +08005017+
developer1a173672023-12-21 14:49:33 +08005018+ switch (mt76_chip(&dev->mt76)) {
5019+ case 0x7915:
5020+ trace_ptr_addr = 0x41F054;
5021+ trace_num_addr = 0x41F058;
5022+ num_addr = mt76_rr(dev, 0x41F05C);
5023+ break;
5024+ case 0x7981:
5025+ trace_ptr_addr = 0x02205100;
5026+ trace_num_addr = 0x02205104;
5027+ break;
5028+ case 0x7906:
5029+ trace_ptr_addr = 0x02205250;
5030+ trace_num_addr = 0x02205254;
5031+ break;
5032+ case 0x7986:
5033+ default:
5034+ trace_ptr_addr = 0x02205188;
5035+ trace_num_addr = 0x0220518C;
5036+ break;
developer8effbd32023-04-17 15:57:28 +08005037+ }
5038+
developer8effbd32023-04-17 15:57:28 +08005039+
developer8effbd32023-04-17 15:57:28 +08005040+
developer1a173672023-12-21 14:49:33 +08005041+ ptr_addr = mt76_rr(dev, trace_ptr_addr);
5042+ msg_history_num = mt76_rr(dev, trace_num_addr);
5043+ idx = (is_mt7915(&dev->mt76) ? MemReadOneByte(dev, num_addr) : (msg_history_num >> 8)) & 0xff;
developer8effbd32023-04-17 15:57:28 +08005044+ msg_history_num = msg_history_num & 0xff;
developer1a173672023-12-21 14:49:33 +08005045+ msg_trace = kzalloc(msg_history_num * sizeof(struct cos_msg_trace_t), GFP_KERNEL);
5046+
5047+ if (!msg_trace) {
5048+ seq_printf(s, "can not allocate cmd msg_trace\n");
5049+ return;
5050+ }
developer8effbd32023-04-17 15:57:28 +08005051+
5052+ if (idx >= msg_history_num) {
5053+ kfree(msg_trace);
5054+ return;
5055+ }
5056+
5057+ length = msg_history_num * sizeof(struct cos_msg_trace_t);
5058+ MemSectionRead(dev, (char *)&(msg_trace[0]), length, ptr_addr);
developer1a173672023-12-21 14:49:33 +08005059+ seq_printf(s, "\n");
developer8effbd32023-04-17 15:57:28 +08005060+ seq_printf(s, " msg trace:\n");
5061+ seq_printf(s, " format: t_id=task_id/task_prempt_cnt/msg_read_idx\n");
5062+
5063+ while (1) {
5064+ seq_printf(s, " (m_%d)t_id=%x/%d/%d, m_id=%d, ts_en=%u, ts_de = %u, ts_fin=%u, wait=%d, exe=%d\n",
5065+ idx,
5066+ msg_trace[idx].dest_id,
5067+ msg_trace[idx].pcount,
5068+ msg_trace[idx].qread,
5069+ msg_trace[idx].msg_id,
5070+ msg_trace[idx].ts_enq,
5071+ msg_trace[idx].ts_deq,
5072+ msg_trace[idx].ts_finshq,
5073+ (msg_trace[idx].ts_deq - msg_trace[idx].ts_enq),
5074+ (msg_trace[idx].ts_finshq - msg_trace[idx].ts_deq));
5075+
5076+ if (++idx >= msg_history_num)
5077+ idx = 0;
5078+
5079+ if (++cnt >= msg_history_num)
5080+ break;
5081+ }
5082+ if (msg_trace)
5083+ kfree(msg_trace);
5084+}
5085+
5086+static int mt7915_show_assert_line(struct seq_file *s)
5087+{
5088+ struct mt7915_dev *dev = dev_get_drvdata(s->private);
5089+ char *msg;
5090+ u32 addr;
5091+ u32 macVal = 0;
5092+ char *ptr;
5093+ char idx;
5094+
5095+ msg = kmalloc(256, GFP_KERNEL);
5096+ if (!msg)
5097+ return 0;
5098+
5099+ memset(msg, 0, 256);
5100+ addr = 0x00400000;
5101+ ptr = msg;
5102+ for (idx = 0 ; idx < 32; idx++) {
5103+ macVal = 0;
5104+ macVal = mt76_rr(dev, addr);
5105+ memcpy(ptr, &macVal, 4);
5106+ addr += 4;
5107+ ptr += 4;
5108+ }
5109+
5110+ *ptr = 0;
developer1a173672023-12-21 14:49:33 +08005111+ seq_printf(s, "\n\n");
5112+ seq_printf(s, " Assert line\n");
5113+ seq_printf(s, " %s\n", msg);
developer8effbd32023-04-17 15:57:28 +08005114+ if (msg)
5115+ kfree(msg);
5116+
5117+ return 0;
5118+}
5119+
5120+
5121+static void mt7915_show_sech_trace(struct seq_file *s)
5122+{
5123+ struct mt7915_dev *dev = dev_get_drvdata(s->private);
5124+ struct cos_task_info_struct task_info_g[2];
developer1a173672023-12-21 14:49:33 +08005125+ u32 length, idx;
5126+ u32 addr, km_total_time;
5127+ u32 task_info_addr, km_total_time_addr;
developer8effbd32023-04-17 15:57:28 +08005128+ struct cos_task_type tcb;
5129+ struct cos_task_type *tcb_ptr;
5130+ char name[2][15] = {
5131+ "WIFI ", "WIFI2 "
5132+ };
5133+
developer1a173672023-12-21 14:49:33 +08005134+ switch (mt76_chip(&dev->mt76)) {
5135+ case 0x7915:
5136+ task_info_addr = 0x215400;
5137+ km_total_time_addr = 0x219838;
5138+ break;
5139+ case 0x7981:
5140+ task_info_addr = 0x02202978;
5141+ km_total_time_addr = 0x0220512C;
5142+ break;
5143+ case 0x7906:
5144+ task_info_addr = 0x02202ACC;
5145+ km_total_time_addr = 0x0220527C;
5146+ break;
5147+ case 0x7986:
5148+ default:
5149+ task_info_addr = 0x02202A18;
5150+ km_total_time_addr = 0x022051B4;
5151+ break;
5152+ }
5153+
developer8effbd32023-04-17 15:57:28 +08005154+ length = 2 * sizeof(struct cos_task_info_struct);
developer1a173672023-12-21 14:49:33 +08005155+ MemSectionRead(dev, (char *)&(task_info_g[0]), length, task_info_addr);
developer8effbd32023-04-17 15:57:28 +08005156+
developer1a173672023-12-21 14:49:33 +08005157+ km_total_time = mt76_rr(dev, km_total_time_addr);
developer8effbd32023-04-17 15:57:28 +08005158+ if (km_total_time == 0) {
5159+ seq_printf(s, "km_total_time zero!\n");
5160+ return;
5161+ }
5162+
developer1a173672023-12-21 14:49:33 +08005163+ seq_printf(s, "\n\n\n TASK XTIME RATIO PREMPT CNT\n");
developer8effbd32023-04-17 15:57:28 +08005164+ for (idx = 0 ; idx < 2 ; idx++) {
5165+ addr = task_info_g[idx].task_id;
developer8effbd32023-04-17 15:57:28 +08005166+ MemSectionRead(dev, (char *)&(tcb), sizeof(struct cos_task_type), addr);
5167+
5168+ length = sizeof(struct cos_task_type);
5169+
5170+ tcb_ptr = &(tcb);
5171+
5172+ if (tcb_ptr) {
5173+ seq_printf(s, " %s %d %d %d\n",
5174+ name[idx],
5175+ tcb_ptr->tc_exe_time,
5176+ (tcb_ptr->tc_exe_time*100/km_total_time),
5177+ tcb_ptr->tc_pcount);
5178+ }
5179+ }
5180+
5181+}
5182+
5183+static void mt7915_show_prog_trace(struct seq_file *s)
5184+{
developer1a173672023-12-21 14:49:33 +08005185+#define mt7915_cos_access_ptr(_idx, _member) (is_mt7915(&dev->mt76) ? \
5186+ mt7915_cos_program_trace_ptr[_idx]._##_member : \
5187+ cos_program_trace_ptr[_idx]._##_member)
developer8effbd32023-04-17 15:57:28 +08005188+ struct mt7915_dev *dev = dev_get_drvdata(s->private);
5189+ struct cos_program_trace_t *cos_program_trace_ptr = NULL;
developer1a173672023-12-21 14:49:33 +08005190+ struct mt7915_cos_program_trace_t *mt7915_cos_program_trace_ptr = NULL;
5191+ char *buf;
5192+ u32 trace_ptr;
5193+ u32 idx;
5194+ u32 old_idx;
5195+ u32 old_idx_addr;
5196+ u32 prev_idx, diff;
5197+ u32 prev_time, prev_dest_id, prev_msg_sn;
5198+ u32 old_time, old_dest_id, old_msg_sn;
5199+ u32 trace_ptr_addr, trace_idx_addr, trace_num_addr, trace_num;
5200+ int size;
5201+
5202+ switch (mt76_chip(&dev->mt76)) {
5203+ case 0x7915:
5204+ trace_ptr_addr = 0x41F0E0;
5205+ trace_idx_addr = 0x41F0E8;
5206+ trace_num_addr = mt76_rr(dev, 0x41F0E4);
5207+ break;
5208+ case 0x7981:
5209+ trace_ptr_addr = 0x022050C4;
5210+ trace_idx_addr = 0x022050C0;
5211+ break;
5212+ case 0x7906:
5213+ trace_ptr_addr = 0x02205214;
5214+ trace_idx_addr = 0x02205210;
5215+ break;
5216+ case 0x7986:
5217+ default:
5218+ trace_ptr_addr = 0x0220514C;
5219+ trace_idx_addr = 0x02205148;
5220+ break;
5221+ }
developer8effbd32023-04-17 15:57:28 +08005222+
developer1a173672023-12-21 14:49:33 +08005223+ size = is_mt7915(&dev->mt76) ? sizeof(struct mt7915_cos_program_trace_t) : sizeof(struct cos_program_trace_t);
5224+ trace_num = is_mt7915(&dev->mt76) ? MemReadOneByte(dev, trace_num_addr) & 0xff : 32;
5225+ buf = kzalloc(trace_num * size, GFP_KERNEL);
5226+ if (!buf) {
developer8effbd32023-04-17 15:57:28 +08005227+ seq_printf(s, "can not allocate cos_program_trace_ptr memory\n");
5228+ return;
5229+ }
developer8effbd32023-04-17 15:57:28 +08005230+
developer1a173672023-12-21 14:49:33 +08005231+ trace_ptr = mt76_rr(dev, trace_ptr_addr);
5232+ old_idx_addr = mt76_rr(dev, trace_idx_addr);
5233+ old_idx = (is_mt7915(&dev->mt76) ? MemReadOneByte(dev, old_idx_addr) : (old_idx_addr >> 8)) & 0xff;
developer8effbd32023-04-17 15:57:28 +08005234+
developer1a173672023-12-21 14:49:33 +08005235+ MemSectionRead(dev, &buf[0], trace_num * size, trace_ptr);
developer8effbd32023-04-17 15:57:28 +08005236+
developer1a173672023-12-21 14:49:33 +08005237+ if (is_mt7915(&dev->mt76))
5238+ mt7915_cos_program_trace_ptr = (struct mt7915_cos_program_trace_t *)buf;
5239+ else
5240+ cos_program_trace_ptr = (struct cos_program_trace_t *)buf;
developer8effbd32023-04-17 15:57:28 +08005241+
developer8effbd32023-04-17 15:57:28 +08005242+ seq_printf(s, "\n");
5243+ seq_printf(s, " program trace:\n");
developer1a173672023-12-21 14:49:33 +08005244+ for (idx = 0 ; idx < trace_num ; idx++) {
5245+ prev_idx = ((old_idx + trace_num - 1) % trace_num);
5246+
5247+ prev_time = mt7915_cos_access_ptr(prev_idx, ts_gpt2);
5248+ old_time = mt7915_cos_access_ptr(old_idx, ts_gpt2);
5249+ prev_dest_id = mt7915_cos_access_ptr(prev_idx, dest_id);
5250+ old_dest_id = mt7915_cos_access_ptr(old_idx, dest_id);
5251+ prev_msg_sn = mt7915_cos_access_ptr(prev_idx, msg_sn);
5252+ old_msg_sn = mt7915_cos_access_ptr(old_idx, msg_sn);
developer8effbd32023-04-17 15:57:28 +08005253+
5254+ seq_printf(s, " (p_%d)t_id=%x/%d, m_id=%d, LP=0x%x, name=%s, ts2=%d, ",
5255+ old_idx,
developer1a173672023-12-21 14:49:33 +08005256+ old_dest_id,
5257+ old_msg_sn,
5258+ mt7915_cos_access_ptr(old_idx, msg_id),
5259+ mt7915_cos_access_ptr(old_idx, LP),
5260+ mt7915_cos_access_ptr(old_idx, name),
5261+ old_time);
developer8effbd32023-04-17 15:57:28 +08005262+
5263+ /* diff for gpt2 */
developer1a173672023-12-21 14:49:33 +08005264+
5265+ diff = 0xFFFFFFFF;
developer8effbd32023-04-17 15:57:28 +08005266+
5267+ if (prev_time) {
developer1a173672023-12-21 14:49:33 +08005268+ if ((prev_dest_id == old_dest_id) && (prev_msg_sn == old_msg_sn)) {
5269+ if (old_time > prev_time)
5270+ diff = old_time - prev_time;
developer8effbd32023-04-17 15:57:28 +08005271+ else
developer1a173672023-12-21 14:49:33 +08005272+ diff = 0xFFFFFFFF - prev_time + old_time + 1;
5273+ }
5274+ }
developer8effbd32023-04-17 15:57:28 +08005275+
5276+ if (diff == 0xFFFFFFFF)
5277+ seq_printf(s, "diff2=NA, \n");
5278+ else
5279+ seq_printf(s, "diff2=%8d\n", diff);
5280+
5281+ old_idx++;
developer1a173672023-12-21 14:49:33 +08005282+ if (old_idx >= trace_num)
developer8effbd32023-04-17 15:57:28 +08005283+ old_idx = 0;
5284+ }
developer1a173672023-12-21 14:49:33 +08005285+ if (buf)
5286+ kfree(buf);
developer8effbd32023-04-17 15:57:28 +08005287+}
5288+
5289+static int mt7915_fw_wm_info_read(struct seq_file *s, void *data)
5290+{
5291+ struct mt7915_dev *dev = dev_get_drvdata(s->private);
developer1a173672023-12-21 14:49:33 +08005292+ u32 macVal, g_exp_type, COS_Interrupt_Count;
5293+ u8 exp_assert_proc_entry_cnt, exp_assert_state, g_irq_history_num;
5294+ u16 processing_irqx;
5295+ u32 processing_lisr, Current_Task_Id, Current_Task_Indx;
5296+ u8 km_irq_info_idx, km_eint_info_idx, km_sched_info_idx, g_sched_history_num;
5297+ u32 km_sched_trace_ptr, km_irq_trace_ptr, km_total_time;
developer8effbd32023-04-17 15:57:28 +08005298+ bool fgIsExp = false, fgIsAssert = false;
developer1a173672023-12-21 14:49:33 +08005299+ u32 TaskStart[2], TaskEnd[2];
5300+ u32 exp_assert_state_addr, g1_exp_counter_addr;
5301+ u32 g_exp_type_addr, cos_interrupt_count_addr;
5302+ u32 processing_irqx_addr, processing_lisr_addr;
5303+ u32 Current_Task_Id_addr, Current_Task_Indx_addr, last_dequeued_msg_id_addr;
5304+ u32 km_irq_info_idx_addr, km_eint_info_idx_addr, km_sched_info_idx_addr;
5305+ u32 g_sched_history_num_addr, km_sched_trace_ptr_addr;
5306+ u32 km_irq_trace_ptr_addr, km_total_time_addr, last_dequeued_msg_id;
5307+ u32 TaskStart_0, TaskEnd_0, TaskStart_1, TaskEnd_1;
5308+ u32 t1_base_addr, t2_base_addr, t3_base_addr, t_addr_ofs;
5309+ u32 cpu_itype_addr, cpu_eva_addr, cpu_ipc_addr, pc_addr;
5310+ u32 busy_addr, peak_addr;
5311+ u32 i, t1, t2, t3;
5312+ u8 idx, exp_type[64];
developer8effbd32023-04-17 15:57:28 +08005313+
developer1a173672023-12-21 14:49:33 +08005314+ switch (mt76_chip(&dev->mt76)) {
5315+ case 0x7915:
5316+ g_exp_type_addr = 0x21987C;
5317+ exp_assert_state_addr = 0x219848;
5318+ g1_exp_counter_addr = 0x219848;
5319+ cos_interrupt_count_addr = 0x216F94;
5320+ processing_irqx_addr = 0x216EF8;
5321+ processing_lisr_addr = 0x2170AC;
5322+ Current_Task_Id_addr = 0x216F90;
5323+ Current_Task_Indx_addr = 0x216F9C;
5324+ last_dequeued_msg_id_addr = 0x216F70;
5325+ km_irq_info_idx_addr = 0x219820;
5326+ km_eint_info_idx_addr = 0x219818;
5327+ km_sched_info_idx_addr = 0x219828;
5328+ g_sched_history_num_addr = 0x219828;
5329+ km_sched_trace_ptr_addr = 0x219824;
5330+ km_irq_trace_ptr_addr = 0x21981C;
5331+ km_total_time_addr = 0x219838;
5332+ TaskStart_0 = 0x2195A0;
5333+ TaskEnd_0 = 0x21959C;
5334+ TaskStart_1 = 0x219680;
5335+ TaskEnd_1 = 0x21967C;
5336+ t1_base_addr = 0x219558;
5337+ t2_base_addr = 0x219554;
5338+ t3_base_addr = 0x219560;
5339+ cpu_itype_addr = 0x41F088;
5340+ cpu_eva_addr = 0x41F08C;
5341+ cpu_ipc_addr = 0x41F094;
5342+ pc_addr = 0x7C060204;
5343+ busy_addr = 0x41F030;
5344+ peak_addr = 0x41F034;
5345+ break;
5346+ case 0x7981:
5347+ g_exp_type_addr = 0x02205054;
5348+ exp_assert_state_addr = 0x02204AC0;
5349+ g1_exp_counter_addr = 0x02204F68;
5350+ cos_interrupt_count_addr = 0x02204FFC;
5351+ processing_irqx_addr = 0x02204E30;
5352+ processing_lisr_addr = 0x02204F7C;
5353+ Current_Task_Id_addr = 0x02204F18;
5354+ Current_Task_Indx_addr = 0x02204F18;
5355+ last_dequeued_msg_id_addr = 0x02204E94;
5356+ km_irq_info_idx_addr = 0x02205114;
5357+ km_eint_info_idx_addr = 0x0220510C;
5358+ km_sched_info_idx_addr = 0x0220511C;
5359+ g_sched_history_num_addr = 0x0220511C;
5360+ km_sched_trace_ptr_addr = 0x02205118;
5361+ km_irq_trace_ptr_addr = 0x02205110;
5362+ km_total_time_addr = 0x0220512C;
5363+ TaskStart_0 = 0x022028B4;
5364+ TaskEnd_0 = 0x022028C0;
5365+ TaskStart_1 = 0x02202A38;
5366+ TaskEnd_1 = 0x02202934;
5367+ t1_base_addr = 0x02202718;
5368+ t2_base_addr = 0x0220287C;
5369+ t3_base_addr = 0x02202884;
5370+ cpu_itype_addr = 0x02205058;
5371+ cpu_eva_addr = 0x02205060;
5372+ cpu_ipc_addr = 0x0220505C;
5373+ pc_addr = 0x7C060204;
5374+ busy_addr = 0x7C053B20;
5375+ peak_addr = 0x7C053B24;
5376+ break;
5377+ case 0x7906:
5378+ g_exp_type_addr = 0x022051A4;
5379+ exp_assert_state_addr = 0x02204C14;
5380+ g1_exp_counter_addr = 0x022050BC;
5381+ cos_interrupt_count_addr = 0x022001AC;
5382+ processing_irqx_addr = 0x02204F84;
5383+ processing_lisr_addr = 0x022050D0;
5384+ Current_Task_Id_addr = 0x0220406C;
5385+ Current_Task_Indx_addr = 0x0220500C;
5386+ last_dequeued_msg_id_addr = 0x02204FE8;
5387+ km_irq_info_idx_addr = 0x02205264;
5388+ km_eint_info_idx_addr = 0x0220525C;
5389+ km_sched_info_idx_addr = 0x0220526C;
5390+ g_sched_history_num_addr = 0x0220516C;
5391+ km_sched_trace_ptr_addr = 0x02205268;
5392+ km_irq_trace_ptr_addr = 0x02205260;
5393+ km_total_time_addr = 0x0220517C;
5394+ TaskStart_0 = 0x022028C8;
5395+ TaskEnd_0 = 0x022028C4;
5396+ TaskStart_1 = 0x02202A38;
5397+ TaskEnd_1 = 0x02202934;
5398+ t1_base_addr = 0x0220286C;
5399+ t2_base_addr = 0x02202870;
5400+ t3_base_addr = 0x02202878;
5401+ cpu_itype_addr = 0x022051A8;
5402+ cpu_eva_addr = 0x022051B0;
5403+ cpu_ipc_addr = 0x022051AC;
5404+ pc_addr = 0x7C060204;
5405+ busy_addr = 0x7C053B20;
5406+ peak_addr = 0x7C053B24;
5407+ break;
5408+ case 0x7986:
5409+ default:
5410+ g_exp_type_addr = 0x022050DC;
5411+ exp_assert_state_addr = 0x02204B54;
5412+ g1_exp_counter_addr = 0x02204FFC;
5413+ cos_interrupt_count_addr = 0x022001AC;
5414+ processing_irqx_addr = 0x02204EC4;
5415+ processing_lisr_addr = 0x02205010;
5416+ Current_Task_Id_addr = 0x02204FAC;
5417+ Current_Task_Indx_addr = 0x02204F4C;
5418+ last_dequeued_msg_id_addr = 0x02204F28;
5419+ km_irq_info_idx_addr = 0x0220519C;
5420+ km_eint_info_idx_addr = 0x02205194;
5421+ km_sched_info_idx_addr = 0x022051A4;
5422+ g_sched_history_num_addr = 0x022051A4;
5423+ km_sched_trace_ptr_addr = 0x022051A0;
5424+ km_irq_trace_ptr_addr = 0x02205198;
5425+ km_total_time_addr = 0x022051B4;
5426+ TaskStart_0 = 0x02202814;
5427+ TaskEnd_0 = 0x02202810;
5428+ TaskStart_1 = 0x02202984;
5429+ TaskEnd_1 = 0x02202980;
5430+ t1_base_addr = 0x022027B8;
5431+ t2_base_addr = 0x022027BC;
5432+ t3_base_addr = 0x022027C4;
5433+ cpu_itype_addr = 0x022050E0;
5434+ cpu_eva_addr = 0x022050E8;
5435+ cpu_ipc_addr = 0x022050E4;
5436+ pc_addr = 0x7C060204;
5437+ busy_addr = 0x7C053B20;
5438+ peak_addr = 0x7C053B24;
5439+ break;
5440+ }
developer8effbd32023-04-17 15:57:28 +08005441+
developer8effbd32023-04-17 15:57:28 +08005442+ macVal = mt76_rr(dev, exp_assert_state_addr);
5443+ exp_assert_state = (macVal & 0xff);
5444+
developer8effbd32023-04-17 15:57:28 +08005445+ macVal = mt76_rr(dev, g1_exp_counter_addr);
developer1a173672023-12-21 14:49:33 +08005446+ exp_assert_proc_entry_cnt = (is_mt7915(&dev->mt76) ? (macVal >> 8) : macVal) & 0xff;
developer8effbd32023-04-17 15:57:28 +08005447+
developer8effbd32023-04-17 15:57:28 +08005448+ macVal = mt76_rr(dev, g_exp_type_addr);
developer1a173672023-12-21 14:49:33 +08005449+ g_exp_type = is_mt7915(&dev->mt76) ? ((macVal >> 8) & 0xff) : macVal;
developer8effbd32023-04-17 15:57:28 +08005450+
developer1a173672023-12-21 14:49:33 +08005451+ COS_Interrupt_Count = mt76_rr(dev, cos_interrupt_count_addr);
developer8effbd32023-04-17 15:57:28 +08005452+
developer8effbd32023-04-17 15:57:28 +08005453+ macVal = mt76_rr(dev, processing_irqx_addr);
developer1a173672023-12-21 14:49:33 +08005454+ processing_irqx = (is_mt7915(&dev->mt76) ? (macVal >> 16) : macVal) & 0xffff;
developer8effbd32023-04-17 15:57:28 +08005455+
developer1a173672023-12-21 14:49:33 +08005456+ processing_lisr = mt76_rr(dev, processing_lisr_addr);
5457+ Current_Task_Id = mt76_rr(dev, Current_Task_Id_addr);
5458+ Current_Task_Indx = mt76_rr(dev, Current_Task_Indx_addr);
5459+ last_dequeued_msg_id = mt76_rr(dev, last_dequeued_msg_id_addr);
developer8effbd32023-04-17 15:57:28 +08005460+
developer8effbd32023-04-17 15:57:28 +08005461+ macVal = mt76_rr(dev, km_eint_info_idx_addr);
developer1a173672023-12-21 14:49:33 +08005462+ km_eint_info_idx = (is_mt7915(&dev->mt76) ? macVal : (macVal >> 8)) & 0xff;
developer8effbd32023-04-17 15:57:28 +08005463+
developer8effbd32023-04-17 15:57:28 +08005464+ macVal = mt76_rr(dev, g_sched_history_num_addr);
developer1a173672023-12-21 14:49:33 +08005465+ g_sched_history_num = (is_mt7915(&dev->mt76) ? (macVal >> 8) : macVal) & 0xff;
5466+ km_sched_info_idx = (is_mt7915(&dev->mt76) ? macVal : (macVal >> 8)) & 0xff;
developer8effbd32023-04-17 15:57:28 +08005467+
developer1a173672023-12-21 14:49:33 +08005468+ km_sched_trace_ptr = mt76_rr(dev, km_sched_trace_ptr_addr);
developer8effbd32023-04-17 15:57:28 +08005469+
developer8effbd32023-04-17 15:57:28 +08005470+ macVal = mt76_rr(dev, km_irq_info_idx_addr);
developer1a173672023-12-21 14:49:33 +08005471+ g_irq_history_num = (is_mt7915(&dev->mt76) ? (macVal >> 8) : macVal) & 0xff;
5472+ km_irq_info_idx = (is_mt7915(&dev->mt76) ? macVal : (macVal >> 16)) & 0xff;
developer8effbd32023-04-17 15:57:28 +08005473+
developer1a173672023-12-21 14:49:33 +08005474+ km_irq_trace_ptr = mt76_rr(dev, km_irq_trace_ptr_addr);
5475+ km_total_time = mt76_rr(dev, km_total_time_addr);
developer8effbd32023-04-17 15:57:28 +08005476+
developer1a173672023-12-21 14:49:33 +08005477+ TaskStart[0] = mt76_rr(dev, TaskStart_0);
5478+ TaskEnd[0] = mt76_rr(dev, TaskEnd_0);
5479+ TaskStart[1] = mt76_rr(dev, TaskStart_1);
5480+ TaskEnd[1] = mt76_rr(dev, TaskEnd_1);
developer8effbd32023-04-17 15:57:28 +08005481+
5482+ seq_printf(s, "================FW DBG INFO===================\n");
5483+ seq_printf(s, " exp_assert_proc_entry_cnt = 0x%x\n",
5484+ exp_assert_proc_entry_cnt);
5485+ seq_printf(s, " exp_assert_state = 0x%x\n",
5486+ exp_assert_state);
5487+
5488+ if (exp_assert_proc_entry_cnt == 0) {
developer1a173672023-12-21 14:49:33 +08005489+ snprintf(exp_type, sizeof(exp_type), "%s", "exp_type : Normal");
5490+ } else if (exp_assert_proc_entry_cnt == 1 && exp_assert_state > 1 && g_exp_type == 5) {
5491+ snprintf(exp_type, sizeof(exp_type), "%s", "exp_type : Assert");
developer8effbd32023-04-17 15:57:28 +08005492+ fgIsExp = true;
5493+ fgIsAssert = true;
5494+ } else if (exp_assert_proc_entry_cnt == 1 && exp_assert_state > 1) {
developer1a173672023-12-21 14:49:33 +08005495+ snprintf(exp_type, sizeof(exp_type), "%s", "exp_type : Exception");
developer8effbd32023-04-17 15:57:28 +08005496+ fgIsExp = true;
5497+ } else if (exp_assert_proc_entry_cnt > 1) {
developer1a173672023-12-21 14:49:33 +08005498+ snprintf(exp_type, sizeof(exp_type), "%s", "exp_type : Exception re-entry");
developer8effbd32023-04-17 15:57:28 +08005499+ fgIsExp = true;
5500+ } else {
developer1a173672023-12-21 14:49:33 +08005501+ snprintf(exp_type, sizeof(exp_type), "%s", "exp_type : Unknown?");
developer8effbd32023-04-17 15:57:28 +08005502+ }
5503+
5504+ seq_printf(s, " COS_Interrupt_Count = 0x%x\n", COS_Interrupt_Count);
5505+ seq_printf(s, " processing_irqx = 0x%x\n", processing_irqx);
5506+ seq_printf(s, " processing_lisr = 0x%x\n", processing_lisr);
5507+ seq_printf(s, " Current_Task_Id = 0x%x\n", Current_Task_Id);
5508+ seq_printf(s, " Current_Task_Indx = 0x%x\n", Current_Task_Indx);
5509+ seq_printf(s, " last_dequeued_msg_id = %d\n", last_dequeued_msg_id);
5510+
5511+ seq_printf(s, " km_irq_info_idx = 0x%x\n", km_irq_info_idx);
5512+ seq_printf(s, " km_eint_info_idx = 0x%x\n", km_eint_info_idx);
5513+ seq_printf(s, " km_sched_info_idx = 0x%x\n", km_sched_info_idx);
5514+ seq_printf(s, " g_sched_history_num = %d\n", g_sched_history_num);
5515+ seq_printf(s, " km_sched_trace_ptr = 0x%x\n", km_sched_trace_ptr);
5516+
5517+ if (fgIsExp) {
5518+ seq_printf(s, "\n <1>print sched trace\n");
5519+ if (g_sched_history_num > 60)
5520+ g_sched_history_num = 60;
5521+
5522+ idx = km_sched_info_idx;
5523+ for (i = 0 ; i < g_sched_history_num ; i++) {
5524+ t1 = mt76_rr(dev, (km_sched_trace_ptr+(idx*12)));
5525+ t2 = mt76_rr(dev, (km_sched_trace_ptr+(idx*12)+4));
5526+ t3 = mt76_rr(dev, (km_sched_trace_ptr+(idx*12)+8));
5527+ seq_printf(s, " (sched_info_%d)sched_t=0x%x, sched_start=%d, PC=0x%x\n",
5528+ idx, t1, t2, t3);
5529+ idx++;
5530+ if (idx >= g_sched_history_num)
5531+ idx = 0;
5532+ }
5533+
5534+ seq_printf(s, "\n <2>print irq trace\n");
5535+ if (g_irq_history_num > 60)
5536+ g_irq_history_num = 60;
5537+
5538+ idx = km_irq_info_idx;
5539+ for (i = 0 ; i < g_irq_history_num ; i++) {
5540+ t1 = mt76_rr(dev, (km_irq_trace_ptr+(idx*16)));
5541+ t2 = mt76_rr(dev, (km_irq_trace_ptr+(idx*16) + 4));
5542+ seq_printf(s, " (irq_info_%d)irq_t=%x, sched_start=%d\n",
5543+ idx, t1, t2);
5544+ idx++;
5545+ if (idx >= g_irq_history_num)
5546+ idx = 0;
5547+ }
5548+ }
5549+
5550+ seq_printf(s, "\n <3>task q_id.read q_id.write\n");
5551+ seq_printf(s, " (WIFI )1 0x%x 0x%x\n", TaskStart[0], TaskEnd[0]);
5552+ seq_printf(s, " (WIFI2 )2 0x%x 0x%x\n", TaskStart[1], TaskEnd[1]);
5553+ seq_printf(s, "\n <4>TASK STACK INFO (size in byte)\n");
5554+ seq_printf(s, " TASK START END SIZE PEAK INTEGRITY\n");
5555+
developer1a173672023-12-21 14:49:33 +08005556+ t_addr_ofs = is_mt7915(&dev->mt76) ? 224 : 368;
developer8effbd32023-04-17 15:57:28 +08005557+ for (i = 0 ; i < 2 ; i++) {
developer1a173672023-12-21 14:49:33 +08005558+ t1 = mt76_rr(dev, t1_base_addr + (i*t_addr_ofs));
5559+ t2 = mt76_rr(dev, t2_base_addr + (i*t_addr_ofs));
5560+ t3 = mt76_rr(dev, t3_base_addr + (i*t_addr_ofs));
developer8effbd32023-04-17 15:57:28 +08005561+
5562+ seq_printf(s, " %s 0x%x 0x%x %d\n",
developer1a173672023-12-21 14:49:33 +08005563+ i == 0 ? "WIFI" : "WIFI2", t1, t2, t3);
developer8effbd32023-04-17 15:57:28 +08005564+ }
5565+
5566+ seq_printf(s, "\n <5>fw state\n");
5567+ seq_printf(s, " %s\n", exp_type);
5568+ if (COS_Interrupt_Count > 0)
5569+ seq_printf(s, " FW in Interrupt CIRQ index (0x%x) CIRQ handler(0x%x)\n"
5570+ , processing_irqx, processing_lisr);
5571+ else {
5572+ if (Current_Task_Id == 0 && Current_Task_Indx == 3)
5573+ seq_printf(s, " FW in IDLE\n");
5574+
5575+ if (Current_Task_Id != 0 && Current_Task_Indx != 3)
5576+ seq_printf(s, " FW in Task , Task id(0x%x) Task index(0x%x)\n",
5577+ Current_Task_Id, Current_Task_Indx);
5578+ }
5579+
developer1a173672023-12-21 14:49:33 +08005580+ macVal = mt76_rr(dev, is_mt7915(&dev->mt76) ? 0x41F080 : g1_exp_counter_addr);
developer8effbd32023-04-17 15:57:28 +08005581+ seq_printf(s, " EXCP_CNT = 0x%x\n", macVal);
5582+
5583+ seq_printf(s, " EXCP_TYPE = 0x%x\n", g_exp_type);
developer1a173672023-12-21 14:49:33 +08005584+ seq_printf(s, " CPU_ITYPE = 0x%x\n", mt76_rr(dev, cpu_itype_addr));
5585+ seq_printf(s, " CPU_EVA = 0x%x\n", mt76_rr(dev, cpu_eva_addr));
5586+ seq_printf(s, " CPU_IPC = 0x%x\n", mt76_rr(dev, cpu_ipc_addr));
5587+ seq_printf(s, " PC = 0x%x\n\n\n", mt76_rr(dev, pc_addr));
developer8effbd32023-04-17 15:57:28 +08005588+
5589+ mt7915_show_lp_history(s, fgIsExp);
5590+ mt7915_show_irq_history(s);
5591+
developer1a173672023-12-21 14:49:33 +08005592+ seq_printf(s, "\n\n cpu utility\n");
developer8effbd32023-04-17 15:57:28 +08005593+ seq_printf(s, " Busy:%d%% Peak:%d%%\n\n",
developer1a173672023-12-21 14:49:33 +08005594+ mt76_rr(dev, busy_addr), mt76_rr(dev, peak_addr));
developer8effbd32023-04-17 15:57:28 +08005595+
5596+ mt7915_show_msg_trace(s);
5597+ mt7915_show_sech_trace(s);
5598+ mt7915_show_prog_trace(s);
developer1a173672023-12-21 14:49:33 +08005599+
developer8effbd32023-04-17 15:57:28 +08005600+ if (fgIsAssert)
5601+ mt7915_show_assert_line(s);
5602+
5603+ seq_printf(s, "============================================\n");
5604+ return 0;
5605+}
5606+
developer73e5a572022-04-19 10:21:20 +08005607+int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir)
5608+{
5609+ struct mt7915_dev *dev = phy->dev;
5610+ u32 device_id = (dev->mt76.rev) >> 16;
5611+ int i = 0;
5612+
5613+ for (i = 0; i < ARRAY_SIZE(dbg_reg_s); i++) {
5614+ if (device_id == dbg_reg_s[i].id) {
5615+ dev->dbg_reg = &dbg_reg_s[i];
5616+ break;
5617+ }
5618+ }
5619+
5620+ mt7915_mcu_fw_log_2_host(dev, MCU_FW_LOG_WM, 0);
5621+
5622+ debugfs_create_file("fw_debug_module", 0600, dir, dev,
5623+ &fops_fw_debug_module);
5624+ debugfs_create_file("fw_debug_level", 0600, dir, dev,
5625+ &fops_fw_debug_level);
5626+
developerd68e00e2022-06-01 10:59:24 +08005627+ debugfs_create_devm_seqfile(dev->mt76.dev, "sta_info", dir,
5628+ mt7915_sta_info);
developer73e5a572022-04-19 10:21:20 +08005629+ debugfs_create_devm_seqfile(dev->mt76.dev, "wtbl_info", dir,
5630+ mt7915_wtbl_read);
5631+ debugfs_create_devm_seqfile(dev->mt76.dev, "uwtbl_info", dir,
5632+ mt7915_uwtbl_read);
5633+
5634+ debugfs_create_devm_seqfile(dev->mt76.dev, "tr_info", dir,
5635+ mt7915_trinfo_read);
5636+
5637+ debugfs_create_devm_seqfile(dev->mt76.dev, "drr_info", dir,
5638+ mt7915_drr_info);
5639+
5640+ debugfs_create_devm_seqfile(dev->mt76.dev, "ple_info", dir,
5641+ mt7915_pleinfo_read);
5642+
5643+ debugfs_create_devm_seqfile(dev->mt76.dev, "pse_info", dir,
5644+ mt7915_pseinfo_read);
5645+
5646+ debugfs_create_devm_seqfile(dev->mt76.dev, "mib_info0", dir,
5647+ mt7915_mibinfo_band0);
5648+ debugfs_create_devm_seqfile(dev->mt76.dev, "mib_info1", dir,
5649+ mt7915_mibinfo_band1);
5650+
5651+ debugfs_create_u32("token_idx", 0600, dir, &dev->dbg.token_idx);
5652+ debugfs_create_devm_seqfile(dev->mt76.dev, "token", dir,
5653+ mt7915_token_read);
5654+ debugfs_create_devm_seqfile(dev->mt76.dev, "token_txd", dir,
5655+ mt7915_token_txd_read);
5656+
5657+ debugfs_create_devm_seqfile(dev->mt76.dev, "amsdu_info", dir,
5658+ mt7915_amsduinfo_read);
5659+
5660+ debugfs_create_devm_seqfile(dev->mt76.dev, "agg_info0", dir,
5661+ mt7915_agginfo_read_band0);
5662+ debugfs_create_devm_seqfile(dev->mt76.dev, "agg_info1", dir,
5663+ mt7915_agginfo_read_band1);
5664+
5665+ debugfs_create_file("tx_amsdu", 0600, dir, dev, &fops_tx_amsdu);
5666+
5667+ debugfs_create_file("fw_wa_query", 0600, dir, dev, &fops_wa_query);
5668+ debugfs_create_file("fw_wa_set", 0600, dir, dev, &fops_wa_set);
developer67705712023-05-30 11:58:00 +08005669+ debugfs_create_devm_seqfile(dev->mt76.dev, "fw_version", dir,
5670+ mt7915_dump_version);
developer73e5a572022-04-19 10:21:20 +08005671+ debugfs_create_file("fw_wa_debug", 0600, dir, dev, &fops_wa_debug);
developer8effbd32023-04-17 15:57:28 +08005672+ debugfs_create_devm_seqfile(dev->mt76.dev, "fw_wm_info", dir,
5673+ mt7915_fw_wm_info_read);
developer73e5a572022-04-19 10:21:20 +08005674+
5675+ debugfs_create_file("red_en", 0600, dir, dev,
5676+ &fops_red_en);
5677+ debugfs_create_file("red_show_sta", 0600, dir, dev,
5678+ &fops_red_show_sta);
5679+ debugfs_create_file("red_target_dly", 0600, dir, dev,
5680+ &fops_red_target_dly);
5681+
5682+ debugfs_create_file("txpower_level", 0400, dir, dev,
5683+ &fops_txpower_level);
5684+
developer7c3a5082022-06-24 13:40:42 +08005685+ debugfs_create_u8("sku_disable", 0600, dir, &dev->dbg.sku_disable);
5686+
developer73e5a572022-04-19 10:21:20 +08005687+ return 0;
5688+}
5689+#endif
5690diff --git a/mt7915/mtk_mcu.c b/mt7915/mtk_mcu.c
5691new file mode 100644
developerdc9eeae2024-04-08 14:36:46 +08005692index 0000000..143dae2
developer73e5a572022-04-19 10:21:20 +08005693--- /dev/null
5694+++ b/mt7915/mtk_mcu.c
5695@@ -0,0 +1,51 @@
5696+#include <linux/firmware.h>
5697+#include <linux/fs.h>
5698+#include<linux/inet.h>
5699+#include "mt7915.h"
5700+#include "mcu.h"
5701+#include "mac.h"
5702+
5703+int mt7915_mcu_set_txpower_level(struct mt7915_phy *phy, u8 drop_level)
5704+{
5705+ struct mt7915_dev *dev = phy->dev;
5706+ struct mt7915_sku_val {
5707+ u8 format_id;
5708+ u8 val;
5709+ u8 band;
5710+ u8 _rsv;
5711+ } __packed req = {
5712+ .format_id = 1,
developer17bb0a82022-12-13 15:52:04 +08005713+ .band = phy->mt76->band_idx,
developer73e5a572022-04-19 10:21:20 +08005714+ .val = !!drop_level,
5715+ };
5716+ int ret;
5717+
5718+ ret = mt76_mcu_send_msg(&dev->mt76,
5719+ MCU_EXT_CMD(TX_POWER_FEATURE_CTRL), &req,
5720+ sizeof(req), true);
5721+ if (ret)
5722+ return ret;
5723+
5724+ req.format_id = 2;
5725+ if ((drop_level > 90 && drop_level < 100) || !drop_level)
5726+ req.val = 0;
5727+ else if (drop_level > 60 && drop_level <= 90)
5728+ /* reduce Pwr for 1 dB. */
5729+ req.val = 2;
5730+ else if (drop_level > 30 && drop_level <= 60)
5731+ /* reduce Pwr for 3 dB. */
5732+ req.val = 6;
5733+ else if (drop_level > 15 && drop_level <= 30)
5734+ /* reduce Pwr for 6 dB. */
5735+ req.val = 12;
5736+ else if (drop_level > 9 && drop_level <= 15)
5737+ /* reduce Pwr for 9 dB. */
5738+ req.val = 18;
5739+ else if (drop_level > 0 && drop_level <= 9)
5740+ /* reduce Pwr for 12 dB. */
5741+ req.val = 24;
5742+
5743+ return mt76_mcu_send_msg(&dev->mt76,
5744+ MCU_EXT_CMD(TX_POWER_FEATURE_CTRL), &req,
5745+ sizeof(req), true);
5746+}
developera46f6132024-03-26 14:09:54 +08005747diff --git a/mt7915/soc.c b/mt7915/soc.c
developerdc9eeae2024-04-08 14:36:46 +08005748index bb3468a..b941a49 100644
developera46f6132024-03-26 14:09:54 +08005749--- a/mt7915/soc.c
5750+++ b/mt7915/soc.c
developerdc9eeae2024-04-08 14:36:46 +08005751@@ -360,6 +360,13 @@ static int mt798x_wmac_sku_setup(struct mt7915_dev *dev, u32 *adie_type)
developera46f6132024-03-26 14:09:54 +08005752 *adie_type = FIELD_GET(MT_ADIE_CHIP_ID_MASK, adie_main) |
5753 (MT_ADIE_CHIP_ID_MASK & adie_ext);
5754
5755+#ifdef MTK_DEBUG
5756+ dev->adie[ADIE0].id = FIELD_GET(MT_ADIE_CHIP_ID_MASK, adie_main);
5757+ dev->adie[ADIE0].version = FIELD_GET(MT_ADIE_VERSION_MASK, adie_main);
5758+ dev->adie[ADIE1].id = FIELD_GET(MT_ADIE_CHIP_ID_MASK, adie_ext);
5759+ dev->adie[ADIE1].version = FIELD_GET(MT_ADIE_VERSION_MASK, adie_ext);
5760+#endif
5761+
5762 out:
5763 mt76_wmac_spi_unlock(dev);
5764
developer73e5a572022-04-19 10:21:20 +08005765diff --git a/tools/fwlog.c b/tools/fwlog.c
developerdc9eeae2024-04-08 14:36:46 +08005766index e5d4a10..3d51d9e 100644
developer73e5a572022-04-19 10:21:20 +08005767--- a/tools/fwlog.c
5768+++ b/tools/fwlog.c
5769@@ -26,7 +26,7 @@ static const char *debugfs_path(const char *phyname, const char *file)
5770 return path;
5771 }
5772
5773-static int mt76_set_fwlog_en(const char *phyname, bool en)
5774+static int mt76_set_fwlog_en(const char *phyname, bool en, char *val)
5775 {
5776 FILE *f = fopen(debugfs_path(phyname, "fw_debug_bin"), "w");
5777
5778@@ -35,7 +35,13 @@ static int mt76_set_fwlog_en(const char *phyname, bool en)
5779 return 1;
5780 }
5781
5782- fprintf(f, "7");
5783+ if (en && val)
5784+ fprintf(f, "%s", val);
5785+ else if (en)
5786+ fprintf(f, "7");
5787+ else
5788+ fprintf(f, "0");
5789+
5790 fclose(f);
5791
5792 return 0;
5793@@ -76,6 +82,7 @@ static void handle_signal(int sig)
5794
5795 int mt76_fwlog(const char *phyname, int argc, char **argv)
5796 {
5797+#define BUF_SIZE 1504
5798 struct sockaddr_in local = {
5799 .sin_family = AF_INET,
5800 .sin_addr.s_addr = INADDR_ANY,
developerd68e00e2022-06-01 10:59:24 +08005801@@ -84,9 +91,10 @@ int mt76_fwlog(const char *phyname, int argc, char **argv)
developer73e5a572022-04-19 10:21:20 +08005802 .sin_family = AF_INET,
5803 .sin_port = htons(55688),
5804 };
5805- char buf[1504];
5806+ char *buf = calloc(BUF_SIZE, sizeof(char));
developerd68e00e2022-06-01 10:59:24 +08005807+ FILE *logfile = NULL;
developer73e5a572022-04-19 10:21:20 +08005808 int ret = 0;
5809- int yes = 1;
5810+ /* int yes = 1; */
5811 int s, fd;
5812
5813 if (argc < 1) {
developerd68e00e2022-06-01 10:59:24 +08005814@@ -99,19 +107,28 @@ int mt76_fwlog(const char *phyname, int argc, char **argv)
5815 return 1;
5816 }
5817
5818+ if (argc == 3) {
5819+ fprintf(stdout, "start logging to file %s\n", argv[2]);
5820+ logfile = fopen(argv[2], "wb");
5821+ if (!logfile) {
5822+ perror("fopen");
5823+ return 1;
5824+ }
5825+ }
5826+
5827 s = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
5828 if (s < 0) {
5829 perror("socket");
developer73e5a572022-04-19 10:21:20 +08005830 return 1;
5831 }
5832
5833- setsockopt(s, SOL_SOCKET, SO_BROADCAST, &yes, sizeof(yes));
5834+ /* setsockopt(s, SOL_SOCKET, SO_BROADCAST, &yes, sizeof(yes)); */
5835 if (bind(s, (struct sockaddr *)&local, sizeof(local)) < 0) {
5836 perror("bind");
5837 return 1;
5838 }
5839
5840- if (mt76_set_fwlog_en(phyname, true))
5841+ if (mt76_set_fwlog_en(phyname, true, argv[1]))
5842 return 1;
5843
5844 fd = open(debugfs_path(phyname, "fwlog_data"), O_RDONLY);
developerd68e00e2022-06-01 10:59:24 +08005845@@ -145,8 +162,8 @@ int mt76_fwlog(const char *phyname, int argc, char **argv)
developer73e5a572022-04-19 10:21:20 +08005846 if (!r)
5847 continue;
5848
5849- if (len > sizeof(buf)) {
5850- fprintf(stderr, "Length error: %d > %d\n", len, (int)sizeof(buf));
5851+ if (len > BUF_SIZE) {
5852+ fprintf(stderr, "Length error: %d > %d\n", len, BUF_SIZE);
5853 ret = 1;
5854 break;
5855 }
developerd68e00e2022-06-01 10:59:24 +08005856@@ -164,14 +181,19 @@ int mt76_fwlog(const char *phyname, int argc, char **argv)
5857 break;
5858 }
5859
5860- /* send buf */
5861- sendto(s, buf, len, 0, (struct sockaddr *)&remote, sizeof(remote));
5862+ if (logfile)
5863+ fwrite(buf, 1, len, logfile);
5864+ else
5865+ /* send buf */
5866+ sendto(s, buf, len, 0, (struct sockaddr *)&remote, sizeof(remote));
5867 }
5868
developer73e5a572022-04-19 10:21:20 +08005869 close(fd);
5870
5871 out:
5872- mt76_set_fwlog_en(phyname, false);
5873+ mt76_set_fwlog_en(phyname, false, NULL);
5874+ free(buf);
developerd68e00e2022-06-01 10:59:24 +08005875+ fclose(logfile);
developer73e5a572022-04-19 10:21:20 +08005876
5877 return ret;
5878 }
5879--
developerbddc9db2023-09-11 13:34:36 +080058802.18.0
developer73e5a572022-04-19 10:21:20 +08005881