On Mon, 2025-02-10 at 10:48 +0100, Pablo MARTIN-GOMEZ wrote: > On 20/01/2025 12:45, Pablo Martin-Gomez wrote: > > - /* on 2.4 GHz, if it supports 40 MHz, the result is 3 */ > > - if (he_cap->phy_cap_info[0] & > > - IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_IN_2G) > > - return 3; > > + /* 20 MHz-only non-AP STA */ > > + if (!from_ap && (he_cap->phy_cap_info[0] & > > + (IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_IN_2G | > > + IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_80MHZ_IN_5G | > > + IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G | > > + IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G)) == 0) > > + return 4; > > > > - /* on 2.4 GHz, these three bits are reserved, so should be 0 */ > > if (he_cap->phy_cap_info[0] & > > - IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_80MHZ_IN_5G) > > + (IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_IN_2G | > > + IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_80MHZ_IN_5G)) > > count += 3; > > > > if (he_cap->phy_cap_info[0] & > > This patch is still reading reserved bits depending on the band being > used. I wanted to do a new version of the patch to avoid doing that by > passing the current band to ieee80211_eht_mcs_nss_size(). Unfortunately, > ieee80211_eht_mcs_nss_size() is called by ieee80211_eht_capa_size_ok() > which itself is called in places where the band is not known. So I'm not > sure I can do better than this. > Took me some time to look into this, but I don't think the band needs to be unknown. I'd still split this and use the existing version for *local* data, such as callers in net/wireless/nl80211.c, and have the band used for parsing in net/mac80211/parse.c. We already pass e.g. "from_ap" in the parsing context, so we can have the band too. Most callers aren't even affected since they don't need to parse this, it'd only be those in net/mac80211/mlme.c, and we can default to NUM_NL80211_BANDS (unknown) for ieee802_11_parse_elems_crc(). Want to take a stab at that? johannes