blob: 3c55ef216762ae5e165d4ab0aa0101101d98d7d6 [file] [log] [blame]
developer1f55fcf2024-10-17 14:52:33 +08001From a478298624f92ce97005a37b5a67e6b9bae17654 Mon Sep 17 00:00:00 2001
developer05f3b2b2024-08-19 19:17:34 +08002From: Peter Chiu <chui-hao.chiu@mediatek.com>
3Date: Fri, 17 May 2024 17:34:03 +0800
developer1f55fcf2024-10-17 14:52:33 +08004Subject: [PATCH 125/193] mtk: mt76: mt7996: refactor amsdu debugfs
developer05f3b2b2024-08-19 19:17:34 +08005
61. Remove hw_amsdu_info which is duplicated with amsdu_info.
7
82. The amsdu_info cannot read CR directly because the CR is read-clear.
9 If amsdu_info read CR directly, the CR would be cleared and the
10 mt7996_mac_work cannot get correct value.
11
developerd0c89452024-10-11 16:53:27 +080012Change-Id: Ie83e861f32fa7ede075916f2393df51e39bebbad
developer05f3b2b2024-08-19 19:17:34 +080013Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
14---
15 mt7996/mtk_debugfs.c | 63 ++++++++++++++++----------------------------
16 1 file changed, 22 insertions(+), 41 deletions(-)
17
18diff --git a/mt7996/mtk_debugfs.c b/mt7996/mtk_debugfs.c
developer1f55fcf2024-10-17 14:52:33 +080019index 06fa83b..9d8c194 100644
developer05f3b2b2024-08-19 19:17:34 +080020--- a/mt7996/mtk_debugfs.c
21+++ b/mt7996/mtk_debugfs.c
22@@ -210,28 +210,35 @@ DEFINE_SHOW_ATTRIBUTE(mt7996_agginfo);
23 /* AMSDU INFO */
24 static int mt7996_amsdu_result_read(struct seq_file *s, void *data)
25 {
26-#define HW_MSDU_CNT_ADDR 0xf400
27-#define HW_MSDU_NUM_MAX 33
28 struct mt7996_dev *dev = dev_get_drvdata(s->private);
29- u32 ple_stat[HW_MSDU_NUM_MAX] = {0}, total_amsdu = 0;
30- u8 i;
31+ struct mt7996_phy *phy = &dev->phy;
32+ struct mt76_mib_stats *mib = &phy->mib;
33+ static u32 tx_amsdu_last[MT76_MAX_AMSDU_NUM] = {0};
34+ static u32 tx_amsdu_cnt_last = 0;
35+ u32 tx_amsdu, tx_amsdu_cnt, ratio;
36+ int i;
37
38- for (i = 0; i < HW_MSDU_NUM_MAX; i++)
39- ple_stat[i] = mt76_rr(dev, HW_MSDU_CNT_ADDR + i * 0x04);
40+ mutex_lock(&dev->mt76.mutex);
41
42- seq_printf(s, "TXD counter status of MSDU:\n");
43+ mt7996_mac_update_stats(phy);
44
45- for (i = 0; i < HW_MSDU_NUM_MAX; i++)
46- total_amsdu += ple_stat[i];
47+ tx_amsdu_cnt = mib->tx_amsdu_cnt - tx_amsdu_cnt_last;
48
49- for (i = 0; i < HW_MSDU_NUM_MAX; i++) {
50- seq_printf(s, "AMSDU pack count of %d MSDU in TXD: 0x%x ", i, ple_stat[i]);
51- if (total_amsdu != 0)
52- seq_printf(s, "(%d%%)\n", ple_stat[i] * 100 / total_amsdu);
53- else
54- seq_printf(s, "\n");
55+ seq_puts(s, "Tx MSDU statistics:\n");
56+ for (i = 0; i < ARRAY_SIZE(mib->tx_amsdu); i++) {
57+ tx_amsdu = mib->tx_amsdu[i] - tx_amsdu_last[i];
58+ ratio = tx_amsdu_cnt ? tx_amsdu * 100 / tx_amsdu_cnt : 0;
59+
60+ seq_printf(s, "AMSDU pack count of %d MSDU in TXD: %8d (%3d%%)\n",
61+ i + 1, tx_amsdu, ratio);
62+
63+ tx_amsdu_last[i] = mib->tx_amsdu[i];
64 }
65
66+ tx_amsdu_cnt_last = mib->tx_amsdu_cnt;
67+
68+ mutex_unlock(&dev->mt76.mutex);
69+
70 return 0;
71 }
72
developerd0c89452024-10-11 16:53:27 +080073@@ -3341,30 +3348,6 @@ static const struct file_operations fops_amsdu_para = {
developer05f3b2b2024-08-19 19:17:34 +080074 .llseek = default_llseek,
75 };
76
77-static int mt7996_hw_amsdu_info_read(struct seq_file *s, void *data)
78-{
79- struct mt7996_dev *dev = dev_get_drvdata(s->private);
80- u32 amsdu_cnt[WF_PLE_TOP_AMSDU_PACK_NUM] = {0}, total_cnt;
81- u8 i;
82-
83- seq_printf(s, "HW A-MSDU Information:\n");
84-
85- for (total_cnt = 0, i = 0; i < WF_PLE_TOP_AMSDU_PACK_NUM; ++i) {
86- amsdu_cnt[i] = mt76_rr(dev, WF_PLE_TOP_AMSDU_PACK_1_MSDU_CNT_ADDR + i * 4);
87- total_cnt += amsdu_cnt[i];
88- }
89-
90- for (i = 0; i < WF_PLE_TOP_AMSDU_PACK_NUM; ++i) {
91- seq_printf(s, "# of HW A-MSDU containing %hhu MSDU: 0x%x",
92- i + 1, amsdu_cnt[i]);
93- seq_printf(s, "\t(%u.%u%%)\n",
94- total_cnt ? amsdu_cnt[i] * 1000 / total_cnt / 10 : 0,
95- total_cnt ? amsdu_cnt[i] * 1000 / total_cnt % 10 : 0);
96- }
97-
98- return 0;
99-}
100-
101 /* PSE INFO */
102 static struct bmac_queue_info_t pse_queue_empty_info[] = {
103 {"CPU Q0", ENUM_UMAC_CPU_PORT_1, ENUM_UMAC_CTX_Q_0},
developerd0c89452024-10-11 16:53:27 +0800104@@ -4304,8 +4287,6 @@ void mt7996_mtk_init_dev_debugfs(struct mt7996_dev *dev, struct dentry *dir)
developer05f3b2b2024-08-19 19:17:34 +0800105 /* amsdu */
106 debugfs_create_file("amsdu_algo", 0600, dir, dev, &fops_amsdu_algo);
107 debugfs_create_file("amsdu_para", 0600, dir, dev, &fops_amsdu_para);
108- debugfs_create_devm_seqfile(dev->mt76.dev, "hw_amsdu_info", dir,
109- mt7996_hw_amsdu_info_read);
110 }
111
112 #endif
113--
developerd0c89452024-10-11 16:53:27 +08001142.45.2
developer05f3b2b2024-08-19 19:17:34 +0800115