1 /* 2 * Copyright (c) 2011-2017 The Linux Foundation. All rights reserved. 3 * 4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc. 5 * 6 * 7 * Permission to use, copy, modify, and/or distribute this software for 8 * any purpose with or without fee is hereby granted, provided that the 9 * above copyright notice and this permission notice appear in all 10 * copies. 11 * 12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 19 * PERFORMANCE OF THIS SOFTWARE. 20 */ 21 22 /* 23 * This file was originally distributed by Qualcomm Atheros, Inc. 24 * under proprietary terms before Copyright ownership was assigned 25 * to the Linux Foundation. 26 */ 27 28 /* 29 * DOC: csr_util.c 30 * 31 * Implementation supporting routines for CSR. 32 */ 33 34 #include "ani_global.h" 35 36 #include "csr_support.h" 37 #include "csr_inside_api.h" 38 #include "sme_qos_internal.h" 39 #include "wma_types.h" 40 #include "cds_utils.h" 41 #include "wlan_policy_mgr_api.h" 42 #include "wlan_serialization_legacy_api.h" 43 #include "wlan_reg_services_api.h" 44 45 46 uint8_t csr_wpa_oui[][CSR_WPA_OUI_SIZE] = { 47 {0x00, 0x50, 0xf2, 0x00} 48 , 49 {0x00, 0x50, 0xf2, 0x01} 50 , 51 {0x00, 0x50, 0xf2, 0x02} 52 , 53 {0x00, 0x50, 0xf2, 0x03} 54 , 55 {0x00, 0x50, 0xf2, 0x04} 56 , 57 {0x00, 0x50, 0xf2, 0x05} 58 , 59 #ifdef FEATURE_WLAN_ESE 60 {0x00, 0x40, 0x96, 0x00} 61 , /* CCKM */ 62 #endif /* FEATURE_WLAN_ESE */ 63 }; 64 65 /* 66 * PLEASE DO NOT ADD THE #IFDEF IN BELOW TABLE, 67 * IF STILL REQUIRE THEN PLEASE ADD NULL ENTRIES 68 * OTHERWISE IT WILL BREAK OTHER LOWER 69 * SECUIRTY MODES. 70 */ 71 72 uint8_t csr_rsn_oui[][CSR_RSN_OUI_SIZE] = { 73 {0x00, 0x0F, 0xAC, 0x00} 74 , /* group cipher */ 75 {0x00, 0x0F, 0xAC, 0x01} 76 , /* WEP-40 or RSN */ 77 {0x00, 0x0F, 0xAC, 0x02} 78 , /* TKIP or RSN-PSK */ 79 {0x00, 0x0F, 0xAC, 0x03} 80 , /* Reserved */ 81 {0x00, 0x0F, 0xAC, 0x04} 82 , /* AES-CCMP */ 83 {0x00, 0x0F, 0xAC, 0x05} 84 , /* WEP-104 */ 85 {0x00, 0x40, 0x96, 0x00} 86 , /* CCKM */ 87 {0x00, 0x0F, 0xAC, 0x06} 88 , /* BIP (encryption type) or 89 * RSN-PSK-SHA256 (authentication type) 90 */ 91 /* RSN-8021X-SHA256 (authentication type) */ 92 {0x00, 0x0F, 0xAC, 0x05}, 93 #ifdef WLAN_FEATURE_FILS_SK 94 #define ENUM_FILS_SHA256 9 95 /* FILS SHA256 */ 96 {0x00, 0x0F, 0xAC, 0x0E}, 97 #define ENUM_FILS_SHA384 10 98 /* FILS SHA384 */ 99 {0x00, 0x0F, 0xAC, 0x0F}, 100 #define ENUM_FT_FILS_SHA256 11 101 /* FILS FT SHA256 */ 102 {0x00, 0x0F, 0xAC, 0x10}, 103 #define ENUM_FT_FILS_SHA384 12 104 /* FILS FT SHA384 */ 105 {0x00, 0x0F, 0xAC, 0x11}, 106 #else 107 {0x00, 0x00, 0x00, 0x00}, 108 {0x00, 0x00, 0x00, 0x00}, 109 {0x00, 0x00, 0x00, 0x00}, 110 {0x00, 0x00, 0x00, 0x00}, 111 #endif 112 /* AES GCMP */ 113 {0x00, 0x0F, 0xAC, 0x08}, 114 /* AES GCMP-256 */ 115 {0x00, 0x0F, 0xAC, 0x09}, 116 #define ENUM_DPP_RSN 15 117 /* DPP RSN */ 118 {0x50, 0x6F, 0x9A, 0x02}, 119 #define ENUM_OWE 16 120 /* OWE https://tools.ietf.org/html/rfc8110 */ 121 {0x00, 0x0F, 0xAC, 0x12}, 122 /* define new oui here, update #define CSR_OUI_***_INDEX */ 123 }; 124 125 #ifdef FEATURE_WLAN_WAPI 126 uint8_t csr_wapi_oui[][CSR_WAPI_OUI_SIZE] = { 127 {0x00, 0x14, 0x72, 0x00} 128 , /* Reserved */ 129 {0x00, 0x14, 0x72, 0x01} 130 , /* WAI certificate or SMS4 */ 131 {0x00, 0x14, 0x72, 0x02} /* WAI PSK */ 132 }; 133 #endif /* FEATURE_WLAN_WAPI */ 134 uint8_t csr_wme_info_oui[CSR_WME_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x02 }; 135 uint8_t csr_wme_parm_oui[CSR_WME_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x02 }; 136 137 /* ////////////////////////////////////////////////////////////////////// */ 138 139 /** 140 * \var g_phy_rates_suppt 141 * 142 * \brief Rate support lookup table 143 * 144 * 145 * This is a lookup table indexing rates & configuration parameters to 146 * support. Given a rate (in unites of 0.5Mpbs) & three bools (MIMO 147 * Enabled, Channel Bonding Enabled, & Concatenation Enabled), one can 148 * determine whether the given rate is supported by computing two 149 * indices. The first maps the rate to table row as indicated below 150 * (i.e. eHddSuppRate_6Mbps maps to row zero, eHddSuppRate_9Mbps to row 151 * 1, and so on). Index two can be computed like so: 152 * 153 * \code 154 * idx2 = ( fEsf ? 0x4 : 0x0 ) | 155 * ( fCb ? 0x2 : 0x0 ) | 156 * ( fMimo ? 0x1 : 0x0 ); 157 * \endcode 158 * 159 * 160 * Given that: 161 * 162 * \code 163 * fSupported = g_phy_rates_suppt[idx1][idx2]; 164 * \endcode 165 * 166 * 167 * This table is based on the document "PHY Supported Rates.doc". This 168 * table is permissive in that a rate is reflected as being supported 169 * even when turning off an enabled feature would be required. For 170 * instance, "PHY Supported Rates" lists 42Mpbs as unsupported when CB, 171 * ESF, & MIMO are all on. However, if we turn off either of CB or 172 * MIMO, it then becomes supported. Therefore, we mark it as supported 173 * even in index 7 of this table. 174 * 175 * 176 */ 177 178 static const bool g_phy_rates_suppt[24][8] = { 179 180 /* SSF SSF SSF SSF ESF ESF ESF ESF */ 181 /* SIMO MIMO SIMO MIMO SIMO MIMO SIMO MIMO */ 182 /* No CB No CB CB CB No CB No CB CB CB */ 183 {true, true, true, true, true, true, true, true}, /* 6Mbps */ 184 {true, true, true, true, true, true, true, true}, /* 9Mbps */ 185 {true, true, true, true, true, true, true, true}, /* 12Mbps */ 186 {true, true, true, true, true, true, true, true}, /* 18Mbps */ 187 {false, false, true, true, false, false, true, true}, /* 20Mbps */ 188 {true, true, true, true, true, true, true, true}, /* 24Mbps */ 189 {true, true, true, true, true, true, true, true}, /* 36Mbps */ 190 {false, false, true, true, false, true, true, true}, /* 40Mbps */ 191 {false, false, true, true, false, true, true, true}, /* 42Mbps */ 192 {true, true, true, true, true, true, true, true}, /* 48Mbps */ 193 {true, true, true, true, true, true, true, true}, /* 54Mbps */ 194 {false, true, true, true, false, true, true, true}, /* 72Mbps */ 195 {false, false, true, true, false, true, true, true}, /* 80Mbps */ 196 {false, false, true, true, false, true, true, true}, /* 84Mbps */ 197 {false, true, true, true, false, true, true, true}, /* 96Mbps */ 198 {false, true, true, true, false, true, true, true}, /* 108Mbps */ 199 {false, false, true, true, false, true, true, true}, /* 120Mbps */ 200 {false, false, true, true, false, true, true, true}, /* 126Mbps */ 201 {false, false, false, true, false, false, false, true}, /* 144Mbps */ 202 {false, false, false, true, false, false, false, true}, /* 160Mbps */ 203 {false, false, false, true, false, false, false, true}, /* 168Mbps */ 204 {false, false, false, true, false, false, false, true}, /* 192Mbps */ 205 {false, false, false, true, false, false, false, true}, /* 216Mbps */ 206 {false, false, false, true, false, false, false, true}, /* 240Mbps */ 207 208 }; 209 210 #define CASE_RETURN_STR(n) {\ 211 case (n): return (# n);\ 212 } 213 214 const char *get_e_roam_cmd_status_str(eRoamCmdStatus val) 215 { 216 switch (val) { 217 CASE_RETURN_STR(eCSR_ROAM_CANCELLED); 218 CASE_RETURN_STR(eCSR_ROAM_FAILED); 219 CASE_RETURN_STR(eCSR_ROAM_ROAMING_START); 220 CASE_RETURN_STR(eCSR_ROAM_ROAMING_COMPLETION); 221 CASE_RETURN_STR(eCSR_ROAM_CONNECT_COMPLETION); 222 CASE_RETURN_STR(eCSR_ROAM_ASSOCIATION_START); 223 CASE_RETURN_STR(eCSR_ROAM_ASSOCIATION_COMPLETION); 224 CASE_RETURN_STR(eCSR_ROAM_DISASSOCIATED); 225 CASE_RETURN_STR(eCSR_ROAM_ASSOCIATION_FAILURE); 226 CASE_RETURN_STR(eCSR_ROAM_SHOULD_ROAM); 227 CASE_RETURN_STR(eCSR_ROAM_SCAN_FOUND_NEW_BSS); 228 CASE_RETURN_STR(eCSR_ROAM_LOSTLINK); 229 CASE_RETURN_STR(eCSR_ROAM_LOSTLINK_DETECTED); 230 CASE_RETURN_STR(eCSR_ROAM_MIC_ERROR_IND); 231 CASE_RETURN_STR(eCSR_ROAM_IBSS_IND); 232 CASE_RETURN_STR(eCSR_ROAM_CONNECT_STATUS_UPDATE); 233 CASE_RETURN_STR(eCSR_ROAM_GEN_INFO); 234 CASE_RETURN_STR(eCSR_ROAM_SET_KEY_COMPLETE); 235 CASE_RETURN_STR(eCSR_ROAM_IBSS_LEAVE); 236 CASE_RETURN_STR(eCSR_ROAM_INFRA_IND); 237 CASE_RETURN_STR(eCSR_ROAM_WPS_PBC_PROBE_REQ_IND); 238 CASE_RETURN_STR(eCSR_ROAM_FT_RESPONSE); 239 CASE_RETURN_STR(eCSR_ROAM_FT_START); 240 CASE_RETURN_STR(eCSR_ROAM_SESSION_OPENED); 241 CASE_RETURN_STR(eCSR_ROAM_FT_REASSOC_FAILED); 242 CASE_RETURN_STR(eCSR_ROAM_PMK_NOTIFY); 243 #ifdef FEATURE_WLAN_LFR_METRICS 244 CASE_RETURN_STR(eCSR_ROAM_PREAUTH_INIT_NOTIFY); 245 CASE_RETURN_STR(eCSR_ROAM_PREAUTH_STATUS_SUCCESS); 246 CASE_RETURN_STR(eCSR_ROAM_PREAUTH_STATUS_FAILURE); 247 CASE_RETURN_STR(eCSR_ROAM_HANDOVER_SUCCESS); 248 #endif 249 #ifdef FEATURE_WLAN_TDLS 250 CASE_RETURN_STR(eCSR_ROAM_TDLS_STATUS_UPDATE); 251 CASE_RETURN_STR(eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND); 252 #endif 253 CASE_RETURN_STR(eCSR_ROAM_DISCONNECT_ALL_P2P_CLIENTS); 254 CASE_RETURN_STR(eCSR_ROAM_SEND_P2P_STOP_BSS); 255 #ifdef WLAN_FEATURE_11W 256 CASE_RETURN_STR(eCSR_ROAM_UNPROT_MGMT_FRAME_IND); 257 #endif 258 #ifdef WLAN_FEATURE_RMC 259 CASE_RETURN_STR(eCSR_ROAM_IBSS_PEER_INFO_COMPLETE); 260 #endif 261 #ifdef FEATURE_WLAN_ESE 262 CASE_RETURN_STR(eCSR_ROAM_TSM_IE_IND); 263 CASE_RETURN_STR(eCSR_ROAM_CCKM_PREAUTH_NOTIFY); 264 CASE_RETURN_STR(eCSR_ROAM_ESE_ADJ_AP_REPORT_IND); 265 CASE_RETURN_STR(eCSR_ROAM_ESE_BCN_REPORT_IND); 266 #endif /* FEATURE_WLAN_ESE */ 267 CASE_RETURN_STR(eCSR_ROAM_DFS_RADAR_IND); 268 CASE_RETURN_STR(eCSR_ROAM_SET_CHANNEL_RSP); 269 CASE_RETURN_STR(eCSR_ROAM_DFS_CHAN_SW_NOTIFY); 270 CASE_RETURN_STR(eCSR_ROAM_EXT_CHG_CHNL_IND); 271 CASE_RETURN_STR(eCSR_ROAM_STA_CHANNEL_SWITCH); 272 CASE_RETURN_STR(eCSR_ROAM_NDP_STATUS_UPDATE); 273 CASE_RETURN_STR(eCSR_ROAM_UPDATE_SCAN_RESULT); 274 CASE_RETURN_STR(eCSR_ROAM_START); 275 CASE_RETURN_STR(eCSR_ROAM_ABORT); 276 CASE_RETURN_STR(eCSR_ROAM_NAPI_OFF); 277 CASE_RETURN_STR(eCSR_ROAM_CHANNEL_COMPLETE_IND); 278 default: 279 return "unknown"; 280 } 281 } 282 283 const char *get_e_csr_roam_result_str(eCsrRoamResult val) 284 { 285 switch (val) { 286 CASE_RETURN_STR(eCSR_ROAM_RESULT_NONE); 287 CASE_RETURN_STR(eCSR_ROAM_RESULT_FAILURE); 288 CASE_RETURN_STR(eCSR_ROAM_RESULT_ASSOCIATED); 289 CASE_RETURN_STR(eCSR_ROAM_RESULT_NOT_ASSOCIATED); 290 CASE_RETURN_STR(eCSR_ROAM_RESULT_MIC_FAILURE); 291 CASE_RETURN_STR(eCSR_ROAM_RESULT_FORCED); 292 CASE_RETURN_STR(eCSR_ROAM_RESULT_DISASSOC_IND); 293 CASE_RETURN_STR(eCSR_ROAM_RESULT_DEAUTH_IND); 294 CASE_RETURN_STR(eCSR_ROAM_RESULT_CAP_CHANGED); 295 CASE_RETURN_STR(eCSR_ROAM_RESULT_IBSS_STARTED); 296 CASE_RETURN_STR(eCSR_ROAM_RESULT_IBSS_START_FAILED); 297 CASE_RETURN_STR(eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS); 298 CASE_RETURN_STR(eCSR_ROAM_RESULT_IBSS_JOIN_FAILED); 299 CASE_RETURN_STR(eCSR_ROAM_RESULT_IBSS_CONNECT); 300 CASE_RETURN_STR(eCSR_ROAM_RESULT_IBSS_INACTIVE); 301 CASE_RETURN_STR(eCSR_ROAM_RESULT_IBSS_NEW_PEER); 302 CASE_RETURN_STR(eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED); 303 CASE_RETURN_STR(eCSR_ROAM_RESULT_IBSS_COALESCED); 304 CASE_RETURN_STR(eCSR_ROAM_RESULT_IBSS_STOP); 305 CASE_RETURN_STR(eCSR_ROAM_RESULT_LOSTLINK); 306 CASE_RETURN_STR(eCSR_ROAM_RESULT_MIC_ERROR_UNICAST); 307 CASE_RETURN_STR(eCSR_ROAM_RESULT_MIC_ERROR_GROUP); 308 CASE_RETURN_STR(eCSR_ROAM_RESULT_AUTHENTICATED); 309 CASE_RETURN_STR(eCSR_ROAM_RESULT_NEW_RSN_BSS); 310 #ifdef FEATURE_WLAN_WAPI 311 CASE_RETURN_STR(eCSR_ROAM_RESULT_NEW_WAPI_BSS); 312 #endif /* FEATURE_WLAN_WAPI */ 313 CASE_RETURN_STR(eCSR_ROAM_RESULT_INFRA_STARTED); 314 CASE_RETURN_STR(eCSR_ROAM_RESULT_INFRA_START_FAILED); 315 CASE_RETURN_STR(eCSR_ROAM_RESULT_INFRA_STOPPED); 316 CASE_RETURN_STR(eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND); 317 CASE_RETURN_STR(eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF); 318 CASE_RETURN_STR(eCSR_ROAM_RESULT_INFRA_DISASSOCIATED); 319 CASE_RETURN_STR(eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND); 320 CASE_RETURN_STR(eCSR_ROAM_RESULT_SEND_ACTION_FAIL); 321 CASE_RETURN_STR(eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED); 322 CASE_RETURN_STR(eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL); 323 CASE_RETURN_STR(eCSR_ROAM_RESULT_ADD_TDLS_PEER); 324 CASE_RETURN_STR(eCSR_ROAM_RESULT_UPDATE_TDLS_PEER); 325 CASE_RETURN_STR(eCSR_ROAM_RESULT_DELETE_TDLS_PEER); 326 CASE_RETURN_STR(eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND); 327 CASE_RETURN_STR(eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND); 328 CASE_RETURN_STR(eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP); 329 CASE_RETURN_STR(eCSR_ROAM_RESULT_TDLS_SHOULD_DISCOVER); 330 CASE_RETURN_STR(eCSR_ROAM_RESULT_TDLS_SHOULD_TEARDOWN); 331 CASE_RETURN_STR(eCSR_ROAM_RESULT_TDLS_SHOULD_PEER_DISCONNECTED); 332 CASE_RETURN_STR 333 (eCSR_ROAM_RESULT_TDLS_CONNECTION_TRACKER_NOTIFICATION); 334 CASE_RETURN_STR(eCSR_ROAM_RESULT_IBSS_PEER_INFO_SUCCESS); 335 CASE_RETURN_STR(eCSR_ROAM_RESULT_IBSS_PEER_INFO_FAILED); 336 CASE_RETURN_STR(eCSR_ROAM_RESULT_DFS_RADAR_FOUND_IND); 337 CASE_RETURN_STR(eCSR_ROAM_RESULT_CHANNEL_CHANGE_SUCCESS); 338 CASE_RETURN_STR(eCSR_ROAM_RESULT_CHANNEL_CHANGE_FAILURE); 339 CASE_RETURN_STR(eCSR_ROAM_RESULT_DFS_CHANSW_UPDATE_SUCCESS); 340 CASE_RETURN_STR(eCSR_ROAM_EXT_CHG_CHNL_UPDATE_IND); 341 CASE_RETURN_STR(eCSR_ROAM_RESULT_NDI_CREATE_RSP); 342 CASE_RETURN_STR(eCSR_ROAM_RESULT_NDI_DELETE_RSP); 343 CASE_RETURN_STR(eCSR_ROAM_RESULT_NDP_INITIATOR_RSP); 344 CASE_RETURN_STR(eCSR_ROAM_RESULT_NDP_NEW_PEER_IND); 345 CASE_RETURN_STR(eCSR_ROAM_RESULT_NDP_CONFIRM_IND); 346 CASE_RETURN_STR(eCSR_ROAM_RESULT_NDP_INDICATION); 347 CASE_RETURN_STR(eCSR_ROAM_RESULT_NDP_SCHED_UPDATE_RSP); 348 CASE_RETURN_STR(eCSR_ROAM_RESULT_NDP_RESPONDER_RSP); 349 CASE_RETURN_STR(eCSR_ROAM_RESULT_NDP_END_RSP); 350 CASE_RETURN_STR(eCSR_ROAM_RESULT_NDP_PEER_DEPARTED_IND); 351 CASE_RETURN_STR(eCSR_ROAM_RESULT_NDP_END_IND); 352 CASE_RETURN_STR(eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE); 353 default: 354 return "unknown"; 355 } 356 } 357 358 void purge_sme_session_active_scan_cmd_list(struct sAniSirGlobal *mac_ctx, 359 uint32_t session_id) 360 { 361 uint8_t vdev_id = session_id; 362 363 wlan_serialization_purge_cmd_list_by_vdev_id(mac_ctx->psoc, vdev_id, 364 true, false, false, false, false); 365 } 366 367 void purge_sme_session_pending_scan_cmd_list(struct sAniSirGlobal *mac_ctx, 368 uint32_t session_id) 369 { 370 uint8_t vdev_id = session_id; 371 372 wlan_serialization_purge_cmd_list_by_vdev_id(mac_ctx->psoc, vdev_id, 373 false, true, false, false, false); 374 } 375 376 void purge_sme_session_pending_cmd_list(struct sAniSirGlobal *mac_ctx, 377 uint32_t session_id) 378 { 379 uint8_t vdev_id = session_id; 380 381 wlan_serialization_purge_cmd_list_by_vdev_id(mac_ctx->psoc, vdev_id, 382 false, false, false, true, false); 383 } 384 385 void purge_sme_session_active_cmd_list(struct sAniSirGlobal *mac_ctx, 386 uint32_t session_id) 387 { 388 uint8_t vdev_id = session_id; 389 390 wlan_serialization_purge_cmd_list_by_vdev_id(mac_ctx->psoc, vdev_id, 391 false, false, true, false, false); 392 } 393 394 void csr_nonscan_active_ll_insert_head(struct sAniSirGlobal *mac_ctx, 395 tListElem *entry, bool inter_locked) 396 { 397 } 398 399 void csr_nonscan_pending_ll_insert_head(struct sAniSirGlobal *mac_ctx, 400 tListElem *entry, bool inter_locked) 401 { 402 } 403 404 void csr_nonscan_pending_ll_insert_tail(struct sAniSirGlobal *mac_ctx, 405 tListElem *entry, bool inter_locked) 406 { 407 } 408 409 void csr_scan_pending_ll_unlock(struct sAniSirGlobal *mac_ctx) 410 { 411 } 412 413 void csr_scan_active_ll_unlock(struct sAniSirGlobal *mac_ctx) 414 { 415 } 416 417 void csr_scan_pending_ll_lock(struct sAniSirGlobal *mac_ctx) 418 { 419 } 420 421 void csr_scan_active_ll_lock(struct sAniSirGlobal *mac_ctx) 422 { 423 } 424 425 void csr_nonscan_pending_ll_unlock(struct sAniSirGlobal *mac_ctx) 426 { 427 } 428 429 void csr_nonscan_active_ll_unlock(struct sAniSirGlobal *mac_ctx) 430 { 431 } 432 433 void csr_nonscan_pending_ll_lock(struct sAniSirGlobal *mac_ctx) 434 { 435 } 436 437 void csr_nonscan_active_ll_lock(struct sAniSirGlobal *mac_ctx) 438 { 439 } 440 441 uint32_t csr_nonscan_active_ll_count(struct sAniSirGlobal *mac_ctx) 442 { 443 return wlan_serialization_get_active_list_count(mac_ctx->psoc, false); 444 } 445 446 uint32_t csr_nonscan_pending_ll_count(struct sAniSirGlobal *mac_ctx) 447 { 448 return wlan_serialization_get_pending_list_count(mac_ctx->psoc, false); 449 } 450 451 uint32_t csr_scan_active_ll_count(struct sAniSirGlobal *mac_ctx) 452 { 453 return wlan_serialization_get_active_list_count(mac_ctx->psoc, true); 454 } 455 456 uint32_t csr_scan_pending_ll_count(struct sAniSirGlobal *mac_ctx) 457 { 458 return wlan_serialization_get_pending_list_count(mac_ctx->psoc, true); 459 } 460 461 bool csr_scan_active_ll_is_list_empty(struct sAniSirGlobal *mac_ctx, 462 bool inter_locked) 463 { 464 return !wlan_serialization_get_active_list_count(mac_ctx->psoc, true); 465 } 466 467 bool csr_scan_pending_ll_is_list_empty(struct sAniSirGlobal *mac_ctx, 468 bool inter_locked) 469 { 470 return !wlan_serialization_get_pending_list_count(mac_ctx->psoc, true); 471 } 472 473 bool csr_nonscan_active_ll_is_list_empty(struct sAniSirGlobal *mac_ctx, 474 bool inter_locked) 475 { 476 return !wlan_serialization_get_active_list_count(mac_ctx->psoc, false); 477 } 478 bool csr_nonscan_pending_ll_is_list_empty(struct sAniSirGlobal *mac_ctx, 479 bool inter_locked) 480 { 481 return !wlan_serialization_get_pending_list_count(mac_ctx->psoc, false); 482 } 483 484 tListElem *csr_nonscan_active_ll_peek_head(struct sAniSirGlobal *mac_ctx, 485 bool inter_locked) 486 { 487 struct wlan_serialization_command *cmd; 488 tSmeCmd *sme_cmd; 489 490 cmd = wlan_serialization_peek_head_active_cmd_using_psoc(mac_ctx->psoc, 491 false); 492 if (!cmd) { 493 sme_err("No cmd found"); 494 return NULL; 495 } 496 sme_cmd = cmd->umac_cmd; 497 498 return &sme_cmd->Link; 499 } 500 501 tListElem *csr_nonscan_pending_ll_peek_head(struct sAniSirGlobal *mac_ctx, 502 bool inter_locked) 503 { 504 struct wlan_serialization_command *cmd; 505 tSmeCmd *sme_cmd; 506 507 cmd = wlan_serialization_peek_head_pending_cmd_using_psoc(mac_ctx->psoc, 508 false); 509 if (!cmd) { 510 sme_err("No cmd found"); 511 return NULL; 512 } 513 sme_cmd = cmd->umac_cmd; 514 515 return &sme_cmd->Link; 516 } 517 518 tListElem *csr_scan_active_ll_peek_head(struct sAniSirGlobal *mac_ctx, 519 bool inter_locked) 520 { 521 struct wlan_serialization_command *cmd; 522 tSmeCmd *sme_cmd; 523 524 SME_ENTER(); 525 cmd = wlan_serialization_peek_head_active_cmd_using_psoc(mac_ctx->psoc, 526 true); 527 if (!cmd) { 528 sme_err("No cmd found"); 529 return NULL; 530 } 531 sme_cmd = cmd->umac_cmd; 532 533 return &sme_cmd->Link; 534 } 535 536 tListElem *csr_scan_pending_ll_peek_head(struct sAniSirGlobal *mac_ctx, 537 bool inter_locked) 538 { 539 struct wlan_serialization_command *cmd; 540 tSmeCmd *sme_cmd; 541 542 cmd = wlan_serialization_peek_head_pending_cmd_using_psoc(mac_ctx->psoc, 543 true); 544 if (!cmd) { 545 sme_err("No cmd found"); 546 return NULL; 547 } 548 sme_cmd = cmd->umac_cmd; 549 550 return &sme_cmd->Link; 551 } 552 553 bool csr_nonscan_active_ll_remove_entry(struct sAniSirGlobal *mac_ctx, 554 tListElem *entry, bool inter_locked) 555 { 556 tListElem *head; 557 558 head = csr_nonscan_active_ll_peek_head(mac_ctx, inter_locked); 559 if (head == entry) 560 return true; 561 562 return false; 563 } 564 565 bool csr_nonscan_pending_ll_remove_entry(struct sAniSirGlobal *mac_ctx, 566 tListElem *entry, bool inter_locked) 567 { 568 tListElem *head; 569 570 head = csr_nonscan_pending_ll_next(mac_ctx, entry, inter_locked); 571 if (head == entry) 572 return true; 573 574 return false; 575 } 576 577 bool csr_scan_active_ll_remove_entry(struct sAniSirGlobal *mac_ctx, 578 tListElem *entry, bool inter_locked) 579 { 580 tListElem *found_sme_cmd; 581 tSmeCmd *sme_cmd; 582 struct wlan_serialization_command *cmd; 583 584 if (!entry) { 585 sme_err("entry is null"); 586 return false; 587 } 588 589 sme_cmd = GET_BASE_ADDR(entry, tSmeCmd, Link); 590 cmd = wlan_serialization_get_scan_cmd_using_scan_id(mac_ctx->psoc, 591 sme_cmd->sessionId, sme_cmd->u.scanCmd.scanID, 592 true); 593 if (!cmd) { 594 sme_err("Can't find the entry"); 595 return false; 596 } 597 sme_cmd = cmd->umac_cmd; 598 found_sme_cmd = &sme_cmd->Link; 599 if (found_sme_cmd == entry) 600 return true; 601 602 return false; 603 } 604 605 bool csr_scan_pending_ll_remove_entry(struct sAniSirGlobal *mac_ctx, 606 tListElem *entry, bool inter_locked) 607 { 608 tListElem *found_sme_cmd; 609 tSmeCmd *sme_cmd; 610 struct wlan_serialization_command *cmd; 611 612 if (!entry) { 613 sme_err("entry is null"); 614 return false; 615 } 616 sme_cmd = GET_BASE_ADDR(entry, tSmeCmd, Link); 617 cmd = wlan_serialization_get_scan_cmd_using_scan_id(mac_ctx->psoc, 618 sme_cmd->sessionId, sme_cmd->u.scanCmd.scanID, 619 false); 620 if (!cmd) { 621 sme_err("Can't find the entry"); 622 return false; 623 } 624 sme_cmd = cmd->umac_cmd; 625 found_sme_cmd = &sme_cmd->Link; 626 if (found_sme_cmd == entry) 627 return true; 628 629 return false; 630 } 631 632 tListElem *csr_scan_active_ll_remove_head(struct sAniSirGlobal *mac_ctx, 633 bool inter_locked) 634 { 635 return csr_scan_active_ll_peek_head(mac_ctx, inter_locked); 636 } 637 638 tListElem *csr_scan_pending_ll_remove_head(struct sAniSirGlobal *mac_ctx, 639 bool inter_locked) 640 { 641 return csr_scan_pending_ll_peek_head(mac_ctx, inter_locked); 642 } 643 644 645 tListElem *csr_nonscan_active_ll_remove_head(struct sAniSirGlobal *mac_ctx, 646 bool inter_locked) 647 { 648 return csr_nonscan_active_ll_peek_head(mac_ctx, inter_locked); 649 } 650 651 tListElem *csr_nonscan_pending_ll_remove_head(struct sAniSirGlobal *mac_ctx, 652 bool inter_locked) 653 { 654 return csr_nonscan_pending_ll_peek_head(mac_ctx, inter_locked); 655 } 656 657 tListElem *csr_scan_active_ll_next(struct sAniSirGlobal *mac_ctx, 658 tListElem *entry, bool inter_locked) 659 { 660 tSmeCmd *sme_cmd; 661 struct wlan_serialization_command cmd, *tcmd; 662 663 if (!entry) 664 return NULL; 665 sme_cmd = GET_BASE_ADDR(entry, tSmeCmd, Link); 666 if (sme_cmd->command == eSmeCommandScan) 667 cmd.cmd_id = sme_cmd->u.scanCmd.scanID; 668 else 669 cmd.cmd_id = 0; 670 cmd.cmd_type = csr_get_cmd_type(sme_cmd); 671 cmd.vdev = wlan_objmgr_get_vdev_by_id_from_psoc(mac_ctx->psoc, 672 sme_cmd->sessionId, WLAN_LEGACY_SME_ID); 673 tcmd = wlan_serialization_get_active_list_next_node_using_psoc( 674 mac_ctx->psoc, &cmd, true); 675 if (cmd.vdev) 676 wlan_objmgr_vdev_release_ref(cmd.vdev, WLAN_LEGACY_SME_ID); 677 if (!tcmd) { 678 sme_err("No cmd found"); 679 return NULL; 680 } 681 sme_cmd = tcmd->umac_cmd; 682 return &sme_cmd->Link; 683 } 684 685 tListElem *csr_scan_pending_ll_next(struct sAniSirGlobal *mac_ctx, 686 tListElem *entry, bool inter_locked) 687 { 688 tSmeCmd *sme_cmd; 689 struct wlan_serialization_command cmd, *tcmd; 690 691 if (!entry) 692 return NULL; 693 sme_cmd = GET_BASE_ADDR(entry, tSmeCmd, Link); 694 if (sme_cmd->command == eSmeCommandScan) 695 cmd.cmd_id = sme_cmd->u.scanCmd.scanID; 696 else 697 cmd.cmd_id = 0; 698 cmd.cmd_type = csr_get_cmd_type(sme_cmd); 699 cmd.vdev = wlan_objmgr_get_vdev_by_id_from_psoc(mac_ctx->psoc, 700 sme_cmd->sessionId, WLAN_LEGACY_SME_ID); 701 tcmd = wlan_serialization_get_pending_list_next_node_using_psoc( 702 mac_ctx->psoc, &cmd, true); 703 if (cmd.vdev) 704 wlan_objmgr_vdev_release_ref(cmd.vdev, WLAN_LEGACY_SME_ID); 705 if (!tcmd) { 706 sme_err("No cmd found"); 707 return NULL; 708 } 709 sme_cmd = tcmd->umac_cmd; 710 return &sme_cmd->Link; 711 } 712 713 tListElem *csr_nonscan_pending_ll_next(struct sAniSirGlobal *mac_ctx, 714 tListElem *entry, bool inter_locked) 715 { 716 tSmeCmd *sme_cmd; 717 struct wlan_serialization_command cmd, *tcmd; 718 719 if (!entry) 720 return NULL; 721 sme_cmd = GET_BASE_ADDR(entry, tSmeCmd, Link); 722 if (sme_cmd->command == eSmeCommandScan) 723 cmd.cmd_id = sme_cmd->u.scanCmd.scanID; 724 else 725 cmd.cmd_id = 0; 726 cmd.cmd_type = csr_get_cmd_type(sme_cmd); 727 cmd.vdev = wlan_objmgr_get_vdev_by_id_from_psoc(mac_ctx->psoc, 728 sme_cmd->sessionId, WLAN_LEGACY_SME_ID); 729 tcmd = wlan_serialization_get_pending_list_next_node_using_psoc( 730 mac_ctx->psoc, &cmd, false); 731 if (cmd.vdev) 732 wlan_objmgr_vdev_release_ref(cmd.vdev, WLAN_LEGACY_SME_ID); 733 if (!tcmd) { 734 sme_err("No cmd found"); 735 return NULL; 736 } 737 sme_cmd = tcmd->umac_cmd; 738 return &sme_cmd->Link; 739 } 740 741 bool csr_get_bss_id_bss_desc(tHalHandle hHal, tSirBssDescription *pSirBssDesc, 742 struct qdf_mac_addr *pBssId) 743 { 744 qdf_mem_copy(pBssId, &pSirBssDesc->bssId[0], 745 sizeof(struct qdf_mac_addr)); 746 return true; 747 } 748 749 bool csr_is_bss_id_equal(tHalHandle hHal, tSirBssDescription *pSirBssDesc1, 750 tSirBssDescription *pSirBssDesc2) 751 { 752 tpAniSirGlobal pMac = PMAC_STRUCT(hHal); 753 bool fEqual = false; 754 struct qdf_mac_addr bssId1; 755 struct qdf_mac_addr bssId2; 756 757 do { 758 if (!pSirBssDesc1) 759 break; 760 if (!pSirBssDesc2) 761 break; 762 763 if (!csr_get_bss_id_bss_desc(pMac, pSirBssDesc1, &bssId1)) 764 break; 765 if (!csr_get_bss_id_bss_desc(pMac, pSirBssDesc2, &bssId2)) 766 break; 767 768 fEqual = qdf_is_macaddr_equal(&bssId1, &bssId2); 769 } while (0); 770 771 return fEqual; 772 } 773 774 bool csr_is_conn_state_connected_ibss(tpAniSirGlobal pMac, uint32_t sessionId) 775 { 776 return eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED == 777 pMac->roam.roamSession[sessionId].connectState; 778 } 779 780 bool csr_is_conn_state_disconnected_ibss(tpAniSirGlobal pMac, 781 uint32_t sessionId) 782 { 783 return eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED == 784 pMac->roam.roamSession[sessionId].connectState; 785 } 786 787 bool csr_is_conn_state_connected_infra(tpAniSirGlobal pMac, uint32_t sessionId) 788 { 789 return eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED == 790 pMac->roam.roamSession[sessionId].connectState; 791 } 792 793 bool csr_is_conn_state_connected(tpAniSirGlobal pMac, uint32_t sessionId) 794 { 795 if (csr_is_conn_state_connected_ibss(pMac, sessionId) 796 || csr_is_conn_state_connected_infra(pMac, sessionId) 797 || csr_is_conn_state_connected_wds(pMac, sessionId)) 798 return true; 799 else 800 return false; 801 } 802 803 bool csr_is_conn_state_infra(tpAniSirGlobal pMac, uint32_t sessionId) 804 { 805 return csr_is_conn_state_connected_infra(pMac, sessionId); 806 } 807 808 bool csr_is_conn_state_ibss(tpAniSirGlobal pMac, uint32_t sessionId) 809 { 810 return csr_is_conn_state_connected_ibss(pMac, sessionId) || 811 csr_is_conn_state_disconnected_ibss(pMac, sessionId); 812 } 813 814 bool csr_is_conn_state_connected_wds(tpAniSirGlobal pMac, uint32_t sessionId) 815 { 816 return eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED == 817 pMac->roam.roamSession[sessionId].connectState; 818 } 819 820 bool csr_is_conn_state_connected_infra_ap(tpAniSirGlobal pMac, 821 uint32_t sessionId) 822 { 823 return (eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED == 824 pMac->roam.roamSession[sessionId].connectState) || 825 (eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED == 826 pMac->roam.roamSession[sessionId].connectState); 827 } 828 829 bool csr_is_conn_state_disconnected_wds(tpAniSirGlobal pMac, uint32_t sessionId) 830 { 831 return eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED == 832 pMac->roam.roamSession[sessionId].connectState; 833 } 834 835 bool csr_is_conn_state_wds(tpAniSirGlobal pMac, uint32_t sessionId) 836 { 837 return csr_is_conn_state_connected_wds(pMac, sessionId) || 838 csr_is_conn_state_disconnected_wds(pMac, sessionId); 839 } 840 841 static bool csr_is_conn_state_ap(tpAniSirGlobal pMac, uint32_t sessionId) 842 { 843 struct csr_roam_session *pSession; 844 845 pSession = CSR_GET_SESSION(pMac, sessionId); 846 if (!pSession) 847 return false; 848 if (CSR_IS_INFRA_AP(&pSession->connectedProfile)) 849 return true; 850 return false; 851 } 852 853 bool csr_is_any_session_in_connect_state(tpAniSirGlobal pMac) 854 { 855 uint32_t i; 856 bool fRc = false; 857 858 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { 859 if (CSR_IS_SESSION_VALID(pMac, i) && 860 (csr_is_conn_state_infra(pMac, i) 861 || csr_is_conn_state_ibss(pMac, i) 862 || csr_is_conn_state_ap(pMac, i))) { 863 fRc = true; 864 break; 865 } 866 } 867 868 return fRc; 869 } 870 871 int8_t csr_get_infra_session_id(tpAniSirGlobal pMac) 872 { 873 uint8_t i; 874 int8_t sessionid = -1; 875 876 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { 877 if (CSR_IS_SESSION_VALID(pMac, i) 878 && csr_is_conn_state_infra(pMac, i)) { 879 sessionid = i; 880 break; 881 } 882 } 883 884 return sessionid; 885 } 886 887 uint8_t csr_get_infra_operation_channel(tpAniSirGlobal pMac, uint8_t sessionId) 888 { 889 uint8_t channel; 890 891 if (CSR_IS_SESSION_VALID(pMac, sessionId)) { 892 channel = 893 pMac->roam.roamSession[sessionId].connectedProfile. 894 operationChannel; 895 } else { 896 channel = 0; 897 } 898 return channel; 899 } 900 901 bool csr_is_session_client_and_connected(tpAniSirGlobal pMac, uint8_t sessionId) 902 { 903 struct csr_roam_session *pSession = NULL; 904 905 if (CSR_IS_SESSION_VALID(pMac, sessionId) 906 && csr_is_conn_state_infra(pMac, sessionId)) { 907 pSession = CSR_GET_SESSION(pMac, sessionId); 908 if (NULL != pSession->pCurRoamProfile) { 909 if ((pSession->pCurRoamProfile->csrPersona == 910 QDF_STA_MODE) 911 || (pSession->pCurRoamProfile->csrPersona == 912 QDF_P2P_CLIENT_MODE)) 913 return true; 914 } 915 } 916 return false; 917 } 918 919 /** 920 * csr_get_concurrent_operation_channel() - To get concurrent operating channel 921 * @mac_ctx: Pointer to mac context 922 * 923 * This routine will return operating channel on FIRST BSS that is 924 * active/operating to be used for concurrency mode. 925 * If other BSS is not up or not connected it will return 0 926 * 927 * Return: uint8_t 928 */ 929 uint8_t csr_get_concurrent_operation_channel(tpAniSirGlobal mac_ctx) 930 { 931 struct csr_roam_session *session = NULL; 932 uint8_t i = 0; 933 enum QDF_OPMODE persona; 934 935 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { 936 if (!CSR_IS_SESSION_VALID(mac_ctx, i)) 937 continue; 938 session = CSR_GET_SESSION(mac_ctx, i); 939 if (NULL == session->pCurRoamProfile) 940 continue; 941 persona = session->pCurRoamProfile->csrPersona; 942 if ((((persona == QDF_STA_MODE) || 943 (persona == QDF_P2P_CLIENT_MODE)) && 944 (session->connectState == 945 eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED)) || 946 (((persona == QDF_P2P_GO_MODE) || 947 (persona == QDF_SAP_MODE)) 948 && (session->connectState != 949 eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED))) 950 return session->connectedProfile.operationChannel; 951 952 } 953 return 0; 954 } 955 956 #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH 957 958 #define HALF_BW_OF(eCSR_bw_val) ((eCSR_bw_val)/2) 959 960 /* calculation of center channel based on V/HT BW and WIFI channel bw=5MHz) */ 961 962 #define CSR_GET_HT40_PLUS_CCH(och) ((och)+2) 963 #define CSR_GET_HT40_MINUS_CCH(och) ((och)-2) 964 965 #define CSR_GET_HT80_PLUS_LL_CCH(och) ((och)+6) 966 #define CSR_GET_HT80_PLUS_HL_CCH(och) ((och)+2) 967 #define CSR_GET_HT80_MINUS_LH_CCH(och) ((och)-2) 968 #define CSR_GET_HT80_MINUS_HH_CCH(och) ((och)-6) 969 970 /** 971 * csr_get_ch_from_ht_profile() - to get channel from HT profile 972 * @pMac: pointer to Mac context 973 * @htp: pointer to HT profile 974 * @och: operating channel 975 * @cfreq: channel frequency 976 * @hbw: half bandwidth 977 * 978 * This function will fill half bandwidth and channel frequency based 979 * on the HT profile 980 * 981 * Return: none 982 */ 983 static void csr_get_ch_from_ht_profile(tpAniSirGlobal pMac, 984 tCsrRoamHTProfile *htp, 985 uint16_t och, uint16_t *cfreq, 986 uint16_t *hbw) 987 { 988 uint16_t cch, ch_bond; 989 990 if (och > 14) 991 ch_bond = pMac->roam.configParam.channelBondingMode5GHz; 992 else 993 ch_bond = pMac->roam.configParam.channelBondingMode24GHz; 994 995 cch = och; 996 *hbw = HALF_BW_OF(eCSR_BW_20MHz_VAL); 997 998 if (!ch_bond) 999 goto ret; 1000 1001 sme_debug("HTC: %d scbw: %d rcbw: %d sco: %d VHTC: %d apc: %d apbw: %d", 1002 htp->htCapability, htp->htSupportedChannelWidthSet, 1003 htp->htRecommendedTxWidthSet, 1004 htp->htSecondaryChannelOffset, 1005 htp->vhtCapability, htp->apCenterChan, htp->apChanWidth 1006 ); 1007 1008 if (htp->vhtCapability) { 1009 cch = htp->apCenterChan; 1010 if (htp->apChanWidth == WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ) 1011 *hbw = HALF_BW_OF(eCSR_BW_80MHz_VAL); 1012 else if (htp->apChanWidth == WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) 1013 *hbw = HALF_BW_OF(eCSR_BW_160MHz_VAL); 1014 1015 if (!*hbw && htp->htCapability) { 1016 if (htp->htSupportedChannelWidthSet == 1017 eHT_CHANNEL_WIDTH_40MHZ) 1018 *hbw = HALF_BW_OF(eCSR_BW_40MHz_VAL); 1019 else 1020 *hbw = HALF_BW_OF(eCSR_BW_20MHz_VAL); 1021 } 1022 } else if (htp->htCapability) { 1023 if (htp->htSupportedChannelWidthSet == 1024 eHT_CHANNEL_WIDTH_40MHZ) { 1025 *hbw = HALF_BW_OF(eCSR_BW_40MHz_VAL); 1026 if (htp->htSecondaryChannelOffset == 1027 PHY_DOUBLE_CHANNEL_LOW_PRIMARY) 1028 cch = CSR_GET_HT40_PLUS_CCH(och); 1029 else if (htp->htSecondaryChannelOffset == 1030 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY) 1031 cch = CSR_GET_HT40_MINUS_CCH(och); 1032 } else { 1033 cch = och; 1034 *hbw = HALF_BW_OF(eCSR_BW_20MHz_VAL); 1035 } 1036 } 1037 1038 ret: 1039 *cfreq = cds_chan_to_freq(cch); 1040 } 1041 1042 /** 1043 * csr_calc_chb_for_sap_phymode() - to calc channel bandwidth for sap phymode 1044 * @mac_ctx: pointer to mac context 1045 * @sap_ch: SAP operating channel 1046 * @sap_phymode: SAP physical mode 1047 * @sap_cch: concurrency channel 1048 * @sap_hbw: SAP half bw 1049 * @chb: channel bandwidth 1050 * 1051 * This routine is called to calculate channel bandwidth 1052 * 1053 * Return: none 1054 */ 1055 static void csr_calc_chb_for_sap_phymode(tpAniSirGlobal mac_ctx, 1056 uint16_t *sap_ch, eCsrPhyMode *sap_phymode, 1057 uint16_t *sap_cch, uint16_t *sap_hbw, uint8_t *chb) 1058 { 1059 if (*sap_phymode == eCSR_DOT11_MODE_11n || 1060 *sap_phymode == eCSR_DOT11_MODE_11n_ONLY) { 1061 1062 *sap_hbw = HALF_BW_OF(eCSR_BW_40MHz_VAL); 1063 if (*chb == PHY_DOUBLE_CHANNEL_LOW_PRIMARY) 1064 *sap_cch = CSR_GET_HT40_PLUS_CCH(*sap_ch); 1065 else if (*chb == PHY_DOUBLE_CHANNEL_HIGH_PRIMARY) 1066 *sap_cch = CSR_GET_HT40_MINUS_CCH(*sap_ch); 1067 1068 } else if (*sap_phymode == eCSR_DOT11_MODE_11ac || 1069 *sap_phymode == eCSR_DOT11_MODE_11ac_ONLY || 1070 *sap_phymode == eCSR_DOT11_MODE_11ax || 1071 *sap_phymode == eCSR_DOT11_MODE_11ax_ONLY) { 1072 /*11AC only 80/40/20 Mhz supported in Rome */ 1073 if (mac_ctx->roam.configParam.nVhtChannelWidth == 1074 (WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1)) { 1075 *sap_hbw = HALF_BW_OF(eCSR_BW_80MHz_VAL); 1076 if (*chb == 1077 (PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW - 1)) 1078 *sap_cch = CSR_GET_HT80_PLUS_LL_CCH(*sap_ch); 1079 else if (*chb == 1080 (PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW 1081 - 1)) 1082 *sap_cch = CSR_GET_HT80_PLUS_HL_CCH(*sap_ch); 1083 else if (*chb == 1084 (PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH 1085 - 1)) 1086 *sap_cch = CSR_GET_HT80_MINUS_LH_CCH(*sap_ch); 1087 else if (*chb == 1088 (PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH 1089 - 1)) 1090 *sap_cch = CSR_GET_HT80_MINUS_HH_CCH(*sap_ch); 1091 } else { 1092 *sap_hbw = HALF_BW_OF(eCSR_BW_40MHz_VAL); 1093 if (*chb == (PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW 1094 - 1)) 1095 *sap_cch = CSR_GET_HT40_PLUS_CCH(*sap_ch); 1096 else if (*chb == 1097 (PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW 1098 - 1)) 1099 *sap_cch = CSR_GET_HT40_MINUS_CCH(*sap_ch); 1100 else if (*chb == 1101 (PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH 1102 - 1)) 1103 *sap_cch = CSR_GET_HT40_PLUS_CCH(*sap_ch); 1104 else if (*chb == 1105 (PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH 1106 - 1)) 1107 *sap_cch = CSR_GET_HT40_MINUS_CCH(*sap_ch); 1108 } 1109 } 1110 } 1111 1112 /** 1113 * csr_handle_conc_chnl_overlap_for_sap_go - To handle overlap for AP+AP 1114 * @mac_ctx: pointer to mac context 1115 * @session: Current session 1116 * @sap_ch: SAP/GO operating channel 1117 * @sap_hbw: SAP/GO half bw 1118 * @sap_cfreq: SAP/GO channel frequency 1119 * @intf_ch: concurrent SAP/GO operating channel 1120 * @intf_hbw: concurrent SAP/GO half bw 1121 * @intf_cfreq: concurrent SAP/GO channel frequency 1122 * 1123 * This routine is called to check if one SAP/GO channel is overlapping with 1124 * other SAP/GO channel 1125 * 1126 * Return: none 1127 */ 1128 static void csr_handle_conc_chnl_overlap_for_sap_go(tpAniSirGlobal mac_ctx, 1129 struct csr_roam_session *session, 1130 uint16_t *sap_ch, uint16_t *sap_hbw, uint16_t *sap_cfreq, 1131 uint16_t *intf_ch, uint16_t *intf_hbw, uint16_t *intf_cfreq) 1132 { 1133 /* 1134 * if conc_custom_rule1 is defined then we don't 1135 * want p2pgo to follow SAP's channel or SAP to 1136 * follow P2PGO's channel. 1137 */ 1138 if (0 == mac_ctx->roam.configParam.conc_custom_rule1 && 1139 0 == mac_ctx->roam.configParam.conc_custom_rule2) { 1140 if (*sap_ch == 0) { 1141 *sap_ch = session->connectedProfile.operationChannel; 1142 csr_get_ch_from_ht_profile(mac_ctx, 1143 &session->connectedProfile.HTProfile, 1144 *sap_ch, sap_cfreq, sap_hbw); 1145 } else if (*sap_ch != 1146 session->connectedProfile.operationChannel) { 1147 *intf_ch = session->connectedProfile.operationChannel; 1148 csr_get_ch_from_ht_profile(mac_ctx, 1149 &session->connectedProfile.HTProfile, 1150 *intf_ch, intf_cfreq, intf_hbw); 1151 } 1152 } else if (*sap_ch == 0 && 1153 (session->pCurRoamProfile->csrPersona == 1154 QDF_SAP_MODE)) { 1155 *sap_ch = session->connectedProfile.operationChannel; 1156 csr_get_ch_from_ht_profile(mac_ctx, 1157 &session->connectedProfile.HTProfile, 1158 *sap_ch, sap_cfreq, sap_hbw); 1159 } 1160 } 1161 1162 1163 /** 1164 * csr_check_concurrent_channel_overlap() - To check concurrent overlap chnls 1165 * @mac_ctx: Pointer to mac context 1166 * @sap_ch: SAP channel 1167 * @sap_phymode: SAP phy mode 1168 * @cc_switch_mode: concurrent switch mode 1169 * 1170 * This routine will be called to check concurrent overlap channels 1171 * 1172 * Return: uint16_t 1173 */ 1174 uint16_t csr_check_concurrent_channel_overlap(tpAniSirGlobal mac_ctx, 1175 uint16_t sap_ch, eCsrPhyMode sap_phymode, 1176 uint8_t cc_switch_mode) 1177 { 1178 struct csr_roam_session *session = NULL; 1179 uint8_t i = 0, chb = PHY_SINGLE_CHANNEL_CENTERED; 1180 uint16_t intf_ch = 0, sap_hbw = 0, intf_hbw = 0, intf_cfreq = 0; 1181 uint16_t sap_cfreq = 0; 1182 uint16_t sap_lfreq, sap_hfreq, intf_lfreq, intf_hfreq, sap_cch = 0; 1183 QDF_STATUS status; 1184 1185 sme_debug("sap_ch: %d sap_phymode: %d", sap_ch, sap_phymode); 1186 1187 if (mac_ctx->roam.configParam.cc_switch_mode == 1188 QDF_MCC_TO_SCC_SWITCH_DISABLE) 1189 return 0; 1190 1191 if (sap_ch != 0) { 1192 sap_cch = sap_ch; 1193 sap_hbw = HALF_BW_OF(eCSR_BW_20MHz_VAL); 1194 1195 if (sap_ch > 14) 1196 chb = mac_ctx->roam.configParam.channelBondingMode5GHz; 1197 else 1198 chb = mac_ctx->roam.configParam.channelBondingMode24GHz; 1199 1200 if (chb) 1201 csr_calc_chb_for_sap_phymode(mac_ctx, &sap_ch, 1202 &sap_phymode, &sap_cch, &sap_hbw, &chb); 1203 sap_cfreq = cds_chan_to_freq(sap_cch); 1204 } 1205 1206 sme_debug("sap_ch:%d sap_phymode:%d sap_cch:%d sap_hbw:%d chb:%d", 1207 sap_ch, sap_phymode, sap_cch, sap_hbw, chb); 1208 1209 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { 1210 if (!CSR_IS_SESSION_VALID(mac_ctx, i)) 1211 continue; 1212 1213 session = CSR_GET_SESSION(mac_ctx, i); 1214 if (NULL == session->pCurRoamProfile) 1215 continue; 1216 if (((session->pCurRoamProfile->csrPersona == QDF_STA_MODE) || 1217 (session->pCurRoamProfile->csrPersona == 1218 QDF_P2P_CLIENT_MODE)) && 1219 (session->connectState == 1220 eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED)) { 1221 intf_ch = session->connectedProfile.operationChannel; 1222 csr_get_ch_from_ht_profile(mac_ctx, 1223 &session->connectedProfile.HTProfile, 1224 intf_ch, &intf_cfreq, &intf_hbw); 1225 sme_debug("%d: intf_ch:%d intf_cfreq:%d intf_hbw:%d", 1226 i, intf_ch, intf_cfreq, intf_hbw); 1227 } else if (((session->pCurRoamProfile->csrPersona == 1228 QDF_P2P_GO_MODE) || 1229 (session->pCurRoamProfile->csrPersona == 1230 QDF_SAP_MODE)) && 1231 (session->connectState != 1232 eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED)) { 1233 if (session->ch_switch_in_progress) 1234 continue; 1235 1236 csr_handle_conc_chnl_overlap_for_sap_go(mac_ctx, 1237 session, &sap_ch, &sap_hbw, &sap_cfreq, 1238 &intf_ch, &intf_hbw, &intf_cfreq); 1239 1240 sme_debug("%d: sap_ch:%d sap_hbw:%d sap_cfreq:%d intf_ch:%d intf_hbw:%d, intf_cfreq:%d", 1241 i, sap_ch, sap_hbw, sap_cfreq, 1242 intf_ch, intf_hbw, intf_cfreq); 1243 } 1244 if (intf_ch && ((intf_ch > 14 && sap_ch > 14) || 1245 (intf_ch <= 14 && sap_ch <= 14))) 1246 break; 1247 } 1248 1249 sme_debug("intf_ch:%d sap_ch:%d cc_switch_mode:%d, dbs:%d", 1250 intf_ch, sap_ch, cc_switch_mode, 1251 policy_mgr_is_dbs_enable(mac_ctx->psoc)); 1252 1253 if (intf_ch && sap_ch != intf_ch && 1254 cc_switch_mode != QDF_MCC_TO_SCC_SWITCH_FORCE && 1255 cc_switch_mode != 1256 QDF_MCC_TO_SCC_SWITCH_FORCE_WITHOUT_DISCONNECTION && 1257 cc_switch_mode != 1258 QDF_MCC_TO_SCC_SWITCH_WITH_FAVORITE_CHANNEL && 1259 cc_switch_mode != 1260 QDF_MCC_TO_SCC_SWITCH_FORCE_PREFERRED_WITHOUT_DISCONNECTION) { 1261 sap_lfreq = sap_cfreq - sap_hbw; 1262 sap_hfreq = sap_cfreq + sap_hbw; 1263 intf_lfreq = intf_cfreq - intf_hbw; 1264 intf_hfreq = intf_cfreq + intf_hbw; 1265 1266 sme_err("SAP: OCH: %03d OCF: %d CCH: %03d CF: %d BW: %d LF: %d HF: %d INTF: OCH: %03d OCF: %d CCH: %03d CF: %d BW: %d LF: %d HF: %d", 1267 sap_ch, cds_chan_to_freq(sap_ch), 1268 cds_freq_to_chan(sap_cfreq), sap_cfreq, sap_hbw * 2, 1269 sap_lfreq, sap_hfreq, intf_ch, 1270 cds_chan_to_freq(intf_ch), cds_freq_to_chan(intf_cfreq), 1271 intf_cfreq, intf_hbw * 2, intf_lfreq, intf_hfreq); 1272 1273 if (!(((sap_lfreq > intf_lfreq && sap_lfreq < intf_hfreq) || 1274 (sap_hfreq > intf_lfreq && sap_hfreq < intf_hfreq)) || 1275 ((intf_lfreq > sap_lfreq && intf_lfreq < sap_hfreq) || 1276 (intf_hfreq > sap_lfreq && intf_hfreq < sap_hfreq)))) 1277 intf_ch = 0; 1278 } else if (intf_ch && sap_ch != intf_ch && 1279 ((cc_switch_mode == QDF_MCC_TO_SCC_SWITCH_FORCE) || 1280 (cc_switch_mode == 1281 QDF_MCC_TO_SCC_SWITCH_FORCE_WITHOUT_DISCONNECTION) || 1282 (cc_switch_mode == 1283 QDF_MCC_TO_SCC_SWITCH_WITH_FAVORITE_CHANNEL) || 1284 (cc_switch_mode == 1285 QDF_MCC_TO_SCC_SWITCH_FORCE_PREFERRED_WITHOUT_DISCONNECTION))) { 1286 if (!((intf_ch <= 14 && sap_ch <= 14) || 1287 (intf_ch > 14 && sap_ch > 14))) { 1288 if (policy_mgr_is_dbs_enable(mac_ctx->psoc)) 1289 intf_ch = 0; 1290 } else if (cc_switch_mode == 1291 QDF_MCC_TO_SCC_SWITCH_WITH_FAVORITE_CHANNEL) { 1292 status = 1293 policy_mgr_get_sap_mandatory_channel( 1294 mac_ctx->psoc, 1295 (uint32_t *)&intf_ch); 1296 if (QDF_IS_STATUS_ERROR(status)) 1297 sme_err("no mandatory channel"); 1298 } 1299 } else if ((intf_ch == sap_ch) && (cc_switch_mode == 1300 QDF_MCC_TO_SCC_SWITCH_WITH_FAVORITE_CHANNEL)) { 1301 if (cds_chan_to_band(intf_ch) == CDS_BAND_2GHZ) { 1302 status = 1303 policy_mgr_get_sap_mandatory_channel( 1304 mac_ctx->psoc, (uint32_t *)&intf_ch); 1305 if (QDF_IS_STATUS_ERROR(status)) 1306 sme_err("no mandatory channel"); 1307 } 1308 } 1309 1310 if (intf_ch == sap_ch) 1311 intf_ch = 0; 1312 1313 sme_err("##Concurrent Channels %s Interfering", 1314 intf_ch == 0 ? "Not" : "Are"); 1315 return intf_ch; 1316 } 1317 #endif 1318 1319 bool csr_is_all_session_disconnected(tpAniSirGlobal pMac) 1320 { 1321 uint32_t i; 1322 bool fRc = true; 1323 1324 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { 1325 if (CSR_IS_SESSION_VALID(pMac, i) 1326 && !csr_is_conn_state_disconnected(pMac, i)) { 1327 fRc = false; 1328 break; 1329 } 1330 } 1331 1332 return fRc; 1333 } 1334 1335 /** 1336 * csr_is_sta_session_connected() - to find if concurrent sta is active 1337 * @mac_ctx: pointer to mac context 1338 * 1339 * This function will iterate through each session and check if sta 1340 * session exist and active 1341 * 1342 * Return: true or false 1343 */ 1344 bool csr_is_sta_session_connected(tpAniSirGlobal mac_ctx) 1345 { 1346 uint32_t i; 1347 struct csr_roam_session *pSession = NULL; 1348 1349 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { 1350 if (CSR_IS_SESSION_VALID(mac_ctx, i) && 1351 !csr_is_conn_state_disconnected(mac_ctx, i)) { 1352 pSession = CSR_GET_SESSION(mac_ctx, i); 1353 1354 if ((NULL != pSession->pCurRoamProfile) && 1355 (QDF_STA_MODE == 1356 pSession->pCurRoamProfile->csrPersona)) 1357 return true; 1358 } 1359 } 1360 1361 return false; 1362 } 1363 1364 /** 1365 * csr_is_p2p_session_connected() - to find if any p2p session is active 1366 * @mac_ctx: pointer to mac context 1367 * 1368 * This function will iterate through each session and check if any p2p 1369 * session exist and active 1370 * 1371 * Return: true or false 1372 */ 1373 bool csr_is_p2p_session_connected(tpAniSirGlobal pMac) 1374 { 1375 uint32_t i; 1376 struct csr_roam_session *pSession = NULL; 1377 enum QDF_OPMODE persona; 1378 1379 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { 1380 if (!CSR_IS_SESSION_VALID(pMac, i)) 1381 continue; 1382 1383 if (csr_is_conn_state_disconnected(pMac, i)) 1384 continue; 1385 1386 pSession = CSR_GET_SESSION(pMac, i); 1387 if (pSession->pCurRoamProfile == NULL) 1388 continue; 1389 1390 persona = pSession->pCurRoamProfile->csrPersona; 1391 if (QDF_P2P_CLIENT_MODE == persona || 1392 QDF_P2P_GO_MODE == persona) 1393 return true; 1394 } 1395 1396 return false; 1397 } 1398 1399 bool csr_is_any_session_connected(tpAniSirGlobal pMac) 1400 { 1401 uint32_t i, count; 1402 bool fRc = false; 1403 1404 count = 0; 1405 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { 1406 if (CSR_IS_SESSION_VALID(pMac, i) 1407 && !csr_is_conn_state_disconnected(pMac, i)) 1408 count++; 1409 } 1410 1411 if (count > 0) 1412 fRc = true; 1413 return fRc; 1414 } 1415 1416 bool csr_is_infra_connected(tpAniSirGlobal pMac) 1417 { 1418 uint32_t i; 1419 bool fRc = false; 1420 1421 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { 1422 if (CSR_IS_SESSION_VALID(pMac, i) 1423 && csr_is_conn_state_connected_infra(pMac, i)) { 1424 fRc = true; 1425 break; 1426 } 1427 } 1428 1429 return fRc; 1430 } 1431 1432 bool csr_is_concurrent_infra_connected(tpAniSirGlobal pMac) 1433 { 1434 uint32_t i, noOfConnectedInfra = 0; 1435 1436 bool fRc = false; 1437 1438 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { 1439 if (CSR_IS_SESSION_VALID(pMac, i) 1440 && csr_is_conn_state_connected_infra(pMac, i)) { 1441 ++noOfConnectedInfra; 1442 } 1443 } 1444 1445 /* More than one Infra Sta Connected */ 1446 if (noOfConnectedInfra > 1) 1447 fRc = true; 1448 return fRc; 1449 } 1450 1451 bool csr_is_ibss_started(tpAniSirGlobal pMac) 1452 { 1453 uint32_t i; 1454 bool fRc = false; 1455 1456 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { 1457 if (CSR_IS_SESSION_VALID(pMac, i) 1458 && csr_is_conn_state_ibss(pMac, i)) { 1459 fRc = true; 1460 break; 1461 } 1462 } 1463 1464 return fRc; 1465 } 1466 1467 bool csr_is_concurrent_session_running(tpAniSirGlobal pMac) 1468 { 1469 uint32_t sessionId, noOfCocurrentSession = 0; 1470 eCsrConnectState connectState; 1471 1472 bool fRc = false; 1473 1474 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++) { 1475 if (CSR_IS_SESSION_VALID(pMac, sessionId)) { 1476 connectState = 1477 pMac->roam.roamSession[sessionId].connectState; 1478 if ((eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED == 1479 connectState) 1480 || (eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED == 1481 connectState) 1482 || (eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED == 1483 connectState)) { 1484 ++noOfCocurrentSession; 1485 } 1486 } 1487 } 1488 1489 /* More than one session is Up and Running */ 1490 if (noOfCocurrentSession > 1) 1491 fRc = true; 1492 return fRc; 1493 } 1494 1495 bool csr_is_infra_ap_started(tpAniSirGlobal pMac) 1496 { 1497 uint32_t sessionId; 1498 bool fRc = false; 1499 1500 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++) { 1501 if (CSR_IS_SESSION_VALID(pMac, sessionId) && 1502 (csr_is_conn_state_connected_infra_ap(pMac, 1503 sessionId))) { 1504 fRc = true; 1505 break; 1506 } 1507 } 1508 1509 return fRc; 1510 1511 } 1512 1513 bool csr_is_conn_state_disconnected(tpAniSirGlobal pMac, uint32_t sessionId) 1514 { 1515 return eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED == 1516 pMac->roam.roamSession[sessionId].connectState; 1517 } 1518 1519 /** 1520 * csr_is_valid_mc_concurrent_session() - To check concurren session is valid 1521 * @mac_ctx: pointer to mac context 1522 * @session_id: session id 1523 * @bss_descr: bss description 1524 * 1525 * This function validates the concurrent session 1526 * 1527 * Return: true or false 1528 */ 1529 bool csr_is_valid_mc_concurrent_session(tpAniSirGlobal mac_ctx, 1530 uint32_t session_id, 1531 tSirBssDescription *bss_descr) 1532 { 1533 struct csr_roam_session *pSession = NULL; 1534 1535 /* Check for MCC support */ 1536 if (!mac_ctx->roam.configParam.fenableMCCMode) 1537 return false; 1538 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) 1539 return false; 1540 /* Validate BeaconInterval */ 1541 pSession = CSR_GET_SESSION(mac_ctx, session_id); 1542 if (NULL == pSession->pCurRoamProfile) 1543 return false; 1544 if (QDF_STATUS_SUCCESS == csr_validate_mcc_beacon_interval(mac_ctx, 1545 bss_descr->channelId, 1546 &bss_descr->beaconInterval, session_id, 1547 pSession->pCurRoamProfile->csrPersona)) 1548 return true; 1549 return false; 1550 } 1551 1552 static tSirMacCapabilityInfo csr_get_bss_capabilities(tSirBssDescription * 1553 pSirBssDesc) 1554 { 1555 tSirMacCapabilityInfo dot11Caps; 1556 1557 /* tSirMacCapabilityInfo is 16-bit */ 1558 qdf_get_u16((uint8_t *) &pSirBssDesc->capabilityInfo, 1559 (uint16_t *) &dot11Caps); 1560 1561 return dot11Caps; 1562 } 1563 1564 bool csr_is_infra_bss_desc(tSirBssDescription *pSirBssDesc) 1565 { 1566 tSirMacCapabilityInfo dot11Caps = csr_get_bss_capabilities(pSirBssDesc); 1567 1568 return (bool) dot11Caps.ess; 1569 } 1570 1571 bool csr_is_ibss_bss_desc(tSirBssDescription *pSirBssDesc) 1572 { 1573 tSirMacCapabilityInfo dot11Caps = csr_get_bss_capabilities(pSirBssDesc); 1574 1575 return (bool) dot11Caps.ibss; 1576 } 1577 1578 static bool csr_is_qos_bss_desc(tSirBssDescription *pSirBssDesc) 1579 { 1580 tSirMacCapabilityInfo dot11Caps = csr_get_bss_capabilities(pSirBssDesc); 1581 1582 return (bool) dot11Caps.qos; 1583 } 1584 1585 bool csr_is_privacy(tSirBssDescription *pSirBssDesc) 1586 { 1587 tSirMacCapabilityInfo dot11Caps = csr_get_bss_capabilities(pSirBssDesc); 1588 1589 return (bool) dot11Caps.privacy; 1590 } 1591 1592 bool csr_is11d_supported(tpAniSirGlobal pMac) 1593 { 1594 return pMac->roam.configParam.Is11dSupportEnabled; 1595 } 1596 1597 bool csr_is11h_supported(tpAniSirGlobal pMac) 1598 { 1599 return pMac->roam.configParam.Is11hSupportEnabled; 1600 } 1601 1602 bool csr_is11e_supported(tpAniSirGlobal pMac) 1603 { 1604 return pMac->roam.configParam.Is11eSupportEnabled; 1605 } 1606 1607 bool csr_is_mcc_supported(tpAniSirGlobal pMac) 1608 { 1609 return pMac->roam.configParam.fenableMCCMode; 1610 1611 } 1612 1613 bool csr_is_wmm_supported(tpAniSirGlobal pMac) 1614 { 1615 if (eCsrRoamWmmNoQos == pMac->roam.configParam.WMMSupportMode) 1616 return false; 1617 else 1618 return true; 1619 } 1620 1621 /* pIes is the IEs for pSirBssDesc2 */ 1622 bool csr_is_ssid_equal(tHalHandle hHal, tSirBssDescription *pSirBssDesc1, 1623 tSirBssDescription *pSirBssDesc2, tDot11fBeaconIEs *pIes2) 1624 { 1625 bool fEqual = false; 1626 tSirMacSSid Ssid1, Ssid2; 1627 tpAniSirGlobal pMac = PMAC_STRUCT(hHal); 1628 tDot11fBeaconIEs *pIes1 = NULL; 1629 tDot11fBeaconIEs *pIesLocal = pIes2; 1630 1631 do { 1632 if ((NULL == pSirBssDesc1) || (NULL == pSirBssDesc2)) 1633 break; 1634 if (!pIesLocal 1635 && 1636 !QDF_IS_STATUS_SUCCESS(csr_get_parsed_bss_description_ies 1637 (pMac, pSirBssDesc2, 1638 &pIesLocal))) { 1639 sme_err("fail to parse IEs"); 1640 break; 1641 } 1642 if (!QDF_IS_STATUS_SUCCESS 1643 (csr_get_parsed_bss_description_ies(pMac, 1644 pSirBssDesc1, &pIes1))) { 1645 break; 1646 } 1647 if ((!pIes1->SSID.present) || (!pIesLocal->SSID.present)) 1648 break; 1649 if (pIes1->SSID.num_ssid != pIesLocal->SSID.num_ssid) 1650 break; 1651 qdf_mem_copy(Ssid1.ssId, pIes1->SSID.ssid, 1652 pIes1->SSID.num_ssid); 1653 qdf_mem_copy(Ssid2.ssId, pIesLocal->SSID.ssid, 1654 pIesLocal->SSID.num_ssid); 1655 1656 fEqual = (!qdf_mem_cmp(Ssid1.ssId, Ssid2.ssId, 1657 pIesLocal->SSID.num_ssid)); 1658 1659 } while (0); 1660 if (pIes1) 1661 qdf_mem_free(pIes1); 1662 if (pIesLocal && !pIes2) 1663 qdf_mem_free(pIesLocal); 1664 1665 return fEqual; 1666 } 1667 1668 /* pIes can be passed in as NULL if the caller doesn't have one prepared */ 1669 static bool csr_is_bss_description_wme(tHalHandle hHal, 1670 tSirBssDescription *pSirBssDesc, 1671 tDot11fBeaconIEs *pIes) 1672 { 1673 tpAniSirGlobal pMac = PMAC_STRUCT(hHal); 1674 /* Assume that WME is found... */ 1675 bool fWme = true; 1676 tDot11fBeaconIEs *pIesTemp = pIes; 1677 1678 do { 1679 if (pIesTemp == NULL) { 1680 if (!QDF_IS_STATUS_SUCCESS 1681 (csr_get_parsed_bss_description_ies 1682 (pMac, pSirBssDesc, &pIesTemp))) { 1683 fWme = false; 1684 break; 1685 } 1686 } 1687 /* if the Wme Info IE is found, then WME is supported... */ 1688 if (CSR_IS_QOS_BSS(pIesTemp)) 1689 break; 1690 /* if none of these are found, then WME is NOT supported... */ 1691 fWme = false; 1692 } while (0); 1693 if (!csr_is_wmm_supported(pMac) && fWme) 1694 if (!pIesTemp->HTCaps.present) 1695 fWme = false; 1696 1697 if ((pIes == NULL) && (NULL != pIesTemp)) 1698 /* we allocate memory here so free it before returning */ 1699 qdf_mem_free(pIesTemp); 1700 1701 return fWme; 1702 } 1703 1704 eCsrMediaAccessType csr_get_qo_s_from_bss_desc(tHalHandle hHal, 1705 tSirBssDescription *pSirBssDesc, 1706 tDot11fBeaconIEs *pIes) 1707 { 1708 eCsrMediaAccessType qosType = eCSR_MEDIUM_ACCESS_DCF; 1709 1710 if (NULL == pIes) { 1711 QDF_ASSERT(pIes != NULL); 1712 return qosType; 1713 } 1714 1715 do { 1716 /* If we find WMM in the Bss Description, then we let this 1717 * override and use WMM. 1718 */ 1719 if (csr_is_bss_description_wme(hHal, pSirBssDesc, pIes)) 1720 qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP; 1721 else { 1722 /* If the QoS bit is on, then the AP is 1723 * advertising 11E QoS. 1724 */ 1725 if (csr_is_qos_bss_desc(pSirBssDesc)) 1726 qosType = eCSR_MEDIUM_ACCESS_11e_eDCF; 1727 else 1728 qosType = eCSR_MEDIUM_ACCESS_DCF; 1729 1730 /* Scale back based on the types turned on 1731 * for the adapter. 1732 */ 1733 if (eCSR_MEDIUM_ACCESS_11e_eDCF == qosType 1734 && !csr_is11e_supported(hHal)) 1735 qosType = eCSR_MEDIUM_ACCESS_DCF; 1736 } 1737 1738 } while (0); 1739 1740 return qosType; 1741 } 1742 1743 /* Caller allocates memory for pIEStruct */ 1744 QDF_STATUS csr_parse_bss_description_ies(tHalHandle hHal, 1745 tSirBssDescription *pBssDesc, 1746 tDot11fBeaconIEs *pIEStruct) 1747 { 1748 QDF_STATUS status = QDF_STATUS_E_FAILURE; 1749 tpAniSirGlobal pMac = PMAC_STRUCT(hHal); 1750 int ieLen = 1751 (int)(pBssDesc->length + sizeof(pBssDesc->length) - 1752 GET_FIELD_OFFSET(tSirBssDescription, ieFields)); 1753 1754 if (ieLen > 0 && pIEStruct) { 1755 if (!DOT11F_FAILED(dot11f_unpack_beacon_i_es 1756 (pMac, (uint8_t *) pBssDesc->ieFields, 1757 ieLen, pIEStruct, false))) 1758 status = QDF_STATUS_SUCCESS; 1759 } 1760 1761 return status; 1762 } 1763 1764 /* This function will allocate memory for the parsed IEs to the caller. 1765 * Caller must free the memory after it is done with the data only if 1766 * this function succeeds 1767 */ 1768 QDF_STATUS csr_get_parsed_bss_description_ies(tHalHandle hHal, 1769 tSirBssDescription *pBssDesc, 1770 tDot11fBeaconIEs **ppIEStruct) 1771 { 1772 QDF_STATUS status = QDF_STATUS_E_INVAL; 1773 1774 if (pBssDesc && ppIEStruct) { 1775 *ppIEStruct = qdf_mem_malloc(sizeof(tDot11fBeaconIEs)); 1776 if ((*ppIEStruct) != NULL) { 1777 status = 1778 csr_parse_bss_description_ies(hHal, pBssDesc, 1779 *ppIEStruct); 1780 if (!QDF_IS_STATUS_SUCCESS(status)) { 1781 qdf_mem_free(*ppIEStruct); 1782 *ppIEStruct = NULL; 1783 } 1784 } else { 1785 sme_err("failed to allocate memory"); 1786 QDF_ASSERT(0); 1787 return QDF_STATUS_E_NOMEM; 1788 } 1789 } 1790 1791 return status; 1792 } 1793 1794 bool csr_is_nullssid(uint8_t *pBssSsid, uint8_t len) 1795 { 1796 bool fNullSsid = false; 1797 1798 uint32_t SsidLength; 1799 uint8_t *pSsidStr; 1800 1801 do { 1802 if (0 == len) { 1803 fNullSsid = true; 1804 break; 1805 } 1806 /* Consider 0 or space for hidden SSID */ 1807 if (0 == pBssSsid[0]) { 1808 fNullSsid = true; 1809 break; 1810 } 1811 1812 SsidLength = len; 1813 pSsidStr = pBssSsid; 1814 1815 while (SsidLength) { 1816 if (*pSsidStr) 1817 break; 1818 1819 pSsidStr++; 1820 SsidLength--; 1821 } 1822 1823 if (0 == SsidLength) { 1824 fNullSsid = true; 1825 break; 1826 } 1827 } while (0); 1828 1829 return fNullSsid; 1830 } 1831 1832 uint32_t csr_get_frag_thresh(tHalHandle hHal) 1833 { 1834 tpAniSirGlobal pMac = PMAC_STRUCT(hHal); 1835 1836 return pMac->roam.configParam.FragmentationThreshold; 1837 } 1838 1839 uint32_t csr_get_rts_thresh(tHalHandle hHal) 1840 { 1841 tpAniSirGlobal pMac = PMAC_STRUCT(hHal); 1842 1843 return pMac->roam.configParam.RTSThreshold; 1844 } 1845 1846 static eCsrPhyMode csr_translate_to_phy_mode_from_bss_desc( 1847 tSirBssDescription *pSirBssDesc) 1848 { 1849 eCsrPhyMode phyMode; 1850 1851 switch (pSirBssDesc->nwType) { 1852 case eSIR_11A_NW_TYPE: 1853 phyMode = eCSR_DOT11_MODE_11a; 1854 break; 1855 1856 case eSIR_11B_NW_TYPE: 1857 phyMode = eCSR_DOT11_MODE_11b; 1858 break; 1859 1860 case eSIR_11G_NW_TYPE: 1861 phyMode = eCSR_DOT11_MODE_11g; 1862 break; 1863 1864 case eSIR_11N_NW_TYPE: 1865 phyMode = eCSR_DOT11_MODE_11n; 1866 break; 1867 case eSIR_11AX_NW_TYPE: 1868 phyMode = eCSR_DOT11_MODE_11ax; 1869 break; 1870 case eSIR_11AC_NW_TYPE: 1871 default: 1872 phyMode = eCSR_DOT11_MODE_11ac; 1873 break; 1874 } 1875 return phyMode; 1876 } 1877 1878 uint32_t csr_translate_to_wni_cfg_dot11_mode(tpAniSirGlobal pMac, 1879 enum csr_cfgdot11mode csrDot11Mode) 1880 { 1881 uint32_t ret; 1882 1883 switch (csrDot11Mode) { 1884 case eCSR_CFG_DOT11_MODE_AUTO: 1885 sme_warn("Warning: sees eCSR_CFG_DOT11_MODE_AUTO"); 1886 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AX)) 1887 ret = WNI_CFG_DOT11_MODE_11AX; 1888 else if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC)) 1889 ret = WNI_CFG_DOT11_MODE_11AC; 1890 else 1891 ret = WNI_CFG_DOT11_MODE_11N; 1892 break; 1893 case eCSR_CFG_DOT11_MODE_11A: 1894 ret = WNI_CFG_DOT11_MODE_11A; 1895 break; 1896 case eCSR_CFG_DOT11_MODE_11B: 1897 ret = WNI_CFG_DOT11_MODE_11B; 1898 break; 1899 case eCSR_CFG_DOT11_MODE_11G: 1900 ret = WNI_CFG_DOT11_MODE_11G; 1901 break; 1902 case eCSR_CFG_DOT11_MODE_11N: 1903 ret = WNI_CFG_DOT11_MODE_11N; 1904 break; 1905 case eCSR_CFG_DOT11_MODE_11G_ONLY: 1906 ret = WNI_CFG_DOT11_MODE_11G_ONLY; 1907 break; 1908 case eCSR_CFG_DOT11_MODE_11N_ONLY: 1909 ret = WNI_CFG_DOT11_MODE_11N_ONLY; 1910 break; 1911 case eCSR_CFG_DOT11_MODE_11AC_ONLY: 1912 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC)) 1913 ret = WNI_CFG_DOT11_MODE_11AC_ONLY; 1914 else 1915 ret = WNI_CFG_DOT11_MODE_11N; 1916 break; 1917 case eCSR_CFG_DOT11_MODE_11AC: 1918 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC)) 1919 ret = WNI_CFG_DOT11_MODE_11AC; 1920 else 1921 ret = WNI_CFG_DOT11_MODE_11N; 1922 break; 1923 case eCSR_CFG_DOT11_MODE_11AX_ONLY: 1924 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AX)) 1925 ret = WNI_CFG_DOT11_MODE_11AX_ONLY; 1926 else if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC)) 1927 ret = WNI_CFG_DOT11_MODE_11AC; 1928 else 1929 ret = WNI_CFG_DOT11_MODE_11N; 1930 break; 1931 case eCSR_CFG_DOT11_MODE_11AX: 1932 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AX)) 1933 ret = WNI_CFG_DOT11_MODE_11AX; 1934 else if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC)) 1935 ret = WNI_CFG_DOT11_MODE_11AC; 1936 else 1937 ret = WNI_CFG_DOT11_MODE_11N; 1938 break; 1939 default: 1940 sme_warn("doesn't expect %d as csrDo11Mode", csrDot11Mode); 1941 if (BAND_2G == pMac->roam.configParam.eBand) 1942 ret = WNI_CFG_DOT11_MODE_11G; 1943 else 1944 ret = WNI_CFG_DOT11_MODE_11A; 1945 break; 1946 } 1947 1948 return ret; 1949 } 1950 1951 /** 1952 * csr_get_phy_mode_from_bss() - Get Phy Mode 1953 * @pMac: Global MAC context 1954 * @pBSSDescription: BSS Descriptor 1955 * @pPhyMode: Physical Mode 1956 * @pIes: Pointer to the IE fields 1957 * 1958 * This function should only return the super set of supported modes 1959 * 11n implies 11b/g/a/n. 1960 * 1961 * Return: success 1962 **/ 1963 QDF_STATUS csr_get_phy_mode_from_bss(tpAniSirGlobal pMac, 1964 tSirBssDescription *pBSSDescription, 1965 eCsrPhyMode *pPhyMode, tDot11fBeaconIEs *pIes) 1966 { 1967 QDF_STATUS status = QDF_STATUS_SUCCESS; 1968 eCsrPhyMode phyMode = 1969 csr_translate_to_phy_mode_from_bss_desc(pBSSDescription); 1970 1971 if (pIes) { 1972 if (pIes->HTCaps.present) { 1973 phyMode = eCSR_DOT11_MODE_11n; 1974 if (IS_BSS_VHT_CAPABLE(pIes->VHTCaps) || 1975 IS_BSS_VHT_CAPABLE(pIes->vendor_vht_ie.VHTCaps)) 1976 phyMode = eCSR_DOT11_MODE_11ac; 1977 if (pIes->he_cap.present) 1978 phyMode = eCSR_DOT11_MODE_11ax; 1979 } 1980 *pPhyMode = phyMode; 1981 } 1982 1983 return status; 1984 } 1985 1986 /** 1987 * csr_get_phy_mode_in_use() - to get phymode 1988 * @phyModeIn: physical mode 1989 * @bssPhyMode: physical mode in bss 1990 * @f5GhzBand: 5Ghz band 1991 * @pCfgDot11ModeToUse: dot11 mode in use 1992 * 1993 * This function returns the correct eCSR_CFG_DOT11_MODE is the two phyModes 1994 * matches. bssPhyMode is the mode derived from the BSS description 1995 * f5GhzBand is derived from the channel id of BSS description 1996 * 1997 * Return: true or false 1998 */ 1999 static bool csr_get_phy_mode_in_use(eCsrPhyMode phyModeIn, 2000 eCsrPhyMode bssPhyMode, 2001 bool f5GhzBand, 2002 enum csr_cfgdot11mode *pCfgDot11ModeToUse) 2003 { 2004 bool fMatch = false; 2005 enum csr_cfgdot11mode cfgDot11Mode; 2006 2007 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N; 2008 switch (phyModeIn) { 2009 /* 11a or 11b or 11g */ 2010 case eCSR_DOT11_MODE_abg: 2011 fMatch = true; 2012 if (f5GhzBand) 2013 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A; 2014 else if (eCSR_DOT11_MODE_11b == bssPhyMode) 2015 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B; 2016 else 2017 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G; 2018 break; 2019 2020 case eCSR_DOT11_MODE_11a: 2021 if (f5GhzBand) { 2022 fMatch = true; 2023 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A; 2024 } 2025 break; 2026 2027 case eCSR_DOT11_MODE_11g: 2028 if (!f5GhzBand) { 2029 fMatch = true; 2030 if (eCSR_DOT11_MODE_11b == bssPhyMode) 2031 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B; 2032 else 2033 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G; 2034 } 2035 break; 2036 2037 case eCSR_DOT11_MODE_11g_ONLY: 2038 if (eCSR_DOT11_MODE_11g == bssPhyMode) { 2039 fMatch = true; 2040 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G; 2041 } 2042 break; 2043 2044 case eCSR_DOT11_MODE_11b: 2045 if (!f5GhzBand) { 2046 fMatch = true; 2047 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B; 2048 } 2049 break; 2050 2051 case eCSR_DOT11_MODE_11b_ONLY: 2052 if (eCSR_DOT11_MODE_11b == bssPhyMode) { 2053 fMatch = true; 2054 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B; 2055 } 2056 break; 2057 2058 case eCSR_DOT11_MODE_11n: 2059 fMatch = true; 2060 switch (bssPhyMode) { 2061 case eCSR_DOT11_MODE_11g: 2062 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G; 2063 break; 2064 case eCSR_DOT11_MODE_11b: 2065 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B; 2066 break; 2067 case eCSR_DOT11_MODE_11a: 2068 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A; 2069 break; 2070 case eCSR_DOT11_MODE_11n: 2071 case eCSR_DOT11_MODE_11ac: 2072 case eCSR_DOT11_MODE_11ax: 2073 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N; 2074 break; 2075 2076 default: 2077 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC; 2078 break; 2079 } 2080 break; 2081 2082 case eCSR_DOT11_MODE_11n_ONLY: 2083 if (eCSR_DOT11_MODE_11n == bssPhyMode) { 2084 fMatch = true; 2085 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N; 2086 2087 } 2088 2089 break; 2090 case eCSR_DOT11_MODE_11ac: 2091 fMatch = true; 2092 switch (bssPhyMode) { 2093 case eCSR_DOT11_MODE_11g: 2094 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G; 2095 break; 2096 case eCSR_DOT11_MODE_11b: 2097 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B; 2098 break; 2099 case eCSR_DOT11_MODE_11a: 2100 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A; 2101 break; 2102 case eCSR_DOT11_MODE_11n: 2103 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N; 2104 break; 2105 case eCSR_DOT11_MODE_11ac: 2106 case eCSR_DOT11_MODE_11ax: 2107 default: 2108 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC; 2109 break; 2110 } 2111 break; 2112 2113 case eCSR_DOT11_MODE_11ac_ONLY: 2114 if (eCSR_DOT11_MODE_11ac == bssPhyMode) { 2115 fMatch = true; 2116 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC; 2117 } 2118 break; 2119 case eCSR_DOT11_MODE_11ax: 2120 fMatch = true; 2121 switch (bssPhyMode) { 2122 case eCSR_DOT11_MODE_11g: 2123 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G; 2124 break; 2125 case eCSR_DOT11_MODE_11b: 2126 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B; 2127 break; 2128 case eCSR_DOT11_MODE_11a: 2129 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A; 2130 break; 2131 case eCSR_DOT11_MODE_11n: 2132 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N; 2133 break; 2134 case eCSR_DOT11_MODE_11ac: 2135 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC; 2136 break; 2137 case eCSR_DOT11_MODE_11ax: 2138 default: 2139 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AX; 2140 break; 2141 } 2142 break; 2143 2144 case eCSR_DOT11_MODE_11ax_ONLY: 2145 if (eCSR_DOT11_MODE_11ax == bssPhyMode) { 2146 fMatch = true; 2147 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AX; 2148 } 2149 break; 2150 2151 default: 2152 fMatch = true; 2153 switch (bssPhyMode) { 2154 case eCSR_DOT11_MODE_11g: 2155 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G; 2156 break; 2157 case eCSR_DOT11_MODE_11b: 2158 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B; 2159 break; 2160 case eCSR_DOT11_MODE_11a: 2161 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A; 2162 break; 2163 case eCSR_DOT11_MODE_11n: 2164 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N; 2165 break; 2166 case eCSR_DOT11_MODE_11ac: 2167 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC; 2168 break; 2169 case eCSR_DOT11_MODE_11ax: 2170 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AX; 2171 break; 2172 default: 2173 cfgDot11Mode = eCSR_CFG_DOT11_MODE_AUTO; 2174 break; 2175 } 2176 break; 2177 } 2178 2179 if (fMatch && pCfgDot11ModeToUse) { 2180 if (cfgDot11Mode == eCSR_CFG_DOT11_MODE_11AX) { 2181 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AX)) 2182 *pCfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11AX; 2183 else if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC)) 2184 *pCfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11AC; 2185 else 2186 *pCfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11N; 2187 } else { 2188 if (cfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC 2189 && (!IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))) 2190 *pCfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11N; 2191 else 2192 *pCfgDot11ModeToUse = cfgDot11Mode; 2193 } 2194 } 2195 return fMatch; 2196 } 2197 2198 /** 2199 * csr_is_phy_mode_match() - to find if phy mode matches 2200 * @pMac: pointer to mac context 2201 * @phyMode: physical mode 2202 * @pSirBssDesc: bss description 2203 * @pProfile: pointer to roam profile 2204 * @pReturnCfgDot11Mode: dot1 mode to return 2205 * @pIes: pointer to IEs 2206 * 2207 * This function decides whether the one of the bit of phyMode is matching the 2208 * mode in the BSS and allowed by the user setting 2209 * 2210 * Return: true or false based on mode that fits the criteria 2211 */ 2212 bool csr_is_phy_mode_match(tpAniSirGlobal pMac, uint32_t phyMode, 2213 tSirBssDescription *pSirBssDesc, 2214 tCsrRoamProfile *pProfile, 2215 enum csr_cfgdot11mode *pReturnCfgDot11Mode, 2216 tDot11fBeaconIEs *pIes) 2217 { 2218 bool fMatch = false; 2219 eCsrPhyMode phyModeInBssDesc = eCSR_DOT11_MODE_AUTO, phyMode2; 2220 enum csr_cfgdot11mode cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_AUTO; 2221 uint32_t bitMask, loopCount; 2222 2223 if (!QDF_IS_STATUS_SUCCESS(csr_get_phy_mode_from_bss(pMac, pSirBssDesc, 2224 &phyModeInBssDesc, pIes))) 2225 return fMatch; 2226 2227 if ((0 == phyMode) || (eCSR_DOT11_MODE_AUTO & phyMode)) { 2228 if (eCSR_CFG_DOT11_MODE_ABG == 2229 pMac->roam.configParam.uCfgDot11Mode) { 2230 phyMode = eCSR_DOT11_MODE_abg; 2231 } else if (eCSR_CFG_DOT11_MODE_AUTO == 2232 pMac->roam.configParam.uCfgDot11Mode) { 2233 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AX)) 2234 phyMode = eCSR_DOT11_MODE_11ax; 2235 else if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC)) 2236 phyMode = eCSR_DOT11_MODE_11ac; 2237 else 2238 phyMode = eCSR_DOT11_MODE_11n; 2239 } else { 2240 /* user's pick */ 2241 phyMode = pMac->roam.configParam.phyMode; 2242 } 2243 } 2244 2245 if ((0 == phyMode) || (eCSR_DOT11_MODE_AUTO & phyMode)) { 2246 if (0 != phyMode) { 2247 if (eCSR_DOT11_MODE_AUTO & phyMode) { 2248 phyMode2 = 2249 eCSR_DOT11_MODE_AUTO & phyMode; 2250 } 2251 } else { 2252 phyMode2 = phyMode; 2253 } 2254 fMatch = csr_get_phy_mode_in_use(phyMode2, phyModeInBssDesc, 2255 WLAN_REG_IS_5GHZ_CH(pSirBssDesc->channelId), 2256 &cfgDot11ModeToUse); 2257 } else { 2258 bitMask = 1; 2259 loopCount = 0; 2260 while (loopCount < eCSR_NUM_PHY_MODE) { 2261 phyMode2 = (phyMode & (bitMask << loopCount++)); 2262 if (0 != phyMode2 && csr_get_phy_mode_in_use(phyMode2, 2263 phyModeInBssDesc, 2264 WLAN_REG_IS_5GHZ_CH 2265 (pSirBssDesc->channelId), 2266 &cfgDot11ModeToUse)) { 2267 fMatch = true; 2268 break; 2269 } 2270 } 2271 } 2272 if (fMatch && pReturnCfgDot11Mode) { 2273 if (pProfile) { 2274 /* 2275 * IEEE 11n spec (8.4.3): HT STA shall 2276 * eliminate TKIP as a choice for the pairwise 2277 * cipher suite if CCMP is advertised by the AP 2278 * or if the AP included an HT capabilities 2279 * element in its Beacons and Probe Response. 2280 */ 2281 if ((!CSR_IS_11n_ALLOWED( 2282 pProfile->negotiatedUCEncryptionType)) 2283 && ((eCSR_CFG_DOT11_MODE_11N == 2284 cfgDot11ModeToUse) || 2285 (eCSR_CFG_DOT11_MODE_11AC == 2286 cfgDot11ModeToUse) || 2287 (eCSR_CFG_DOT11_MODE_11AX == 2288 cfgDot11ModeToUse))) { 2289 /* We cannot do 11n here */ 2290 if (!WLAN_REG_IS_5GHZ_CH 2291 (pSirBssDesc->channelId)) { 2292 cfgDot11ModeToUse = 2293 eCSR_CFG_DOT11_MODE_11G; 2294 } else { 2295 cfgDot11ModeToUse = 2296 eCSR_CFG_DOT11_MODE_11A; 2297 } 2298 } 2299 } 2300 *pReturnCfgDot11Mode = cfgDot11ModeToUse; 2301 } 2302 2303 return fMatch; 2304 } 2305 2306 enum csr_cfgdot11mode csr_find_best_phy_mode(tpAniSirGlobal pMac, 2307 uint32_t phyMode) 2308 { 2309 enum csr_cfgdot11mode cfgDot11ModeToUse; 2310 enum band_info eBand = pMac->roam.configParam.eBand; 2311 2312 if ((0 == phyMode) || 2313 (eCSR_DOT11_MODE_AUTO & phyMode) || 2314 (eCSR_DOT11_MODE_11ax & phyMode)) { 2315 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AX)) { 2316 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11AX; 2317 } else if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC)) { 2318 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11AC; 2319 } else { 2320 /* Default to 11N mode if user has configured 11ac mode 2321 * and FW doesn't supports 11ac mode . 2322 */ 2323 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11N; 2324 } 2325 } else if (eCSR_DOT11_MODE_11ac & phyMode) { 2326 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC)) { 2327 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11AC; 2328 } else { 2329 /* Default to 11N mode if user has configured 11ac mode 2330 * and FW doesn't supports 11ac mode . 2331 */ 2332 } cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11N; 2333 } else { 2334 if ((eCSR_DOT11_MODE_11n | eCSR_DOT11_MODE_11n_ONLY) & phyMode) 2335 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11N; 2336 else if (eCSR_DOT11_MODE_abg & phyMode) { 2337 if (BAND_2G != eBand) 2338 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11A; 2339 else 2340 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11G; 2341 } else if (eCSR_DOT11_MODE_11a & phyMode) 2342 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11A; 2343 else if ((eCSR_DOT11_MODE_11g | eCSR_DOT11_MODE_11g_ONLY) & 2344 phyMode) 2345 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11G; 2346 else 2347 cfgDot11ModeToUse = eCSR_CFG_DOT11_MODE_11B; 2348 } 2349 2350 return cfgDot11ModeToUse; 2351 } 2352 2353 uint32_t csr_get11h_power_constraint(tHalHandle hHal, 2354 tDot11fIEPowerConstraints *pPowerConstraint) 2355 { 2356 tpAniSirGlobal pMac = PMAC_STRUCT(hHal); 2357 uint32_t localPowerConstraint = 0; 2358 2359 /* check if .11h support is enabled, if not, 2360 * the power constraint is 0. 2361 */ 2362 if (pMac->roam.configParam.Is11hSupportEnabled 2363 && pPowerConstraint->present) { 2364 localPowerConstraint = pPowerConstraint->localPowerConstraints; 2365 } 2366 2367 return localPowerConstraint; 2368 } 2369 2370 bool csr_is_profile_wpa(tCsrRoamProfile *pProfile) 2371 { 2372 bool fWpaProfile = false; 2373 2374 switch (pProfile->negotiatedAuthType) { 2375 case eCSR_AUTH_TYPE_WPA: 2376 case eCSR_AUTH_TYPE_WPA_PSK: 2377 case eCSR_AUTH_TYPE_WPA_NONE: 2378 #ifdef FEATURE_WLAN_ESE 2379 case eCSR_AUTH_TYPE_CCKM_WPA: 2380 #endif 2381 fWpaProfile = true; 2382 break; 2383 2384 default: 2385 fWpaProfile = false; 2386 break; 2387 } 2388 2389 if (fWpaProfile) { 2390 switch (pProfile->negotiatedUCEncryptionType) { 2391 case eCSR_ENCRYPT_TYPE_WEP40: 2392 case eCSR_ENCRYPT_TYPE_WEP104: 2393 case eCSR_ENCRYPT_TYPE_TKIP: 2394 case eCSR_ENCRYPT_TYPE_AES: 2395 fWpaProfile = true; 2396 break; 2397 2398 default: 2399 fWpaProfile = false; 2400 break; 2401 } 2402 } 2403 return fWpaProfile; 2404 } 2405 2406 bool csr_is_profile_rsn(tCsrRoamProfile *pProfile) 2407 { 2408 bool fRSNProfile = false; 2409 2410 switch (pProfile->negotiatedAuthType) { 2411 case eCSR_AUTH_TYPE_RSN: 2412 case eCSR_AUTH_TYPE_RSN_PSK: 2413 case eCSR_AUTH_TYPE_FT_RSN: 2414 case eCSR_AUTH_TYPE_FT_RSN_PSK: 2415 #ifdef FEATURE_WLAN_ESE 2416 case eCSR_AUTH_TYPE_CCKM_RSN: 2417 #endif 2418 #ifdef WLAN_FEATURE_11W 2419 case eCSR_AUTH_TYPE_RSN_PSK_SHA256: 2420 case eCSR_AUTH_TYPE_RSN_8021X_SHA256: 2421 #endif 2422 /* fallthrough */ 2423 case eCSR_AUTH_TYPE_FILS_SHA256: 2424 case eCSR_AUTH_TYPE_FILS_SHA384: 2425 case eCSR_AUTH_TYPE_FT_FILS_SHA256: 2426 case eCSR_AUTH_TYPE_FT_FILS_SHA384: 2427 case eCSR_AUTH_TYPE_DPP_RSN: 2428 fRSNProfile = true; 2429 break; 2430 2431 case eCSR_AUTH_TYPE_OWE: 2432 fRSNProfile = true; 2433 break; 2434 2435 default: 2436 fRSNProfile = false; 2437 break; 2438 } 2439 2440 if (fRSNProfile) { 2441 switch (pProfile->negotiatedUCEncryptionType) { 2442 /* !!REVIEW - For WPA2, use of RSN IE mandates */ 2443 /* use of AES as encryption. Here, we qualify */ 2444 /* even if encryption type is WEP or TKIP */ 2445 case eCSR_ENCRYPT_TYPE_WEP40: 2446 case eCSR_ENCRYPT_TYPE_WEP104: 2447 case eCSR_ENCRYPT_TYPE_TKIP: 2448 case eCSR_ENCRYPT_TYPE_AES: 2449 case eCSR_ENCRYPT_TYPE_AES_GCMP: 2450 case eCSR_ENCRYPT_TYPE_AES_GCMP_256: 2451 fRSNProfile = true; 2452 break; 2453 2454 default: 2455 fRSNProfile = false; 2456 break; 2457 } 2458 } 2459 return fRSNProfile; 2460 } 2461 2462 /** 2463 * csr_update_mcc_p2p_beacon_interval() - update p2p beacon interval 2464 * @mac_ctx: pointer to mac context 2465 * 2466 * This function is to update the mcc p2p beacon interval 2467 * 2468 * Return: QDF_STATUS 2469 */ 2470 static QDF_STATUS csr_update_mcc_p2p_beacon_interval(tpAniSirGlobal mac_ctx) 2471 { 2472 uint32_t session_id = 0; 2473 struct csr_roam_session *roam_session; 2474 2475 /* If MCC is not supported just break and return SUCCESS */ 2476 if (!mac_ctx->roam.configParam.fenableMCCMode) 2477 return QDF_STATUS_E_FAILURE; 2478 2479 for (session_id = 0; session_id < CSR_ROAM_SESSION_MAX; session_id++) { 2480 /* 2481 * If GO in MCC support different beacon interval, 2482 * change the BI of the P2P-GO 2483 */ 2484 roam_session = &mac_ctx->roam.roamSession[session_id]; 2485 if (roam_session->bssParams.bssPersona != QDF_P2P_GO_MODE) 2486 continue; 2487 /* 2488 * Handle different BI scneario based on the 2489 * configuration set.If Config is set to 0x02 then 2490 * Disconnect all the P2P clients associated. If config 2491 * is set to 0x04 then update the BI without 2492 * disconnecting all the clients 2493 */ 2494 if ((mac_ctx->roam.configParam.fAllowMCCGODiffBI == 0x04) 2495 && (roam_session->bssParams. 2496 updatebeaconInterval)) { 2497 return csr_send_chng_mcc_beacon_interval(mac_ctx, 2498 session_id); 2499 } else if (roam_session->bssParams.updatebeaconInterval) { 2500 /* 2501 * If the configuration of fAllowMCCGODiffBI is set to 2502 * other than 0x04 2503 */ 2504 return csr_roam_call_callback(mac_ctx, 2505 session_id, 2506 NULL, 0, 2507 eCSR_ROAM_DISCONNECT_ALL_P2P_CLIENTS, 2508 eCSR_ROAM_RESULT_NONE); 2509 } 2510 } 2511 return QDF_STATUS_E_FAILURE; 2512 } 2513 2514 static uint16_t csr_calculate_mcc_beacon_interval(tpAniSirGlobal pMac, 2515 uint16_t sta_bi, 2516 uint16_t go_gbi) 2517 { 2518 uint8_t num_beacons = 0; 2519 uint8_t is_multiple = 0; 2520 uint16_t go_cbi = 0; 2521 uint16_t go_fbi = 0; 2522 uint16_t sta_cbi = 0; 2523 2524 /* If GO's given beacon Interval is less than 100 */ 2525 if (go_gbi < 100) 2526 go_cbi = 100; 2527 /* if GO's given beacon Interval is greater than or equal to 100 */ 2528 else 2529 go_cbi = 100 + (go_gbi % 100); 2530 2531 if (sta_bi == 0) { 2532 /* There is possibility to receive zero as value. 2533 * Which will cause divide by zero. Hence initialise with 100 2534 */ 2535 sta_bi = 100; 2536 sme_warn("sta_bi 2nd parameter is zero, initialize to %d", 2537 sta_bi); 2538 } 2539 /* check, if either one is multiple of another */ 2540 if (sta_bi > go_cbi) 2541 is_multiple = !(sta_bi % go_cbi); 2542 else 2543 is_multiple = !(go_cbi % sta_bi); 2544 2545 /* if it is multiple, then accept GO's beacon interval 2546 * range [100,199] as it is 2547 */ 2548 if (is_multiple) 2549 return go_cbi; 2550 2551 /* else , if it is not multiple, then then check for number of beacons 2552 * to be inserted based on sta BI 2553 */ 2554 num_beacons = sta_bi / 100; 2555 if (num_beacons) { 2556 /* GO's final beacon interval will be aligned to sta beacon 2557 * interval, but in the range of [100, 199]. 2558 */ 2559 sta_cbi = sta_bi / num_beacons; 2560 go_fbi = sta_cbi; 2561 } else 2562 /* if STA beacon interval is less than 100, use GO's change 2563 * bacon interval instead of updating to STA's beacon interval. 2564 */ 2565 go_fbi = go_cbi; 2566 2567 return go_fbi; 2568 } 2569 2570 /** 2571 * csr_validate_p2pcli_bcn_intrvl() - to validate p2pcli beacon interval 2572 * @mac_ctx: pointer to mac context 2573 * @chnl_id: channel id variable 2574 * @bcn_interval: pointer to given beacon interval 2575 * @session_id: given session id 2576 * @status: fill the status in terms of QDF_STATUS to inform caller 2577 * 2578 * This API can provide the validation the beacon interval and re-calculate 2579 * in case concurrency 2580 * 2581 * Return: bool 2582 */ 2583 static bool csr_validate_p2pcli_bcn_intrvl(tpAniSirGlobal mac_ctx, 2584 uint8_t chnl_id, uint16_t *bcn_interval, uint32_t session_id, 2585 QDF_STATUS *status) 2586 { 2587 struct csr_roam_session *roamsession; 2588 2589 roamsession = &mac_ctx->roam.roamSession[session_id]; 2590 if (roamsession->pCurRoamProfile && 2591 (roamsession->pCurRoamProfile->csrPersona == 2592 QDF_STA_MODE)) { 2593 /* check for P2P client mode */ 2594 sme_debug("Ignore Beacon Interval Validation..."); 2595 } else if (roamsession->bssParams.bssPersona == QDF_P2P_GO_MODE) { 2596 /* Check for P2P go scenario */ 2597 if ((roamsession->bssParams.operationChn != chnl_id) 2598 && (roamsession->bssParams.beaconInterval != 2599 *bcn_interval)) { 2600 sme_err("BcnIntrvl is diff can't connect to P2P_GO network"); 2601 *status = QDF_STATUS_E_FAILURE; 2602 return true; 2603 } 2604 } 2605 return false; 2606 } 2607 2608 /** 2609 * csr_validate_p2pgo_bcn_intrvl() - to validate p2pgo beacon interval 2610 * @mac_ctx: pointer to mac context 2611 * @chnl_id: channel id variable 2612 * @bcn_interval: pointer to given beacon interval 2613 * @session_id: given session id 2614 * @status: fill the status in terms of QDF_STATUS to inform caller 2615 * 2616 * This API can provide the validation the beacon interval and re-calculate 2617 * in case concurrency 2618 * 2619 * Return: bool 2620 */ 2621 static bool csr_validate_p2pgo_bcn_intrvl(tpAniSirGlobal mac_ctx, 2622 uint8_t chnl_id, uint16_t *bcn_interval, 2623 uint32_t session_id, QDF_STATUS *status) 2624 { 2625 struct csr_roam_session *roamsession; 2626 struct csr_config *cfg_param; 2627 tCsrRoamConnectedProfile *conn_profile; 2628 uint16_t new_bcn_interval; 2629 2630 roamsession = &mac_ctx->roam.roamSession[session_id]; 2631 cfg_param = &mac_ctx->roam.configParam; 2632 conn_profile = &roamsession->connectedProfile; 2633 if (roamsession->pCurRoamProfile && 2634 ((roamsession->pCurRoamProfile->csrPersona == 2635 QDF_P2P_CLIENT_MODE) || 2636 (roamsession->pCurRoamProfile->csrPersona == 2637 QDF_STA_MODE))) { 2638 /* check for P2P_client scenario */ 2639 if ((conn_profile->operationChannel == 0) && 2640 (conn_profile->beaconInterval == 0)) 2641 return false; 2642 2643 if (csr_is_conn_state_connected_infra(mac_ctx, session_id) && 2644 (conn_profile->operationChannel != chnl_id) && 2645 (conn_profile->beaconInterval != *bcn_interval)) { 2646 /* 2647 * Updated beaconInterval should be used only when 2648 * we are starting a new BSS not incase of 2649 * client or STA case 2650 */ 2651 2652 /* Calculate beacon Interval for P2P-GO incase of MCC */ 2653 if (cfg_param->conc_custom_rule1 || 2654 cfg_param->conc_custom_rule2) { 2655 new_bcn_interval = CSR_CUSTOM_CONC_GO_BI; 2656 } else { 2657 new_bcn_interval = 2658 csr_calculate_mcc_beacon_interval( 2659 mac_ctx, 2660 conn_profile->beaconInterval, 2661 *bcn_interval); 2662 } 2663 if (*bcn_interval != new_bcn_interval) 2664 *bcn_interval = new_bcn_interval; 2665 *status = QDF_STATUS_SUCCESS; 2666 return true; 2667 } 2668 } 2669 return false; 2670 } 2671 2672 /** 2673 * csr_validate_sta_bcn_intrvl() - to validate sta beacon interval 2674 * @mac_ctx: pointer to mac context 2675 * @chnl_id: channel id variable 2676 * @bcn_interval: pointer to given beacon interval 2677 * @session_id: given session id 2678 * @status: fill the status in terms of QDF_STATUS to inform caller 2679 * 2680 * This API can provide the validation the beacon interval and re-calculate 2681 * in case concurrency 2682 * 2683 * Return: bool 2684 */ 2685 static bool csr_validate_sta_bcn_intrvl(tpAniSirGlobal mac_ctx, 2686 uint8_t chnl_id, uint16_t *bcn_interval, 2687 uint32_t session_id, QDF_STATUS *status) 2688 { 2689 struct csr_roam_session *roamsession; 2690 struct csr_config *cfg_param; 2691 uint16_t new_bcn_interval; 2692 2693 roamsession = &mac_ctx->roam.roamSession[session_id]; 2694 cfg_param = &mac_ctx->roam.configParam; 2695 2696 if (roamsession->pCurRoamProfile && 2697 (roamsession->pCurRoamProfile->csrPersona == 2698 QDF_P2P_CLIENT_MODE)) { 2699 /* check for P2P client mode */ 2700 sme_debug("Bcn Intrvl validation not require for STA/CLIENT"); 2701 return false; 2702 } 2703 if ((roamsession->bssParams.bssPersona == QDF_SAP_MODE) && 2704 (roamsession->bssParams.operationChn != chnl_id)) { 2705 /* 2706 * IF SAP has started and STA wants to connect 2707 * on different channel MCC should 2708 * MCC should not be enabled so making it 2709 * false to enforce on same channel 2710 */ 2711 sme_err("*** MCC with SAP+STA sessions ****"); 2712 *status = QDF_STATUS_SUCCESS; 2713 return true; 2714 } 2715 /* 2716 * Check for P2P go scenario 2717 * if GO in MCC support different 2718 * beacon interval, 2719 * change the BI of the P2P-GO 2720 */ 2721 if ((roamsession->bssParams.bssPersona == QDF_P2P_GO_MODE) && 2722 (roamsession->bssParams.operationChn != chnl_id) && 2723 (roamsession->bssParams.beaconInterval != *bcn_interval)) { 2724 /* if GO in MCC support diff beacon interval, return success */ 2725 if (cfg_param->fAllowMCCGODiffBI == 0x01) { 2726 *status = QDF_STATUS_SUCCESS; 2727 return true; 2728 } 2729 /* 2730 * Send only Broadcast disassoc and update bcn_interval 2731 * If configuration is set to 0x04 then dont 2732 * disconnect all the station 2733 */ 2734 if ((cfg_param->fAllowMCCGODiffBI == 0x02) 2735 || (cfg_param->fAllowMCCGODiffBI == 0x04)) { 2736 /* Check to pass the right beacon Interval */ 2737 if (cfg_param->conc_custom_rule1 || 2738 cfg_param->conc_custom_rule2) { 2739 new_bcn_interval = CSR_CUSTOM_CONC_GO_BI; 2740 } else { 2741 new_bcn_interval = 2742 csr_calculate_mcc_beacon_interval( 2743 mac_ctx, *bcn_interval, 2744 roamsession->bssParams.beaconInterval); 2745 } 2746 sme_debug("Peer AP BI : %d, new Beacon Interval: %d", 2747 *bcn_interval, new_bcn_interval); 2748 /* Update the becon Interval */ 2749 if (new_bcn_interval != 2750 roamsession->bssParams.beaconInterval) { 2751 /* Update the bcn_interval now */ 2752 sme_err("Beacon Interval got changed config used: %d", 2753 cfg_param->fAllowMCCGODiffBI); 2754 2755 roamsession->bssParams.beaconInterval = 2756 new_bcn_interval; 2757 roamsession->bssParams.updatebeaconInterval = 2758 true; 2759 *status = csr_update_mcc_p2p_beacon_interval( 2760 mac_ctx); 2761 return true; 2762 } 2763 *status = QDF_STATUS_SUCCESS; 2764 return true; 2765 } 2766 if (cfg_param->fAllowMCCGODiffBI 2767 == 0x03) { 2768 /* Disconnect the P2P session */ 2769 roamsession->bssParams.updatebeaconInterval = false; 2770 *status = csr_roam_call_callback(mac_ctx, 2771 session_id, NULL, 0, 2772 eCSR_ROAM_SEND_P2P_STOP_BSS, 2773 eCSR_ROAM_RESULT_NONE); 2774 return true; 2775 } 2776 sme_err("BcnIntrvl is diff can't connect to preferred AP"); 2777 *status = QDF_STATUS_E_FAILURE; 2778 return true; 2779 } 2780 return false; 2781 } 2782 2783 /** 2784 * csr_validate_mcc_beacon_interval() - to validate the mcc beacon interval 2785 * @mac_ctx: pointer to mac context 2786 * @chnl_id: channel number 2787 * @bcn_interval: provided beacon interval 2788 * @cur_session_id: current session id 2789 * @cur_bss_persona: Current BSS persona 2790 * 2791 * This API will validate the mcc beacon interval 2792 * 2793 * Return: QDF_STATUS 2794 */ 2795 QDF_STATUS csr_validate_mcc_beacon_interval(tpAniSirGlobal mac_ctx, 2796 uint8_t chnl_id, 2797 uint16_t *bcn_interval, 2798 uint32_t cur_session_id, 2799 enum QDF_OPMODE cur_bss_persona) 2800 { 2801 uint32_t session_id = 0; 2802 QDF_STATUS status; 2803 bool is_done; 2804 2805 /* If MCC is not supported just break */ 2806 if (!mac_ctx->roam.configParam.fenableMCCMode) 2807 return QDF_STATUS_E_FAILURE; 2808 2809 for (session_id = 0; session_id < CSR_ROAM_SESSION_MAX; session_id++) { 2810 if (cur_session_id == session_id) 2811 continue; 2812 2813 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) 2814 continue; 2815 2816 switch (cur_bss_persona) { 2817 case QDF_STA_MODE: 2818 is_done = csr_validate_sta_bcn_intrvl(mac_ctx, chnl_id, 2819 bcn_interval, session_id, &status); 2820 if (true == is_done) 2821 return status; 2822 break; 2823 2824 case QDF_P2P_CLIENT_MODE: 2825 is_done = csr_validate_p2pcli_bcn_intrvl(mac_ctx, 2826 chnl_id, bcn_interval, session_id, 2827 &status); 2828 if (true == is_done) 2829 return status; 2830 break; 2831 2832 case QDF_SAP_MODE: 2833 case QDF_IBSS_MODE: 2834 break; 2835 2836 case QDF_P2P_GO_MODE: 2837 is_done = csr_validate_p2pgo_bcn_intrvl(mac_ctx, 2838 chnl_id, bcn_interval, 2839 session_id, &status); 2840 if (true == is_done) 2841 return status; 2842 break; 2843 2844 default: 2845 sme_err("Persona not supported: %d", cur_bss_persona); 2846 return QDF_STATUS_E_FAILURE; 2847 } 2848 } 2849 return QDF_STATUS_SUCCESS; 2850 } 2851 2852 /** 2853 * csr_is_auth_type11r() - Check if Authentication type is 11R 2854 * @auth_type: The authentication type that is used to make the connection 2855 * @mdie_present: Is MDIE IE present 2856 * 2857 * Return: true if is 11R auth type, false otherwise 2858 */ 2859 bool csr_is_auth_type11r(eCsrAuthType auth_type, uint8_t mdie_present) 2860 { 2861 switch (auth_type) { 2862 case eCSR_AUTH_TYPE_OPEN_SYSTEM: 2863 if (mdie_present) 2864 return true; 2865 break; 2866 case eCSR_AUTH_TYPE_FT_RSN_PSK: 2867 case eCSR_AUTH_TYPE_FT_RSN: 2868 return true; 2869 default: 2870 break; 2871 } 2872 return false; 2873 } 2874 2875 /* Function to return true if the profile is 11r */ 2876 bool csr_is_profile11r(tCsrRoamProfile *pProfile) 2877 { 2878 return csr_is_auth_type11r(pProfile->negotiatedAuthType, 2879 pProfile->MDID.mdiePresent); 2880 } 2881 2882 bool csr_is_auth_type_ese(eCsrAuthType AuthType) 2883 { 2884 switch (AuthType) { 2885 case eCSR_AUTH_TYPE_CCKM_WPA: 2886 case eCSR_AUTH_TYPE_CCKM_RSN: 2887 return true; 2888 default: 2889 break; 2890 } 2891 return false; 2892 } 2893 2894 #ifdef FEATURE_WLAN_ESE 2895 2896 /* Function to return true if the profile is ESE */ 2897 bool csr_is_profile_ese(tCsrRoamProfile *pProfile) 2898 { 2899 return csr_is_auth_type_ese(pProfile->negotiatedAuthType); 2900 } 2901 2902 #endif 2903 2904 #ifdef FEATURE_WLAN_WAPI 2905 bool csr_is_profile_wapi(tCsrRoamProfile *pProfile) 2906 { 2907 bool fWapiProfile = false; 2908 2909 switch (pProfile->negotiatedAuthType) { 2910 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE: 2911 case eCSR_AUTH_TYPE_WAPI_WAI_PSK: 2912 fWapiProfile = true; 2913 break; 2914 2915 default: 2916 fWapiProfile = false; 2917 break; 2918 } 2919 2920 if (fWapiProfile) { 2921 switch (pProfile->negotiatedUCEncryptionType) { 2922 case eCSR_ENCRYPT_TYPE_WPI: 2923 fWapiProfile = true; 2924 break; 2925 2926 default: 2927 fWapiProfile = false; 2928 break; 2929 } 2930 } 2931 return fWapiProfile; 2932 } 2933 2934 static bool csr_is_wapi_oui_equal(tpAniSirGlobal pMac, uint8_t *Oui1, 2935 uint8_t *Oui2) 2936 { 2937 return !qdf_mem_cmp(Oui1, Oui2, CSR_WAPI_OUI_SIZE); 2938 } 2939 2940 static bool csr_is_wapi_oui_match(tpAniSirGlobal pMac, 2941 uint8_t AllCyphers[][CSR_WAPI_OUI_SIZE], 2942 uint8_t cAllCyphers, uint8_t Cypher[], 2943 uint8_t Oui[]) 2944 { 2945 bool fYes = false; 2946 uint8_t idx; 2947 2948 for (idx = 0; idx < cAllCyphers; idx++) { 2949 if (csr_is_wapi_oui_equal(pMac, AllCyphers[idx], Cypher)) { 2950 fYes = true; 2951 break; 2952 } 2953 } 2954 2955 if (fYes && Oui) 2956 qdf_mem_copy(Oui, AllCyphers[idx], CSR_WAPI_OUI_SIZE); 2957 2958 return fYes; 2959 } 2960 #endif /* FEATURE_WLAN_WAPI */ 2961 2962 static bool csr_is_wpa_oui_equal(tpAniSirGlobal pMac, uint8_t *Oui1, 2963 uint8_t *Oui2) 2964 { 2965 return !qdf_mem_cmp(Oui1, Oui2, CSR_WPA_OUI_SIZE); 2966 } 2967 2968 static bool csr_is_oui_match(tpAniSirGlobal pMac, 2969 uint8_t AllCyphers[][CSR_WPA_OUI_SIZE], 2970 uint8_t cAllCyphers, uint8_t Cypher[], uint8_t Oui[]) 2971 { 2972 bool fYes = false; 2973 uint8_t idx; 2974 2975 for (idx = 0; idx < cAllCyphers; idx++) { 2976 if (csr_is_wpa_oui_equal(pMac, AllCyphers[idx], Cypher)) { 2977 fYes = true; 2978 break; 2979 } 2980 } 2981 2982 if (fYes && Oui) 2983 qdf_mem_copy(Oui, AllCyphers[idx], CSR_WPA_OUI_SIZE); 2984 2985 return fYes; 2986 } 2987 2988 static bool csr_match_rsnoui_index(tpAniSirGlobal pMac, 2989 uint8_t AllCyphers[][CSR_RSN_OUI_SIZE], 2990 uint8_t cAllCyphers, uint8_t ouiIndex, 2991 uint8_t Oui[]) 2992 { 2993 return csr_is_oui_match 2994 (pMac, AllCyphers, cAllCyphers, csr_rsn_oui[ouiIndex], Oui); 2995 2996 } 2997 2998 #ifdef FEATURE_WLAN_WAPI 2999 static bool csr_match_wapi_oui_index(tpAniSirGlobal pMac, 3000 uint8_t AllCyphers[][CSR_WAPI_OUI_SIZE], 3001 uint8_t cAllCyphers, uint8_t ouiIndex, 3002 uint8_t Oui[]) 3003 { 3004 return csr_is_wapi_oui_match 3005 (pMac, AllCyphers, cAllCyphers, csr_wapi_oui[ouiIndex], Oui); 3006 3007 } 3008 #endif /* FEATURE_WLAN_WAPI */ 3009 3010 static bool csr_match_wpaoui_index(tpAniSirGlobal pMac, 3011 uint8_t AllCyphers[][CSR_RSN_OUI_SIZE], 3012 uint8_t cAllCyphers, uint8_t ouiIndex, 3013 uint8_t Oui[]) 3014 { 3015 if (ouiIndex < QDF_ARRAY_SIZE(csr_wpa_oui)) 3016 return csr_is_oui_match 3017 (pMac, AllCyphers, cAllCyphers, 3018 csr_wpa_oui[ouiIndex], Oui); 3019 else 3020 return false; 3021 } 3022 3023 #ifdef FEATURE_WLAN_WAPI 3024 static bool csr_is_auth_wapi_cert(tpAniSirGlobal pMac, 3025 uint8_t AllSuites[][CSR_WAPI_OUI_SIZE], 3026 uint8_t cAllSuites, uint8_t Oui[]) 3027 { 3028 return csr_is_wapi_oui_match 3029 (pMac, AllSuites, cAllSuites, csr_wapi_oui[1], Oui); 3030 } 3031 3032 static bool csr_is_auth_wapi_psk(tpAniSirGlobal pMac, 3033 uint8_t AllSuites[][CSR_WAPI_OUI_SIZE], 3034 uint8_t cAllSuites, uint8_t Oui[]) 3035 { 3036 return csr_is_wapi_oui_match 3037 (pMac, AllSuites, cAllSuites, csr_wapi_oui[2], Oui); 3038 } 3039 #endif /* FEATURE_WLAN_WAPI */ 3040 3041 3042 /* 3043 * Function for 11R FT Authentication. We match the FT Authentication Cipher 3044 * suite here. This matches for FT Auth with the 802.1X exchange. 3045 */ 3046 static bool csr_is_ft_auth_rsn(tpAniSirGlobal pMac, 3047 uint8_t AllSuites[][CSR_RSN_OUI_SIZE], 3048 uint8_t cAllSuites, uint8_t Oui[]) 3049 { 3050 return csr_is_oui_match 3051 (pMac, AllSuites, cAllSuites, csr_rsn_oui[03], Oui); 3052 } 3053 3054 /* 3055 * Function for 11R FT Authentication. We match the FT Authentication Cipher 3056 * suite here. This matches for FT Auth with the PSK. 3057 */ 3058 static bool csr_is_ft_auth_rsn_psk(tpAniSirGlobal pMac, 3059 uint8_t AllSuites[][CSR_RSN_OUI_SIZE], 3060 uint8_t cAllSuites, uint8_t Oui[]) 3061 { 3062 return csr_is_oui_match 3063 (pMac, AllSuites, cAllSuites, csr_rsn_oui[04], Oui); 3064 } 3065 3066 3067 #ifdef FEATURE_WLAN_ESE 3068 3069 /* 3070 * Function for ESE CCKM AKM Authentication. We match the CCKM AKM 3071 * Authentication Key Management suite here. This matches for CCKM AKM Auth 3072 * with the 802.1X exchange. 3073 */ 3074 static bool csr_is_ese_cckm_auth_rsn(tpAniSirGlobal pMac, 3075 uint8_t AllSuites[][CSR_RSN_OUI_SIZE], 3076 uint8_t cAllSuites, uint8_t Oui[]) 3077 { 3078 return csr_is_oui_match 3079 (pMac, AllSuites, cAllSuites, csr_rsn_oui[06], Oui); 3080 } 3081 3082 static bool csr_is_ese_cckm_auth_wpa(tpAniSirGlobal pMac, 3083 uint8_t AllSuites[][CSR_WPA_OUI_SIZE], 3084 uint8_t cAllSuites, uint8_t Oui[]) 3085 { 3086 return csr_is_oui_match 3087 (pMac, AllSuites, cAllSuites, csr_wpa_oui[06], Oui); 3088 } 3089 3090 #endif 3091 3092 static bool csr_is_auth_rsn(tpAniSirGlobal pMac, 3093 uint8_t AllSuites[][CSR_RSN_OUI_SIZE], 3094 uint8_t cAllSuites, uint8_t Oui[]) 3095 { 3096 return csr_is_oui_match 3097 (pMac, AllSuites, cAllSuites, csr_rsn_oui[01], Oui); 3098 } 3099 3100 static bool csr_is_auth_rsn_psk(tpAniSirGlobal pMac, 3101 uint8_t AllSuites[][CSR_RSN_OUI_SIZE], 3102 uint8_t cAllSuites, uint8_t Oui[]) 3103 { 3104 return csr_is_oui_match 3105 (pMac, AllSuites, cAllSuites, csr_rsn_oui[02], Oui); 3106 } 3107 3108 #ifdef WLAN_FEATURE_11W 3109 static bool csr_is_auth_rsn_psk_sha256(tpAniSirGlobal pMac, 3110 uint8_t AllSuites[][CSR_RSN_OUI_SIZE], 3111 uint8_t cAllSuites, uint8_t Oui[]) 3112 { 3113 return csr_is_oui_match 3114 (pMac, AllSuites, cAllSuites, csr_rsn_oui[07], Oui); 3115 } 3116 static bool csr_is_auth_rsn8021x_sha256(tpAniSirGlobal pMac, 3117 uint8_t AllSuites[][CSR_RSN_OUI_SIZE], 3118 uint8_t cAllSuites, uint8_t Oui[]) 3119 { 3120 return csr_is_oui_match 3121 (pMac, AllSuites, cAllSuites, csr_rsn_oui[8], Oui); 3122 } 3123 #endif 3124 3125 #ifdef WLAN_FEATURE_FILS_SK 3126 /* 3127 * csr_is_auth_fils_sha256() - check whether oui is fils sha256 3128 * @mac: Global MAC context 3129 * @all_suites: pointer to all supported akm suites 3130 * @suite_count: all supported akm suites count 3131 * @oui: Oui needs to be matched 3132 * 3133 * Return: True if OUI is FILS SHA256, false otherwise 3134 */ 3135 static bool csr_is_auth_fils_sha256(tpAniSirGlobal mac, 3136 uint8_t all_suites[][CSR_RSN_OUI_SIZE], 3137 uint8_t suite_count, uint8_t oui[]) 3138 { 3139 return csr_is_oui_match(mac, all_suites, suite_count, 3140 csr_rsn_oui[ENUM_FILS_SHA256], oui); 3141 } 3142 3143 /* 3144 * csr_is_auth_fils_sha384() - check whether oui is fils sha384 3145 * @mac: Global MAC context 3146 * @all_suites: pointer to all supported akm suites 3147 * @suite_count: all supported akm suites count 3148 * @oui: Oui needs to be matched 3149 * 3150 * Return: True if OUI is FILS SHA384, false otherwise 3151 */ 3152 static bool csr_is_auth_fils_sha384(tpAniSirGlobal mac, 3153 uint8_t all_suites[][CSR_RSN_OUI_SIZE], 3154 uint8_t suite_count, uint8_t oui[]) 3155 { 3156 return csr_is_oui_match(mac, all_suites, suite_count, 3157 csr_rsn_oui[ENUM_FILS_SHA384], oui); 3158 } 3159 3160 /* 3161 * csr_is_auth_fils_ft_sha256() - check whether oui is fils ft sha256 3162 * @mac: Global MAC context 3163 * @all_suites: pointer to all supported akm suites 3164 * @suite_count: all supported akm suites count 3165 * @oui: Oui needs to be matched 3166 * 3167 * Return: True if OUI is FT FILS SHA256, false otherwise 3168 */ 3169 static bool csr_is_auth_fils_ft_sha256(tpAniSirGlobal mac, 3170 uint8_t all_suites[][CSR_RSN_OUI_SIZE], 3171 uint8_t suite_count, uint8_t oui[]) 3172 { 3173 return csr_is_oui_match(mac, all_suites, suite_count, 3174 csr_rsn_oui[ENUM_FT_FILS_SHA256], oui); 3175 } 3176 3177 /* 3178 * csr_is_auth_fils_ft_sha384() - check whether oui is fils ft sha384 3179 * @mac: Global MAC context 3180 * @all_suites: pointer to all supported akm suites 3181 * @suite_count: all supported akm suites count 3182 * @oui: Oui needs to be matched 3183 * 3184 * Return: True if OUI is FT FILS SHA384, false otherwise 3185 */ 3186 static bool csr_is_auth_fils_ft_sha384(tpAniSirGlobal mac, 3187 uint8_t all_suites[][CSR_RSN_OUI_SIZE], 3188 uint8_t suite_count, uint8_t oui[]) 3189 { 3190 return csr_is_oui_match(mac, all_suites, suite_count, 3191 csr_rsn_oui[ENUM_FT_FILS_SHA384], oui); 3192 } 3193 #endif 3194 3195 /* 3196 * csr_is_auth_dpp_rsn() - check whether oui is dpp rsn 3197 * @mac: Global MAC context 3198 * @all_suites: pointer to all supported akm suites 3199 * @suite_count: all supported akm suites count 3200 * @oui: Oui needs to be matched 3201 * 3202 * Return: True if OUI is dpp rsn, false otherwise 3203 */ 3204 static bool csr_is_auth_dpp_rsn(tpAniSirGlobal mac, 3205 uint8_t all_suites[][CSR_RSN_OUI_SIZE], 3206 uint8_t suite_count, uint8_t oui[]) 3207 { 3208 return csr_is_oui_match(mac, all_suites, suite_count, 3209 csr_rsn_oui[ENUM_DPP_RSN], oui); 3210 } 3211 3212 /* 3213 * csr_is_auth_wpa_owe() - check whether oui is OWE 3214 * @mac: Global MAC context 3215 * @all_suites: pointer to all supported akm suites 3216 * @suite_count: all supported akm suites count 3217 * @oui: Oui needs to be matched 3218 * 3219 * Return: True if OUI is SAE, false otherwise 3220 */ 3221 static bool csr_is_auth_wpa_owe(tpAniSirGlobal mac, 3222 uint8_t all_suites[][CSR_RSN_OUI_SIZE], 3223 uint8_t suite_count, uint8_t oui[]) 3224 { 3225 return csr_is_oui_match 3226 (mac, all_suites, suite_count, csr_rsn_oui[ENUM_OWE], oui); 3227 } 3228 3229 static bool csr_is_auth_wpa(tpAniSirGlobal pMac, 3230 uint8_t AllSuites[][CSR_WPA_OUI_SIZE], 3231 uint8_t cAllSuites, uint8_t Oui[]) 3232 { 3233 return csr_is_oui_match 3234 (pMac, AllSuites, cAllSuites, csr_wpa_oui[01], Oui); 3235 } 3236 3237 static bool csr_is_auth_wpa_psk(tpAniSirGlobal pMac, 3238 uint8_t AllSuites[][CSR_WPA_OUI_SIZE], 3239 uint8_t cAllSuites, uint8_t Oui[]) 3240 { 3241 return csr_is_oui_match 3242 (pMac, AllSuites, cAllSuites, csr_wpa_oui[02], Oui); 3243 } 3244 3245 static uint8_t csr_get_oui_index_from_cipher(eCsrEncryptionType enType) 3246 { 3247 uint8_t OUIIndex; 3248 3249 switch (enType) { 3250 case eCSR_ENCRYPT_TYPE_WEP40: 3251 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY: 3252 OUIIndex = CSR_OUI_WEP40_OR_1X_INDEX; 3253 break; 3254 case eCSR_ENCRYPT_TYPE_WEP104: 3255 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY: 3256 OUIIndex = CSR_OUI_WEP104_INDEX; 3257 break; 3258 case eCSR_ENCRYPT_TYPE_TKIP: 3259 OUIIndex = CSR_OUI_TKIP_OR_PSK_INDEX; 3260 break; 3261 case eCSR_ENCRYPT_TYPE_AES: 3262 OUIIndex = CSR_OUI_AES_INDEX; 3263 break; 3264 case eCSR_ENCRYPT_TYPE_AES_GCMP: 3265 OUIIndex = CSR_OUI_AES_GCMP_INDEX; 3266 break; 3267 case eCSR_ENCRYPT_TYPE_AES_GCMP_256: 3268 OUIIndex = CSR_OUI_AES_GCMP_256_INDEX; 3269 break; 3270 case eCSR_ENCRYPT_TYPE_NONE: 3271 OUIIndex = CSR_OUI_USE_GROUP_CIPHER_INDEX; 3272 break; 3273 #ifdef FEATURE_WLAN_WAPI 3274 case eCSR_ENCRYPT_TYPE_WPI: 3275 OUIIndex = CSR_OUI_WAPI_WAI_CERT_OR_SMS4_INDEX; 3276 break; 3277 #endif /* FEATURE_WLAN_WAPI */ 3278 default: /* HOWTO handle this? */ 3279 OUIIndex = CSR_OUI_RESERVED_INDEX; 3280 break; 3281 } /* switch */ 3282 3283 return OUIIndex; 3284 } 3285 3286 #ifdef WLAN_FEATURE_FILS_SK 3287 /** 3288 * csr_is_fils_auth() - update negotiated auth if matches to FILS auth type 3289 * @mac_ctx: pointer to mac context 3290 * @authsuites: auth suites 3291 * @c_auth_suites: auth suites count 3292 * @authentication: authentication 3293 * @auth_type: authentication type list 3294 * @index: current counter 3295 * @neg_authtype: pointer to negotiated auth 3296 * 3297 * Return: None 3298 */ 3299 static void csr_is_fils_auth(tpAniSirGlobal mac_ctx, 3300 uint8_t authsuites[][CSR_RSN_OUI_SIZE], uint8_t c_auth_suites, 3301 uint8_t authentication[], tCsrAuthList *auth_type, 3302 uint8_t index, eCsrAuthType *neg_authtype) 3303 { 3304 /* 3305 * TODO Always try with highest security 3306 * move this down once sha384 is validated 3307 */ 3308 if (csr_is_auth_fils_sha256(mac_ctx, authsuites, 3309 c_auth_suites, authentication)) { 3310 if (eCSR_AUTH_TYPE_FILS_SHA256 == 3311 auth_type->authType[index]) 3312 *neg_authtype = eCSR_AUTH_TYPE_FILS_SHA256; 3313 } 3314 if ((*neg_authtype == eCSR_AUTH_TYPE_UNKNOWN) && 3315 csr_is_auth_fils_sha384(mac_ctx, authsuites, 3316 c_auth_suites, authentication)) { 3317 if (eCSR_AUTH_TYPE_FILS_SHA384 == 3318 auth_type->authType[index]) 3319 *neg_authtype = eCSR_AUTH_TYPE_FILS_SHA384; 3320 } 3321 if ((*neg_authtype == eCSR_AUTH_TYPE_UNKNOWN) && 3322 csr_is_auth_fils_ft_sha256(mac_ctx, authsuites, 3323 c_auth_suites, authentication)) { 3324 if (eCSR_AUTH_TYPE_FT_FILS_SHA256 == 3325 auth_type->authType[index]) 3326 *neg_authtype = eCSR_AUTH_TYPE_FT_FILS_SHA256; 3327 } 3328 if ((*neg_authtype == eCSR_AUTH_TYPE_UNKNOWN) && 3329 csr_is_auth_fils_ft_sha384(mac_ctx, authsuites, 3330 c_auth_suites, authentication)) { 3331 if (eCSR_AUTH_TYPE_FT_FILS_SHA384 == 3332 auth_type->authType[index]) 3333 *neg_authtype = eCSR_AUTH_TYPE_FT_FILS_SHA384; 3334 } 3335 sme_debug("negotiated auth type is %d", *neg_authtype); 3336 } 3337 #else 3338 static void csr_is_fils_auth(tpAniSirGlobal mac_ctx, 3339 uint8_t authsuites[][CSR_RSN_OUI_SIZE], uint8_t c_auth_suites, 3340 uint8_t authentication[], tCsrAuthList *auth_type, 3341 uint8_t index, eCsrAuthType *neg_authtype) 3342 { 3343 } 3344 #endif 3345 /** 3346 * csr_get_rsn_information() - to get RSN infomation 3347 * @hal: pointer to HAL 3348 * @auth_type: auth type 3349 * @encr_type: encryption type 3350 * @mc_encryption: multicast encryption type 3351 * @rsn_ie: pointer to RSN IE 3352 * @ucast_cipher: Unicast cipher 3353 * @mcast_cipher: Multicast cipher 3354 * @auth_suite: Authentication suite 3355 * @capabilities: RSN capabilities 3356 * @negotiated_authtype: Negotiated auth type 3357 * @negotiated_mccipher: negotiated multicast cipher 3358 * 3359 * This routine will get all RSN information 3360 * 3361 * Return: bool 3362 */ 3363 static bool csr_get_rsn_information(tHalHandle hal, tCsrAuthList *auth_type, 3364 eCsrEncryptionType encr_type, 3365 tCsrEncryptionList *mc_encryption, 3366 tDot11fIERSN *rsn_ie, uint8_t *ucast_cipher, 3367 uint8_t *mcast_cipher, uint8_t *auth_suite, 3368 tCsrRSNCapabilities *capabilities, 3369 eCsrAuthType *negotiated_authtype, 3370 eCsrEncryptionType *negotiated_mccipher) 3371 { 3372 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal); 3373 bool acceptable_cipher = false; 3374 uint8_t c_ucast_cipher = 0; 3375 uint8_t c_mcast_cipher = 0; 3376 uint8_t c_auth_suites = 0, i; 3377 uint8_t unicast[CSR_RSN_OUI_SIZE]; 3378 uint8_t multicast[CSR_RSN_OUI_SIZE]; 3379 uint8_t authsuites[CSR_RSN_MAX_AUTH_SUITES][CSR_RSN_OUI_SIZE]; 3380 uint8_t authentication[CSR_RSN_OUI_SIZE]; 3381 uint8_t mccipher_arr[CSR_RSN_MAX_MULTICAST_CYPHERS][CSR_RSN_OUI_SIZE]; 3382 eCsrAuthType neg_authtype = eCSR_AUTH_TYPE_UNKNOWN; 3383 3384 if (!rsn_ie->present) 3385 goto end; 3386 c_mcast_cipher++; 3387 qdf_mem_copy(mccipher_arr, rsn_ie->gp_cipher_suite, 3388 CSR_RSN_OUI_SIZE); 3389 c_ucast_cipher = 3390 (uint8_t) (rsn_ie->pwise_cipher_suite_count); 3391 c_auth_suites = (uint8_t) (rsn_ie->akm_suite_count); 3392 for (i = 0; i < c_auth_suites && i < CSR_RSN_MAX_AUTH_SUITES; i++) { 3393 qdf_mem_copy((void *)&authsuites[i], 3394 (void *)&rsn_ie->akm_suites[i], CSR_RSN_OUI_SIZE); 3395 } 3396 3397 /* Check - Is requested unicast Cipher supported by the BSS. */ 3398 acceptable_cipher = csr_match_rsnoui_index(mac_ctx, 3399 rsn_ie->pwise_cipher_suites, c_ucast_cipher, 3400 csr_get_oui_index_from_cipher(encr_type), 3401 unicast); 3402 3403 if (!acceptable_cipher) 3404 goto end; 3405 3406 /* unicast is supported. Pick the first matching Group cipher, if any */ 3407 for (i = 0; i < mc_encryption->numEntries; i++) { 3408 acceptable_cipher = csr_match_rsnoui_index(mac_ctx, 3409 mccipher_arr, c_mcast_cipher, 3410 csr_get_oui_index_from_cipher( 3411 mc_encryption->encryptionType[i]), 3412 multicast); 3413 if (acceptable_cipher) 3414 break; 3415 } 3416 if (!acceptable_cipher) 3417 goto end; 3418 3419 if (negotiated_mccipher) 3420 *negotiated_mccipher = mc_encryption->encryptionType[i]; 3421 3422 /* Initializing with false as it has true value already */ 3423 acceptable_cipher = false; 3424 for (i = 0; i < auth_type->numEntries; i++) { 3425 /* 3426 * Ciphers are supported, Match authentication algorithm and 3427 * pick first matching authtype. 3428 */ 3429 /* Set FILS as first preference */ 3430 csr_is_fils_auth(mac_ctx, authsuites, c_auth_suites, 3431 authentication, auth_type, i, &neg_authtype); 3432 /* Changed the AKM suites according to order of preference */ 3433 if ((neg_authtype == eCSR_AUTH_TYPE_UNKNOWN) && 3434 csr_is_auth_dpp_rsn(mac_ctx, authsuites, 3435 c_auth_suites, authentication)) { 3436 if (eCSR_AUTH_TYPE_DPP_RSN == auth_type->authType[i]) 3437 neg_authtype = eCSR_AUTH_TYPE_DPP_RSN; 3438 } 3439 if ((neg_authtype == eCSR_AUTH_TYPE_UNKNOWN) && 3440 csr_is_ft_auth_rsn(mac_ctx, authsuites, 3441 c_auth_suites, authentication)) { 3442 if (eCSR_AUTH_TYPE_FT_RSN == auth_type->authType[i]) 3443 neg_authtype = eCSR_AUTH_TYPE_FT_RSN; 3444 } 3445 if ((neg_authtype == eCSR_AUTH_TYPE_UNKNOWN) 3446 && csr_is_ft_auth_rsn_psk(mac_ctx, authsuites, 3447 c_auth_suites, authentication)) { 3448 if (eCSR_AUTH_TYPE_FT_RSN_PSK == 3449 auth_type->authType[i]) 3450 neg_authtype = eCSR_AUTH_TYPE_FT_RSN_PSK; 3451 } 3452 #ifdef FEATURE_WLAN_ESE 3453 /* ESE only supports 802.1X. No PSK. */ 3454 if ((neg_authtype == eCSR_AUTH_TYPE_UNKNOWN) && 3455 csr_is_ese_cckm_auth_rsn(mac_ctx, authsuites, 3456 c_auth_suites, authentication)) { 3457 if (eCSR_AUTH_TYPE_CCKM_RSN == auth_type->authType[i]) 3458 neg_authtype = eCSR_AUTH_TYPE_CCKM_RSN; 3459 } 3460 #endif 3461 if ((neg_authtype == eCSR_AUTH_TYPE_UNKNOWN) 3462 && csr_is_auth_rsn(mac_ctx, authsuites, 3463 c_auth_suites, authentication)) { 3464 if (eCSR_AUTH_TYPE_RSN == auth_type->authType[i]) 3465 neg_authtype = eCSR_AUTH_TYPE_RSN; 3466 } 3467 if ((neg_authtype == eCSR_AUTH_TYPE_UNKNOWN) 3468 && csr_is_auth_rsn_psk(mac_ctx, authsuites, 3469 c_auth_suites, authentication)) { 3470 if (eCSR_AUTH_TYPE_RSN_PSK == auth_type->authType[i]) 3471 neg_authtype = eCSR_AUTH_TYPE_RSN_PSK; 3472 } 3473 #ifdef WLAN_FEATURE_11W 3474 if ((neg_authtype == eCSR_AUTH_TYPE_UNKNOWN) 3475 && csr_is_auth_rsn_psk_sha256(mac_ctx, authsuites, 3476 c_auth_suites, authentication)) { 3477 if (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == 3478 auth_type->authType[i]) 3479 neg_authtype = eCSR_AUTH_TYPE_RSN_PSK_SHA256; 3480 } 3481 if ((neg_authtype == eCSR_AUTH_TYPE_UNKNOWN) && 3482 csr_is_auth_rsn8021x_sha256(mac_ctx, authsuites, 3483 c_auth_suites, authentication)) { 3484 if (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == 3485 auth_type->authType[i]) 3486 neg_authtype = eCSR_AUTH_TYPE_RSN_8021X_SHA256; 3487 } 3488 #endif 3489 if ((neg_authtype == eCSR_AUTH_TYPE_UNKNOWN) && 3490 csr_is_auth_wpa_owe(mac_ctx, authsuites, 3491 c_auth_suites, authentication)) { 3492 if (eCSR_AUTH_TYPE_OWE == auth_type->authType[i]) 3493 neg_authtype = eCSR_AUTH_TYPE_OWE; 3494 } 3495 3496 /* 3497 * The 1st auth type in the APs RSN IE, to match stations 3498 * connecting profiles auth type will cause us to exit this 3499 * loop. This is added as some APs advertise multiple akms in 3500 * the RSN IE 3501 */ 3502 if (eCSR_AUTH_TYPE_UNKNOWN != neg_authtype) { 3503 acceptable_cipher = true; 3504 break; 3505 } 3506 } /* for */ 3507 end: 3508 if (acceptable_cipher) { 3509 if (mcast_cipher) 3510 qdf_mem_copy(mcast_cipher, multicast, 3511 CSR_RSN_OUI_SIZE); 3512 3513 if (ucast_cipher) 3514 qdf_mem_copy(ucast_cipher, unicast, CSR_RSN_OUI_SIZE); 3515 3516 if (auth_suite) 3517 qdf_mem_copy(auth_suite, authentication, 3518 CSR_RSN_OUI_SIZE); 3519 3520 if (negotiated_authtype) 3521 *negotiated_authtype = neg_authtype; 3522 3523 if (capabilities) { 3524 /* Bit 0 Preauthentication */ 3525 capabilities->PreAuthSupported = 3526 (rsn_ie->RSN_Cap[0] >> 0) & 0x1; 3527 /* Bit 1 No Pairwise */ 3528 capabilities->NoPairwise = 3529 (rsn_ie->RSN_Cap[0] >> 1) & 0x1; 3530 /* Bit 2, 3 PTKSA Replay Counter */ 3531 capabilities->PTKSAReplayCounter = 3532 (rsn_ie->RSN_Cap[0] >> 2) & 0x3; 3533 /* Bit 4, 5 GTKSA Replay Counter */ 3534 capabilities->GTKSAReplayCounter = 3535 (rsn_ie->RSN_Cap[0] >> 4) & 0x3; 3536 #ifdef WLAN_FEATURE_11W 3537 /* Bit 6 MFPR */ 3538 capabilities->MFPRequired = 3539 (rsn_ie->RSN_Cap[0] >> 6) & 0x1; 3540 /* Bit 7 MFPC */ 3541 capabilities->MFPCapable = 3542 (rsn_ie->RSN_Cap[0] >> 7) & 0x1; 3543 #else 3544 /* Bit 6 MFPR */ 3545 capabilities->MFPRequired = 0; 3546 /* Bit 7 MFPC */ 3547 capabilities->MFPCapable = 0; 3548 #endif 3549 /* remaining reserved */ 3550 capabilities->Reserved = rsn_ie->RSN_Cap[1] & 0xff; 3551 } 3552 } 3553 return acceptable_cipher; 3554 } 3555 3556 #ifdef WLAN_FEATURE_11W 3557 /** 3558 * csr_is_pmf_capabilities_in_rsn_match() - check for PMF capability 3559 * @hHal: Global HAL handle 3560 * @pFilterMFPEnabled: given by supplicant to us to specify what kind 3561 * of connection supplicant is expecting to make 3562 * if it is enabled then make PMF connection. 3563 * if it is disabled then make normal connection. 3564 * @pFilterMFPRequired: given by supplicant based on our configuration 3565 * if it is 1 then we will require mandatory 3566 * PMF connection and if it is 0 then we PMF 3567 * connection is optional. 3568 * @pFilterMFPCapable: given by supplicant based on our configuration 3569 * if it 1 then we are PMF capable and if it 0 3570 * then we are not PMF capable. 3571 * @pRSNIe: RSNIe from Beacon/probe response of 3572 * neighbor AP against which we will compare 3573 * our capabilities. 3574 * 3575 * This function is to match our current capabilities with the AP 3576 * to which we are expecting make the connection. 3577 * 3578 * Return: if our PMF capabilities matches with AP then we 3579 * will return true to indicate that we are good 3580 * to make connection with it. Else we will return false 3581 **/ 3582 static bool 3583 csr_is_pmf_capabilities_in_rsn_match(tHalHandle hHal, 3584 bool *pFilterMFPEnabled, 3585 uint8_t *pFilterMFPRequired, 3586 uint8_t *pFilterMFPCapable, 3587 tDot11fIERSN *pRSNIe) 3588 { 3589 uint8_t apProfileMFPCapable = 0; 3590 uint8_t apProfileMFPRequired = 0; 3591 3592 if (pRSNIe && pFilterMFPEnabled && pFilterMFPCapable 3593 && pFilterMFPRequired) { 3594 /* Extracting MFPCapable bit from RSN Ie */ 3595 apProfileMFPCapable = csr_is_mfpc_capable(pRSNIe); 3596 apProfileMFPRequired = (pRSNIe->RSN_Cap[0] >> 6) & 0x1; 3597 3598 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG, 3599 "pFilterMFPEnabled: %d pFilterMFPRequired: %d pFilterMFPCapable: %d apProfileMFPCapable: %d apProfileMFPRequired: %d", 3600 *pFilterMFPEnabled, *pFilterMFPRequired, 3601 *pFilterMFPCapable, apProfileMFPCapable, 3602 apProfileMFPRequired); 3603 3604 if (*pFilterMFPEnabled && *pFilterMFPCapable 3605 && *pFilterMFPRequired && (apProfileMFPCapable == 0)) { 3606 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG, 3607 "AP is not capable to make PMF connection"); 3608 return false; 3609 } else if (!(*pFilterMFPCapable) && 3610 apProfileMFPCapable && apProfileMFPRequired) { 3611 3612 /* 3613 * In this case, AP with whom we trying to connect 3614 * requires mandatory PMF connections and we are not 3615 * capable so this AP is not good choice to connect 3616 */ 3617 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG, 3618 "AP needs PMF connection and we are not capable of pmf connection"); 3619 return false; 3620 } 3621 } 3622 return true; 3623 } 3624 #endif 3625 3626 static bool csr_is_rsn_match(tHalHandle hHal, tCsrAuthList *pAuthType, 3627 eCsrEncryptionType enType, 3628 tCsrEncryptionList *pEnMcType, 3629 bool *pMFPEnabled, uint8_t *pMFPRequired, 3630 uint8_t *pMFPCapable, 3631 tDot11fBeaconIEs *pIes, 3632 eCsrAuthType *pNegotiatedAuthType, 3633 eCsrEncryptionType *pNegotiatedMCCipher) 3634 { 3635 bool fRSNMatch = false; 3636 3637 /* See if the cyphers in the Bss description match with the 3638 * settings in the profile. 3639 */ 3640 fRSNMatch = csr_get_rsn_information(hHal, pAuthType, enType, 3641 pEnMcType, &pIes->RSN, 3642 NULL, NULL, NULL, NULL, 3643 pNegotiatedAuthType, 3644 pNegotiatedMCCipher); 3645 #ifdef WLAN_FEATURE_11W 3646 /* If all the filter matches then finally checks for PMF capabilities */ 3647 if (fRSNMatch) 3648 fRSNMatch = csr_is_pmf_capabilities_in_rsn_match(hHal, 3649 pMFPEnabled, 3650 pMFPRequired, 3651 pMFPCapable, 3652 &pIes->RSN); 3653 #endif 3654 return fRSNMatch; 3655 } 3656 3657 /** 3658 * csr_lookup_pmkid_using_ssid() - lookup pmkid using ssid and cache_id 3659 * @mac: pointer to mac 3660 * @session: sme session pointer 3661 * @pmk_cache: pointer to pmk cache 3662 * @index: index value needs to be seached 3663 * 3664 * Return: true if pmkid is found else false 3665 */ 3666 static bool csr_lookup_pmkid_using_ssid(tpAniSirGlobal mac, 3667 struct csr_roam_session *session, 3668 tPmkidCacheInfo *pmk_cache, 3669 uint32_t *index) 3670 { 3671 uint32_t i; 3672 tPmkidCacheInfo *session_pmk; 3673 3674 for (i = 0; i < session->NumPmkidCache; i++) { 3675 session_pmk = &session->PmkidCacheInfo[i]; 3676 sme_debug("match PMKID ssid %*.*s cache id %x %x ssid_len %d to ssid %s cache_id %x %x", 3677 pmk_cache->ssid_len, pmk_cache->ssid_len, 3678 pmk_cache->ssid, pmk_cache->cache_id[0], 3679 pmk_cache->cache_id[1], pmk_cache->ssid_len, 3680 session_pmk->ssid, 3681 session_pmk->cache_id[0], session_pmk->cache_id[1]); 3682 3683 if ((!qdf_mem_cmp(pmk_cache->ssid, session_pmk->ssid, 3684 pmk_cache->ssid_len)) && 3685 (!qdf_mem_cmp(session_pmk->cache_id, 3686 pmk_cache->cache_id, CACHE_ID_LEN))) { 3687 /* match found */ 3688 *index = i; 3689 sme_debug("PMKID found at index %d", i); 3690 return true; 3691 } 3692 } 3693 3694 return false; 3695 } 3696 3697 /** 3698 * csr_lookup_pmkid_using_bssid() - lookup pmkid using bssid 3699 * @mac: pointer to mac 3700 * @session: sme session pointer 3701 * @pmk_cache: pointer to pmk cache 3702 * @index: index value needs to be seached 3703 * 3704 * Return: true if pmkid is found else false 3705 */ 3706 static bool csr_lookup_pmkid_using_bssid(tpAniSirGlobal mac, 3707 struct csr_roam_session *session, 3708 tPmkidCacheInfo *pmk_cache, 3709 uint32_t *index) 3710 { 3711 uint32_t i; 3712 tPmkidCacheInfo *session_pmk; 3713 3714 for (i = 0; i < session->NumPmkidCache; i++) { 3715 session_pmk = &session->PmkidCacheInfo[i]; 3716 sme_debug("Matching BSSID: " MAC_ADDRESS_STR " to cached BSSID:" 3717 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pmk_cache->BSSID.bytes), 3718 MAC_ADDR_ARRAY(session_pmk->BSSID.bytes)); 3719 if (qdf_is_macaddr_equal(&pmk_cache->BSSID, 3720 &session_pmk->BSSID)) { 3721 /* match found */ 3722 *index = i; 3723 sme_debug("PMKID found at index %d", i); 3724 return true; 3725 } 3726 } 3727 3728 return false; 3729 } 3730 3731 /** 3732 * csr_lookup_pmkid() - lookup pmkid using bssid or ssid + cache_id 3733 * @mac: pointer to mac 3734 * @session: sme session pointer 3735 * @pmk_cache: pointer to pmk cache 3736 * @index: index value needs to be seached 3737 * 3738 * Return: true if pmkid is found else false 3739 */ 3740 static bool csr_lookup_pmkid(tpAniSirGlobal pMac, uint32_t sessionId, 3741 tPmkidCacheInfo *pmk_cache) 3742 { 3743 bool fRC = false, fMatchFound = false; 3744 uint32_t Index; 3745 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId); 3746 3747 if (!pSession) { 3748 sme_err("session %d not found", sessionId); 3749 return false; 3750 } 3751 3752 if (pmk_cache->ssid_len) { 3753 /* Try to find based on cache_id and ssid first */ 3754 fMatchFound = csr_lookup_pmkid_using_ssid(pMac, pSession, 3755 pmk_cache, &Index); 3756 } 3757 3758 /* If not able to find using cache id or ssid_len is not present */ 3759 if (!fMatchFound) 3760 fMatchFound = csr_lookup_pmkid_using_bssid(pMac, 3761 pSession, pmk_cache, &Index); 3762 3763 if (!fMatchFound) { 3764 sme_debug("no pmkid match found NumPmkidCache = %d", 3765 pSession->NumPmkidCache); 3766 return false; 3767 } 3768 3769 qdf_mem_copy(pmk_cache->PMKID, 3770 pSession->PmkidCacheInfo[Index].PMKID, 3771 CSR_RSN_PMKID_SIZE); 3772 3773 qdf_mem_copy(pmk_cache->pmk, 3774 pSession->PmkidCacheInfo[Index].pmk, 3775 pSession->PmkidCacheInfo[Index].pmk_len); 3776 pmk_cache->pmk_len = pSession->PmkidCacheInfo[Index].pmk_len; 3777 3778 fRC = true; 3779 sme_debug("match = %d NumPmkidCache = %d", 3780 fRC, pSession->NumPmkidCache); 3781 3782 return fRC; 3783 } 3784 3785 #ifdef WLAN_FEATURE_FILS_SK 3786 /* 3787 * csr_update_pmksa_for_cache_id: update tPmkidCacheInfo to lookup using 3788 * ssid and cache id 3789 * @bss_desc: bss description 3790 * @profile: csr roam profile 3791 * @pmkid_cache: pmksa cache 3792 * 3793 * Return: true if cache identifier present else false 3794 */ 3795 static bool csr_update_pmksa_for_cache_id(tSirBssDescription *bss_desc, 3796 tCsrRoamProfile *profile, 3797 tPmkidCacheInfo *pmkid_cache) 3798 { 3799 if (!bss_desc->fils_info_element.is_cache_id_present) 3800 return false; 3801 3802 pmkid_cache->ssid_len = 3803 profile->SSIDs.SSIDList[0].SSID.length; 3804 qdf_mem_copy(pmkid_cache->ssid, 3805 profile->SSIDs.SSIDList[0].SSID.ssId, 3806 profile->SSIDs.SSIDList[0].SSID.length); 3807 qdf_mem_copy(pmkid_cache->cache_id, 3808 bss_desc->fils_info_element.cache_id, 3809 CACHE_ID_LEN); 3810 qdf_mem_copy(pmkid_cache->BSSID.bytes, 3811 bss_desc->bssId, QDF_MAC_ADDR_SIZE); 3812 3813 return true; 3814 3815 } 3816 3817 /* 3818 * csr_update_pmksa_to_profile: update pmk and pmkid to profile which will be 3819 * used in case of fils session 3820 * @profile: profile 3821 * @pmkid_cache: pmksa cache 3822 * 3823 * Return: None 3824 */ 3825 static inline void csr_update_pmksa_to_profile(tCsrRoamProfile *profile, 3826 tPmkidCacheInfo *pmkid_cache) 3827 { 3828 if (!profile->fils_con_info) 3829 return; 3830 3831 profile->fils_con_info->pmk_len = pmkid_cache->pmk_len; 3832 qdf_mem_copy(profile->fils_con_info->pmk, 3833 pmkid_cache->pmk, pmkid_cache->pmk_len); 3834 qdf_mem_copy(profile->fils_con_info->pmkid, 3835 pmkid_cache->PMKID, CSR_RSN_PMKID_SIZE); 3836 3837 } 3838 #else 3839 static inline bool csr_update_pmksa_for_cache_id(tSirBssDescription *bss_desc, 3840 tCsrRoamProfile *profile, 3841 tPmkidCacheInfo *pmkid_cache) 3842 { 3843 return false; 3844 } 3845 3846 static inline void csr_update_pmksa_to_profile(tCsrRoamProfile *profile, 3847 tPmkidCacheInfo *pmkid_cache) 3848 { 3849 } 3850 #endif 3851 3852 uint8_t csr_construct_rsn_ie(tHalHandle hHal, uint32_t sessionId, 3853 tCsrRoamProfile *pProfile, 3854 tSirBssDescription *pSirBssDesc, 3855 tDot11fBeaconIEs *pIes, tCsrRSNIe *pRSNIe) 3856 { 3857 tpAniSirGlobal pMac = PMAC_STRUCT(hHal); 3858 bool fRSNMatch; 3859 uint8_t cbRSNIe = 0; 3860 uint8_t UnicastCypher[CSR_RSN_OUI_SIZE]; 3861 uint8_t MulticastCypher[CSR_RSN_OUI_SIZE]; 3862 uint8_t AuthSuite[CSR_RSN_OUI_SIZE]; 3863 tCsrRSNAuthIe *pAuthSuite; 3864 tCsrRSNCapabilities RSNCapabilities; 3865 tCsrRSNPMKIe *pPMK; 3866 tPmkidCacheInfo pmkid_cache; 3867 #ifdef WLAN_FEATURE_11W 3868 uint8_t *pGroupMgmtCipherSuite; 3869 #endif 3870 tDot11fBeaconIEs *pIesLocal = pIes; 3871 eCsrAuthType negAuthType = eCSR_AUTH_TYPE_UNKNOWN; 3872 3873 qdf_mem_zero(&pmkid_cache, sizeof(pmkid_cache)); 3874 do { 3875 if (!csr_is_profile_rsn(pProfile)) 3876 break; 3877 3878 if (!pIesLocal 3879 && 3880 (!QDF_IS_STATUS_SUCCESS 3881 (csr_get_parsed_bss_description_ies 3882 (pMac, pSirBssDesc, &pIesLocal)))) { 3883 break; 3884 } 3885 /* See if the cyphers in the Bss description match with the 3886 * settings in the profile. 3887 */ 3888 fRSNMatch = csr_get_rsn_information(hHal, &pProfile->AuthType, 3889 pProfile->negotiatedUCEncryptionType, 3890 &pProfile->mcEncryptionType, 3891 &pIesLocal->RSN, UnicastCypher, 3892 MulticastCypher, AuthSuite, 3893 &RSNCapabilities, &negAuthType, NULL); 3894 if (!fRSNMatch) 3895 break; 3896 3897 pRSNIe->IeHeader.ElementID = SIR_MAC_RSN_EID; 3898 3899 pRSNIe->Version = CSR_RSN_VERSION_SUPPORTED; 3900 3901 qdf_mem_copy(pRSNIe->MulticastOui, MulticastCypher, 3902 sizeof(MulticastCypher)); 3903 3904 pRSNIe->cUnicastCyphers = 1; 3905 3906 qdf_mem_copy(&pRSNIe->UnicastOui[0], UnicastCypher, 3907 sizeof(UnicastCypher)); 3908 3909 pAuthSuite = 3910 (tCsrRSNAuthIe *) (&pRSNIe-> 3911 UnicastOui[pRSNIe->cUnicastCyphers]); 3912 3913 pAuthSuite->cAuthenticationSuites = 1; 3914 qdf_mem_copy(&pAuthSuite->AuthOui[0], AuthSuite, 3915 sizeof(AuthSuite)); 3916 3917 /* RSN capabilities follows the Auth Suite (two octects) 3918 * !!REVIEW - What should STA put in RSN capabilities, currently 3919 * just putting back APs capabilities For one, we shouldn't 3920 * EVER be sending out "pre-auth supported". It is an AP only 3921 * capability For another, we should use the Management Frame 3922 * Protection values given by the supplicant 3923 */ 3924 RSNCapabilities.PreAuthSupported = 0; 3925 #ifdef WLAN_FEATURE_11W 3926 if (RSNCapabilities.MFPCapable && pProfile->MFPCapable) { 3927 RSNCapabilities.MFPCapable = pProfile->MFPCapable; 3928 RSNCapabilities.MFPRequired = pProfile->MFPRequired; 3929 } else { 3930 RSNCapabilities.MFPCapable = 0; 3931 RSNCapabilities.MFPRequired = 0; 3932 } 3933 #endif 3934 *(uint16_t *) (&pAuthSuite->AuthOui[1]) = 3935 *((uint16_t *) (&RSNCapabilities)); 3936 3937 pPMK = (tCsrRSNPMKIe *) (((uint8_t *) (&pAuthSuite->AuthOui[1])) 3938 + sizeof(uint16_t)); 3939 3940 if (!csr_update_pmksa_for_cache_id(pSirBssDesc, 3941 pProfile, &pmkid_cache)) 3942 qdf_mem_copy(pmkid_cache.BSSID.bytes, 3943 pSirBssDesc->bssId, QDF_MAC_ADDR_SIZE); 3944 /* Don't include the PMK SA IDs for CCKM associations. */ 3945 if ( 3946 #ifdef FEATURE_WLAN_ESE 3947 (eCSR_AUTH_TYPE_CCKM_RSN != negAuthType) && 3948 #endif 3949 csr_lookup_pmkid(pMac, sessionId, &pmkid_cache)) { 3950 pPMK->cPMKIDs = 1; 3951 3952 qdf_trace_hex_dump(QDF_MODULE_ID_PE, 3953 QDF_TRACE_LEVEL_INFO, 3954 pmkid_cache.pmk, pmkid_cache.pmk_len); 3955 qdf_mem_copy(pPMK->PMKIDList[0].PMKID, 3956 pmkid_cache.PMKID, 3957 CSR_RSN_PMKID_SIZE); 3958 csr_update_pmksa_to_profile(pProfile, &pmkid_cache); 3959 } else { 3960 pPMK->cPMKIDs = 0; 3961 } 3962 3963 #ifdef WLAN_FEATURE_11W 3964 /* Advertise BIP in group cipher key management only if PMF is 3965 * enabled and AP is capable. 3966 */ 3967 if (pProfile->MFPEnabled && 3968 (RSNCapabilities.MFPCapable && pProfile->MFPCapable)) { 3969 pGroupMgmtCipherSuite = 3970 (uint8_t *) pPMK + sizeof(uint16_t) + 3971 (pPMK->cPMKIDs * CSR_RSN_PMKID_SIZE); 3972 qdf_mem_copy(pGroupMgmtCipherSuite, csr_rsn_oui[07], 3973 CSR_WPA_OUI_SIZE); 3974 } 3975 #endif 3976 3977 /* Add in the fixed fields plus 1 Unicast cypher, less the 3978 * IE Header length Add in the size of the Auth suite (count 3979 * plus a single OUI) Add in the RSN caps field. 3980 * Add PMKID count and PMKID (if any) 3981 * Add group management cipher suite 3982 */ 3983 pRSNIe->IeHeader.Length = 3984 (uint8_t) (sizeof(*pRSNIe) - sizeof(pRSNIe->IeHeader) + 3985 sizeof(*pAuthSuite) + 3986 sizeof(tCsrRSNCapabilities)); 3987 if (pPMK->cPMKIDs) 3988 pRSNIe->IeHeader.Length += (uint8_t) (sizeof(uint16_t) + 3989 (pPMK->cPMKIDs * 3990 CSR_RSN_PMKID_SIZE)); 3991 #ifdef WLAN_FEATURE_11W 3992 if (pProfile->MFPEnabled && 3993 (RSNCapabilities.MFPCapable && pProfile->MFPCapable)) { 3994 if (0 == pPMK->cPMKIDs) 3995 pRSNIe->IeHeader.Length += sizeof(uint16_t); 3996 pRSNIe->IeHeader.Length += CSR_WPA_OUI_SIZE; 3997 } 3998 #endif 3999 4000 /* return the size of the IE header (total) constructed... */ 4001 cbRSNIe = pRSNIe->IeHeader.Length + sizeof(pRSNIe->IeHeader); 4002 4003 } while (0); 4004 4005 if (!pIes && pIesLocal) 4006 /* locally allocated */ 4007 qdf_mem_free(pIesLocal); 4008 4009 return cbRSNIe; 4010 } 4011 4012 #ifdef FEATURE_WLAN_WAPI 4013 /** 4014 * csr_get_wapi_information() - to get WAPI infomation 4015 * @hal: pointer to HAL 4016 * @auth_type: auth type 4017 * @encr_type: encryption type 4018 * @mc_encryption: multicast encryption type 4019 * @wapi_ie: pointer to WAPI IE 4020 * @ucast_cipher: Unicast cipher 4021 * @mcast_cipher: Multicast cipher 4022 * @auth_suite: Authentication suite 4023 * @negotiated_authtype: Negotiated auth type 4024 * @negotiated_mccipher: negotiated multicast cipher 4025 * 4026 * This routine will get all WAPI information 4027 * 4028 * Return: bool 4029 */ 4030 static bool csr_get_wapi_information(tHalHandle hal, tCsrAuthList *auth_type, 4031 eCsrEncryptionType encr_type, 4032 tCsrEncryptionList *mc_encryption, 4033 tDot11fIEWAPI *wapi_ie, 4034 uint8_t *ucast_cipher, 4035 uint8_t *mcast_cipher, uint8_t *auth_suite, 4036 eCsrAuthType *negotiated_authtype, 4037 eCsrEncryptionType *negotiated_mccipher) 4038 { 4039 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal); 4040 bool acceptable_cipher = false; 4041 uint8_t c_ucast_cipher = 0; 4042 uint8_t c_mcast_cipher = 0; 4043 uint8_t c_auth_suites = 0, i; 4044 uint8_t unicast[CSR_WAPI_OUI_SIZE]; 4045 uint8_t multicast[CSR_WAPI_OUI_SIZE]; 4046 uint8_t authsuites[CSR_WAPI_MAX_AUTH_SUITES][CSR_WAPI_OUI_SIZE]; 4047 uint8_t authentication[CSR_WAPI_OUI_SIZE]; 4048 uint8_t mccipher_arr[CSR_WAPI_MAX_MULTICAST_CYPHERS][CSR_WAPI_OUI_SIZE]; 4049 eCsrAuthType neg_authtype = eCSR_AUTH_TYPE_UNKNOWN; 4050 uint8_t wapioui_idx = 0; 4051 4052 if (!wapi_ie->present) 4053 goto end; 4054 4055 c_mcast_cipher++; 4056 qdf_mem_copy(mccipher_arr, wapi_ie->multicast_cipher_suite, 4057 CSR_WAPI_OUI_SIZE); 4058 c_ucast_cipher = (uint8_t) (wapi_ie->unicast_cipher_suite_count); 4059 c_auth_suites = (uint8_t) (wapi_ie->akm_suite_count); 4060 for (i = 0; i < c_auth_suites && i < CSR_WAPI_MAX_AUTH_SUITES; i++) 4061 qdf_mem_copy((void *)&authsuites[i], 4062 (void *)&wapi_ie->akm_suites[i], CSR_WAPI_OUI_SIZE); 4063 4064 wapioui_idx = csr_get_oui_index_from_cipher(encr_type); 4065 if (wapioui_idx >= CSR_OUI_WAPI_WAI_MAX_INDEX) { 4066 sme_err("Wapi OUI index = %d out of limit", 4067 wapioui_idx); 4068 acceptable_cipher = false; 4069 goto end; 4070 } 4071 /* Check - Is requested unicast Cipher supported by the BSS. */ 4072 acceptable_cipher = csr_match_wapi_oui_index(mac_ctx, 4073 wapi_ie->unicast_cipher_suites, 4074 c_ucast_cipher, wapioui_idx, unicast); 4075 if (!acceptable_cipher) 4076 goto end; 4077 4078 /* unicast is supported. Pick the first matching Group cipher, if any */ 4079 for (i = 0; i < mc_encryption->numEntries; i++) { 4080 wapioui_idx = csr_get_oui_index_from_cipher( 4081 mc_encryption->encryptionType[i]); 4082 if (wapioui_idx >= CSR_OUI_WAPI_WAI_MAX_INDEX) { 4083 sme_err("Wapi OUI index = %d out of limit", 4084 wapioui_idx); 4085 acceptable_cipher = false; 4086 break; 4087 } 4088 acceptable_cipher = csr_match_wapi_oui_index(mac_ctx, 4089 mccipher_arr, c_mcast_cipher, 4090 wapioui_idx, multicast); 4091 if (acceptable_cipher) 4092 break; 4093 } 4094 if (!acceptable_cipher) 4095 goto end; 4096 4097 if (negotiated_mccipher) 4098 *negotiated_mccipher = 4099 mc_encryption->encryptionType[i]; 4100 4101 /* 4102 * Ciphers are supported, Match authentication algorithm and 4103 * pick first matching authtype 4104 */ 4105 if (csr_is_auth_wapi_cert 4106 (mac_ctx, authsuites, c_auth_suites, authentication)) { 4107 neg_authtype = 4108 eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE; 4109 } else if (csr_is_auth_wapi_psk(mac_ctx, authsuites, 4110 c_auth_suites, authentication)) { 4111 neg_authtype = eCSR_AUTH_TYPE_WAPI_WAI_PSK; 4112 } else { 4113 acceptable_cipher = false; 4114 neg_authtype = eCSR_AUTH_TYPE_UNKNOWN; 4115 } 4116 4117 /* Caller doesn't care about auth type, or BSS doesn't match */ 4118 if ((0 == auth_type->numEntries) || (false == acceptable_cipher)) 4119 goto end; 4120 4121 acceptable_cipher = false; 4122 for (i = 0; i < auth_type->numEntries; i++) { 4123 if (auth_type->authType[i] == neg_authtype) { 4124 acceptable_cipher = true; 4125 break; 4126 } 4127 } 4128 4129 end: 4130 if (acceptable_cipher) { 4131 if (mcast_cipher) 4132 qdf_mem_copy(mcast_cipher, multicast, 4133 CSR_WAPI_OUI_SIZE); 4134 if (ucast_cipher) 4135 qdf_mem_copy(ucast_cipher, unicast, CSR_WAPI_OUI_SIZE); 4136 if (auth_suite) 4137 qdf_mem_copy(auth_suite, authentication, 4138 CSR_WAPI_OUI_SIZE); 4139 if (negotiated_authtype) 4140 *negotiated_authtype = neg_authtype; 4141 } 4142 return acceptable_cipher; 4143 } 4144 4145 static bool csr_is_wapi_match(tHalHandle hHal, tCsrAuthList *pAuthType, 4146 eCsrEncryptionType enType, 4147 tCsrEncryptionList *pEnMcType, 4148 tDot11fBeaconIEs *pIes, 4149 eCsrAuthType *pNegotiatedAuthType, 4150 eCsrEncryptionType *pNegotiatedMCCipher) 4151 { 4152 bool fWapiMatch = false; 4153 4154 /* See if the cyphers in the Bss description match with the 4155 * settings in the profile. 4156 */ 4157 fWapiMatch = 4158 csr_get_wapi_information(hHal, pAuthType, enType, pEnMcType, 4159 &pIes->WAPI, NULL, NULL, NULL, 4160 pNegotiatedAuthType, 4161 pNegotiatedMCCipher); 4162 4163 return fWapiMatch; 4164 } 4165 4166 static bool csr_lookup_bkid(tpAniSirGlobal pMac, uint32_t sessionId, 4167 uint8_t *pBSSId, uint8_t *pBKId) 4168 { 4169 bool fRC = false, fMatchFound = false; 4170 uint32_t Index; 4171 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId); 4172 4173 if (!pSession) { 4174 sme_err("session %d not found", sessionId); 4175 return false; 4176 } 4177 4178 do { 4179 for (Index = 0; Index < pSession->NumBkidCache; Index++) { 4180 sme_debug("match BKID " MAC_ADDRESS_STR " to ", 4181 MAC_ADDR_ARRAY(pBSSId)); 4182 if (!qdf_mem_cmp 4183 (pBSSId, pSession->BkidCacheInfo[Index].BSSID.bytes, 4184 sizeof(struct qdf_mac_addr))) { 4185 /* match found */ 4186 fMatchFound = true; 4187 break; 4188 } 4189 } 4190 4191 if (!fMatchFound) 4192 break; 4193 4194 qdf_mem_copy(pBKId, pSession->BkidCacheInfo[Index].BKID, 4195 CSR_WAPI_BKID_SIZE); 4196 4197 fRC = true; 4198 } while (0); 4199 sme_debug( 4200 "csr_lookup_bkid called return match = %d pMac->roam.NumBkidCache = %d", 4201 fRC, pSession->NumBkidCache); 4202 4203 return fRC; 4204 } 4205 4206 uint8_t csr_construct_wapi_ie(tpAniSirGlobal pMac, uint32_t sessionId, 4207 tCsrRoamProfile *pProfile, 4208 tSirBssDescription *pSirBssDesc, 4209 tDot11fBeaconIEs *pIes, tCsrWapiIe *pWapiIe) 4210 { 4211 bool fWapiMatch = false; 4212 uint8_t cbWapiIe = 0; 4213 uint8_t UnicastCypher[CSR_WAPI_OUI_SIZE]; 4214 uint8_t MulticastCypher[CSR_WAPI_OUI_SIZE]; 4215 uint8_t AuthSuite[CSR_WAPI_OUI_SIZE]; 4216 uint8_t BKId[CSR_WAPI_BKID_SIZE]; 4217 uint8_t *pWapi = NULL; 4218 bool fBKIDFound = false; 4219 tDot11fBeaconIEs *pIesLocal = pIes; 4220 4221 do { 4222 if (!csr_is_profile_wapi(pProfile)) 4223 break; 4224 4225 if (!pIesLocal 4226 && 4227 (!QDF_IS_STATUS_SUCCESS 4228 (csr_get_parsed_bss_description_ies 4229 (pMac, pSirBssDesc, &pIesLocal)))) { 4230 break; 4231 } 4232 /* See if the cyphers in the Bss description match with the 4233 * settings in the profile. 4234 */ 4235 fWapiMatch = 4236 csr_get_wapi_information(pMac, &pProfile->AuthType, 4237 pProfile->negotiatedUCEncryptionType, 4238 &pProfile->mcEncryptionType, 4239 &pIesLocal->WAPI, UnicastCypher, 4240 MulticastCypher, AuthSuite, NULL, 4241 NULL); 4242 if (!fWapiMatch) 4243 break; 4244 4245 qdf_mem_set(pWapiIe, sizeof(tCsrWapiIe), 0); 4246 4247 pWapiIe->IeHeader.ElementID = DOT11F_EID_WAPI; 4248 4249 pWapiIe->Version = CSR_WAPI_VERSION_SUPPORTED; 4250 4251 pWapiIe->cAuthenticationSuites = 1; 4252 qdf_mem_copy(&pWapiIe->AuthOui[0], AuthSuite, 4253 sizeof(AuthSuite)); 4254 4255 pWapi = (uint8_t *) (&pWapiIe->AuthOui[1]); 4256 4257 *pWapi = (uint16_t) 1; /* cUnicastCyphers */ 4258 pWapi += 2; 4259 qdf_mem_copy(pWapi, UnicastCypher, sizeof(UnicastCypher)); 4260 pWapi += sizeof(UnicastCypher); 4261 4262 qdf_mem_copy(pWapi, MulticastCypher, sizeof(MulticastCypher)); 4263 pWapi += sizeof(MulticastCypher); 4264 4265 /* WAPI capabilities follows the Auth Suite (two octects) 4266 * we shouldn't EVER be sending out "pre-auth supported". 4267 * It is an AP only capability & since we already did a memset 4268 * pWapiIe to 0, skip these fields 4269 */ 4270 pWapi += 2; 4271 4272 fBKIDFound = 4273 csr_lookup_bkid(pMac, sessionId, pSirBssDesc->bssId, 4274 &(BKId[0])); 4275 4276 if (fBKIDFound) { 4277 /* Do we need to change the endianness here */ 4278 *pWapi = (uint16_t) 1; /* cBKIDs */ 4279 pWapi += 2; 4280 qdf_mem_copy(pWapi, BKId, CSR_WAPI_BKID_SIZE); 4281 } else { 4282 *pWapi = 0; 4283 pWapi += 1; 4284 *pWapi = 0; 4285 pWapi += 1; 4286 } 4287 4288 /* Add in the IE fields except the IE header */ 4289 /* Add BKID count and BKID (if any) */ 4290 pWapiIe->IeHeader.Length = 4291 (uint8_t) (sizeof(*pWapiIe) - 4292 sizeof(pWapiIe->IeHeader)); 4293 4294 /*2 bytes for BKID Count field */ 4295 pWapiIe->IeHeader.Length += sizeof(uint16_t); 4296 4297 if (fBKIDFound) 4298 pWapiIe->IeHeader.Length += CSR_WAPI_BKID_SIZE; 4299 4300 /* return the size of the IE header (total) constructed... */ 4301 cbWapiIe = pWapiIe->IeHeader.Length + sizeof(pWapiIe->IeHeader); 4302 4303 } while (0); 4304 4305 if (!pIes && pIesLocal) 4306 /* locally allocated */ 4307 qdf_mem_free(pIesLocal); 4308 4309 return cbWapiIe; 4310 } 4311 #endif /* FEATURE_WLAN_WAPI */ 4312 4313 /** 4314 * csr_get_wpa_cyphers() - to get WPA cipher info 4315 * @mac_ctx: pointer to mac context 4316 * @auth_type: auth type 4317 * @encr_type: encryption type 4318 * @mc_encryption: multicast encryption type 4319 * @wpa_ie: pointer to WPA IE 4320 * @ucast_cipher: Unicast cipher 4321 * @mcast_cipher: Multicast cipher 4322 * @auth_suite: Authentication suite 4323 * @negotiated_authtype: Negotiated auth type 4324 * @negotiated_mccipher: negotiated multicast cipher 4325 * 4326 * This routine will get all WPA information 4327 * 4328 * Return: bool 4329 */ 4330 static bool csr_get_wpa_cyphers(tpAniSirGlobal mac_ctx, tCsrAuthList *auth_type, 4331 eCsrEncryptionType encr_type, 4332 tCsrEncryptionList *mc_encryption, 4333 tDot11fIEWPA *wpa_ie, uint8_t *ucast_cipher, 4334 uint8_t *mcast_cipher, uint8_t *auth_suite, 4335 eCsrAuthType *negotiated_authtype, 4336 eCsrEncryptionType *negotiated_mccipher) 4337 { 4338 bool acceptable_cipher = false; 4339 uint8_t c_ucast_cipher = 0; 4340 uint8_t c_mcast_cipher = 0; 4341 uint8_t c_auth_suites = 0; 4342 uint8_t unicast[CSR_WPA_OUI_SIZE]; 4343 uint8_t multicast[CSR_WPA_OUI_SIZE]; 4344 uint8_t authentication[CSR_WPA_OUI_SIZE]; 4345 uint8_t mccipher_arr[1][CSR_WPA_OUI_SIZE]; 4346 uint8_t i; 4347 uint8_t index; 4348 eCsrAuthType neg_authtype = eCSR_AUTH_TYPE_UNKNOWN; 4349 4350 if (!wpa_ie->present) 4351 goto end; 4352 c_mcast_cipher = 1; 4353 qdf_mem_copy(mccipher_arr, wpa_ie->multicast_cipher, CSR_WPA_OUI_SIZE); 4354 c_ucast_cipher = (uint8_t) (wpa_ie->unicast_cipher_count); 4355 c_auth_suites = (uint8_t) (wpa_ie->auth_suite_count); 4356 4357 /* 4358 * csr_match_wpaoui_index will provide the index of the 4359 * array csr_wpa_oui to be read and determine if it is 4360 * accepatable cipher or not. Below check ensures that 4361 * the index will not be out of range of the array size. 4362 */ 4363 index = csr_get_oui_index_from_cipher(encr_type); 4364 if (!(index < (sizeof(csr_wpa_oui)/CSR_WPA_OUI_SIZE))) { 4365 sme_debug("Unacceptable index: %d", index); 4366 goto end; 4367 } 4368 4369 sme_debug("kw_dbg: index: %d", index); 4370 /* Check - Is requested unicast Cipher supported by the BSS. */ 4371 acceptable_cipher = csr_match_wpaoui_index(mac_ctx, 4372 wpa_ie->unicast_ciphers, c_ucast_cipher, 4373 index, unicast); 4374 if (!acceptable_cipher) 4375 goto end; 4376 /* unicast is supported. Pick the first matching Group cipher, if any */ 4377 for (i = 0; i < mc_encryption->numEntries; i++) { 4378 index = csr_get_oui_index_from_cipher( 4379 mc_encryption->encryptionType[i]); 4380 sme_debug("kw_dbg: index: %d", index); 4381 if (!(index < (sizeof(csr_wpa_oui)/CSR_WPA_OUI_SIZE))) { 4382 sme_debug("Unacceptable MC index: %d", index); 4383 acceptable_cipher = false; 4384 continue; 4385 } 4386 acceptable_cipher = csr_match_wpaoui_index(mac_ctx, 4387 mccipher_arr, c_mcast_cipher, 4388 index, multicast); 4389 if (acceptable_cipher) 4390 break; 4391 } 4392 if (!acceptable_cipher) 4393 goto end; 4394 4395 if (negotiated_mccipher) 4396 *negotiated_mccipher = mc_encryption->encryptionType[i]; 4397 4398 /* Initializing with false as it has true value already */ 4399 acceptable_cipher = false; 4400 for (i = 0; i < auth_type->numEntries; i++) { 4401 /* 4402 * Ciphers are supported, Match authentication algorithm and 4403 * pick first matching authtype 4404 */ 4405 if (csr_is_auth_wpa(mac_ctx, wpa_ie->auth_suites, c_auth_suites, 4406 authentication)) { 4407 if (eCSR_AUTH_TYPE_WPA == auth_type->authType[i]) 4408 neg_authtype = eCSR_AUTH_TYPE_WPA; 4409 } 4410 if ((neg_authtype == eCSR_AUTH_TYPE_UNKNOWN) && 4411 csr_is_auth_wpa_psk(mac_ctx, 4412 wpa_ie->auth_suites, c_auth_suites, 4413 authentication)) { 4414 if (eCSR_AUTH_TYPE_WPA_PSK == auth_type->authType[i]) 4415 neg_authtype = eCSR_AUTH_TYPE_WPA_PSK; 4416 } 4417 #ifdef FEATURE_WLAN_ESE 4418 if ((neg_authtype == eCSR_AUTH_TYPE_UNKNOWN) 4419 && csr_is_ese_cckm_auth_wpa(mac_ctx, 4420 wpa_ie->auth_suites, c_auth_suites, 4421 authentication)) { 4422 if (eCSR_AUTH_TYPE_CCKM_WPA == auth_type->authType[i]) 4423 neg_authtype = eCSR_AUTH_TYPE_CCKM_WPA; 4424 } 4425 #endif /* FEATURE_WLAN_ESE */ 4426 4427 /* 4428 * The 1st auth type in the APs WPA IE, to match stations 4429 * connecting profiles auth type will cause us to exit this 4430 * loop. This is added as some APs advertise multiple akms in 4431 * the WPA IE 4432 */ 4433 if (eCSR_AUTH_TYPE_UNKNOWN != neg_authtype) { 4434 acceptable_cipher = true; 4435 break; 4436 } 4437 } 4438 4439 end: 4440 if (acceptable_cipher) { 4441 if (mcast_cipher) 4442 qdf_mem_copy((uint8_t **) mcast_cipher, multicast, 4443 CSR_WPA_OUI_SIZE); 4444 4445 if (ucast_cipher) 4446 qdf_mem_copy((uint8_t **) ucast_cipher, unicast, 4447 CSR_WPA_OUI_SIZE); 4448 4449 if (auth_suite) 4450 qdf_mem_copy((uint8_t **) auth_suite, authentication, 4451 CSR_WPA_OUI_SIZE); 4452 4453 if (negotiated_authtype) 4454 *negotiated_authtype = neg_authtype; 4455 } 4456 4457 return acceptable_cipher; 4458 } 4459 4460 static bool csr_is_wpa_encryption_match(tpAniSirGlobal pMac, 4461 tCsrAuthList *pAuthType, 4462 eCsrEncryptionType enType, 4463 tCsrEncryptionList *pEnMcType, 4464 tDot11fBeaconIEs *pIes, 4465 eCsrAuthType *pNegotiatedAuthtype, 4466 eCsrEncryptionType *pNegotiatedMCCipher) 4467 { 4468 bool fWpaMatch = false; 4469 4470 /* See if the cyphers in the Bss description match with the 4471 * settings in the profile. 4472 */ 4473 fWpaMatch = 4474 csr_get_wpa_cyphers(pMac, pAuthType, enType, pEnMcType, 4475 &pIes->WPA, 4476 NULL, NULL, NULL, pNegotiatedAuthtype, 4477 pNegotiatedMCCipher); 4478 4479 return fWpaMatch; 4480 } 4481 4482 uint8_t csr_construct_wpa_ie(tHalHandle hHal, tCsrRoamProfile *pProfile, 4483 tSirBssDescription *pSirBssDesc, 4484 tDot11fBeaconIEs *pIes, tCsrWpaIe *pWpaIe) 4485 { 4486 tpAniSirGlobal pMac = PMAC_STRUCT(hHal); 4487 bool fWpaMatch; 4488 uint8_t cbWpaIe = 0; 4489 uint8_t UnicastCypher[CSR_WPA_OUI_SIZE]; 4490 uint8_t MulticastCypher[CSR_WPA_OUI_SIZE]; 4491 uint8_t AuthSuite[CSR_WPA_OUI_SIZE]; 4492 tCsrWpaAuthIe *pAuthSuite; 4493 tDot11fBeaconIEs *pIesLocal = pIes; 4494 4495 do { 4496 if (!csr_is_profile_wpa(pProfile)) 4497 break; 4498 4499 if (!pIesLocal 4500 && 4501 (!QDF_IS_STATUS_SUCCESS 4502 (csr_get_parsed_bss_description_ies 4503 (pMac, pSirBssDesc, &pIesLocal)))) 4504 break; 4505 /* See if the cyphers in the Bss description match with the 4506 * settings in the profile. 4507 */ 4508 fWpaMatch = 4509 csr_get_wpa_cyphers(hHal, &pProfile->AuthType, 4510 pProfile->negotiatedUCEncryptionType, 4511 &pProfile->mcEncryptionType, 4512 &pIesLocal->WPA, UnicastCypher, 4513 MulticastCypher, AuthSuite, NULL, NULL); 4514 if (!fWpaMatch) 4515 break; 4516 4517 pWpaIe->IeHeader.ElementID = SIR_MAC_WPA_EID; 4518 4519 qdf_mem_copy(pWpaIe->Oui, csr_wpa_oui[01], sizeof(pWpaIe->Oui)); 4520 4521 pWpaIe->Version = CSR_WPA_VERSION_SUPPORTED; 4522 4523 qdf_mem_copy(pWpaIe->MulticastOui, MulticastCypher, 4524 sizeof(MulticastCypher)); 4525 4526 pWpaIe->cUnicastCyphers = 1; 4527 4528 qdf_mem_copy(&pWpaIe->UnicastOui[0], UnicastCypher, 4529 sizeof(UnicastCypher)); 4530 4531 pAuthSuite = 4532 (tCsrWpaAuthIe *) (&pWpaIe-> 4533 UnicastOui[pWpaIe->cUnicastCyphers]); 4534 4535 pAuthSuite->cAuthenticationSuites = 1; 4536 qdf_mem_copy(&pAuthSuite->AuthOui[0], AuthSuite, 4537 sizeof(AuthSuite)); 4538 4539 /* The WPA capabilities follows the Auth Suite (two octects)- 4540 * this field is optional, and we always "send" zero, so just 4541 * remove it. This is consistent with our assumptions in the 4542 * frames compiler; c.f. bug 15234: 4543 * http://gold.woodsidenet.com/bugzilla/show_bug.cgi?id=15234 4544 * Add in the fixed fields plus 1 Unicast cypher, less the IE 4545 * Header length Add in the size of the Auth suite (count plus 4546 * a single OUI) 4547 */ 4548 pWpaIe->IeHeader.Length = 4549 sizeof(*pWpaIe) - sizeof(pWpaIe->IeHeader) + 4550 sizeof(*pAuthSuite); 4551 4552 /* return the size of the IE header (total) constructed... */ 4553 cbWpaIe = pWpaIe->IeHeader.Length + sizeof(pWpaIe->IeHeader); 4554 4555 } while (0); 4556 4557 if (!pIes && pIesLocal) 4558 /* locally allocated */ 4559 qdf_mem_free(pIesLocal); 4560 4561 return cbWpaIe; 4562 } 4563 4564 /* If a WPAIE exists in the profile, just use it. Or else construct 4565 * one from the BSS Caller allocated memory for pWpaIe and guarrantee 4566 * it can contain a max length WPA IE 4567 */ 4568 uint8_t csr_retrieve_wpa_ie(tHalHandle hHal, tCsrRoamProfile *pProfile, 4569 tSirBssDescription *pSirBssDesc, 4570 tDot11fBeaconIEs *pIes, tCsrWpaIe *pWpaIe) 4571 { 4572 tpAniSirGlobal pMac = PMAC_STRUCT(hHal); 4573 uint8_t cbWpaIe = 0; 4574 4575 do { 4576 if (!csr_is_profile_wpa(pProfile)) 4577 break; 4578 if (pProfile->nWPAReqIELength && pProfile->pWPAReqIE) { 4579 if (pProfile->nWPAReqIELength <= 4580 DOT11F_IE_RSN_MAX_LEN) { 4581 cbWpaIe = (uint8_t) pProfile->nWPAReqIELength; 4582 qdf_mem_copy(pWpaIe, pProfile->pWPAReqIE, 4583 cbWpaIe); 4584 } else 4585 sme_warn("csr_retrieve_wpa_ie detect invalid WPA IE length (%d)", 4586 pProfile->nWPAReqIELength); 4587 } else 4588 cbWpaIe = csr_construct_wpa_ie(pMac, pProfile, 4589 pSirBssDesc, pIes, pWpaIe); 4590 } while (0); 4591 4592 return cbWpaIe; 4593 } 4594 4595 /* If a RSNIE exists in the profile, just use it. Or else construct 4596 * one from the BSS Caller allocated memory for pWpaIe and guarrantee 4597 * it can contain a max length WPA IE 4598 */ 4599 uint8_t csr_retrieve_rsn_ie(tHalHandle hHal, uint32_t sessionId, 4600 tCsrRoamProfile *pProfile, 4601 tSirBssDescription *pSirBssDesc, 4602 tDot11fBeaconIEs *pIes, tCsrRSNIe *pRsnIe) 4603 { 4604 tpAniSirGlobal pMac = PMAC_STRUCT(hHal); 4605 uint8_t cbRsnIe = 0; 4606 4607 do { 4608 if (!csr_is_profile_rsn(pProfile)) 4609 break; 4610 if (csr_roam_is_fast_roam_enabled(pMac, sessionId)) { 4611 /* If "Legacy Fast Roaming" is enabled ALWAYS rebuild 4612 * the RSN IE from scratch. So it contains the current 4613 * PMK-IDs 4614 */ 4615 cbRsnIe = 4616 csr_construct_rsn_ie(pMac, sessionId, pProfile, 4617 pSirBssDesc, pIes, pRsnIe); 4618 } else if (pProfile->nRSNReqIELength && pProfile->pRSNReqIE) { 4619 /* If you have one started away, re-use it. */ 4620 if (pProfile->nRSNReqIELength <= 4621 DOT11F_IE_RSN_MAX_LEN) { 4622 cbRsnIe = (uint8_t) pProfile->nRSNReqIELength; 4623 qdf_mem_copy(pRsnIe, pProfile->pRSNReqIE, 4624 cbRsnIe); 4625 } else 4626 sme_warn("csr_retrieve_rsn_ie detect invalid RSN IE length (%d)", 4627 pProfile->nRSNReqIELength); 4628 } else 4629 cbRsnIe = csr_construct_rsn_ie(pMac, sessionId, 4630 pProfile, 4631 pSirBssDesc, pIes, pRsnIe); 4632 } while (0); 4633 4634 return cbRsnIe; 4635 } 4636 4637 #ifdef FEATURE_WLAN_WAPI 4638 /* If a WAPI IE exists in the profile, just use it. Or else construct 4639 * one from the BSS Caller allocated memory for pWapiIe and guarrantee 4640 * it can contain a max length WAPI IE 4641 */ 4642 uint8_t csr_retrieve_wapi_ie(tHalHandle hHal, uint32_t sessionId, 4643 tCsrRoamProfile *pProfile, 4644 tSirBssDescription *pSirBssDesc, 4645 tDot11fBeaconIEs *pIes, tCsrWapiIe *pWapiIe) 4646 { 4647 tpAniSirGlobal pMac = PMAC_STRUCT(hHal); 4648 uint8_t cbWapiIe = 0; 4649 4650 do { 4651 if (!csr_is_profile_wapi(pProfile)) 4652 break; 4653 if (pProfile->nWAPIReqIELength && pProfile->pWAPIReqIE) { 4654 if (DOT11F_IE_WAPI_MAX_LEN >= 4655 pProfile->nWAPIReqIELength) { 4656 cbWapiIe = (uint8_t) pProfile->nWAPIReqIELength; 4657 qdf_mem_copy(pWapiIe, pProfile->pWAPIReqIE, 4658 cbWapiIe); 4659 } else 4660 sme_warn("csr_retrieve_wapi_ie detect invalid WAPI IE length (%d)", 4661 pProfile->nWAPIReqIELength); 4662 } else 4663 cbWapiIe = 4664 csr_construct_wapi_ie(pMac, sessionId, pProfile, 4665 pSirBssDesc, pIes, pWapiIe); 4666 } while (0); 4667 4668 return cbWapiIe; 4669 } 4670 #endif /* FEATURE_WLAN_WAPI */ 4671 4672 bool csr_rates_is_dot11_rate11b_supported_rate(uint8_t dot11Rate) 4673 { 4674 bool fSupported = false; 4675 uint16_t nonBasicRate = 4676 (uint16_t) (BITS_OFF(dot11Rate, CSR_DOT11_BASIC_RATE_MASK)); 4677 4678 switch (nonBasicRate) { 4679 case eCsrSuppRate_1Mbps: 4680 case eCsrSuppRate_2Mbps: 4681 case eCsrSuppRate_5_5Mbps: 4682 case eCsrSuppRate_11Mbps: 4683 fSupported = true; 4684 break; 4685 4686 default: 4687 break; 4688 } 4689 4690 return fSupported; 4691 } 4692 4693 bool csr_rates_is_dot11_rate11a_supported_rate(uint8_t dot11Rate) 4694 { 4695 bool fSupported = false; 4696 uint16_t nonBasicRate = 4697 (uint16_t) (BITS_OFF(dot11Rate, CSR_DOT11_BASIC_RATE_MASK)); 4698 4699 switch (nonBasicRate) { 4700 case eCsrSuppRate_6Mbps: 4701 case eCsrSuppRate_9Mbps: 4702 case eCsrSuppRate_12Mbps: 4703 case eCsrSuppRate_18Mbps: 4704 case eCsrSuppRate_24Mbps: 4705 case eCsrSuppRate_36Mbps: 4706 case eCsrSuppRate_48Mbps: 4707 case eCsrSuppRate_54Mbps: 4708 fSupported = true; 4709 break; 4710 4711 default: 4712 break; 4713 } 4714 4715 return fSupported; 4716 } 4717 4718 tAniEdType csr_translate_encrypt_type_to_ed_type(eCsrEncryptionType EncryptType) 4719 { 4720 tAniEdType edType; 4721 4722 switch (EncryptType) { 4723 default: 4724 case eCSR_ENCRYPT_TYPE_NONE: 4725 edType = eSIR_ED_NONE; 4726 break; 4727 4728 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY: 4729 case eCSR_ENCRYPT_TYPE_WEP40: 4730 edType = eSIR_ED_WEP40; 4731 break; 4732 4733 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY: 4734 case eCSR_ENCRYPT_TYPE_WEP104: 4735 edType = eSIR_ED_WEP104; 4736 break; 4737 4738 case eCSR_ENCRYPT_TYPE_TKIP: 4739 edType = eSIR_ED_TKIP; 4740 break; 4741 4742 case eCSR_ENCRYPT_TYPE_AES: 4743 edType = eSIR_ED_CCMP; 4744 break; 4745 #ifdef FEATURE_WLAN_WAPI 4746 case eCSR_ENCRYPT_TYPE_WPI: 4747 edType = eSIR_ED_WPI; 4748 break; 4749 #endif 4750 #ifdef WLAN_FEATURE_11W 4751 /* 11w BIP */ 4752 case eCSR_ENCRYPT_TYPE_AES_CMAC: 4753 edType = eSIR_ED_AES_128_CMAC; 4754 break; 4755 case eCSR_ENCRYPT_TYPE_AES_GCMP: 4756 edType = eSIR_ED_GCMP; 4757 break; 4758 case eCSR_ENCRYPT_TYPE_AES_GCMP_256: 4759 edType = eSIR_ED_GCMP_256; 4760 break; 4761 4762 #endif 4763 } 4764 4765 return edType; 4766 } 4767 4768 /** 4769 * csr_validate_wep() - to validate wep 4770 * @uc_encry_type: unicast encryption type 4771 * @auth_list: Auth list 4772 * @mc_encryption_list: multicast encryption type 4773 * @negotiated_authtype: negotiated auth type 4774 * @negotiated_mc_encry: negotiated mc encry type 4775 * @bss_descr: BSS description 4776 * @ie_ptr: IE pointer 4777 * 4778 * This function just checks whether HDD is giving correct values for 4779 * Multicast cipher and Auth 4780 * 4781 * Return: bool 4782 */ 4783 static bool csr_validate_wep(tpAniSirGlobal mac_ctx, 4784 eCsrEncryptionType uc_encry_type, 4785 tCsrAuthList *auth_list, 4786 tCsrEncryptionList *mc_encryption_list, 4787 eCsrAuthType *negotiated_authtype, 4788 eCsrEncryptionType *negotiated_mc_encry, 4789 tSirBssDescription *bss_descr, 4790 tDot11fBeaconIEs *ie_ptr) 4791 { 4792 uint32_t idx; 4793 bool match = false; 4794 eCsrAuthType negotiated_auth = eCSR_AUTH_TYPE_OPEN_SYSTEM; 4795 eCsrEncryptionType negotiated_mccipher = eCSR_ENCRYPT_TYPE_UNKNOWN; 4796 uint8_t oui_index; 4797 4798 /* If privacy bit is not set, consider no match */ 4799 if (!csr_is_privacy(bss_descr)) 4800 goto end; 4801 4802 for (idx = 0; idx < mc_encryption_list->numEntries; idx++) { 4803 switch (mc_encryption_list->encryptionType[idx]) { 4804 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY: 4805 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY: 4806 case eCSR_ENCRYPT_TYPE_WEP40: 4807 case eCSR_ENCRYPT_TYPE_WEP104: 4808 /* 4809 * Multicast list may contain WEP40/WEP104. 4810 * Check whether it matches UC. 4811 */ 4812 if (uc_encry_type == 4813 mc_encryption_list->encryptionType[idx]) { 4814 match = true; 4815 negotiated_mccipher = 4816 mc_encryption_list->encryptionType[idx]; 4817 } 4818 break; 4819 default: 4820 match = false; 4821 break; 4822 } 4823 if (match) 4824 break; 4825 } 4826 4827 if (!match) 4828 goto end; 4829 4830 for (idx = 0; idx < auth_list->numEntries; idx++) { 4831 switch (auth_list->authType[idx]) { 4832 case eCSR_AUTH_TYPE_OPEN_SYSTEM: 4833 case eCSR_AUTH_TYPE_SHARED_KEY: 4834 case eCSR_AUTH_TYPE_AUTOSWITCH: 4835 match = true; 4836 negotiated_auth = auth_list->authType[idx]; 4837 break; 4838 default: 4839 match = false; 4840 } 4841 if (match) 4842 break; 4843 } 4844 4845 if (!match) 4846 goto end; 4847 4848 if (!ie_ptr) 4849 goto end; 4850 4851 /* 4852 * In case of WPA / WPA2, check whether it supports WEP as well. 4853 * Prepare the encryption type for WPA/WPA2 functions 4854 */ 4855 if (eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == uc_encry_type) 4856 uc_encry_type = eCSR_ENCRYPT_TYPE_WEP40; 4857 else if (eCSR_ENCRYPT_TYPE_WEP104 == uc_encry_type) 4858 uc_encry_type = eCSR_ENCRYPT_TYPE_WEP104; 4859 4860 /* else we can use the encryption type directly */ 4861 if (ie_ptr->WPA.present) { 4862 oui_index = csr_get_oui_index_from_cipher(uc_encry_type); 4863 if (oui_index < QDF_ARRAY_SIZE(csr_wpa_oui)) 4864 match = (!qdf_mem_cmp(ie_ptr->WPA.multicast_cipher, 4865 csr_wpa_oui[oui_index], 4866 CSR_WPA_OUI_SIZE)); 4867 if (match) 4868 goto end; 4869 } 4870 if (ie_ptr->RSN.present) { 4871 match = (!qdf_mem_cmp(ie_ptr->RSN.gp_cipher_suite, 4872 csr_rsn_oui[csr_get_oui_index_from_cipher( 4873 uc_encry_type)], 4874 CSR_RSN_OUI_SIZE)); 4875 } 4876 4877 4878 end: 4879 if (match) { 4880 if (negotiated_authtype) 4881 *negotiated_authtype = negotiated_auth; 4882 if (negotiated_mc_encry) 4883 *negotiated_mc_encry = negotiated_mccipher; 4884 } 4885 return match; 4886 } 4887 4888 /** 4889 * csr_validate_open_none() - Check if the security is matching 4890 * @bss_desc: BSS Descriptor on which the check is done 4891 * @mc_enc_type: Multicast encryption type 4892 * @mc_cipher: Multicast Cipher 4893 * @auth_type: Authentication type 4894 * @neg_auth_type: Negotiated Auth type with the AP 4895 * 4896 * Return: Boolean value to tell if matched or not. 4897 */ 4898 static bool csr_validate_open_none(tSirBssDescription *bss_desc, 4899 tCsrEncryptionList *mc_enc_type, eCsrEncryptionType *mc_cipher, 4900 tCsrAuthList *auth_type, eCsrAuthType *neg_auth_type) 4901 { 4902 bool match; 4903 uint8_t idx; 4904 4905 /* 4906 * for NO encryption, if the Bss description has the 4907 * Privacy bit turned on, then encryption is required 4908 * so we have to reject this Bss. 4909 */ 4910 if (csr_is_privacy(bss_desc)) 4911 match = false; 4912 else 4913 match = true; 4914 if (match) { 4915 match = false; 4916 /* Check MC cipher and Auth type requested. */ 4917 for (idx = 0; idx < mc_enc_type->numEntries; idx++) { 4918 if (eCSR_ENCRYPT_TYPE_NONE == 4919 mc_enc_type->encryptionType[idx]) { 4920 match = true; 4921 *mc_cipher = mc_enc_type->encryptionType[idx]; 4922 break; 4923 } 4924 } 4925 if (!match) 4926 return match; 4927 4928 match = false; 4929 /* Check Auth list. It should contain AuthOpen. */ 4930 for (idx = 0; idx < auth_type->numEntries; idx++) { 4931 if ((eCSR_AUTH_TYPE_OPEN_SYSTEM == 4932 auth_type->authType[idx]) || 4933 (eCSR_AUTH_TYPE_AUTOSWITCH == 4934 auth_type->authType[idx])) { 4935 match = true; 4936 *neg_auth_type = 4937 eCSR_AUTH_TYPE_OPEN_SYSTEM; 4938 break; 4939 } 4940 } 4941 if (!match) 4942 return match; 4943 4944 } 4945 return match; 4946 } 4947 4948 /** 4949 * csr_validate_any_default() - Check if the security is matching 4950 * @hal: Global HAL handle 4951 * @auth_type: Authentication type 4952 * @mc_enc_type: Multicast encryption type 4953 * @mfp_enabled: Management frame protection feature 4954 * @mfp_required: Mangement frame protection mandatory 4955 * @mfp_capable: Device capable of MFP 4956 * @ies_ptr: Pointer to the IE fields 4957 * @neg_auth_type: Negotiated Auth type with the AP 4958 * @bss_desc: BSS Descriptor 4959 * @neg_uc_cipher: Negotiated unicast cipher suite 4960 * @neg_mc_cipher: Negotiated multicast cipher 4961 * 4962 * Return: Boolean value to tell if matched or not. 4963 */ 4964 static bool csr_validate_any_default(tHalHandle hal, tCsrAuthList *auth_type, 4965 tCsrEncryptionList *mc_enc_type, bool *mfp_enabled, 4966 uint8_t *mfp_required, uint8_t *mfp_capable, 4967 tDot11fBeaconIEs *ies_ptr, eCsrAuthType *neg_auth_type, 4968 tSirBssDescription *bss_desc, eCsrEncryptionType *uc_cipher, 4969 eCsrEncryptionType *mc_cipher) 4970 { 4971 bool match_any = false; 4972 bool match = true; 4973 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal); 4974 /* It is allowed to match anything. Try the more secured ones first. */ 4975 if (ies_ptr) { 4976 /* Check GCMP-256 first */ 4977 *uc_cipher = eCSR_ENCRYPT_TYPE_AES_GCMP_256; 4978 match_any = csr_is_rsn_match(hal, auth_type, 4979 *uc_cipher, mc_enc_type, mfp_enabled, 4980 mfp_required, mfp_capable, ies_ptr, 4981 neg_auth_type, mc_cipher); 4982 /* Check GCMP second */ 4983 *uc_cipher = eCSR_ENCRYPT_TYPE_AES_GCMP; 4984 match_any = csr_is_rsn_match(hal, auth_type, 4985 *uc_cipher, mc_enc_type, mfp_enabled, 4986 mfp_required, mfp_capable, ies_ptr, 4987 neg_auth_type, mc_cipher); 4988 /* Check AES third */ 4989 *uc_cipher = eCSR_ENCRYPT_TYPE_AES; 4990 match_any = csr_is_rsn_match(hal, auth_type, 4991 *uc_cipher, mc_enc_type, mfp_enabled, 4992 mfp_required, mfp_capable, ies_ptr, 4993 neg_auth_type, mc_cipher); 4994 if (!match_any) { 4995 /* Check TKIP */ 4996 *uc_cipher = eCSR_ENCRYPT_TYPE_TKIP; 4997 match_any = csr_is_rsn_match(hal, auth_type, *uc_cipher, 4998 mc_enc_type, mfp_enabled, mfp_required, 4999 mfp_capable, ies_ptr, neg_auth_type, 5000 mc_cipher); 5001 } 5002 #ifdef FEATURE_WLAN_WAPI 5003 if (!match_any) { 5004 /* Check WAPI */ 5005 *uc_cipher = eCSR_ENCRYPT_TYPE_WPI; 5006 match_any = csr_is_wapi_match(hal, auth_type, 5007 *uc_cipher, mc_enc_type, ies_ptr, 5008 neg_auth_type, mc_cipher); 5009 } 5010 #endif 5011 } 5012 if (match_any) 5013 return match; 5014 *uc_cipher = eCSR_ENCRYPT_TYPE_WEP104; 5015 if (csr_validate_wep(mac_ctx, *uc_cipher, auth_type, mc_enc_type, 5016 neg_auth_type, mc_cipher, bss_desc, ies_ptr)) 5017 return match; 5018 *uc_cipher = eCSR_ENCRYPT_TYPE_WEP40; 5019 if (csr_validate_wep(mac_ctx, *uc_cipher, auth_type, mc_enc_type, 5020 neg_auth_type, mc_cipher, bss_desc, ies_ptr)) 5021 return match; 5022 *uc_cipher = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY; 5023 if (csr_validate_wep(mac_ctx, *uc_cipher, auth_type, mc_enc_type, 5024 neg_auth_type, mc_cipher, bss_desc, ies_ptr)) 5025 return match; 5026 *uc_cipher = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; 5027 if (csr_validate_wep(mac_ctx, *uc_cipher, auth_type, mc_enc_type, 5028 neg_auth_type, mc_cipher, bss_desc, ies_ptr)) 5029 return match; 5030 /* It must be open and no enc */ 5031 if (csr_is_privacy(bss_desc)) { 5032 match = false; 5033 return match; 5034 } 5035 5036 *neg_auth_type = eCSR_AUTH_TYPE_OPEN_SYSTEM; 5037 *mc_cipher = eCSR_ENCRYPT_TYPE_NONE; 5038 *uc_cipher = eCSR_ENCRYPT_TYPE_NONE; 5039 return match; 5040 5041 } 5042 5043 /** 5044 * csr_is_security_match() - Check if the security is matching 5045 * @hal: Global HAL handle 5046 * @auth_type: Authentication type 5047 * @uc_enc_type: Unicast Encryption type 5048 * @mc_enc_type: Multicast encryption type 5049 * @mfp_enabled: Management frame protection feature 5050 * @mfp_required: Mangement frame protection mandatory 5051 * @mfp_capable: Device capable of MFP 5052 * @bss_desc: BSS Descriptor 5053 * @ies_ptr: Pointer to the IE fields 5054 * @neg_auth_type: Negotiated Auth type with the AP 5055 * @neg_uc_cipher: Negotiated unicast cipher suite 5056 * @neg_mc_cipher: Negotiated multicast cipher 5057 * 5058 * Return: Boolean value to tell if matched or not. 5059 */ 5060 bool csr_is_security_match(tHalHandle hal, tCsrAuthList *auth_type, 5061 tCsrEncryptionList *uc_enc_type, 5062 tCsrEncryptionList *mc_enc_type, bool *mfp_enabled, 5063 uint8_t *mfp_required, uint8_t *mfp_capable, 5064 tSirBssDescription *bss_desc, tDot11fBeaconIEs *ies_ptr, 5065 eCsrAuthType *neg_auth_type, 5066 eCsrEncryptionType *neg_uc_cipher, 5067 eCsrEncryptionType *neg_mc_cipher) 5068 { 5069 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal); 5070 bool match = false; 5071 uint8_t i; 5072 eCsrEncryptionType mc_cipher = eCSR_ENCRYPT_TYPE_UNKNOWN; 5073 eCsrEncryptionType uc_cipher = eCSR_ENCRYPT_TYPE_UNKNOWN; 5074 eCsrAuthType local_neg_auth_type = eCSR_AUTH_TYPE_UNKNOWN; 5075 5076 for (i = 0; ((i < uc_enc_type->numEntries) && (!match)); i++) { 5077 uc_cipher = uc_enc_type->encryptionType[i]; 5078 /* 5079 * If the Bss description shows the Privacy bit is on, then we 5080 * must have some sort of encryption configured for the profile 5081 * to work. Don't attempt to join networks with Privacy bit 5082 * set when profiles say NONE for encryption type. 5083 */ 5084 switch (uc_cipher) { 5085 case eCSR_ENCRYPT_TYPE_NONE: 5086 match = csr_validate_open_none(bss_desc, mc_enc_type, 5087 &mc_cipher, auth_type, 5088 &local_neg_auth_type); 5089 break; 5090 5091 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY: 5092 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY: 5093 /* 5094 * !! might want to check for WEP keys set in the 5095 * Profile.... ? !! don't need to have the privacy bit 5096 * in the Bss description. Many AP policies make 5097 * legacy encryption 'optional' so we don't know if we 5098 * can associate or not. The AP will reject if 5099 * encryption is not allowed without the Privacy bit 5100 * turned on. 5101 */ 5102 match = csr_validate_wep(mac_ctx, uc_cipher, auth_type, 5103 mc_enc_type, &local_neg_auth_type, 5104 &mc_cipher, bss_desc, ies_ptr); 5105 5106 break; 5107 /* these are all of the WPA encryption types... */ 5108 case eCSR_ENCRYPT_TYPE_WEP40: 5109 case eCSR_ENCRYPT_TYPE_WEP104: 5110 match = csr_validate_wep(mac_ctx, uc_cipher, auth_type, 5111 mc_enc_type, &local_neg_auth_type, 5112 &mc_cipher, bss_desc, ies_ptr); 5113 break; 5114 5115 case eCSR_ENCRYPT_TYPE_TKIP: 5116 case eCSR_ENCRYPT_TYPE_AES: 5117 case eCSR_ENCRYPT_TYPE_AES_GCMP: 5118 case eCSR_ENCRYPT_TYPE_AES_GCMP_256: 5119 if (!ies_ptr) { 5120 match = false; 5121 break; 5122 } 5123 /* First check if there is a RSN match */ 5124 match = csr_is_rsn_match(mac_ctx, auth_type, 5125 uc_cipher, mc_enc_type, 5126 mfp_enabled, mfp_required, 5127 mfp_capable, ies_ptr, 5128 &local_neg_auth_type, 5129 &mc_cipher); 5130 /* If not RSN, then check WPA match */ 5131 if (!match) 5132 match = csr_is_wpa_encryption_match( 5133 mac_ctx, auth_type, 5134 uc_cipher, mc_enc_type, 5135 ies_ptr, 5136 &local_neg_auth_type, 5137 &mc_cipher); 5138 break; 5139 #ifdef FEATURE_WLAN_WAPI 5140 case eCSR_ENCRYPT_TYPE_WPI: /* WAPI */ 5141 if (ies_ptr) 5142 match = csr_is_wapi_match(hal, auth_type, 5143 uc_cipher, mc_enc_type, ies_ptr, 5144 &local_neg_auth_type, 5145 &mc_cipher); 5146 else 5147 match = false; 5148 break; 5149 #endif /* FEATURE_WLAN_WAPI */ 5150 case eCSR_ENCRYPT_TYPE_ANY: 5151 default: 5152 match = csr_validate_any_default(hal, auth_type, 5153 mc_enc_type, mfp_enabled, mfp_required, 5154 mfp_capable, ies_ptr, 5155 &local_neg_auth_type, bss_desc, 5156 &uc_cipher, &mc_cipher); 5157 break; 5158 } 5159 5160 } 5161 5162 if (match) { 5163 if (neg_uc_cipher) 5164 *neg_uc_cipher = uc_cipher; 5165 if (neg_mc_cipher) 5166 *neg_mc_cipher = mc_cipher; 5167 if (neg_auth_type) 5168 *neg_auth_type = local_neg_auth_type; 5169 } 5170 return match; 5171 } 5172 5173 bool csr_is_ssid_match(tpAniSirGlobal pMac, uint8_t *ssid1, uint8_t ssid1Len, 5174 uint8_t *bssSsid, uint8_t bssSsidLen, bool fSsidRequired) 5175 { 5176 bool fMatch = false; 5177 5178 do { 5179 /* 5180 * Check for the specification of the Broadcast SSID at the 5181 * beginning of the list. If specified, then all SSIDs are 5182 * matches (broadcast SSID means accept all SSIDs). 5183 */ 5184 if (ssid1Len == 0) { 5185 fMatch = true; 5186 break; 5187 } 5188 5189 /* There are a few special cases. If the Bss description has 5190 * a Broadcast SSID, then our Profile must have a single SSID 5191 * without Wildcards so we can program the SSID. 5192 * 5193 * SSID could be suppressed in beacons. In that case SSID IE 5194 * has valid length but the SSID value is all NULL characters. 5195 * That condition is trated same as NULL SSID 5196 */ 5197 if (csr_is_nullssid(bssSsid, bssSsidLen)) { 5198 if (false == fSsidRequired) { 5199 fMatch = true; 5200 break; 5201 } 5202 } 5203 5204 if (ssid1Len != bssSsidLen) 5205 break; 5206 if (!qdf_mem_cmp(bssSsid, ssid1, bssSsidLen)) { 5207 fMatch = true; 5208 break; 5209 } 5210 5211 } while (0); 5212 5213 return fMatch; 5214 } 5215 5216 /* Null ssid means match */ 5217 bool csr_is_ssid_in_list(tHalHandle hHal, tSirMacSSid *pSsid, 5218 tCsrSSIDs *pSsidList) 5219 { 5220 bool fMatch = false; 5221 uint32_t i; 5222 5223 if (pSsidList && pSsid) { 5224 for (i = 0; i < pSsidList->numOfSSIDs; i++) { 5225 if (csr_is_nullssid 5226 (pSsidList->SSIDList[i].SSID.ssId, 5227 pSsidList->SSIDList[i].SSID.length) 5228 || 5229 ((pSsidList->SSIDList[i].SSID.length == 5230 pSsid->length) 5231 && (!qdf_mem_cmp(pSsid->ssId, 5232 pSsidList->SSIDList[i].SSID. 5233 ssId, pSsid->length)))) { 5234 fMatch = true; 5235 break; 5236 } 5237 } 5238 } 5239 5240 return fMatch; 5241 } 5242 5243 bool csr_is_bssid_match(tHalHandle hHal, struct qdf_mac_addr *pProfBssid, 5244 struct qdf_mac_addr *BssBssid) 5245 { 5246 bool fMatch = false; 5247 struct qdf_mac_addr ProfileBssid; 5248 5249 /* for efficiency of the MAC_ADDRESS functions, move the */ 5250 /* Bssid's into MAC_ADDRESS structs. */ 5251 qdf_mem_copy(&ProfileBssid, pProfBssid, sizeof(struct qdf_mac_addr)); 5252 5253 do { 5254 /* Give the profile the benefit of the doubt... accept 5255 * either all 0 or the real broadcast Bssid (all 0xff) 5256 * as broadcast Bssids (meaning to match any Bssids). 5257 */ 5258 if (qdf_is_macaddr_zero(&ProfileBssid) || 5259 qdf_is_macaddr_broadcast(&ProfileBssid)) { 5260 fMatch = true; 5261 break; 5262 } 5263 5264 if (qdf_is_macaddr_equal(BssBssid, &ProfileBssid)) { 5265 fMatch = true; 5266 break; 5267 } 5268 5269 } while (0); 5270 5271 return fMatch; 5272 } 5273 5274 bool csr_is_bss_type_match(eCsrRoamBssType bssType1, eCsrRoamBssType bssType2) 5275 { 5276 if ((eCSR_BSS_TYPE_ANY != bssType1 && eCSR_BSS_TYPE_ANY != bssType2) 5277 && (bssType1 != bssType2)) 5278 return false; 5279 else 5280 return true; 5281 } 5282 5283 bool csr_is_bss_type_ibss(eCsrRoamBssType bssType) 5284 { 5285 return (bool) 5286 (eCSR_BSS_TYPE_START_IBSS == bssType 5287 || eCSR_BSS_TYPE_IBSS == bssType); 5288 } 5289 5290 5291 static bool csr_is_bss_type_caps_match(eCsrRoamBssType bssType, 5292 tSirBssDescription *pSirBssDesc) 5293 { 5294 bool fMatch = true; 5295 5296 do { 5297 switch (bssType) { 5298 case eCSR_BSS_TYPE_ANY: 5299 break; 5300 5301 case eCSR_BSS_TYPE_INFRASTRUCTURE: 5302 if (!csr_is_infra_bss_desc(pSirBssDesc)) 5303 fMatch = false; 5304 break; 5305 5306 case eCSR_BSS_TYPE_IBSS: 5307 case eCSR_BSS_TYPE_START_IBSS: 5308 if (!csr_is_ibss_bss_desc(pSirBssDesc)) 5309 fMatch = false; 5310 5311 break; 5312 default: 5313 fMatch = false; 5314 break; 5315 } 5316 } while (0); 5317 5318 return fMatch; 5319 } 5320 5321 static bool csr_is_capabilities_match(tpAniSirGlobal pMac, eCsrRoamBssType 5322 bssType, tSirBssDescription *pSirBssDesc) 5323 { 5324 return csr_is_bss_type_caps_match(bssType, pSirBssDesc); 5325 } 5326 5327 static bool csr_is_specific_channel_match(tpAniSirGlobal pMac, 5328 tSirBssDescription *pSirBssDesc, 5329 uint8_t Channel) 5330 { 5331 bool fMatch = true; 5332 5333 do { 5334 /* if the channel is ANY, then always match... */ 5335 if (eCSR_OPERATING_CHANNEL_ANY == Channel) 5336 break; 5337 if (Channel == pSirBssDesc->channelId) 5338 break; 5339 5340 /* didn't match anything.. so return NO match */ 5341 fMatch = false; 5342 5343 } while (0); 5344 5345 return fMatch; 5346 } 5347 5348 static bool csr_is_channel_band_match(tpAniSirGlobal pMac, uint8_t channelId, 5349 tSirBssDescription *pSirBssDesc) 5350 { 5351 bool fMatch = true; 5352 5353 do { 5354 /* If the profile says Any channel AND the global settings 5355 * says ANY channel, then we always match. 5356 */ 5357 if (eCSR_OPERATING_CHANNEL_ANY == channelId) 5358 break; 5359 5360 if (eCSR_OPERATING_CHANNEL_ANY != channelId) { 5361 fMatch = 5362 csr_is_specific_channel_match(pMac, pSirBssDesc, 5363 channelId); 5364 } 5365 5366 } while (0); 5367 5368 return fMatch; 5369 } 5370 5371 /** 5372 * csr_is_aggregate_rate_supported() - to check if aggregate rate is supported 5373 * @mac_ctx: pointer to mac context 5374 * @rate: A rate in units of 500kbps 5375 * 5376 * 5377 * The rate encoding is just as in 802.11 Information Elements, except 5378 * that the high bit is \em not interpreted as indicating a Basic Rate, 5379 * and proprietary rates are allowed, too. 5380 * 5381 * Note that if the adapter's dot11Mode is g, we don't restrict the 5382 * rates. According to hwReadEepromParameters, this will happen when: 5383 * ... the card is configured for ALL bands through the property 5384 * page. If this occurs, and the card is not an ABG card ,then this 5385 * code is setting the dot11Mode to assume the mode that the 5386 * hardware can support. For example, if the card is an 11BG card 5387 * and we are configured to support ALL bands, then we change the 5388 * dot11Mode to 11g because ALL in this case is only what the 5389 * hardware can support. 5390 * 5391 * Return: true if the adapter is currently capable of supporting this rate 5392 */ 5393 5394 static bool csr_is_aggregate_rate_supported(tpAniSirGlobal mac_ctx, 5395 uint16_t rate) 5396 { 5397 bool supported = false; 5398 uint16_t idx, new_rate; 5399 5400 /* In case basic rate flag is set */ 5401 new_rate = BITS_OFF(rate, CSR_DOT11_BASIC_RATE_MASK); 5402 if (eCSR_CFG_DOT11_MODE_11A == 5403 mac_ctx->roam.configParam.uCfgDot11Mode) { 5404 switch (new_rate) { 5405 case eCsrSuppRate_6Mbps: 5406 case eCsrSuppRate_9Mbps: 5407 case eCsrSuppRate_12Mbps: 5408 case eCsrSuppRate_18Mbps: 5409 case eCsrSuppRate_24Mbps: 5410 case eCsrSuppRate_36Mbps: 5411 case eCsrSuppRate_48Mbps: 5412 case eCsrSuppRate_54Mbps: 5413 supported = true; 5414 break; 5415 default: 5416 supported = false; 5417 break; 5418 } 5419 5420 } else if (eCSR_CFG_DOT11_MODE_11B == 5421 mac_ctx->roam.configParam.uCfgDot11Mode) { 5422 switch (new_rate) { 5423 case eCsrSuppRate_1Mbps: 5424 case eCsrSuppRate_2Mbps: 5425 case eCsrSuppRate_5_5Mbps: 5426 case eCsrSuppRate_11Mbps: 5427 supported = true; 5428 break; 5429 default: 5430 supported = false; 5431 break; 5432 } 5433 } else if (!mac_ctx->roam.configParam.ProprietaryRatesEnabled) { 5434 5435 switch (new_rate) { 5436 case eCsrSuppRate_1Mbps: 5437 case eCsrSuppRate_2Mbps: 5438 case eCsrSuppRate_5_5Mbps: 5439 case eCsrSuppRate_6Mbps: 5440 case eCsrSuppRate_9Mbps: 5441 case eCsrSuppRate_11Mbps: 5442 case eCsrSuppRate_12Mbps: 5443 case eCsrSuppRate_18Mbps: 5444 case eCsrSuppRate_24Mbps: 5445 case eCsrSuppRate_36Mbps: 5446 case eCsrSuppRate_48Mbps: 5447 case eCsrSuppRate_54Mbps: 5448 supported = true; 5449 break; 5450 default: 5451 supported = false; 5452 break; 5453 } 5454 } else if (eCsrSuppRate_1Mbps == new_rate || 5455 eCsrSuppRate_2Mbps == new_rate || 5456 eCsrSuppRate_5_5Mbps == new_rate || 5457 eCsrSuppRate_11Mbps == new_rate) 5458 supported = true; 5459 else { 5460 idx = 0x1; 5461 5462 switch (new_rate) { 5463 case eCsrSuppRate_6Mbps: 5464 supported = g_phy_rates_suppt[0][idx]; 5465 break; 5466 case eCsrSuppRate_9Mbps: 5467 supported = g_phy_rates_suppt[1][idx]; 5468 break; 5469 case eCsrSuppRate_12Mbps: 5470 supported = g_phy_rates_suppt[2][idx]; 5471 break; 5472 case eCsrSuppRate_18Mbps: 5473 supported = g_phy_rates_suppt[3][idx]; 5474 break; 5475 case eCsrSuppRate_20Mbps: 5476 supported = g_phy_rates_suppt[4][idx]; 5477 break; 5478 case eCsrSuppRate_24Mbps: 5479 supported = g_phy_rates_suppt[5][idx]; 5480 break; 5481 case eCsrSuppRate_36Mbps: 5482 supported = g_phy_rates_suppt[6][idx]; 5483 break; 5484 case eCsrSuppRate_40Mbps: 5485 supported = g_phy_rates_suppt[7][idx]; 5486 break; 5487 case eCsrSuppRate_42Mbps: 5488 supported = g_phy_rates_suppt[8][idx]; 5489 break; 5490 case eCsrSuppRate_48Mbps: 5491 supported = g_phy_rates_suppt[9][idx]; 5492 break; 5493 case eCsrSuppRate_54Mbps: 5494 supported = g_phy_rates_suppt[10][idx]; 5495 break; 5496 case eCsrSuppRate_72Mbps: 5497 supported = g_phy_rates_suppt[11][idx]; 5498 break; 5499 case eCsrSuppRate_80Mbps: 5500 supported = g_phy_rates_suppt[12][idx]; 5501 break; 5502 case eCsrSuppRate_84Mbps: 5503 supported = g_phy_rates_suppt[13][idx]; 5504 break; 5505 case eCsrSuppRate_96Mbps: 5506 supported = g_phy_rates_suppt[14][idx]; 5507 break; 5508 case eCsrSuppRate_108Mbps: 5509 supported = g_phy_rates_suppt[15][idx]; 5510 break; 5511 case eCsrSuppRate_120Mbps: 5512 supported = g_phy_rates_suppt[16][idx]; 5513 break; 5514 case eCsrSuppRate_126Mbps: 5515 supported = g_phy_rates_suppt[17][idx]; 5516 break; 5517 case eCsrSuppRate_144Mbps: 5518 supported = g_phy_rates_suppt[18][idx]; 5519 break; 5520 case eCsrSuppRate_160Mbps: 5521 supported = g_phy_rates_suppt[19][idx]; 5522 break; 5523 case eCsrSuppRate_168Mbps: 5524 supported = g_phy_rates_suppt[20][idx]; 5525 break; 5526 case eCsrSuppRate_192Mbps: 5527 supported = g_phy_rates_suppt[21][idx]; 5528 break; 5529 case eCsrSuppRate_216Mbps: 5530 supported = g_phy_rates_suppt[22][idx]; 5531 break; 5532 case eCsrSuppRate_240Mbps: 5533 supported = g_phy_rates_suppt[23][idx]; 5534 break; 5535 default: 5536 supported = false; 5537 break; 5538 } 5539 } 5540 return supported; 5541 } 5542 5543 /** 5544 * csr_is_rate_set_match() - to check if rate set is matching 5545 * @mac_ctx: pointer to mac context 5546 * @bss_supported_rates: supported rates of BSS 5547 * @bss_ext_supp_rates: extended rates of bss 5548 * 5549 * This routine is to checke if rate set is matched or no 5550 * 5551 * Return: bool 5552 */ 5553 static bool csr_is_rate_set_match(tpAniSirGlobal mac_ctx, 5554 tDot11fIESuppRates *bss_supported_rates, 5555 tDot11fIEExtSuppRates *bss_ext_supp_rates) 5556 { 5557 bool match = true; 5558 uint32_t i; 5559 5560 /* 5561 * Validate that all of the Basic rates advertised in the Bss 5562 * description are supported 5563 */ 5564 if (bss_supported_rates) { 5565 for (i = 0; i < bss_supported_rates->num_rates; i++) { 5566 if (!CSR_IS_BASIC_RATE(bss_supported_rates->rates[i])) 5567 continue; 5568 if (!csr_is_aggregate_rate_supported(mac_ctx, 5569 bss_supported_rates->rates[i])) { 5570 match = false; 5571 break; 5572 } 5573 } 5574 } 5575 if (match && bss_ext_supp_rates) { 5576 for (i = 0; i < bss_ext_supp_rates->num_rates; i++) { 5577 if (!CSR_IS_BASIC_RATE(bss_ext_supp_rates->rates[i])) 5578 continue; 5579 if (!csr_is_aggregate_rate_supported(mac_ctx, 5580 bss_ext_supp_rates->rates[i])) { 5581 match = false; 5582 break; 5583 } 5584 } 5585 } 5586 return match; 5587 } 5588 5589 #ifdef WLAN_FEATURE_FILS_SK 5590 /* 5591 * csr_is_fils_realm_match: API to check whether realm in scan filter is 5592 * matching with realm in bss info 5593 * @bss_descr: bss description 5594 * @filter: scan filter 5595 * 5596 * Return: true if success else false 5597 */ 5598 static bool csr_is_fils_realm_match(tSirBssDescription *bss_descr, 5599 tCsrScanResultFilter *filter) 5600 { 5601 int i; 5602 bool is_match = true; 5603 5604 if (filter->realm_check) { 5605 is_match = false; 5606 for (i = 0; i < bss_descr->fils_info_element.realm_cnt; i++) { 5607 if (!qdf_mem_cmp(filter->fils_realm, 5608 bss_descr->fils_info_element.realm[i], 5609 SIR_REALM_LEN)) { 5610 return true; 5611 } 5612 } 5613 } 5614 5615 return is_match; 5616 } 5617 #else 5618 static bool csr_is_fils_realm_match(tSirBssDescription *bss_descr, 5619 tCsrScanResultFilter *filter) 5620 { 5621 return true; 5622 } 5623 #endif 5624 /** 5625 * csr_match_bss() - to compare the bss 5626 * @hal: pointer to hal context 5627 * @bss_descr: pointer bss description 5628 * @filter: scan filter 5629 * @neg_auth: negotiated auth 5630 * @neg_uc: negotiated for unicast 5631 * @neg_mc: negotiated for multicast 5632 * @ie_dblptr: double pointer to IE 5633 * 5634 * This routine will be called to match the bss 5635 * If caller want to get the *ie_dblptr allocated by this function, 5636 * pass in *ie_dblptr = NULL 5637 * 5638 * Return: bool 5639 */ 5640 bool csr_match_bss(tHalHandle hal, tSirBssDescription *bss_descr, 5641 tCsrScanResultFilter *filter, eCsrAuthType *neg_auth, 5642 eCsrEncryptionType *neg_uc, eCsrEncryptionType *neg_mc, 5643 tDot11fBeaconIEs **ie_dblptr) 5644 { 5645 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal); 5646 bool rc = false, check, blacklist_check; 5647 uint32_t i; 5648 tDot11fBeaconIEs *ie_ptr = NULL; 5649 uint8_t *pb; 5650 struct roam_ext_params *roam_params; 5651 uint8_t *p2p_macaddr = NULL; 5652 5653 roam_params = &mac_ctx->roam.configParam.roam_params; 5654 if ((NULL == ie_dblptr) || (*ie_dblptr) == NULL) { 5655 /* If no IEs passed in, get our own. */ 5656 if (!QDF_IS_STATUS_SUCCESS( 5657 csr_get_parsed_bss_description_ies(mac_ctx, 5658 bss_descr, &ie_ptr))) { 5659 goto end; 5660 } 5661 } else { 5662 /* Save the one pass in for local use */ 5663 ie_ptr = *ie_dblptr; 5664 } 5665 5666 /* Check if caller wants P2P */ 5667 check = (!filter->p2pResult || ie_ptr->P2PBeaconProbeRes.present); 5668 if (!check) 5669 goto end; 5670 5671 /* Check for Blacklist BSSID's and avoid connections */ 5672 blacklist_check = false; 5673 for (i = 0; i < roam_params->num_bssid_avoid_list; i++) { 5674 if (qdf_is_macaddr_equal((struct qdf_mac_addr *) 5675 &roam_params->bssid_avoid_list[i], 5676 (struct qdf_mac_addr *)bss_descr->bssId)) { 5677 blacklist_check = true; 5678 break; 5679 } 5680 } 5681 if (blacklist_check) { 5682 sme_err("Don't Attempt connect to blacklist bssid"); 5683 goto end; 5684 } 5685 5686 if (ie_ptr->SSID.present) { 5687 for (i = 0; i < filter->SSIDs.numOfSSIDs; i++) { 5688 check = csr_is_ssid_match(mac_ctx, 5689 filter->SSIDs.SSIDList[i].SSID.ssId, 5690 filter->SSIDs.SSIDList[i].SSID.length, 5691 ie_ptr->SSID.ssid, 5692 ie_ptr->SSID.num_ssid, true); 5693 if (check) 5694 break; 5695 } 5696 if (!check) 5697 goto end; 5698 } 5699 check = true; 5700 p2p_macaddr = ie_ptr->P2PBeaconProbeRes.P2PDeviceInfo.P2PDeviceAddress; 5701 for (i = 0; i < filter->BSSIDs.numOfBSSIDs; i++) { 5702 check = csr_is_bssid_match(mac_ctx, 5703 (struct qdf_mac_addr *)&filter->BSSIDs.bssid[i], 5704 (struct qdf_mac_addr *)bss_descr->bssId); 5705 if (check) 5706 break; 5707 5708 if (filter->p2pResult && ie_ptr->P2PBeaconProbeRes.present) { 5709 check = csr_is_bssid_match(mac_ctx, 5710 (struct qdf_mac_addr *) 5711 &filter->BSSIDs.bssid[i], 5712 (struct qdf_mac_addr *)p2p_macaddr); 5713 if (check) 5714 break; 5715 } 5716 } 5717 if (!check) 5718 goto end; 5719 5720 check = true; 5721 for (i = 0; i < filter->ChannelInfo.numOfChannels; i++) { 5722 check = csr_is_channel_band_match(mac_ctx, 5723 filter->ChannelInfo.ChannelList[i], bss_descr); 5724 if (check) 5725 break; 5726 } 5727 if (!check) 5728 goto end; 5729 /* If this is for measurement filtering */ 5730 if (filter->fMeasurement) { 5731 rc = true; 5732 goto end; 5733 } 5734 if (!csr_is_phy_mode_match(mac_ctx, filter->phyMode, bss_descr, 5735 NULL, NULL, ie_ptr)) 5736 goto end; 5737 5738 #ifdef WLAN_FEATURE_11W 5739 if ((!filter->bWPSAssociation) && (!filter->bOSENAssociation) && 5740 !csr_is_security_match(mac_ctx, &filter->authType, 5741 &filter->EncryptionType, 5742 &filter->mcEncryptionType, 5743 &filter->MFPEnabled, 5744 &filter->MFPRequired, 5745 &filter->MFPCapable, 5746 bss_descr, ie_ptr, neg_auth, 5747 neg_uc, neg_mc)) 5748 #else 5749 if ((!filter->bWPSAssociation) && (!filter->bOSENAssociation) && 5750 !csr_is_security_match(mac_ctx, &filter->authType, 5751 &filter->EncryptionType, 5752 &filter->mcEncryptionType, 5753 NULL, NULL, NULL, 5754 bss_descr, ie_ptr, neg_auth, 5755 neg_uc, neg_mc)) 5756 #endif 5757 goto end; 5758 if (!csr_is_capabilities_match(mac_ctx, filter->BSSType, bss_descr)) 5759 goto end; 5760 if (!csr_is_rate_set_match(mac_ctx, &ie_ptr->SuppRates, 5761 &ie_ptr->ExtSuppRates)) 5762 goto end; 5763 if ((eCsrRoamWmmQbssOnly == mac_ctx->roam.configParam.WMMSupportMode) 5764 && !CSR_IS_QOS_BSS(ie_ptr)) 5765 goto end; 5766 /* 5767 * Check country. check even when pb is NULL because we may 5768 * want to make sure 5769 */ 5770 pb = (filter->countryCode[0]) ? (filter->countryCode) : NULL; 5771 check = csr_match_country_code(mac_ctx, pb, ie_ptr); 5772 if (!check) 5773 goto end; 5774 5775 if (filter->MDID.mdiePresent && csr_roam_is11r_assoc(mac_ctx, 5776 mac_ctx->roam.roamSession->sessionId)) { 5777 if (bss_descr->mdiePresent) { 5778 if (filter->MDID.mobilityDomain != 5779 (bss_descr->mdie[1] << 8 | 5780 bss_descr->mdie[0])) 5781 goto end; 5782 } else { 5783 goto end; 5784 } 5785 } 5786 rc = true; 5787 if (rc) 5788 rc = csr_is_fils_realm_match(bss_descr, filter); 5789 5790 end: 5791 if (ie_dblptr) 5792 *ie_dblptr = ie_ptr; 5793 else if (ie_ptr) 5794 qdf_mem_free(ie_ptr); 5795 return rc; 5796 } 5797 5798 static bool csr_match_connected_bss_security(tpAniSirGlobal pMac, 5799 tCsrRoamConnectedProfile *pProfile, 5800 tSirBssDescription *pBssDesc, 5801 tDot11fBeaconIEs *pIes) 5802 { 5803 tCsrEncryptionList ucEncryptionList, mcEncryptionList; 5804 tCsrAuthList authList; 5805 5806 ucEncryptionList.numEntries = 1; 5807 ucEncryptionList.encryptionType[0] = pProfile->EncryptionType; 5808 5809 mcEncryptionList.numEntries = 1; 5810 mcEncryptionList.encryptionType[0] = pProfile->mcEncryptionType; 5811 5812 authList.numEntries = 1; 5813 authList.authType[0] = pProfile->AuthType; 5814 5815 #ifdef WLAN_FEATURE_11W 5816 return csr_is_security_match(pMac, &authList, &ucEncryptionList, 5817 &mcEncryptionList, 5818 &pProfile->MFPEnabled, 5819 &pProfile->MFPRequired, 5820 &pProfile->MFPCapable, 5821 pBssDesc, pIes, NULL, NULL, NULL); 5822 #else 5823 return csr_is_security_match(pMac, &authList, &ucEncryptionList, 5824 &mcEncryptionList, NULL, NULL, NULL, 5825 pBssDesc, pIes, NULL, NULL, NULL); 5826 #endif 5827 5828 } 5829 5830 bool csr_match_bss_to_connect_profile(tHalHandle hHal, 5831 tCsrRoamConnectedProfile *pProfile, 5832 tSirBssDescription *pBssDesc, 5833 tDot11fBeaconIEs *pIes) 5834 { 5835 tpAniSirGlobal pMac = PMAC_STRUCT(hHal); 5836 bool fRC = false, fCheck; 5837 tDot11fBeaconIEs *pIesLocal = pIes; 5838 5839 do { 5840 if (!pIes) { 5841 if (!QDF_IS_STATUS_SUCCESS 5842 (csr_get_parsed_bss_description_ies 5843 (pMac, pBssDesc, &pIesLocal))) 5844 break; 5845 } 5846 fCheck = true; 5847 if (pIesLocal->SSID.present) { 5848 bool fCheckSsid = false; 5849 5850 if (pProfile->SSID.length) 5851 fCheckSsid = true; 5852 5853 fCheck = 5854 csr_is_ssid_match(pMac, pProfile->SSID.ssId, 5855 pProfile->SSID.length, 5856 pIesLocal->SSID.ssid, 5857 pIesLocal->SSID.num_ssid, 5858 fCheckSsid); 5859 if (!fCheck) 5860 break; 5861 } 5862 if (!csr_match_connected_bss_security 5863 (pMac, pProfile, pBssDesc, pIesLocal)) 5864 break; 5865 if (!csr_is_capabilities_match(pMac, pProfile->BSSType, 5866 pBssDesc)) 5867 break; 5868 if (!csr_is_rate_set_match(pMac, &pIesLocal->SuppRates, 5869 &pIesLocal->ExtSuppRates)) 5870 break; 5871 fCheck = csr_is_channel_band_match(pMac, 5872 pProfile->operationChannel, 5873 pBssDesc); 5874 if (!fCheck) 5875 break; 5876 5877 fRC = true; 5878 5879 } while (0); 5880 5881 if (!pIes && pIesLocal) 5882 /* locally allocated */ 5883 qdf_mem_free(pIesLocal); 5884 5885 return fRC; 5886 } 5887 5888 void csr_add_rate_bitmap(uint8_t rate, uint16_t *pRateBitmap) 5889 { 5890 uint16_t rateBitmap; 5891 uint16_t n = BITS_OFF(rate, CSR_DOT11_BASIC_RATE_MASK); 5892 5893 rateBitmap = *pRateBitmap; 5894 switch (n) { 5895 case SIR_MAC_RATE_1: 5896 rateBitmap |= SIR_MAC_RATE_1_BITMAP; 5897 break; 5898 case SIR_MAC_RATE_2: 5899 rateBitmap |= SIR_MAC_RATE_2_BITMAP; 5900 break; 5901 case SIR_MAC_RATE_5_5: 5902 rateBitmap |= SIR_MAC_RATE_5_5_BITMAP; 5903 break; 5904 case SIR_MAC_RATE_11: 5905 rateBitmap |= SIR_MAC_RATE_11_BITMAP; 5906 break; 5907 case SIR_MAC_RATE_6: 5908 rateBitmap |= SIR_MAC_RATE_6_BITMAP; 5909 break; 5910 case SIR_MAC_RATE_9: 5911 rateBitmap |= SIR_MAC_RATE_9_BITMAP; 5912 break; 5913 case SIR_MAC_RATE_12: 5914 rateBitmap |= SIR_MAC_RATE_12_BITMAP; 5915 break; 5916 case SIR_MAC_RATE_18: 5917 rateBitmap |= SIR_MAC_RATE_18_BITMAP; 5918 break; 5919 case SIR_MAC_RATE_24: 5920 rateBitmap |= SIR_MAC_RATE_24_BITMAP; 5921 break; 5922 case SIR_MAC_RATE_36: 5923 rateBitmap |= SIR_MAC_RATE_36_BITMAP; 5924 break; 5925 case SIR_MAC_RATE_48: 5926 rateBitmap |= SIR_MAC_RATE_48_BITMAP; 5927 break; 5928 case SIR_MAC_RATE_54: 5929 rateBitmap |= SIR_MAC_RATE_54_BITMAP; 5930 break; 5931 } 5932 *pRateBitmap = rateBitmap; 5933 } 5934 5935 bool csr_check_rate_bitmap(uint8_t rate, uint16_t rateBitmap) 5936 { 5937 uint16_t n = BITS_OFF(rate, CSR_DOT11_BASIC_RATE_MASK); 5938 5939 switch (n) { 5940 case SIR_MAC_RATE_1: 5941 rateBitmap &= SIR_MAC_RATE_1_BITMAP; 5942 break; 5943 case SIR_MAC_RATE_2: 5944 rateBitmap &= SIR_MAC_RATE_2_BITMAP; 5945 break; 5946 case SIR_MAC_RATE_5_5: 5947 rateBitmap &= SIR_MAC_RATE_5_5_BITMAP; 5948 break; 5949 case SIR_MAC_RATE_11: 5950 rateBitmap &= SIR_MAC_RATE_11_BITMAP; 5951 break; 5952 case SIR_MAC_RATE_6: 5953 rateBitmap &= SIR_MAC_RATE_6_BITMAP; 5954 break; 5955 case SIR_MAC_RATE_9: 5956 rateBitmap &= SIR_MAC_RATE_9_BITMAP; 5957 break; 5958 case SIR_MAC_RATE_12: 5959 rateBitmap &= SIR_MAC_RATE_12_BITMAP; 5960 break; 5961 case SIR_MAC_RATE_18: 5962 rateBitmap &= SIR_MAC_RATE_18_BITMAP; 5963 break; 5964 case SIR_MAC_RATE_24: 5965 rateBitmap &= SIR_MAC_RATE_24_BITMAP; 5966 break; 5967 case SIR_MAC_RATE_36: 5968 rateBitmap &= SIR_MAC_RATE_36_BITMAP; 5969 break; 5970 case SIR_MAC_RATE_48: 5971 rateBitmap &= SIR_MAC_RATE_48_BITMAP; 5972 break; 5973 case SIR_MAC_RATE_54: 5974 rateBitmap &= SIR_MAC_RATE_54_BITMAP; 5975 break; 5976 } 5977 return !!rateBitmap; 5978 } 5979 5980 bool csr_rates_is_dot11_rate_supported(tHalHandle hHal, uint8_t rate) 5981 { 5982 tpAniSirGlobal pMac = PMAC_STRUCT(hHal); 5983 uint16_t n = BITS_OFF(rate, CSR_DOT11_BASIC_RATE_MASK); 5984 5985 return csr_is_aggregate_rate_supported(pMac, n); 5986 } 5987 5988 static uint16_t csr_rates_mac_prop_to_dot11(uint16_t Rate) 5989 { 5990 uint16_t ConvertedRate = Rate; 5991 5992 switch (Rate) { 5993 case SIR_MAC_RATE_1: 5994 ConvertedRate = 2; 5995 break; 5996 case SIR_MAC_RATE_2: 5997 ConvertedRate = 4; 5998 break; 5999 case SIR_MAC_RATE_5_5: 6000 ConvertedRate = 11; 6001 break; 6002 case SIR_MAC_RATE_11: 6003 ConvertedRate = 22; 6004 break; 6005 6006 case SIR_MAC_RATE_6: 6007 ConvertedRate = 12; 6008 break; 6009 case SIR_MAC_RATE_9: 6010 ConvertedRate = 18; 6011 break; 6012 case SIR_MAC_RATE_12: 6013 ConvertedRate = 24; 6014 break; 6015 case SIR_MAC_RATE_18: 6016 ConvertedRate = 36; 6017 break; 6018 case SIR_MAC_RATE_24: 6019 ConvertedRate = 48; 6020 break; 6021 case SIR_MAC_RATE_36: 6022 ConvertedRate = 72; 6023 break; 6024 case SIR_MAC_RATE_42: 6025 ConvertedRate = 84; 6026 break; 6027 case SIR_MAC_RATE_48: 6028 ConvertedRate = 96; 6029 break; 6030 case SIR_MAC_RATE_54: 6031 ConvertedRate = 108; 6032 break; 6033 6034 case SIR_MAC_RATE_72: 6035 ConvertedRate = 144; 6036 break; 6037 case SIR_MAC_RATE_84: 6038 ConvertedRate = 168; 6039 break; 6040 case SIR_MAC_RATE_96: 6041 ConvertedRate = 192; 6042 break; 6043 case SIR_MAC_RATE_108: 6044 ConvertedRate = 216; 6045 break; 6046 case SIR_MAC_RATE_126: 6047 ConvertedRate = 252; 6048 break; 6049 case SIR_MAC_RATE_144: 6050 ConvertedRate = 288; 6051 break; 6052 case SIR_MAC_RATE_168: 6053 ConvertedRate = 336; 6054 break; 6055 case SIR_MAC_RATE_192: 6056 ConvertedRate = 384; 6057 break; 6058 case SIR_MAC_RATE_216: 6059 ConvertedRate = 432; 6060 break; 6061 case SIR_MAC_RATE_240: 6062 ConvertedRate = 480; 6063 break; 6064 6065 case 0xff: 6066 ConvertedRate = 0; 6067 break; 6068 } 6069 6070 return ConvertedRate; 6071 } 6072 6073 uint16_t csr_rates_find_best_rate(tSirMacRateSet *pSuppRates, 6074 tSirMacRateSet *pExtRates, 6075 tSirMacPropRateSet *pPropRates) 6076 { 6077 uint8_t i; 6078 uint16_t nBest; 6079 6080 nBest = pSuppRates->rate[0] & (~CSR_DOT11_BASIC_RATE_MASK); 6081 6082 if (pSuppRates->numRates > SIR_MAC_RATESET_EID_MAX) 6083 pSuppRates->numRates = SIR_MAC_RATESET_EID_MAX; 6084 6085 for (i = 1U; i < pSuppRates->numRates; ++i) { 6086 nBest = 6087 (uint16_t) CSR_MAX(nBest, 6088 pSuppRates-> 6089 rate[i] & (~CSR_DOT11_BASIC_RATE_MASK)); 6090 } 6091 6092 if (NULL != pExtRates) { 6093 for (i = 0U; i < pExtRates->numRates; ++i) { 6094 nBest = 6095 (uint16_t) CSR_MAX(nBest, 6096 pExtRates-> 6097 rate[i] & 6098 (~CSR_DOT11_BASIC_RATE_MASK)); 6099 } 6100 } 6101 6102 if (NULL != pPropRates) { 6103 for (i = 0U; i < pPropRates->numPropRates; ++i) { 6104 nBest = 6105 (uint16_t) CSR_MAX(nBest, 6106 csr_rates_mac_prop_to_dot11 6107 (pPropRates->propRate[i])); 6108 } 6109 } 6110 6111 return nBest; 6112 } 6113 6114 #ifdef WLAN_FEATURE_FILS_SK 6115 static inline void csr_free_fils_profile_info(tCsrRoamProfile *profile) 6116 { 6117 if (profile->fils_con_info) { 6118 qdf_mem_free(profile->fils_con_info); 6119 profile->fils_con_info = NULL; 6120 } 6121 6122 if (profile->hlp_ie) { 6123 qdf_mem_free(profile->hlp_ie); 6124 profile->hlp_ie = NULL; 6125 profile->hlp_ie_len = 0; 6126 } 6127 } 6128 #else 6129 static inline void csr_free_fils_profile_info(tCsrRoamProfile *profile) 6130 { } 6131 #endif 6132 6133 void csr_release_profile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile) 6134 { 6135 if (pProfile) { 6136 if (pProfile->BSSIDs.bssid) { 6137 qdf_mem_free(pProfile->BSSIDs.bssid); 6138 pProfile->BSSIDs.bssid = NULL; 6139 } 6140 if (pProfile->SSIDs.SSIDList) { 6141 qdf_mem_free(pProfile->SSIDs.SSIDList); 6142 pProfile->SSIDs.SSIDList = NULL; 6143 } 6144 if (pProfile->pWPAReqIE) { 6145 qdf_mem_free(pProfile->pWPAReqIE); 6146 pProfile->pWPAReqIE = NULL; 6147 } 6148 if (pProfile->pRSNReqIE) { 6149 qdf_mem_free(pProfile->pRSNReqIE); 6150 pProfile->pRSNReqIE = NULL; 6151 } 6152 #ifdef FEATURE_WLAN_WAPI 6153 if (pProfile->pWAPIReqIE) { 6154 qdf_mem_free(pProfile->pWAPIReqIE); 6155 pProfile->pWAPIReqIE = NULL; 6156 } 6157 #endif /* FEATURE_WLAN_WAPI */ 6158 6159 if (pProfile->pAddIEScan) { 6160 qdf_mem_free(pProfile->pAddIEScan); 6161 pProfile->pAddIEScan = NULL; 6162 } 6163 6164 if (pProfile->pAddIEAssoc) { 6165 qdf_mem_free(pProfile->pAddIEAssoc); 6166 pProfile->pAddIEAssoc = NULL; 6167 } 6168 if (pProfile->ChannelInfo.ChannelList) { 6169 qdf_mem_free(pProfile->ChannelInfo.ChannelList); 6170 pProfile->ChannelInfo.ChannelList = NULL; 6171 } 6172 csr_free_fils_profile_info(pProfile); 6173 qdf_mem_set(pProfile, sizeof(tCsrRoamProfile), 0); 6174 } 6175 } 6176 6177 void csr_free_scan_filter(tpAniSirGlobal pMac, tCsrScanResultFilter 6178 *pScanFilter) 6179 { 6180 if (pScanFilter->BSSIDs.bssid) { 6181 qdf_mem_free(pScanFilter->BSSIDs.bssid); 6182 pScanFilter->BSSIDs.bssid = NULL; 6183 } 6184 if (pScanFilter->ChannelInfo.ChannelList) { 6185 qdf_mem_free(pScanFilter->ChannelInfo.ChannelList); 6186 pScanFilter->ChannelInfo.ChannelList = NULL; 6187 } 6188 if (pScanFilter->SSIDs.SSIDList) { 6189 qdf_mem_free(pScanFilter->SSIDs.SSIDList); 6190 pScanFilter->SSIDs.SSIDList = NULL; 6191 } 6192 } 6193 6194 void csr_free_roam_profile(tpAniSirGlobal pMac, uint32_t sessionId) 6195 { 6196 struct csr_roam_session *pSession = &pMac->roam.roamSession[sessionId]; 6197 6198 if (pSession->pCurRoamProfile) { 6199 csr_release_profile(pMac, pSession->pCurRoamProfile); 6200 qdf_mem_free(pSession->pCurRoamProfile); 6201 pSession->pCurRoamProfile = NULL; 6202 } 6203 } 6204 6205 void csr_free_connect_bss_desc(tpAniSirGlobal pMac, uint32_t sessionId) 6206 { 6207 struct csr_roam_session *pSession = &pMac->roam.roamSession[sessionId]; 6208 6209 if (pSession->pConnectBssDesc) { 6210 qdf_mem_free(pSession->pConnectBssDesc); 6211 pSession->pConnectBssDesc = NULL; 6212 } 6213 } 6214 6215 tSirResultCodes csr_get_disassoc_rsp_status_code(tSirSmeDisassocRsp * 6216 pSmeDisassocRsp) 6217 { 6218 uint8_t *pBuffer = (uint8_t *) pSmeDisassocRsp; 6219 uint32_t ret; 6220 6221 pBuffer += (sizeof(uint16_t) + sizeof(uint16_t) + sizeof(tSirMacAddr)); 6222 /* tSirResultCodes is an enum, assuming is 32bit */ 6223 /* If we cannot make this assumption, use copymemory */ 6224 qdf_get_u32(pBuffer, &ret); 6225 6226 return (tSirResultCodes) ret; 6227 } 6228 6229 tSirResultCodes csr_get_de_auth_rsp_status_code(tSirSmeDeauthRsp *pSmeRsp) 6230 { 6231 uint8_t *pBuffer = (uint8_t *) pSmeRsp; 6232 uint32_t ret; 6233 6234 pBuffer += 6235 (sizeof(uint16_t) + sizeof(uint16_t) + sizeof(uint8_t) + 6236 sizeof(uint16_t)); 6237 /* tSirResultCodes is an enum, assuming is 32bit */ 6238 /* If we cannot make this assumption, use copymemory */ 6239 qdf_get_u32(pBuffer, &ret); 6240 6241 return (tSirResultCodes) ret; 6242 } 6243 6244 tSirScanType csr_get_scan_type(tpAniSirGlobal pMac, uint8_t chnId) 6245 { 6246 tSirScanType scanType = eSIR_PASSIVE_SCAN; 6247 enum channel_state channelEnabledType; 6248 6249 channelEnabledType = wlan_reg_get_channel_state(pMac->pdev, chnId); 6250 if (CHANNEL_STATE_ENABLE == channelEnabledType) 6251 scanType = eSIR_ACTIVE_SCAN; 6252 6253 return scanType; 6254 } 6255 6256 uint8_t csr_to_upper(uint8_t ch) 6257 { 6258 uint8_t chOut; 6259 6260 if (ch >= 'a' && ch <= 'z') 6261 chOut = ch - 'a' + 'A'; 6262 else 6263 chOut = ch; 6264 6265 return chOut; 6266 } 6267 6268 tSirBssType csr_translate_bsstype_to_mac_type(eCsrRoamBssType csrtype) 6269 { 6270 tSirBssType ret; 6271 6272 switch (csrtype) { 6273 case eCSR_BSS_TYPE_INFRASTRUCTURE: 6274 ret = eSIR_INFRASTRUCTURE_MODE; 6275 break; 6276 case eCSR_BSS_TYPE_IBSS: 6277 case eCSR_BSS_TYPE_START_IBSS: 6278 ret = eSIR_IBSS_MODE; 6279 break; 6280 case eCSR_BSS_TYPE_INFRA_AP: 6281 ret = eSIR_INFRA_AP_MODE; 6282 break; 6283 case eCSR_BSS_TYPE_NDI: 6284 ret = eSIR_NDI_MODE; 6285 break; 6286 case eCSR_BSS_TYPE_ANY: 6287 default: 6288 ret = eSIR_AUTO_MODE; 6289 break; 6290 } 6291 6292 return ret; 6293 } 6294 6295 /* This function use the parameters to decide the CFG value. */ 6296 /* CSR never sets WNI_CFG_DOT11_MODE_ALL to the CFG */ 6297 /* So PE should not see WNI_CFG_DOT11_MODE_ALL when it gets the CFG value */ 6298 enum csr_cfgdot11mode csr_get_cfg_dot11_mode_from_csr_phy_mode(tCsrRoamProfile 6299 *pProfile, 6300 eCsrPhyMode phyMode, 6301 bool fProprietary) 6302 { 6303 uint32_t cfgDot11Mode = eCSR_CFG_DOT11_MODE_ABG; 6304 6305 switch (phyMode) { 6306 case eCSR_DOT11_MODE_11a: 6307 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A; 6308 break; 6309 case eCSR_DOT11_MODE_11b: 6310 case eCSR_DOT11_MODE_11b_ONLY: 6311 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B; 6312 break; 6313 case eCSR_DOT11_MODE_11g: 6314 case eCSR_DOT11_MODE_11g_ONLY: 6315 if (pProfile && (CSR_IS_INFRA_AP(pProfile)) 6316 && (phyMode == eCSR_DOT11_MODE_11g_ONLY)) 6317 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G_ONLY; 6318 else 6319 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G; 6320 break; 6321 case eCSR_DOT11_MODE_11n: 6322 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N; 6323 break; 6324 case eCSR_DOT11_MODE_11n_ONLY: 6325 if (pProfile && CSR_IS_INFRA_AP(pProfile)) 6326 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N_ONLY; 6327 else 6328 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N; 6329 break; 6330 case eCSR_DOT11_MODE_abg: 6331 cfgDot11Mode = eCSR_CFG_DOT11_MODE_ABG; 6332 break; 6333 case eCSR_DOT11_MODE_AUTO: 6334 cfgDot11Mode = eCSR_CFG_DOT11_MODE_AUTO; 6335 break; 6336 6337 case eCSR_DOT11_MODE_11ac: 6338 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC)) 6339 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC; 6340 else 6341 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N; 6342 break; 6343 case eCSR_DOT11_MODE_11ac_ONLY: 6344 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC)) 6345 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY; 6346 else 6347 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N; 6348 break; 6349 case eCSR_DOT11_MODE_11ax: 6350 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AX)) 6351 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AX; 6352 else if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC)) 6353 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC; 6354 else 6355 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N; 6356 break; 6357 case eCSR_DOT11_MODE_11ax_ONLY: 6358 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AX)) 6359 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AX_ONLY; 6360 else if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC)) 6361 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC; 6362 else 6363 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N; 6364 break; 6365 6366 default: 6367 /* No need to assign anything here */ 6368 break; 6369 } 6370 6371 return cfgDot11Mode; 6372 } 6373 6374 QDF_STATUS csr_get_regulatory_domain_for_country(tpAniSirGlobal pMac, 6375 uint8_t *pCountry, 6376 v_REGDOMAIN_t *pDomainId, 6377 enum country_src source) 6378 { 6379 QDF_STATUS status = QDF_STATUS_E_INVAL; 6380 QDF_STATUS qdf_status; 6381 uint8_t countryCode[CDS_COUNTRY_CODE_LEN + 1]; 6382 v_REGDOMAIN_t domainId; 6383 6384 if (pCountry) { 6385 countryCode[0] = pCountry[0]; 6386 countryCode[1] = pCountry[1]; 6387 qdf_status = wlan_reg_get_domain_from_country_code(&domainId, 6388 countryCode, 6389 source); 6390 6391 if (QDF_IS_STATUS_SUCCESS(qdf_status)) { 6392 if (pDomainId) 6393 *pDomainId = domainId; 6394 status = QDF_STATUS_SUCCESS; 6395 } else { 6396 sme_warn("Couldn't find domain for country code %c%c", 6397 pCountry[0], pCountry[1]); 6398 status = QDF_STATUS_E_INVAL; 6399 } 6400 } 6401 6402 return status; 6403 } 6404 6405 /* To check whether a country code matches the one in the IE 6406 * Only check the first two characters, ignoring in/outdoor 6407 * pCountry -- caller allocated buffer contain the country 6408 * code that is checking against the one in pIes. It can be 6409 * NULL. Caller must provide pIes, it cannot be NULL This 6410 * function always return true if 11d support is not turned on. 6411 */ 6412 bool csr_match_country_code(tpAniSirGlobal pMac, uint8_t *pCountry, 6413 tDot11fBeaconIEs *pIes) 6414 { 6415 bool fRet = true; 6416 6417 do { 6418 if (!wlan_reg_11d_enabled_on_host(pMac->psoc)) 6419 break; 6420 6421 if (!pIes) { 6422 sme_err("No IEs"); 6423 break; 6424 } 6425 6426 if (pCountry) { 6427 uint32_t i; 6428 6429 if (!pIes->Country.present) { 6430 fRet = false; 6431 break; 6432 } 6433 /* Convert the CountryCode characters to upper */ 6434 for (i = 0; i < WNI_CFG_COUNTRY_CODE_LEN - 1; i++) 6435 pCountry[i] = csr_to_upper(pCountry[i]); 6436 6437 if (qdf_mem_cmp(pIes->Country.country, pCountry, 6438 WNI_CFG_COUNTRY_CODE_LEN - 1)) { 6439 fRet = false; 6440 break; 6441 } 6442 } 6443 } while (0); 6444 6445 return fRet; 6446 } 6447 6448 QDF_STATUS csr_get_modify_profile_fields(tpAniSirGlobal pMac, 6449 uint32_t sessionId, 6450 tCsrRoamModifyProfileFields * 6451 pModifyProfileFields) 6452 { 6453 if (!pModifyProfileFields) 6454 return QDF_STATUS_E_FAILURE; 6455 6456 qdf_mem_copy(pModifyProfileFields, 6457 &pMac->roam.roamSession[sessionId].connectedProfile. 6458 modifyProfileFields, sizeof(tCsrRoamModifyProfileFields)); 6459 6460 return QDF_STATUS_SUCCESS; 6461 } 6462 6463 QDF_STATUS csr_set_modify_profile_fields(tpAniSirGlobal pMac, 6464 uint32_t sessionId, 6465 tCsrRoamModifyProfileFields * 6466 pModifyProfileFields) 6467 { 6468 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId); 6469 6470 qdf_mem_copy(&pSession->connectedProfile.modifyProfileFields, 6471 pModifyProfileFields, sizeof(tCsrRoamModifyProfileFields)); 6472 6473 return QDF_STATUS_SUCCESS; 6474 } 6475 6476 6477 bool csr_is_set_key_allowed(tpAniSirGlobal pMac, uint32_t sessionId) 6478 { 6479 bool fRet = true; 6480 struct csr_roam_session *pSession; 6481 6482 pSession = CSR_GET_SESSION(pMac, sessionId); 6483 6484 /* 6485 * This condition is not working for infra state. When infra is in 6486 * not-connected state the pSession->pCurRoamProfile is NULL, this 6487 * function returns true, that is incorrect. 6488 * Since SAP requires to set key without any BSS started, it needs 6489 * this condition to be met. In other words, this function is useless. 6490 * The current work-around is to process setcontext_rsp no matter 6491 * what the state is. 6492 */ 6493 sme_debug("is not what it intends to. Must be revisit or removed"); 6494 if ((NULL == pSession) 6495 || (csr_is_conn_state_disconnected(pMac, sessionId) 6496 && (pSession->pCurRoamProfile != NULL) 6497 && (!(CSR_IS_INFRA_AP(pSession->pCurRoamProfile)))) 6498 ) { 6499 fRet = false; 6500 } 6501 6502 return fRet; 6503 } 6504 6505 /* no need to acquire lock for this basic function */ 6506 uint16_t sme_chn_to_freq(uint8_t chanNum) 6507 { 6508 int i; 6509 6510 for (i = 0; i < NUM_CHANNELS; i++) { 6511 if (WLAN_REG_CH_NUM(i) == chanNum) 6512 return WLAN_REG_CH_TO_FREQ(i); 6513 } 6514 6515 return 0; 6516 } 6517 6518 /* Disconnect all active sessions by sending disassoc. This is mainly 6519 * used to disconnect the remaining session when we transition from 6520 * concurrent sessions to a single session. The use case is Infra STA 6521 * and wifi direct multiple sessions are up and P2P session is removed. 6522 * The Infra STA session remains and should resume BMPS if BMPS is enabled 6523 * by default. However, there are some issues seen with BMPS resume during 6524 * this transition and this is a workaround which will allow the Infra STA 6525 * session to disconnect and auto connect back and enter BMPS this giving 6526 * the same effect as resuming BMPS 6527 */ 6528 6529 /* Remove this code once SLM_Sessionization is supported */ 6530 /* BMPS_WORKAROUND_NOT_NEEDED */ 6531 void csr_disconnect_all_active_sessions(tpAniSirGlobal pMac) 6532 { 6533 uint8_t i; 6534 6535 /* Disconnect all the active sessions */ 6536 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { 6537 if (CSR_IS_SESSION_VALID(pMac, i) 6538 && !csr_is_conn_state_disconnected(pMac, i)) 6539 csr_roam_disconnect_internal(pMac, i, 6540 eCSR_DISCONNECT_REASON_UNSPECIFIED); 6541 } 6542 } 6543 6544 struct lim_channel_status *csr_get_channel_status( 6545 void *p_mac, uint32_t channel_id) 6546 { 6547 uint8_t i; 6548 struct lim_scan_channel_status *channel_status; 6549 tpAniSirGlobal mac_ptr = (tpAniSirGlobal)p_mac; 6550 6551 if (!mac_ptr->sap.acs_with_more_param) 6552 return NULL; 6553 6554 channel_status = (struct lim_scan_channel_status *) 6555 &mac_ptr->lim.scan_channel_status; 6556 for (i = 0; i < channel_status->total_channel; i++) { 6557 if (channel_status->channel_status_list[i].channel_id == 6558 channel_id) 6559 return &channel_status->channel_status_list[i]; 6560 } 6561 cds_err("Channel %d status info not exist", channel_id); 6562 6563 return NULL; 6564 } 6565 6566 void csr_clear_channel_status(void *p_mac) 6567 { 6568 tpAniSirGlobal mac_ptr = (tpAniSirGlobal)p_mac; 6569 struct lim_scan_channel_status *channel_status; 6570 6571 if (!mac_ptr->sap.acs_with_more_param) 6572 return; 6573 6574 channel_status = (struct lim_scan_channel_status *) 6575 &mac_ptr->lim.scan_channel_status; 6576 channel_status->total_channel = 0; 6577 6578 return; 6579 } 6580 6581 bool csr_is_channel_present_in_list(uint8_t *pChannelList, 6582 int numChannels, uint8_t channel) 6583 { 6584 int i = 0; 6585 6586 /* Check for NULL pointer */ 6587 if (!pChannelList || (numChannels == 0)) 6588 return false; 6589 6590 /* Look for the channel in the list */ 6591 for (i = 0; (i < numChannels) && 6592 (i < WNI_CFG_VALID_CHANNEL_LIST_LEN); i++) { 6593 if (pChannelList[i] == channel) 6594 return true; 6595 } 6596 6597 return false; 6598 } 6599 6600 /** 6601 * sme_request_type_to_string(): converts scan request enum to string. 6602 * @request_type: scan request type enum. 6603 * 6604 * Return: Printable string for request_type 6605 */ 6606 const char *sme_request_type_to_string(const uint8_t request_type) 6607 { 6608 switch (request_type) { 6609 CASE_RETURN_STRING(eCSR_SCAN_REQUEST_11D_SCAN); 6610 CASE_RETURN_STRING(eCSR_SCAN_REQUEST_FULL_SCAN); 6611 CASE_RETURN_STRING(eCSR_SCAN_IDLE_MODE_SCAN); 6612 CASE_RETURN_STRING(eCSR_SCAN_HO_PROBE_SCAN); 6613 CASE_RETURN_STRING(eCSR_SCAN_P2P_DISCOVERY); 6614 CASE_RETURN_STRING(eCSR_SCAN_SOFTAP_CHANNEL_RANGE); 6615 CASE_RETURN_STRING(eCSR_SCAN_P2P_FIND_PEER); 6616 default: 6617 return "Unknown Scan Request Type"; 6618 } 6619 } 6620 6621 /** 6622 * sme_bsstype_to_string() - converts bss type to string. 6623 * @bss_type: bss type enum 6624 * 6625 * Return: printable string for bss type 6626 */ 6627 const char *sme_bss_type_to_string(const uint8_t bss_type) 6628 { 6629 switch (bss_type) { 6630 CASE_RETURN_STRING(eCSR_BSS_TYPE_INFRASTRUCTURE); 6631 CASE_RETURN_STRING(eCSR_BSS_TYPE_INFRA_AP); 6632 CASE_RETURN_STRING(eCSR_BSS_TYPE_IBSS); 6633 CASE_RETURN_STRING(eCSR_BSS_TYPE_START_IBSS); 6634 CASE_RETURN_STRING(eCSR_BSS_TYPE_ANY); 6635 default: 6636 return "unknown bss type"; 6637 } 6638 } 6639 6640 /** 6641 * sme_scantype_to_string() - converts scan type to string. 6642 * @scan_type: scan type enum 6643 * 6644 * Return: printable string for scan type 6645 */ 6646 const char *sme_scan_type_to_string(const uint8_t scan_type) 6647 { 6648 switch (scan_type) { 6649 CASE_RETURN_STRING(eSIR_PASSIVE_SCAN); 6650 CASE_RETURN_STRING(eSIR_ACTIVE_SCAN); 6651 CASE_RETURN_STRING(eSIR_BEACON_TABLE); 6652 default: 6653 return "unknown scan type"; 6654 } 6655 } 6656 6657 QDF_STATUS csr_add_to_channel_list_front(uint8_t *pChannelList, 6658 int numChannels, uint8_t channel) 6659 { 6660 int i = 0; 6661 6662 /* Check for NULL pointer */ 6663 if (!pChannelList) 6664 return QDF_STATUS_E_NULL_VALUE; 6665 6666 /* Make room for the addition. (Start moving from the back.) */ 6667 for (i = numChannels; i > 0; i--) 6668 pChannelList[i] = pChannelList[i - 1]; 6669 6670 /* Now add the NEW channel...at the front */ 6671 pChannelList[0] = channel; 6672 6673 return QDF_STATUS_SUCCESS; 6674 } 6675 6676 /** 6677 * csr_wait_for_connection_update() - Wait for hw mode update 6678 * @mac: Pointer to the MAC context 6679 * @do_release_reacquire_lock: Indicates whether release and 6680 * re-acquisition of SME global lock is required. 6681 * 6682 * Waits for CONNECTION_UPDATE_TIMEOUT time so that the 6683 * hw mode update can get processed. 6684 * 6685 * Return: True if the wait was successful, false otherwise 6686 */ 6687 bool csr_wait_for_connection_update(tpAniSirGlobal mac, 6688 bool do_release_reacquire_lock) 6689 { 6690 QDF_STATUS status, ret; 6691 6692 if (do_release_reacquire_lock == true) { 6693 ret = sme_release_global_lock(&mac->sme); 6694 if (!QDF_IS_STATUS_SUCCESS(ret)) { 6695 cds_err("lock release fail %d", ret); 6696 return false; 6697 } 6698 } 6699 6700 status = policy_mgr_wait_for_connection_update(mac->psoc); 6701 6702 if (do_release_reacquire_lock == true) { 6703 ret = sme_acquire_global_lock(&mac->sme); 6704 if (!QDF_IS_STATUS_SUCCESS(ret)) { 6705 cds_err("lock acquire fail %d", ret); 6706 return false; 6707 } 6708 } 6709 6710 if (!QDF_IS_STATUS_SUCCESS(status)) { 6711 cds_err("wait for event failed"); 6712 return false; 6713 } 6714 6715 return true; 6716 } 6717 6718 /** 6719 * csr_get_session_persona() - get persona of a session 6720 * @pmac: pointer to global MAC context 6721 * @session_id: session id 6722 * 6723 * This function is to return the persona of a session 6724 * 6725 * Reture: enum QDF_OPMODE persona 6726 */ 6727 enum QDF_OPMODE csr_get_session_persona(tpAniSirGlobal pmac, 6728 uint32_t session_id) 6729 { 6730 struct csr_roam_session *session = NULL; 6731 6732 session = CSR_GET_SESSION(pmac, session_id); 6733 if (NULL == session || NULL == session->pCurRoamProfile) 6734 return QDF_MAX_NO_OF_MODE; 6735 6736 return session->pCurRoamProfile->csrPersona; 6737 } 6738 6739 /** 6740 * csr_is_ndi_started() - function to check if NDI is started 6741 * @mac_ctx: handle to mac context 6742 * @session_id: session identifier 6743 * 6744 * returns: true if NDI is started, false otherwise 6745 */ 6746 bool csr_is_ndi_started(tpAniSirGlobal mac_ctx, uint32_t session_id) 6747 { 6748 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, session_id); 6749 6750 if (!session) 6751 return false; 6752 6753 return eCSR_CONNECT_STATE_TYPE_NDI_STARTED == session->connectState; 6754 } 6755