blob: e9ab141ec0ac951fc6c293305ddcaae0bc4c9e16 [file] [log] [blame]
developera43cc482023-04-17 15:57:28 +08001From f5a0fb214a18b6b2627c671b16f20bc6a0e03aea Mon Sep 17 00:00:00 2001
developer5eddc512023-02-13 16:01:56 +08002From: Peter Chiu <chui-hao.chiu@mediatek.com>
3Date: Mon, 30 Jan 2023 11:36:32 +0800
developera43cc482023-04-17 15:57:28 +08004Subject: [PATCH 3011/3013] wifi: mt76: update debugfs knob for reset counter
developer5eddc512023-02-13 16:01:56 +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
developera43cc482023-04-17 15:57:28 +080012index b9f4de5..aedd48d 100644
developer5eddc512023-02-13 16:01:56 +080013--- a/mt7915/mtk_debugfs.c
14+++ b/mt7915/mtk_debugfs.c
developera43cc482023-04-17 15:57:28 +080015@@ -3787,6 +3787,66 @@ mt7915_sw_aci_set(void *data, u64 val)
developer5eddc512023-02-13 16:01:56 +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;
developera43cc482023-04-17 15:57:28 +080082@@ -3878,6 +3938,8 @@ int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir)
developer5eddc512023-02-13 16:01:56 +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--
developera43cc482023-04-17 15:57:28 +0800922.18.0
developer5eddc512023-02-13 16:01:56 +080093