Commit e5328c14 authored by Sarika Sharma's avatar Sarika Sharma Committed by Johannes Berg
Browse files

wifi: mac80211: refactor populating mesh related fields in sinfo



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: default avatarSarika 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: default avatarJohannes Berg <johannes.berg@intel.com>
parent 23ff5f6f
Loading
Loading
Loading
Loading
+35 −29
Original line number Diff line number Diff line
@@ -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)