* [RFC PATCH wireless-next] wifi: mac80211: follow the BSS color of the AP's beacons
@ 2026-11-29 12:50 Ho Jie Feng
0 siblings, 0 replies; only message in thread
From: Ho Jie Feng @ 2026-11-29 12:50 UTC (permalink / raw)
To: Johannes Berg; +Cc: linux-wireless, Ho Jie Feng
A station sets bss_conf->he_bss_color only from the HE Operation element
of the (Re)Association Response. When the AP changes its BSS color,
the update is not processed in the mac80211 stack, and the driver
is never notified. Most drivers upstream handle this in their firmware,
but drivers such as rtw89 do not, and so the connection will drop
until it reassociates.
Parse the BSS color change in ieee80211_rx_mgmt_beacon(), and notify
the driver of it. The parsing has to happen even when the CRC is
the same since the CRC does not cover the element for color change.
Therefore, elements in the profile can also change without changing
the CRC.
The CRC same path now calls ieee80211_link_info_change_notify()
unconditionally, but it returns immediately if changed is 0, and the
only other flag set before the CRC check is BSS_CHANGED_P2P_PS, where
setting it also clears beacon_crc_valid, where the CRC check fails.
Known caveats:
The station switches on the first usable beacon with the new color.
Switching on the BSS Color Change Announcement countdown would need a
timer like the one used for channel switches.
Same CRC beacon can also change WMM and MU EDCA parameters.
This requires some interaction with S1G checks, so due to the
complexity of the change, this is left out
Testing:
rtw89 with RTL8852CE. Previously, on a color change, it drops the
connection and requires a reassociation. With this patch and a
separate patch to rtw89 to put the new color into the device,
it stays connected.
---
net/mac80211/mlme.c | 60 +++++++++++++++++++++++++++++++++++----------
1 file changed, 47 insertions(+), 13 deletions(-)
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 4ea214e250..be99493547 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -5897,6 +5897,39 @@ static bool ieee80211_twt_bcast_support(struct ieee80211_sub_if_data *sdata,
IEEE80211_HE_MAC_CAP2_BCAST_TWT);
}
+static void
+ieee80211_he_oper_to_bss_color(const struct ieee80211_he_operation *he_oper,
+ struct cfg80211_he_bss_color *bss_color)
+{
+ bss_color->color = le32_get_bits(he_oper->he_oper_params,
+ IEEE80211_HE_OPERATION_BSS_COLOR_MASK);
+ bss_color->partial = le32_get_bits(he_oper->he_oper_params,
+ IEEE80211_HE_OPERATION_PARTIAL_BSS_COLOR);
+ bss_color->enabled = !le32_get_bits(he_oper->he_oper_params,
+ IEEE80211_HE_OPERATION_BSS_COLOR_DISABLED);
+}
+
+static u64
+ieee80211_recalc_he_bss_color(struct ieee80211_link_data *link,
+ const struct ieee80211_he_operation *he_oper)
+{
+ struct cfg80211_he_bss_color *cur = &link->conf->he_bss_color;
+ struct cfg80211_he_bss_color new;
+
+ ieee80211_he_oper_to_bss_color(he_oper, &new);
+
+ if (new.color == cur->color && new.partial == cur->partial &&
+ new.enabled == cur->enabled)
+ return 0;
+
+ link_dbg(link, "AP changed BSS color %u%s to %u%s\n",
+ cur->color, cur->enabled ? "" : " (disabled)",
+ new.color, new.enabled ? "" : " (disabled)");
+
+ *cur = new;
+ return BSS_CHANGED_HE_BSS_COLOR;
+}
+
static void ieee80211_epcs_changed(struct ieee80211_sub_if_data *sdata,
bool enabled)
{
@@ -6390,15 +6423,8 @@ bool ieee80211_assoc_config_link(struct ieee80211_mgd_assoc_data *assoc_data,
ieee80211_twt_bcast_support(sdata, bss_conf, sband, link_sta);
if (bss_conf->he_support) {
- bss_conf->he_bss_color.color =
- le32_get_bits(elems->he_operation->he_oper_params,
- IEEE80211_HE_OPERATION_BSS_COLOR_MASK);
- bss_conf->he_bss_color.partial =
- le32_get_bits(elems->he_operation->he_oper_params,
- IEEE80211_HE_OPERATION_PARTIAL_BSS_COLOR);
- bss_conf->he_bss_color.enabled =
- !le32_get_bits(elems->he_operation->he_oper_params,
- IEEE80211_HE_OPERATION_BSS_COLOR_DISABLED);
+ ieee80211_he_oper_to_bss_color(elems->he_operation,
+ &bss_conf->he_bss_color);
if (bss_conf->he_bss_color.enabled)
*changed |= BSS_CHANGED_HE_BSS_COLOR;
@@ -8842,11 +8868,15 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_link_data *link,
bss_conf->sync_dtim_count = elems->dtim_count;
}
- if ((ncrc == link->u.mgd.beacon_crc && link->u.mgd.beacon_crc_valid) ||
- (ext && ieee80211_is_s1g_short_beacon(ext->frame_control,
- parse_params.start,
- parse_params.len)))
+ /* Our EMA profile may reappear or change with the same CRC. */
+ if (ncrc == link->u.mgd.beacon_crc && link->u.mgd.beacon_crc_valid)
+ goto apply;
+
+ if (ext && ieee80211_is_s1g_short_beacon(ext->frame_control,
+ parse_params.start,
+ parse_params.len))
goto free;
+
link->u.mgd.beacon_crc = ncrc;
link->u.mgd.beacon_crc_valid = true;
@@ -8994,6 +9024,10 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_link_data *link,
goto free;
apply:
+ if (bss_conf->he_support && !elems->mbssid_nontx_profile_missing &&
+ elems->he_operation)
+ changed |= ieee80211_recalc_he_bss_color(link, elems->he_operation);
+
ieee80211_link_info_change_notify(sdata, link, changed);
free:
kfree(elems);
base-commit: 18d0bedbb5f0538396cb7f763ed9cd1dd69c5b23
--
2.53.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-29 12:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29 12:50 [RFC PATCH wireless-next] wifi: mac80211: follow the BSS color of the AP's beacons Ho Jie Feng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox