diff --git a/mt76x2_mac.c b/mt76x2_mac.c index d9fc9a6f..0b4fecc1 100644 --- a/mt76x2_mac.c +++ b/mt76x2_mac.c @@ -145,6 +145,16 @@ mt76x2_mac_tx_rate_val(struct mt76x2_dev *dev, return cpu_to_le16(rateval); } +void mt76x2_mac_wcid_set_drop(struct mt76x2_dev *dev, u8 idx, bool drop) +{ + u32 val = mt76_rr(dev, MT_WCID_DROP(idx)); + u32 bit = MT_WCID_DROP_MASK(idx); + + /* prevent unnecessary writes */ + if ((val & bit) != (bit * drop)) + mt76_wr(dev, MT_WCID_DROP(idx), (val & ~bit) | (bit * drop)); +} + void mt76x2_mac_wcid_set_rate(struct mt76x2_dev *dev, struct mt76_wcid *wcid, const struct ieee80211_tx_rate *rate) { diff --git a/mt76x2_mac.h b/mt76x2_mac.h index 7236e572..8a8a25e3 100644 --- a/mt76x2_mac.h +++ b/mt76x2_mac.h @@ -173,6 +173,7 @@ int mt76x2_mac_wcid_set_key(struct mt76x2_dev *dev, u8 idx, struct ieee80211_key_conf *key); void mt76x2_mac_wcid_set_rate(struct mt76x2_dev *dev, struct mt76_wcid *wcid, const struct ieee80211_tx_rate *rate); +void mt76x2_mac_wcid_set_drop(struct mt76x2_dev *dev, u8 idx, bool drop); int mt76x2_mac_shared_key_setup(struct mt76x2_dev *dev, u8 vif_idx, u8 key_idx, struct ieee80211_key_conf *key); diff --git a/mt76x2_main.c b/mt76x2_main.c index c3de1e73..2cef48ed 100644 --- a/mt76x2_main.c +++ b/mt76x2_main.c @@ -263,7 +263,7 @@ mt76x2_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, msta->wcid.idx = idx; msta->wcid.hw_key_idx = -1; mt76x2_mac_wcid_setup(dev, idx, mvif->idx, sta->addr); - mt76_clear(dev, MT_WCID_DROP(idx), MT_WCID_DROP_MASK(idx)); + mt76x2_mac_wcid_set_drop(dev, idx, false); for (i = 0; i < ARRAY_SIZE(sta->txq); i++) mt76x2_txq_init(dev, sta->txq[i]); @@ -288,7 +288,7 @@ mt76x2_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, rcu_assign_pointer(dev->wcid[idx], NULL); for (i = 0; i < ARRAY_SIZE(sta->txq); i++) mt76_txq_remove(&dev->mt76, sta->txq[i]); - mt76_set(dev, MT_WCID_DROP(idx), MT_WCID_DROP_MASK(idx)); + mt76x2_mac_wcid_set_drop(dev, idx, true); mt76_wcid_free(dev->wcid_mask, idx); mt76x2_mac_wcid_setup(dev, idx, 0, NULL); mutex_unlock(&dev->mutex); @@ -306,11 +306,11 @@ mt76x2_sta_notify(struct ieee80211_hw *hw, struct ieee80211_vif *vif, switch (cmd) { case STA_NOTIFY_SLEEP: - mt76_set(dev, MT_WCID_DROP(idx), MT_WCID_DROP_MASK(idx)); + mt76x2_mac_wcid_set_drop(dev, idx, true); mt76_stop_tx_queues(&dev->mt76, sta, true); break; case STA_NOTIFY_AWAKE: - mt76_clear(dev, MT_WCID_DROP(idx), MT_WCID_DROP_MASK(idx)); + mt76x2_mac_wcid_set_drop(dev, idx, false); break; } }