mt76: mt7921: move tx amsdu stats in mib_stats
authorLorenzo Bianconi <lorenzo@kernel.org>
Tue, 19 Oct 2021 10:12:31 +0000 (12:12 +0200)
committerFelix Fietkau <nbd@nbd.name>
Wed, 20 Oct 2021 08:37:03 +0000 (10:37 +0200)
Move tx_amsdu histogram stats in mib_stats structure since registers are
clear-on-read

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c
drivers/net/wireless/mediatek/mt76/mt7921/mac.c
drivers/net/wireless/mediatek/mt76/mt7921/main.c
drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h

index 68f393c..7cdfdf8 100644 (file)
@@ -95,30 +95,27 @@ static int
 mt7921_tx_stats_show(struct seq_file *file, void *data)
 {
        struct mt7921_dev *dev = file->private;
-       int stat[8], i, n;
+       struct mt7921_phy *phy = &dev->phy;
+       struct mib_stats *mib = &phy->mib;
+       int i;
 
        mt7921_mutex_acquire(dev);
 
-       mt7921_ampdu_stat_read_phy(&dev->phy, file);
+       mt7921_ampdu_stat_read_phy(phy, file);
 
-       /* Tx amsdu info */
        seq_puts(file, "Tx MSDU stat:\n");
-       for (i = 0, n = 0; i < ARRAY_SIZE(stat); i++) {
-               stat[i] = mt76_rr(dev,  MT_PLE_AMSDU_PACK_MSDU_CNT(i));
-               n += stat[i];
-       }
-
-       mt7921_mutex_release(dev);
-
-       for (i = 0; i < ARRAY_SIZE(stat); i++) {
-               seq_printf(file, "AMSDU pack count of %d MSDU in TXD: 0x%x ",
-                          i + 1, stat[i]);
-               if (n != 0)
-                       seq_printf(file, "(%d%%)\n", stat[i] * 100 / n);
+       for (i = 0; i < ARRAY_SIZE(mib->tx_amsdu); i++) {
+               seq_printf(file, "AMSDU pack count of %d MSDU in TXD: %8d ",
+                          i + 1, mib->tx_amsdu[i]);
+               if (mib->tx_amsdu_cnt)
+                       seq_printf(file, "(%3d%%)\n",
+                                  mib->tx_amsdu[i] * 100 / mib->tx_amsdu_cnt);
                else
                        seq_puts(file, "\n");
        }
 
+       mt7921_mutex_release(dev);
+
        return 0;
 }
 
index d45c54f..db3302b 100644 (file)
@@ -1375,6 +1375,12 @@ void mt7921_mac_update_mib_stats(struct mt7921_phy *phy)
        mib->rx_ampdu_bytes_cnt += mt76_rr(dev, MT_MIB_SDR23(0));
        mib->rx_ba_cnt += mt76_rr(dev, MT_MIB_SDR31(0));
 
+       for (i = 0; i < ARRAY_SIZE(mib->tx_amsdu); i++) {
+               val = mt76_rr(dev, MT_PLE_AMSDU_PACK_MSDU_CNT(i));
+               mib->tx_amsdu[i] += val;
+               mib->tx_amsdu_cnt += val;
+       }
+
        for (i = 0, aggr1 = aggr0 + 4; i < 4; i++) {
                u32 val2;
 
index bd49cfd..575f23d 100644 (file)
@@ -958,8 +958,8 @@ void mt7921_get_et_stats(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
        data[ei++] = mib->tx_bf_rx_fb_ht_cnt;
 
        /* Tx amsdu info (pack-count histogram) */
-       for (i = 0; i < 8; i++)
-               data[ei++] = mt76_rr(dev,  MT_PLE_AMSDU_PACK_MSDU_CNT(i));
+       for (i = 0; i < ARRAY_SIZE(mib->tx_amsdu); i++)
+               data[ei++] = mib->tx_amsdu[i];
 
        /* rx counters */
        data[ei++] = mib->rx_mpdu_cnt;
index 9347859..e9c7c3a 100644 (file)
@@ -148,6 +148,9 @@ struct mib_stats {
        u32 rx_ampdu_cnt;
        u32 rx_ampdu_bytes_cnt;
        u32 rx_ba_cnt;
+
+       u32 tx_amsdu[8];
+       u32 tx_amsdu_cnt;
 };
 
 struct mt7921_phy {