From 9c52f360914fb356835591528e86310eff717919 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Thu, 12 Apr 2018 18:17:09 +0200 Subject: [PATCH] mt7603: pull the final rate index from the status descriptor When doing rate probing, multiple frames might end up getting sent with the probe rate, because of the way that rate probing is set up. This race window is most visible with MCS rates and aggregation. To improve rate control stats accuracy, pull the final tx rate from the descriptor Signed-off-by: Felix Fietkau --- mt7603_mac.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mt7603_mac.c b/mt7603_mac.c index 64dc446cb..7292d4b94 100644 --- a/mt7603_mac.c +++ b/mt7603_mac.c @@ -917,6 +917,8 @@ static bool mt7603_fill_txs(struct mt7603_dev *dev, struct mt7603_sta *sta, struct ieee80211_tx_info *info, __le32 *txs_data) { + int final_idx = 0; + u32 final_rate; bool final_mpdu; bool ack_timeout; bool fixed_rate; @@ -938,6 +940,7 @@ mt7603_fill_txs(struct mt7603_dev *dev, struct mt7603_sta *sta, count = FIELD_GET(MT_TXS4_TX_COUNT, txs); txs = le32_to_cpu(txs_data[0]); + final_rate = FIELD_GET(MT_TXS0_TX_RATE, txs); ack_timeout = txs & MT_TXS0_ACK_TIMEOUT; if (!(txs & MT_TXS0_ACK_ERROR_MASK)) { @@ -998,9 +1001,13 @@ mt7603_fill_txs(struct mt7603_dev *dev, struct mt7603_sta *sta, } info->status.rates[i].count = cur_count; + final_idx = i; count -= cur_count; } + if (sta->rates[final_idx].flags & IEEE80211_TX_RC_MCS) + info->status.rates[final_idx].idx = final_rate & GENMASK(5, 0); + return true; }