developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 1 | From aff4c26706fa1403abca8067cd0073db88c9f6cf Mon Sep 17 00:00:00 2001 |
| 2 | From: Peter Chiu <chui-hao.chiu@mediatek.com> |
| 3 | Date: Fri, 17 May 2024 15:28:06 +0800 |
| 4 | Subject: [PATCH 011/199] mtk: mt76: mt7996: fix amsdu information |
| 5 | |
| 6 | The amsdu information is common information for all bands so maintain |
| 7 | it by main phy instead of calculating by each phy. |
| 8 | Without this patch, the statistics of tx_amsdu_cnt and tx_amsdu would |
| 9 | be incorrect. |
| 10 | |
| 11 | Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com> |
| 12 | --- |
| 13 | mt76.h | 3 ++- |
| 14 | mt7996/debugfs.c | 13 ------------- |
| 15 | mt7996/mac.c | 15 +++++++++------ |
| 16 | 3 files changed, 11 insertions(+), 20 deletions(-) |
| 17 | |
| 18 | diff --git a/mt76.h b/mt76.h |
| 19 | index 5c9d6c64..45039377 100644 |
| 20 | --- a/mt76.h |
| 21 | +++ b/mt76.h |
| 22 | @@ -916,6 +916,7 @@ struct mt76_dev { |
| 23 | }; |
| 24 | }; |
| 25 | |
| 26 | +#define MT76_MAX_AMSDU_NUM 8 |
| 27 | /* per-phy stats. */ |
| 28 | struct mt76_mib_stats { |
| 29 | u32 ack_fail_cnt; |
| 30 | @@ -975,7 +976,7 @@ struct mt76_mib_stats { |
| 31 | u32 rx_vec_queue_overflow_drop_cnt; |
| 32 | u32 rx_ba_cnt; |
| 33 | |
| 34 | - u32 tx_amsdu[8]; |
| 35 | + u32 tx_amsdu[MT76_MAX_AMSDU_NUM]; |
| 36 | u32 tx_amsdu_cnt; |
| 37 | |
| 38 | /* mcu_muru_stats */ |
| 39 | diff --git a/mt7996/debugfs.c b/mt7996/debugfs.c |
| 40 | index 62c03d08..a17c99a2 100644 |
| 41 | --- a/mt7996/debugfs.c |
| 42 | +++ b/mt7996/debugfs.c |
| 43 | @@ -530,7 +530,6 @@ mt7996_tx_stats_show(struct seq_file *file, void *data) |
| 44 | struct mt7996_phy *phy = file->private; |
| 45 | struct mt7996_dev *dev = phy->dev; |
| 46 | struct mt76_mib_stats *mib = &phy->mib; |
| 47 | - int i; |
| 48 | u32 attempts, success, per; |
| 49 | |
| 50 | mutex_lock(&dev->mt76.mutex); |
| 51 | @@ -547,18 +546,6 @@ mt7996_tx_stats_show(struct seq_file *file, void *data) |
| 52 | |
| 53 | mt7996_txbf_stat_read_phy(phy, file); |
| 54 | |
| 55 | - /* Tx amsdu info */ |
| 56 | - seq_puts(file, "Tx MSDU statistics:\n"); |
| 57 | - for (i = 0; i < ARRAY_SIZE(mib->tx_amsdu); i++) { |
| 58 | - seq_printf(file, "AMSDU pack count of %d MSDU in TXD: %8d ", |
| 59 | - i + 1, mib->tx_amsdu[i]); |
| 60 | - if (mib->tx_amsdu_cnt) |
| 61 | - seq_printf(file, "(%3d%%)\n", |
| 62 | - mib->tx_amsdu[i] * 100 / mib->tx_amsdu_cnt); |
| 63 | - else |
| 64 | - seq_puts(file, "\n"); |
| 65 | - } |
| 66 | - |
| 67 | mutex_unlock(&dev->mt76.mutex); |
| 68 | |
| 69 | return 0; |
| 70 | diff --git a/mt7996/mac.c b/mt7996/mac.c |
| 71 | index 109a74a9..503e92c0 100644 |
| 72 | --- a/mt7996/mac.c |
| 73 | +++ b/mt7996/mac.c |
| 74 | @@ -2103,10 +2103,19 @@ void mt7996_mac_update_stats(struct mt7996_phy *phy) |
| 75 | { |
| 76 | struct mt76_mib_stats *mib = &phy->mib; |
| 77 | struct mt7996_dev *dev = phy->dev; |
| 78 | + struct mt76_mib_stats *main_mib = &dev->phy.mib; |
| 79 | u8 band_idx = phy->mt76->band_idx; |
| 80 | u32 cnt; |
| 81 | int i; |
| 82 | |
| 83 | + /* Update per-dev structures */ |
| 84 | + for (i = 0; i < ARRAY_SIZE(main_mib->tx_amsdu); i++) { |
| 85 | + cnt = mt76_rr(dev, MT_PLE_AMSDU_PACK_MSDU_CNT(i)); |
| 86 | + main_mib->tx_amsdu[i] += cnt; |
| 87 | + main_mib->tx_amsdu_cnt += cnt; |
| 88 | + } |
| 89 | + |
| 90 | + /* Update per-phy structures */ |
| 91 | cnt = mt76_rr(dev, MT_MIB_RSCR1(band_idx)); |
| 92 | mib->fcs_err_cnt += cnt; |
| 93 | |
| 94 | @@ -2212,12 +2221,6 @@ void mt7996_mac_update_stats(struct mt7996_phy *phy) |
| 95 | cnt = mt76_rr(dev, MT_MIB_BSCR17(band_idx)); |
| 96 | mib->tx_bf_fb_cpl_cnt += cnt; |
| 97 | |
| 98 | - for (i = 0; i < ARRAY_SIZE(mib->tx_amsdu); i++) { |
| 99 | - cnt = mt76_rr(dev, MT_PLE_AMSDU_PACK_MSDU_CNT(i)); |
| 100 | - mib->tx_amsdu[i] += cnt; |
| 101 | - mib->tx_amsdu_cnt += cnt; |
| 102 | - } |
| 103 | - |
| 104 | /* rts count */ |
| 105 | cnt = mt76_rr(dev, MT_MIB_BTSCR5(band_idx)); |
| 106 | mib->rts_cnt += cnt; |
| 107 | -- |
| 108 | 2.18.0 |
| 109 | |