blob: 3142884a73ec9dd4ab0f5ab660bbe60daadeae44 [file] [log] [blame]
developerbbd45e12023-05-19 08:22:06 +08001From 629de725ea7db82076de9c1d23e84b24c64dc64b Mon Sep 17 00:00:00 2001
developer33554a22023-01-30 14:11:29 +08002From: Peter Chiu <chui-hao.chiu@mediatek.com>
3Date: Mon, 30 Jan 2023 11:36:32 +0800
developerbbd45e12023-05-19 08:22:06 +08004Subject: [PATCH 3010/3012] wifi: mt76: update debugfs knob for reset counter
developer33554a22023-01-30 14:11:29 +08005 and get tx packet error rate
6
7---
8 mt7915/mtk_debugfs.c | 62 ++++++++++++++++++++++++++++++++++++++++++++
9 1 file changed, 62 insertions(+)
10
11diff --git a/mt7915/mtk_debugfs.c b/mt7915/mtk_debugfs.c
developerbbd45e12023-05-19 08:22:06 +080012index 361b50c..f896e53 100644
developer33554a22023-01-30 14:11:29 +080013--- a/mt7915/mtk_debugfs.c
14+++ b/mt7915/mtk_debugfs.c
developerbbd45e12023-05-19 08:22:06 +080015@@ -3790,6 +3790,66 @@ mt7915_sw_aci_set(void *data, u64 val)
developer33554a22023-01-30 14:11:29 +080016 DEFINE_DEBUGFS_ATTRIBUTE(fops_sw_aci, NULL,
17 mt7915_sw_aci_set, "%llx\n");
18
19+static int mt7915_reset_counter(void *data, u64 val)
20+{
21+ struct mt7915_phy *phy = data;
22+ struct mt7915_dev *dev = phy->dev;
23+ struct mt76_wcid *wcid;
24+
25+ /* Clear the firmware counters */
26+ mt7915_mcu_get_tx_stat_wa(dev, dev->wlan_idx);
27+ mt7915_get_tx_stat(phy, dev->wlan_idx);
28+
29+ rcu_read_lock();
30+ wcid = rcu_dereference(dev->mt76.wcid[dev->wlan_idx]);
31+ if (!wcid)
32+ return -EINVAL;
33+
34+ memset(&wcid->stats, 0, sizeof(struct mt76_sta_stats));
35+
36+ rcu_read_unlock();
37+
38+ return 0;
39+}
40+
41+DEFINE_DEBUGFS_ATTRIBUTE(fops_reset_counter, NULL,
42+ mt7915_reset_counter, "%lld\n");
43+
44+static int
45+mt7915_per_read(struct seq_file *s, void *data)
46+{
47+ struct mt7915_dev *dev = dev_get_drvdata(s->private);
48+ struct mt76_sta_stats *stats;
49+ struct mt76_wcid *wcid;
50+ int ret;
51+ u8 phy_idx;
52+
53+ if (!dev->mt76.wcid[dev->wlan_idx])
54+ return -EINVAL;
55+
56+ phy_idx = dev->mt76.wcid[dev->wlan_idx]->phy_idx;
57+
58+ ret = mt7915_get_tx_stat(dev->mt76.phys[phy_idx]->priv, dev->wlan_idx);
59+ if (ret)
60+ return ret;
61+
62+ rcu_read_lock();
63+ wcid = rcu_dereference(dev->mt76.wcid[dev->wlan_idx]);
64+ if (!wcid)
65+ return -EINVAL;
66+
67+ stats = &wcid->stats;
68+
69+ seq_printf(s, "sta %d, tx_mpdu_cnt = %u, tx_failed = %u, PER = %u.%u%%\n", dev->wlan_idx,
70+ stats->tx_mpdu_cnt, stats->tx_failed,
71+ stats->tx_mpdu_cnt ? stats->tx_failed * 1000 / stats->tx_mpdu_cnt / 10 : 0,
72+ stats->tx_mpdu_cnt ? stats->tx_failed * 1000 / stats->tx_mpdu_cnt % 10 : 0);
73+
74+ rcu_read_unlock();
75+
76+ return 0;
77+}
78+
79 int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir)
80 {
81 struct mt7915_dev *dev = phy->dev;
developerbbd45e12023-05-19 08:22:06 +080082@@ -3881,6 +3941,8 @@ int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir)
developer33554a22023-01-30 14:11:29 +080083 mt7915_show_eeprom_mode);
84 debugfs_create_file("sw_aci", 0600, dir, dev,
85 &fops_sw_aci);
86+ debugfs_create_file("reset_counter", 0200, dir, dev, &fops_reset_counter);
87+ debugfs_create_devm_seqfile(dev->mt76.dev, "per", dir, mt7915_per_read);
88 return 0;
89 }
90 #endif
91--
developer2324aa22023-04-12 11:30:15 +0800922.18.0
developer33554a22023-01-30 14:11:29 +080093