linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: linux-wireless@vger.kernel.org
Cc: Johannes Berg <johannes.berg@intel.com>
Subject: [PATCH 04/28] wifi: mac80211: recalc station aggregate data during link switch
Date: Wed,  5 Oct 2022 15:00:24 +0200	[thread overview]
Message-ID: <20221005145226.0605ef900411.I9354dd019bc87dc98e10b036a03fac844e547ad8@changeid> (raw)
In-Reply-To: <20221005130048.217341-1-johannes@sipsolutions.net>

From: Johannes Berg <johannes.berg@intel.com>

During link switching, the active links change, so we need to
recalculate the aggregate data in the stations.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 net/mac80211/link.c     | 17 +++++++++++++++++
 net/mac80211/sta_info.c | 33 ++++++++++++++++++++++++---------
 net/mac80211/sta_info.h |  2 ++
 3 files changed, 43 insertions(+), 9 deletions(-)

diff --git a/net/mac80211/link.c b/net/mac80211/link.c
index e309708abae8..d1f5a9f7c647 100644
--- a/net/mac80211/link.c
+++ b/net/mac80211/link.c
@@ -357,6 +357,11 @@ static int _ieee80211_set_active_links(struct ieee80211_sub_if_data *sdata,
 	list_for_each_entry(sta, &local->sta_list, list) {
 		if (sdata != sta->sdata)
 			continue;
+
+		/* this is very temporary, but do it anyway */
+		__ieee80211_sta_recalc_aggregates(sta,
+						  old_active | active_links);
+
 		ret = drv_change_sta_links(local, sdata, &sta->sta,
 					   old_active,
 					   old_active | active_links);
@@ -369,10 +374,22 @@ static int _ieee80211_set_active_links(struct ieee80211_sub_if_data *sdata,
 	list_for_each_entry(sta, &local->sta_list, list) {
 		if (sdata != sta->sdata)
 			continue;
+
+		__ieee80211_sta_recalc_aggregates(sta, active_links);
+
 		ret = drv_change_sta_links(local, sdata, &sta->sta,
 					   old_active | active_links,
 					   active_links);
 		WARN_ON_ONCE(ret);
+
+		/*
+		 * Do it again, just in case - the driver might very
+		 * well have called ieee80211_sta_recalc_aggregates()
+		 * from there when filling in the new links, which
+		 * would set it wrong since the vif's active links are
+		 * not switched yet...
+		 */
+		__ieee80211_sta_recalc_aggregates(sta, active_links);
 	}
 
 	for_each_set_bit(link_id, &add, IEEE80211_MLD_MAX_NUM_LINKS) {
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
index e6beaea4075e..2bb6a71c72ef 100644
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -2151,22 +2151,30 @@ void ieee80211_sta_register_airtime(struct ieee80211_sta *pubsta, u8 tid,
 }
 EXPORT_SYMBOL(ieee80211_sta_register_airtime);
 
-void ieee80211_sta_recalc_aggregates(struct ieee80211_sta *pubsta)
+void __ieee80211_sta_recalc_aggregates(struct sta_info *sta, u16 active_links)
 {
-	struct sta_info *sta = container_of(pubsta, struct sta_info, sta);
-	struct ieee80211_link_sta *link_sta;
-	int link_id, i;
 	bool first = true;
+	int link_id;
 
-	if (!pubsta->valid_links || !pubsta->mlo) {
-		pubsta->cur = &pubsta->deflink.agg;
+	if (!sta->sta.valid_links || !sta->sta.mlo) {
+		sta->sta.cur = &sta->sta.deflink.agg;
 		return;
 	}
 
 	rcu_read_lock();
-	for_each_sta_active_link(&sta->sdata->vif, pubsta, link_sta, link_id) {
+	for (link_id = 0; link_id < ARRAY_SIZE((sta)->link); link_id++) {
+		struct ieee80211_link_sta *link_sta;
+		int i;
+
+		if (!(active_links & BIT(link_id)))
+			continue;
+
+		link_sta = rcu_dereference(sta->sta.link[link_id]);
+		if (!link_sta)
+			continue;
+
 		if (first) {
-			sta->cur = pubsta->deflink.agg;
+			sta->cur = sta->sta.deflink.agg;
 			first = false;
 			continue;
 		}
@@ -2185,7 +2193,14 @@ void ieee80211_sta_recalc_aggregates(struct ieee80211_sta *pubsta)
 	}
 	rcu_read_unlock();
 
-	pubsta->cur = &sta->cur;
+	sta->sta.cur = &sta->cur;
+}
+
+void ieee80211_sta_recalc_aggregates(struct ieee80211_sta *pubsta)
+{
+	struct sta_info *sta = container_of(pubsta, struct sta_info, sta);
+
+	__ieee80211_sta_recalc_aggregates(sta, sta->sdata->vif.active_links);
 }
 EXPORT_SYMBOL(ieee80211_sta_recalc_aggregates);
 
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
index 6e672bf9c79d..69820b551668 100644
--- a/net/mac80211/sta_info.h
+++ b/net/mac80211/sta_info.h
@@ -927,6 +927,8 @@ void ieee80211_sta_set_max_amsdu_subframes(struct sta_info *sta,
 					   const u8 *ext_capab,
 					   unsigned int ext_capab_len);
 
+void __ieee80211_sta_recalc_aggregates(struct sta_info *sta, u16 active_links);
+
 enum sta_stats_type {
 	STA_STATS_RATE_TYPE_INVALID = 0,
 	STA_STATS_RATE_TYPE_LEGACY,
-- 
2.37.3


  parent reply	other threads:[~2022-10-05 13:01 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-05 13:00 [PATCH 00/28] wifi: further MLO work Johannes Berg
2022-10-05 13:00 ` [PATCH 01/28] wifi: mac80211: add pointer from link STA to STA Johannes Berg
2022-10-05 13:00 ` [PATCH 02/28] wifi: mac80211: add API to show the link STAs in debugfs Johannes Berg
2022-10-05 13:00 ` [PATCH 03/28] wifi: mac80211: include link address " Johannes Berg
2022-10-05 13:00 ` Johannes Berg [this message]
2022-10-05 13:00 ` [PATCH 05/28] wifi: cfg80211: support reporting failed links Johannes Berg
2022-10-06 10:49   ` Veerendranath Jakkam
2022-10-06 10:51     ` Johannes Berg
2022-10-06 11:09       ` Veerendranath Jakkam
2022-10-06 11:11         ` Johannes Berg
2022-10-06 14:40           ` Veerendranath Jakkam
2022-10-05 13:00 ` [PATCH 06/28] wifi: ieee80211: Support validating ML station profile length Johannes Berg
2022-10-05 13:00 ` [PATCH 07/28] wifi: cfg80211/mac80211: Fix ML element common size calculation Johannes Berg
2022-10-05 13:00 ` [PATCH 08/28] wifi: cfg80211/mac80211: Fix ML element common size validation Johannes Berg
2022-10-05 13:00 ` [PATCH 09/28] wifi: mac80211: Parse station profile from association response Johannes Berg
2022-10-05 13:00 ` [PATCH 10/28] wifi: mac80211: Process association status for affiliated links Johannes Berg
2022-10-05 13:00 ` [PATCH 11/28] wifi: mac80211: wme: use ap_addr instead of deflink BSSID Johannes Berg
2022-10-05 13:00 ` [PATCH 12/28] wifi: mac80211: transmit AddBA with MLD address Johannes Berg
2022-10-05 13:00 ` [PATCH 13/28] wifi: nl80211: use link ID in NL80211_CMD_SET_BSS Johannes Berg
2022-10-05 13:00 ` [PATCH 14/28] wifi: mac80211: use link_id in ieee80211_change_bss() Johannes Berg
2022-10-05 13:00 ` [PATCH 15/28] wifi: mac80211: advertise TWT requester only with HW support Johannes Berg
2022-10-05 13:00 ` [PATCH 16/28] wifi: mac80211: set internal scan request BSSID Johannes Berg
2022-10-05 13:00 ` [PATCH 17/28] wifi: mac80211: fix AddBA response addressing Johannes Berg
2022-10-05 13:00 ` [PATCH 18/28] wifi: mac80211: add RCU _check() link access variants Johannes Berg
2022-10-05 13:00 ` [PATCH 19/28] wifi: fix multi-link element subelement iteration Johannes Berg
2022-10-05 13:00 ` [PATCH 20/28] wifi: mac80211: mlme: fix null-ptr deref on failed assoc Johannes Berg
2022-10-05 13:00 ` [PATCH 21/28] wifi: mac80211: check link ID in auth/assoc continuation Johannes Berg
2022-10-05 13:00 ` [PATCH 22/28] wifi: mac80211: mlme: mark assoc link in output Johannes Berg
2022-10-05 13:00 ` [PATCH 23/28] wifi: mac80211: change AddBA deny error message Johannes Berg
2022-10-05 13:00 ` [PATCH 24/28] wifi: mac80211: don't clear DTIM period after setting it Johannes Berg
2022-10-05 13:00 ` [PATCH 25/28] wifi: mac80211: prohibit IEEE80211_HT_CAP_DELAY_BA with MLO Johannes Berg
2022-10-05 13:00 ` [PATCH 26/28] wifi: mac80211: agg-rx: avoid band check Johannes Berg
2022-10-05 13:00 ` [PATCH 27/28] wifi: mac80211: remove support for AddBA with fragmentation Johannes Berg
2022-10-05 13:00 ` [PATCH 28/28] wifi: mac80211: fix ifdef symbol name Johannes Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221005145226.0605ef900411.I9354dd019bc87dc98e10b036a03fac844e547ad8@changeid \
    --to=johannes@sipsolutions.net \
    --cc=johannes.berg@intel.com \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).