developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 1 | From e7b50308230e874028c65233d5e2f7a7d1ad6479 Mon Sep 17 00:00:00 2001 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 2 | From: Peter Chiu <chui-hao.chiu@mediatek.com> |
| 3 | Date: Fri, 17 May 2024 17:34:03 +0800 |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 125/223] mtk: mt76: mt7996: refactor amsdu debugfs |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 5 | |
| 6 | 1. Remove hw_amsdu_info which is duplicated with amsdu_info. |
| 7 | |
| 8 | 2. 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 | |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 12 | Change-Id: Ie83e861f32fa7ede075916f2393df51e39bebbad |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 13 | Signed-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 | |
| 18 | diff --git a/mt7996/mtk_debugfs.c b/mt7996/mtk_debugfs.c |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 19 | index 06fa83bb..9d8c1942 100644 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 20 | --- 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 | |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 73 | @@ -3341,30 +3348,6 @@ static const struct file_operations fops_amsdu_para = { |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 74 | .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}, |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 104 | @@ -4304,8 +4287,6 @@ void mt7996_mtk_init_dev_debugfs(struct mt7996_dev *dev, struct dentry *dir) |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 105 | /* 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 | -- |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 114 | 2.45.2 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 115 | |