Skip to content

Commit

Permalink
mt76: mt7615: switch to per-vif power_save support
Browse files Browse the repository at this point in the history
switch to per-vif ps support since mt7615 offload firmware can handle it
properly. This patch allows enabling/disabling power-save support on p2p
interface

Tested-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
  • Loading branch information
Lorenzo Bianconi authored and Felix Fietkau committed May 28, 2020
1 parent b62db09 commit a5e0aa7
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 38 deletions.
1 change: 0 additions & 1 deletion drivers/net/wireless/mediatek/mt76/mt76.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ enum {
MT76_REMOVED,
MT76_READING_STATS,
MT76_STATE_POWER_OFF,
MT76_STATE_PS,
MT76_STATE_SUSPEND,
MT76_STATE_ROC,
};
Expand Down
2 changes: 0 additions & 2 deletions drivers/net/wireless/mediatek/mt76/mt7615/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,6 @@ int mt7615_register_ext_phy(struct mt7615_dev *dev)
INIT_DELAYED_WORK(&phy->scan_work, mt7615_scan_work);
skb_queue_head_init(&phy->scan_event_list);

INIT_WORK(&phy->ps_work, mt7615_ps_work);
INIT_WORK(&phy->roc_work, mt7615_roc_work);
timer_setup(&phy->roc_timer, mt7615_roc_timer, 0);
init_waitqueue_head(&phy->roc_wait);
Expand Down Expand Up @@ -447,7 +446,6 @@ void mt7615_init_device(struct mt7615_dev *dev)
init_waitqueue_head(&dev->phy.roc_wait);

INIT_WORK(&dev->reset_work, mt7615_mac_reset_work);
INIT_WORK(&dev->phy.ps_work, mt7615_ps_work);
INIT_WORK(&dev->phy.roc_work, mt7615_roc_work);
timer_setup(&dev->phy.roc_timer, mt7615_roc_timer, 0);

Expand Down
26 changes: 3 additions & 23 deletions drivers/net/wireless/mediatek/mt76/mt7615/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ static void mt7615_stop(struct ieee80211_hw *hw)
struct mt7615_phy *phy = mt7615_hw_phy(hw);

cancel_delayed_work_sync(&phy->mac_work);
cancel_work_sync(&phy->ps_work);
del_timer_sync(&phy->roc_timer);
cancel_work_sync(&phy->roc_work);

Expand Down Expand Up @@ -362,20 +361,6 @@ static int mt7615_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
return mt7615_mac_wtbl_set_key(dev, wcid, key, cmd);
}

void mt7615_ps_work(struct work_struct *work)
{
struct mt7615_phy *phy;

phy = (struct mt7615_phy *)container_of(work, struct mt7615_phy,
ps_work);

mutex_lock(&phy->dev->mt76.mutex);
ieee80211_iterate_active_interfaces(phy->mt76->hw,
IEEE80211_IFACE_ITER_RESUME_ALL,
m7615_mcu_set_ps_iter, phy);
mutex_unlock(&phy->dev->mt76.mutex);
}

static int mt7615_config(struct ieee80211_hw *hw, u32 changed)
{
struct mt7615_dev *dev = mt7615_hw_dev(hw);
Expand All @@ -401,14 +386,6 @@ static int mt7615_config(struct ieee80211_hw *hw, u32 changed)
mt76_wr(dev, MT_WF_RFCR(band), phy->rxfilter);
}

if (changed & IEEE80211_CONF_CHANGE_PS) {
if (hw->conf.flags & IEEE80211_CONF_PS)
set_bit(MT76_STATE_PS, &phy->mt76->state);
else
clear_bit(MT76_STATE_PS, &phy->mt76->state);
ieee80211_queue_work(hw, &phy->ps_work);
}

mutex_unlock(&dev->mt76.mutex);

return ret;
Expand Down Expand Up @@ -511,6 +488,9 @@ static void mt7615_bss_info_changed(struct ieee80211_hw *hw,
BSS_CHANGED_BEACON_ENABLED))
mt7615_mcu_add_beacon(dev, hw, vif, info->enable_beacon);

if (changed & BSS_CHANGED_PS)
mt7615_mcu_set_vif_ps(dev, vif);

mutex_unlock(&dev->mt76.mutex);
}

Expand Down
14 changes: 7 additions & 7 deletions drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2772,11 +2772,9 @@ int mt7615_mcu_set_sku_en(struct mt7615_phy *phy, bool enable)
sizeof(req), true);
}

void m7615_mcu_set_ps_iter(void *priv, u8 *mac, struct ieee80211_vif *vif)
int mt7615_mcu_set_vif_ps(struct mt7615_dev *dev, struct ieee80211_vif *vif)
{
struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
struct mt7615_phy *phy = priv;
struct mt76_phy *mphy = phy->mt76;
struct {
u8 bss_idx;
u8 ps_state; /* 0: device awake
Expand All @@ -2785,12 +2783,14 @@ void m7615_mcu_set_ps_iter(void *priv, u8 *mac, struct ieee80211_vif *vif)
*/
} req = {
.bss_idx = mvif->idx,
.ps_state = test_bit(MT76_STATE_PS, &mphy->state) ? 2 : 0,
.ps_state = vif->bss_conf.ps ? 2 : 0,
};

if (vif->type == NL80211_IFTYPE_STATION)
__mt76_mcu_send_msg(&phy->dev->mt76, MCU_CMD_SET_PS_PROFILE,
&req, sizeof(req), false);
if (vif->type != NL80211_IFTYPE_STATION)
return -ENOTSUPP;

return __mt76_mcu_send_msg(&dev->mt76, MCU_CMD_SET_PS_PROFILE,
&req, sizeof(req), false);
}

int mt7615_mcu_set_channel_domain(struct mt7615_phy *phy)
Expand Down
5 changes: 1 addition & 4 deletions drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,6 @@ struct mt7615_phy {
struct timer_list roc_timer;
wait_queue_head_t roc_wait;
bool roc_grant;

struct work_struct ps_work;
};

#define mt7615_mcu_add_tx_ba(dev, ...) (dev)->mcu_ops->add_tx_ba((dev), __VA_ARGS__)
Expand Down Expand Up @@ -448,7 +446,6 @@ void mt7615_dma_reset(struct mt7615_dev *dev);
void mt7615_scan_work(struct work_struct *work);
void mt7615_roc_work(struct work_struct *work);
void mt7615_roc_timer(struct timer_list *timer);
void mt7615_ps_work(struct work_struct *work);
void mt7615_init_txpower(struct mt7615_dev *dev,
struct ieee80211_supported_band *sband);
void mt7615_phy_init(struct mt7615_dev *dev);
Expand Down Expand Up @@ -534,7 +531,7 @@ int mt7615_mcu_set_radar_th(struct mt7615_dev *dev, int index,
int mt7615_mcu_set_sku_en(struct mt7615_phy *phy, bool enable);
int mt7615_mcu_apply_rx_dcoc(struct mt7615_phy *phy);
int mt7615_mcu_apply_tx_dpd(struct mt7615_phy *phy);
void m7615_mcu_set_ps_iter(void *priv, u8 *mac, struct ieee80211_vif *vif);
int mt7615_mcu_set_vif_ps(struct mt7615_dev *dev, struct ieee80211_vif *vif);
int mt7615_dfs_init_radar_detector(struct mt7615_phy *phy);

int mt7615_mcu_set_p2p_oppps(struct ieee80211_hw *hw,
Expand Down
1 change: 0 additions & 1 deletion drivers/net/wireless/mediatek/mt76/mt7615/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ static void mt7663u_stop(struct ieee80211_hw *hw)
struct mt7615_dev *dev = hw->priv;

clear_bit(MT76_STATE_RUNNING, &dev->mphy.state);
cancel_work_sync(&phy->ps_work);
del_timer_sync(&phy->roc_timer);
cancel_work_sync(&phy->roc_work);
cancel_delayed_work_sync(&phy->scan_work);
Expand Down

0 comments on commit a5e0aa7

Please sign in to comment.