blob: a1164321522fdda08d2a74463bf225a8ed2c3c06 [file] [log] [blame]
developer05f3b2b2024-08-19 19:17:34 +08001From e35c211ac14b2189475f945ca9025e444d825c97 Mon Sep 17 00:00:00 2001
2From: Peter Chiu <chui-hao.chiu@mediatek.com>
3Date: Wed, 29 May 2024 18:45:50 +0800
4Subject: [PATCH 146/199] mtk: mt76: mt7996: add debugfs knob to show mlo
5 related table
6
7Add the following debugfs knob
8- /sys/kernel/debug/ieee80211/phy0/mt76/mat_table
9- /sys/kernel/debug/ieee80211/phy0/mt76/band0/agg_table
10- /sys/kernel/debug/ieee80211/phy0/mt76/band0/rmac_table
11
12Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
13---
14 mt7996/debugfs.c | 3 +-
15 mt7996/mt7996.h | 3 +-
16 mt7996/mtk_debug_i.h | 24 +++++++++++
17 mt7996/mtk_debugfs_i.c | 92 +++++++++++++++++++++++++++++++++++++++++-
18 4 files changed, 119 insertions(+), 3 deletions(-)
19
20diff --git a/mt7996/debugfs.c b/mt7996/debugfs.c
21index 6eb395c4..968174e6 100644
22--- a/mt7996/debugfs.c
23+++ b/mt7996/debugfs.c
24@@ -1107,6 +1107,7 @@ int mt7996_init_band_debugfs(struct mt7996_phy *phy)
25
26 #ifdef CONFIG_MTK_DEBUG
27 mt7996_mtk_init_band_debugfs(phy, dir);
28+ mt7996_mtk_init_band_debugfs_internal(phy, dir);
29 #endif
30 return 0;
31 }
32@@ -1143,7 +1144,7 @@ int mt7996_init_dev_debugfs(struct mt7996_phy *phy)
33 if (phy == &dev->phy) {
34 dev->debugfs_dir = dir;
35 #ifdef CONFIG_MTK_DEBUG
36- mt7996_mtk_init_debugfs_internal(phy, dir);
37+ mt7996_mtk_init_dev_debugfs_internal(phy, dir);
38 #endif
39 }
40
41diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h
42index b5869bb8..96d8aae9 100644
43--- a/mt7996/mt7996.h
44+++ b/mt7996/mt7996.h
45@@ -1322,7 +1322,8 @@ void mt7996_packet_log_to_host(struct mt7996_dev *dev, const void *data, int len
46 void mt7996_dump_bmac_rxd_info(struct mt7996_dev *dev, __le32 *rxd);
47 void mt7996_dump_bmac_txd_info(struct seq_file *s, struct mt7996_dev *dev,
48 __le32 *txd, bool is_hif_txd, bool dump_txp);
49-int mt7996_mtk_init_debugfs_internal(struct mt7996_phy *phy, struct dentry *dir);
50+int mt7996_mtk_init_dev_debugfs_internal(struct mt7996_phy *phy, struct dentry *dir);
51+int mt7996_mtk_init_band_debugfs_internal(struct mt7996_phy *phy, struct dentry *dir);
52 #endif
53
54 #ifdef CONFIG_NET_MEDIATEK_SOC_WED
55diff --git a/mt7996/mtk_debug_i.h b/mt7996/mtk_debug_i.h
56index d3756fa2..cec8d57e 100644
57--- a/mt7996/mtk_debug_i.h
58+++ b/mt7996/mtk_debug_i.h
59@@ -982,6 +982,30 @@
60 #define HIF_TXP_ML_SHIFT 16
61 #define HIF_TXP_ML_MASK 0xffff0000
62
63+/* UWTBL */
64+#define MT_WF_UWTBL_BASE 0x820c4000
65+#define MT_WF_UWTBL(ofs) (MT_WF_UWTBL_BASE + (ofs))
66+
67+#define MT_WF_UWTBL_ITCR MT_WF_UWTBL(0x130)
68+#define MT_WF_UWTBL_ITCR0 MT_WF_UWTBL(0x138)
69+#define MT_WF_UWTBL_ITCR1 MT_WF_UWTBL(0x13c)
70+
71+#define MT_WF_UWTBL_ITCR_SET BIT(31)
72+#define MT_WF_UWTBL_ITCR_INDEX GENMASK(5, 0)
73+
74+/* RMAC */
75+#define MT_WF_RMAC_SRAM_DATA0(_band) MT_WF_RMAC(_band, 0x210)
76+#define MT_WF_RMAC_SRAM_DATA1(_band) MT_WF_RMAC(_band, 0x214)
77+#define MT_WF_RMAC_SRAM_BITMAP0(_band) MT_WF_RMAC(_band, 0x220)
78+#define MT_WF_RMAC_SRAM_BITMAP1(_band) MT_WF_RMAC(_band, 0x224)
79+#define MT_WF_RMAC_MEM_CTRL(_band) MT_WF_RMAC(_band, 0x228)
80+
81+#define MT_WF_RMAC_MEM_CRTL_TRIG BIT(31)
82+#define MT_WF_RMAC_MEM_CRTL_TDX GENMASK(7, 0)
83+
84+/* AGG */
85+#define MT_AGG_REMAP_CTRL(_band) MT_WF_AGG(_band, 0x094)
86+#define MT_AGG_REMAP_CTRL_OM_REMAP GENMASK(5, 0)
87 #endif
88
89 #endif
90diff --git a/mt7996/mtk_debugfs_i.c b/mt7996/mtk_debugfs_i.c
91index ea412cd5..839c3e31 100644
92--- a/mt7996/mtk_debugfs_i.c
93+++ b/mt7996/mtk_debugfs_i.c
94@@ -695,7 +695,86 @@ static int mt7996_rx_msdu_pg_read(struct seq_file *s, void *data)
95 return 0;
96 }
97
98-int mt7996_mtk_init_debugfs_internal(struct mt7996_phy *phy, struct dentry *dir)
99+static int
100+mt7996_mat_table_show(struct seq_file *s, void *data)
101+{
102+#define MT_MAX_MAT_TABLE_SIZE 63
103+ struct mt7996_dev *dev = s->private;
104+ int i;
105+
106+ for (i = 0; i < MT_MAX_MAT_TABLE_SIZE; i++) {
107+ u32 req = MT_WF_UWTBL_ITCR_SET |
108+ u32_encode_bits(i, MT_WF_UWTBL_ITCR_INDEX);
109+ u32 dw[2];
110+ u8 *addr = (u8 *)dw;
111+
112+ mt76_wr(dev, MT_WF_UWTBL_ITCR, req);
113+ dw[0] = mt76_rr(dev, MT_WF_UWTBL_ITCR0);
114+ dw[1] = mt76_rr(dev, MT_WF_UWTBL_ITCR1);
115+
116+ if (dw[0] || dw[1])
117+ seq_printf(s, "own_mld_id%d\tAddr: %pM\n", i, addr);
118+ }
119+ return 0;
120+}
121+DEFINE_SHOW_ATTRIBUTE(mt7996_mat_table);
122+
123+static int
124+mt7996_rmac_table_show(struct seq_file *s, void *data)
125+{
126+ struct mt7996_phy *phy = s->private;
127+ struct mt7996_dev *dev = phy->dev;
128+ unsigned long usage_bitmap[2] = {0};
129+ int i, j;
130+ u8 band = phy->mt76->band_idx;
131+
132+ usage_bitmap[0] = (unsigned long)mt76_rr(dev, MT_WF_RMAC_SRAM_BITMAP0(band));
133+ usage_bitmap[1] = (unsigned long)mt76_rr(dev, MT_WF_RMAC_SRAM_BITMAP1(band));
134+
135+ for (i = 0; i < 2; i++) {
136+ for_each_set_bit(j, &usage_bitmap[i], 32) {
137+ u32 req = MT_WF_RMAC_MEM_CRTL_TRIG |
138+ u32_encode_bits(i * 32 + j, MT_WF_RMAC_MEM_CRTL_TDX);
139+ u32 dw[2];
140+ u8 *addr = (u8 *)dw;
141+
142+ mt76_wr(dev, MT_WF_RMAC_MEM_CTRL(band), req);
143+ dw[0] = mt76_rr(dev, MT_WF_RMAC_SRAM_DATA0(band));
144+ dw[1] = mt76_rr(dev, MT_WF_RMAC_SRAM_DATA1(band));
145+
146+ seq_printf(s, "omac_idx%d\tAddr: %pM\n", i * 32 + j, addr);
147+ }
148+ }
149+
150+ return 0;
151+}
152+DEFINE_SHOW_ATTRIBUTE(mt7996_rmac_table);
153+
154+static int
155+mt7996_agg_table_show(struct seq_file *s, void *data)
156+{
157+ struct mt7996_phy *phy = s->private;
158+ struct mt7996_dev *dev = phy->dev;
159+ int i, j;
160+ u8 band = phy->mt76->band_idx;
161+
162+ for (i = 0; i < 4; i++) {
163+ u32 value = mt76_rr(dev, MT_AGG_REMAP_CTRL(band) + 4 * i);
164+
165+ for (j = 0; j < 4; j++) {
166+ u8 shift = 8 * j;
167+ u32 mask = MT_AGG_REMAP_CTRL_OM_REMAP << shift;
168+
169+ seq_printf(s, "idx%d: %d\n", i * 4 + j,
170+ (value & mask) >> shift);
171+ }
172+ }
173+
174+ return 0;
175+}
176+DEFINE_SHOW_ATTRIBUTE(mt7996_agg_table);
177+
178+int mt7996_mtk_init_dev_debugfs_internal(struct mt7996_phy *phy, struct dentry *dir)
179 {
180 struct mt7996_dev *dev = phy->dev;
181
182@@ -714,7 +793,18 @@ int mt7996_mtk_init_debugfs_internal(struct mt7996_phy *phy, struct dentry *dir)
183 mt7996_pse_fid_read);
184
185 debugfs_create_u8("dump_ple_txd", 0600, dir, &dev->dbg.dump_ple_txd);
186+
187+ /* MLO related Table */
188+ debugfs_create_file("mat_table", 0400, dir, dev, &mt7996_mat_table_fops);
189 return 0;
190 }
191
192+int mt7996_mtk_init_band_debugfs_internal(struct mt7996_phy *phy, struct dentry *dir)
193+{
194+ /* MLO related Table */
195+ debugfs_create_file("rmac_table", 0400, dir, phy, &mt7996_rmac_table_fops);
196+ debugfs_create_file("agg_table", 0400, dir, phy, &mt7996_agg_table_fops);
197+
198+ return 0;
199+}
200 #endif
201--
2022.18.0
203