wifi: mac80211: refactor populating mesh related fields in sinfo
authorSarika Sharma <quic_sarishar@quicinc.com>
Thu, 13 Feb 2025 17:16:22 +0000 (22:46 +0530)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 28 Feb 2025 13:09:51 +0000 (14:09 +0100)
Introduce the sta_set_mesh_sinfo() to populate mesh related
fields in sinfo structure for station statistics.
This will allow for the simplified population of other fields in the
sinfo structure for link level in a subsequent patch to add support
for MLO station statistics.
No functionality changes added.

Signed-off-by: Sarika Sharma <quic_sarishar@quicinc.com>
Link: https://patch.msgid.link/20250213171632.1646538-3-quic_sarishar@quicinc.com
[reword since it's just an internal thing]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/sta_info.c

index f83268fa9f928ec468c0d4510d088ed9ea56b400..a4b4506cd35bac26418f050dc8e5eb48e4849cd0 100644 (file)
@@ -2584,6 +2584,39 @@ static inline u64 sta_get_stats_bytes(struct ieee80211_sta_rx_stats *rxstats)
        return value;
 }
 
+#ifdef CONFIG_MAC80211_MESH
+static void sta_set_mesh_sinfo(struct sta_info *sta,
+                              struct station_info *sinfo)
+{
+       struct ieee80211_local *local = sta->sdata->local;
+
+       sinfo->filled |= BIT_ULL(NL80211_STA_INFO_LLID) |
+                        BIT_ULL(NL80211_STA_INFO_PLID) |
+                        BIT_ULL(NL80211_STA_INFO_PLINK_STATE) |
+                        BIT_ULL(NL80211_STA_INFO_LOCAL_PM) |
+                        BIT_ULL(NL80211_STA_INFO_PEER_PM) |
+                        BIT_ULL(NL80211_STA_INFO_NONPEER_PM) |
+                        BIT_ULL(NL80211_STA_INFO_CONNECTED_TO_GATE) |
+                        BIT_ULL(NL80211_STA_INFO_CONNECTED_TO_AS);
+
+       sinfo->llid = sta->mesh->llid;
+       sinfo->plid = sta->mesh->plid;
+       sinfo->plink_state = sta->mesh->plink_state;
+       if (test_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN)) {
+               sinfo->filled |= BIT_ULL(NL80211_STA_INFO_T_OFFSET);
+               sinfo->t_offset = sta->mesh->t_offset;
+       }
+       sinfo->local_pm = sta->mesh->local_pm;
+       sinfo->peer_pm = sta->mesh->peer_pm;
+       sinfo->nonpeer_pm = sta->mesh->nonpeer_pm;
+       sinfo->connected_to_gate = sta->mesh->connected_to_gate;
+       sinfo->connected_to_as = sta->mesh->connected_to_as;
+
+       sinfo->filled |= BIT_ULL(NL80211_STA_INFO_AIRTIME_LINK_METRIC);
+       sinfo->airtime_link_metric = airtime_link_metric_get(local, sta);
+}
+#endif
+
 void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo,
                   bool tidstats)
 {
@@ -2768,31 +2801,10 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo,
                        sta_set_tidstats(sta, &sinfo->pertid[i], i);
        }
 
-       if (ieee80211_vif_is_mesh(&sdata->vif)) {
 #ifdef CONFIG_MAC80211_MESH
-               sinfo->filled |= BIT_ULL(NL80211_STA_INFO_LLID) |
-                                BIT_ULL(NL80211_STA_INFO_PLID) |
-                                BIT_ULL(NL80211_STA_INFO_PLINK_STATE) |
-                                BIT_ULL(NL80211_STA_INFO_LOCAL_PM) |
-                                BIT_ULL(NL80211_STA_INFO_PEER_PM) |
-                                BIT_ULL(NL80211_STA_INFO_NONPEER_PM) |
-                                BIT_ULL(NL80211_STA_INFO_CONNECTED_TO_GATE) |
-                                BIT_ULL(NL80211_STA_INFO_CONNECTED_TO_AS);
-
-               sinfo->llid = sta->mesh->llid;
-               sinfo->plid = sta->mesh->plid;
-               sinfo->plink_state = sta->mesh->plink_state;
-               if (test_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN)) {
-                       sinfo->filled |= BIT_ULL(NL80211_STA_INFO_T_OFFSET);
-                       sinfo->t_offset = sta->mesh->t_offset;
-               }
-               sinfo->local_pm = sta->mesh->local_pm;
-               sinfo->peer_pm = sta->mesh->peer_pm;
-               sinfo->nonpeer_pm = sta->mesh->nonpeer_pm;
-               sinfo->connected_to_gate = sta->mesh->connected_to_gate;
-               sinfo->connected_to_as = sta->mesh->connected_to_as;
+       if (ieee80211_vif_is_mesh(&sdata->vif))
+               sta_set_mesh_sinfo(sta, sinfo);
 #endif
-       }
 
        sinfo->bss_param.flags = 0;
        if (sdata->vif.bss_conf.use_cts_prot)
@@ -2848,12 +2860,6 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo,
                sinfo->filled |=
                        BIT_ULL(NL80211_STA_INFO_ACK_SIGNAL_AVG);
        }
-
-       if (ieee80211_vif_is_mesh(&sdata->vif)) {
-               sinfo->filled |= BIT_ULL(NL80211_STA_INFO_AIRTIME_LINK_METRIC);
-               sinfo->airtime_link_metric =
-                       airtime_link_metric_get(local, sta);
-       }
 }
 
 u32 sta_get_expected_throughput(struct sta_info *sta)