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