Skip to content

Commit

Permalink
mt7603: add mt7603_wtbl_set_skip_tx, change mt7603_wtbl_set_ps users
Browse files Browse the repository at this point in the history
Avoids unnecessary toggling of the MT_WTBL1_OR_PSM_WRITE flag

Signed-off-by: Felix Fietkau <nbd@nbd.name>
  • Loading branch information
nbd168 committed Nov 16, 2018
1 parent 13f1e82 commit 90e2c1b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
19 changes: 16 additions & 3 deletions mt7603/mac.c
Expand Up @@ -160,8 +160,8 @@ void mt7603_wtbl_set_ps(struct mt7603_dev *dev, int idx, bool enabled)
{
u32 addr = mt7603_wtbl1_addr(idx);
u32 reg = mt76_rr(dev, addr + 3 * 4);
u32 val = (reg & ~MT_WTBL1_W3_SKIP_TX) |
(enabled * MT_WTBL1_W3_SKIP_TX);
u32 val = (reg & ~MT_WTBL1_W3_POWER_SAVE) |
(enabled * MT_WTBL1_W3_POWER_SAVE);

if (reg == val)
return;
Expand All @@ -171,6 +171,19 @@ void mt7603_wtbl_set_ps(struct mt7603_dev *dev, int idx, bool enabled)
mt76_clear(dev, MT_WTBL1_OR, MT_WTBL1_OR_PSM_WRITE);
}

void mt7603_wtbl_set_skip_tx(struct mt7603_dev *dev, int idx, bool enabled)
{
u32 addr = mt7603_wtbl1_addr(idx);
u32 reg = mt76_rr(dev, addr + 3 * 4);
u32 val = (reg & ~MT_WTBL1_W3_SKIP_TX) |
(enabled * MT_WTBL1_W3_SKIP_TX);

if (reg == val)
return;

mt76_wr(dev, addr + 3 * 4, val);
}

void mt7603_wtbl_clear(struct mt7603_dev *dev, int idx)
{
int wtbl2_frame_size = MT_PSE_PAGE_SIZE / MT_WTBL2_SIZE;
Expand Down Expand Up @@ -874,7 +887,7 @@ int mt7603_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
} else {
if (info->flags & (IEEE80211_TX_CTL_NO_PS_BUFFER |
IEEE80211_TX_CTL_CLEAR_PS_FILT))
mt7603_wtbl_set_ps(dev, wcid->idx, false);
mt7603_wtbl_set_skip_tx(dev, wcid->idx, false);
}

pid = mt76_tx_status_skb_add(mdev, wcid, skb);
Expand Down
4 changes: 2 additions & 2 deletions mt7603/main.c
Expand Up @@ -95,7 +95,7 @@ mt7603_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)

eth_broadcast_addr(bc_addr);
mt7603_wtbl_init(dev, idx, mvif->idx, bc_addr);
mt7603_wtbl_set_ps(dev, idx, false);
mt7603_wtbl_set_skip_tx(dev, idx, false);

rcu_assign_pointer(dev->mt76.wcid[idx], &mvif->sta.wcid);
mt7603_txq_init(dev, vif->txq);
Expand Down Expand Up @@ -336,7 +336,7 @@ mt7603_sta_ps(struct mt76_dev *mdev, struct ieee80211_sta *sta, bool ps)
int idx = msta->wcid.idx;

mt76_stop_tx_queues(&dev->mt76, sta, false);
mt7603_wtbl_set_ps(dev, idx, ps);
mt7603_wtbl_set_skip_tx(dev, idx, ps);
}

static int
Expand Down
3 changes: 2 additions & 1 deletion mt7603/mt7603.h
Expand Up @@ -208,7 +208,8 @@ void mt7603_wtbl_set_rates(struct mt7603_dev *dev, struct mt7603_sta *sta,
struct ieee80211_tx_rate *rates);
int mt7603_wtbl_set_key(struct mt7603_dev *dev, int wcid,
struct ieee80211_key_conf *key);
void mt7603_wtbl_set_ps(struct mt7603_dev *dev, int idx, bool val);
void mt7603_wtbl_set_ps(struct mt7603_dev *dev, int idx, bool enabled);
void mt7603_wtbl_set_skip_tx(struct mt7603_dev *dev, int idx, bool val);

int mt7603_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
struct sk_buff *skb, struct mt76_queue *q,
Expand Down

0 comments on commit 90e2c1b

Please sign in to comment.