Skip to content

Commit

Permalink
mt76: mt76x02: do not copy beacon skb in mt76x02_mac_set_beacon_enable
Browse files Browse the repository at this point in the history
Do not copy beacon skb in mt76x02_mac_set_beacon_enable for usb devices
since it will be done in mt76x02_update_beacon_iter. Moreover squash
mt76x02_mac_set_beacon_enable and __mt76x02_mac_set_beacon_enable since
the latter is run just by mt76x02_mac_set_beacon_enable

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
  • Loading branch information
LorenzoBianconi authored and nbd168 committed Sep 5, 2019
1 parent 1920a0c commit d5160d8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 37 deletions.
61 changes: 25 additions & 36 deletions drivers/net/wireless/mediatek/mt76/mt76x02_beacon.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,51 +104,40 @@ int mt76x02_mac_set_beacon(struct mt76x02_dev *dev, u8 vif_idx,
}
EXPORT_SYMBOL_GPL(mt76x02_mac_set_beacon);

static void
__mt76x02_mac_set_beacon_enable(struct mt76x02_dev *dev, u8 vif_idx,
bool val, struct sk_buff *skb)
{
u8 old_mask = dev->mt76.beacon_mask;
bool en;
u32 reg;

if (val) {
dev->mt76.beacon_mask |= BIT(vif_idx);
if (skb)
mt76x02_mac_set_beacon(dev, vif_idx, skb);
} else {
dev->mt76.beacon_mask &= ~BIT(vif_idx);
mt76x02_mac_set_beacon(dev, vif_idx, NULL);
}

if (!!old_mask == !!dev->mt76.beacon_mask)
return;

en = dev->mt76.beacon_mask;

reg = MT_BEACON_TIME_CFG_BEACON_TX |
MT_BEACON_TIME_CFG_TBTT_EN |
MT_BEACON_TIME_CFG_TIMER_EN;
mt76_rmw(dev, MT_BEACON_TIME_CFG, reg, reg * en);
mt76x02_beacon_enable(dev, en);
}

void mt76x02_mac_set_beacon_enable(struct mt76x02_dev *dev,
struct ieee80211_vif *vif, bool val)
struct ieee80211_vif *vif, bool enable)
{
u8 vif_idx = ((struct mt76x02_vif *)vif->drv_priv)->idx;
struct sk_buff *skb = NULL;
struct mt76x02_vif *mvif = (struct mt76x02_vif *)vif->drv_priv;
u8 old_mask = dev->mt76.beacon_mask;

mt76x02_pre_tbtt_enable(dev, false);

if (mt76_is_usb(dev))
skb = ieee80211_beacon_get(mt76_hw(dev), vif);

if (!dev->mt76.beacon_mask)
dev->tbtt_count = 0;

__mt76x02_mac_set_beacon_enable(dev, vif_idx, val, skb);
if (enable) {
dev->mt76.beacon_mask |= BIT(mvif->idx);
} else {
dev->mt76.beacon_mask &= ~BIT(mvif->idx);
mt76x02_mac_set_beacon(dev, mvif->idx, NULL);
}

if (!!old_mask == !!dev->mt76.beacon_mask)
goto out;

if (dev->mt76.beacon_mask)
mt76_set(dev, MT_BEACON_TIME_CFG,
MT_BEACON_TIME_CFG_BEACON_TX |
MT_BEACON_TIME_CFG_TBTT_EN |
MT_BEACON_TIME_CFG_TIMER_EN);
else
mt76_clear(dev, MT_BEACON_TIME_CFG,
MT_BEACON_TIME_CFG_BEACON_TX |
MT_BEACON_TIME_CFG_TBTT_EN |
MT_BEACON_TIME_CFG_TIMER_EN);
mt76x02_beacon_enable(dev, !!dev->mt76.beacon_mask);

out:
mt76x02_pre_tbtt_enable(dev, true);
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/mediatek/mt76/mt76x02_mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ void mt76x02_mac_set_bssid(struct mt76x02_dev *dev, u8 idx, const u8 *addr);
int mt76x02_mac_set_beacon(struct mt76x02_dev *dev, u8 vif_idx,
struct sk_buff *skb);
void mt76x02_mac_set_beacon_enable(struct mt76x02_dev *dev,
struct ieee80211_vif *vif, bool val);
struct ieee80211_vif *vif, bool enable);

void mt76x02_edcca_init(struct mt76x02_dev *dev);
#endif

0 comments on commit d5160d8

Please sign in to comment.