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