From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.177 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795956631; b=0XwJ9v3xoJqfCi2a22KGIAZmJLRoeeZu1LpayyFHnvAa3ECbZCFGs/uU9rGRT77ha19y HsyxvHuNnc5hhD63f6uvuYXbNaQSwbOqjzKwpBvUIK0ZJK08nKnnaJ9Ru0cI1wHD4EQX7 y3i1IeiJZ5h9Cs0A90UuK//Cj/X44UC7Qh9iW4oPpSqd/Z7aNcTnTTPrIdhC510A2hki0 sib4vdHZkR0GkSkacGYmXPVeLwxl2ibDEefS/OTX9kxbKbcJUpvUp+pxSth4EqS9CR4Nz 76f3ug5tx+/e8lCXsqteHW/PuILjTKzWoO0ebYR1Mk3DN/tuvh9mvEYgzvLUHe+T0Rw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795956631; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding; bh=P1sEa9RLIj77SbnEXxWB3ZwT51xdc+Kvy/Vv9efYz34=; b=S236phSutW9/rUmR1vPhKJGYnIkHh6aSEOd/subIPYwnR5IF33yIUqVx2lMAw0gFiu8s r1/VlTo2pWCW3cRbwmDGQcDsvUYAZ8epasPvDbGlirUqB0/Rb7EhpC60mBtVwQerUnTIE HhDU85T24SkK55IbPvgNTBKl0iVDZpXACBhw2g2Obtb+ZwD+YVKx9Lnc2Z16d2KC6LNAK Luv2ZCmU96uR5tTguwIcyVpHOcyYa2JKEIMyt8z98lL1TRovwGpLT1Oi33AuqYu4O2+bE h+0AJG/bVKJTWeW2NTfAuIAz7K3UsXhH9NHjAKgSsvelTsd37xCj+MBIY8hlOObq32A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=aN6IkeDT; arc=none smtp.remote-ip=74.125.82.177 Received: from mail-dy1-f177.google.com (mail-dy1-f177.google.com [74.125.82.177]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0FA22606A323 for ; Sun, 29 Nov 2026 12:50:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0FA22606A323 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=aN6IkeDT Received: by mail-dy1-f177.google.com with SMTP id 5a478bee46e88-33bf40b0c8bso1584279eec.0 for ; Sun, 29 Nov 2026 04:50:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795956630; x=1796561430; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=P1sEa9RLIj77SbnEXxWB3ZwT51xdc+Kvy/Vv9efYz34=; b=aN6IkeDTrl4dQSh87hpABYK33kkCF8OfQD1u8lxpJ6KP2tNrpWWpY+wcVAoS2zMqBE 6cX4L+TCadQKG0C/M2NXxf2IdgoYB2ntpmktbH8w53LUZTaqGDdEx0tEkSNkD9f32XSp fSRMAbOMnMUB1d8hqmZmt0/a/21bNPX/FJ1zO7LfyPVB/c/gMRrvGVaX0hkl8USphZJL 3f+1bxZcnw/E5+uDviWpD+bz8euBHvyo4ttQ39o9x+EGgIZBywvVLRLS3JmMwlB7osxW iBpXCn1ek/1AA/Ue9p4eb06MGvmepZzFk5CeQEDHVohAzAt25sMVt3a/lXJPP0MjiRZ9 jn9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795956630; x=1796561430; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=P1sEa9RLIj77SbnEXxWB3ZwT51xdc+Kvy/Vv9efYz34=; b=W+7gSEPudff3UcOEk5r30Po1NLPjxHURMIHkP6cXXWPUqhR+vTAKeoxv1rF1jWZ8Ho VWuwd4Wait0UKoJ1Ut+mFA4zpNAhdxRqUVKHRUQzFIVww3Qqojr2scedLPdErTEEA4LR 4K7A/H6K3Ufkb01MIei5sIOqASZODPn5UNWztQ0fi3rbAzMp2Dnuc0lALIyw7LPda1tA FvPjHpuyIWfcnWN6L9g/qa1OEcslbKCWebxIKf3pSDxkAKYW/itUmxt9D7jQ2rygp9pb MvIqKYy0sIGruLPqNHuOUjrRjNA8ijEhETBvsHLnxm1fOEEZfGIHlDFN6G4O8U0krIqq +y0w== X-Gm-Message-State: APuU4Z+a/l2Qc53WmQHi/Qkb8o18cW3gjvaJRnwBWAiizk2bxPkWNx3x QBym+0nIkpSF5bJm8GofvniYXy4KUNoZidRPjq44K3thqeUAEshVrSlZ X-Gm-Gg: AZFdTZca9ukGgEFL3gL3yhCM3yJFLuspOJKcFgTE3MVIUIYGMNXsW9hwSuBzWTR2qc+ cptHiAKj+knWD+uYhA9Wl1sa4qE/q5bjkgIu+3dgieLbgpImJ8VL2kt9jYrSYJK5gz6zmZSZS1w BWw9th23RZXLkBsOpj0W+rFQsCX/WR0pYCYlU/NG+ls77BMc7I/RIkdOH6XcIxh6bwiElsndHCS bWihYnKQNvu5uFHSDDnFwLK42VZ44cmqjFvwl9YIAnH03gDVmg+2xyjhq/JxjALLbhPFLSRgP13 bvnDrJxEaPOTJGL07+c9PCGnBq6+ps2Ar4ex1X26onJ2SKh1IhQ0/btfGFUJmBAw1JtBTyzxufa pI3ISIT6V2UiOeZ88dPhMMk5oihCrt1C42fp30cbpIMd26T331gcUgQx0ZJ0hQmgnR/mjDTQ1Xp zbWvoj15phqX4qrdse/GP6wn6GgEv/Q26THst0YQdnsCy5tosrNS00hZ/jl+I+r20EIyfQ2/HCB /0Veu3f+fj7kqmK6BLG2hQ5GZarSTPRsUFaMmoGdg46eneK+XNoS3dpsxokT9KPgm7ZScCfnpDG n5uMFzsbbkENdhWgQydcZsilVb/qYO4pubyRf3VMUVMmYE39A3cMX+Yzm4g46s5XYrUYUmLmKzN IGHntoXSpEM3WpFcHXKrliLRzX8s= X-Received: by 2002:a05:7300:c3aa:b0:385:c28b:a4d5 with SMTP id 5a478bee46e88-385c28baffbmr31252447eec.17.1795956629896; Sun, 29 Nov 2026 04:50:29 -0800 (PST) Received: from acemagic-m1.lan ([2401:7400:c804:b668:671c:1b55:418e:d0e4]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-385f68bc0adsm85362930eec.13.2026.11.29.04.50.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2026 04:50:29 -0800 (PST) From: Ho Jie Feng To: Johannes Berg Cc: linux-wireless@vger.kernel.org, Ho Jie Feng Subject: [RFC PATCH wireless-next] wifi: mac80211: follow the BSS color of the AP's beacons Date: Sun, 29 Nov 2026 20:50:21 +0800 Message-ID: <20261129125021.2677784-1-hjf3108@gmail.com> X-Mailer: git-send-email 2.53.0 X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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