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