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