Skip to contentSkip to conversation

wifi: mac80211: fix get inactive time for station mode

PATCH In review Issam Hamdi 2 participants 2 messages Jun 28, 2022 – Jul 1, 2022 mac80211

lore
Share & tools
lore
#0 lore raw

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
index d017ad14d7db..6ce899b18614 100644
@@ -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
index 014032369994..88a9f81e7083 100644
@@ -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
maintainer
#1 lore raw
Quoted 6 lines · Issam Hamdi

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).

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.c

net/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 -1
 	sinfo->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