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