1 // SPDX-License-Identifier: GPL-2.0-only 1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 2 /* 3 * HE handling 3 * HE handling 4 * 4 * 5 * Copyright(c) 2017 Intel Deutschland GmbH 5 * Copyright(c) 2017 Intel Deutschland GmbH 6 * Copyright(c) 2019 - 2023 Intel Corporation !! 6 * Copyright(c) 2019 - 2020 Intel Corporation 7 */ 7 */ 8 8 9 #include "ieee80211_i.h" 9 #include "ieee80211_i.h" 10 10 11 static void 11 static void 12 ieee80211_update_from_he_6ghz_capa(const struc 12 ieee80211_update_from_he_6ghz_capa(const struct ieee80211_he_6ghz_capa *he_6ghz_capa, 13 struct link !! 13 struct sta_info *sta) 14 { 14 { 15 struct sta_info *sta = link_sta->sta; << 16 enum ieee80211_smps_mode smps_mode; 15 enum ieee80211_smps_mode smps_mode; 17 16 18 if (sta->sdata->vif.type == NL80211_IF 17 if (sta->sdata->vif.type == NL80211_IFTYPE_AP || 19 sta->sdata->vif.type == NL80211_IF 18 sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { 20 switch (le16_get_bits(he_6ghz_ 19 switch (le16_get_bits(he_6ghz_capa->capa, 21 IEEE8021 20 IEEE80211_HE_6GHZ_CAP_SM_PS)) { 22 case WLAN_HT_CAP_SM_PS_INVALID 21 case WLAN_HT_CAP_SM_PS_INVALID: 23 case WLAN_HT_CAP_SM_PS_STATIC: 22 case WLAN_HT_CAP_SM_PS_STATIC: 24 smps_mode = IEEE80211_ 23 smps_mode = IEEE80211_SMPS_STATIC; 25 break; 24 break; 26 case WLAN_HT_CAP_SM_PS_DYNAMIC 25 case WLAN_HT_CAP_SM_PS_DYNAMIC: 27 smps_mode = IEEE80211_ 26 smps_mode = IEEE80211_SMPS_DYNAMIC; 28 break; 27 break; 29 case WLAN_HT_CAP_SM_PS_DISABLE 28 case WLAN_HT_CAP_SM_PS_DISABLED: 30 smps_mode = IEEE80211_ 29 smps_mode = IEEE80211_SMPS_OFF; 31 break; 30 break; 32 } 31 } 33 32 34 link_sta->pub->smps_mode = smp !! 33 sta->sta.smps_mode = smps_mode; 35 } else { 34 } else { 36 link_sta->pub->smps_mode = IEE !! 35 sta->sta.smps_mode = IEEE80211_SMPS_OFF; 37 } 36 } 38 37 39 switch (le16_get_bits(he_6ghz_capa->ca 38 switch (le16_get_bits(he_6ghz_capa->capa, 40 IEEE80211_HE_6GH 39 IEEE80211_HE_6GHZ_CAP_MAX_MPDU_LEN)) { 41 case IEEE80211_VHT_CAP_MAX_MPDU_LENGTH 40 case IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454: 42 link_sta->pub->agg.max_amsdu_l !! 41 sta->sta.max_amsdu_len = IEEE80211_MAX_MPDU_LEN_VHT_11454; 43 break; 42 break; 44 case IEEE80211_VHT_CAP_MAX_MPDU_LENGTH 43 case IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991: 45 link_sta->pub->agg.max_amsdu_l !! 44 sta->sta.max_amsdu_len = IEEE80211_MAX_MPDU_LEN_VHT_7991; 46 break; 45 break; 47 case IEEE80211_VHT_CAP_MAX_MPDU_LENGTH 46 case IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895: 48 default: 47 default: 49 link_sta->pub->agg.max_amsdu_l !! 48 sta->sta.max_amsdu_len = IEEE80211_MAX_MPDU_LEN_VHT_3895; 50 break; 49 break; 51 } 50 } 52 51 53 ieee80211_sta_recalc_aggregates(&sta-> !! 52 sta->sta.he_6ghz_capa = *he_6ghz_capa; 54 << 55 link_sta->pub->he_6ghz_capa = *he_6ghz << 56 } 53 } 57 54 58 static void ieee80211_he_mcs_disable(__le16 *h 55 static void ieee80211_he_mcs_disable(__le16 *he_mcs) 59 { 56 { 60 u32 i; 57 u32 i; 61 58 62 for (i = 0; i < 8; i++) 59 for (i = 0; i < 8; i++) 63 *he_mcs |= cpu_to_le16(IEEE802 60 *he_mcs |= cpu_to_le16(IEEE80211_HE_MCS_NOT_SUPPORTED << i * 2); 64 } 61 } 65 62 66 static void ieee80211_he_mcs_intersection(__le 63 static void ieee80211_he_mcs_intersection(__le16 *he_own_rx, __le16 *he_peer_rx, 67 __le 64 __le16 *he_own_tx, __le16 *he_peer_tx) 68 { 65 { 69 u32 i; 66 u32 i; 70 u16 own_rx, own_tx, peer_rx, peer_tx; 67 u16 own_rx, own_tx, peer_rx, peer_tx; 71 68 72 for (i = 0; i < 8; i++) { 69 for (i = 0; i < 8; i++) { 73 own_rx = le16_to_cpu(*he_own_r 70 own_rx = le16_to_cpu(*he_own_rx); 74 own_rx = (own_rx >> i * 2) & I 71 own_rx = (own_rx >> i * 2) & IEEE80211_HE_MCS_NOT_SUPPORTED; 75 72 76 own_tx = le16_to_cpu(*he_own_t 73 own_tx = le16_to_cpu(*he_own_tx); 77 own_tx = (own_tx >> i * 2) & I 74 own_tx = (own_tx >> i * 2) & IEEE80211_HE_MCS_NOT_SUPPORTED; 78 75 79 peer_rx = le16_to_cpu(*he_peer 76 peer_rx = le16_to_cpu(*he_peer_rx); 80 peer_rx = (peer_rx >> i * 2) & 77 peer_rx = (peer_rx >> i * 2) & IEEE80211_HE_MCS_NOT_SUPPORTED; 81 78 82 peer_tx = le16_to_cpu(*he_peer 79 peer_tx = le16_to_cpu(*he_peer_tx); 83 peer_tx = (peer_tx >> i * 2) & 80 peer_tx = (peer_tx >> i * 2) & IEEE80211_HE_MCS_NOT_SUPPORTED; 84 81 85 if (peer_tx != IEEE80211_HE_MC 82 if (peer_tx != IEEE80211_HE_MCS_NOT_SUPPORTED) { 86 if (own_rx == IEEE8021 83 if (own_rx == IEEE80211_HE_MCS_NOT_SUPPORTED) 87 peer_tx = IEEE 84 peer_tx = IEEE80211_HE_MCS_NOT_SUPPORTED; 88 else if (own_rx < peer 85 else if (own_rx < peer_tx) 89 peer_tx = own_ 86 peer_tx = own_rx; 90 } 87 } 91 88 92 if (peer_rx != IEEE80211_HE_MC 89 if (peer_rx != IEEE80211_HE_MCS_NOT_SUPPORTED) { 93 if (own_tx == IEEE8021 90 if (own_tx == IEEE80211_HE_MCS_NOT_SUPPORTED) 94 peer_rx = IEEE 91 peer_rx = IEEE80211_HE_MCS_NOT_SUPPORTED; 95 else if (own_tx < peer 92 else if (own_tx < peer_rx) 96 peer_rx = own_ 93 peer_rx = own_tx; 97 } 94 } 98 95 99 *he_peer_rx &= 96 *he_peer_rx &= 100 ~cpu_to_le16(IEEE80211 97 ~cpu_to_le16(IEEE80211_HE_MCS_NOT_SUPPORTED << i * 2); 101 *he_peer_rx |= cpu_to_le16(pee 98 *he_peer_rx |= cpu_to_le16(peer_rx << i * 2); 102 99 103 *he_peer_tx &= 100 *he_peer_tx &= 104 ~cpu_to_le16(IEEE80211 101 ~cpu_to_le16(IEEE80211_HE_MCS_NOT_SUPPORTED << i * 2); 105 *he_peer_tx |= cpu_to_le16(pee 102 *he_peer_tx |= cpu_to_le16(peer_tx << i * 2); 106 } 103 } 107 } 104 } 108 105 109 void 106 void 110 ieee80211_he_cap_ie_to_sta_he_cap(struct ieee8 107 ieee80211_he_cap_ie_to_sta_he_cap(struct ieee80211_sub_if_data *sdata, 111 struct ieee8 108 struct ieee80211_supported_band *sband, 112 const u8 *he 109 const u8 *he_cap_ie, u8 he_cap_len, 113 const struct 110 const struct ieee80211_he_6ghz_capa *he_6ghz_capa, 114 struct link_ !! 111 struct sta_info *sta) 115 { 112 { 116 struct ieee80211_sta_he_cap *he_cap = !! 113 struct ieee80211_sta_he_cap *he_cap = &sta->sta.he_cap; 117 const struct ieee80211_sta_he_cap *own << 118 struct ieee80211_sta_he_cap own_he_cap 114 struct ieee80211_sta_he_cap own_he_cap; 119 struct ieee80211_he_cap_elem *he_cap_i 115 struct ieee80211_he_cap_elem *he_cap_ie_elem = (void *)he_cap_ie; 120 u8 he_ppe_size; 116 u8 he_ppe_size; 121 u8 mcs_nss_size; 117 u8 mcs_nss_size; 122 u8 he_total_size; 118 u8 he_total_size; 123 bool own_160, peer_160, own_80p80, pee 119 bool own_160, peer_160, own_80p80, peer_80p80; 124 120 125 memset(he_cap, 0, sizeof(*he_cap)); 121 memset(he_cap, 0, sizeof(*he_cap)); 126 122 127 if (!he_cap_ie) !! 123 if (!he_cap_ie || 128 return; !! 124 !ieee80211_get_he_iftype_cap(sband, 129 !! 125 ieee80211_vif_type_p2p(&sdata->vif))) 130 own_he_cap_ptr = << 131 ieee80211_get_he_iftype_cap_vi << 132 if (!own_he_cap_ptr) << 133 return; 126 return; 134 127 135 own_he_cap = *own_he_cap_ptr; !! 128 own_he_cap = sband->iftype_data->he_cap; 136 129 137 /* Make sure size is OK */ 130 /* Make sure size is OK */ 138 mcs_nss_size = ieee80211_he_mcs_nss_si 131 mcs_nss_size = ieee80211_he_mcs_nss_size(he_cap_ie_elem); 139 he_ppe_size = 132 he_ppe_size = 140 ieee80211_he_ppe_size(he_cap_i 133 ieee80211_he_ppe_size(he_cap_ie[sizeof(he_cap->he_cap_elem) + 141 134 mcs_nss_size], 142 he_cap_i 135 he_cap_ie_elem->phy_cap_info); 143 he_total_size = sizeof(he_cap->he_cap_ 136 he_total_size = sizeof(he_cap->he_cap_elem) + mcs_nss_size + 144 he_ppe_size; 137 he_ppe_size; 145 if (he_cap_len < he_total_size) 138 if (he_cap_len < he_total_size) 146 return; 139 return; 147 140 148 memcpy(&he_cap->he_cap_elem, he_cap_ie 141 memcpy(&he_cap->he_cap_elem, he_cap_ie, sizeof(he_cap->he_cap_elem)); 149 142 150 /* HE Tx/Rx HE MCS NSS Support Field * 143 /* HE Tx/Rx HE MCS NSS Support Field */ 151 memcpy(&he_cap->he_mcs_nss_supp, 144 memcpy(&he_cap->he_mcs_nss_supp, 152 &he_cap_ie[sizeof(he_cap->he_ca 145 &he_cap_ie[sizeof(he_cap->he_cap_elem)], mcs_nss_size); 153 146 154 /* Check if there are (optional) PPE T 147 /* Check if there are (optional) PPE Thresholds */ 155 if (he_cap->he_cap_elem.phy_cap_info[6 148 if (he_cap->he_cap_elem.phy_cap_info[6] & 156 IEEE80211_HE_PHY_CAP6_PPE_THRESHOL 149 IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT) 157 memcpy(he_cap->ppe_thres, 150 memcpy(he_cap->ppe_thres, 158 &he_cap_ie[sizeof(he_ca 151 &he_cap_ie[sizeof(he_cap->he_cap_elem) + mcs_nss_size], 159 he_ppe_size); 152 he_ppe_size); 160 153 161 he_cap->has_he = true; 154 he_cap->has_he = true; 162 155 163 link_sta->cur_max_bandwidth = ieee8021 !! 156 sta->cur_max_bandwidth = ieee80211_sta_cap_rx_bw(sta); 164 link_sta->pub->bandwidth = ieee80211_s !! 157 sta->sta.bandwidth = ieee80211_sta_cur_vht_bw(sta); 165 158 166 if (sband->band == NL80211_BAND_6GHZ & 159 if (sband->band == NL80211_BAND_6GHZ && he_6ghz_capa) 167 ieee80211_update_from_he_6ghz_ !! 160 ieee80211_update_from_he_6ghz_capa(he_6ghz_capa, sta); 168 161 169 ieee80211_he_mcs_intersection(&own_he_ 162 ieee80211_he_mcs_intersection(&own_he_cap.he_mcs_nss_supp.rx_mcs_80, 170 &he_cap- 163 &he_cap->he_mcs_nss_supp.rx_mcs_80, 171 &own_he_ 164 &own_he_cap.he_mcs_nss_supp.tx_mcs_80, 172 &he_cap- 165 &he_cap->he_mcs_nss_supp.tx_mcs_80); 173 166 174 own_160 = own_he_cap.he_cap_elem.phy_c 167 own_160 = own_he_cap.he_cap_elem.phy_cap_info[0] & 175 IEEE80211_HE_PHY_CAP0_CHANNE 168 IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G; 176 peer_160 = he_cap->he_cap_elem.phy_cap 169 peer_160 = he_cap->he_cap_elem.phy_cap_info[0] & 177 IEEE80211_HE_PHY_CAP0_CHANN 170 IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G; 178 171 179 if (peer_160 && own_160) { 172 if (peer_160 && own_160) { 180 ieee80211_he_mcs_intersection( 173 ieee80211_he_mcs_intersection(&own_he_cap.he_mcs_nss_supp.rx_mcs_160, 181 174 &he_cap->he_mcs_nss_supp.rx_mcs_160, 182 175 &own_he_cap.he_mcs_nss_supp.tx_mcs_160, 183 176 &he_cap->he_mcs_nss_supp.tx_mcs_160); 184 } else if (peer_160 && !own_160) { 177 } else if (peer_160 && !own_160) { 185 ieee80211_he_mcs_disable(&he_c 178 ieee80211_he_mcs_disable(&he_cap->he_mcs_nss_supp.rx_mcs_160); 186 ieee80211_he_mcs_disable(&he_c 179 ieee80211_he_mcs_disable(&he_cap->he_mcs_nss_supp.tx_mcs_160); 187 he_cap->he_cap_elem.phy_cap_in 180 he_cap->he_cap_elem.phy_cap_info[0] &= 188 ~IEEE80211_HE_PHY_CAP0 181 ~IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G; 189 } 182 } 190 183 191 own_80p80 = own_he_cap.he_cap_elem.phy 184 own_80p80 = own_he_cap.he_cap_elem.phy_cap_info[0] & 192 IEEE80211_HE_PHY_CAP0_CHAN 185 IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G; 193 peer_80p80 = he_cap->he_cap_elem.phy_c 186 peer_80p80 = he_cap->he_cap_elem.phy_cap_info[0] & 194 IEEE80211_HE_PHY_CAP0_CHA 187 IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G; 195 188 196 if (peer_80p80 && own_80p80) { 189 if (peer_80p80 && own_80p80) { 197 ieee80211_he_mcs_intersection( 190 ieee80211_he_mcs_intersection(&own_he_cap.he_mcs_nss_supp.rx_mcs_80p80, 198 191 &he_cap->he_mcs_nss_supp.rx_mcs_80p80, 199 192 &own_he_cap.he_mcs_nss_supp.tx_mcs_80p80, 200 193 &he_cap->he_mcs_nss_supp.tx_mcs_80p80); 201 } else if (peer_80p80 && !own_80p80) { 194 } else if (peer_80p80 && !own_80p80) { 202 ieee80211_he_mcs_disable(&he_c 195 ieee80211_he_mcs_disable(&he_cap->he_mcs_nss_supp.rx_mcs_80p80); 203 ieee80211_he_mcs_disable(&he_c 196 ieee80211_he_mcs_disable(&he_cap->he_mcs_nss_supp.tx_mcs_80p80); 204 he_cap->he_cap_elem.phy_cap_in 197 he_cap->he_cap_elem.phy_cap_info[0] &= 205 ~IEEE80211_HE_PHY_CAP0 198 ~IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G; 206 } 199 } 207 } 200 } 208 201 209 void 202 void 210 ieee80211_he_op_ie_to_bss_conf(struct ieee8021 203 ieee80211_he_op_ie_to_bss_conf(struct ieee80211_vif *vif, 211 const struct ieee80211 204 const struct ieee80211_he_operation *he_op_ie) 212 { 205 { 213 memset(&vif->bss_conf.he_oper, 0, size 206 memset(&vif->bss_conf.he_oper, 0, sizeof(vif->bss_conf.he_oper)); 214 if (!he_op_ie) 207 if (!he_op_ie) 215 return; 208 return; 216 209 217 vif->bss_conf.he_oper.params = __le32_ 210 vif->bss_conf.he_oper.params = __le32_to_cpu(he_op_ie->he_oper_params); 218 vif->bss_conf.he_oper.nss_set = __le16 211 vif->bss_conf.he_oper.nss_set = __le16_to_cpu(he_op_ie->he_mcs_nss_set); 219 } 212 } 220 213 221 void 214 void 222 ieee80211_he_spr_ie_to_bss_conf(struct ieee802 215 ieee80211_he_spr_ie_to_bss_conf(struct ieee80211_vif *vif, 223 const struct i 216 const struct ieee80211_he_spr *he_spr_ie_elem) 224 { 217 { 225 struct ieee80211_he_obss_pd *he_obss_p 218 struct ieee80211_he_obss_pd *he_obss_pd = 226 &vif-> 219 &vif->bss_conf.he_obss_pd; 227 const u8 *data; 220 const u8 *data; 228 221 229 memset(he_obss_pd, 0, sizeof(*he_obss_ 222 memset(he_obss_pd, 0, sizeof(*he_obss_pd)); 230 223 231 if (!he_spr_ie_elem) 224 if (!he_spr_ie_elem) 232 return; 225 return; 233 << 234 he_obss_pd->sr_ctrl = he_spr_ie_elem-> << 235 data = he_spr_ie_elem->optional; 226 data = he_spr_ie_elem->optional; 236 227 237 if (he_spr_ie_elem->he_sr_control & 228 if (he_spr_ie_elem->he_sr_control & 238 IEEE80211_HE_SPR_NON_SRG_OFFSET_PR 229 IEEE80211_HE_SPR_NON_SRG_OFFSET_PRESENT) 239 he_obss_pd->non_srg_max_offset !! 230 data++; 240 << 241 if (he_spr_ie_elem->he_sr_control & 231 if (he_spr_ie_elem->he_sr_control & 242 IEEE80211_HE_SPR_SRG_INFORMATION_P 232 IEEE80211_HE_SPR_SRG_INFORMATION_PRESENT) { 243 he_obss_pd->min_offset = *data << 244 he_obss_pd->max_offset = *data 233 he_obss_pd->max_offset = *data++; 245 memcpy(he_obss_pd->bss_color_b !! 234 he_obss_pd->min_offset = *data++; 246 data += 8; << 247 memcpy(he_obss_pd->partial_bss << 248 he_obss_pd->enable = true; 235 he_obss_pd->enable = true; 249 } 236 } 250 } 237 } 251 238
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.