Commit c560b137 authored by Ryder Lee's avatar Ryder Lee Committed by Felix Fietkau
Browse files

mt76: make mt76_update_survey() per phy



Reduce duplicated survey for DBDC.

Signed-off-by: default avatarRyder Lee <ryder.lee@mediatek.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 0d733327
Loading
Loading
Loading
Loading
+7 −8
Original line number Diff line number Diff line
@@ -659,20 +659,19 @@ void mt76_update_survey_active_time(struct mt76_phy *phy, ktime_t time)
}
EXPORT_SYMBOL_GPL(mt76_update_survey_active_time);

void mt76_update_survey(struct mt76_dev *dev)
void mt76_update_survey(struct mt76_phy *phy)
{
	struct mt76_dev *dev = phy->dev;
	ktime_t cur_time;

	if (dev->drv->update_survey)
		dev->drv->update_survey(dev);
		dev->drv->update_survey(phy);

	cur_time = ktime_get_boottime();
	mt76_update_survey_active_time(&dev->phy, cur_time);
	if (dev->phy2)
		mt76_update_survey_active_time(dev->phy2, cur_time);
	mt76_update_survey_active_time(phy, cur_time);

	if (dev->drv->drv_flags & MT_DRV_SW_RX_AIRTIME) {
		struct mt76_channel_state *state = dev->phy.chan_state;
		struct mt76_channel_state *state = phy->chan_state;

		spin_lock_bh(&dev->cc_lock);
		state->cc_bss_rx += dev->cur_cc_bss_rx;
@@ -691,7 +690,7 @@ void mt76_set_channel(struct mt76_phy *phy)
	int timeout = HZ / 5;

	wait_event_timeout(dev->tx_wait, !mt76_has_tx_pending(phy), timeout);
	mt76_update_survey(dev);
	mt76_update_survey(phy);

	phy->chandef = *chandef;
	phy->chan_state = mt76_channel_state(phy, chandef->chan);
@@ -716,7 +715,7 @@ int mt76_get_survey(struct ieee80211_hw *hw, int idx,

	mutex_lock(&dev->mutex);
	if (idx == 0 && dev->drv->update_survey)
		mt76_update_survey(dev);
		mt76_update_survey(phy);

	sband = &phy->sband_2g;
	if (idx >= sband->sband.n_channels) {
+2 −2
Original line number Diff line number Diff line
@@ -337,7 +337,7 @@ struct mt76_driver_ops {
	u16 token_size;
	u8 mcs_rates;

	void (*update_survey)(struct mt76_dev *dev);
	void (*update_survey)(struct mt76_phy *phy);

	int (*tx_prepare_skb)(struct mt76_dev *dev, void *txwi_ptr,
			      enum mt76_txq_id qid, struct mt76_wcid *wcid,
@@ -1047,7 +1047,7 @@ void mt76_release_buffered_frames(struct ieee80211_hw *hw,
				  bool more_data);
bool mt76_has_tx_pending(struct mt76_phy *phy);
void mt76_set_channel(struct mt76_phy *phy);
void mt76_update_survey(struct mt76_dev *dev);
void mt76_update_survey(struct mt76_phy *phy);
void mt76_update_survey_active_time(struct mt76_phy *phy, ktime_t time);
int mt76_get_survey(struct ieee80211_hw *hw, int idx,
		    struct survey_info *survey);
+4 −4
Original line number Diff line number Diff line
@@ -1584,12 +1584,12 @@ mt7603_watchdog_check(struct mt7603_dev *dev, u8 *counter,
	return true;
}

void mt7603_update_channel(struct mt76_dev *mdev)
void mt7603_update_channel(struct mt76_phy *mphy)
{
	struct mt7603_dev *dev = container_of(mdev, struct mt7603_dev, mt76);
	struct mt7603_dev *dev = container_of(mphy->dev, struct mt7603_dev, mt76);
	struct mt76_channel_state *state;

	state = mdev->phy.chan_state;
	state = mphy->chan_state;
	state->cc_busy += mt76_rr(dev, MT_MIB_STAT_CCA);
}

@@ -1806,7 +1806,7 @@ void mt7603_mac_work(struct work_struct *work)
	mutex_lock(&dev->mt76.mutex);

	dev->mphy.mac_work_count++;
	mt76_update_survey(&dev->mt76);
	mt76_update_survey(&dev->mphy);
	mt7603_edcca_check(dev);

	for (i = 0, idx = 0; i < 2; i++) {
+1 −1
Original line number Diff line number Diff line
@@ -256,7 +256,7 @@ void mt7603_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,

void mt7603_pre_tbtt_tasklet(struct tasklet_struct *t);

void mt7603_update_channel(struct mt76_dev *mdev);
void mt7603_update_channel(struct mt76_phy *mphy);

void mt7603_edcca_set_strict(struct mt7603_dev *dev, bool val);
void mt7603_cca_stats_reset(struct mt7603_dev *dev);
+15 −17
Original line number Diff line number Diff line
@@ -1819,43 +1819,41 @@ mt7615_phy_update_channel(struct mt76_phy *mphy, int idx)
	state->noise = -(phy->noise >> 4);
}

static void __mt7615_update_channel(struct mt7615_dev *dev)
static void mt7615_update_survey(struct mt7615_dev *dev)
{
	struct mt76_dev *mdev = &dev->mt76;
	ktime_t cur_time;

	/* MT7615 can only update both phys simultaneously
	 * since some reisters are shared across bands.
	 */

	mt7615_phy_update_channel(&mdev->phy, 0);
	if (mdev->phy2)
		mt7615_phy_update_channel(mdev->phy2, 1);

	cur_time = ktime_get_boottime();

	mt76_update_survey_active_time(&mdev->phy, cur_time);
	if (mdev->phy2)
		mt76_update_survey_active_time(mdev->phy2, cur_time);

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

void mt7615_update_channel(struct mt76_dev *mdev)
void mt7615_update_channel(struct mt76_phy *mphy)
{
	struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76);
	struct mt7615_dev *dev = container_of(mphy->dev, struct mt7615_dev, mt76);

	if (mt76_connac_pm_wake(&dev->mphy, &dev->pm))
		return;

	__mt7615_update_channel(dev);
	mt7615_update_survey(dev);
	mt76_connac_power_save_sched(&dev->mphy, &dev->pm);
}
EXPORT_SYMBOL_GPL(mt7615_update_channel);

static void mt7615_update_survey(struct mt7615_dev *dev)
{
	struct mt76_dev *mdev = &dev->mt76;
	ktime_t cur_time;

	__mt7615_update_channel(dev);
	cur_time = ktime_get_boottime();

	mt76_update_survey_active_time(&mdev->phy, cur_time);
	if (mdev->phy2)
		mt76_update_survey_active_time(mdev->phy2, cur_time);
}

static void
mt7615_mac_update_mib_stats(struct mt7615_phy *phy)
{
Loading