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

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
...@@ -659,20 +659,19 @@ void mt76_update_survey_active_time(struct mt76_phy *phy, ktime_t time) ...@@ -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); 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; ktime_t cur_time;
if (dev->drv->update_survey) if (dev->drv->update_survey)
dev->drv->update_survey(dev); dev->drv->update_survey(phy);
cur_time = ktime_get_boottime(); cur_time = ktime_get_boottime();
mt76_update_survey_active_time(&dev->phy, cur_time); mt76_update_survey_active_time(phy, cur_time);
if (dev->phy2)
mt76_update_survey_active_time(dev->phy2, cur_time);
if (dev->drv->drv_flags & MT_DRV_SW_RX_AIRTIME) { 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); spin_lock_bh(&dev->cc_lock);
state->cc_bss_rx += dev->cur_cc_bss_rx; state->cc_bss_rx += dev->cur_cc_bss_rx;
...@@ -691,7 +690,7 @@ void mt76_set_channel(struct mt76_phy *phy) ...@@ -691,7 +690,7 @@ void mt76_set_channel(struct mt76_phy *phy)
int timeout = HZ / 5; int timeout = HZ / 5;
wait_event_timeout(dev->tx_wait, !mt76_has_tx_pending(phy), timeout); wait_event_timeout(dev->tx_wait, !mt76_has_tx_pending(phy), timeout);
mt76_update_survey(dev); mt76_update_survey(phy);
phy->chandef = *chandef; phy->chandef = *chandef;
phy->chan_state = mt76_channel_state(phy, chandef->chan); phy->chan_state = mt76_channel_state(phy, chandef->chan);
...@@ -716,7 +715,7 @@ int mt76_get_survey(struct ieee80211_hw *hw, int idx, ...@@ -716,7 +715,7 @@ int mt76_get_survey(struct ieee80211_hw *hw, int idx,
mutex_lock(&dev->mutex); mutex_lock(&dev->mutex);
if (idx == 0 && dev->drv->update_survey) if (idx == 0 && dev->drv->update_survey)
mt76_update_survey(dev); mt76_update_survey(phy);
sband = &phy->sband_2g; sband = &phy->sband_2g;
if (idx >= sband->sband.n_channels) { if (idx >= sband->sband.n_channels) {
......
...@@ -337,7 +337,7 @@ struct mt76_driver_ops { ...@@ -337,7 +337,7 @@ struct mt76_driver_ops {
u16 token_size; u16 token_size;
u8 mcs_rates; 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, int (*tx_prepare_skb)(struct mt76_dev *dev, void *txwi_ptr,
enum mt76_txq_id qid, struct mt76_wcid *wcid, enum mt76_txq_id qid, struct mt76_wcid *wcid,
...@@ -1047,7 +1047,7 @@ void mt76_release_buffered_frames(struct ieee80211_hw *hw, ...@@ -1047,7 +1047,7 @@ void mt76_release_buffered_frames(struct ieee80211_hw *hw,
bool more_data); bool more_data);
bool mt76_has_tx_pending(struct mt76_phy *phy); bool mt76_has_tx_pending(struct mt76_phy *phy);
void mt76_set_channel(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); void mt76_update_survey_active_time(struct mt76_phy *phy, ktime_t time);
int mt76_get_survey(struct ieee80211_hw *hw, int idx, int mt76_get_survey(struct ieee80211_hw *hw, int idx,
struct survey_info *survey); struct survey_info *survey);
......
...@@ -1584,12 +1584,12 @@ mt7603_watchdog_check(struct mt7603_dev *dev, u8 *counter, ...@@ -1584,12 +1584,12 @@ mt7603_watchdog_check(struct mt7603_dev *dev, u8 *counter,
return true; 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; struct mt76_channel_state *state;
state = mdev->phy.chan_state; state = mphy->chan_state;
state->cc_busy += mt76_rr(dev, MT_MIB_STAT_CCA); state->cc_busy += mt76_rr(dev, MT_MIB_STAT_CCA);
} }
...@@ -1806,7 +1806,7 @@ void mt7603_mac_work(struct work_struct *work) ...@@ -1806,7 +1806,7 @@ void mt7603_mac_work(struct work_struct *work)
mutex_lock(&dev->mt76.mutex); mutex_lock(&dev->mt76.mutex);
dev->mphy.mac_work_count++; dev->mphy.mac_work_count++;
mt76_update_survey(&dev->mt76); mt76_update_survey(&dev->mphy);
mt7603_edcca_check(dev); mt7603_edcca_check(dev);
for (i = 0, idx = 0; i < 2; i++) { for (i = 0, idx = 0; i < 2; i++) {
......
...@@ -256,7 +256,7 @@ void mt7603_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif, ...@@ -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_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_edcca_set_strict(struct mt7603_dev *dev, bool val);
void mt7603_cca_stats_reset(struct mt7603_dev *dev); void mt7603_cca_stats_reset(struct mt7603_dev *dev);
......
...@@ -1819,43 +1819,41 @@ mt7615_phy_update_channel(struct mt76_phy *mphy, int idx) ...@@ -1819,43 +1819,41 @@ mt7615_phy_update_channel(struct mt76_phy *mphy, int idx)
state->noise = -(phy->noise >> 4); 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; 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); mt7615_phy_update_channel(&mdev->phy, 0);
if (mdev->phy2) if (mdev->phy2)
mt7615_phy_update_channel(mdev->phy2, 1); 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 */ /* reset obss airtime */
mt76_set(dev, MT_WF_RMAC_MIB_TIME0, MT_WF_RMAC_MIB_RXTIME_CLR); 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)) if (mt76_connac_pm_wake(&dev->mphy, &dev->pm))
return; return;
__mt7615_update_channel(dev); mt7615_update_survey(dev);
mt76_connac_power_save_sched(&dev->mphy, &dev->pm); mt76_connac_power_save_sched(&dev->mphy, &dev->pm);
} }
EXPORT_SYMBOL_GPL(mt7615_update_channel); 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 static void
mt7615_mac_update_mib_stats(struct mt7615_phy *phy) mt7615_mac_update_mib_stats(struct mt7615_phy *phy)
{ {
......
...@@ -471,7 +471,7 @@ int mt7615_set_channel(struct mt7615_phy *phy); ...@@ -471,7 +471,7 @@ int mt7615_set_channel(struct mt7615_phy *phy);
void mt7615_init_work(struct mt7615_dev *dev); void mt7615_init_work(struct mt7615_dev *dev);
int mt7615_mcu_restart(struct mt76_dev *dev); int mt7615_mcu_restart(struct mt76_dev *dev);
void mt7615_update_channel(struct mt76_dev *mdev); void mt7615_update_channel(struct mt76_phy *mphy);
bool mt7615_mac_wtbl_update(struct mt7615_dev *dev, int idx, u32 mask); bool mt7615_mac_wtbl_update(struct mt7615_dev *dev, int idx, u32 mask);
void mt7615_mac_reset_counters(struct mt7615_dev *dev); void mt7615_mac_reset_counters(struct mt7615_dev *dev);
void mt7615_mac_cca_stats_reset(struct mt7615_phy *phy); void mt7615_mac_cca_stats_reset(struct mt7615_phy *phy);
......
...@@ -1022,12 +1022,12 @@ void mt76x02_mac_set_tx_protection(struct mt76x02_dev *dev, bool legacy_prot, ...@@ -1022,12 +1022,12 @@ void mt76x02_mac_set_tx_protection(struct mt76x02_dev *dev, bool legacy_prot,
mt76_wr(dev, MT_TX_PROT_CFG6 + i * 4, vht_prot[i]); mt76_wr(dev, MT_TX_PROT_CFG6 + i * 4, vht_prot[i]);
} }
void mt76x02_update_channel(struct mt76_dev *mdev) void mt76x02_update_channel(struct mt76_phy *mphy)
{ {
struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76); struct mt76x02_dev *dev = container_of(mphy->dev, struct mt76x02_dev, mt76);
struct mt76_channel_state *state; struct mt76_channel_state *state;
state = mdev->phy.chan_state; state = mphy->chan_state;
state->cc_busy += mt76_rr(dev, MT_CH_BUSY); state->cc_busy += mt76_rr(dev, MT_CH_BUSY);
spin_lock_bh(&dev->mt76.cc_lock); spin_lock_bh(&dev->mt76.cc_lock);
...@@ -1169,7 +1169,7 @@ void mt76x02_mac_work(struct work_struct *work) ...@@ -1169,7 +1169,7 @@ void mt76x02_mac_work(struct work_struct *work)
mutex_lock(&dev->mt76.mutex); mutex_lock(&dev->mt76.mutex);
mt76_update_survey(&dev->mt76); mt76_update_survey(&dev->mphy);
for (i = 0, idx = 0; i < 16; i++) { for (i = 0, idx = 0; i < 16; i++) {
u32 val = mt76_rr(dev, MT_TX_AGG_CNT(i)); u32 val = mt76_rr(dev, MT_TX_AGG_CNT(i));
......
...@@ -195,7 +195,7 @@ void mt76x02_mac_write_txwi(struct mt76x02_dev *dev, struct mt76x02_txwi *txwi, ...@@ -195,7 +195,7 @@ void mt76x02_mac_write_txwi(struct mt76x02_dev *dev, struct mt76x02_txwi *txwi,
struct ieee80211_sta *sta, int len); struct ieee80211_sta *sta, int len);
void mt76x02_mac_poll_tx_status(struct mt76x02_dev *dev, bool irq); void mt76x02_mac_poll_tx_status(struct mt76x02_dev *dev, bool irq);
void mt76x02_tx_complete_skb(struct mt76_dev *mdev, struct mt76_queue_entry *e); void mt76x02_tx_complete_skb(struct mt76_dev *mdev, struct mt76_queue_entry *e);
void mt76x02_update_channel(struct mt76_dev *mdev); void mt76x02_update_channel(struct mt76_phy *mphy);
void mt76x02_mac_work(struct work_struct *work); void mt76x02_mac_work(struct work_struct *work);
void mt76x02_mac_cc_reset(struct mt76x02_dev *dev); void mt76x02_mac_cc_reset(struct mt76x02_dev *dev);
......
...@@ -1471,16 +1471,16 @@ mt7915_phy_get_nf(struct mt7915_phy *phy, int idx) ...@@ -1471,16 +1471,16 @@ mt7915_phy_get_nf(struct mt7915_phy *phy, int idx)
return sum / n; return sum / n;
} }
static void void mt7915_update_channel(struct mt76_phy *mphy)
mt7915_phy_update_channel(struct mt76_phy *mphy, int idx)
{ {
struct mt7915_phy *phy = (struct mt7915_phy *)mphy->priv; struct mt7915_phy *phy = (struct mt7915_phy *)mphy->priv;
struct mt76_channel_state *state = mphy->chan_state; struct mt76_channel_state *state = mphy->chan_state;
bool ext_phy = phy != &phy->dev->phy;
int nf; int nf;
mt7915_mcu_get_chan_mib_info(phy, false); mt7915_mcu_get_chan_mib_info(phy, false);
nf = mt7915_phy_get_nf(phy, idx); nf = mt7915_phy_get_nf(phy, ext_phy);
if (!phy->noise) if (!phy->noise)
phy->noise = nf << 4; phy->noise = nf << 4;
else if (nf) else if (nf)
...@@ -1489,13 +1489,6 @@ mt7915_phy_update_channel(struct mt76_phy *mphy, int idx) ...@@ -1489,13 +1489,6 @@ mt7915_phy_update_channel(struct mt76_phy *mphy, int idx)
state->noise = -(phy->noise >> 4); state->noise = -(phy->noise >> 4);
} }
void mt7915_update_channel(struct mt76_dev *mdev)
{
mt7915_phy_update_channel(&mdev->phy, 0);
if (mdev->phy2)
mt7915_phy_update_channel(mdev->phy2, 1);
}
static bool static bool
mt7915_wait_reset_state(struct mt7915_dev *dev, u32 state) mt7915_wait_reset_state(struct mt7915_dev *dev, u32 state)
{ {
...@@ -1804,7 +1797,7 @@ void mt7915_mac_work(struct work_struct *work) ...@@ -1804,7 +1797,7 @@ void mt7915_mac_work(struct work_struct *work)
mutex_lock(&mphy->dev->mutex); mutex_lock(&mphy->dev->mutex);
mt76_update_survey(mphy->dev); mt76_update_survey(mphy);
if (++mphy->mac_work_count == 5) { if (++mphy->mac_work_count == 5) {
mphy->mac_work_count = 0; mphy->mac_work_count = 0;
......
...@@ -436,7 +436,7 @@ int mt76_dfs_start_rdd(struct mt7915_dev *dev, bool force); ...@@ -436,7 +436,7 @@ int mt76_dfs_start_rdd(struct mt7915_dev *dev, bool force);
int mt7915_dfs_init_radar_detector(struct mt7915_phy *phy); int mt7915_dfs_init_radar_detector(struct mt7915_phy *phy);
void mt7915_set_stream_he_caps(struct mt7915_phy *phy); void mt7915_set_stream_he_caps(struct mt7915_phy *phy);
void mt7915_set_stream_vht_txbf_caps(struct mt7915_phy *phy); void mt7915_set_stream_vht_txbf_caps(struct mt7915_phy *phy);
void mt7915_update_channel(struct mt76_dev *mdev); void mt7915_update_channel(struct mt76_phy *mphy);
int mt7915_init_debugfs(struct mt7915_dev *dev); int mt7915_init_debugfs(struct mt7915_dev *dev);
#ifdef CONFIG_MAC80211_DEBUGFS #ifdef CONFIG_MAC80211_DEBUGFS
void mt7915_sta_add_debugfs(struct ieee80211_hw *hw, struct ieee80211_vif *vif, void mt7915_sta_add_debugfs(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
......
...@@ -1227,18 +1227,18 @@ mt7921_phy_update_channel(struct mt76_phy *mphy, int idx) ...@@ -1227,18 +1227,18 @@ mt7921_phy_update_channel(struct mt76_phy *mphy, int idx)
state->noise = -(phy->noise >> 4); state->noise = -(phy->noise >> 4);
} }
void mt7921_update_channel(struct mt76_dev *mdev) void mt7921_update_channel(struct mt76_phy *mphy)
{ {
struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76); struct mt7921_dev *dev = container_of(mphy->dev, struct mt7921_dev, mt76);
if (mt76_connac_pm_wake(&dev->mphy, &dev->pm)) if (mt76_connac_pm_wake(mphy, &dev->pm))
return; return;
mt7921_phy_update_channel(&mdev->phy, 0); mt7921_phy_update_channel(mphy, 0);
/* reset obss airtime */ /* reset obss airtime */
mt76_set(dev, MT_WF_RMAC_MIB_TIME0(0), MT_WF_RMAC_MIB_RXTIME_CLR); mt76_set(dev, MT_WF_RMAC_MIB_TIME0(0), MT_WF_RMAC_MIB_RXTIME_CLR);
mt76_connac_power_save_sched(&dev->mphy, &dev->pm); mt76_connac_power_save_sched(mphy, &dev->pm);
} }
void mt7921_tx_token_put(struct mt7921_dev *dev) void mt7921_tx_token_put(struct mt7921_dev *dev)
...@@ -1436,7 +1436,7 @@ void mt7921_mac_work(struct work_struct *work) ...@@ -1436,7 +1436,7 @@ void mt7921_mac_work(struct work_struct *work)
mt7921_mutex_acquire(phy->dev); mt7921_mutex_acquire(phy->dev);
mt76_update_survey(mphy->dev); mt76_update_survey(mphy);
if (++mphy->mac_work_count == 2) { if (++mphy->mac_work_count == 2) {
mphy->mac_work_count = 0; mphy->mac_work_count = 0;
......
...@@ -356,7 +356,7 @@ void mt7921_stats_work(struct work_struct *work); ...@@ -356,7 +356,7 @@ void mt7921_stats_work(struct work_struct *work);
void mt7921_txp_skb_unmap(struct mt76_dev *dev, void mt7921_txp_skb_unmap(struct mt76_dev *dev,
struct mt76_txwi_cache *txwi); struct mt76_txwi_cache *txwi);
void mt7921_set_stream_he_caps(struct mt7921_phy *phy); void mt7921_set_stream_he_caps(struct mt7921_phy *phy);
void mt7921_update_channel(struct mt76_dev *mdev); void mt7921_update_channel(struct mt76_phy *mphy);
int mt7921_init_debugfs(struct mt7921_dev *dev); int mt7921_init_debugfs(struct mt7921_dev *dev);
int mt7921_mcu_uni_tx_ba(struct mt7921_dev *dev, int mt7921_mcu_uni_tx_ba(struct mt7921_dev *dev,
......
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