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