blob: 238dab3efcfff693030cc88d44f4dadabfcc46f4 [file] [log] [blame]
developerd0c89452024-10-11 16:53:27 +08001From afaacba412a34baf39e58b27003d4d09516a15c2 Mon Sep 17 00:00:00 2001
developer05f3b2b2024-08-19 19:17:34 +08002From: Peter Chiu <chui-hao.chiu@mediatek.com>
3Date: Fri, 17 May 2024 15:28:06 +0800
developerd0c89452024-10-11 16:53:27 +08004Subject: [PATCH 002/223] mtk: mt76: mt7996: fix amsdu information
developer05f3b2b2024-08-19 19:17:34 +08005
6The amsdu information is common information for all bands so maintain
7it by main phy instead of calculating by each phy.
8Without this patch, the statistics of tx_amsdu_cnt and tx_amsdu would
9be incorrect.
10
developerd0c89452024-10-11 16:53:27 +080011Change-Id: Iac324d9dd63ceb3a55b51c0210e3e547e20a71cb
developer05f3b2b2024-08-19 19:17:34 +080012Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
13---
14 mt76.h | 3 ++-
15 mt7996/debugfs.c | 13 -------------
16 mt7996/mac.c | 15 +++++++++------
17 3 files changed, 11 insertions(+), 20 deletions(-)
18
19diff --git a/mt76.h b/mt76.h
developerd0c89452024-10-11 16:53:27 +080020index 19c4f11c..063c45d2 100644
developer05f3b2b2024-08-19 19:17:34 +080021--- a/mt76.h
22+++ b/mt76.h
developerd0c89452024-10-11 16:53:27 +080023@@ -931,6 +931,7 @@ struct mt76_dev {
developer05f3b2b2024-08-19 19:17:34 +080024 };
25 };
26
27+#define MT76_MAX_AMSDU_NUM 8
28 /* per-phy stats. */
29 struct mt76_mib_stats {
30 u32 ack_fail_cnt;
developerd0c89452024-10-11 16:53:27 +080031@@ -990,7 +991,7 @@ struct mt76_mib_stats {
developer05f3b2b2024-08-19 19:17:34 +080032 u32 rx_vec_queue_overflow_drop_cnt;
33 u32 rx_ba_cnt;
34
35- u32 tx_amsdu[8];
36+ u32 tx_amsdu[MT76_MAX_AMSDU_NUM];
37 u32 tx_amsdu_cnt;
38
39 /* mcu_muru_stats */
40diff --git a/mt7996/debugfs.c b/mt7996/debugfs.c
41index 62c03d08..a17c99a2 100644
42--- a/mt7996/debugfs.c
43+++ b/mt7996/debugfs.c
44@@ -530,7 +530,6 @@ mt7996_tx_stats_show(struct seq_file *file, void *data)
45 struct mt7996_phy *phy = file->private;
46 struct mt7996_dev *dev = phy->dev;
47 struct mt76_mib_stats *mib = &phy->mib;
48- int i;
49 u32 attempts, success, per;
50
51 mutex_lock(&dev->mt76.mutex);
52@@ -547,18 +546,6 @@ mt7996_tx_stats_show(struct seq_file *file, void *data)
53
54 mt7996_txbf_stat_read_phy(phy, file);
55
56- /* Tx amsdu info */
57- seq_puts(file, "Tx MSDU statistics:\n");
58- for (i = 0; i < ARRAY_SIZE(mib->tx_amsdu); i++) {
59- seq_printf(file, "AMSDU pack count of %d MSDU in TXD: %8d ",
60- i + 1, mib->tx_amsdu[i]);
61- if (mib->tx_amsdu_cnt)
62- seq_printf(file, "(%3d%%)\n",
63- mib->tx_amsdu[i] * 100 / mib->tx_amsdu_cnt);
64- else
65- seq_puts(file, "\n");
66- }
67-
68 mutex_unlock(&dev->mt76.mutex);
69
70 return 0;
71diff --git a/mt7996/mac.c b/mt7996/mac.c
developerd0c89452024-10-11 16:53:27 +080072index 29297c07..cfcfc3ea 100644
developer05f3b2b2024-08-19 19:17:34 +080073--- a/mt7996/mac.c
74+++ b/mt7996/mac.c
developerd0c89452024-10-11 16:53:27 +080075@@ -2114,10 +2114,19 @@ void mt7996_mac_update_stats(struct mt7996_phy *phy)
developer05f3b2b2024-08-19 19:17:34 +080076 {
77 struct mt76_mib_stats *mib = &phy->mib;
78 struct mt7996_dev *dev = phy->dev;
79+ struct mt76_mib_stats *main_mib = &dev->phy.mib;
80 u8 band_idx = phy->mt76->band_idx;
81 u32 cnt;
82 int i;
83
84+ /* Update per-dev structures */
85+ for (i = 0; i < ARRAY_SIZE(main_mib->tx_amsdu); i++) {
86+ cnt = mt76_rr(dev, MT_PLE_AMSDU_PACK_MSDU_CNT(i));
87+ main_mib->tx_amsdu[i] += cnt;
88+ main_mib->tx_amsdu_cnt += cnt;
89+ }
90+
91+ /* Update per-phy structures */
92 cnt = mt76_rr(dev, MT_MIB_RSCR1(band_idx));
93 mib->fcs_err_cnt += cnt;
94
developerd0c89452024-10-11 16:53:27 +080095@@ -2223,12 +2232,6 @@ void mt7996_mac_update_stats(struct mt7996_phy *phy)
developer05f3b2b2024-08-19 19:17:34 +080096 cnt = mt76_rr(dev, MT_MIB_BSCR17(band_idx));
97 mib->tx_bf_fb_cpl_cnt += cnt;
98
99- for (i = 0; i < ARRAY_SIZE(mib->tx_amsdu); i++) {
100- cnt = mt76_rr(dev, MT_PLE_AMSDU_PACK_MSDU_CNT(i));
101- mib->tx_amsdu[i] += cnt;
102- mib->tx_amsdu_cnt += cnt;
103- }
104-
105 /* rts count */
106 cnt = mt76_rr(dev, MT_MIB_BTSCR5(band_idx));
107 mib->rts_cnt += cnt;
108--
developerd0c89452024-10-11 16:53:27 +08001092.45.2
developer05f3b2b2024-08-19 19:17:34 +0800110