wifi: mac80211: fix get inactive time for station mode
PATCH 1/1 wifi: mac80211: fix get inactive time for station mode
In station mode, the value last_rx is not updated often. Therefore the calculation of the inactive time will be wrong (will give values between 1000 ms to 30000 ms).
To fix this add the update of "sta->deflink.rx_stats.last_rx" for station mode in the response of the packets process (ieee80211_rx_h_sta_process).
--- net/mac80211/rx.c | 3 +++ net/mac80211/sta_info.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-)
net/mac80211/rx.c +3 -0
@@ -1756,6 +1756,9 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx) sta->deflink.rx_stats.last_rate =sta_stats_encode_rate (status); } +if (rx->sdata->vif.type ==NL80211_IFTYPE_STATION ) + sta->deflink.rx_stats.last_rx = jiffies; + sta->deflink.rx_stats.fragments++;u64_stats_update_begin (&rx->sta->deflink.rx_stats.syncp);
net/mac80211/sta_info.c +1 -1
@@ -2430,7 +2430,7 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo, sinfo->connected_time =ktime_get_seconds () - sta->last_connected; sinfo->assoc_at = sta->assoc_at; sinfo->inactive_time = -jiffies_to_msecs (jiffies -ieee80211_sta_last_active (sta)); +jiffies_to_msecs (abs (jiffies -ieee80211_sta_last_active (sta)));if (!(sinfo->filled & (BIT_ULL (NL80211_STA_INFO_TX_BYTES64 ) |BIT_ULL (NL80211_STA_INFO_TX_BYTES )))) {
Signature · 1 line
2.30.2
Johannes Berg
maintainerQuoted 6 lines · Issam Hamdi
In station mode, the value
last_rxis not updated often. Therefore the calculation of the inactive time will be wrong (will give values between 1000 ms to 30000 ms).
To fix this add the update of "sta->deflink.rx_stats.last_rx" for station mode in the response of the packets process (ieee80211_rx_h_sta_process).
Not really sure I understand that.
net/mac80211/rx.c ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx) · line 1760
Quoted 7 lines
+++
b/net/mac80211/rx.cnet/mac80211/rx.c +2
-0@@ -1756,6 +1756,9 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx) sta->deflink.rx_stats.last_rate =sta_stats_encode_rate (status); } +if (rx->sdata->vif.type ==NL80211_IFTYPE_STATION ) + sta->deflink.rx_stats.last_rx = jiffies;
Why the interface type check? It's a per-station thing, so why would it not apply here for other types?
net/mac80211/sta_info.c void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo, · line 2434
Quoted 4 lines
net/mac80211/sta_info.c +1
-1sinfo->inactive_time = -jiffies_to_msecs (jiffies -ieee80211_sta_last_active (sta)); +jiffies_to_msecs (abs (jiffies -ieee80211_sta_last_active (sta)));
That seems ... rather questionable.
johannes