Commit 6bfa6e38 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau
Browse files

mt76: mt7615: report tx_time, bss_rx and busy time to mac80211



Report tx time/rx time and obss time from hw mib counters to fill survey
info requested by mac80211

Co-developed-by: default avatarFelix Fietkau <nbd@nbd.name>
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 355f8d00
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -505,6 +505,7 @@ int mt76_get_survey(struct ieee80211_hw *hw, int idx,
	survey->time = div_u64(state->cc_active, 1000);
	survey->time_busy = div_u64(state->cc_busy, 1000);
	survey->time_bss_rx = div_u64(state->cc_bss_rx, 1000);
	survey->time_rx = div_u64(state->cc_rx, 1000);
	survey->time_tx = div_u64(state->cc_tx, 1000);
	spin_unlock_bh(&dev->cc_lock);

+1 −0
Original line number Diff line number Diff line
@@ -322,6 +322,7 @@ struct mt76_driver_ops {
struct mt76_channel_state {
	u64 cc_active;
	u64 cc_busy;
	u64 cc_rx;
	u64 cc_bss_rx;
	u64 cc_tx;
};
+2 −0
Original line number Diff line number Diff line
@@ -96,6 +96,8 @@ static void mt7615_mac_init(struct mt7615_dev *dev)
	      FIELD_PREP(MT_DMA_RCFR0_RX_DROPPED_MCAST, 2);
	mt76_rmw(dev, MT_DMA_BN0RCFR0, mask, set);
	mt76_rmw(dev, MT_DMA_BN1RCFR0, mask, set);

	mt76_set(dev, MT_WF_RMAC_MIB_TIME0, MT_WF_RMAC_MIB_RXTIME_EN);
}

static int mt7615_init_hardware(struct mt7615_dev *dev)
+24 −2
Original line number Diff line number Diff line
@@ -49,6 +49,14 @@ void mt7615_mac_reset_counters(struct mt7615_dev *dev)
		mt76_rr(dev, MT_TX_AGG_CNT(i));

	memset(dev->mt76.aggr_stats, 0, sizeof(dev->mt76.aggr_stats));

	/* TODO: add DBDC support */

	/* reset airtime counters */
	mt76_rr(dev, MT_MIB_SDR16(0));
	mt76_rr(dev, MT_MIB_SDR36(0));
	mt76_rr(dev, MT_MIB_SDR37(0));
	mt76_set(dev, MT_WF_RMAC_MIB_TIME0, MT_WF_RMAC_MIB_RXTIME_CLR);
}

int mt7615_mac_fill_rx(struct mt7615_dev *dev, struct sk_buff *skb)
@@ -1263,11 +1271,25 @@ void mt7615_update_channel(struct mt76_dev *mdev)
{
	struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76);
	struct mt76_channel_state *state;
	u64 busy_time, tx_time, rx_time, obss_time;

	/* TODO: add DBDC support */
	busy_time = mt76_get_field(dev, MT_MIB_SDR16(0), MT_MIB_BUSY_MASK);
	tx_time = mt76_get_field(dev, MT_MIB_SDR36(0),
				 MT_MIB_SDR36_TXTIME_MASK);
	rx_time = mt76_get_field(dev, MT_MIB_SDR37(0),
				 MT_MIB_SDR37_RXTIME_MASK);
	obss_time = mt76_get_field(dev, MT_WF_RMAC_MIB_TIME5,
				   MT_MIB_OBSSTIME_MASK);

	state = mdev->chan_state;
	state->cc_busy += mt76_get_field(dev, MT_MIB_SDR16(0),
					 MT_MIB_BUSY_MASK);
	state->cc_busy += busy_time;
	state->cc_tx += tx_time;
	state->cc_rx += rx_time + obss_time;
	state->cc_bss_rx += rx_time;

	/* reset obss airtime */
	mt76_set(dev, MT_WF_RMAC_MIB_TIME0, MT_WF_RMAC_MIB_RXTIME_CLR);
}

void mt7615_mac_work(struct work_struct *work)
+2 −2
Original line number Diff line number Diff line
@@ -153,8 +153,8 @@ static int mt7615_set_channel(struct mt7615_dev *dev)
	ret = mt7615_dfs_init_radar_detector(dev);
	mt7615_mac_cca_stats_reset(dev);
	dev->mt76.survey_time = ktime_get_boottime();
	/* TODO: add DBDC support */
	mt76_rr(dev, MT_MIB_SDR16(0));

	mt7615_mac_reset_counters(dev);

out:
	clear_bit(MT76_RESET, &dev->mt76.state);
Loading