developer | 047bc18 | 2022-11-16 12:20:48 +0800 | [diff] [blame] | 1 | From: Aditya Kumar Singh <quic_adisi@quicinc.com> |
| 2 | Date: Fri, 1 Jul 2022 19:06:11 +0530 |
| 3 | Subject: [PATCH] wifi: mac80211: fix mesh airtime link metric estimating |
| 4 | |
| 5 | ieee80211s_update_metric function uses sta_set_rate_info_tx |
| 6 | function to get struct rate_info data from ieee80211_tx_rate |
| 7 | struct, present in ieee80211_sta->deflink.tx_stats. However, |
| 8 | drivers can skip tx rate calculation by setting rate idx as |
| 9 | -1. Such drivers provides rate_info directly and hence |
| 10 | ieee80211s metric is updated incorrectly since ieee80211_tx_rate |
| 11 | has inconsistent data. |
| 12 | |
| 13 | Add fix to use rate_info directly if present instead of |
| 14 | sta_set_rate_info_tx for updating ieee80211s metric. |
| 15 | |
| 16 | Signed-off-by: Aditya Kumar Singh <quic_adisi@quicinc.com> |
| 17 | Link: https://lore.kernel.org/r/20220701133611.544-1-quic_adisi@quicinc.com |
| 18 | Signed-off-by: Johannes Berg <johannes.berg@intel.com> |
| 19 | --- |
| 20 | |
| 21 | --- a/net/mac80211/mesh_hwmp.c |
| 22 | +++ b/net/mac80211/mesh_hwmp.c |
| 23 | @@ -310,7 +310,12 @@ void ieee80211s_update_metric(struct iee |
| 24 | LINK_FAIL_THRESH) |
| 25 | mesh_plink_broken(sta); |
| 26 | |
| 27 | - sta_set_rate_info_tx(sta, &sta->tx_stats.last_rate, &rinfo); |
| 28 | + /* use rate info set by the driver directly if present */ |
| 29 | + if (st->rate) |
| 30 | + rinfo = sta->tx_stats.last_rate_info; |
| 31 | + else |
| 32 | + sta_set_rate_info_tx(sta, &sta->tx_stats.last_rate, &rinfo); |
| 33 | + |
| 34 | ewma_mesh_tx_rate_avg_add(&sta->mesh->tx_rate_avg, |
| 35 | cfg80211_calculate_bitrate(&rinfo)); |
| 36 | } |