mt76: unify channel survey update code

Host time is used to calculate the channel active time on mt7603 and mt7615.
Use the same on mt76x02 and move the lock to core code to get rid of some
duplicated code.

Signed-off-by: Felix Fietkau <[email protected]>
This commit is contained in:
Felix Fietkau
2019-09-26 14:59:06 +02:00
parent fdf0163fd1
commit de118bb403
8 changed files with 33 additions and 52 deletions
+14 -2
View File
@@ -416,13 +416,25 @@ mt76_channel_state(struct mt76_dev *dev, struct ieee80211_channel *c)
void mt76_update_survey(struct mt76_dev *dev)
{
struct mt76_channel_state *state;
struct mt76_channel_state *state = dev->chan_state;
ktime_t cur_time;
if (!test_bit(MT76_STATE_RUNNING, &dev->state))
return;
spin_lock_bh(&dev->cc_lock);
if (dev->drv->update_survey)
dev->drv->update_survey(dev);
cur_time = ktime_get_boottime();
state->cc_active += ktime_to_us(ktime_sub(cur_time,
dev->survey_time));
dev->survey_time = cur_time;
spin_unlock_bh(&dev->cc_lock);
if (dev->drv->drv_flags & MT_DRV_SW_RX_AIRTIME) {
state = mt76_channel_state(dev, dev->chandef.chan);
spin_lock_bh(&dev->rx_lock);
spin_lock(&dev->cc_lock);
state->cc_bss_rx += dev->cur_cc_bss_rx;