Commit 2eb6f6c4 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau

mt76: mt7615: fix mib stats counter reporting to mac80211

In order to properly report MIB counters to mac80211, resets stats in
mt7615_get_stats routine and hold mt76 mutex accessing MIB counters.
Sum up MIB counters in mt7615_mac_update_mib_stats routine.

Fixes: c388d858 ("mt76: mt7615: add a get_stats() callback")
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent d43c7301
...@@ -1873,9 +1873,7 @@ mt7615_mac_update_mib_stats(struct mt7615_phy *phy) ...@@ -1873,9 +1873,7 @@ mt7615_mac_update_mib_stats(struct mt7615_phy *phy)
int i, aggr; int i, aggr;
u32 val, val2; u32 val, val2;
memset(mib, 0, sizeof(*mib)); mib->fcs_err_cnt += mt76_get_field(dev, MT_MIB_SDR3(ext_phy),
mib->fcs_err_cnt = mt76_get_field(dev, MT_MIB_SDR3(ext_phy),
MT_MIB_SDR3_FCS_ERR_MASK); MT_MIB_SDR3_FCS_ERR_MASK);
val = mt76_get_field(dev, MT_MIB_SDR14(ext_phy), val = mt76_get_field(dev, MT_MIB_SDR14(ext_phy),
...@@ -1889,24 +1887,16 @@ mt7615_mac_update_mib_stats(struct mt7615_phy *phy) ...@@ -1889,24 +1887,16 @@ mt7615_mac_update_mib_stats(struct mt7615_phy *phy)
aggr = ext_phy ? ARRAY_SIZE(dev->mt76.aggr_stats) / 2 : 0; aggr = ext_phy ? ARRAY_SIZE(dev->mt76.aggr_stats) / 2 : 0;
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
val = mt76_rr(dev, MT_MIB_MB_SDR1(ext_phy, i)); val = mt76_rr(dev, MT_MIB_MB_SDR1(ext_phy, i));
mib->ba_miss_cnt += FIELD_GET(MT_MIB_BA_MISS_COUNT_MASK, val);
val2 = FIELD_GET(MT_MIB_ACK_FAIL_COUNT_MASK, val); mib->ack_fail_cnt += FIELD_GET(MT_MIB_ACK_FAIL_COUNT_MASK,
if (val2 > mib->ack_fail_cnt) val);
mib->ack_fail_cnt = val2;
val2 = FIELD_GET(MT_MIB_BA_MISS_COUNT_MASK, val);
if (val2 > mib->ba_miss_cnt)
mib->ba_miss_cnt = val2;
val = mt76_rr(dev, MT_MIB_MB_SDR0(ext_phy, i)); val = mt76_rr(dev, MT_MIB_MB_SDR0(ext_phy, i));
val2 = FIELD_GET(MT_MIB_RTS_RETRIES_COUNT_MASK, val); mib->rts_cnt += FIELD_GET(MT_MIB_RTS_COUNT_MASK, val);
if (val2 > mib->rts_retries_cnt) { mib->rts_retries_cnt += FIELD_GET(MT_MIB_RTS_RETRIES_COUNT_MASK,
mib->rts_cnt = FIELD_GET(MT_MIB_RTS_COUNT_MASK, val); val);
mib->rts_retries_cnt = val2;
}
val = mt76_rr(dev, MT_TX_AGG_CNT(ext_phy, i)); val = mt76_rr(dev, MT_TX_AGG_CNT(ext_phy, i));
dev->mt76.aggr_stats[aggr++] += val & 0xffff; dev->mt76.aggr_stats[aggr++] += val & 0xffff;
dev->mt76.aggr_stats[aggr++] += val >> 16; dev->mt76.aggr_stats[aggr++] += val >> 16;
} }
......
...@@ -807,11 +807,17 @@ mt7615_get_stats(struct ieee80211_hw *hw, ...@@ -807,11 +807,17 @@ mt7615_get_stats(struct ieee80211_hw *hw,
struct mt7615_phy *phy = mt7615_hw_phy(hw); struct mt7615_phy *phy = mt7615_hw_phy(hw);
struct mib_stats *mib = &phy->mib; struct mib_stats *mib = &phy->mib;
mt7615_mutex_acquire(phy->dev);
stats->dot11RTSSuccessCount = mib->rts_cnt; stats->dot11RTSSuccessCount = mib->rts_cnt;
stats->dot11RTSFailureCount = mib->rts_retries_cnt; stats->dot11RTSFailureCount = mib->rts_retries_cnt;
stats->dot11FCSErrorCount = mib->fcs_err_cnt; stats->dot11FCSErrorCount = mib->fcs_err_cnt;
stats->dot11ACKFailureCount = mib->ack_fail_cnt; stats->dot11ACKFailureCount = mib->ack_fail_cnt;
memset(mib, 0, sizeof(*mib));
mt7615_mutex_release(phy->dev);
return 0; return 0;
} }
......
...@@ -133,11 +133,11 @@ struct mt7615_vif { ...@@ -133,11 +133,11 @@ struct mt7615_vif {
}; };
struct mib_stats { struct mib_stats {
u16 ack_fail_cnt; u32 ack_fail_cnt;
u16 fcs_err_cnt; u32 fcs_err_cnt;
u16 rts_cnt; u32 rts_cnt;
u16 rts_retries_cnt; u32 rts_retries_cnt;
u16 ba_miss_cnt; u32 ba_miss_cnt;
unsigned long aggr_per; unsigned long aggr_per;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment