Commit 890809ca authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau

mt76: mt7921: introduce mt7921_mcu_set_beacon_filter utility routine

Introduce mt7921_mcu_set_beacon_filter utility routine in order to
remove duplicated code for hw beacon filtering.
Move mt7921_pm_interface_iter in debugfs since it is just used there.
Make the following routine static:
- mt7921_pm_interface_iter
- mt7921_mcu_uni_bss_bcnft
- mt7921_mcu_set_bss_pm
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent b3036310
...@@ -229,30 +229,38 @@ mt7921_txpwr(struct seq_file *s, void *data) ...@@ -229,30 +229,38 @@ mt7921_txpwr(struct seq_file *s, void *data)
return 0; return 0;
} }
static void
mt7921_pm_interface_iter(void *priv, u8 *mac, struct ieee80211_vif *vif)
{
struct mt7921_dev *dev = priv;
mt7921_mcu_set_beacon_filter(dev, vif, dev->pm.enable);
}
static int static int
mt7921_pm_set(void *data, u64 val) mt7921_pm_set(void *data, u64 val)
{ {
struct mt7921_dev *dev = data; struct mt7921_dev *dev = data;
struct mt76_connac_pm *pm = &dev->pm; struct mt76_connac_pm *pm = &dev->pm;
struct mt76_phy *mphy = dev->phy.mt76;
if (val == pm->enable)
return 0;
mt7921_mutex_acquire(dev); mt7921_mutex_acquire(dev);
if (val == pm->enable)
goto out;
if (!pm->enable) { if (!pm->enable) {
pm->stats.last_wake_event = jiffies; pm->stats.last_wake_event = jiffies;
pm->stats.last_doze_event = jiffies; pm->stats.last_doze_event = jiffies;
} }
pm->enable = val; pm->enable = val;
ieee80211_iterate_active_interfaces(mphy->hw, ieee80211_iterate_active_interfaces(mt76_hw(dev),
IEEE80211_IFACE_ITER_RESUME_ALL, IEEE80211_IFACE_ITER_RESUME_ALL,
mt7921_pm_interface_iter, mphy->priv); mt7921_pm_interface_iter, dev);
mt76_connac_mcu_set_deep_sleep(&dev->mt76, pm->ds_enable); mt76_connac_mcu_set_deep_sleep(&dev->mt76, pm->ds_enable);
out:
mt7921_mutex_release(dev); mt7921_mutex_release(dev);
return 0; return 0;
......
...@@ -526,36 +526,6 @@ static void mt7921_configure_filter(struct ieee80211_hw *hw, ...@@ -526,36 +526,6 @@ static void mt7921_configure_filter(struct ieee80211_hw *hw,
mt7921_mutex_release(dev); mt7921_mutex_release(dev);
} }
static int
mt7921_bss_bcnft_apply(struct mt7921_dev *dev, struct ieee80211_vif *vif,
bool assoc)
{
int ret;
if (!dev->pm.enable)
return 0;
if (assoc) {
ret = mt7921_mcu_uni_bss_bcnft(dev, vif, true);
if (ret)
return ret;
vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER;
mt76_set(dev, MT_WF_RFCR(0), MT_WF_RFCR_DROP_OTHER_BEACON);
return 0;
}
ret = mt7921_mcu_set_bss_pm(dev, vif, false);
if (ret)
return ret;
vif->driver_flags &= ~IEEE80211_VIF_BEACON_FILTER;
mt76_clear(dev, MT_WF_RFCR(0), MT_WF_RFCR_DROP_OTHER_BEACON);
return 0;
}
static void mt7921_bss_info_changed(struct ieee80211_hw *hw, static void mt7921_bss_info_changed(struct ieee80211_hw *hw,
struct ieee80211_vif *vif, struct ieee80211_vif *vif,
struct ieee80211_bss_conf *info, struct ieee80211_bss_conf *info,
...@@ -585,7 +555,8 @@ static void mt7921_bss_info_changed(struct ieee80211_hw *hw, ...@@ -585,7 +555,8 @@ static void mt7921_bss_info_changed(struct ieee80211_hw *hw,
if (changed & BSS_CHANGED_ASSOC) { if (changed & BSS_CHANGED_ASSOC) {
mt7921_mcu_sta_update(dev, NULL, vif, true, mt7921_mcu_sta_update(dev, NULL, vif, true,
MT76_STA_INFO_STATE_ASSOC); MT76_STA_INFO_STATE_ASSOC);
mt7921_bss_bcnft_apply(dev, vif, info->assoc); if (dev->pm.enable)
mt7921_mcu_set_beacon_filter(dev, vif, info->assoc);
} }
if (changed & BSS_CHANGED_ARP_FILTER) { if (changed & BSS_CHANGED_ARP_FILTER) {
......
...@@ -1259,7 +1259,8 @@ int mt7921_mcu_uni_bss_ps(struct mt7921_dev *dev, struct ieee80211_vif *vif) ...@@ -1259,7 +1259,8 @@ int mt7921_mcu_uni_bss_ps(struct mt7921_dev *dev, struct ieee80211_vif *vif)
&ps_req, sizeof(ps_req), true); &ps_req, sizeof(ps_req), true);
} }
int mt7921_mcu_uni_bss_bcnft(struct mt7921_dev *dev, struct ieee80211_vif *vif, static int
mt7921_mcu_uni_bss_bcnft(struct mt7921_dev *dev, struct ieee80211_vif *vif,
bool enable) bool enable)
{ {
struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv; struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
...@@ -1294,7 +1295,8 @@ int mt7921_mcu_uni_bss_bcnft(struct mt7921_dev *dev, struct ieee80211_vif *vif, ...@@ -1294,7 +1295,8 @@ int mt7921_mcu_uni_bss_bcnft(struct mt7921_dev *dev, struct ieee80211_vif *vif,
&bcnft_req, sizeof(bcnft_req), true); &bcnft_req, sizeof(bcnft_req), true);
} }
int mt7921_mcu_set_bss_pm(struct mt7921_dev *dev, struct ieee80211_vif *vif, static int
mt7921_mcu_set_bss_pm(struct mt7921_dev *dev, struct ieee80211_vif *vif,
bool enable) bool enable)
{ {
struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv; struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
...@@ -1444,31 +1446,34 @@ int mt7921_mcu_fw_pmctrl(struct mt7921_dev *dev) ...@@ -1444,31 +1446,34 @@ int mt7921_mcu_fw_pmctrl(struct mt7921_dev *dev)
return err; return err;
} }
void int mt7921_mcu_set_beacon_filter(struct mt7921_dev *dev,
mt7921_pm_interface_iter(void *priv, u8 *mac, struct ieee80211_vif *vif) struct ieee80211_vif *vif,
bool enable)
{ {
struct mt7921_phy *phy = priv;
struct mt7921_dev *dev = phy->dev;
struct ieee80211_hw *hw = mt76_hw(dev); struct ieee80211_hw *hw = mt76_hw(dev);
int ret; int err;
if (dev->pm.enable)
ret = mt7921_mcu_uni_bss_bcnft(dev, vif, true);
else
ret = mt7921_mcu_set_bss_pm(dev, vif, false);
if (ret) if (enable) {
return; err = mt7921_mcu_uni_bss_bcnft(dev, vif, true);
if (err)
return err;
if (dev->pm.enable) {
vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER; vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER;
ieee80211_hw_set(hw, CONNECTION_MONITOR); ieee80211_hw_set(hw, CONNECTION_MONITOR);
mt76_set(dev, MT_WF_RFCR(0), MT_WF_RFCR_DROP_OTHER_BEACON); mt76_set(dev, MT_WF_RFCR(0), MT_WF_RFCR_DROP_OTHER_BEACON);
} else {
return 0;
}
err = mt7921_mcu_set_bss_pm(dev, vif, false);
if (err)
return err;
vif->driver_flags &= ~IEEE80211_VIF_BEACON_FILTER; vif->driver_flags &= ~IEEE80211_VIF_BEACON_FILTER;
__clear_bit(IEEE80211_HW_CONNECTION_MONITOR, hw->flags); __clear_bit(IEEE80211_HW_CONNECTION_MONITOR, hw->flags);
mt76_clear(dev, MT_WF_RFCR(0), MT_WF_RFCR_DROP_OTHER_BEACON); mt76_clear(dev, MT_WF_RFCR(0), MT_WF_RFCR_DROP_OTHER_BEACON);
}
return 0;
} }
int mt7921_get_txpwr_info(struct mt7921_dev *dev, struct mt7921_txpwr *txpwr) int mt7921_get_txpwr_info(struct mt7921_dev *dev, struct mt7921_txpwr *txpwr)
......
...@@ -362,6 +362,9 @@ void mt7921_set_stream_he_caps(struct mt7921_phy *phy); ...@@ -362,6 +362,9 @@ void mt7921_set_stream_he_caps(struct mt7921_phy *phy);
void mt7921_update_channel(struct mt76_phy *mphy); 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_set_beacon_filter(struct mt7921_dev *dev,
struct ieee80211_vif *vif,
bool enable);
int mt7921_mcu_uni_tx_ba(struct mt7921_dev *dev, int mt7921_mcu_uni_tx_ba(struct mt7921_dev *dev,
struct ieee80211_ampdu_params *params, struct ieee80211_ampdu_params *params,
bool enable); bool enable);
...@@ -370,17 +373,12 @@ int mt7921_mcu_uni_rx_ba(struct mt7921_dev *dev, ...@@ -370,17 +373,12 @@ int mt7921_mcu_uni_rx_ba(struct mt7921_dev *dev,
bool enable); bool enable);
void mt7921_scan_work(struct work_struct *work); void mt7921_scan_work(struct work_struct *work);
int mt7921_mcu_uni_bss_ps(struct mt7921_dev *dev, struct ieee80211_vif *vif); int mt7921_mcu_uni_bss_ps(struct mt7921_dev *dev, struct ieee80211_vif *vif);
int mt7921_mcu_uni_bss_bcnft(struct mt7921_dev *dev, struct ieee80211_vif *vif,
bool enable);
int mt7921_mcu_set_bss_pm(struct mt7921_dev *dev, struct ieee80211_vif *vif,
bool enable);
int __mt7921_mcu_drv_pmctrl(struct mt7921_dev *dev); int __mt7921_mcu_drv_pmctrl(struct mt7921_dev *dev);
int mt7921_mcu_drv_pmctrl(struct mt7921_dev *dev); int mt7921_mcu_drv_pmctrl(struct mt7921_dev *dev);
int mt7921_mcu_fw_pmctrl(struct mt7921_dev *dev); int mt7921_mcu_fw_pmctrl(struct mt7921_dev *dev);
void mt7921_pm_wake_work(struct work_struct *work); void mt7921_pm_wake_work(struct work_struct *work);
void mt7921_pm_power_save_work(struct work_struct *work); void mt7921_pm_power_save_work(struct work_struct *work);
bool mt7921_wait_for_mcu_init(struct mt7921_dev *dev); bool mt7921_wait_for_mcu_init(struct mt7921_dev *dev);
void mt7921_pm_interface_iter(void *priv, u8 *mac, struct ieee80211_vif *vif);
void mt7921_coredump_work(struct work_struct *work); void mt7921_coredump_work(struct work_struct *work);
int mt7921_wfsys_reset(struct mt7921_dev *dev); int mt7921_wfsys_reset(struct mt7921_dev *dev);
int mt7921_get_txpwr_info(struct mt7921_dev *dev, struct mt7921_txpwr *txpwr); int mt7921_get_txpwr_info(struct mt7921_dev *dev, struct mt7921_txpwr *txpwr);
......
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