developer | ad9333b | 2023-05-22 15:16:16 +0800 | [diff] [blame^] | 1 | From 629de725ea7db82076de9c1d23e84b24c64dc64b Mon Sep 17 00:00:00 2001 |
developer | 5eddc51 | 2023-02-13 16:01:56 +0800 | [diff] [blame] | 2 | From: Peter Chiu <chui-hao.chiu@mediatek.com> |
| 3 | Date: Mon, 30 Jan 2023 11:36:32 +0800 |
developer | ad9333b | 2023-05-22 15:16:16 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 3010/3012] wifi: mt76: update debugfs knob for reset counter |
developer | 5eddc51 | 2023-02-13 16:01:56 +0800 | [diff] [blame] | 5 | and get tx packet error rate |
| 6 | |
| 7 | --- |
| 8 | mt7915/mtk_debugfs.c | 62 ++++++++++++++++++++++++++++++++++++++++++++ |
| 9 | 1 file changed, 62 insertions(+) |
| 10 | |
| 11 | diff --git a/mt7915/mtk_debugfs.c b/mt7915/mtk_debugfs.c |
developer | ad9333b | 2023-05-22 15:16:16 +0800 | [diff] [blame^] | 12 | index 361b50c..f896e53 100644 |
developer | 5eddc51 | 2023-02-13 16:01:56 +0800 | [diff] [blame] | 13 | --- a/mt7915/mtk_debugfs.c |
| 14 | +++ b/mt7915/mtk_debugfs.c |
developer | ad9333b | 2023-05-22 15:16:16 +0800 | [diff] [blame^] | 15 | @@ -3790,6 +3790,66 @@ mt7915_sw_aci_set(void *data, u64 val) |
developer | 5eddc51 | 2023-02-13 16:01:56 +0800 | [diff] [blame] | 16 | 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; |
developer | ad9333b | 2023-05-22 15:16:16 +0800 | [diff] [blame^] | 82 | @@ -3881,6 +3941,8 @@ int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir) |
developer | 5eddc51 | 2023-02-13 16:01:56 +0800 | [diff] [blame] | 83 | 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 | -- |
developer | a43cc48 | 2023-04-17 15:57:28 +0800 | [diff] [blame] | 92 | 2.18.0 |
developer | 5eddc51 | 2023-02-13 16:01:56 +0800 | [diff] [blame] | 93 | |