wifi: mac80211: refactor STA CSA parsing flows
authorMichael-CY Lee <michael-cy.lee@mediatek.com>
Fri, 22 Dec 2023 01:09:14 +0000 (09:09 +0800)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 8 Feb 2024 14:00:45 +0000 (15:00 +0100)
commit21c3f8f95554feff9bed15703e89adbe582e0383
tree979775a3911184d4d9b9931f1ba44c79be046592
parent68de13028b94572fc570b7eb1e0e2de1d751fe7e
wifi: mac80211: refactor STA CSA parsing flows

The new Wi-Fi Standard (IEEE Std 802.11-2020 9.4.2.160) specifies that
the Wide Bandwidth Channel Switch (WBCS) Element subfields have the same
definitions as VHT operation information if the operating band is not
S1G.

The problem comes when the BSS is in 6 GHz band, the STA parses the WBCS
Element by ieee80211_chandef_vht_oper(), which checks the capabilities for
HT/VHT mode, not HE/EHT mode.

This patch refactors STA CSA parsing flow so that the corresponding
capabilities can be checked. Also, it adds the way to use op_class in ECSA
Element to build a new chandef.

In summary, the new steps for STA to handle CSA event are:
1. build the new chandef from one of the CSA-related (Sub)Elements in
   following order,
   - Bandwidth Indication (Sub)Element
   - Wide Bandwidth Channel Switch (Sub)Element
   - Operating class in Extended Channel Switch Announcement Element
   - Channel Switch Announcement Element
2. convert the new chandef into operation information according to the
   operating band in order to check if the new chandef fits STA's
   capabilities.
3. downgrade the bandwidth until current bandwidth is not disabled.

Co-developed-by: Money Wang <money.wang@mediatek.com>
Signed-off-by: Michael-CY Lee <michael-cy.lee@mediatek.com>
Link: https://msgid.link/20231222010914.6521-3-michael-cy.lee@mediatek.com
[rebase on top of the changes with struct ieee80211_conn_settings,
 prefer leXY_encode_bits()]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/spectmgmt.c