blob: a05b8ca5a2e81a7b78e24c53fc05c59459f5b2ed [file] [log] [blame]
developer05f3b2b2024-08-19 19:17:34 +08001From 48926fde96602e41c02879d7a020f4b24d332f75 Mon Sep 17 00:00:00 2001
2From: Peter Chiu <chui-hao.chiu@mediatek.com>
3Date: Fri, 17 May 2024 17:34:03 +0800
4Subject: [PATCH 137/199] mtk: mt76: mt7996: refactor amsdu debugfs
5
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
12Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
13---
14 mt7996/mtk_debugfs.c | 63 ++++++++++++++++----------------------------
15 1 file changed, 22 insertions(+), 41 deletions(-)
16
17diff --git a/mt7996/mtk_debugfs.c b/mt7996/mtk_debugfs.c
18index 59c6db73..a7cbde3e 100644
19--- a/mt7996/mtk_debugfs.c
20+++ b/mt7996/mtk_debugfs.c
21@@ -210,28 +210,35 @@ DEFINE_SHOW_ATTRIBUTE(mt7996_agginfo);
22 /* AMSDU INFO */
23 static int mt7996_amsdu_result_read(struct seq_file *s, void *data)
24 {
25-#define HW_MSDU_CNT_ADDR 0xf400
26-#define HW_MSDU_NUM_MAX 33
27 struct mt7996_dev *dev = dev_get_drvdata(s->private);
28- u32 ple_stat[HW_MSDU_NUM_MAX] = {0}, total_amsdu = 0;
29- u8 i;
30+ struct mt7996_phy *phy = &dev->phy;
31+ struct mt76_mib_stats *mib = &phy->mib;
32+ static u32 tx_amsdu_last[MT76_MAX_AMSDU_NUM] = {0};
33+ static u32 tx_amsdu_cnt_last = 0;
34+ u32 tx_amsdu, tx_amsdu_cnt, ratio;
35+ int i;
36
37- for (i = 0; i < HW_MSDU_NUM_MAX; i++)
38- ple_stat[i] = mt76_rr(dev, HW_MSDU_CNT_ADDR + i * 0x04);
39+ mutex_lock(&dev->mt76.mutex);
40
41- seq_printf(s, "TXD counter status of MSDU:\n");
42+ mt7996_mac_update_stats(phy);
43
44- for (i = 0; i < HW_MSDU_NUM_MAX; i++)
45- total_amsdu += ple_stat[i];
46+ tx_amsdu_cnt = mib->tx_amsdu_cnt - tx_amsdu_cnt_last;
47
48- for (i = 0; i < HW_MSDU_NUM_MAX; i++) {
49- seq_printf(s, "AMSDU pack count of %d MSDU in TXD: 0x%x ", i, ple_stat[i]);
50- if (total_amsdu != 0)
51- seq_printf(s, "(%d%%)\n", ple_stat[i] * 100 / total_amsdu);
52- else
53- seq_printf(s, "\n");
54+ seq_puts(s, "Tx MSDU statistics:\n");
55+ for (i = 0; i < ARRAY_SIZE(mib->tx_amsdu); i++) {
56+ tx_amsdu = mib->tx_amsdu[i] - tx_amsdu_last[i];
57+ ratio = tx_amsdu_cnt ? tx_amsdu * 100 / tx_amsdu_cnt : 0;
58+
59+ seq_printf(s, "AMSDU pack count of %d MSDU in TXD: %8d (%3d%%)\n",
60+ i + 1, tx_amsdu, ratio);
61+
62+ tx_amsdu_last[i] = mib->tx_amsdu[i];
63 }
64
65+ tx_amsdu_cnt_last = mib->tx_amsdu_cnt;
66+
67+ mutex_unlock(&dev->mt76.mutex);
68+
69 return 0;
70 }
71
72@@ -3342,30 +3349,6 @@ static const struct file_operations fops_amsdu_para = {
73 .llseek = default_llseek,
74 };
75
76-static int mt7996_hw_amsdu_info_read(struct seq_file *s, void *data)
77-{
78- struct mt7996_dev *dev = dev_get_drvdata(s->private);
79- u32 amsdu_cnt[WF_PLE_TOP_AMSDU_PACK_NUM] = {0}, total_cnt;
80- u8 i;
81-
82- seq_printf(s, "HW A-MSDU Information:\n");
83-
84- for (total_cnt = 0, i = 0; i < WF_PLE_TOP_AMSDU_PACK_NUM; ++i) {
85- amsdu_cnt[i] = mt76_rr(dev, WF_PLE_TOP_AMSDU_PACK_1_MSDU_CNT_ADDR + i * 4);
86- total_cnt += amsdu_cnt[i];
87- }
88-
89- for (i = 0; i < WF_PLE_TOP_AMSDU_PACK_NUM; ++i) {
90- seq_printf(s, "# of HW A-MSDU containing %hhu MSDU: 0x%x",
91- i + 1, amsdu_cnt[i]);
92- seq_printf(s, "\t(%u.%u%%)\n",
93- total_cnt ? amsdu_cnt[i] * 1000 / total_cnt / 10 : 0,
94- total_cnt ? amsdu_cnt[i] * 1000 / total_cnt % 10 : 0);
95- }
96-
97- return 0;
98-}
99-
100 /* PSE INFO */
101 static struct bmac_queue_info_t pse_queue_empty_info[] = {
102 {"CPU Q0", ENUM_UMAC_CPU_PORT_1, ENUM_UMAC_CTX_Q_0},
103@@ -4305,8 +4288,6 @@ void mt7996_mtk_init_dev_debugfs(struct mt7996_dev *dev, struct dentry *dir)
104 /* amsdu */
105 debugfs_create_file("amsdu_algo", 0600, dir, dev, &fops_amsdu_algo);
106 debugfs_create_file("amsdu_para", 0600, dir, dev, &fops_amsdu_para);
107- debugfs_create_devm_seqfile(dev->mt76.dev, "hw_amsdu_info", dir,
108- mt7996_hw_amsdu_info_read);
109 }
110
111 #endif
112--
1132.18.0
114