From: Ben Greear <greearb@xxxxxxxxxxxxxxx> These counters are clear-on-read, so we need to accumulate them in the update_stats poll logic, and read the accumulated values instead of directly doing register reads when reporting to debugfs and ethtool stats. Signed-off-by: Ben Greear <greearb@xxxxxxxxxxxxxxx> --- .../wireless/mediatek/mt76/mt7915/debugfs.c | 33 ++++++++----------- .../net/wireless/mediatek/mt76/mt7915/mac.c | 13 +++++++- .../wireless/mediatek/mt76/mt7915/mt7915.h | 4 +++ 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c index 61a57c86cbdb..9dce4a0e7a5c 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c @@ -152,6 +152,7 @@ mt7915_txbf_stat_read_phy(struct mt7915_phy *phy, struct seq_file *s) "BW20", "BW40", "BW80", "BW160" }; int cnt; + struct mib_stats *mib = &phy->mib; if (!phy) return; @@ -187,15 +188,13 @@ mt7915_txbf_stat_read_phy(struct mt7915_phy *phy, struct seq_file *s) FIELD_GET(MT_ETBF_TX_FB_TRI, cnt)); /* Tx SU & MU counters */ - cnt = mt76_rr(dev, MT_MIB_SDR34(ext_phy)); - seq_printf(s, "Tx multi-user Beamforming counts: %ld\n", - FIELD_GET(MT_MIB_MU_BF_TX_CNT, cnt)); - cnt = mt76_rr(dev, MT_MIB_DR8(ext_phy)); - seq_printf(s, "Tx multi-user MPDU counts: %d\n", cnt); - cnt = mt76_rr(dev, MT_MIB_DR9(ext_phy)); - seq_printf(s, "Tx multi-user successful MPDU counts: %d\n", cnt); - cnt = mt76_rr(dev, MT_MIB_DR11(ext_phy)); - seq_printf(s, "Tx single-user successful MPDU counts: %d\n", cnt); + seq_printf(s, "Tx multi-user Beamforming counts: %d\n", + mib->tx_bf_cnt); + seq_printf(s, "Tx multi-user MPDU counts: %d\n", mib->tx_mu_mpdu_cnt); + seq_printf(s, "Tx multi-user successful MPDU counts: %d\n", + mib->tx_mu_successful_mpdu_cnt); + seq_printf(s, "Tx single-user successful MPDU counts: %d\n", + mib->tx_su_successful_mpdu_cnt); seq_puts(s, "\n"); } @@ -488,6 +487,7 @@ void mt7915_debug_get_et_stats(struct ieee80211_hw *hw, struct mt7915_sta *msta; struct mt7915_sta_stats *mstats; bool found_sta = false; + struct mib_stats *mib = &phy->mib; /* See mt7915_ampdu_stat_read_phy, etc */ bool ext_phy = phy != &dev->phy; @@ -527,17 +527,10 @@ void mt7915_debug_get_et_stats(struct ieee80211_hw *hw, data[ei++] = FIELD_GET(MT_ETBF_TX_FB_TRI, cnt); /* Tx SU & MU counters */ - cnt = mt76_rr(dev, MT_MIB_SDR34(ext_phy)); - data[ei++] = FIELD_GET(MT_MIB_MU_BF_TX_CNT, cnt); - - cnt = mt76_rr(dev, MT_MIB_DR8(ext_phy)); - data[ei++] = cnt; - - cnt = mt76_rr(dev, MT_MIB_DR9(ext_phy)); - data[ei++] = cnt; /* MU MPDU SUccessful */ - - cnt = mt76_rr(dev, MT_MIB_DR11(ext_phy)); - data[ei++] = cnt; /* SU MPDU successful */ + data[ei++] = mib->tx_bf_cnt; + data[ei++] = mib->tx_mu_mpdu_cnt; + data[ei++] = mib->tx_mu_successful_mpdu_cnt; + data[ei++] = mib->tx_su_successful_mpdu_cnt; /* TODO: External phy too?? */ diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index 585f67daec8e..53e8347ef75b 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -1880,10 +1880,21 @@ mt7915_mac_update_stats(struct mt7915_phy *phy) struct mt7915_dev *dev = phy->dev; struct mib_stats *mib = &phy->mib; bool ext_phy = phy != &dev->phy; - int i, aggr0, aggr1; + int i, aggr0, aggr1, cnt; mib->fcs_err_cnt += mt76_get_field(dev, MT_MIB_SDR3(ext_phy), MT_MIB_SDR3_FCS_ERR_MASK); + cnt = mt76_rr(dev, MT_MIB_SDR34(ext_phy)); + mib->tx_bf_cnt += FIELD_GET(MT_MIB_MU_BF_TX_CNT, cnt); + + cnt = mt76_rr(dev, MT_MIB_DR8(ext_phy)); + mib->tx_mu_mpdu_cnt += cnt; + + cnt = mt76_rr(dev, MT_MIB_DR9(ext_phy)); + mib->tx_mu_successful_mpdu_cnt += cnt; + + cnt = mt76_rr(dev, MT_MIB_DR11(ext_phy)); + mib->tx_su_successful_mpdu_cnt += cnt; aggr0 = ext_phy ? ARRAY_SIZE(dev->mt76.aggr_stats) / 2 : 0; for (i = 0, aggr1 = aggr0 + 4; i < 4; i++) { diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h index ff944d1cf527..c5d0f2331b6f 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h @@ -116,6 +116,10 @@ struct mib_stats { u32 rts_cnt; u32 rts_retries_cnt; u32 ba_miss_cnt; + u32 tx_bf_cnt; + u32 tx_mu_mpdu_cnt; + u32 tx_mu_successful_mpdu_cnt; + u32 tx_su_successful_mpdu_cnt; /* Add more stats here, updated from mac_update_stats */ }; -- 2.20.1