Commit db9f11d3 authored by Felix Fietkau's avatar Felix Fietkau

mt76: store wcid tx rate info in one u32 reduce locking

Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 2fe30dce
...@@ -188,6 +188,11 @@ enum mt76_wcid_flags { ...@@ -188,6 +188,11 @@ enum mt76_wcid_flags {
DECLARE_EWMA(signal, 10, 8); DECLARE_EWMA(signal, 10, 8);
#define MT_WCID_TX_INFO_RATE GENMASK(15, 0)
#define MT_WCID_TX_INFO_NSS GENMASK(17, 16)
#define MT_WCID_TX_INFO_TXPWR_ADJ GENMASK(25, 18)
#define MT_WCID_TX_INFO_SET BIT(31)
struct mt76_wcid { struct mt76_wcid {
struct mt76_rx_tid __rcu *aggr[IEEE80211_NUM_TIDS]; struct mt76_rx_tid __rcu *aggr[IEEE80211_NUM_TIDS];
...@@ -206,10 +211,7 @@ struct mt76_wcid { ...@@ -206,10 +211,7 @@ struct mt76_wcid {
u8 rx_check_pn; u8 rx_check_pn;
u8 rx_key_pn[IEEE80211_NUM_TIDS][6]; u8 rx_key_pn[IEEE80211_NUM_TIDS][6];
__le16 tx_rate; u32 tx_info;
bool tx_rate_set;
u8 tx_rate_nss;
s8 max_txpwr_adj;
bool sw_iv; bool sw_iv;
u8 packet_id; u8 packet_id;
......
...@@ -717,11 +717,11 @@ void mt7603_wtbl_set_rates(struct mt7603_dev *dev, struct mt7603_sta *sta, ...@@ -717,11 +717,11 @@ void mt7603_wtbl_set_rates(struct mt7603_dev *dev, struct mt7603_sta *sta,
MT_WTBL_UPDATE_RATE_UPDATE | MT_WTBL_UPDATE_RATE_UPDATE |
MT_WTBL_UPDATE_TX_COUNT_CLEAR); MT_WTBL_UPDATE_TX_COUNT_CLEAR);
if (!sta->wcid.tx_rate_set) if (!(sta->wcid.tx_info & MT_WCID_TX_INFO_SET))
mt76_poll(dev, MT_WTBL_UPDATE, MT_WTBL_UPDATE_BUSY, 0, 5000); mt76_poll(dev, MT_WTBL_UPDATE, MT_WTBL_UPDATE_BUSY, 0, 5000);
sta->rate_count = 2 * MT7603_RATE_RETRY * n_rates; sta->rate_count = 2 * MT7603_RATE_RETRY * n_rates;
sta->wcid.tx_rate_set = true; sta->wcid.tx_info |= MT_WCID_TX_INFO_SET;
} }
static enum mt7603_cipher_type static enum mt7603_cipher_type
......
...@@ -218,10 +218,17 @@ mt76x02_mac_tx_rate_val(struct mt76x02_dev *dev, ...@@ -218,10 +218,17 @@ mt76x02_mac_tx_rate_val(struct mt76x02_dev *dev,
void mt76x02_mac_wcid_set_rate(struct mt76x02_dev *dev, struct mt76_wcid *wcid, void mt76x02_mac_wcid_set_rate(struct mt76x02_dev *dev, struct mt76_wcid *wcid,
const struct ieee80211_tx_rate *rate) const struct ieee80211_tx_rate *rate)
{ {
spin_lock_bh(&dev->mt76.lock); s8 max_txpwr_adj = mt76x02_tx_get_max_txpwr_adj(dev, rate);
wcid->tx_rate = mt76x02_mac_tx_rate_val(dev, rate, &wcid->tx_rate_nss); __le16 rateval;
wcid->tx_rate_set = true; u32 tx_info;
spin_unlock_bh(&dev->mt76.lock); s8 nss;
rateval = mt76x02_mac_tx_rate_val(dev, rate, &nss);
tx_info = FIELD_PREP(MT_WCID_TX_INFO_RATE, rateval) |
FIELD_PREP(MT_WCID_TX_INFO_NSS, nss) |
FIELD_PREP(MT_WCID_TX_INFO_TXPWR_ADJ, max_txpwr_adj) |
MT_WCID_TX_INFO_SET;
wcid->tx_info = tx_info;
} }
void mt76x02_mac_set_short_preamble(struct mt76x02_dev *dev, bool enable) void mt76x02_mac_set_short_preamble(struct mt76x02_dev *dev, bool enable)
...@@ -323,6 +330,7 @@ void mt76x02_mac_write_txwi(struct mt76x02_dev *dev, struct mt76x02_txwi *txwi, ...@@ -323,6 +330,7 @@ void mt76x02_mac_write_txwi(struct mt76x02_dev *dev, struct mt76x02_txwi *txwi,
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
struct ieee80211_tx_rate *rate = &info->control.rates[0]; struct ieee80211_tx_rate *rate = &info->control.rates[0];
struct ieee80211_key_conf *key = info->control.hw_key; struct ieee80211_key_conf *key = info->control.hw_key;
u32 wcid_tx_info;
u16 rate_ht_mask = FIELD_PREP(MT_RXWI_RATE_PHY, BIT(1) | BIT(2)); u16 rate_ht_mask = FIELD_PREP(MT_RXWI_RATE_PHY, BIT(1) | BIT(2));
u16 txwi_flags = 0; u16 txwi_flags = 0;
u8 nss; u8 nss;
...@@ -357,16 +365,16 @@ void mt76x02_mac_write_txwi(struct mt76x02_dev *dev, struct mt76x02_txwi *txwi, ...@@ -357,16 +365,16 @@ void mt76x02_mac_write_txwi(struct mt76x02_dev *dev, struct mt76x02_txwi *txwi,
txwi->eiv = *((__le32 *)&ccmp_pn[4]); txwi->eiv = *((__le32 *)&ccmp_pn[4]);
} }
spin_lock_bh(&dev->mt76.lock);
if (wcid && (rate->idx < 0 || !rate->count)) { if (wcid && (rate->idx < 0 || !rate->count)) {
txwi->rate = wcid->tx_rate; wcid_tx_info = wcid->tx_info;
max_txpwr_adj = wcid->max_txpwr_adj; txwi->rate = FIELD_GET(MT_WCID_TX_INFO_RATE, wcid_tx_info);
nss = wcid->tx_rate_nss; max_txpwr_adj = FIELD_GET(MT_WCID_TX_INFO_TXPWR_ADJ,
wcid_tx_info);
nss = FIELD_GET(MT_WCID_TX_INFO_NSS, wcid_tx_info);
} else { } else {
txwi->rate = mt76x02_mac_tx_rate_val(dev, rate, &nss); txwi->rate = mt76x02_mac_tx_rate_val(dev, rate, &nss);
max_txpwr_adj = mt76x02_tx_get_max_txpwr_adj(dev, rate); max_txpwr_adj = mt76x02_tx_get_max_txpwr_adj(dev, rate);
} }
spin_unlock_bh(&dev->mt76.lock);
txpwr_adj = mt76x02_tx_get_txpwr_adj(dev, dev->mt76.txpower_conf, txpwr_adj = mt76x02_tx_get_txpwr_adj(dev, dev->mt76.txpower_conf,
max_txpwr_adj); max_txpwr_adj);
......
...@@ -572,7 +572,6 @@ void mt76x02_sta_rate_tbl_update(struct ieee80211_hw *hw, ...@@ -572,7 +572,6 @@ void mt76x02_sta_rate_tbl_update(struct ieee80211_hw *hw,
rate.idx = rates->rate[0].idx; rate.idx = rates->rate[0].idx;
rate.flags = rates->rate[0].flags; rate.flags = rates->rate[0].flags;
mt76x02_mac_wcid_set_rate(dev, &msta->wcid, &rate); mt76x02_mac_wcid_set_rate(dev, &msta->wcid, &rate);
msta->wcid.max_txpwr_adj = mt76x02_tx_get_max_txpwr_adj(dev, &rate);
} }
EXPORT_SYMBOL_GPL(mt76x02_sta_rate_tbl_update); EXPORT_SYMBOL_GPL(mt76x02_sta_rate_tbl_update);
......
...@@ -266,7 +266,7 @@ mt76_tx(struct mt76_dev *dev, struct ieee80211_sta *sta, ...@@ -266,7 +266,7 @@ mt76_tx(struct mt76_dev *dev, struct ieee80211_sta *sta,
skb_set_queue_mapping(skb, qid); skb_set_queue_mapping(skb, qid);
} }
if (!wcid->tx_rate_set) if (!(wcid->tx_info & MT_WCID_TX_INFO_SET))
ieee80211_get_tx_rates(info->control.vif, sta, skb, ieee80211_get_tx_rates(info->control.vif, sta, skb,
info->control.rates, 1); info->control.rates, 1);
...@@ -412,7 +412,7 @@ mt76_txq_send_burst(struct mt76_dev *dev, struct mt76_sw_queue *sq, ...@@ -412,7 +412,7 @@ mt76_txq_send_burst(struct mt76_dev *dev, struct mt76_sw_queue *sq,
} }
info = IEEE80211_SKB_CB(skb); info = IEEE80211_SKB_CB(skb);
if (!wcid->tx_rate_set) if (!(wcid->tx_info & MT_WCID_TX_INFO_SET))
ieee80211_get_tx_rates(txq->vif, txq->sta, skb, ieee80211_get_tx_rates(txq->vif, txq->sta, skb,
info->control.rates, 1); info->control.rates, 1);
tx_rate = info->control.rates[0]; tx_rate = info->control.rates[0];
......
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