From cf0f4dc260afc27b0fad0ebdc264e01eb947434f Mon Sep 17 00:00:00 2001 From: vlad Date: Wed, 2 Dec 2026 09:17:26 +0200 Subject: [PATCH 1/2] wifi: apple: centauri: t6050: take HT, VHT and HE band caps from firmware The 2.4 and 5 GHz bands were registered without HT, VHT or HE capabilities; only 6 GHz had HE. The firmware already reports all three in its capabilities reply (system command 8): the HT element at offset 87 of TLV 262, the VHT element in TLV 0xbf and the HE element in TLV 0xff. Port band_caps_from_firmware() from the shared-transport driver: HT on 2.4 and 5 GHz, VHT on 5 GHz, HE on all three bands with 40 MHz and 160 MHz masked on 2.4 GHz, and the 6 GHz band caps as before. A missing element leaves its band as it was; without HE there is still no 6 GHz. Signed-off-by: vlad --- .../apple/centauri/t6050/centauri_wifi.c | 141 +++++++++++++----- 1 file changed, 101 insertions(+), 40 deletions(-) diff --git a/drivers/net/wireless/apple/centauri/t6050/centauri_wifi.c b/drivers/net/wireless/apple/centauri/t6050/centauri_wifi.c index 9c6b2339e2078..05aa3d876f478 100644 --- a/drivers/net/wireless/apple/centauri/t6050/centauri_wifi.c +++ b/drivers/net/wireless/apple/centauri/t6050/centauri_wifi.c @@ -124,7 +124,8 @@ struct centauri_t6050_wifi { u8 tx_defaults_applied; struct ieee80211_supported_band bands[3]; struct ieee80211_channel channels[CEN_CHANNELS]; - struct ieee80211_sband_iftype_data iftype_6ghz; + /* The station's HE capabilities per band: 2.4, 5 and 6 GHz. */ + struct ieee80211_sband_iftype_data iftype_data[3]; /* The firmware's own reports, read at bring-up (system commands 19 and 8). */ u8 hw_channels[REPLY_SIZE], system_caps[REPLY_SIZE]; struct debugfs_blob_wrapper hw_channels_blob, system_caps_blob; @@ -1119,16 +1120,21 @@ static void country_set(struct centauri_t6050_wifi *wifi, const u8 country[3]) } /* - * 6 GHz needs HE: the station's HE capabilities element as the firmware - * reports it (capabilities TLV 0xff), with the 6 GHz band capabilities taken - * from its VHT element (TLV 0xbf). Without them the band is not registered. + * The station's HT, VHT and HE capabilities as the firmware reports them + * (system command 8): the HT element at offset 87 of TLV 262, the VHT element + * (TLV 0xbf) and the HE capabilities element (TLV 0xff). HT applies to 2.4 and + * 5 GHz, VHT to 5 GHz and HE to all three bands, without 40 MHz on 2.4 GHz + * where the firmware does not list it and without 160 MHz there. The 6 GHz + * band capabilities come from the VHT element. A band keeps what it has when + * its element is missing; without HE, 6 GHz is not registered. */ -static bool he_6ghz_from_firmware(struct centauri_t6050_wifi *wifi) +static bool band_caps_from_firmware(struct centauri_t6050_wifi *wifi) { - struct ieee80211_sband_iftype_data *data = &wifi->iftype_6ghz; - struct ieee80211_sta_he_cap *he = &data->he_cap; - const u8 *caps = wifi->system_caps, *he_elem = NULL, *vht = NULL; + const u8 *caps = wifi->system_caps; + const u8 *ht_elem = NULL, *vht_elem = NULL, *he_elem = NULL; size_t size = wifi->system_caps_blob.size, pos = 0, mcs; + struct ieee80211_sta_he_cap base_he = {}; + unsigned int band; u32 vht_cap = 0; while (pos + 4 <= size) { @@ -1138,43 +1144,100 @@ static bool he_6ghz_from_firmware(struct centauri_t6050_wifi *wifi) if (length > size - pos - 4) break; + if (tag == 262 && + length >= 87 + 2 + sizeof(struct ieee80211_ht_cap) && + value[87] == WLAN_EID_HT_CAPABILITY && + value[88] == sizeof(struct ieee80211_ht_cap)) + ht_elem = value + 87; + if (tag == WLAN_EID_VHT_CAPABILITY && + length >= 2 + sizeof(struct ieee80211_vht_cap) && + value[0] == WLAN_EID_VHT_CAPABILITY && + value[1] == sizeof(struct ieee80211_vht_cap)) + vht_elem = value; if (tag == WLAN_EID_EXTENSION && length >= 3 + 6 + 11 + 4 && value[0] == WLAN_EID_EXTENSION && value[1] == length - 2 && value[2] == WLAN_EID_EXT_HE_CAPABILITY) he_elem = value; - if (tag == WLAN_EID_VHT_CAPABILITY && length >= 2 + 12 && - value[0] == WLAN_EID_VHT_CAPABILITY) - vht = value; pos += 4 + length; } + + if (ht_elem) { + const struct ieee80211_ht_cap *ht = + (const struct ieee80211_ht_cap *)(ht_elem + 2); + struct ieee80211_sta_ht_cap ht_cap = { + .ht_supported = true, + .cap = le16_to_cpu(ht->cap_info), + .ampdu_factor = ht->ampdu_params_info & + IEEE80211_HT_AMPDU_PARM_FACTOR, + .ampdu_density = FIELD_GET(IEEE80211_HT_AMPDU_PARM_DENSITY, + ht->ampdu_params_info), + .mcs = ht->mcs, + }; + + wifi->bands[0].ht_cap = ht_cap; + wifi->bands[1].ht_cap = ht_cap; + } + + if (vht_elem) { + struct ieee80211_sta_vht_cap *vht = &wifi->bands[1].vht_cap; + + vht_cap = get_unaligned_le32(vht_elem + 2); + vht->vht_supported = true; + vht->cap = vht_cap; + memcpy(&vht->vht_mcs, vht_elem + 6, sizeof(vht->vht_mcs)); + } + if (!he_elem) return false; - memcpy(&he->he_cap_elem, he_elem + 3, sizeof(he->he_cap_elem)); - mcs = he_elem[1] - 1 - sizeof(he->he_cap_elem); - memcpy(&he->he_mcs_nss_supp, he_elem + 3 + sizeof(he->he_cap_elem), - min(mcs, sizeof(he->he_mcs_nss_supp))); - if (mcs > sizeof(he->he_mcs_nss_supp)) - memcpy(he->ppe_thres, - he_elem + 3 + sizeof(he->he_cap_elem) + - sizeof(he->he_mcs_nss_supp), - min(mcs - sizeof(he->he_mcs_nss_supp), - sizeof(he->ppe_thres))); - he->has_he = true; - if (vht) - vht_cap = get_unaligned_le32(vht + 2); - data->he_6ghz_capa.capa = cpu_to_le16( - u16_encode_bits(u32_get_bits(vht_cap, - IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK), - IEEE80211_HE_6GHZ_CAP_MAX_AMPDU_LEN_EXP) | - u16_encode_bits(vht_cap & IEEE80211_VHT_CAP_MAX_MPDU_MASK, - IEEE80211_HE_6GHZ_CAP_MAX_MPDU_LEN) | - u16_encode_bits(WLAN_HT_CAP_SM_PS_DISABLED, - IEEE80211_HE_6GHZ_CAP_SM_PS) | - (vht_cap & IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN ? - IEEE80211_HE_6GHZ_CAP_RX_ANTPAT_CONS : 0) | - (vht_cap & IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN ? - IEEE80211_HE_6GHZ_CAP_TX_ANTPAT_CONS : 0)); - data->types_mask = BIT(NL80211_IFTYPE_STATION); + + memcpy(&base_he.he_cap_elem, he_elem + 3, sizeof(base_he.he_cap_elem)); + mcs = he_elem[1] - 1 - sizeof(base_he.he_cap_elem); + memcpy(&base_he.he_mcs_nss_supp, + he_elem + 3 + sizeof(base_he.he_cap_elem), + min(mcs, sizeof(base_he.he_mcs_nss_supp))); + if (mcs > sizeof(base_he.he_mcs_nss_supp)) + memcpy(base_he.ppe_thres, + he_elem + 3 + sizeof(base_he.he_cap_elem) + + sizeof(base_he.he_mcs_nss_supp), + min(mcs - sizeof(base_he.he_mcs_nss_supp), + sizeof(base_he.ppe_thres))); + base_he.has_he = true; + + for (band = 0; band < ARRAY_SIZE(wifi->iftype_data); band++) { + struct ieee80211_sband_iftype_data *data = + &wifi->iftype_data[band]; + struct ieee80211_he_mcs_nss_supp *he_mcs = + &data->he_cap.he_mcs_nss_supp; + + memset(data, 0, sizeof(*data)); + data->types_mask = BIT(NL80211_IFTYPE_STATION); + data->he_cap = base_he; + if (band == 0) { + data->he_cap.he_cap_elem.phy_cap_info[0] &= + IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_IN_2G; + he_mcs->rx_mcs_160 = cpu_to_le16(0xffff); + he_mcs->tx_mcs_160 = cpu_to_le16(0xffff); + he_mcs->rx_mcs_80p80 = cpu_to_le16(0xffff); + he_mcs->tx_mcs_80p80 = cpu_to_le16(0xffff); + } else { + data->he_cap.he_cap_elem.phy_cap_info[0] &= + ~IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_IN_2G; + } + if (band == 2) + data->he_6ghz_capa.capa = cpu_to_le16( + u16_encode_bits(u32_get_bits(vht_cap, + IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK), + IEEE80211_HE_6GHZ_CAP_MAX_AMPDU_LEN_EXP) | + u16_encode_bits(vht_cap & IEEE80211_VHT_CAP_MAX_MPDU_MASK, + IEEE80211_HE_6GHZ_CAP_MAX_MPDU_LEN) | + u16_encode_bits(WLAN_HT_CAP_SM_PS_DISABLED, + IEEE80211_HE_6GHZ_CAP_SM_PS) | + (vht_cap & IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN ? + IEEE80211_HE_6GHZ_CAP_RX_ANTPAT_CONS : 0) | + (vht_cap & IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN ? + IEEE80211_HE_6GHZ_CAP_TX_ANTPAT_CONS : 0)); + _ieee80211_set_sband_iftype_data(&wifi->bands[band], data, 1); + } return true; } @@ -1216,9 +1279,7 @@ static void bands_init(struct centauri_t6050_wifi *wifi) } wifi->wiphy->bands[NL80211_BAND_2GHZ] = &wifi->bands[0]; wifi->wiphy->bands[NL80211_BAND_5GHZ] = &wifi->bands[1]; - if (he_6ghz_from_firmware(wifi)) { - _ieee80211_set_sband_iftype_data(&wifi->bands[2], - &wifi->iftype_6ghz, 1); + if (band_caps_from_firmware(wifi)) { wifi->wiphy->bands[NL80211_BAND_6GHZ] = &wifi->bands[2]; } else { dev_warn(&wifi->control->pdev->dev, From a040d04c0562f56783627366cc1f6622db6a89f3 Mon Sep 17 00:00:00 2001 From: vlad Date: Wed, 2 Dec 2026 09:35:50 +0200 Subject: [PATCH 2/2] wifi: apple: centauri: t6050: trim the 2.4 GHz HE caps and size the HE maps The firmware HE element lists 160 MHz features: punctured preamble, beamformee sounding above 80 MHz and the 160 MHz PPDU bits. Clear them in the 2.4 GHz copy, which can only use 20 and 40 MHz. Check the element with ieee80211_he_capa_size_ok() and read only the MCS maps its width set lists, so PPE bytes are never taken for a map and a map the element leaves out stays unsupported. Give the 6 GHz capability the minimum MPDU start spacing from the HT element. Signed-off-by: vlad --- .../apple/centauri/t6050/centauri_wifi.c | 45 +++++++++++++------ 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/drivers/net/wireless/apple/centauri/t6050/centauri_wifi.c b/drivers/net/wireless/apple/centauri/t6050/centauri_wifi.c index 05aa3d876f478..80ce3fca3bafc 100644 --- a/drivers/net/wireless/apple/centauri/t6050/centauri_wifi.c +++ b/drivers/net/wireless/apple/centauri/t6050/centauri_wifi.c @@ -1132,10 +1132,11 @@ static bool band_caps_from_firmware(struct centauri_t6050_wifi *wifi) { const u8 *caps = wifi->system_caps; const u8 *ht_elem = NULL, *vht_elem = NULL, *he_elem = NULL; - size_t size = wifi->system_caps_blob.size, pos = 0, mcs; + size_t size = wifi->system_caps_blob.size, pos = 0, mcs, ppe; struct ieee80211_sta_he_cap base_he = {}; unsigned int band; u32 vht_cap = 0; + u8 ampdu_density = 0; while (pos + 4 <= size) { u16 tag = get_unaligned_le16(caps + pos); @@ -1156,7 +1157,8 @@ static bool band_caps_from_firmware(struct centauri_t6050_wifi *wifi) vht_elem = value; if (tag == WLAN_EID_EXTENSION && length >= 3 + 6 + 11 + 4 && value[0] == WLAN_EID_EXTENSION && value[1] == length - 2 && - value[2] == WLAN_EID_EXT_HE_CAPABILITY) + value[2] == WLAN_EID_EXT_HE_CAPABILITY && + ieee80211_he_capa_size_ok(value + 3, value[1] - 1)) he_elem = value; pos += 4 + length; } @@ -1176,6 +1178,7 @@ static bool band_caps_from_firmware(struct centauri_t6050_wifi *wifi) wifi->bands[0].ht_cap = ht_cap; wifi->bands[1].ht_cap = ht_cap; + ampdu_density = ht_cap.ampdu_density; } if (vht_elem) { @@ -1190,17 +1193,22 @@ static bool band_caps_from_firmware(struct centauri_t6050_wifi *wifi) if (!he_elem) return false; + /* + * The MCS maps follow the fixed fields: 80 MHz always, 160 and 80+80 + * only when the width set lists them (ieee80211_he_capa_size_ok() + * checked the length). A map the element leaves out is unsupported. + */ memcpy(&base_he.he_cap_elem, he_elem + 3, sizeof(base_he.he_cap_elem)); - mcs = he_elem[1] - 1 - sizeof(base_he.he_cap_elem); + memset(&base_he.he_mcs_nss_supp, 0xff, sizeof(base_he.he_mcs_nss_supp)); + mcs = ieee80211_he_mcs_nss_size(&base_he.he_cap_elem); memcpy(&base_he.he_mcs_nss_supp, - he_elem + 3 + sizeof(base_he.he_cap_elem), - min(mcs, sizeof(base_he.he_mcs_nss_supp))); - if (mcs > sizeof(base_he.he_mcs_nss_supp)) + he_elem + 3 + sizeof(base_he.he_cap_elem), mcs); + ppe = he_elem[1] - 1 - sizeof(base_he.he_cap_elem) - mcs; + if (base_he.he_cap_elem.phy_cap_info[6] & + IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT) memcpy(base_he.ppe_thres, - he_elem + 3 + sizeof(base_he.he_cap_elem) + - sizeof(base_he.he_mcs_nss_supp), - min(mcs - sizeof(base_he.he_mcs_nss_supp), - sizeof(base_he.ppe_thres))); + he_elem + 3 + sizeof(base_he.he_cap_elem) + mcs, + min(ppe, sizeof(base_he.ppe_thres))); base_he.has_he = true; for (band = 0; band < ARRAY_SIZE(wifi->iftype_data); band++) { @@ -1213,18 +1221,29 @@ static bool band_caps_from_firmware(struct centauri_t6050_wifi *wifi) data->types_mask = BIT(NL80211_IFTYPE_STATION); data->he_cap = base_he; if (band == 0) { - data->he_cap.he_cap_elem.phy_cap_info[0] &= - IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_IN_2G; + u8 *phy = data->he_cap.he_cap_elem.phy_cap_info; + + /* Nothing wider than 40 MHz exists on 2.4 GHz. */ + phy[0] &= IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_IN_2G | + IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_RU_MAPPING_IN_2G; + phy[1] &= ~IEEE80211_HE_PHY_CAP1_PREAMBLE_PUNC_RX_MASK; + phy[4] &= ~IEEE80211_HE_PHY_CAP4_BEAMFORMEE_MAX_STS_ABOVE_80MHZ_MASK; + phy[5] &= ~IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_MASK; + phy[8] &= ~(IEEE80211_HE_PHY_CAP8_20MHZ_IN_160MHZ_HE_PPDU | + IEEE80211_HE_PHY_CAP8_80MHZ_IN_160MHZ_HE_PPDU); he_mcs->rx_mcs_160 = cpu_to_le16(0xffff); he_mcs->tx_mcs_160 = cpu_to_le16(0xffff); he_mcs->rx_mcs_80p80 = cpu_to_le16(0xffff); he_mcs->tx_mcs_80p80 = cpu_to_le16(0xffff); } else { data->he_cap.he_cap_elem.phy_cap_info[0] &= - ~IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_IN_2G; + ~(IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_IN_2G | + IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_RU_MAPPING_IN_2G); } if (band == 2) data->he_6ghz_capa.capa = cpu_to_le16( + u16_encode_bits(ampdu_density, + IEEE80211_HE_6GHZ_CAP_MIN_MPDU_START) | u16_encode_bits(u32_get_bits(vht_cap, IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK), IEEE80211_HE_6GHZ_CAP_MAX_AMPDU_LEN_EXP) |