Commit 7124198a authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau

mt76: mt7615: enable beacon filtering by default for offload fw

In order to reduce cpu cycles, enable hw beacon filter by default if
the device is running offload fw with sta only interfaces.
Disable runtime pm for multi-vif scenario.
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent ed89b893
...@@ -55,11 +55,26 @@ static int ...@@ -55,11 +55,26 @@ static int
mt7615_pm_set(void *data, u64 val) mt7615_pm_set(void *data, u64 val)
{ {
struct mt7615_dev *dev = data; struct mt7615_dev *dev = data;
int ret = 0;
if (!mt7615_wait_for_mcu_init(dev)) if (!mt7615_wait_for_mcu_init(dev))
return 0; return 0;
return mt7615_pm_set_enable(dev, val); if (!mt7615_firmware_offload(dev) || !mt76_is_mmio(&dev->mt76))
return -EOPNOTSUPP;
mt7615_mutex_acquire(dev);
if (dev->phy.n_beacon_vif) {
ret = -EBUSY;
goto out;
}
dev->pm.enable = val;
out:
mt7615_mutex_release(dev);
return ret;
} }
static int static int
......
...@@ -1969,49 +1969,6 @@ void mt7615_pm_power_save_work(struct work_struct *work) ...@@ -1969,49 +1969,6 @@ void mt7615_pm_power_save_work(struct work_struct *work)
queue_delayed_work(dev->mt76.wq, &dev->pm.ps_work, delta); queue_delayed_work(dev->mt76.wq, &dev->pm.ps_work, delta);
} }
static void
mt7615_pm_interface_iter(void *priv, u8 *mac, struct ieee80211_vif *vif)
{
struct mt7615_phy *phy = priv;
struct mt7615_dev *dev = phy->dev;
bool ext_phy = phy != &dev->phy;
if (mt7615_mcu_set_bss_pm(dev, vif, dev->pm.enable))
return;
if (dev->pm.enable) {
vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER;
mt76_set(dev, MT_WF_RFCR(ext_phy),
MT_WF_RFCR_DROP_OTHER_BEACON);
} else {
vif->driver_flags &= ~IEEE80211_VIF_BEACON_FILTER;
mt76_clear(dev, MT_WF_RFCR(ext_phy),
MT_WF_RFCR_DROP_OTHER_BEACON);
}
}
int mt7615_pm_set_enable(struct mt7615_dev *dev, bool enable)
{
struct mt76_phy *mphy = dev->phy.mt76;
if (!mt7615_firmware_offload(dev) || !mt76_is_mmio(&dev->mt76))
return -EOPNOTSUPP;
mt7615_mutex_acquire(dev);
if (dev->pm.enable == enable)
goto out;
dev->pm.enable = enable;
ieee80211_iterate_active_interfaces(mphy->hw,
IEEE80211_IFACE_ITER_RESUME_ALL,
mt7615_pm_interface_iter, mphy->priv);
out:
mt7615_mutex_release(dev);
return 0;
}
void mt7615_mac_work(struct work_struct *work) void mt7615_mac_work(struct work_struct *work)
{ {
struct mt7615_phy *phy; struct mt7615_phy *phy;
...@@ -2314,3 +2271,46 @@ int mt7615_dfs_init_radar_detector(struct mt7615_phy *phy) ...@@ -2314,3 +2271,46 @@ int mt7615_dfs_init_radar_detector(struct mt7615_phy *phy)
mt7615_dfs_stop_radar_detector(phy); mt7615_dfs_stop_radar_detector(phy);
return 0; return 0;
} }
int mt7615_mac_set_beacon_filter(struct mt7615_phy *phy,
struct ieee80211_vif *vif,
bool enable)
{
struct mt7615_dev *dev = phy->dev;
bool ext_phy = phy != &dev->phy;
int err;
if (!mt7615_firmware_offload(dev))
return -EOPNOTSUPP;
switch (vif->type) {
case NL80211_IFTYPE_MONITOR:
return 0;
case NL80211_IFTYPE_MESH_POINT:
case NL80211_IFTYPE_ADHOC:
case NL80211_IFTYPE_AP:
if (enable)
phy->n_beacon_vif++;
else
phy->n_beacon_vif--;
fallthrough;
default:
break;
}
err = mt7615_mcu_set_bss_pm(dev, vif, !phy->n_beacon_vif);
if (err)
return err;
if (phy->n_beacon_vif) {
vif->driver_flags &= ~IEEE80211_VIF_BEACON_FILTER;
mt76_clear(dev, MT_WF_RFCR(ext_phy),
MT_WF_RFCR_DROP_OTHER_BEACON);
} else {
vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER;
mt76_set(dev, MT_WF_RFCR(ext_phy),
MT_WF_RFCR_DROP_OTHER_BEACON);
}
return 0;
}
...@@ -211,15 +211,7 @@ static int mt7615_add_interface(struct ieee80211_hw *hw, ...@@ -211,15 +211,7 @@ static int mt7615_add_interface(struct ieee80211_hw *hw,
if (ret) if (ret)
goto out; goto out;
if (dev->pm.enable) { mt7615_mac_set_beacon_filter(phy, vif, true);
ret = mt7615_mcu_set_bss_pm(dev, vif, true);
if (ret)
goto out;
vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER;
mt76_set(dev, MT_WF_RFCR(ext_phy),
MT_WF_RFCR_DROP_OTHER_BEACON);
}
out: out:
mt7615_mutex_release(dev); mt7615_mutex_release(dev);
...@@ -245,13 +237,7 @@ static void mt7615_remove_interface(struct ieee80211_hw *hw, ...@@ -245,13 +237,7 @@ static void mt7615_remove_interface(struct ieee80211_hw *hw,
mt7615_free_pending_tx_skbs(dev, msta); mt7615_free_pending_tx_skbs(dev, msta);
if (dev->pm.enable) { mt7615_mac_set_beacon_filter(phy, vif, false);
bool ext_phy = phy != &dev->phy;
mt7615_mcu_set_bss_pm(dev, vif, false);
mt76_clear(dev, MT_WF_RFCR(ext_phy),
MT_WF_RFCR_DROP_OTHER_BEACON);
}
mt7615_mcu_add_dev_info(dev, vif, false); mt7615_mcu_add_dev_info(dev, vif, false);
rcu_assign_pointer(dev->mt76.wcid[idx], NULL); rcu_assign_pointer(dev->mt76.wcid[idx], NULL);
...@@ -511,7 +497,6 @@ static void mt7615_configure_filter(struct ieee80211_hw *hw, ...@@ -511,7 +497,6 @@ static void mt7615_configure_filter(struct ieee80211_hw *hw,
} while (0) } while (0)
phy->rxfilter &= ~(MT_WF_RFCR_DROP_OTHER_BSS | phy->rxfilter &= ~(MT_WF_RFCR_DROP_OTHER_BSS |
MT_WF_RFCR_DROP_OTHER_BEACON |
MT_WF_RFCR_DROP_FRAME_REPORT | MT_WF_RFCR_DROP_FRAME_REPORT |
MT_WF_RFCR_DROP_PROBEREQ | MT_WF_RFCR_DROP_PROBEREQ |
MT_WF_RFCR_DROP_MCAST_FILTERED | MT_WF_RFCR_DROP_MCAST_FILTERED |
...@@ -522,6 +507,9 @@ static void mt7615_configure_filter(struct ieee80211_hw *hw, ...@@ -522,6 +507,9 @@ static void mt7615_configure_filter(struct ieee80211_hw *hw,
MT_WF_RFCR_DROP_UNWANTED_CTL | MT_WF_RFCR_DROP_UNWANTED_CTL |
MT_WF_RFCR_DROP_STBC_MULTI); MT_WF_RFCR_DROP_STBC_MULTI);
if (phy->n_beacon_vif || !mt7615_firmware_offload(dev))
phy->rxfilter &= ~MT_WF_RFCR_DROP_OTHER_BEACON;
MT76_FILTER(OTHER_BSS, MT_WF_RFCR_DROP_OTHER_TIM | MT76_FILTER(OTHER_BSS, MT_WF_RFCR_DROP_OTHER_TIM |
MT_WF_RFCR_DROP_A3_MAC | MT_WF_RFCR_DROP_A3_MAC |
MT_WF_RFCR_DROP_A3_BSSID); MT_WF_RFCR_DROP_A3_BSSID);
...@@ -1127,7 +1115,6 @@ static int mt7615_suspend(struct ieee80211_hw *hw, ...@@ -1127,7 +1115,6 @@ static int mt7615_suspend(struct ieee80211_hw *hw,
{ {
struct mt7615_dev *dev = mt7615_hw_dev(hw); struct mt7615_dev *dev = mt7615_hw_dev(hw);
struct mt7615_phy *phy = mt7615_hw_phy(hw); struct mt7615_phy *phy = mt7615_hw_phy(hw);
bool ext_phy = phy != &dev->phy;
int err = 0; int err = 0;
cancel_delayed_work_sync(&dev->pm.ps_work); cancel_delayed_work_sync(&dev->pm.ps_work);
...@@ -1139,8 +1126,6 @@ static int mt7615_suspend(struct ieee80211_hw *hw, ...@@ -1139,8 +1126,6 @@ static int mt7615_suspend(struct ieee80211_hw *hw,
cancel_delayed_work_sync(&phy->scan_work); cancel_delayed_work_sync(&phy->scan_work);
cancel_delayed_work_sync(&phy->mac_work); cancel_delayed_work_sync(&phy->mac_work);
mt76_set(dev, MT_WF_RFCR(ext_phy), MT_WF_RFCR_DROP_OTHER_BEACON);
set_bit(MT76_STATE_SUSPEND, &phy->mt76->state); set_bit(MT76_STATE_SUSPEND, &phy->mt76->state);
ieee80211_iterate_active_interfaces(hw, ieee80211_iterate_active_interfaces(hw,
IEEE80211_IFACE_ITER_RESUME_ALL, IEEE80211_IFACE_ITER_RESUME_ALL,
...@@ -1158,7 +1143,7 @@ static int mt7615_resume(struct ieee80211_hw *hw) ...@@ -1158,7 +1143,7 @@ static int mt7615_resume(struct ieee80211_hw *hw)
{ {
struct mt7615_dev *dev = mt7615_hw_dev(hw); struct mt7615_dev *dev = mt7615_hw_dev(hw);
struct mt7615_phy *phy = mt7615_hw_phy(hw); struct mt7615_phy *phy = mt7615_hw_phy(hw);
bool running, ext_phy = phy != &dev->phy; bool running;
mt7615_mutex_acquire(dev); mt7615_mutex_acquire(dev);
...@@ -1182,7 +1167,6 @@ static int mt7615_resume(struct ieee80211_hw *hw) ...@@ -1182,7 +1167,6 @@ static int mt7615_resume(struct ieee80211_hw *hw)
ieee80211_queue_delayed_work(hw, &phy->mac_work, ieee80211_queue_delayed_work(hw, &phy->mac_work,
MT7615_WATCHDOG_TIME); MT7615_WATCHDOG_TIME);
mt76_clear(dev, MT_WF_RFCR(ext_phy), MT_WF_RFCR_DROP_OTHER_BEACON);
mt7615_mutex_release(dev); mt7615_mutex_release(dev);
......
...@@ -3478,9 +3478,8 @@ int mt7615_mcu_set_bss_pm(struct mt7615_dev *dev, struct ieee80211_vif *vif, ...@@ -3478,9 +3478,8 @@ int mt7615_mcu_set_bss_pm(struct mt7615_dev *dev, struct ieee80211_vif *vif,
}; };
int err; int err;
if (vif->type != NL80211_IFTYPE_STATION || if (vif->type != NL80211_IFTYPE_STATION)
!mt7615_firmware_offload(dev)) return 0;
return -ENOTSUPP;
err = mt76_mcu_send_msg(&dev->mt76, MCU_CMD_SET_BSS_ABORT, &req_hdr, err = mt76_mcu_send_msg(&dev->mt76, MCU_CMD_SET_BSS_ABORT, &req_hdr,
sizeof(req_hdr), false); sizeof(req_hdr), false);
...@@ -3694,8 +3693,6 @@ void mt7615_mcu_set_suspend_iter(void *priv, u8 *mac, ...@@ -3694,8 +3693,6 @@ void mt7615_mcu_set_suspend_iter(void *priv, u8 *mac,
struct cfg80211_wowlan *wowlan = hw->wiphy->wowlan_config; struct cfg80211_wowlan *wowlan = hw->wiphy->wowlan_config;
int i; int i;
mt7615_mcu_set_bss_pm(phy->dev, vif, suspend);
mt7615_mcu_set_gtk_rekey(phy->dev, vif, suspend); mt7615_mcu_set_gtk_rekey(phy->dev, vif, suspend);
mt7615_mcu_set_arp_filter(phy->dev, vif, suspend); mt7615_mcu_set_arp_filter(phy->dev, vif, suspend);
......
...@@ -175,6 +175,8 @@ struct mt7615_phy { ...@@ -175,6 +175,8 @@ struct mt7615_phy {
struct ieee80211_vif *monitor_vif; struct ieee80211_vif *monitor_vif;
u8 n_beacon_vif;
u32 rxfilter; u32 rxfilter;
u32 omac_mask; u32 omac_mask;
...@@ -454,7 +456,6 @@ bool mt7615_wait_for_mcu_init(struct mt7615_dev *dev); ...@@ -454,7 +456,6 @@ bool mt7615_wait_for_mcu_init(struct mt7615_dev *dev);
void mt7615_mac_set_rates(struct mt7615_phy *phy, struct mt7615_sta *sta, void mt7615_mac_set_rates(struct mt7615_phy *phy, struct mt7615_sta *sta,
struct ieee80211_tx_rate *probe_rate, struct ieee80211_tx_rate *probe_rate,
struct ieee80211_tx_rate *rates); struct ieee80211_tx_rate *rates);
int mt7615_pm_set_enable(struct mt7615_dev *dev, bool enable);
void mt7615_pm_wake_work(struct work_struct *work); void mt7615_pm_wake_work(struct work_struct *work);
int mt7615_pm_wake(struct mt7615_dev *dev); int mt7615_pm_wake(struct mt7615_dev *dev);
void mt7615_pm_power_save_sched(struct mt7615_dev *dev); void mt7615_pm_power_save_sched(struct mt7615_dev *dev);
...@@ -652,6 +653,9 @@ int mt7615_mcu_set_roc(struct mt7615_phy *phy, struct ieee80211_vif *vif, ...@@ -652,6 +653,9 @@ int mt7615_mcu_set_roc(struct mt7615_phy *phy, struct ieee80211_vif *vif,
int mt7615_init_debugfs(struct mt7615_dev *dev); int mt7615_init_debugfs(struct mt7615_dev *dev);
int mt7615_mcu_wait_response(struct mt7615_dev *dev, int cmd, int seq); int mt7615_mcu_wait_response(struct mt7615_dev *dev, int cmd, int seq);
int mt7615_mac_set_beacon_filter(struct mt7615_phy *phy,
struct ieee80211_vif *vif,
bool enable);
int mt7615_mcu_set_bss_pm(struct mt7615_dev *dev, struct ieee80211_vif *vif, int mt7615_mcu_set_bss_pm(struct mt7615_dev *dev, struct ieee80211_vif *vif,
bool enable); bool enable);
int mt7615_mcu_set_hif_suspend(struct mt7615_dev *dev, bool suspend); int mt7615_mcu_set_hif_suspend(struct mt7615_dev *dev, bool suspend);
......
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