Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Abhishek Singh | 5432c35 | 2019-01-02 17:11:44 +0530 | [diff] [blame] | 2 | * Copyright (c) 2011-2019 The Linux Foundation. All rights reserved. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4 | * Permission to use, copy, modify, and/or distribute this software for |
| 5 | * any purpose with or without fee is hereby granted, provided that the |
| 6 | * above copyright notice and this permission notice appear in all |
| 7 | * copies. |
| 8 | * |
| 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 10 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 11 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 12 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 13 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 14 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 15 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 16 | * PERFORMANCE OF THIS SOFTWARE. |
| 17 | */ |
| 18 | |
| 19 | /* |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 20 | * DOC: csr_api_scan.c |
| 21 | * |
| 22 | * Implementation for the Common Scan interfaces. |
| 23 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 24 | |
| 25 | #include "ani_global.h" |
| 26 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 27 | #include "csr_inside_api.h" |
| 28 | #include "sme_inside.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 29 | |
| 30 | #include "csr_support.h" |
| 31 | |
| 32 | #include "host_diag_core_log.h" |
| 33 | #include "host_diag_core_event.h" |
| 34 | |
| 35 | #include "cds_reg_service.h" |
| 36 | #include "wma_types.h" |
| 37 | #include "cds_utils.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 38 | #include "wma.h" |
| 39 | |
Tushnim Bhattacharyya | 0c4ad2d | 2017-03-09 15:59:03 -0800 | [diff] [blame] | 40 | #include "wlan_policy_mgr_api.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 41 | #include "wlan_hdd_main.h" |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 42 | #include "pld_common.h" |
yeshwanth sriram guntuka | db50122 | 2017-01-24 15:21:31 +0530 | [diff] [blame] | 43 | #include "csr_internal.h" |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 44 | #include <wlan_scan_ucfg_api.h> |
Abhishek Singh | cd131ae | 2019-04-09 15:05:17 +0530 | [diff] [blame] | 45 | #include <wlan_scan_api.h> |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 46 | #include <wlan_scan_utils_api.h> |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 47 | #include <wlan_objmgr_vdev_obj.h> |
| 48 | #include <wlan_objmgr_pdev_obj.h> |
| 49 | #include <wlan_utility.h> |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 50 | #include "wlan_reg_services_api.h" |
Wu Gao | f3cbeaf | 2019-01-15 18:26:25 +0800 | [diff] [blame] | 51 | #include "sch_api.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 52 | |
Jeff Johnson | 70fa7bb | 2018-12-05 08:27:19 -0800 | [diff] [blame] | 53 | static void csr_set_cfg_valid_channel_list(struct mac_context *mac, |
| 54 | uint8_t *pChannelList, |
| 55 | uint8_t NumChannels); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 56 | |
Jeff Johnson | 70fa7bb | 2018-12-05 08:27:19 -0800 | [diff] [blame] | 57 | static void csr_save_tx_power_to_cfg(struct mac_context *mac, |
| 58 | tDblLinkList *pList, |
| 59 | uint32_t cfgId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 60 | |
Jeff Johnson | 70fa7bb | 2018-12-05 08:27:19 -0800 | [diff] [blame] | 61 | static void csr_set_cfg_country_code(struct mac_context *mac, |
| 62 | uint8_t *countryCode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 63 | |
Jeff Johnson | 70fa7bb | 2018-12-05 08:27:19 -0800 | [diff] [blame] | 64 | static void csr_purge_channel_power(struct mac_context *mac, |
| 65 | tDblLinkList *pChannelList); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 66 | |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 67 | static bool csr_roam_is_valid_channel(struct mac_context *mac, uint8_t channel); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 68 | |
Abhishek Singh | 221cf99 | 2018-02-22 13:44:53 +0530 | [diff] [blame] | 69 | /* pResult is invalid calling this function. */ |
Jeff Johnson | 8c3ecdd | 2018-12-05 08:48:54 -0800 | [diff] [blame] | 70 | void csr_free_scan_result_entry(struct mac_context *mac, |
| 71 | struct tag_csrscan_result *pResult) |
Abhishek Singh | 221cf99 | 2018-02-22 13:44:53 +0530 | [diff] [blame] | 72 | { |
Jeff Johnson | 038efe7 | 2019-03-18 13:39:31 -0700 | [diff] [blame] | 73 | if (pResult->Result.pvIes) |
Abhishek Singh | 221cf99 | 2018-02-22 13:44:53 +0530 | [diff] [blame] | 74 | qdf_mem_free(pResult->Result.pvIes); |
| 75 | |
| 76 | qdf_mem_free(pResult); |
| 77 | } |
| 78 | |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 79 | static QDF_STATUS csr_ll_scan_purge_result(struct mac_context *mac, |
Abhishek Singh | 221cf99 | 2018-02-22 13:44:53 +0530 | [diff] [blame] | 80 | tDblLinkList *pList) |
| 81 | { |
| 82 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
| 83 | tListElem *pEntry; |
| 84 | struct tag_csrscan_result *pBssDesc; |
| 85 | |
Abhishek Singh | 221cf99 | 2018-02-22 13:44:53 +0530 | [diff] [blame] | 86 | while ((pEntry = csr_ll_remove_head(pList, LL_ACCESS_NOLOCK)) != NULL) { |
| 87 | pBssDesc = GET_BASE_ADDR(pEntry, struct tag_csrscan_result, |
| 88 | Link); |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 89 | csr_free_scan_result_entry(mac, pBssDesc); |
Abhishek Singh | 221cf99 | 2018-02-22 13:44:53 +0530 | [diff] [blame] | 90 | } |
| 91 | |
Abhishek Singh | 221cf99 | 2018-02-22 13:44:53 +0530 | [diff] [blame] | 92 | return status; |
| 93 | } |
| 94 | |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 95 | QDF_STATUS csr_scan_open(struct mac_context *mac_ctx) |
Abhishek Singh | 221cf99 | 2018-02-22 13:44:53 +0530 | [diff] [blame] | 96 | { |
Jeff Johnson | 616417f | 2018-06-27 10:20:53 -0700 | [diff] [blame] | 97 | csr_ll_open(&mac_ctx->scan.channelPowerInfoList24); |
| 98 | csr_ll_open(&mac_ctx->scan.channelPowerInfoList5G); |
Abhishek Singh | 221cf99 | 2018-02-22 13:44:53 +0530 | [diff] [blame] | 99 | |
| 100 | return QDF_STATUS_SUCCESS; |
| 101 | } |
| 102 | |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 103 | QDF_STATUS csr_scan_close(struct mac_context *mac) |
Abhishek Singh | 221cf99 | 2018-02-22 13:44:53 +0530 | [diff] [blame] | 104 | { |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 105 | csr_purge_channel_power(mac, &mac->scan.channelPowerInfoList24); |
| 106 | csr_purge_channel_power(mac, &mac->scan.channelPowerInfoList5G); |
| 107 | csr_ll_close(&mac->scan.channelPowerInfoList24); |
| 108 | csr_ll_close(&mac->scan.channelPowerInfoList5G); |
Abhishek Singh | 935e477 | 2018-11-21 14:14:10 +0530 | [diff] [blame] | 109 | ucfg_scan_psoc_set_disable(mac->psoc, REASON_SYSTEM_DOWN); |
| 110 | |
Abhishek Singh | 221cf99 | 2018-02-22 13:44:53 +0530 | [diff] [blame] | 111 | return QDF_STATUS_SUCCESS; |
| 112 | } |
Jeff Johnson | 8c3ecdd | 2018-12-05 08:48:54 -0800 | [diff] [blame] | 113 | |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 114 | QDF_STATUS csr_scan_handle_search_for_ssid(struct mac_context *mac_ctx, |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 115 | uint32_t session_id) |
| 116 | { |
| 117 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
| 118 | tScanResultHandle hBSSList = CSR_INVALID_SCANRESULT_HANDLE; |
| 119 | tCsrScanResultFilter *pScanFilter = NULL; |
Jeff Johnson | 66ee8a9 | 2018-03-17 15:24:26 -0700 | [diff] [blame] | 120 | struct csr_roam_profile *profile; |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 121 | struct csr_roam_session *session; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 122 | |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 123 | session = CSR_GET_SESSION(mac_ctx, session_id); |
| 124 | if (!session) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 125 | sme_err("session %d not found", session_id); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 126 | return QDF_STATUS_E_FAILURE; |
| 127 | } |
| 128 | profile = session->scan_info.profile; |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 129 | sme_debug("session %d", session_id); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 130 | do { |
Will Huang | ea70106 | 2018-06-26 14:03:18 +0800 | [diff] [blame] | 131 | /* If this scan is for HDD reassociate */ |
| 132 | if (mac_ctx->roam.neighborRoamInfo[session_id]. |
| 133 | uOsRequestedHandoff) { |
| 134 | /* notify LFR state m/c */ |
| 135 | status = csr_neighbor_roam_sssid_scan_done |
| 136 | (mac_ctx, session_id, QDF_STATUS_SUCCESS); |
| 137 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 138 | csr_neighbor_roam_start_lfr_scan(mac_ctx, |
| 139 | session_id); |
| 140 | status = QDF_STATUS_SUCCESS; |
| 141 | break; |
| 142 | } |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 143 | /* |
| 144 | * If there is roam command waiting, ignore this roam because |
| 145 | * the newer roam command is the one to execute |
| 146 | */ |
| 147 | if (csr_is_roam_command_waiting_for_session(mac_ctx, session_id)) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 148 | sme_warn("aborts because roam command waiting"); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 149 | break; |
| 150 | } |
Jeff Johnson | 038efe7 | 2019-03-18 13:39:31 -0700 | [diff] [blame] | 151 | if (!profile) |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 152 | break; |
| 153 | pScanFilter = qdf_mem_malloc(sizeof(tCsrScanResultFilter)); |
Jeff Johnson | 038efe7 | 2019-03-18 13:39:31 -0700 | [diff] [blame] | 154 | if (!pScanFilter) { |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 155 | status = QDF_STATUS_E_NOMEM; |
| 156 | break; |
| 157 | } |
| 158 | status = csr_roam_prepare_filter_from_profile(mac_ctx, profile, |
| 159 | pScanFilter); |
| 160 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 161 | break; |
| 162 | status = csr_scan_get_result(mac_ctx, pScanFilter, &hBSSList); |
| 163 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 164 | break; |
| 165 | if (mac_ctx->roam.roamSession[session_id].connectState == |
| 166 | eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTING) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 167 | sme_err("upper layer issued disconnetion"); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 168 | status = QDF_STATUS_E_FAILURE; |
| 169 | break; |
| 170 | } |
| 171 | status = csr_roam_issue_connect(mac_ctx, session_id, profile, |
| 172 | hBSSList, eCsrHddIssued, |
| 173 | session->scan_info.roam_id, |
| 174 | true, true); |
Will Huang | 8e8d300 | 2018-05-11 10:48:03 +0800 | [diff] [blame] | 175 | hBSSList = CSR_INVALID_SCANRESULT_HANDLE; |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 176 | } while (0); |
| 177 | |
| 178 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 179 | if (CSR_INVALID_SCANRESULT_HANDLE != hBSSList) { |
| 180 | csr_scan_result_purge(mac_ctx, hBSSList); |
| 181 | } |
| 182 | /* We haven't done anything to this profile */ |
| 183 | csr_roam_call_callback(mac_ctx, session_id, NULL, |
| 184 | session->scan_info.roam_id, |
| 185 | eCSR_ROAM_ASSOCIATION_FAILURE, |
| 186 | eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE); |
| 187 | } |
| 188 | if (pScanFilter) { |
| 189 | csr_free_scan_filter(mac_ctx, pScanFilter); |
| 190 | qdf_mem_free(pScanFilter); |
| 191 | } |
| 192 | return status; |
| 193 | } |
| 194 | |
Vignesh Viswanathan | 014096a | 2017-12-07 01:24:44 +0530 | [diff] [blame] | 195 | /** |
| 196 | * csr_handle_fils_scan_for_ssid_failure() - Checks and fills FILS seq number |
| 197 | * in roam_info structure to send to hdd |
| 198 | * |
| 199 | * @roam_profile: Pointer to current roam_profile structure |
| 200 | * @roam_info: Pointer to roam_info strucure to be filled |
| 201 | * |
| 202 | * Return: true for FILS connection else false |
| 203 | */ |
| 204 | #ifdef WLAN_FEATURE_FILS_SK |
Jeff Johnson | 66ee8a9 | 2018-03-17 15:24:26 -0700 | [diff] [blame] | 205 | static bool |
| 206 | csr_handle_fils_scan_for_ssid_failure(struct csr_roam_profile *roam_profile, |
| 207 | struct csr_roam_info *roam_info) |
Vignesh Viswanathan | 014096a | 2017-12-07 01:24:44 +0530 | [diff] [blame] | 208 | { |
| 209 | if (roam_profile && roam_profile->fils_con_info && |
| 210 | roam_profile->fils_con_info->is_fils_connection) { |
| 211 | sme_debug("send roam_info for FILS connection failure, seq %d", |
| 212 | roam_profile->fils_con_info->sequence_number); |
| 213 | roam_info->is_fils_connection = true; |
| 214 | roam_info->fils_seq_num = |
| 215 | roam_profile->fils_con_info->sequence_number; |
| 216 | return true; |
| 217 | } |
| 218 | |
| 219 | return false; |
| 220 | } |
| 221 | #else |
Jeff Johnson | 66ee8a9 | 2018-03-17 15:24:26 -0700 | [diff] [blame] | 222 | static bool |
| 223 | csr_handle_fils_scan_for_ssid_failure(struct csr_roam_profile *roam_profile, |
| 224 | struct csr_roam_info *roam_info) |
Vignesh Viswanathan | 014096a | 2017-12-07 01:24:44 +0530 | [diff] [blame] | 225 | { |
| 226 | return false; |
| 227 | } |
| 228 | #endif |
| 229 | |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 230 | QDF_STATUS csr_scan_handle_search_for_ssid_failure(struct mac_context *mac_ctx, |
Jeff Johnson | 8c3ecdd | 2018-12-05 08:48:54 -0800 | [diff] [blame] | 231 | uint32_t session_id) |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 232 | { |
| 233 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Jeff Johnson | 66ee8a9 | 2018-03-17 15:24:26 -0700 | [diff] [blame] | 234 | struct csr_roam_profile *profile; |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 235 | struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, session_id); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 236 | eCsrRoamResult roam_result; |
Vignesh Viswanathan | 014096a | 2017-12-07 01:24:44 +0530 | [diff] [blame] | 237 | struct csr_roam_info *roam_info = NULL; |
| 238 | struct tag_csrscan_result *scan_result; |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 239 | |
| 240 | if (!session) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 241 | sme_err("session %d not found", session_id); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 242 | return QDF_STATUS_E_FAILURE; |
| 243 | } |
Will Huang | ea70106 | 2018-06-26 14:03:18 +0800 | [diff] [blame] | 244 | |
| 245 | /* If this scan is for HDD reassociate */ |
| 246 | if (mac_ctx->roam.neighborRoamInfo[session_id].uOsRequestedHandoff) { |
| 247 | /* notify LFR state m/c */ |
| 248 | status = csr_neighbor_roam_sssid_scan_done |
| 249 | (mac_ctx, session_id, QDF_STATUS_E_FAILURE); |
| 250 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 251 | csr_neighbor_roam_start_lfr_scan(mac_ctx, session_id); |
| 252 | return QDF_STATUS_SUCCESS; |
| 253 | } |
| 254 | |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 255 | profile = session->scan_info.profile; |
| 256 | |
| 257 | /* |
| 258 | * Check whether it is for start ibss. No need to do anything if it |
| 259 | * is a JOIN request |
| 260 | */ |
| 261 | if (profile && CSR_IS_START_IBSS(profile)) { |
| 262 | status = csr_roam_issue_connect(mac_ctx, session_id, profile, NULL, |
| 263 | eCsrHddIssued, session->scan_info.roam_id, |
| 264 | true, true); |
| 265 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 266 | sme_err("failed to issue startIBSS, session_id %d status: 0x%08X roam id %d", |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 267 | session_id, status, session->scan_info.roam_id); |
| 268 | csr_roam_call_callback(mac_ctx, session_id, NULL, |
| 269 | session->scan_info.roam_id, eCSR_ROAM_FAILED, |
| 270 | eCSR_ROAM_RESULT_FAILURE); |
| 271 | } |
| 272 | return status; |
| 273 | } |
| 274 | roam_result = eCSR_ROAM_RESULT_FAILURE; |
Jeff Johnson | 038efe7 | 2019-03-18 13:39:31 -0700 | [diff] [blame] | 275 | if (profile && csr_is_bss_type_ibss(profile->BSSType)) { |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 276 | roam_result = eCSR_ROAM_RESULT_IBSS_START_FAILED; |
| 277 | goto roam_completion; |
| 278 | } |
Vignesh Viswanathan | 014096a | 2017-12-07 01:24:44 +0530 | [diff] [blame] | 279 | |
| 280 | roam_info = qdf_mem_malloc(sizeof(struct csr_roam_info)); |
Arif Hussain | 0ef7708 | 2018-10-10 16:42:53 -0700 | [diff] [blame] | 281 | if (!roam_info) |
Vignesh Viswanathan | 014096a | 2017-12-07 01:24:44 +0530 | [diff] [blame] | 282 | goto roam_completion; |
Vignesh Viswanathan | 014096a | 2017-12-07 01:24:44 +0530 | [diff] [blame] | 283 | |
| 284 | if (session->scan_info.roambssentry) { |
| 285 | scan_result = GET_BASE_ADDR(session->scan_info.roambssentry, |
| 286 | struct tag_csrscan_result, Link); |
| 287 | roam_info->pBssDesc = &scan_result->Result.BssDescriptor; |
| 288 | } |
| 289 | roam_info->statusCode = session->joinFailStatusCode.statusCode; |
| 290 | roam_info->reasonCode = session->joinFailStatusCode.reasonCode; |
| 291 | |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 292 | /* Only indicate assoc_completion if we indicate assoc_start. */ |
| 293 | if (session->bRefAssocStartCnt > 0) { |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 294 | session->bRefAssocStartCnt--; |
Jeff Johnson | eddf544 | 2017-10-04 10:55:53 -0700 | [diff] [blame] | 295 | csr_roam_call_callback(mac_ctx, session_id, roam_info, |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 296 | session->scan_info.roam_id, |
| 297 | eCSR_ROAM_ASSOCIATION_COMPLETION, |
| 298 | eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE); |
| 299 | } else { |
Vignesh Viswanathan | 014096a | 2017-12-07 01:24:44 +0530 | [diff] [blame] | 300 | if (!csr_handle_fils_scan_for_ssid_failure( |
| 301 | profile, roam_info)) { |
| 302 | qdf_mem_free(roam_info); |
| 303 | roam_info = NULL; |
| 304 | } |
| 305 | csr_roam_call_callback(mac_ctx, session_id, roam_info, |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 306 | session->scan_info.roam_id, |
| 307 | eCSR_ROAM_ASSOCIATION_FAILURE, |
| 308 | eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE); |
| 309 | } |
Vignesh Viswanathan | 014096a | 2017-12-07 01:24:44 +0530 | [diff] [blame] | 310 | |
| 311 | if (roam_info) |
| 312 | qdf_mem_free(roam_info); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 313 | roam_completion: |
| 314 | csr_roam_completion(mac_ctx, session_id, NULL, NULL, roam_result, |
| 315 | false); |
| 316 | return status; |
| 317 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 318 | |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 319 | QDF_STATUS csr_scan_result_purge(struct mac_context *mac, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 320 | tScanResultHandle hScanList) |
| 321 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 322 | QDF_STATUS status = QDF_STATUS_E_INVAL; |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 323 | struct scan_result_list *pScanList = |
| 324 | (struct scan_result_list *) hScanList; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 325 | |
| 326 | if (pScanList) { |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 327 | status = csr_ll_scan_purge_result(mac, &pScanList->List); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 328 | csr_ll_close(&pScanList->List); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 329 | qdf_mem_free(pScanList); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 330 | } |
| 331 | return status; |
| 332 | } |
| 333 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 334 | /* Add the channel to the occupiedChannels array */ |
Jianmin Zhu | 8d7afc2 | 2019-04-17 13:10:22 +0800 | [diff] [blame] | 335 | static void csr_add_to_occupied_channels(struct mac_context *mac, |
| 336 | uint8_t ch, |
| 337 | uint8_t sessionId, |
| 338 | struct csr_channel *occupied_ch, |
| 339 | bool is_init_list) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 340 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 341 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 342 | uint8_t num_occupied_ch = occupied_ch->numChannels; |
| 343 | uint8_t *occupied_ch_lst = occupied_ch->channelList; |
| 344 | |
Kapil Gupta | 0a2477b | 2016-08-23 18:00:34 +0530 | [diff] [blame] | 345 | if (is_init_list) |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 346 | mac->scan.roam_candidate_count[sessionId]++; |
Kapil Gupta | 0a2477b | 2016-08-23 18:00:34 +0530 | [diff] [blame] | 347 | |
| 348 | if (csr_is_channel_present_in_list(occupied_ch_lst, |
| 349 | num_occupied_ch, ch)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 350 | return; |
| 351 | |
| 352 | status = csr_add_to_channel_list_front(occupied_ch_lst, |
| 353 | num_occupied_ch, ch); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 354 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 355 | occupied_ch->numChannels++; |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 356 | sme_debug("Added channel %d to the list (count=%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 357 | ch, occupied_ch->numChannels); |
| 358 | if (occupied_ch->numChannels > |
| 359 | CSR_BG_SCAN_OCCUPIED_CHANNEL_LIST_LEN) |
| 360 | occupied_ch->numChannels = |
| 361 | CSR_BG_SCAN_OCCUPIED_CHANNEL_LIST_LEN; |
| 362 | } |
| 363 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 364 | |
| 365 | /* Put the BSS into the scan result list */ |
| 366 | /* pIes can not be NULL */ |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 367 | static void csr_scan_add_result(struct mac_context *mac_ctx, |
Abhishek Singh | f723e3d | 2018-02-20 18:02:37 +0530 | [diff] [blame] | 368 | struct tag_csrscan_result *pResult) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 369 | { |
Abhishek Singh | 6f56d21 | 2017-04-12 14:31:57 +0530 | [diff] [blame] | 370 | qdf_nbuf_t buf; |
| 371 | uint8_t *data; |
| 372 | struct mgmt_rx_event_params rx_param = {0}; |
| 373 | struct wlan_frame_hdr *hdr; |
| 374 | struct wlan_bcn_frame *fixed_frame; |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 375 | uint32_t buf_len, i; |
Abhishek Singh | 6f56d21 | 2017-04-12 14:31:57 +0530 | [diff] [blame] | 376 | tSirBssDescription *bss_desc; |
| 377 | enum mgmt_frame_type frm_type = MGMT_BEACON; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 378 | |
Abhishek Singh | f723e3d | 2018-02-20 18:02:37 +0530 | [diff] [blame] | 379 | if (!pResult) { |
| 380 | sme_err("pResult is null"); |
| 381 | return; |
| 382 | } |
| 383 | |
Abhishek Singh | 6f56d21 | 2017-04-12 14:31:57 +0530 | [diff] [blame] | 384 | bss_desc = &pResult->Result.BssDescriptor; |
| 385 | if (bss_desc->fProbeRsp) |
| 386 | frm_type = MGMT_PROBE_RESP; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 387 | |
Abhishek Singh | 6f56d21 | 2017-04-12 14:31:57 +0530 | [diff] [blame] | 388 | rx_param.pdev_id = 0; |
| 389 | rx_param.channel = bss_desc->channelId; |
| 390 | rx_param.rssi = bss_desc->rssi; |
| 391 | rx_param.tsf_delta = bss_desc->tsf_delta; |
Abhishek Singh | f723e3d | 2018-02-20 18:02:37 +0530 | [diff] [blame] | 392 | |
Abhishek Singh | f05b0cb6 | 2018-02-20 18:06:13 +0530 | [diff] [blame] | 393 | /* Set all per chain rssi as invalid */ |
| 394 | for (i = 0; i < WLAN_MGMT_TXRX_HOST_MAX_ANTENNA; i++) |
| 395 | rx_param.rssi_ctl[i] = WLAN_INVALID_PER_CHAIN_RSSI; |
| 396 | |
Abhishek Singh | 6f56d21 | 2017-04-12 14:31:57 +0530 | [diff] [blame] | 397 | buf_len = GET_IE_LEN_IN_BSS(bss_desc->length) + |
| 398 | + offsetof(struct wlan_bcn_frame, ie) + sizeof(*hdr); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 399 | |
Abhishek Singh | 6f56d21 | 2017-04-12 14:31:57 +0530 | [diff] [blame] | 400 | buf = qdf_nbuf_alloc(NULL, qdf_roundup(buf_len, 4), |
| 401 | 0, 4, false); |
Arif Hussain | 0ef7708 | 2018-10-10 16:42:53 -0700 | [diff] [blame] | 402 | if (!buf) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 403 | return; |
Arif Hussain | 0ef7708 | 2018-10-10 16:42:53 -0700 | [diff] [blame] | 404 | |
Abhishek Singh | 6f56d21 | 2017-04-12 14:31:57 +0530 | [diff] [blame] | 405 | qdf_nbuf_put_tail(buf, buf_len); |
| 406 | qdf_nbuf_set_protocol(buf, ETH_P_CONTROL); |
| 407 | |
| 408 | data = qdf_nbuf_data(buf); |
| 409 | hdr = (struct wlan_frame_hdr *) data; |
| 410 | qdf_mem_copy(hdr->i_addr3, bss_desc->bssId, QDF_MAC_ADDR_SIZE); |
| 411 | qdf_mem_copy(hdr->i_addr2, bss_desc->bssId, QDF_MAC_ADDR_SIZE); |
| 412 | qdf_mem_copy(hdr->i_seq, |
| 413 | &bss_desc->seq_ctrl, sizeof(uint16_t)); |
| 414 | |
| 415 | data += sizeof(*hdr); |
| 416 | fixed_frame = (struct wlan_bcn_frame *)data; |
| 417 | qdf_mem_copy(fixed_frame->timestamp, |
| 418 | bss_desc->timeStamp, 8); |
| 419 | fixed_frame->beacon_interval = bss_desc->beaconInterval; |
| 420 | fixed_frame->capability.value = bss_desc->capabilityInfo; |
| 421 | data += offsetof(struct wlan_bcn_frame, ie); |
| 422 | |
| 423 | qdf_mem_copy(data, bss_desc->ieFields, |
| 424 | GET_IE_LEN_IN_BSS(bss_desc->length)); |
Abhishek Singh | cd131ae | 2019-04-09 15:05:17 +0530 | [diff] [blame] | 425 | wlan_scan_process_bcn_probe_rx_sync(mac_ctx->psoc, buf, &rx_param, |
| 426 | frm_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 427 | } |
| 428 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 429 | /* |
| 430 | * NOTE: This routine is being added to make |
| 431 | * sure that scan results are not being flushed |
| 432 | * while roaming. If the scan results are flushed, |
| 433 | * we are unable to recover from |
| 434 | * csr_roam_roaming_state_disassoc_rsp_processor. |
| 435 | * If it is needed to remove this routine, |
| 436 | * first ensure that we recover gracefully from |
| 437 | * csr_roam_roaming_state_disassoc_rsp_processor if |
| 438 | * csr_scan_get_result returns with a failure because |
| 439 | * of not being able to find the roaming BSS. |
| 440 | */ |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 441 | static bool csr_scan_flush_denied(struct mac_context *mac) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 442 | { |
| 443 | uint8_t sessionId; |
| 444 | |
Dustin Brown | ad06be6 | 2019-02-04 14:52:56 -0800 | [diff] [blame] | 445 | for (sessionId = 0; sessionId < WLAN_MAX_VDEVS; sessionId++) { |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 446 | if (CSR_IS_SESSION_VALID(mac, sessionId)) { |
| 447 | if (csr_neighbor_middle_of_roaming(mac, sessionId)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 448 | return 1; |
| 449 | } |
| 450 | } |
| 451 | return 0; |
| 452 | } |
| 453 | |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 454 | static bool csr_scan_save_bss_description(struct mac_context *mac, |
Jeff Johnson | 8c3ecdd | 2018-12-05 08:48:54 -0800 | [diff] [blame] | 455 | tSirBssDescription *pBSSDescription) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 456 | { |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 457 | struct tag_csrscan_result *pCsrBssDescription = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 458 | uint32_t cbBSSDesc; |
| 459 | uint32_t cbAllocated; |
| 460 | |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 461 | /* figure out how big the BSS description is (the BSSDesc->length does |
| 462 | * NOT include the size of the length field itself). |
| 463 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 464 | cbBSSDesc = pBSSDescription->length + sizeof(pBSSDescription->length); |
| 465 | |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 466 | cbAllocated = sizeof(struct tag_csrscan_result) + cbBSSDesc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 467 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 468 | pCsrBssDescription = qdf_mem_malloc(cbAllocated); |
Arif Hussain | 0ef7708 | 2018-10-10 16:42:53 -0700 | [diff] [blame] | 469 | if (!pCsrBssDescription) |
Abhishek Singh | a92cf1e | 2017-11-02 17:04:11 +0530 | [diff] [blame] | 470 | return false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 471 | |
Abhishek Singh | a92cf1e | 2017-11-02 17:04:11 +0530 | [diff] [blame] | 472 | pCsrBssDescription->AgingCount = |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 473 | (int32_t) mac->roam.configParam.agingCount; |
Abhishek Singh | a92cf1e | 2017-11-02 17:04:11 +0530 | [diff] [blame] | 474 | sme_debug( |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 475 | "Set Aging Count = %d for BSS " QDF_MAC_ADDR_STR " ", |
Abhishek Singh | a92cf1e | 2017-11-02 17:04:11 +0530 | [diff] [blame] | 476 | pCsrBssDescription->AgingCount, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 477 | QDF_MAC_ADDR_ARRAY(pCsrBssDescription->Result.BssDescriptor. |
Abhishek Singh | a92cf1e | 2017-11-02 17:04:11 +0530 | [diff] [blame] | 478 | bssId)); |
| 479 | qdf_mem_copy(&pCsrBssDescription->Result.BssDescriptor, |
| 480 | pBSSDescription, cbBSSDesc); |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 481 | csr_scan_add_result(mac, pCsrBssDescription); |
| 482 | csr_free_scan_result_entry(mac, pCsrBssDescription); |
Abhishek Singh | a92cf1e | 2017-11-02 17:04:11 +0530 | [diff] [blame] | 483 | |
| 484 | return true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 485 | } |
| 486 | |
| 487 | /* Append a Bss Description... */ |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 488 | bool csr_scan_append_bss_description(struct mac_context *mac, |
Abhishek Singh | f723e3d | 2018-02-20 18:02:37 +0530 | [diff] [blame] | 489 | tSirBssDescription *pSirBssDescription) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 490 | { |
Jeff Johnson | 8c3ecdd | 2018-12-05 08:48:54 -0800 | [diff] [blame] | 491 | return csr_scan_save_bss_description(mac, pSirBssDescription); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 492 | } |
| 493 | |
Jeff Johnson | 8c3ecdd | 2018-12-05 08:48:54 -0800 | [diff] [blame] | 494 | static void csr_purge_channel_power(struct mac_context *mac, |
| 495 | tDblLinkList *pChannelList) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 496 | { |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 497 | struct csr_channel_powerinfo *pChannelSet; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 498 | tListElem *pEntry; |
| 499 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 500 | /* |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 501 | * Remove the channel sets from the learned list and put them |
| 502 | * in the free list |
| 503 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 504 | while ((pEntry = csr_ll_remove_head(pChannelList, |
| 505 | LL_ACCESS_NOLOCK)) != NULL) { |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 506 | pChannelSet = GET_BASE_ADDR(pEntry, |
| 507 | struct csr_channel_powerinfo, link); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 508 | if (pChannelSet) |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 509 | qdf_mem_free(pChannelSet); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 510 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 511 | } |
| 512 | |
| 513 | /* |
| 514 | * Save the channelList into the ultimate storage as the final stage of channel |
| 515 | * Input: pCountryInfo -- the country code (e.g. "USI"), channel list, and power |
| 516 | * limit are all stored inside this data structure |
| 517 | */ |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 518 | QDF_STATUS csr_save_to_channel_power2_g_5_g(struct mac_context *mac, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 519 | uint32_t tableSize, |
| 520 | tSirMacChanInfo *channelTable) |
| 521 | { |
| 522 | uint32_t i = tableSize / sizeof(tSirMacChanInfo); |
| 523 | tSirMacChanInfo *pChannelInfo; |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 524 | struct csr_channel_powerinfo *pChannelSet; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 525 | bool f2GHzInfoFound = false; |
| 526 | bool f2GListPurged = false, f5GListPurged = false; |
| 527 | |
| 528 | pChannelInfo = channelTable; |
| 529 | /* atleast 3 bytes have to be remaining -- from "countryString" */ |
| 530 | while (i--) { |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 531 | pChannelSet = qdf_mem_malloc(sizeof(struct csr_channel_powerinfo)); |
Jeff Johnson | 038efe7 | 2019-03-18 13:39:31 -0700 | [diff] [blame] | 532 | if (!pChannelSet) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 533 | pChannelInfo++; |
| 534 | continue; |
| 535 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 536 | pChannelSet->firstChannel = pChannelInfo->firstChanNum; |
| 537 | pChannelSet->numChannels = pChannelInfo->numChannels; |
| 538 | /* |
| 539 | * Now set the inter-channel offset based on the frequency band |
| 540 | * the channel set lies in |
| 541 | */ |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 542 | if ((WLAN_REG_IS_24GHZ_CH(pChannelSet->firstChannel)) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 543 | ((pChannelSet->firstChannel + |
| 544 | (pChannelSet->numChannels - 1)) <= |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 545 | WLAN_REG_MAX_24GHZ_CH_NUM)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 546 | pChannelSet->interChannelOffset = 1; |
| 547 | f2GHzInfoFound = true; |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 548 | } else if ((WLAN_REG_IS_5GHZ_CH(pChannelSet->firstChannel)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 549 | && ((pChannelSet->firstChannel + |
| 550 | ((pChannelSet->numChannels - 1) * 4)) <= |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 551 | WLAN_REG_MAX_5GHZ_CH_NUM)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 552 | pChannelSet->interChannelOffset = 4; |
| 553 | f2GHzInfoFound = false; |
| 554 | } else { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 555 | sme_warn("Invalid Channel %d Present in Country IE", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 556 | pChannelSet->firstChannel); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 557 | qdf_mem_free(pChannelSet); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 558 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 559 | } |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 560 | pChannelSet->txPower = QDF_MIN(pChannelInfo->maxTxPower, |
Wu Gao | 5f76408 | 2019-01-04 15:54:38 +0800 | [diff] [blame] | 561 | mac->mlme_cfg->power.max_tx_power); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 562 | if (f2GHzInfoFound) { |
| 563 | if (!f2GListPurged) { |
| 564 | /* purge previous results if found new */ |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 565 | csr_purge_channel_power(mac, |
| 566 | &mac->scan. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 567 | channelPowerInfoList24); |
| 568 | f2GListPurged = true; |
| 569 | } |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 570 | if (CSR_IS_OPERATING_BG_BAND(mac)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 571 | /* add to the list of 2.4 GHz channel sets */ |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 572 | csr_ll_insert_tail(&mac->scan. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 573 | channelPowerInfoList24, |
| 574 | &pChannelSet->link, |
| 575 | LL_ACCESS_LOCK); |
| 576 | } else { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 577 | sme_debug( |
| 578 | "Adding 11B/G ch in 11A. 1st ch %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 579 | pChannelSet->firstChannel); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 580 | qdf_mem_free(pChannelSet); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 581 | } |
| 582 | } else { |
| 583 | /* 5GHz info found */ |
| 584 | if (!f5GListPurged) { |
| 585 | /* purge previous results if found new */ |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 586 | csr_purge_channel_power(mac, |
| 587 | &mac->scan. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 588 | channelPowerInfoList5G); |
| 589 | f5GListPurged = true; |
| 590 | } |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 591 | if (CSR_IS_OPERATING_A_BAND(mac)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 592 | /* add to the list of 5GHz channel sets */ |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 593 | csr_ll_insert_tail(&mac->scan. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 594 | channelPowerInfoList5G, |
| 595 | &pChannelSet->link, |
| 596 | LL_ACCESS_LOCK); |
| 597 | } else { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 598 | sme_debug( |
| 599 | "Adding 11A ch in B/G. 1st ch %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 600 | pChannelSet->firstChannel); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 601 | qdf_mem_free(pChannelSet); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 602 | } |
| 603 | } |
| 604 | pChannelInfo++; /* move to next entry */ |
| 605 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 606 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 607 | } |
| 608 | |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 609 | void csr_apply_power2_current(struct mac_context *mac) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 610 | { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 611 | sme_debug("Updating Cfg with power settings"); |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 612 | csr_save_tx_power_to_cfg(mac, &mac->scan.channelPowerInfoList24, |
gaurank kathpalia | 3d2e385 | 2018-10-03 22:03:23 +0530 | [diff] [blame] | 613 | BAND_2G); |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 614 | csr_save_tx_power_to_cfg(mac, &mac->scan.channelPowerInfoList5G, |
gaurank kathpalia | 3d2e385 | 2018-10-03 22:03:23 +0530 | [diff] [blame] | 615 | BAND_5G); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 616 | } |
| 617 | |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 618 | void csr_apply_channel_power_info_to_fw(struct mac_context *mac_ctx, |
Jeff Johnson | 8c3ecdd | 2018-12-05 08:48:54 -0800 | [diff] [blame] | 619 | struct csr_channel *ch_lst, |
| 620 | uint8_t *countryCode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 621 | { |
| 622 | int i; |
| 623 | uint8_t num_ch = 0; |
| 624 | uint8_t tempNumChannels = 0; |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 625 | struct csr_channel tmp_ch_lst; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 626 | |
| 627 | if (ch_lst->numChannels) { |
Srinivas Girigowda | 9823453 | 2019-03-11 15:31:12 -0700 | [diff] [blame] | 628 | tempNumChannels = QDF_MIN(ch_lst->numChannels, |
Wu Gao | 0821b0d | 2019-01-11 17:31:11 +0800 | [diff] [blame] | 629 | CFG_VALID_CHANNEL_LIST_LEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 630 | for (i = 0; i < tempNumChannels; i++) { |
| 631 | tmp_ch_lst.channelList[num_ch] = ch_lst->channelList[i]; |
| 632 | num_ch++; |
| 633 | } |
| 634 | tmp_ch_lst.numChannels = num_ch; |
| 635 | /* Store the channel+power info in the global place: Cfg */ |
| 636 | csr_apply_power2_current(mac_ctx); |
| 637 | csr_set_cfg_valid_channel_list(mac_ctx, tmp_ch_lst.channelList, |
| 638 | tmp_ch_lst.numChannels); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 639 | } else { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 640 | sme_err("11D channel list is empty"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 641 | } |
| 642 | csr_set_cfg_country_code(mac_ctx, countryCode); |
| 643 | } |
| 644 | |
| 645 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 646 | static void csr_diag_reset_country_information(struct mac_context *mac) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 647 | { |
| 648 | |
| 649 | host_log_802_11d_pkt_type *p11dLog; |
| 650 | int Index; |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 651 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 652 | WLAN_HOST_DIAG_LOG_ALLOC(p11dLog, host_log_802_11d_pkt_type, |
| 653 | LOG_WLAN_80211D_C); |
| 654 | if (!p11dLog) |
| 655 | return; |
| 656 | |
| 657 | p11dLog->eventId = WLAN_80211D_EVENT_RESET; |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 658 | qdf_mem_copy(p11dLog->countryCode, mac->scan.countryCodeCurrent, 3); |
| 659 | p11dLog->numChannel = mac->scan.base_channels.numChannels; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 660 | if (p11dLog->numChannel <= HOST_LOG_MAX_NUM_CHANNEL) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 661 | qdf_mem_copy(p11dLog->Channels, |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 662 | mac->scan.base_channels.channelList, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 663 | p11dLog->numChannel); |
| 664 | for (Index = 0; |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 665 | Index < mac->scan.base_channels.numChannels; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 666 | Index++) { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 667 | p11dLog->TxPwr[Index] = QDF_MIN( |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 668 | mac->scan.defaultPowerTable[Index].tx_power, |
Wu Gao | 5f76408 | 2019-01-04 15:54:38 +0800 | [diff] [blame] | 669 | mac->mlme_cfg->power.max_tx_power); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 670 | } |
| 671 | } |
Abhinav Kumar | d4d6eb7 | 2018-12-04 20:30:37 +0530 | [diff] [blame] | 672 | if (!mac->mlme_cfg->gen.enabled_11d) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 673 | p11dLog->supportMultipleDomain = WLAN_80211D_DISABLED; |
| 674 | else |
| 675 | p11dLog->supportMultipleDomain = |
| 676 | WLAN_80211D_SUPPORT_MULTI_DOMAIN; |
| 677 | WLAN_HOST_DIAG_LOG_REPORT(p11dLog); |
| 678 | } |
| 679 | #endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */ |
| 680 | |
| 681 | /** |
| 682 | * csr_apply_channel_power_info_wrapper() - sends channel info to fw |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 683 | * @mac: main MAC data structure |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 684 | * |
| 685 | * This function sends the channel power info to firmware |
| 686 | * |
| 687 | * Return: none |
| 688 | */ |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 689 | void csr_apply_channel_power_info_wrapper(struct mac_context *mac) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 690 | { |
| 691 | |
| 692 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 693 | csr_diag_reset_country_information(mac); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 694 | #endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */ |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 695 | csr_prune_channel_list_for_mode(mac, &mac->scan.base_channels); |
| 696 | csr_save_channel_power_for_band(mac, false); |
| 697 | csr_save_channel_power_for_band(mac, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 698 | /* apply the channel list, power settings, and the country code. */ |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 699 | csr_apply_channel_power_info_to_fw(mac, |
| 700 | &mac->scan.base_channels, mac->scan.countryCodeCurrent); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 701 | /* clear the 11d channel list */ |
hangtian | 127c953 | 2019-01-12 13:29:07 +0800 | [diff] [blame] | 702 | qdf_mem_zero(&mac->scan.channels11d, sizeof(mac->scan.channels11d)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 703 | } |
| 704 | |
Qiwei Cai | ba95ce6 | 2018-08-23 10:43:16 +0800 | [diff] [blame] | 705 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 706 | /* caller allocated memory for pNumChn and pChnPowerInfo */ |
| 707 | /* As input, *pNumChn has the size of the array of pChnPowerInfo */ |
| 708 | /* Upon return, *pNumChn has the number of channels assigned. */ |
Jeff Johnson | 8c3ecdd | 2018-12-05 08:48:54 -0800 | [diff] [blame] | 709 | static void csr_get_channel_power_info(struct mac_context *mac, |
| 710 | tDblLinkList *list, |
Jeff Johnson | 00fa67d | 2016-10-14 08:07:36 -0700 | [diff] [blame] | 711 | uint32_t *num_ch, |
| 712 | struct channel_power *chn_pwr_info) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 713 | { |
| 714 | tListElem *entry; |
| 715 | uint32_t chn_idx = 0, idx; |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 716 | struct csr_channel_powerinfo *ch_set; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 717 | |
| 718 | /* Get 2.4Ghz first */ |
| 719 | entry = csr_ll_peek_head(list, LL_ACCESS_LOCK); |
| 720 | while (entry && (chn_idx < *num_ch)) { |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 721 | ch_set = GET_BASE_ADDR(entry, |
| 722 | struct csr_channel_powerinfo, link); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 723 | for (idx = 0; (idx < ch_set->numChannels) |
| 724 | && (chn_idx < *num_ch); idx++) { |
Amar Singhal | a297bfa | 2015-10-15 15:07:29 -0700 | [diff] [blame] | 725 | chn_pwr_info[chn_idx].chan_num = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 726 | (uint8_t) (ch_set->firstChannel |
| 727 | + (idx * ch_set->interChannelOffset)); |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 728 | chn_pwr_info[chn_idx++].tx_power = ch_set->txPower; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 729 | } |
| 730 | entry = csr_ll_next(list, entry, LL_ACCESS_LOCK); |
| 731 | } |
| 732 | *num_ch = chn_idx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 733 | } |
| 734 | |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 735 | static void csr_diag_apply_country_info(struct mac_context *mac_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 736 | { |
| 737 | host_log_802_11d_pkt_type *p11dLog; |
Wu Gao | 0821b0d | 2019-01-11 17:31:11 +0800 | [diff] [blame] | 738 | struct channel_power chnPwrInfo[CFG_VALID_CHANNEL_LIST_LEN]; |
| 739 | uint32_t nChnInfo = CFG_VALID_CHANNEL_LIST_LEN, nTmp; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 740 | |
| 741 | WLAN_HOST_DIAG_LOG_ALLOC(p11dLog, host_log_802_11d_pkt_type, |
| 742 | LOG_WLAN_80211D_C); |
| 743 | if (!p11dLog) |
| 744 | return; |
| 745 | |
| 746 | p11dLog->eventId = WLAN_80211D_EVENT_COUNTRY_SET; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 747 | qdf_mem_copy(p11dLog->countryCode, mac_ctx->scan.countryCode11d, 3); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 748 | p11dLog->numChannel = mac_ctx->scan.channels11d.numChannels; |
| 749 | if (p11dLog->numChannel > HOST_LOG_MAX_NUM_CHANNEL) |
| 750 | goto diag_end; |
| 751 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 752 | qdf_mem_copy(p11dLog->Channels, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 753 | mac_ctx->scan.channels11d.channelList, |
| 754 | p11dLog->numChannel); |
| 755 | csr_get_channel_power_info(mac_ctx, |
| 756 | &mac_ctx->scan.channelPowerInfoList24, |
| 757 | &nChnInfo, chnPwrInfo); |
| 758 | nTmp = nChnInfo; |
Wu Gao | 0821b0d | 2019-01-11 17:31:11 +0800 | [diff] [blame] | 759 | nChnInfo = CFG_VALID_CHANNEL_LIST_LEN - nTmp; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 760 | csr_get_channel_power_info(mac_ctx, |
| 761 | &mac_ctx->scan.channelPowerInfoList5G, |
| 762 | &nChnInfo, &chnPwrInfo[nTmp]); |
| 763 | for (nTmp = 0; nTmp < p11dLog->numChannel; nTmp++) { |
| 764 | for (nChnInfo = 0; |
Wu Gao | 0821b0d | 2019-01-11 17:31:11 +0800 | [diff] [blame] | 765 | nChnInfo < CFG_VALID_CHANNEL_LIST_LEN; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 766 | nChnInfo++) { |
| 767 | if (p11dLog->Channels[nTmp] == |
Amar Singhal | a297bfa | 2015-10-15 15:07:29 -0700 | [diff] [blame] | 768 | chnPwrInfo[nChnInfo].chan_num) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 769 | p11dLog->TxPwr[nTmp] = |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 770 | chnPwrInfo[nChnInfo].tx_power; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 771 | break; |
| 772 | } |
| 773 | } |
| 774 | } |
| 775 | diag_end: |
Abhinav Kumar | d4d6eb7 | 2018-12-04 20:30:37 +0530 | [diff] [blame] | 776 | if (!mac_ctx->mlme_cfg->gen.enabled_11d) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 777 | p11dLog->supportMultipleDomain = WLAN_80211D_DISABLED; |
| 778 | else |
| 779 | p11dLog->supportMultipleDomain = |
| 780 | WLAN_80211D_SUPPORT_MULTI_DOMAIN; |
| 781 | WLAN_HOST_DIAG_LOG_REPORT(p11dLog); |
| 782 | } |
| 783 | #endif /* #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR */ |
| 784 | |
| 785 | /** |
| 786 | * csr_apply_country_information() - apply country code information |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 787 | * @mac: core MAC data structure |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 788 | * |
| 789 | * This function programs the new country code |
| 790 | * |
| 791 | * Return: none |
| 792 | */ |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 793 | void csr_apply_country_information(struct mac_context *mac) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 794 | { |
| 795 | v_REGDOMAIN_t domainId; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 796 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 797 | |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 798 | if (!wlan_reg_11d_enabled_on_host(mac->psoc)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 799 | return; |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 800 | status = csr_get_regulatory_domain_for_country(mac, |
| 801 | mac->scan.countryCode11d, &domainId, SOURCE_QUERY); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 802 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 803 | return; |
| 804 | /* Check whether we need to enforce default domain */ |
| 805 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 806 | csr_diag_apply_country_info(mac); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 807 | #endif /* #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR */ |
| 808 | |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 809 | if (mac->scan.domainIdCurrent != domainId) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 810 | return; |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 811 | if (mac->scan.domainIdCurrent != domainId) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 812 | sme_debug("Domain Changed Old %d, new %d", |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 813 | mac->scan.domainIdCurrent, domainId); |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 814 | if (domainId >= REGDOMAIN_COUNT) |
| 815 | sme_err("fail to set regId %d", domainId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 816 | } |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 817 | mac->scan.domainIdCurrent = domainId; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 818 | /* switch to active scans using this new channel list */ |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 819 | mac->scan.curScanType = eSIR_ACTIVE_SCAN; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 820 | } |
| 821 | |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 822 | void csr_save_channel_power_for_band(struct mac_context *mac, bool fill_5f) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 823 | { |
| 824 | uint32_t idx, count = 0; |
| 825 | tSirMacChanInfo *chan_info; |
| 826 | tSirMacChanInfo *ch_info_start; |
| 827 | int32_t max_ch_idx; |
| 828 | bool tmp_bool; |
| 829 | uint8_t ch = 0; |
| 830 | |
| 831 | max_ch_idx = |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 832 | (mac->scan.base_channels.numChannels < |
Wu Gao | 0821b0d | 2019-01-11 17:31:11 +0800 | [diff] [blame] | 833 | CFG_VALID_CHANNEL_LIST_LEN) ? |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 834 | mac->scan.base_channels.numChannels : |
Wu Gao | 0821b0d | 2019-01-11 17:31:11 +0800 | [diff] [blame] | 835 | CFG_VALID_CHANNEL_LIST_LEN; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 836 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 837 | chan_info = qdf_mem_malloc(sizeof(tSirMacChanInfo) * |
Wu Gao | 0821b0d | 2019-01-11 17:31:11 +0800 | [diff] [blame] | 838 | CFG_VALID_CHANNEL_LIST_LEN); |
Jeff Johnson | 038efe7 | 2019-03-18 13:39:31 -0700 | [diff] [blame] | 839 | if (!chan_info) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 840 | return; |
| 841 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 842 | ch_info_start = chan_info; |
| 843 | for (idx = 0; idx < max_ch_idx; idx++) { |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 844 | ch = mac->scan.defaultPowerTable[idx].chan_num; |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 845 | tmp_bool = (fill_5f && WLAN_REG_IS_5GHZ_CH(ch)) || |
| 846 | (!fill_5f && WLAN_REG_IS_24GHZ_CH(ch)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 847 | if (!tmp_bool) |
| 848 | continue; |
| 849 | |
Wu Gao | 0821b0d | 2019-01-11 17:31:11 +0800 | [diff] [blame] | 850 | if (count >= CFG_VALID_CHANNEL_LIST_LEN) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 851 | sme_warn("count: %d exceeded", count); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 852 | break; |
| 853 | } |
| 854 | |
| 855 | chan_info->firstChanNum = |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 856 | mac->scan.defaultPowerTable[idx].chan_num; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 857 | chan_info->numChannels = 1; |
| 858 | chan_info->maxTxPower = |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 859 | QDF_MIN(mac->scan.defaultPowerTable[idx].tx_power, |
Wu Gao | 5f76408 | 2019-01-04 15:54:38 +0800 | [diff] [blame] | 860 | mac->mlme_cfg->power.max_tx_power); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 861 | chan_info++; |
| 862 | count++; |
| 863 | } |
| 864 | if (count) { |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 865 | csr_save_to_channel_power2_g_5_g(mac, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 866 | count * sizeof(tSirMacChanInfo), ch_info_start); |
| 867 | } |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 868 | qdf_mem_free(ch_info_start); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 869 | } |
| 870 | |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 871 | bool csr_is_supported_channel(struct mac_context *mac, uint8_t channelId) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 872 | { |
| 873 | bool fRet = false; |
| 874 | uint32_t i; |
| 875 | |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 876 | for (i = 0; i < mac->scan.base_channels.numChannels; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 877 | if (channelId == |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 878 | mac->scan.base_channels.channelList[i]) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 879 | fRet = true; |
| 880 | break; |
| 881 | } |
| 882 | } |
| 883 | |
| 884 | return fRet; |
| 885 | } |
| 886 | |
| 887 | /* |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 888 | * 802.11D only: Gather 11d IE via beacon or Probe response and store them in |
| 889 | * pAdapter->channels11d |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 890 | */ |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 891 | bool csr_learn_11dcountry_information(struct mac_context *mac, |
Jeff Johnson | 8c3ecdd | 2018-12-05 08:48:54 -0800 | [diff] [blame] | 892 | tSirBssDescription *pSirBssDesc, |
| 893 | tDot11fBeaconIEs *pIes, bool fForce) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 894 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 895 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 896 | uint8_t *pCountryCodeSelected; |
| 897 | bool fRet = false; |
| 898 | v_REGDOMAIN_t domainId; |
| 899 | tDot11fBeaconIEs *pIesLocal = pIes; |
| 900 | bool useVoting = false; |
| 901 | |
Jeff Johnson | 038efe7 | 2019-03-18 13:39:31 -0700 | [diff] [blame] | 902 | if ((!pSirBssDesc) && (!pIes)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 903 | useVoting = true; |
| 904 | |
| 905 | /* check if .11d support is enabled */ |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 906 | if (!wlan_reg_11d_enabled_on_host(mac->psoc)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 907 | goto free_ie; |
| 908 | |
| 909 | if (false == useVoting) { |
| 910 | if (!pIesLocal && |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 911 | (!QDF_IS_STATUS_SUCCESS( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 912 | csr_get_parsed_bss_description_ies( |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 913 | mac, pSirBssDesc, &pIesLocal)))) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 914 | goto free_ie; |
| 915 | /* check if country information element is present */ |
| 916 | if (!pIesLocal->Country.present) |
| 917 | /* No country info */ |
| 918 | goto free_ie; |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 919 | status = csr_get_regulatory_domain_for_country(mac, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 920 | pIesLocal->Country.country, &domainId, |
Amar Singhal | a297bfa | 2015-10-15 15:07:29 -0700 | [diff] [blame] | 921 | SOURCE_QUERY); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 922 | if (QDF_IS_STATUS_SUCCESS(status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 923 | && (domainId == REGDOMAIN_WORLD)) |
| 924 | goto free_ie; |
| 925 | } /* useVoting == false */ |
| 926 | |
| 927 | if (false == useVoting) |
| 928 | pCountryCodeSelected = pIesLocal->Country.country; |
| 929 | else |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 930 | pCountryCodeSelected = mac->scan.countryCodeElected; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 931 | |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 932 | if (qdf_mem_cmp(pCountryCodeSelected, mac->scan.countryCodeCurrent, |
Amar Singhal | b6d0dc4 | 2016-10-19 09:45:05 -0700 | [diff] [blame] | 933 | CDS_COUNTRY_CODE_LEN) == 0) { |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 934 | qdf_mem_copy(mac->scan.countryCode11d, |
| 935 | mac->scan.countryCodeCurrent, |
Amar Singhal | b6d0dc4 | 2016-10-19 09:45:05 -0700 | [diff] [blame] | 936 | CDS_COUNTRY_CODE_LEN); |
Amar Singhal | 9d5b1fe | 2016-10-16 20:16:05 -0700 | [diff] [blame] | 937 | goto free_ie; |
Amar Singhal | b6d0dc4 | 2016-10-19 09:45:05 -0700 | [diff] [blame] | 938 | } |
Amar Singhal | 9d5b1fe | 2016-10-16 20:16:05 -0700 | [diff] [blame] | 939 | |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 940 | mac->reg_hint_src = SOURCE_11D; |
| 941 | status = csr_get_regulatory_domain_for_country(mac, |
Amar Singhal | a297bfa | 2015-10-15 15:07:29 -0700 | [diff] [blame] | 942 | pCountryCodeSelected, &domainId, SOURCE_11D); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 943 | if (status != QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 944 | sme_err("fail to get regId %d", domainId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 945 | fRet = false; |
| 946 | goto free_ie; |
| 947 | } |
| 948 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 949 | fRet = true; |
| 950 | free_ie: |
| 951 | if (!pIes && pIesLocal) { |
| 952 | /* locally allocated */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 953 | qdf_mem_free(pIesLocal); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 954 | } |
| 955 | return fRet; |
| 956 | } |
| 957 | |
Jeff Johnson | 8c3ecdd | 2018-12-05 08:48:54 -0800 | [diff] [blame] | 958 | static enum csr_scancomplete_nextcommand |
| 959 | csr_scan_get_next_command_state(struct mac_context *mac_ctx, |
| 960 | uint32_t session_id, |
| 961 | eCsrScanStatus scan_status, |
| 962 | uint8_t *chan) |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 963 | { |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 964 | enum csr_scancomplete_nextcommand NextCommand = eCsrNextScanNothing; |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 965 | int8_t channel; |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 966 | struct csr_roam_session *session; |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 967 | |
Krunal Soni | 35a9453 | 2018-01-09 10:54:31 -0800 | [diff] [blame] | 968 | if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) { |
| 969 | sme_err("session %d is invalid", session_id); |
| 970 | return NextCommand; |
| 971 | } |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 972 | session = CSR_GET_SESSION(mac_ctx, session_id); |
| 973 | switch (session->scan_info.scan_reason) { |
| 974 | case eCsrScanForSsid: |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 975 | sme_debug("Resp for Scan For Ssid"); |
Liangwei Dong | 1ba9948 | 2018-10-19 02:57:29 -0400 | [diff] [blame] | 976 | channel = csr_scan_get_channel_for_hw_mode_change( |
| 977 | mac_ctx, |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 978 | session_id, |
| 979 | session->scan_info.profile); |
| 980 | if ((!channel) || scan_status) { |
| 981 | NextCommand = eCsrNexteScanForSsidFailure; |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 982 | sme_err("next Scan For Ssid Failure %d %d", |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 983 | channel, scan_status); |
| 984 | } else { |
| 985 | NextCommand = eCsrNextCheckAllowConc; |
| 986 | *chan = channel; |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 987 | sme_debug("next CheckAllowConc"); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 988 | } |
| 989 | break; |
| 990 | default: |
| 991 | NextCommand = eCsrNextScanNothing; |
| 992 | break; |
| 993 | } |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 994 | sme_debug("Next Command %d", NextCommand); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 995 | return NextCommand; |
| 996 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 997 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 998 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 999 | static void |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 1000 | csr_diag_scan_complete(struct mac_context *mac_ctx, |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1001 | eCsrScanStatus scan_status) |
| 1002 | { |
| 1003 | host_log_scan_pkt_type *pScanLog = NULL; |
Abhishek Singh | 6f56d21 | 2017-04-12 14:31:57 +0530 | [diff] [blame] | 1004 | qdf_list_t *list = NULL; |
| 1005 | struct wlan_objmgr_pdev *pdev = NULL; |
| 1006 | struct scan_cache_node *cur_node = NULL; |
| 1007 | struct scan_cache_node *next_node = NULL; |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1008 | int n = 0, c = 0; |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1009 | |
| 1010 | WLAN_HOST_DIAG_LOG_ALLOC(pScanLog, |
| 1011 | host_log_scan_pkt_type, |
| 1012 | LOG_WLAN_SCAN_C); |
| 1013 | if (!pScanLog) |
| 1014 | return; |
| 1015 | |
| 1016 | pScanLog->eventId = WLAN_SCAN_EVENT_ACTIVE_SCAN_RSP; |
| 1017 | |
| 1018 | if (eCSR_SCAN_SUCCESS != scan_status) { |
| 1019 | pScanLog->status = WLAN_SCAN_STATUS_FAILURE; |
| 1020 | WLAN_HOST_DIAG_LOG_REPORT(pScanLog); |
| 1021 | return; |
| 1022 | } |
Abhishek Singh | 6f56d21 | 2017-04-12 14:31:57 +0530 | [diff] [blame] | 1023 | pdev = wlan_objmgr_get_pdev_by_id(mac_ctx->psoc, |
| 1024 | 0, WLAN_LEGACY_MAC_ID); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1025 | |
Abhishek Singh | 6f56d21 | 2017-04-12 14:31:57 +0530 | [diff] [blame] | 1026 | if (!pdev) { |
| 1027 | sme_err("pdev is NULL"); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1028 | return; |
| 1029 | } |
| 1030 | |
Abhishek Singh | 6f56d21 | 2017-04-12 14:31:57 +0530 | [diff] [blame] | 1031 | list = ucfg_scan_get_result(pdev, NULL); |
Krunal Soni | 35a9453 | 2018-01-09 10:54:31 -0800 | [diff] [blame] | 1032 | if (list) |
| 1033 | sme_debug("num_entries %d", qdf_list_size(list)); |
| 1034 | if (!list || (list && !qdf_list_size(list))) { |
Abhishek Singh | 6f56d21 | 2017-04-12 14:31:57 +0530 | [diff] [blame] | 1035 | sme_err("get scan result failed"); |
| 1036 | WLAN_HOST_DIAG_LOG_REPORT(pScanLog); |
| 1037 | wlan_objmgr_pdev_release_ref(pdev, WLAN_LEGACY_MAC_ID); |
Sandeep Puligilla | 2e233c6 | 2017-11-07 12:45:57 -0800 | [diff] [blame] | 1038 | if (list) |
| 1039 | ucfg_scan_purge_results(list); |
Abhishek Singh | 6f56d21 | 2017-04-12 14:31:57 +0530 | [diff] [blame] | 1040 | return; |
| 1041 | } |
| 1042 | |
| 1043 | qdf_list_peek_front(list, |
| 1044 | (qdf_list_node_t **) &cur_node); |
| 1045 | while (cur_node) { |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1046 | if (n < HOST_LOG_MAX_NUM_BSSID) { |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1047 | qdf_mem_copy(pScanLog->bssid[n], |
Abhishek Singh | 6f56d21 | 2017-04-12 14:31:57 +0530 | [diff] [blame] | 1048 | cur_node->entry->bssid.bytes, |
| 1049 | QDF_MAC_ADDR_SIZE); |
| 1050 | if (cur_node->entry->ssid.length > |
| 1051 | WLAN_SSID_MAX_LEN) |
| 1052 | cur_node->entry->ssid.length = |
| 1053 | WLAN_SSID_MAX_LEN; |
| 1054 | qdf_mem_copy(pScanLog->ssid[n], |
| 1055 | cur_node->entry->ssid.ssid, |
| 1056 | cur_node->entry->ssid.length); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1057 | n++; |
| 1058 | } |
| 1059 | c++; |
Abhishek Singh | 6f56d21 | 2017-04-12 14:31:57 +0530 | [diff] [blame] | 1060 | qdf_list_peek_next( |
| 1061 | list, |
| 1062 | (qdf_list_node_t *) cur_node, |
| 1063 | (qdf_list_node_t **) &next_node); |
| 1064 | cur_node = next_node; |
| 1065 | next_node = NULL; |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1066 | } |
| 1067 | pScanLog->numSsid = (uint8_t) n; |
| 1068 | pScanLog->totalSsid = (uint8_t) c; |
Abhishek Singh | 6f56d21 | 2017-04-12 14:31:57 +0530 | [diff] [blame] | 1069 | ucfg_scan_purge_results(list); |
| 1070 | wlan_objmgr_pdev_release_ref(pdev, WLAN_LEGACY_MAC_ID); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1071 | WLAN_HOST_DIAG_LOG_REPORT(pScanLog); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1072 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1073 | #endif /* #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR */ |
| 1074 | |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1075 | /** |
Deepak Dhamdhere | 6f7fbbe | 2017-02-28 13:35:52 -0800 | [diff] [blame] | 1076 | * csr_saved_scan_cmd_free_fields() - Free internal fields of scan command |
| 1077 | * |
| 1078 | * @mac_ctx: Global MAC context |
Abhishek Singh | 221cf99 | 2018-02-22 13:44:53 +0530 | [diff] [blame] | 1079 | * @session: sme session |
Deepak Dhamdhere | 6f7fbbe | 2017-02-28 13:35:52 -0800 | [diff] [blame] | 1080 | * |
| 1081 | * Frees data structures allocated inside saved_scan_cmd and releases |
| 1082 | * the profile. |
| 1083 | * Return: None |
| 1084 | */ |
| 1085 | |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 1086 | void csr_saved_scan_cmd_free_fields(struct mac_context *mac_ctx, |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 1087 | struct csr_roam_session *session) |
Deepak Dhamdhere | 6f7fbbe | 2017-02-28 13:35:52 -0800 | [diff] [blame] | 1088 | { |
| 1089 | if (session->scan_info.profile) { |
Jianmin Zhu | 9b7bef7 | 2018-12-18 21:17:15 +0800 | [diff] [blame] | 1090 | sme_debug("Free profile for session %d", session->sessionId); |
Deepak Dhamdhere | 6f7fbbe | 2017-02-28 13:35:52 -0800 | [diff] [blame] | 1091 | csr_release_profile(mac_ctx, |
| 1092 | session->scan_info.profile); |
| 1093 | qdf_mem_free(session->scan_info.profile); |
| 1094 | session->scan_info.profile = NULL; |
| 1095 | } |
| 1096 | |
| 1097 | if (session->scan_info.roambssentry) { |
| 1098 | qdf_mem_free(session->scan_info.roambssentry); |
| 1099 | session->scan_info.roambssentry = NULL; |
| 1100 | } |
| 1101 | } |
| 1102 | /** |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1103 | * csr_save_profile() - Save the profile info from sme command |
| 1104 | * @mac_ctx: Global MAC context |
| 1105 | * @save_cmd: Pointer where the command will be saved |
| 1106 | * @command: Command from which the profile will be saved |
| 1107 | * |
| 1108 | * Saves the profile information from the SME's scan command |
| 1109 | * |
| 1110 | * Return: QDF_STATUS |
| 1111 | */ |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 1112 | static QDF_STATUS csr_save_profile(struct mac_context *mac_ctx, |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1113 | uint32_t session_id) |
| 1114 | { |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 1115 | struct tag_csrscan_result *scan_result; |
| 1116 | struct tag_csrscan_result *temp; |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1117 | uint32_t bss_len; |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 1118 | struct csr_roam_session *session; |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1119 | |
Krunal Soni | 35a9453 | 2018-01-09 10:54:31 -0800 | [diff] [blame] | 1120 | /* |
| 1121 | * check the session's validity first, if session itself |
| 1122 | * is not valid then there is no point of releasing the memory |
| 1123 | * for invalid session (i.e. "goto error" case) |
| 1124 | */ |
| 1125 | if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) { |
| 1126 | sme_err("session %d is invalid", session_id); |
| 1127 | return QDF_STATUS_E_FAILURE; |
| 1128 | } |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1129 | session = CSR_GET_SESSION(mac_ctx, session_id); |
| 1130 | if (!session->scan_info.roambssentry) |
| 1131 | return QDF_STATUS_SUCCESS; |
| 1132 | |
| 1133 | scan_result = GET_BASE_ADDR(session->scan_info.roambssentry, |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 1134 | struct tag_csrscan_result, Link); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1135 | |
| 1136 | bss_len = scan_result->Result.BssDescriptor.length + |
| 1137 | sizeof(scan_result->Result.BssDescriptor.length); |
| 1138 | |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 1139 | temp = qdf_mem_malloc(sizeof(struct tag_csrscan_result) + bss_len); |
Arif Hussain | 0ef7708 | 2018-10-10 16:42:53 -0700 | [diff] [blame] | 1140 | if (!temp) |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1141 | goto error; |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1142 | |
| 1143 | temp->AgingCount = scan_result->AgingCount; |
| 1144 | temp->preferValue = scan_result->preferValue; |
| 1145 | temp->capValue = scan_result->capValue; |
| 1146 | temp->ucEncryptionType = scan_result->ucEncryptionType; |
| 1147 | temp->mcEncryptionType = scan_result->mcEncryptionType; |
| 1148 | temp->authType = scan_result->authType; |
| 1149 | /* pvIes is unsued in success/failure */ |
| 1150 | temp->Result.pvIes = NULL; |
| 1151 | |
| 1152 | qdf_mem_copy(temp->Result.pvIes, |
| 1153 | scan_result->Result.pvIes, |
| 1154 | sizeof(*scan_result->Result.pvIes)); |
| 1155 | temp->Result.ssId.length = scan_result->Result.ssId.length; |
| 1156 | qdf_mem_copy(temp->Result.ssId.ssId, |
| 1157 | scan_result->Result.ssId.ssId, |
| 1158 | sizeof(scan_result->Result.ssId.ssId)); |
| 1159 | temp->Result.timer = scan_result->Result.timer; |
| 1160 | qdf_mem_copy(&temp->Result.BssDescriptor, |
| 1161 | &scan_result->Result.BssDescriptor, |
| 1162 | sizeof(temp->Result.BssDescriptor)); |
| 1163 | temp->Link.last = temp->Link.next = NULL; |
| 1164 | session->scan_info.roambssentry = (tListElem *)temp; |
| 1165 | |
| 1166 | return QDF_STATUS_SUCCESS; |
| 1167 | error: |
| 1168 | csr_scan_handle_search_for_ssid_failure(mac_ctx, |
| 1169 | session_id); |
Deepak Dhamdhere | 6f7fbbe | 2017-02-28 13:35:52 -0800 | [diff] [blame] | 1170 | csr_saved_scan_cmd_free_fields(mac_ctx, session); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1171 | |
| 1172 | return QDF_STATUS_E_FAILURE; |
| 1173 | } |
| 1174 | |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 1175 | static void csr_handle_nxt_cmd(struct mac_context *mac_ctx, |
Jeff Johnson | 8c3ecdd | 2018-12-05 08:48:54 -0800 | [diff] [blame] | 1176 | enum csr_scancomplete_nextcommand nxt_cmd, |
| 1177 | uint32_t session_id, |
| 1178 | uint8_t chan) |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1179 | { |
| 1180 | QDF_STATUS status, ret; |
Jianmin Zhu | 9b7bef7 | 2018-12-18 21:17:15 +0800 | [diff] [blame] | 1181 | struct csr_roam_session *session; |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1182 | |
| 1183 | switch (nxt_cmd) { |
| 1184 | |
| 1185 | case eCsrNexteScanForSsidSuccess: |
| 1186 | csr_scan_handle_search_for_ssid(mac_ctx, session_id); |
| 1187 | break; |
| 1188 | case eCsrNexteScanForSsidFailure: |
| 1189 | csr_scan_handle_search_for_ssid_failure(mac_ctx, session_id); |
| 1190 | break; |
| 1191 | case eCsrNextCheckAllowConc: |
Tushnim Bhattacharyya | 0c4ad2d | 2017-03-09 15:59:03 -0800 | [diff] [blame] | 1192 | ret = policy_mgr_current_connections_update(mac_ctx->psoc, |
| 1193 | session_id, chan, |
Tushnim Bhattacharyya | 3b99f4b | 2018-03-26 14:19:24 -0700 | [diff] [blame] | 1194 | POLICY_MGR_UPDATE_REASON_HIDDEN_STA); |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1195 | sme_debug("chan: %d session: %d status: %d", |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1196 | chan, session_id, ret); |
| 1197 | |
| 1198 | status = csr_save_profile(mac_ctx, session_id); |
| 1199 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 1200 | /* csr_save_profile should report error */ |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1201 | sme_err("profile save failed %d", status); |
Jianmin Zhu | 9b7bef7 | 2018-12-18 21:17:15 +0800 | [diff] [blame] | 1202 | break; |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1203 | } |
| 1204 | |
| 1205 | if (QDF_STATUS_E_FAILURE == ret) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1206 | sme_err("conn update fail %d", chan); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1207 | csr_scan_handle_search_for_ssid_failure(mac_ctx, |
| 1208 | session_id); |
| 1209 | } else if ((QDF_STATUS_E_NOSUPPORT == ret) || |
| 1210 | (QDF_STATUS_E_ALREADY == ret)) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1211 | sme_err("conn update ret %d", ret); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1212 | csr_scan_handle_search_for_ssid(mac_ctx, session_id); |
| 1213 | } |
| 1214 | /* Else: Set hw mode was issued and the saved connect would |
| 1215 | * be issued after set hw mode response |
| 1216 | */ |
Jianmin Zhu | d443946 | 2018-12-27 14:03:17 +0800 | [diff] [blame] | 1217 | if (QDF_IS_STATUS_SUCCESS(ret)) |
Jianmin Zhu | 9b7bef7 | 2018-12-18 21:17:15 +0800 | [diff] [blame] | 1218 | return; |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1219 | default: |
| 1220 | break; |
| 1221 | } |
Jianmin Zhu | 9b7bef7 | 2018-12-18 21:17:15 +0800 | [diff] [blame] | 1222 | session = CSR_GET_SESSION(mac_ctx, session_id); |
| 1223 | if (session) |
| 1224 | csr_saved_scan_cmd_free_fields(mac_ctx, session); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1225 | } |
Abhishek Singh | e685781 | 2017-03-10 18:20:06 +0530 | [diff] [blame] | 1226 | |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1227 | void csr_scan_callback(struct wlan_objmgr_vdev *vdev, |
Jeff Johnson | 8c3ecdd | 2018-12-05 08:48:54 -0800 | [diff] [blame] | 1228 | struct scan_event *event, void *arg) |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1229 | { |
| 1230 | eCsrScanStatus scan_status = eCSR_SCAN_FAILURE; |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 1231 | enum csr_scancomplete_nextcommand NextCommand = eCsrNextScanNothing; |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 1232 | struct mac_context *mac_ctx; |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 1233 | struct csr_roam_session *session; |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1234 | uint32_t session_id = 0; |
| 1235 | uint8_t chan = 0; |
Jiachao Wu | b8f8921 | 2018-05-24 15:43:59 +0800 | [diff] [blame] | 1236 | bool success = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1237 | |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 1238 | mac_ctx = (struct mac_context *)arg; |
Jiachao Wu | b8f8921 | 2018-05-24 15:43:59 +0800 | [diff] [blame] | 1239 | |
Ashish Kumar Dhanotiya | 8d039c8 | 2018-07-11 20:41:14 +0530 | [diff] [blame] | 1240 | qdf_mtrace(QDF_MODULE_ID_SCAN, QDF_MODULE_ID_SME, event->type, |
| 1241 | event->vdev_id, event->scan_id); |
| 1242 | |
Jiachao Wu | b8f8921 | 2018-05-24 15:43:59 +0800 | [diff] [blame] | 1243 | if (!util_is_scan_completed(event, &success)) |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1244 | return; |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 1245 | |
Jiachao Wu | b8f8921 | 2018-05-24 15:43:59 +0800 | [diff] [blame] | 1246 | if (success) |
| 1247 | scan_status = eCSR_SCAN_SUCCESS; |
| 1248 | |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1249 | session_id = wlan_vdev_get_id(vdev); |
Krunal Soni | 35a9453 | 2018-01-09 10:54:31 -0800 | [diff] [blame] | 1250 | if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) { |
| 1251 | sme_err("session %d is invalid", session_id); |
| 1252 | return; |
| 1253 | } |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1254 | session = CSR_GET_SESSION(mac_ctx, session_id); |
| 1255 | |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1256 | sme_debug("Scan Completion: status %d session %d scan_id %d", |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1257 | scan_status, session_id, event->scan_id); |
| 1258 | |
| 1259 | /* verify whether scan event is related to scan interested by CSR */ |
| 1260 | if (session->scan_info.scan_id != event->scan_id) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1261 | sme_debug("Scan Completion on wrong scan_id %d, expected %d", |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1262 | session->scan_info.scan_id, event->scan_id); |
| 1263 | return; |
| 1264 | } |
| 1265 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 1266 | csr_diag_scan_complete(mac_ctx, scan_status); |
| 1267 | #endif |
| 1268 | NextCommand = csr_scan_get_next_command_state(mac_ctx, |
| 1269 | session_id, scan_status, |
| 1270 | &chan); |
| 1271 | /* We reuse the command here instead reissue a new command */ |
| 1272 | csr_handle_nxt_cmd(mac_ctx, NextCommand, |
| 1273 | session_id, chan); |
| 1274 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1275 | |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 1276 | tCsrScanResultInfo *csr_scan_result_get_first(struct mac_context *mac, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1277 | tScanResultHandle hScanResult) |
| 1278 | { |
| 1279 | tListElem *pEntry; |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 1280 | struct tag_csrscan_result *pResult; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1281 | tCsrScanResultInfo *pRet = NULL; |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 1282 | struct scan_result_list *pResultList = |
| 1283 | (struct scan_result_list *) hScanResult; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1284 | |
| 1285 | if (pResultList) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1286 | pEntry = csr_ll_peek_head(&pResultList->List, LL_ACCESS_NOLOCK); |
| 1287 | if (pEntry) { |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 1288 | pResult = GET_BASE_ADDR(pEntry, struct |
| 1289 | tag_csrscan_result, Link); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1290 | pRet = &pResult->Result; |
| 1291 | } |
| 1292 | pResultList->pCurEntry = pEntry; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1293 | } |
| 1294 | |
| 1295 | return pRet; |
| 1296 | } |
| 1297 | |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 1298 | tCsrScanResultInfo *csr_scan_result_get_next(struct mac_context *mac, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1299 | tScanResultHandle hScanResult) |
| 1300 | { |
| 1301 | tListElem *pEntry = NULL; |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 1302 | struct tag_csrscan_result *pResult = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1303 | tCsrScanResultInfo *pRet = NULL; |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 1304 | struct scan_result_list *pResultList = |
| 1305 | (struct scan_result_list *) hScanResult; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1306 | |
| 1307 | if (!pResultList) |
| 1308 | return NULL; |
| 1309 | |
Jeff Johnson | 038efe7 | 2019-03-18 13:39:31 -0700 | [diff] [blame] | 1310 | if (!pResultList->pCurEntry) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1311 | pEntry = csr_ll_peek_head(&pResultList->List, LL_ACCESS_NOLOCK); |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 1312 | else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1313 | pEntry = csr_ll_next(&pResultList->List, pResultList->pCurEntry, |
| 1314 | LL_ACCESS_NOLOCK); |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 1315 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1316 | if (pEntry) { |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 1317 | pResult = GET_BASE_ADDR(pEntry, struct tag_csrscan_result, |
| 1318 | Link); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1319 | pRet = &pResult->Result; |
| 1320 | } |
| 1321 | pResultList->pCurEntry = pEntry; |
Jianmin Zhu | b659fa1 | 2019-01-30 11:48:49 +0800 | [diff] [blame] | 1322 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1323 | return pRet; |
| 1324 | } |
| 1325 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1326 | /** |
| 1327 | * csr_scan_for_ssid() - Function usually used for BSSs that suppresses SSID |
| 1328 | * @mac_ctx: Pointer to Global Mac structure |
Jeff Johnson | 66ee8a9 | 2018-03-17 15:24:26 -0700 | [diff] [blame] | 1329 | * @profile: pointer to struct csr_roam_profile |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1330 | * @roam_id: variable representing roam id |
| 1331 | * @notify: boolean variable |
| 1332 | * |
| 1333 | * Function is usually used for BSSs that suppresses SSID so the profile |
| 1334 | * shall have one and only one SSID. |
| 1335 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1336 | * Return: Success - QDF_STATUS_SUCCESS, Failure - error number |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1337 | */ |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 1338 | QDF_STATUS csr_scan_for_ssid(struct mac_context *mac_ctx, uint32_t session_id, |
Jeff Johnson | 8c3ecdd | 2018-12-05 08:48:54 -0800 | [diff] [blame] | 1339 | struct csr_roam_profile *profile, uint32_t roam_id, |
| 1340 | bool notify) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1341 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1342 | QDF_STATUS status = QDF_STATUS_E_INVAL; |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1343 | uint32_t num_ssid = profile->SSIDs.numOfSSIDs; |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1344 | struct scan_start_request *req; |
| 1345 | struct wlan_objmgr_vdev *vdev; |
Himanshu Agarwal | 12445c1 | 2017-11-07 14:56:09 +0530 | [diff] [blame] | 1346 | uint8_t i, chan, num_chan = 0; |
Vignesh Viswanathan | ad47f0a | 2018-03-15 16:42:17 +0530 | [diff] [blame] | 1347 | uint8_t pdev_id; |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1348 | wlan_scan_id scan_id; |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 1349 | struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1350 | |
Krunal Soni | 35a9453 | 2018-01-09 10:54:31 -0800 | [diff] [blame] | 1351 | if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) { |
| 1352 | sme_err("session %d is invalid", session_id); |
| 1353 | return status; |
| 1354 | } |
Abhinav Kumar | f998958 | 2018-02-06 17:42:22 +0530 | [diff] [blame] | 1355 | |
Abhishek Singh | 935e477 | 2018-11-21 14:14:10 +0530 | [diff] [blame] | 1356 | if (num_ssid != 1) { |
| 1357 | sme_err("numSSID (%d) is invalid", profile->SSIDs.numOfSSIDs); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1358 | return status; |
| 1359 | } |
| 1360 | |
Vignesh Viswanathan | ad47f0a | 2018-03-15 16:42:17 +0530 | [diff] [blame] | 1361 | if (!mac_ctx->pdev) { |
| 1362 | sme_err("pdev ctx is NULL"); |
| 1363 | return status; |
| 1364 | } |
| 1365 | pdev_id = wlan_objmgr_pdev_get_pdev_id(mac_ctx->pdev); |
| 1366 | |
Jianmin Zhu | d443946 | 2018-12-27 14:03:17 +0800 | [diff] [blame] | 1367 | /* Free old memory if any before its overwritten */ |
| 1368 | csr_saved_scan_cmd_free_fields(mac_ctx, session); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1369 | session->scan_info.profile = |
Jeff Johnson | 66ee8a9 | 2018-03-17 15:24:26 -0700 | [diff] [blame] | 1370 | qdf_mem_malloc(sizeof(struct csr_roam_profile)); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1371 | if (!session->scan_info.profile) |
| 1372 | status = QDF_STATUS_E_NOMEM; |
| 1373 | else |
| 1374 | status = csr_roam_copy_profile(mac_ctx, |
| 1375 | session->scan_info.profile, |
| 1376 | profile); |
Abhinav Kumar | 3b724f5 | 2018-12-26 15:18:11 +0530 | [diff] [blame] | 1377 | if (QDF_IS_STATUS_ERROR(status)) |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1378 | goto error; |
| 1379 | scan_id = ucfg_scan_get_scan_id(mac_ctx->psoc); |
| 1380 | session->scan_info.scan_id = scan_id; |
| 1381 | session->scan_info.scan_reason = eCsrScanForSsid; |
| 1382 | session->scan_info.roam_id = roam_id; |
| 1383 | req = qdf_mem_malloc(sizeof(*req)); |
Abhinav Kumar | 3b724f5 | 2018-12-26 15:18:11 +0530 | [diff] [blame] | 1384 | if (!req) { |
| 1385 | status = QDF_STATUS_E_NOMEM; |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1386 | goto error; |
Abhinav Kumar | 3b724f5 | 2018-12-26 15:18:11 +0530 | [diff] [blame] | 1387 | } |
Vignesh Viswanathan | ad47f0a | 2018-03-15 16:42:17 +0530 | [diff] [blame] | 1388 | |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1389 | vdev = wlan_objmgr_get_vdev_by_macaddr_from_psoc(mac_ctx->psoc, |
Vignesh Viswanathan | ad47f0a | 2018-03-15 16:42:17 +0530 | [diff] [blame] | 1390 | pdev_id, |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1391 | session->selfMacAddr.bytes, |
| 1392 | WLAN_LEGACY_SME_ID); |
| 1393 | ucfg_scan_init_default_params(vdev, req); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1394 | req->scan_req.scan_id = scan_id; |
| 1395 | req->scan_req.vdev_id = session_id; |
| 1396 | req->scan_req.scan_req_id = mac_ctx->scan.requester_id; |
Deepak Dhamdhere | ca7315c | 2017-10-20 13:05:56 -0700 | [diff] [blame] | 1397 | req->scan_req.scan_f_passive = false; |
| 1398 | req->scan_req.scan_f_bcast_probe = false; |
| 1399 | |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1400 | if (QDF_P2P_CLIENT_MODE == profile->csrPersona) |
| 1401 | req->scan_req.scan_priority = SCAN_PRIORITY_HIGH; |
| 1402 | |
| 1403 | /* Allocate memory for IE field */ |
| 1404 | if (profile->pAddIEScan) { |
| 1405 | req->scan_req.extraie.ptr = |
| 1406 | qdf_mem_malloc(profile->nAddIEScanLength); |
| 1407 | |
Jeff Johnson | 038efe7 | 2019-03-18 13:39:31 -0700 | [diff] [blame] | 1408 | if (!req->scan_req.extraie.ptr) |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1409 | status = QDF_STATUS_E_NOMEM; |
| 1410 | else |
| 1411 | status = QDF_STATUS_SUCCESS; |
| 1412 | |
| 1413 | if (QDF_IS_STATUS_SUCCESS(status)) { |
| 1414 | qdf_mem_copy(req->scan_req.extraie.ptr, |
| 1415 | profile->pAddIEScan, |
| 1416 | profile->nAddIEScanLength); |
| 1417 | req->scan_req.extraie.len = profile->nAddIEScanLength; |
| 1418 | } else { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1419 | sme_err("No memory for scanning IE fields"); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1420 | } |
| 1421 | } |
| 1422 | |
| 1423 | req->scan_req.num_bssid = 1; |
| 1424 | if (profile->BSSIDs.numOfBSSIDs == 1) |
| 1425 | qdf_copy_macaddr(&req->scan_req.bssid_list[0], |
| 1426 | profile->BSSIDs.bssid); |
| 1427 | else |
| 1428 | qdf_set_macaddr_broadcast(&req->scan_req.bssid_list[0]); |
| 1429 | |
| 1430 | if (profile->ChannelInfo.numOfChannels) { |
| 1431 | for (i = 0; i < profile->ChannelInfo.numOfChannels; i++) { |
| 1432 | if (csr_roam_is_valid_channel(mac_ctx, |
| 1433 | profile->ChannelInfo.ChannelList[i])) { |
| 1434 | chan = profile->ChannelInfo.ChannelList[i]; |
Abhishek Singh | a394b6c | 2017-11-03 17:14:58 +0530 | [diff] [blame] | 1435 | req->scan_req.chan_list.chan[num_chan].freq = |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1436 | wlan_chan_to_freq(chan); |
| 1437 | num_chan++; |
| 1438 | } |
| 1439 | } |
Abhishek Singh | a394b6c | 2017-11-03 17:14:58 +0530 | [diff] [blame] | 1440 | req->scan_req.chan_list.num_chan = num_chan; |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1441 | } |
| 1442 | |
| 1443 | /* Extend it for multiple SSID */ |
| 1444 | if (profile->SSIDs.numOfSSIDs) { |
Srinivas Girigowda | b8fdc64 | 2019-03-19 15:33:03 -0700 | [diff] [blame] | 1445 | if (profile->SSIDs.SSIDList[0].SSID.length > WLAN_SSID_MAX_LEN) { |
Sandeep Puligilla | c0f7744 | 2017-11-07 01:20:32 -0800 | [diff] [blame] | 1446 | sme_debug("wrong ssid length = %d", |
| 1447 | profile->SSIDs.SSIDList[0].SSID.length); |
| 1448 | status = QDF_STATUS_E_INVAL; |
| 1449 | goto error; |
| 1450 | } |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1451 | req->scan_req.num_ssids = 1; |
| 1452 | qdf_mem_copy(&req->scan_req.ssid[0].ssid, |
| 1453 | &profile->SSIDs.SSIDList[0].SSID.ssId, |
| 1454 | profile->SSIDs.SSIDList[0].SSID.length); |
| 1455 | req->scan_req.ssid[0].length = |
| 1456 | profile->SSIDs.SSIDList[0].SSID.length; |
Himanshu Agarwal | 12445c1 | 2017-11-07 14:56:09 +0530 | [diff] [blame] | 1457 | sme_debug("scan for SSID = %.*s", req->scan_req.ssid[0].length, |
| 1458 | req->scan_req.ssid[0].ssid); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1459 | } |
| 1460 | status = ucfg_scan_start(req); |
| 1461 | wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_SME_ID); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1462 | error: |
Abhinav Kumar | 3b724f5 | 2018-12-26 15:18:11 +0530 | [diff] [blame] | 1463 | if (QDF_IS_STATUS_ERROR(status)) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1464 | sme_err("failed to initiate scan with status: %d", status); |
Sandeep Puligilla | b0e017c | 2017-06-09 18:09:55 -0700 | [diff] [blame] | 1465 | csr_release_profile(mac_ctx, session->scan_info.profile); |
| 1466 | qdf_mem_free(session->scan_info.profile); |
| 1467 | session->scan_info.profile = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1468 | if (notify) |
| 1469 | csr_roam_call_callback(mac_ctx, session_id, NULL, |
| 1470 | roam_id, eCSR_ROAM_FAILED, |
| 1471 | eCSR_ROAM_RESULT_FAILURE); |
| 1472 | } |
| 1473 | return status; |
| 1474 | } |
| 1475 | |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 1476 | static void csr_set_cfg_valid_channel_list(struct mac_context *mac, |
Jeff Johnson | 8c3ecdd | 2018-12-05 08:48:54 -0800 | [diff] [blame] | 1477 | uint8_t *pChannelList, |
| 1478 | uint8_t NumChannels) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1479 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1480 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1481 | |
Abhishek Singh | 438cd7e | 2017-08-11 12:21:06 +0530 | [diff] [blame] | 1482 | QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1483 | "%s: dump valid channel list(NumChannels(%d))", |
| 1484 | __func__, NumChannels); |
Abhishek Singh | 438cd7e | 2017-08-11 12:21:06 +0530 | [diff] [blame] | 1485 | QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1486 | pChannelList, NumChannels); |
Wu Gao | f3cbeaf | 2019-01-15 18:26:25 +0800 | [diff] [blame] | 1487 | qdf_mem_copy(mac->mlme_cfg->reg.valid_channel_list, pChannelList, |
| 1488 | NumChannels); |
| 1489 | mac->mlme_cfg->reg.valid_channel_list_num = NumChannels; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1490 | |
Abhishek Singh | 438cd7e | 2017-08-11 12:21:06 +0530 | [diff] [blame] | 1491 | QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1492 | "Scan offload is enabled, update default chan list"); |
| 1493 | /* |
| 1494 | * disable fcc constraint since new country code |
| 1495 | * is being set |
| 1496 | */ |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 1497 | mac->scan.fcc_constraint = false; |
| 1498 | status = csr_update_channel_list(mac); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1499 | if (QDF_STATUS_SUCCESS != status) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1500 | QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1501 | "failed to update the supported channel list"); |
| 1502 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1503 | } |
| 1504 | |
| 1505 | /* |
| 1506 | * The Tx power limits are saved in the cfg for future usage. |
| 1507 | */ |
Jeff Johnson | 61b5089 | 2019-03-20 09:22:05 -0700 | [diff] [blame] | 1508 | static void csr_save_tx_power_to_cfg(struct mac_context *mac, |
gaurank kathpalia | 3d2e385 | 2018-10-03 22:03:23 +0530 | [diff] [blame] | 1509 | tDblLinkList *pList, |
| 1510 | enum band_info band) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1511 | { |
| 1512 | tListElem *pEntry; |
| 1513 | uint32_t cbLen = 0, dataLen, tmp_len; |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 1514 | struct csr_channel_powerinfo *ch_set; |
Paul Zhang | 2f78923 | 2019-04-19 16:40:24 +0800 | [diff] [blame] | 1515 | uint32_t idx, count = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1516 | tSirMacChanInfo *ch_pwr_set; |
gaurank kathpalia | 3d2e385 | 2018-10-03 22:03:23 +0530 | [diff] [blame] | 1517 | uint8_t *p_buf = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1518 | |
| 1519 | /* allocate maximum space for all channels */ |
Wu Gao | 0821b0d | 2019-01-11 17:31:11 +0800 | [diff] [blame] | 1520 | dataLen = CFG_VALID_CHANNEL_LIST_LEN * sizeof(tSirMacChanInfo); |
gaurank kathpalia | 3d2e385 | 2018-10-03 22:03:23 +0530 | [diff] [blame] | 1521 | p_buf = qdf_mem_malloc(dataLen); |
| 1522 | if (!p_buf) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1523 | return; |
| 1524 | |
gaurank kathpalia | 3d2e385 | 2018-10-03 22:03:23 +0530 | [diff] [blame] | 1525 | ch_pwr_set = (tSirMacChanInfo *)(p_buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1526 | pEntry = csr_ll_peek_head(pList, LL_ACCESS_LOCK); |
| 1527 | /* |
| 1528 | * write the tuples (startChan, numChan, txPower) for each channel found |
| 1529 | * in the channel power list. |
| 1530 | */ |
| 1531 | while (pEntry) { |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 1532 | ch_set = GET_BASE_ADDR(pEntry, |
| 1533 | struct csr_channel_powerinfo, link); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1534 | if (1 != ch_set->interChannelOffset) { |
| 1535 | /* |
| 1536 | * we keep the 5G channel sets internally with an |
| 1537 | * interchannel offset of 4. Expand these to the right |
| 1538 | * format. (inter channel offset of 1 is the only option |
| 1539 | * for the triplets that 11d advertises. |
| 1540 | */ |
| 1541 | tmp_len = cbLen + (ch_set->numChannels * |
| 1542 | sizeof(tSirMacChanInfo)); |
| 1543 | if (tmp_len >= dataLen) { |
| 1544 | /* |
| 1545 | * expanding this entry will overflow our |
| 1546 | * allocation |
| 1547 | */ |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1548 | sme_err( |
| 1549 | "Buffer overflow, start %d, num %d, offset %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1550 | ch_set->firstChannel, |
| 1551 | ch_set->numChannels, |
| 1552 | ch_set->interChannelOffset); |
| 1553 | break; |
| 1554 | } |
| 1555 | |
| 1556 | for (idx = 0; idx < ch_set->numChannels; idx++) { |
| 1557 | ch_pwr_set->firstChanNum = (tSirMacChanNum) |
| 1558 | (ch_set->firstChannel + (idx * |
| 1559 | ch_set->interChannelOffset)); |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1560 | sme_debug( |
| 1561 | "Setting Channel Number %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1562 | ch_pwr_set->firstChanNum); |
| 1563 | ch_pwr_set->numChannels = 1; |
| 1564 | ch_pwr_set->maxTxPower = |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1565 | QDF_MIN(ch_set->txPower, |
Jeff Johnson | 61b5089 | 2019-03-20 09:22:05 -0700 | [diff] [blame] | 1566 | mac->mlme_cfg->power.max_tx_power); |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1567 | sme_debug( |
| 1568 | "Setting Max Transmit Power %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1569 | ch_pwr_set->maxTxPower); |
| 1570 | cbLen += sizeof(tSirMacChanInfo); |
| 1571 | ch_pwr_set++; |
Paul Zhang | 2f78923 | 2019-04-19 16:40:24 +0800 | [diff] [blame] | 1572 | count++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1573 | } |
| 1574 | } else { |
| 1575 | if (cbLen >= dataLen) { |
| 1576 | /* this entry will overflow our allocation */ |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1577 | sme_err( |
| 1578 | "Buffer overflow, start %d, num %d, offset %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1579 | ch_set->firstChannel, |
| 1580 | ch_set->numChannels, |
| 1581 | ch_set->interChannelOffset); |
| 1582 | break; |
| 1583 | } |
| 1584 | ch_pwr_set->firstChanNum = ch_set->firstChannel; |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1585 | sme_debug("Setting Channel Number %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1586 | ch_pwr_set->firstChanNum); |
| 1587 | ch_pwr_set->numChannels = ch_set->numChannels; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1588 | ch_pwr_set->maxTxPower = QDF_MIN(ch_set->txPower, |
Jeff Johnson | 61b5089 | 2019-03-20 09:22:05 -0700 | [diff] [blame] | 1589 | mac->mlme_cfg->power.max_tx_power); |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1590 | sme_debug( |
| 1591 | "Setting Max Tx Power %d, nTxPower %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1592 | ch_pwr_set->maxTxPower, |
Jeff Johnson | 61b5089 | 2019-03-20 09:22:05 -0700 | [diff] [blame] | 1593 | mac->mlme_cfg->power.max_tx_power); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1594 | cbLen += sizeof(tSirMacChanInfo); |
| 1595 | ch_pwr_set++; |
Paul Zhang | 2f78923 | 2019-04-19 16:40:24 +0800 | [diff] [blame] | 1596 | count++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1597 | } |
| 1598 | pEntry = csr_ll_next(pList, pEntry, LL_ACCESS_LOCK); |
| 1599 | } |
Paul Zhang | 2f78923 | 2019-04-19 16:40:24 +0800 | [diff] [blame] | 1600 | if (band == BAND_2G) { |
| 1601 | mac->mlme_cfg->power.max_tx_power_24.len = 3 * count; |
Jeff Johnson | 61b5089 | 2019-03-20 09:22:05 -0700 | [diff] [blame] | 1602 | qdf_mem_copy(mac->mlme_cfg->power.max_tx_power_24.data, |
gaurank kathpalia | 3d2e385 | 2018-10-03 22:03:23 +0530 | [diff] [blame] | 1603 | (uint8_t *)p_buf, |
Jeff Johnson | 61b5089 | 2019-03-20 09:22:05 -0700 | [diff] [blame] | 1604 | mac->mlme_cfg->power.max_tx_power_24.len); |
Paul Zhang | 2f78923 | 2019-04-19 16:40:24 +0800 | [diff] [blame] | 1605 | } |
| 1606 | if (band == BAND_5G) { |
| 1607 | mac->mlme_cfg->power.max_tx_power_5.len = 3 * count; |
Jeff Johnson | 61b5089 | 2019-03-20 09:22:05 -0700 | [diff] [blame] | 1608 | qdf_mem_copy(mac->mlme_cfg->power.max_tx_power_5.data, |
gaurank kathpalia | 3d2e385 | 2018-10-03 22:03:23 +0530 | [diff] [blame] | 1609 | (uint8_t *)p_buf, |
Jeff Johnson | 61b5089 | 2019-03-20 09:22:05 -0700 | [diff] [blame] | 1610 | mac->mlme_cfg->power.max_tx_power_5.len); |
Paul Zhang | 2f78923 | 2019-04-19 16:40:24 +0800 | [diff] [blame] | 1611 | } |
gaurank kathpalia | 3d2e385 | 2018-10-03 22:03:23 +0530 | [diff] [blame] | 1612 | qdf_mem_free(p_buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1613 | } |
| 1614 | |
Jeff Johnson | 8c3ecdd | 2018-12-05 08:48:54 -0800 | [diff] [blame] | 1615 | static void csr_set_cfg_country_code(struct mac_context *mac, |
| 1616 | uint8_t *countryCode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1617 | { |
Wu Gao | aa15514 | 2019-01-14 15:09:26 +0800 | [diff] [blame] | 1618 | uint8_t cc[CFG_COUNTRY_CODE_LEN]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1619 | /* v_REGDOMAIN_t DomainId */ |
| 1620 | |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1621 | sme_debug("Setting Country Code in Cfg %s", countryCode); |
Wu Gao | aa15514 | 2019-01-14 15:09:26 +0800 | [diff] [blame] | 1622 | qdf_mem_copy(cc, countryCode, CFG_COUNTRY_CODE_LEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1623 | |
| 1624 | /* |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 1625 | * Don't program the bogus country codes that we created for Korea in |
| 1626 | * the MAC. if we see the bogus country codes, program the MAC with |
| 1627 | * the right country code. |
| 1628 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1629 | if (('K' == countryCode[0] && '1' == countryCode[1]) || |
| 1630 | ('K' == countryCode[0] && '2' == countryCode[1]) || |
| 1631 | ('K' == countryCode[0] && '3' == countryCode[1]) || |
| 1632 | ('K' == countryCode[0] && '4' == countryCode[1])) { |
| 1633 | /* |
| 1634 | * replace the alternate Korea country codes, 'K1', 'K2', .. |
| 1635 | * with 'KR' for Korea |
| 1636 | */ |
| 1637 | cc[1] = 'R'; |
| 1638 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1639 | |
| 1640 | /* |
Wu Gao | f3cbeaf | 2019-01-15 18:26:25 +0800 | [diff] [blame] | 1641 | * country code is moved to mlme component, and it is limited to call |
| 1642 | * legacy api, so required to call sch_edca_profile_update_all if |
| 1643 | * overwrite country code in mlme component |
| 1644 | */ |
| 1645 | qdf_mem_copy(mac->mlme_cfg->reg.country_code, cc, CFG_COUNTRY_CODE_LEN); |
| 1646 | mac->mlme_cfg->reg.country_code_len = CFG_COUNTRY_CODE_LEN; |
| 1647 | sme_debug("CFG_COUNTRY_CODE changed"); |
| 1648 | sch_edca_profile_update_all(mac); |
| 1649 | /* |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1650 | * Need to let HALPHY know about the current domain so it can apply some |
| 1651 | * domain-specific settings (TX filter...) |
| 1652 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1653 | } |
| 1654 | |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 1655 | QDF_STATUS csr_get_country_code(struct mac_context *mac, uint8_t *pBuf, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1656 | uint8_t *pbLen) |
| 1657 | { |
Wu Gao | aa15514 | 2019-01-14 15:09:26 +0800 | [diff] [blame] | 1658 | if (pBuf && pbLen && (*pbLen >= CFG_COUNTRY_CODE_LEN)) { |
Wu Gao | f3cbeaf | 2019-01-15 18:26:25 +0800 | [diff] [blame] | 1659 | *pbLen = mac->mlme_cfg->reg.country_code_len; |
| 1660 | qdf_mem_copy(pBuf, mac->mlme_cfg->reg.country_code, |
| 1661 | (uint32_t)*pbLen); |
| 1662 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1663 | } |
| 1664 | |
Varun Reddy Yeturu | 7b2a657 | 2017-06-15 11:07:28 -0700 | [diff] [blame] | 1665 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1666 | } |
| 1667 | |
Jeff Johnson | 8c3ecdd | 2018-12-05 08:48:54 -0800 | [diff] [blame] | 1668 | QDF_STATUS csr_scan_abort_mac_scan(struct mac_context *mac_ctx, |
| 1669 | uint32_t vdev_id, |
Abhishek Singh | 9fabbbb | 2018-01-29 17:38:36 +0530 | [diff] [blame] | 1670 | uint32_t scan_id) |
Sandeep Puligilla | df6454a | 2016-10-21 16:10:59 -0700 | [diff] [blame] | 1671 | { |
Abhishek Singh | 9fabbbb | 2018-01-29 17:38:36 +0530 | [diff] [blame] | 1672 | struct scan_cancel_request *req; |
| 1673 | QDF_STATUS status; |
| 1674 | struct wlan_objmgr_vdev *vdev; |
Sandeep Puligilla | df6454a | 2016-10-21 16:10:59 -0700 | [diff] [blame] | 1675 | |
Abhishek Singh | 9fabbbb | 2018-01-29 17:38:36 +0530 | [diff] [blame] | 1676 | req = qdf_mem_malloc(sizeof(*req)); |
Arif Hussain | 0ef7708 | 2018-10-10 16:42:53 -0700 | [diff] [blame] | 1677 | if (!req) |
Abhishek Singh | 9fabbbb | 2018-01-29 17:38:36 +0530 | [diff] [blame] | 1678 | return QDF_STATUS_E_NOMEM; |
Sandeep Puligilla | df6454a | 2016-10-21 16:10:59 -0700 | [diff] [blame] | 1679 | |
Abhishek Singh | 9fabbbb | 2018-01-29 17:38:36 +0530 | [diff] [blame] | 1680 | /* Get NL global context from objmgr*/ |
| 1681 | if (vdev_id == INVAL_VDEV_ID) |
Abhishek Singh | cdd3d4c | 2018-11-14 11:56:05 +0530 | [diff] [blame] | 1682 | vdev = wlan_objmgr_pdev_get_first_vdev(mac_ctx->pdev, |
| 1683 | WLAN_LEGACY_SME_ID); |
Abhishek Singh | 9fabbbb | 2018-01-29 17:38:36 +0530 | [diff] [blame] | 1684 | else |
| 1685 | vdev = wlan_objmgr_get_vdev_by_id_from_pdev(mac_ctx->pdev, |
| 1686 | vdev_id, WLAN_LEGACY_SME_ID); |
Sandeep Puligilla | df6454a | 2016-10-21 16:10:59 -0700 | [diff] [blame] | 1687 | |
Abhishek Singh | 9fabbbb | 2018-01-29 17:38:36 +0530 | [diff] [blame] | 1688 | if (!vdev) { |
| 1689 | sme_err("Failed get vdev"); |
| 1690 | qdf_mem_free(req); |
| 1691 | return QDF_STATUS_E_INVAL; |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 1692 | } |
Abhishek Singh | 9fabbbb | 2018-01-29 17:38:36 +0530 | [diff] [blame] | 1693 | |
| 1694 | req->vdev = vdev; |
| 1695 | req->cancel_req.scan_id = scan_id; |
| 1696 | req->cancel_req.pdev_id = wlan_objmgr_pdev_get_pdev_id(mac_ctx->pdev); |
| 1697 | req->cancel_req.vdev_id = vdev_id; |
| 1698 | if (scan_id != INVAL_SCAN_ID) |
| 1699 | req->cancel_req.req_type = WLAN_SCAN_CANCEL_SINGLE; |
| 1700 | if (vdev_id == INVAL_VDEV_ID) |
| 1701 | req->cancel_req.req_type = WLAN_SCAN_CANCEL_PDEV_ALL; |
| 1702 | else |
| 1703 | req->cancel_req.req_type = WLAN_SCAN_CANCEL_VDEV_ALL; |
| 1704 | |
| 1705 | status = ucfg_scan_cancel(req); |
| 1706 | if (QDF_IS_STATUS_ERROR(status)) |
| 1707 | sme_err("Cancel scan request failed"); |
| 1708 | |
| 1709 | wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_SME_ID); |
| 1710 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1711 | return status; |
| 1712 | } |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 1713 | QDF_STATUS csr_remove_nonscan_cmd_from_pending_list(struct mac_context *mac, |
Jeff Johnson | 8c3ecdd | 2018-12-05 08:48:54 -0800 | [diff] [blame] | 1714 | uint8_t sessionId, |
| 1715 | eSmeCommandType commandType) |
Krunal Soni | 72dba66 | 2017-02-15 20:13:17 -0800 | [diff] [blame] | 1716 | { |
| 1717 | tDblLinkList localList; |
| 1718 | tListElem *pEntry; |
| 1719 | tSmeCmd *pCommand; |
| 1720 | tListElem *pEntryToRemove; |
| 1721 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
| 1722 | |
| 1723 | qdf_mem_zero(&localList, sizeof(tDblLinkList)); |
Jeff Johnson | 616417f | 2018-06-27 10:20:53 -0700 | [diff] [blame] | 1724 | if (!QDF_IS_STATUS_SUCCESS(csr_ll_open(&localList))) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1725 | sme_err("failed to open list"); |
Krunal Soni | 72dba66 | 2017-02-15 20:13:17 -0800 | [diff] [blame] | 1726 | return status; |
| 1727 | } |
| 1728 | |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 1729 | pEntry = csr_nonscan_pending_ll_peek_head(mac, LL_ACCESS_NOLOCK); |
Krunal Soni | 72dba66 | 2017-02-15 20:13:17 -0800 | [diff] [blame] | 1730 | |
| 1731 | /* |
| 1732 | * Have to make sure we don't loop back to the head of the list, |
| 1733 | * which will happen if the entry is NOT on the list |
| 1734 | */ |
| 1735 | while (pEntry) { |
| 1736 | pEntryToRemove = pEntry; |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 1737 | pEntry = csr_nonscan_pending_ll_next(mac, |
Krunal Soni | 72dba66 | 2017-02-15 20:13:17 -0800 | [diff] [blame] | 1738 | pEntry, LL_ACCESS_NOLOCK); |
| 1739 | pCommand = GET_BASE_ADDR(pEntryToRemove, tSmeCmd, Link); |
| 1740 | |
| 1741 | if ((pCommand->command == commandType) && |
| 1742 | (pCommand->sessionId == sessionId)) { |
Will Huang | 24d272b | 2018-09-07 20:25:30 +0800 | [diff] [blame] | 1743 | /* Insert to localList and remove later */ |
| 1744 | csr_ll_insert_tail(&localList, pEntryToRemove, |
| 1745 | LL_ACCESS_NOLOCK); |
| 1746 | status = QDF_STATUS_SUCCESS; |
Krunal Soni | 72dba66 | 2017-02-15 20:13:17 -0800 | [diff] [blame] | 1747 | } |
| 1748 | } |
Jianmin Zhu | b659fa1 | 2019-01-30 11:48:49 +0800 | [diff] [blame] | 1749 | |
Krunal Soni | 72dba66 | 2017-02-15 20:13:17 -0800 | [diff] [blame] | 1750 | |
| 1751 | while ((pEntry = csr_ll_remove_head(&localList, LL_ACCESS_NOLOCK))) { |
| 1752 | pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link); |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1753 | sme_debug("Sending abort for command ID %d", |
Abhinav Kumar | f998958 | 2018-02-06 17:42:22 +0530 | [diff] [blame] | 1754 | sessionId); |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 1755 | csr_release_command(mac, pCommand); |
Krunal Soni | 72dba66 | 2017-02-15 20:13:17 -0800 | [diff] [blame] | 1756 | } |
| 1757 | |
| 1758 | csr_ll_close(&localList); |
| 1759 | return status; |
| 1760 | } |
Jeff Johnson | 8c3ecdd | 2018-12-05 08:48:54 -0800 | [diff] [blame] | 1761 | |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 1762 | bool csr_roam_is_valid_channel(struct mac_context *mac, uint8_t channel) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1763 | { |
| 1764 | bool fValid = false; |
| 1765 | uint32_t idx_valid_ch; |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 1766 | uint32_t len = mac->roam.numValidChannels; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1767 | |
| 1768 | for (idx_valid_ch = 0; (idx_valid_ch < len); idx_valid_ch++) { |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 1769 | if (channel == mac->roam.validChannelList[idx_valid_ch]) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1770 | fValid = true; |
| 1771 | break; |
| 1772 | } |
| 1773 | } |
| 1774 | return fValid; |
| 1775 | } |
| 1776 | |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 1777 | QDF_STATUS csr_scan_create_entry_in_scan_cache(struct mac_context *mac, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1778 | uint32_t sessionId, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1779 | struct qdf_mac_addr bssid, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1780 | uint8_t channel) |
| 1781 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1782 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 1783 | struct csr_roam_session *pSession = CSR_GET_SESSION(mac, sessionId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1784 | tSirBssDescription *pNewBssDescriptor = NULL; |
| 1785 | uint32_t size = 0; |
| 1786 | |
Jeff Johnson | 038efe7 | 2019-03-18 13:39:31 -0700 | [diff] [blame] | 1787 | if (!pSession) { |
Abhishek Singh | f723e3d | 2018-02-20 18:02:37 +0530 | [diff] [blame] | 1788 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1789 | } |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 1790 | sme_debug("Current bssid::"QDF_MAC_ADDR_STR, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 1791 | QDF_MAC_ADDR_ARRAY(pSession->pConnectBssDesc->bssId)); |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 1792 | sme_debug("My bssid::"QDF_MAC_ADDR_STR" channel %d", |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 1793 | QDF_MAC_ADDR_ARRAY(bssid.bytes), channel); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1794 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1795 | size = pSession->pConnectBssDesc->length + |
| 1796 | sizeof(pSession->pConnectBssDesc->length); |
| 1797 | if (!size) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1798 | sme_err("length of bss descriptor is 0"); |
Abhishek Singh | f723e3d | 2018-02-20 18:02:37 +0530 | [diff] [blame] | 1799 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1800 | } |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1801 | pNewBssDescriptor = qdf_mem_malloc(size); |
Arif Hussain | 0ef7708 | 2018-10-10 16:42:53 -0700 | [diff] [blame] | 1802 | if (pNewBssDescriptor) |
Abhishek Singh | f723e3d | 2018-02-20 18:02:37 +0530 | [diff] [blame] | 1803 | return QDF_STATUS_E_FAILURE; |
Arif Hussain | 0ef7708 | 2018-10-10 16:42:53 -0700 | [diff] [blame] | 1804 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1805 | qdf_mem_copy(pNewBssDescriptor, pSession->pConnectBssDesc, size); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1806 | /* change the BSSID & channel as passed */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1807 | qdf_mem_copy(pNewBssDescriptor->bssId, bssid.bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1808 | sizeof(tSirMacAddr)); |
| 1809 | pNewBssDescriptor->channelId = channel; |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 1810 | if (!csr_scan_append_bss_description(mac, pNewBssDescriptor)) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1811 | sme_err("csr_scan_append_bss_description failed"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1812 | status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1813 | goto free_mem; |
| 1814 | } |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1815 | sme_err("entry successfully added in scan cache"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1816 | |
| 1817 | free_mem: |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 1818 | if (pNewBssDescriptor) |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1819 | qdf_mem_free(pNewBssDescriptor); |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 1820 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1821 | return status; |
| 1822 | } |
| 1823 | |
| 1824 | #ifdef FEATURE_WLAN_ESE |
| 1825 | /* Update the TSF with the difference in system time */ |
| 1826 | void update_cckmtsf(uint32_t *timeStamp0, uint32_t *timeStamp1, |
Arun Khandavalli | 8a711cb | 2017-01-03 20:23:56 +0530 | [diff] [blame] | 1827 | uint64_t *incr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1828 | { |
| 1829 | uint64_t timeStamp64 = ((uint64_t) *timeStamp1 << 32) | (*timeStamp0); |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 1830 | |
Arun Khandavalli | 8a711cb | 2017-01-03 20:23:56 +0530 | [diff] [blame] | 1831 | timeStamp64 = (uint64_t)(timeStamp64 + (*incr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1832 | *timeStamp0 = (uint32_t) (timeStamp64 & 0xffffffff); |
| 1833 | *timeStamp1 = (uint32_t) ((timeStamp64 >> 32) & 0xffffffff); |
| 1834 | } |
| 1835 | #endif |
| 1836 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1837 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
Pragaspathi Thilagaraj | 1d8e2ab | 2019-03-04 23:59:21 +0530 | [diff] [blame] | 1838 | QDF_STATUS |
| 1839 | csr_rso_save_ap_to_scan_cache(struct mac_context *mac, |
| 1840 | struct roam_offload_synch_ind *roam_sync_ind_ptr, |
| 1841 | struct bss_description *bss_desc_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1842 | { |
| 1843 | uint32_t length = 0; |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 1844 | struct tag_csrscan_result *scan_res_ptr = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1845 | |
| 1846 | length = roam_sync_ind_ptr->beaconProbeRespLength - |
| 1847 | (SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_SSID_OFFSET); |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 1848 | scan_res_ptr = qdf_mem_malloc(sizeof(struct tag_csrscan_result) + |
| 1849 | length); |
Arif Hussain | 0ef7708 | 2018-10-10 16:42:53 -0700 | [diff] [blame] | 1850 | if (!scan_res_ptr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1851 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1852 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1853 | qdf_mem_copy(&scan_res_ptr->Result.BssDescriptor, |
Varun Reddy Yeturu | d5939f8 | 2015-12-24 18:14:02 -0800 | [diff] [blame] | 1854 | bss_desc_ptr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1855 | (sizeof(tSirBssDescription) + length)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1856 | |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 1857 | sme_debug("LFR3:Add BSSID to scan cache" QDF_MAC_ADDR_STR, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 1858 | QDF_MAC_ADDR_ARRAY(scan_res_ptr->Result.BssDescriptor.bssId)); |
Jeff Johnson | c44820d | 2018-11-22 13:40:38 -0800 | [diff] [blame] | 1859 | csr_scan_add_result(mac, scan_res_ptr); |
| 1860 | csr_free_scan_result_entry(mac, scan_res_ptr); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1861 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1862 | } |
| 1863 | #endif |
Jeff Johnson | 8c3ecdd | 2018-12-05 08:48:54 -0800 | [diff] [blame] | 1864 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1865 | /** |
Naveen Rawat | 664a7cb | 2017-01-19 17:58:14 -0800 | [diff] [blame] | 1866 | * csr_get_fst_bssdescr_ptr() - This function returns the pointer to first bss |
| 1867 | * description from scan handle |
| 1868 | * @result_handle: an object for the result. |
| 1869 | * |
| 1870 | * Return: first bss descriptor from the scan handle. |
| 1871 | */ |
Pragaspathi Thilagaraj | 1d8e2ab | 2019-03-04 23:59:21 +0530 | [diff] [blame] | 1872 | struct bss_description* |
| 1873 | csr_get_fst_bssdescr_ptr(tScanResultHandle result_handle) |
Naveen Rawat | 664a7cb | 2017-01-19 17:58:14 -0800 | [diff] [blame] | 1874 | { |
| 1875 | tListElem *first_element = NULL; |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 1876 | struct tag_csrscan_result *scan_result = NULL; |
| 1877 | struct scan_result_list *bss_list = |
| 1878 | (struct scan_result_list *)result_handle; |
Naveen Rawat | 664a7cb | 2017-01-19 17:58:14 -0800 | [diff] [blame] | 1879 | |
Jeff Johnson | 038efe7 | 2019-03-18 13:39:31 -0700 | [diff] [blame] | 1880 | if (!bss_list) { |
Naveen Rawat | 664a7cb | 2017-01-19 17:58:14 -0800 | [diff] [blame] | 1881 | QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, |
| 1882 | FL("Empty bss_list")); |
| 1883 | return NULL; |
| 1884 | } |
| 1885 | if (csr_ll_is_list_empty(&bss_list->List, LL_ACCESS_NOLOCK)) { |
| 1886 | QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, |
| 1887 | FL("bss_list->List is empty")); |
Naveen Rawat | 664a7cb | 2017-01-19 17:58:14 -0800 | [diff] [blame] | 1888 | return NULL; |
| 1889 | } |
| 1890 | first_element = csr_ll_peek_head(&bss_list->List, LL_ACCESS_NOLOCK); |
Jeff Johnson | 038efe7 | 2019-03-18 13:39:31 -0700 | [diff] [blame] | 1891 | if (!first_element) { |
Naveen Rawat | 664a7cb | 2017-01-19 17:58:14 -0800 | [diff] [blame] | 1892 | QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, |
| 1893 | FL("peer head return NULL")); |
| 1894 | return NULL; |
| 1895 | } |
| 1896 | |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 1897 | scan_result = GET_BASE_ADDR(first_element, struct tag_csrscan_result, |
| 1898 | Link); |
Naveen Rawat | 664a7cb | 2017-01-19 17:58:14 -0800 | [diff] [blame] | 1899 | |
| 1900 | return &scan_result->Result.BssDescriptor; |
| 1901 | } |
| 1902 | |
| 1903 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1904 | * csr_get_bssdescr_from_scan_handle() - This function to extract |
| 1905 | * first bss description from scan handle |
| 1906 | * @result_handle: an object for the result. |
| 1907 | * |
| 1908 | * This function is written to extract first bss from scan handle. |
| 1909 | * |
| 1910 | * Return: first bss descriptor from the scan handle. |
| 1911 | */ |
Jeff Johnson | 8c3ecdd | 2018-12-05 08:48:54 -0800 | [diff] [blame] | 1912 | tSirBssDescription * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1913 | csr_get_bssdescr_from_scan_handle(tScanResultHandle result_handle, |
Jeff Johnson | 8c3ecdd | 2018-12-05 08:48:54 -0800 | [diff] [blame] | 1914 | tSirBssDescription *bss_descr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1915 | { |
| 1916 | tListElem *first_element = NULL; |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 1917 | struct tag_csrscan_result *scan_result = NULL; |
| 1918 | struct scan_result_list *bss_list = |
| 1919 | (struct scan_result_list *)result_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1920 | |
Jeff Johnson | 038efe7 | 2019-03-18 13:39:31 -0700 | [diff] [blame] | 1921 | if (!bss_list) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1922 | QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1923 | FL("Empty bss_list")); |
| 1924 | return NULL; |
| 1925 | } |
| 1926 | if (csr_ll_is_list_empty(&bss_list->List, LL_ACCESS_NOLOCK)) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1927 | QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1928 | FL("bss_list->List is empty")); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1929 | qdf_mem_free(bss_list); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1930 | return NULL; |
| 1931 | } |
| 1932 | first_element = csr_ll_peek_head(&bss_list->List, LL_ACCESS_NOLOCK); |
| 1933 | if (first_element) { |
| 1934 | scan_result = GET_BASE_ADDR(first_element, |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 1935 | struct tag_csrscan_result, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1936 | Link); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1937 | qdf_mem_copy(bss_descr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1938 | &scan_result->Result.BssDescriptor, |
| 1939 | sizeof(tSirBssDescription)); |
| 1940 | } |
| 1941 | return bss_descr; |
| 1942 | } |
| 1943 | |
Tushnim Bhattacharyya | 3f78053 | 2018-08-01 19:11:40 -0700 | [diff] [blame] | 1944 | uint8_t |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 1945 | csr_get_channel_for_hw_mode_change(struct mac_context *mac_ctx, |
Tushnim Bhattacharyya | 3f78053 | 2018-08-01 19:11:40 -0700 | [diff] [blame] | 1946 | tScanResultHandle result_handle, |
| 1947 | uint32_t session_id) |
| 1948 | { |
| 1949 | tListElem *next_element = NULL; |
| 1950 | struct tag_csrscan_result *scan_result = NULL; |
| 1951 | struct scan_result_list *bss_list = |
| 1952 | (struct scan_result_list *)result_handle; |
| 1953 | uint8_t channel_id = 0; |
| 1954 | |
Jeff Johnson | 038efe7 | 2019-03-18 13:39:31 -0700 | [diff] [blame] | 1955 | if (!bss_list) { |
Tushnim Bhattacharyya | 3f78053 | 2018-08-01 19:11:40 -0700 | [diff] [blame] | 1956 | QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, |
| 1957 | FL("Empty bss_list")); |
| 1958 | goto end; |
| 1959 | } |
| 1960 | |
| 1961 | if (policy_mgr_is_hw_dbs_capable(mac_ctx->psoc) == false) { |
| 1962 | QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG, |
| 1963 | FL("driver isn't dbs capable")); |
| 1964 | goto end; |
| 1965 | } |
| 1966 | |
| 1967 | if (policy_mgr_is_current_hwmode_dbs(mac_ctx->psoc)) { |
| 1968 | QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG, |
| 1969 | FL("driver is already in DBS")); |
| 1970 | goto end; |
| 1971 | } |
| 1972 | |
| 1973 | if (!policy_mgr_is_dbs_allowed_for_concurrency(mac_ctx->psoc, |
| 1974 | QDF_STA_MODE)) { |
| 1975 | QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG, |
| 1976 | FL("DBS is not allowed for this concurrency combo")); |
| 1977 | goto end; |
| 1978 | } |
| 1979 | |
| 1980 | if (!policy_mgr_is_hw_dbs_2x2_capable(mac_ctx->psoc) && |
| 1981 | !policy_mgr_get_connection_count(mac_ctx->psoc)) { |
| 1982 | QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG, |
| 1983 | FL("1x1 DBS HW with no prior connection")); |
| 1984 | goto end; |
| 1985 | } |
| 1986 | |
| 1987 | if (csr_ll_is_list_empty(&bss_list->List, LL_ACCESS_NOLOCK)) { |
| 1988 | QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, |
| 1989 | FL("bss_list->List is empty")); |
| 1990 | qdf_mem_free(bss_list); |
| 1991 | goto end; |
| 1992 | } |
| 1993 | |
| 1994 | next_element = csr_ll_peek_head(&bss_list->List, LL_ACCESS_NOLOCK); |
| 1995 | while (next_element) { |
| 1996 | scan_result = GET_BASE_ADDR(next_element, |
| 1997 | struct tag_csrscan_result, |
| 1998 | Link); |
| 1999 | if (policy_mgr_is_hw_dbs_2x2_capable(mac_ctx->psoc)) { |
| 2000 | if (WLAN_REG_IS_24GHZ_CH |
| 2001 | (scan_result->Result.BssDescriptor.channelId)) { |
| 2002 | channel_id = |
| 2003 | scan_result-> |
| 2004 | Result.BssDescriptor.channelId; |
| 2005 | break; |
| 2006 | } |
| 2007 | } else { |
| 2008 | if (WLAN_REG_IS_24GHZ_CH |
| 2009 | (scan_result->Result.BssDescriptor.channelId) && |
| 2010 | policy_mgr_is_any_mode_active_on_band_along_with_session |
| 2011 | (mac_ctx->psoc, |
| 2012 | session_id, POLICY_MGR_BAND_5)) { |
| 2013 | channel_id = |
| 2014 | scan_result-> |
| 2015 | Result.BssDescriptor.channelId; |
| 2016 | break; |
| 2017 | } |
| 2018 | if (WLAN_REG_IS_5GHZ_CH |
| 2019 | (scan_result->Result.BssDescriptor.channelId) && |
| 2020 | policy_mgr_is_any_mode_active_on_band_along_with_session |
| 2021 | (mac_ctx->psoc, |
| 2022 | session_id, POLICY_MGR_BAND_24)) { |
| 2023 | channel_id = |
| 2024 | scan_result-> |
| 2025 | Result.BssDescriptor.channelId; |
| 2026 | break; |
| 2027 | } |
| 2028 | } |
| 2029 | next_element = csr_ll_next(&bss_list->List, next_element, |
| 2030 | LL_ACCESS_NOLOCK); |
| 2031 | } |
| 2032 | end: |
| 2033 | return channel_id; |
| 2034 | } |
| 2035 | |
Liangwei Dong | 1ba9948 | 2018-10-19 02:57:29 -0400 | [diff] [blame] | 2036 | uint8_t |
Jeff Johnson | 8c3ecdd | 2018-12-05 08:48:54 -0800 | [diff] [blame] | 2037 | csr_scan_get_channel_for_hw_mode_change(struct mac_context *mac_ctx, |
| 2038 | uint32_t session_id, |
| 2039 | struct csr_roam_profile *profile) |
Liangwei Dong | 1ba9948 | 2018-10-19 02:57:29 -0400 | [diff] [blame] | 2040 | { |
| 2041 | tScanResultHandle result_handle = NULL; |
| 2042 | QDF_STATUS status; |
| 2043 | uint8_t first_ap_ch = 0; |
| 2044 | uint8_t candidate_chan; |
| 2045 | |
| 2046 | status = sme_get_ap_channel_from_scan_cache(profile, &result_handle, |
| 2047 | &first_ap_ch); |
| 2048 | if (status != QDF_STATUS_SUCCESS || !result_handle || !first_ap_ch) { |
| 2049 | if (result_handle) |
| 2050 | sme_scan_result_purge(result_handle); |
| 2051 | sme_err("fail get scan result: status %d first ap ch %d", |
| 2052 | status, first_ap_ch); |
| 2053 | return 0; |
| 2054 | } |
| 2055 | if (!policy_mgr_check_for_session_conc(mac_ctx->psoc, session_id, |
| 2056 | first_ap_ch)) { |
| 2057 | sme_scan_result_purge(result_handle); |
| 2058 | sme_err("Conc not allowed for the session %d ch %d", |
| 2059 | session_id, first_ap_ch); |
| 2060 | return 0; |
| 2061 | } |
| 2062 | |
| 2063 | candidate_chan = csr_get_channel_for_hw_mode_change(mac_ctx, |
| 2064 | result_handle, |
| 2065 | session_id); |
| 2066 | sme_scan_result_purge(result_handle); |
| 2067 | if (!candidate_chan) |
| 2068 | candidate_chan = first_ap_ch; |
| 2069 | sme_debug("session %d hw mode check candidate_chan %d", session_id, |
| 2070 | candidate_chan); |
| 2071 | |
| 2072 | return candidate_chan; |
| 2073 | } |
| 2074 | |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2075 | static enum wlan_auth_type csr_covert_auth_type_new(eCsrAuthType auth) |
| 2076 | { |
| 2077 | switch (auth) { |
| 2078 | case eCSR_AUTH_TYPE_NONE: |
| 2079 | case eCSR_AUTH_TYPE_OPEN_SYSTEM: |
| 2080 | return WLAN_AUTH_TYPE_OPEN_SYSTEM; |
| 2081 | case eCSR_AUTH_TYPE_SHARED_KEY: |
| 2082 | return WLAN_AUTH_TYPE_SHARED_KEY; |
| 2083 | case eCSR_AUTH_TYPE_AUTOSWITCH: |
| 2084 | return WLAN_AUTH_TYPE_AUTOSWITCH; |
| 2085 | case eCSR_AUTH_TYPE_WPA: |
| 2086 | return WLAN_AUTH_TYPE_WPA; |
| 2087 | case eCSR_AUTH_TYPE_WPA_PSK: |
| 2088 | return WLAN_AUTH_TYPE_WPA_PSK; |
| 2089 | case eCSR_AUTH_TYPE_WPA_NONE: |
| 2090 | return WLAN_AUTH_TYPE_WPA_NONE; |
| 2091 | case eCSR_AUTH_TYPE_RSN: |
| 2092 | return WLAN_AUTH_TYPE_RSN; |
| 2093 | case eCSR_AUTH_TYPE_RSN_PSK: |
| 2094 | return WLAN_AUTH_TYPE_RSN_PSK; |
| 2095 | case eCSR_AUTH_TYPE_FT_RSN: |
| 2096 | return WLAN_AUTH_TYPE_FT_RSN; |
| 2097 | case eCSR_AUTH_TYPE_FT_RSN_PSK: |
| 2098 | return WLAN_AUTH_TYPE_FT_RSN_PSK; |
| 2099 | case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE: |
| 2100 | return WLAN_AUTH_TYPE_WAPI_WAI_CERTIFICATE; |
| 2101 | case eCSR_AUTH_TYPE_WAPI_WAI_PSK: |
| 2102 | return WLAN_AUTH_TYPE_WAPI_WAI_PSK; |
| 2103 | case eCSR_AUTH_TYPE_CCKM_WPA: |
| 2104 | return WLAN_AUTH_TYPE_CCKM_WPA; |
| 2105 | case eCSR_AUTH_TYPE_CCKM_RSN: |
| 2106 | return WLAN_AUTH_TYPE_CCKM_RSN; |
| 2107 | case eCSR_AUTH_TYPE_RSN_PSK_SHA256: |
| 2108 | return WLAN_AUTH_TYPE_RSN_PSK_SHA256; |
| 2109 | case eCSR_AUTH_TYPE_RSN_8021X_SHA256: |
| 2110 | return WLAN_AUTH_TYPE_RSN_8021X_SHA256; |
Sridhar Selvaraj | 6cf642f | 2017-08-21 14:28:10 +0530 | [diff] [blame] | 2111 | case eCSR_AUTH_TYPE_FILS_SHA256: |
| 2112 | return WLAN_AUTH_TYPE_FILS_SHA256; |
| 2113 | case eCSR_AUTH_TYPE_FILS_SHA384: |
| 2114 | return WLAN_AUTH_TYPE_FILS_SHA384; |
| 2115 | case eCSR_AUTH_TYPE_FT_FILS_SHA256: |
| 2116 | return WLAN_AUTH_TYPE_FT_FILS_SHA256; |
| 2117 | case eCSR_AUTH_TYPE_FT_FILS_SHA384: |
| 2118 | return WLAN_AUTH_TYPE_FT_FILS_SHA384; |
Abhishek Singh | 02cb9e0 | 2017-08-30 17:39:50 +0530 | [diff] [blame] | 2119 | case eCSR_AUTH_TYPE_DPP_RSN: |
| 2120 | return WLAN_AUTH_TYPE_DPP_RSN; |
Padma, Santhosh Kumar | c69ce07 | 2017-11-06 18:21:05 +0530 | [diff] [blame] | 2121 | case eCSR_AUTH_TYPE_OWE: |
| 2122 | return WLAN_AUTH_TYPE_OWE; |
Padma, Santhosh Kumar | e587a5c | 2017-12-21 12:44:46 +0530 | [diff] [blame] | 2123 | case eCSR_AUTH_TYPE_SUITEB_EAP_SHA256: |
| 2124 | return WLAN_AUTH_TYPE_SUITEB_EAP_SHA256; |
| 2125 | case eCSR_AUTH_TYPE_SUITEB_EAP_SHA384: |
| 2126 | return WLAN_AUTH_TYPE_SUITEB_EAP_SHA384; |
Padma, Santhosh Kumar | 07eb80b | 2017-07-05 16:10:06 +0530 | [diff] [blame] | 2127 | case eCSR_AUTH_TYPE_SAE: |
| 2128 | return WLAN_AUTH_TYPE_SAE; |
Srinivas Dasari | b328f1a | 2018-12-18 17:45:06 +0530 | [diff] [blame] | 2129 | case eCSR_AUTH_TYPE_OSEN: |
| 2130 | return WLAN_AUTH_TYPE_OSEN; |
Pragaspathi Thilagaraj | 96259b2 | 2019-02-15 01:08:27 +0530 | [diff] [blame] | 2131 | case eCSR_AUTH_TYPE_FT_SAE: |
| 2132 | return WLAN_AUTH_TYPE_FT_SAE; |
| 2133 | case eCSR_AUTH_TYPE_FT_SUITEB_EAP_SHA384: |
| 2134 | return WLAN_AUTH_TYPE_FT_SUITEB_EAP_SHA384; |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2135 | case eCSR_NUM_OF_SUPPORT_AUTH_TYPE: |
| 2136 | default: |
| 2137 | return WLAN_AUTH_TYPE_OPEN_SYSTEM; |
| 2138 | } |
| 2139 | } |
| 2140 | |
| 2141 | static eCsrAuthType csr_covert_auth_type_old(enum wlan_auth_type auth) |
| 2142 | { |
| 2143 | switch (auth) { |
| 2144 | case WLAN_AUTH_TYPE_OPEN_SYSTEM: |
| 2145 | return eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 2146 | case WLAN_AUTH_TYPE_SHARED_KEY: |
| 2147 | return eCSR_AUTH_TYPE_SHARED_KEY; |
| 2148 | case WLAN_AUTH_TYPE_AUTOSWITCH: |
| 2149 | return eCSR_AUTH_TYPE_AUTOSWITCH; |
| 2150 | case WLAN_AUTH_TYPE_WPA: |
| 2151 | return eCSR_AUTH_TYPE_WPA; |
| 2152 | case WLAN_AUTH_TYPE_WPA_PSK: |
| 2153 | return eCSR_AUTH_TYPE_WPA_PSK; |
| 2154 | case WLAN_AUTH_TYPE_WPA_NONE: |
| 2155 | return eCSR_AUTH_TYPE_WPA_NONE; |
| 2156 | case WLAN_AUTH_TYPE_RSN: |
| 2157 | return eCSR_AUTH_TYPE_RSN; |
| 2158 | case WLAN_AUTH_TYPE_RSN_PSK: |
| 2159 | return eCSR_AUTH_TYPE_RSN_PSK; |
| 2160 | case WLAN_AUTH_TYPE_FT_RSN: |
| 2161 | return eCSR_AUTH_TYPE_FT_RSN; |
| 2162 | case WLAN_AUTH_TYPE_FT_RSN_PSK: |
| 2163 | return eCSR_AUTH_TYPE_FT_RSN_PSK; |
| 2164 | case WLAN_AUTH_TYPE_WAPI_WAI_CERTIFICATE: |
| 2165 | return eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE; |
| 2166 | case WLAN_AUTH_TYPE_WAPI_WAI_PSK: |
| 2167 | return eCSR_AUTH_TYPE_WAPI_WAI_PSK; |
| 2168 | case WLAN_AUTH_TYPE_CCKM_WPA: |
| 2169 | return eCSR_AUTH_TYPE_CCKM_WPA; |
| 2170 | case WLAN_AUTH_TYPE_CCKM_RSN: |
| 2171 | return eCSR_AUTH_TYPE_CCKM_RSN; |
| 2172 | case WLAN_AUTH_TYPE_RSN_PSK_SHA256: |
| 2173 | return eCSR_AUTH_TYPE_RSN_PSK_SHA256; |
| 2174 | case WLAN_AUTH_TYPE_RSN_8021X_SHA256: |
| 2175 | return eCSR_AUTH_TYPE_RSN_8021X_SHA256; |
Sridhar Selvaraj | 6cf642f | 2017-08-21 14:28:10 +0530 | [diff] [blame] | 2176 | case WLAN_AUTH_TYPE_FILS_SHA256: |
| 2177 | return eCSR_AUTH_TYPE_FILS_SHA256; |
| 2178 | case WLAN_AUTH_TYPE_FILS_SHA384: |
| 2179 | return eCSR_AUTH_TYPE_FILS_SHA384; |
| 2180 | case WLAN_AUTH_TYPE_FT_FILS_SHA256: |
| 2181 | return eCSR_AUTH_TYPE_FT_FILS_SHA256; |
| 2182 | case WLAN_AUTH_TYPE_FT_FILS_SHA384: |
| 2183 | return eCSR_AUTH_TYPE_FT_FILS_SHA384; |
Abhishek Singh | 02cb9e0 | 2017-08-30 17:39:50 +0530 | [diff] [blame] | 2184 | case WLAN_AUTH_TYPE_DPP_RSN: |
| 2185 | return eCSR_AUTH_TYPE_DPP_RSN; |
Padma, Santhosh Kumar | c69ce07 | 2017-11-06 18:21:05 +0530 | [diff] [blame] | 2186 | case WLAN_AUTH_TYPE_OWE: |
| 2187 | return eCSR_AUTH_TYPE_OWE; |
Padma, Santhosh Kumar | e587a5c | 2017-12-21 12:44:46 +0530 | [diff] [blame] | 2188 | case WLAN_AUTH_TYPE_SUITEB_EAP_SHA256: |
| 2189 | return eCSR_AUTH_TYPE_SUITEB_EAP_SHA256; |
| 2190 | case WLAN_AUTH_TYPE_SUITEB_EAP_SHA384: |
| 2191 | return eCSR_AUTH_TYPE_SUITEB_EAP_SHA384; |
Padma, Santhosh Kumar | 07eb80b | 2017-07-05 16:10:06 +0530 | [diff] [blame] | 2192 | case WLAN_AUTH_TYPE_SAE: |
| 2193 | return eCSR_AUTH_TYPE_SAE; |
Srinivas Dasari | b328f1a | 2018-12-18 17:45:06 +0530 | [diff] [blame] | 2194 | case WLAN_AUTH_TYPE_OSEN: |
| 2195 | return eCSR_AUTH_TYPE_OSEN; |
Pragaspathi Thilagaraj | 96259b2 | 2019-02-15 01:08:27 +0530 | [diff] [blame] | 2196 | case WLAN_AUTH_TYPE_FT_SAE: |
| 2197 | return eCSR_AUTH_TYPE_FT_SAE; |
| 2198 | case WLAN_AUTH_TYPE_FT_SUITEB_EAP_SHA384: |
| 2199 | return eCSR_AUTH_TYPE_FT_SUITEB_EAP_SHA384; |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2200 | case WLAN_NUM_OF_SUPPORT_AUTH_TYPE: |
| 2201 | default: |
| 2202 | return eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 2203 | } |
| 2204 | } |
| 2205 | |
| 2206 | static enum wlan_enc_type csr_covert_enc_type_new(eCsrEncryptionType enc) |
| 2207 | { |
| 2208 | switch (enc) { |
| 2209 | case eCSR_ENCRYPT_TYPE_NONE: |
| 2210 | return WLAN_ENCRYPT_TYPE_NONE; |
| 2211 | case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY: |
| 2212 | return WLAN_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 2213 | case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY: |
| 2214 | return WLAN_ENCRYPT_TYPE_WEP104_STATICKEY; |
| 2215 | case eCSR_ENCRYPT_TYPE_WEP40: |
| 2216 | return WLAN_ENCRYPT_TYPE_WEP40; |
| 2217 | case eCSR_ENCRYPT_TYPE_WEP104: |
| 2218 | return WLAN_ENCRYPT_TYPE_WEP104; |
| 2219 | case eCSR_ENCRYPT_TYPE_TKIP: |
| 2220 | return WLAN_ENCRYPT_TYPE_TKIP; |
| 2221 | case eCSR_ENCRYPT_TYPE_AES: |
| 2222 | return WLAN_ENCRYPT_TYPE_AES; |
| 2223 | case eCSR_ENCRYPT_TYPE_WPI: |
| 2224 | return WLAN_ENCRYPT_TYPE_WPI; |
| 2225 | case eCSR_ENCRYPT_TYPE_KRK: |
| 2226 | return WLAN_ENCRYPT_TYPE_KRK; |
| 2227 | case eCSR_ENCRYPT_TYPE_BTK: |
| 2228 | return WLAN_ENCRYPT_TYPE_BTK; |
| 2229 | case eCSR_ENCRYPT_TYPE_AES_CMAC: |
| 2230 | return WLAN_ENCRYPT_TYPE_AES_CMAC; |
Mukul Sharma | 05504ac | 2017-06-08 12:35:53 +0530 | [diff] [blame] | 2231 | case eCSR_ENCRYPT_TYPE_AES_GCMP: |
| 2232 | return WLAN_ENCRYPT_TYPE_AES_GCMP; |
| 2233 | case eCSR_ENCRYPT_TYPE_AES_GCMP_256: |
| 2234 | return WLAN_ENCRYPT_TYPE_AES_GCMP_256; |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2235 | case eCSR_ENCRYPT_TYPE_ANY: |
| 2236 | default: |
| 2237 | return WLAN_ENCRYPT_TYPE_NONE; |
| 2238 | } |
| 2239 | } |
| 2240 | |
| 2241 | static eCsrEncryptionType csr_covert_enc_type_old(enum wlan_enc_type enc) |
| 2242 | { |
| 2243 | switch (enc) { |
| 2244 | case WLAN_ENCRYPT_TYPE_NONE: |
| 2245 | return eCSR_ENCRYPT_TYPE_NONE; |
| 2246 | case WLAN_ENCRYPT_TYPE_WEP40_STATICKEY: |
| 2247 | return eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 2248 | case WLAN_ENCRYPT_TYPE_WEP104_STATICKEY: |
| 2249 | return eCSR_ENCRYPT_TYPE_WEP104_STATICKEY; |
| 2250 | case WLAN_ENCRYPT_TYPE_WEP40: |
| 2251 | return eCSR_ENCRYPT_TYPE_WEP40; |
| 2252 | case WLAN_ENCRYPT_TYPE_WEP104: |
| 2253 | return eCSR_ENCRYPT_TYPE_WEP104; |
| 2254 | case WLAN_ENCRYPT_TYPE_TKIP: |
| 2255 | return eCSR_ENCRYPT_TYPE_TKIP; |
| 2256 | case WLAN_ENCRYPT_TYPE_AES: |
| 2257 | return eCSR_ENCRYPT_TYPE_AES; |
| 2258 | case WLAN_ENCRYPT_TYPE_WPI: |
| 2259 | return eCSR_ENCRYPT_TYPE_WPI; |
| 2260 | case WLAN_ENCRYPT_TYPE_KRK: |
| 2261 | return eCSR_ENCRYPT_TYPE_KRK; |
| 2262 | case WLAN_ENCRYPT_TYPE_BTK: |
| 2263 | return eCSR_ENCRYPT_TYPE_BTK; |
| 2264 | case WLAN_ENCRYPT_TYPE_AES_CMAC: |
| 2265 | return eCSR_ENCRYPT_TYPE_AES_CMAC; |
Mukul Sharma | 05504ac | 2017-06-08 12:35:53 +0530 | [diff] [blame] | 2266 | case WLAN_ENCRYPT_TYPE_AES_GCMP: |
| 2267 | return eCSR_ENCRYPT_TYPE_AES_GCMP; |
| 2268 | case WLAN_ENCRYPT_TYPE_AES_GCMP_256: |
| 2269 | return eCSR_ENCRYPT_TYPE_AES_GCMP_256; |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2270 | case WLAN_ENCRYPT_TYPE_ANY: |
| 2271 | default: |
| 2272 | return eCSR_ENCRYPT_TYPE_NONE; |
| 2273 | } |
| 2274 | } |
| 2275 | |
Padma, Santhosh Kumar | 4117d7a | 2017-12-20 17:39:33 +0530 | [diff] [blame] | 2276 | #ifdef WLAN_FEATURE_11W |
| 2277 | /** |
| 2278 | * csr_update_pmf_cap: Updates PMF cap |
| 2279 | * @src_filter: Source filter |
| 2280 | * @dst_filter: Destination filter |
| 2281 | * |
| 2282 | * Return: None |
| 2283 | */ |
| 2284 | static void csr_update_pmf_cap(tCsrScanResultFilter *src_filter, |
Jeff Johnson | 8c3ecdd | 2018-12-05 08:48:54 -0800 | [diff] [blame] | 2285 | struct scan_filter *dst_filter) { |
Padma, Santhosh Kumar | 4117d7a | 2017-12-20 17:39:33 +0530 | [diff] [blame] | 2286 | |
| 2287 | if (src_filter->MFPCapable || src_filter->MFPEnabled) |
| 2288 | dst_filter->pmf_cap = WLAN_PMF_CAPABLE; |
| 2289 | if (src_filter->MFPRequired) |
| 2290 | dst_filter->pmf_cap = WLAN_PMF_REQUIRED; |
| 2291 | } |
| 2292 | #else |
| 2293 | static inline void csr_update_pmf_cap(tCsrScanResultFilter *src_filter, |
Jeff Johnson | 8c3ecdd | 2018-12-05 08:48:54 -0800 | [diff] [blame] | 2294 | struct scan_filter *dst_filter) |
Padma, Santhosh Kumar | 4117d7a | 2017-12-20 17:39:33 +0530 | [diff] [blame] | 2295 | {} |
| 2296 | #endif |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2297 | |
Sandeep Puligilla | 2fcc254 | 2018-03-27 17:54:06 -0700 | [diff] [blame] | 2298 | /** |
| 2299 | * csr_convert_dotllmod_phymode: Convert eCsrPhyMode to wlan_phymode |
| 2300 | * @dotllmode: phy mode |
| 2301 | * |
| 2302 | * Return: returns enum wlan_phymode |
| 2303 | */ |
| 2304 | static enum wlan_phymode csr_convert_dotllmod_phymode(eCsrPhyMode dotllmode) |
| 2305 | { |
| 2306 | |
| 2307 | enum wlan_phymode con_phy_mode; |
| 2308 | |
| 2309 | switch (dotllmode) { |
| 2310 | case eCSR_DOT11_MODE_abg: |
| 2311 | con_phy_mode = WLAN_PHYMODE_AUTO; |
| 2312 | break; |
| 2313 | case eCSR_DOT11_MODE_11a: |
| 2314 | con_phy_mode = WLAN_PHYMODE_11A; |
| 2315 | break; |
| 2316 | case eCSR_DOT11_MODE_11b: |
| 2317 | con_phy_mode = WLAN_PHYMODE_11B; |
| 2318 | break; |
| 2319 | case eCSR_DOT11_MODE_11g: |
| 2320 | con_phy_mode = WLAN_PHYMODE_11G; |
| 2321 | break; |
| 2322 | case eCSR_DOT11_MODE_11n: |
| 2323 | con_phy_mode = WLAN_PHYMODE_11NA_HT20; |
| 2324 | break; |
| 2325 | case eCSR_DOT11_MODE_11g_ONLY: |
| 2326 | con_phy_mode = WLAN_PHYMODE_11G; |
| 2327 | break; |
| 2328 | case eCSR_DOT11_MODE_11n_ONLY: |
| 2329 | con_phy_mode = WLAN_PHYMODE_11NA_HT20; |
| 2330 | break; |
| 2331 | case eCSR_DOT11_MODE_11b_ONLY: |
| 2332 | con_phy_mode = WLAN_PHYMODE_11B; |
| 2333 | break; |
| 2334 | case eCSR_DOT11_MODE_11ac: |
| 2335 | con_phy_mode = WLAN_PHYMODE_11AC_VHT160; |
| 2336 | break; |
| 2337 | case eCSR_DOT11_MODE_11ac_ONLY: |
| 2338 | con_phy_mode = WLAN_PHYMODE_11AC_VHT160; |
| 2339 | break; |
| 2340 | case eCSR_DOT11_MODE_AUTO: |
| 2341 | con_phy_mode = WLAN_PHYMODE_AUTO; |
| 2342 | break; |
| 2343 | case eCSR_DOT11_MODE_11ax: |
| 2344 | con_phy_mode = WLAN_PHYMODE_11AXA_HE160; |
| 2345 | break; |
| 2346 | case eCSR_DOT11_MODE_11ax_ONLY: |
| 2347 | con_phy_mode = WLAN_PHYMODE_11AXA_HE160; |
| 2348 | break; |
| 2349 | default: |
| 2350 | con_phy_mode = WLAN_PHYMODE_AUTO; |
| 2351 | break; |
| 2352 | } |
| 2353 | |
| 2354 | return con_phy_mode; |
| 2355 | } |
| 2356 | |
Pragaspathi Thilagaraj | 1f3f99f | 2019-04-24 23:48:47 +0530 | [diff] [blame^] | 2357 | #ifdef WLAN_ADAPTIVE_11R |
| 2358 | /** |
| 2359 | * csr_update_adaptive_11r_scan_filter - Copy adaptive 11r ini to scan |
| 2360 | * module |
| 2361 | * @mac_ctx: Pointer to mac_context |
| 2362 | * @scan_filter: Scan filter to be sent to scan module |
| 2363 | * |
| 2364 | * Return: None |
| 2365 | */ |
| 2366 | static void |
| 2367 | csr_update_adaptive_11r_scan_filter(struct mac_context *mac_ctx, |
| 2368 | struct scan_filter *filter) |
| 2369 | { |
| 2370 | filter->enable_adaptive_11r = |
| 2371 | mac_ctx->mlme_cfg->lfr.enable_adaptive_11r; |
| 2372 | } |
| 2373 | #else |
| 2374 | static inline void |
| 2375 | csr_update_adaptive_11r_scan_filter(struct mac_context *mac_ctx, |
| 2376 | struct scan_filter *filter) |
| 2377 | { |
| 2378 | filter->enable_adaptive_11r = false; |
| 2379 | } |
| 2380 | #endif |
| 2381 | |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 2382 | static QDF_STATUS csr_prepare_scan_filter(struct mac_context *mac_ctx, |
Jeff Johnson | 8c3ecdd | 2018-12-05 08:48:54 -0800 | [diff] [blame] | 2383 | tCsrScanResultFilter *pFilter, |
| 2384 | struct scan_filter *filter) |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2385 | { |
| 2386 | int i; |
| 2387 | uint32_t len = 0; |
| 2388 | QDF_STATUS status; |
Tushnim Bhattacharyya | 0c4ad2d | 2017-03-09 15:59:03 -0800 | [diff] [blame] | 2389 | enum policy_mgr_con_mode new_mode; |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2390 | |
| 2391 | filter->num_of_bssid = pFilter->BSSIDs.numOfBSSIDs; |
| 2392 | if (filter->num_of_bssid > WLAN_SCAN_FILTER_NUM_BSSID) |
| 2393 | filter->num_of_bssid = WLAN_SCAN_FILTER_NUM_BSSID; |
| 2394 | for (i = 0; i < filter->num_of_bssid; i++) |
| 2395 | qdf_mem_copy(filter->bssid_list[i].bytes, |
| 2396 | pFilter->BSSIDs.bssid[i].bytes, |
| 2397 | QDF_MAC_ADDR_SIZE); |
| 2398 | |
| 2399 | filter->num_of_ssid = pFilter->SSIDs.numOfSSIDs; |
| 2400 | if (filter->num_of_ssid > WLAN_SCAN_FILTER_NUM_SSID) |
| 2401 | filter->num_of_ssid = WLAN_SCAN_FILTER_NUM_SSID; |
| 2402 | for (i = 0; i < filter->num_of_ssid; i++) { |
| 2403 | filter->ssid_list[i].length = |
| 2404 | pFilter->SSIDs.SSIDList[i].SSID.length; |
| 2405 | qdf_mem_copy(filter->ssid_list[i].ssid, |
| 2406 | pFilter->SSIDs.SSIDList[i].SSID.ssId, |
| 2407 | filter->ssid_list[i].length); |
| 2408 | } |
| 2409 | |
| 2410 | filter->num_of_channels = |
| 2411 | pFilter->ChannelInfo.numOfChannels; |
| 2412 | if (filter->num_of_channels > QDF_MAX_NUM_CHAN) |
| 2413 | filter->num_of_channels = QDF_MAX_NUM_CHAN; |
| 2414 | qdf_mem_copy(filter->channel_list, |
| 2415 | pFilter->ChannelInfo.ChannelList, |
| 2416 | filter->num_of_channels); |
| 2417 | |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 2418 | if (pFilter->realm_check) { |
| 2419 | filter->fils_scan_filter.realm_check = true; |
| 2420 | qdf_mem_copy(filter->fils_scan_filter.fils_realm, |
| 2421 | pFilter->fils_realm, REAM_HASH_LEN); |
| 2422 | } |
| 2423 | |
Abhishek Singh | edb7360 | 2018-02-20 15:20:26 +0530 | [diff] [blame] | 2424 | if (pFilter->force_rsne_override) { |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2425 | |
Abhishek Singh | 821f09c | 2018-02-26 15:18:40 +0530 | [diff] [blame] | 2426 | sme_debug("force_rsne_override set auth type and enctype to any and ignore pmf cap"); |
Abhishek Singh | edb7360 | 2018-02-20 15:20:26 +0530 | [diff] [blame] | 2427 | |
Abhishek Singh | 821f09c | 2018-02-26 15:18:40 +0530 | [diff] [blame] | 2428 | filter->num_of_auth = 1; |
| 2429 | filter->auth_type[0] = WLAN_AUTH_TYPE_ANY; |
| 2430 | filter->num_of_enc_type = 1; |
| 2431 | filter->enc_type[0] = WLAN_ENCRYPT_TYPE_ANY; |
| 2432 | filter->num_of_mc_enc_type = 1; |
| 2433 | filter->mc_enc_type[0] = WLAN_ENCRYPT_TYPE_ANY; |
| 2434 | |
Abhishek Singh | 6378103 | 2018-02-23 14:59:22 +0530 | [diff] [blame] | 2435 | filter->ignore_pmf_cap = true; |
Abhishek Singh | edb7360 | 2018-02-20 15:20:26 +0530 | [diff] [blame] | 2436 | } else { |
| 2437 | filter->num_of_auth = |
| 2438 | pFilter->authType.numEntries; |
| 2439 | if (filter->num_of_auth > WLAN_NUM_OF_SUPPORT_AUTH_TYPE) |
| 2440 | filter->num_of_auth = WLAN_NUM_OF_SUPPORT_AUTH_TYPE; |
| 2441 | for (i = 0; i < filter->num_of_auth; i++) |
| 2442 | filter->auth_type[i] = |
| 2443 | csr_covert_auth_type_new( |
| 2444 | pFilter->authType.authType[i]); |
| 2445 | filter->num_of_enc_type = |
| 2446 | pFilter->EncryptionType.numEntries; |
| 2447 | if (filter->num_of_enc_type > WLAN_NUM_OF_ENCRYPT_TYPE) |
| 2448 | filter->num_of_enc_type = WLAN_NUM_OF_ENCRYPT_TYPE; |
| 2449 | for (i = 0; i < filter->num_of_enc_type; i++) |
| 2450 | filter->enc_type[i] = |
| 2451 | csr_covert_enc_type_new( |
| 2452 | pFilter->EncryptionType.encryptionType[i]); |
| 2453 | filter->num_of_mc_enc_type = |
| 2454 | pFilter->mcEncryptionType.numEntries; |
| 2455 | if (filter->num_of_mc_enc_type > WLAN_NUM_OF_ENCRYPT_TYPE) |
| 2456 | filter->num_of_mc_enc_type = WLAN_NUM_OF_ENCRYPT_TYPE; |
| 2457 | for (i = 0; i < filter->num_of_mc_enc_type; i++) |
| 2458 | filter->mc_enc_type[i] = |
| 2459 | csr_covert_enc_type_new( |
| 2460 | pFilter->mcEncryptionType.encryptionType[i]); |
| 2461 | } |
Jeff Johnson | 9e76083 | 2018-12-15 12:41:36 -0800 | [diff] [blame] | 2462 | qdf_mem_copy(filter->country, pFilter->countryCode, |
Wu Gao | aa15514 | 2019-01-14 15:09:26 +0800 | [diff] [blame] | 2463 | CFG_COUNTRY_CODE_LEN); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2464 | |
gaurank kathpalia | 2690098 | 2017-12-19 13:57:48 +0530 | [diff] [blame] | 2465 | if (pFilter->bWPSAssociation || pFilter->bOSENAssociation) |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2466 | filter->ignore_auth_enc_type = true; |
| 2467 | |
| 2468 | filter->rrm_measurement_filter = pFilter->fMeasurement; |
| 2469 | |
Jeff Johnson | 9e76083 | 2018-12-15 12:41:36 -0800 | [diff] [blame] | 2470 | filter->mobility_domain = pFilter->mdid.mobility_domain; |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2471 | |
| 2472 | filter->p2p_results = pFilter->p2pResult; |
| 2473 | |
Padma, Santhosh Kumar | 4117d7a | 2017-12-20 17:39:33 +0530 | [diff] [blame] | 2474 | csr_update_pmf_cap(pFilter, filter); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2475 | |
| 2476 | if (pFilter->BSSType == eCSR_BSS_TYPE_INFRASTRUCTURE) |
| 2477 | filter->bss_type = WLAN_TYPE_BSS; |
| 2478 | else if (pFilter->BSSType == eCSR_BSS_TYPE_IBSS || |
| 2479 | pFilter->BSSType == eCSR_BSS_TYPE_START_IBSS) |
| 2480 | filter->bss_type = WLAN_TYPE_IBSS; |
| 2481 | else |
| 2482 | filter->bss_type = WLAN_TYPE_ANY; |
| 2483 | |
Sandeep Puligilla | 2fcc254 | 2018-03-27 17:54:06 -0700 | [diff] [blame] | 2484 | filter->dot11_mode = csr_convert_dotllmod_phymode(pFilter->phyMode); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2485 | |
gaurank kathpalia | 5efa73b | 2017-12-29 10:55:16 +0530 | [diff] [blame] | 2486 | // enable bss scoring for only STA mode |
| 2487 | if (pFilter->csrPersona == QDF_STA_MODE) |
| 2488 | filter->bss_scoring_required = true; |
| 2489 | else |
| 2490 | filter->bss_scoring_required = false; |
Pragaspathi Thilagaraj | 1f3f99f | 2019-04-24 23:48:47 +0530 | [diff] [blame^] | 2491 | |
| 2492 | csr_update_adaptive_11r_scan_filter(mac_ctx, filter); |
| 2493 | |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2494 | if (!pFilter->BSSIDs.numOfBSSIDs) { |
Tushnim Bhattacharyya | 0c4ad2d | 2017-03-09 15:59:03 -0800 | [diff] [blame] | 2495 | if (policy_mgr_map_concurrency_mode( |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2496 | &pFilter->csrPersona, &new_mode)) { |
Tushnim Bhattacharyya | 0c4ad2d | 2017-03-09 15:59:03 -0800 | [diff] [blame] | 2497 | status = policy_mgr_get_pcl(mac_ctx->psoc, new_mode, |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2498 | filter->pcl_channel_list, &len, |
Abhishek Singh | b58164a | 2017-07-19 18:47:23 +0530 | [diff] [blame] | 2499 | filter->pcl_weight_list, QDF_MAX_NUM_CHAN); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2500 | filter->num_of_pcl_channels = (uint8_t)len; |
| 2501 | } |
| 2502 | } |
Abhishek Singh | b58164a | 2017-07-19 18:47:23 +0530 | [diff] [blame] | 2503 | qdf_mem_copy(filter->bssid_hint.bytes, |
| 2504 | pFilter->bssid_hint.bytes, |
| 2505 | QDF_MAC_ADDR_SIZE); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2506 | |
| 2507 | return QDF_STATUS_SUCCESS; |
| 2508 | } |
| 2509 | |
Sridhar Selvaraj | a44c19e | 2017-08-21 14:20:20 +0530 | [diff] [blame] | 2510 | #ifdef WLAN_FEATURE_FILS_SK |
| 2511 | /** |
| 2512 | * csr_update_bss_with_fils_data: Fill FILS params in bss desc from scan entry |
| 2513 | * @mac_ctx: mac context |
| 2514 | * @scan_entry: scan entry |
| 2515 | * @bss_descr: bss description |
| 2516 | */ |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 2517 | static void csr_update_bss_with_fils_data(struct mac_context *mac_ctx, |
Sridhar Selvaraj | a44c19e | 2017-08-21 14:20:20 +0530 | [diff] [blame] | 2518 | struct scan_cache_entry *scan_entry, |
| 2519 | tSirBssDescription *bss_descr) |
| 2520 | { |
Naveen Rawat | 72475db | 2017-12-13 18:07:35 -0800 | [diff] [blame] | 2521 | int ret; |
Krunal Soni | 35a9453 | 2018-01-09 10:54:31 -0800 | [diff] [blame] | 2522 | tDot11fIEfils_indication fils_indication = {0}; |
Sridhar Selvaraj | a44c19e | 2017-08-21 14:20:20 +0530 | [diff] [blame] | 2523 | struct sir_fils_indication fils_ind; |
| 2524 | |
| 2525 | if (!scan_entry->ie_list.fils_indication) |
| 2526 | return; |
| 2527 | |
Naveen Rawat | 72475db | 2017-12-13 18:07:35 -0800 | [diff] [blame] | 2528 | ret = dot11f_unpack_ie_fils_indication(mac_ctx, |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 2529 | scan_entry->ie_list.fils_indication + |
| 2530 | SIR_FILS_IND_ELEM_OFFSET, |
Sridhar Selvaraj | a44c19e | 2017-08-21 14:20:20 +0530 | [diff] [blame] | 2531 | *(scan_entry->ie_list.fils_indication + 1), |
| 2532 | &fils_indication, false); |
Srinivas Girigowda | eff16d9 | 2018-09-12 14:56:29 -0700 | [diff] [blame] | 2533 | if (DOT11F_FAILED(ret)) { |
Naveen Rawat | 72475db | 2017-12-13 18:07:35 -0800 | [diff] [blame] | 2534 | sme_err("unpack failed ret: 0x%x", ret); |
| 2535 | return; |
| 2536 | } |
Sridhar Selvaraj | a44c19e | 2017-08-21 14:20:20 +0530 | [diff] [blame] | 2537 | |
| 2538 | update_fils_data(&fils_ind, &fils_indication); |
| 2539 | if (fils_ind.realm_identifier.realm_cnt > SIR_MAX_REALM_COUNT) |
| 2540 | fils_ind.realm_identifier.realm_cnt = SIR_MAX_REALM_COUNT; |
| 2541 | |
| 2542 | bss_descr->fils_info_element.realm_cnt = |
| 2543 | fils_ind.realm_identifier.realm_cnt; |
| 2544 | qdf_mem_copy(bss_descr->fils_info_element.realm, |
| 2545 | fils_ind.realm_identifier.realm, |
| 2546 | bss_descr->fils_info_element.realm_cnt * SIR_REALM_LEN); |
| 2547 | if (fils_ind.cache_identifier.is_present) { |
| 2548 | bss_descr->fils_info_element.is_cache_id_present = true; |
| 2549 | qdf_mem_copy(bss_descr->fils_info_element.cache_id, |
| 2550 | fils_ind.cache_identifier.identifier, CACHE_ID_LEN); |
| 2551 | } |
| 2552 | if (fils_ind.is_fils_sk_auth_supported) |
| 2553 | bss_descr->fils_info_element.is_fils_sk_supported = true; |
| 2554 | } |
| 2555 | #else |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 2556 | static void csr_update_bss_with_fils_data(struct mac_context *mac_ctx, |
Sridhar Selvaraj | a44c19e | 2017-08-21 14:20:20 +0530 | [diff] [blame] | 2557 | struct scan_cache_entry *scan_entry, |
| 2558 | tSirBssDescription *bss_descr) |
| 2559 | { } |
| 2560 | #endif |
| 2561 | |
Yeshwanth Sriram Guntuka | a6c3d27 | 2019-04-13 12:25:53 +0530 | [diff] [blame] | 2562 | /** |
| 2563 | * csr_is_assoc_disallowed() - Find if assoc disallowed |
| 2564 | * bit is set in AP's beacon or probe response |
| 2565 | * @mac_ctx: mac context |
| 2566 | * @scan_entry: scan entry |
| 2567 | * |
| 2568 | * Return: True if assoc disallowed is set else false |
| 2569 | */ |
| 2570 | static bool csr_is_assoc_disallowed(struct mac_context *mac_ctx, |
| 2571 | struct scan_cache_entry *scan_entry) |
| 2572 | { |
| 2573 | int ret; |
| 2574 | tDot11fIEMBO_IE mbo_ie = {0}; |
| 2575 | uint8_t *mbo_oce; |
| 2576 | |
| 2577 | mbo_oce = util_scan_entry_mbo_oce(scan_entry); |
| 2578 | |
| 2579 | if (!mbo_oce) |
| 2580 | return false; |
| 2581 | |
| 2582 | ret = dot11f_unpack_ie_MBO_IE(mac_ctx, mbo_oce + SIR_MBO_ELEM_OFFSET, |
| 2583 | *(mbo_oce + 1) - SIR_MAC_MBO_OUI_SIZE, |
| 2584 | &mbo_ie, false); |
| 2585 | |
| 2586 | if (DOT11F_FAILED(ret)) { |
| 2587 | sme_err("unpack failed ret: 0x%x", ret); |
| 2588 | return false; |
| 2589 | } |
| 2590 | |
| 2591 | return mbo_ie.assoc_disallowed.present; |
| 2592 | } |
| 2593 | |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 2594 | static QDF_STATUS csr_fill_bss_from_scan_entry(struct mac_context *mac_ctx, |
Jeff Johnson | 8c3ecdd | 2018-12-05 08:48:54 -0800 | [diff] [blame] | 2595 | struct scan_cache_entry *scan_entry, |
| 2596 | struct tag_csrscan_result **p_result) |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2597 | { |
| 2598 | tDot11fBeaconIEs *bcn_ies; |
| 2599 | tSirBssDescription *bss_desc; |
| 2600 | tCsrScanResultInfo *result_info; |
| 2601 | tpSirMacMgmtHdr hdr; |
| 2602 | uint8_t *ie_ptr; |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 2603 | struct tag_csrscan_result *bss; |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2604 | uint32_t bss_len, alloc_len, ie_len; |
| 2605 | QDF_STATUS status; |
| 2606 | |
| 2607 | ie_len = util_scan_entry_ie_len(scan_entry); |
| 2608 | ie_ptr = util_scan_entry_ie_data(scan_entry); |
| 2609 | |
| 2610 | hdr = (tpSirMacMgmtHdr)scan_entry->raw_frame.ptr; |
| 2611 | |
| 2612 | bss_len = (uint16_t)(offsetof(tSirBssDescription, |
| 2613 | ieFields[0]) + ie_len); |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 2614 | alloc_len = sizeof(struct tag_csrscan_result) + bss_len; |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2615 | bss = qdf_mem_malloc(alloc_len); |
Arif Hussain | 0ef7708 | 2018-10-10 16:42:53 -0700 | [diff] [blame] | 2616 | if (!bss) |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2617 | return QDF_STATUS_E_NOMEM; |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2618 | |
| 2619 | bss->AgingCount = |
| 2620 | (int32_t) mac_ctx->roam.configParam.agingCount; |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2621 | bss->ucEncryptionType = |
| 2622 | csr_covert_enc_type_old(scan_entry->neg_sec_info.uc_enc); |
| 2623 | bss->mcEncryptionType = |
| 2624 | csr_covert_enc_type_old(scan_entry->neg_sec_info.mc_enc); |
| 2625 | bss->authType = |
| 2626 | csr_covert_auth_type_old(scan_entry->neg_sec_info.auth_type); |
Abhishek Singh | b58164a | 2017-07-19 18:47:23 +0530 | [diff] [blame] | 2627 | bss->bss_score = scan_entry->bss_score; |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2628 | |
| 2629 | result_info = &bss->Result; |
| 2630 | result_info->ssId.length = scan_entry->ssid.length; |
| 2631 | qdf_mem_copy(result_info->ssId.ssId, |
| 2632 | scan_entry->ssid.ssid, |
| 2633 | result_info->ssId.length); |
| 2634 | result_info->timer = scan_entry->hidden_ssid_timestamp; |
| 2635 | |
| 2636 | bss_desc = &result_info->BssDescriptor; |
| 2637 | |
| 2638 | bss_desc->length = (uint16_t) (offsetof(tSirBssDescription, |
| 2639 | ieFields[0]) - sizeof(bss_desc->length) + ie_len); |
| 2640 | |
| 2641 | qdf_mem_copy(bss_desc->bssId, |
| 2642 | scan_entry->bssid.bytes, |
| 2643 | QDF_MAC_ADDR_SIZE); |
Sandeep Puligilla | 1fcdb77 | 2017-02-22 21:14:59 -0800 | [diff] [blame] | 2644 | bss_desc->scansystimensec = scan_entry->scan_entry_time; |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2645 | qdf_mem_copy(bss_desc->timeStamp, |
| 2646 | scan_entry->tsf_info.data, 8); |
| 2647 | |
| 2648 | bss_desc->beaconInterval = scan_entry->bcn_int; |
| 2649 | bss_desc->capabilityInfo = scan_entry->cap_info.value; |
| 2650 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 2651 | if (WLAN_REG_IS_5GHZ_CH(scan_entry->channel.chan_idx)) |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2652 | bss_desc->nwType = eSIR_11A_NW_TYPE; |
| 2653 | else if (scan_entry->phy_mode == WLAN_PHYMODE_11B) |
| 2654 | bss_desc->nwType = eSIR_11B_NW_TYPE; |
| 2655 | else |
| 2656 | bss_desc->nwType = eSIR_11G_NW_TYPE; |
| 2657 | |
| 2658 | bss_desc->rssi = scan_entry->rssi_raw; |
| 2659 | bss_desc->rssi_raw = scan_entry->rssi_raw; |
| 2660 | |
| 2661 | /* channelId what peer sent in beacon/probersp. */ |
| 2662 | bss_desc->channelId = |
| 2663 | scan_entry->channel.chan_idx; |
| 2664 | /* channelId on which we are parked at. */ |
| 2665 | /* used only in scan case. */ |
| 2666 | bss_desc->channelIdSelf = |
| 2667 | scan_entry->channel.chan_idx; |
| 2668 | bss_desc->rx_channel = bss_desc->channelIdSelf; |
| 2669 | bss_desc->received_time = |
| 2670 | scan_entry->scan_entry_time; |
| 2671 | bss_desc->startTSF[0] = |
| 2672 | mac_ctx->rrm.rrmPEContext.startTSF[0]; |
| 2673 | bss_desc->startTSF[1] = |
| 2674 | mac_ctx->rrm.rrmPEContext.startTSF[1]; |
| 2675 | bss_desc->parentTSF = |
| 2676 | scan_entry->rrm_parent_tsf; |
| 2677 | bss_desc->fProbeRsp = (scan_entry->frm_subtype == |
Srinivas Girigowda | df90cea | 2019-03-07 16:03:25 -0800 | [diff] [blame] | 2678 | MGMT_SUBTYPE_PROBE_RESP); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2679 | bss_desc->seq_ctrl = hdr->seqControl; |
| 2680 | bss_desc->tsf_delta = scan_entry->tsf_delta; |
Yeshwanth Sriram Guntuka | a6c3d27 | 2019-04-13 12:25:53 +0530 | [diff] [blame] | 2681 | bss_desc->assoc_disallowed = csr_is_assoc_disallowed(mac_ctx, |
| 2682 | scan_entry); |
Pragaspathi Thilagaraj | 1f3f99f | 2019-04-24 23:48:47 +0530 | [diff] [blame^] | 2683 | bss_desc->adaptive_11r_ap = scan_entry->adaptive_11r_ap; |
Sandeep Puligilla | d8546bb | 2019-02-15 10:49:38 -0800 | [diff] [blame] | 2684 | qdf_mem_copy(&bss_desc->mbssid_info, &scan_entry->mbssid_info, |
| 2685 | sizeof(struct scan_mbssid_info)); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2686 | |
| 2687 | qdf_mem_copy((uint8_t *) &bss_desc->ieFields, |
| 2688 | ie_ptr, ie_len); |
| 2689 | |
| 2690 | status = csr_get_parsed_bss_description_ies(mac_ctx, |
| 2691 | bss_desc, &bcn_ies); |
| 2692 | if (QDF_IS_STATUS_ERROR(status)) { |
| 2693 | qdf_mem_free(bss); |
| 2694 | return status; |
| 2695 | } |
| 2696 | result_info->pvIes = bcn_ies; |
| 2697 | |
| 2698 | if (bcn_ies->MobilityDomain.present) { |
| 2699 | bss_desc->mdiePresent = true; |
| 2700 | qdf_mem_copy((uint8_t *)&(bss_desc->mdie[0]), |
| 2701 | (uint8_t *)&(bcn_ies->MobilityDomain.MDID), |
| 2702 | sizeof(uint16_t)); |
| 2703 | bss_desc->mdie[2] = |
| 2704 | ((bcn_ies->MobilityDomain.overDSCap << 0) | |
| 2705 | (bcn_ies->MobilityDomain.resourceReqCap << 1)); |
| 2706 | } |
| 2707 | #ifdef FEATURE_WLAN_ESE |
| 2708 | if (bcn_ies->QBSSLoad.present) { |
| 2709 | bss_desc->QBSSLoad_present = true; |
| 2710 | bss_desc->QBSSLoad_avail = |
| 2711 | bcn_ies->QBSSLoad.avail; |
| 2712 | } |
| 2713 | #endif |
Sridhar Selvaraj | a44c19e | 2017-08-21 14:20:20 +0530 | [diff] [blame] | 2714 | csr_update_bss_with_fils_data(mac_ctx, scan_entry, bss_desc); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2715 | if (scan_entry->alt_wcn_ie.ptr) { |
| 2716 | bss_desc->WscIeLen = scan_entry->alt_wcn_ie.len; |
| 2717 | qdf_mem_copy(bss_desc->WscIeProbeRsp, |
| 2718 | scan_entry->alt_wcn_ie.ptr, |
| 2719 | scan_entry->alt_wcn_ie.len); |
| 2720 | } |
| 2721 | |
| 2722 | *p_result = bss; |
| 2723 | return QDF_STATUS_SUCCESS; |
| 2724 | } |
| 2725 | |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 2726 | static QDF_STATUS csr_parse_scan_list(struct mac_context *mac_ctx, |
Jeff Johnson | 8c3ecdd | 2018-12-05 08:48:54 -0800 | [diff] [blame] | 2727 | struct scan_result_list *ret_list, |
| 2728 | qdf_list_t *scan_list) |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2729 | { |
| 2730 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 2731 | struct tag_csrscan_result *pResult = NULL; |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2732 | struct scan_cache_node *cur_node = NULL; |
| 2733 | struct scan_cache_node *next_node = NULL; |
| 2734 | |
| 2735 | status = |
| 2736 | qdf_list_peek_front(scan_list, |
| 2737 | (qdf_list_node_t **) &cur_node); |
| 2738 | |
| 2739 | while (cur_node) { |
| 2740 | qdf_list_peek_next( |
| 2741 | scan_list, |
| 2742 | (qdf_list_node_t *) cur_node, |
| 2743 | (qdf_list_node_t **) &next_node); |
| 2744 | status = csr_fill_bss_from_scan_entry(mac_ctx, |
| 2745 | cur_node->entry, &pResult); |
| 2746 | if (QDF_IS_STATUS_ERROR(status)) |
| 2747 | return status; |
| 2748 | if (pResult) |
| 2749 | csr_ll_insert_tail(&ret_list->List, &pResult->Link, |
| 2750 | LL_ACCESS_NOLOCK); |
| 2751 | cur_node = next_node; |
| 2752 | next_node = NULL; |
| 2753 | } |
| 2754 | |
| 2755 | return status; |
| 2756 | } |
Abhishek Singh | f3756fc | 2017-06-28 16:04:06 +0530 | [diff] [blame] | 2757 | |
| 2758 | /** |
| 2759 | * csr_remove_ap_due_to_rssi() - check if bss is present in |
| 2760 | * list of BSSID which rejected Assoc due to RSSI |
| 2761 | * @list: rssi based rejected BSS list |
| 2762 | * @bss_descr: pointer to bss description |
| 2763 | * |
| 2764 | * Check if the time interval indicated in last Assoc reject |
| 2765 | * has expired OR rssi has improved by margin indicated |
| 2766 | * in last Assoc reject. If any of the condition match remove |
| 2767 | * the AP from the avoid list, else do not try to conenct |
| 2768 | * to the AP |
| 2769 | * |
| 2770 | * Return: true if connection cannot be tried with AP else false |
| 2771 | */ |
| 2772 | static bool csr_remove_ap_due_to_rssi(qdf_list_t *list, |
Jeff Johnson | 8c3ecdd | 2018-12-05 08:48:54 -0800 | [diff] [blame] | 2773 | tSirBssDescription *bss_descr) |
Abhishek Singh | f3756fc | 2017-06-28 16:04:06 +0530 | [diff] [blame] | 2774 | { |
| 2775 | QDF_STATUS status; |
| 2776 | struct sir_rssi_disallow_lst *cur_node = NULL; |
| 2777 | qdf_list_node_t *cur_lst = NULL, *next_lst = NULL; |
| 2778 | qdf_time_t cur_time; |
| 2779 | uint32_t time_diff; |
| 2780 | |
| 2781 | if (!qdf_list_size(list)) |
| 2782 | return false; |
| 2783 | |
| 2784 | cur_time = qdf_do_div(qdf_get_monotonic_boottime(), |
| 2785 | QDF_MC_TIMER_TO_MS_UNIT); |
| 2786 | |
| 2787 | qdf_list_peek_front(list, &cur_lst); |
| 2788 | while (cur_lst) { |
| 2789 | cur_node = qdf_container_of(cur_lst, |
| 2790 | struct sir_rssi_disallow_lst, node); |
| 2791 | |
| 2792 | qdf_list_peek_next(list, cur_lst, &next_lst); |
| 2793 | |
| 2794 | time_diff = cur_time - cur_node->time_during_rejection; |
| 2795 | if ((time_diff > cur_node->retry_delay)) { |
| 2796 | sme_debug("Remove %pM as time diff %d is greater retry delay %d", |
| 2797 | cur_node->bssid.bytes, time_diff, |
| 2798 | cur_node->retry_delay); |
| 2799 | status = qdf_list_remove_node(list, cur_lst); |
| 2800 | if (QDF_IS_STATUS_SUCCESS(status)) |
| 2801 | qdf_mem_free(cur_node); |
| 2802 | cur_lst = next_lst; |
| 2803 | next_lst = NULL; |
| 2804 | cur_node = NULL; |
| 2805 | continue; |
| 2806 | } |
| 2807 | |
| 2808 | if (!qdf_mem_cmp(cur_node->bssid.bytes, |
| 2809 | bss_descr->bssId, QDF_MAC_ADDR_SIZE)) |
| 2810 | break; |
| 2811 | cur_lst = next_lst; |
| 2812 | next_lst = NULL; |
| 2813 | cur_node = NULL; |
| 2814 | } |
| 2815 | |
| 2816 | if (cur_node) { |
| 2817 | time_diff = cur_time - cur_node->time_during_rejection; |
| 2818 | if (!(time_diff > cur_node->retry_delay || |
| 2819 | bss_descr->rssi_raw >= cur_node->expected_rssi)) { |
| 2820 | sme_err("Don't Attempt to connect %pM (time diff %d retry delay %d rssi %d expected rssi %d)", |
| 2821 | cur_node->bssid.bytes, time_diff, |
| 2822 | cur_node->retry_delay, bss_descr->rssi_raw, |
| 2823 | cur_node->expected_rssi); |
| 2824 | return true; |
| 2825 | } |
| 2826 | sme_debug("Remove %pM as time diff %d is greater retry delay %d or RSSI %d is greater than expected %d", |
| 2827 | cur_node->bssid.bytes, time_diff, |
| 2828 | cur_node->retry_delay, |
| 2829 | bss_descr->rssi_raw, |
| 2830 | cur_node->expected_rssi); |
| 2831 | status = qdf_list_remove_node(list, cur_lst); |
| 2832 | if (QDF_IS_STATUS_SUCCESS(status)) |
| 2833 | qdf_mem_free(cur_node); |
| 2834 | } |
| 2835 | |
| 2836 | return false; |
| 2837 | } |
| 2838 | |
| 2839 | /** |
| 2840 | * csr_filter_ap_due_to_rssi_reject() - filter the AP who has sent |
| 2841 | * assoc reject due to RSSI if condition has not improved |
| 2842 | * @mac_ctx: mac context |
| 2843 | * @scan_list: candidate list for the connection |
| 2844 | * |
| 2845 | * Return: void |
| 2846 | */ |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 2847 | static void csr_filter_ap_due_to_rssi_reject(struct mac_context *mac_ctx, |
Jeff Johnson | 8c3ecdd | 2018-12-05 08:48:54 -0800 | [diff] [blame] | 2848 | struct scan_result_list *scan_list) |
Abhishek Singh | f3756fc | 2017-06-28 16:04:06 +0530 | [diff] [blame] | 2849 | { |
| 2850 | tListElem *cur_entry; |
| 2851 | tListElem *next_entry; |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 2852 | struct tag_csrscan_result *scan_res; |
Abhishek Singh | f3756fc | 2017-06-28 16:04:06 +0530 | [diff] [blame] | 2853 | bool remove; |
| 2854 | |
| 2855 | if (!scan_list || |
| 2856 | !qdf_list_size(&mac_ctx->roam.rssi_disallow_bssid)) |
| 2857 | return; |
| 2858 | |
Abhishek Singh | f3756fc | 2017-06-28 16:04:06 +0530 | [diff] [blame] | 2859 | cur_entry = csr_ll_peek_head(&scan_list->List, LL_ACCESS_NOLOCK); |
| 2860 | while (cur_entry) { |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 2861 | scan_res = GET_BASE_ADDR(cur_entry, struct tag_csrscan_result, |
Abhishek Singh | f3756fc | 2017-06-28 16:04:06 +0530 | [diff] [blame] | 2862 | Link); |
| 2863 | next_entry = csr_ll_next(&scan_list->List, |
| 2864 | cur_entry, LL_ACCESS_NOLOCK); |
Jingxiang Ge | f95dc4d | 2019-02-26 14:20:31 +0800 | [diff] [blame] | 2865 | |
| 2866 | qdf_mutex_acquire(&mac_ctx->roam.rssi_disallow_bssid_lock); |
Abhishek Singh | f3756fc | 2017-06-28 16:04:06 +0530 | [diff] [blame] | 2867 | remove = csr_remove_ap_due_to_rssi( |
| 2868 | &mac_ctx->roam.rssi_disallow_bssid, |
| 2869 | &scan_res->Result.BssDescriptor); |
Jingxiang Ge | f95dc4d | 2019-02-26 14:20:31 +0800 | [diff] [blame] | 2870 | qdf_mutex_release(&mac_ctx->roam.rssi_disallow_bssid_lock); |
| 2871 | |
Abhishek Singh | f3756fc | 2017-06-28 16:04:06 +0530 | [diff] [blame] | 2872 | if (remove) { |
| 2873 | csr_ll_remove_entry(&scan_list->List, |
| 2874 | cur_entry, LL_ACCESS_NOLOCK); |
| 2875 | csr_free_scan_result_entry(mac_ctx, scan_res); |
| 2876 | } |
| 2877 | cur_entry = next_entry; |
| 2878 | next_entry = NULL; |
| 2879 | } |
Abhishek Singh | f3756fc | 2017-06-28 16:04:06 +0530 | [diff] [blame] | 2880 | } |
| 2881 | |
Yeshwanth Sriram Guntuka | a6c3d27 | 2019-04-13 12:25:53 +0530 | [diff] [blame] | 2882 | /** |
| 2883 | * csr_remove_ap_with_assoc_disallowed() - Remove APs with assoc |
| 2884 | * disallowed bit set |
| 2885 | * @mac_ctx: mac context |
| 2886 | * @scan_list: candidate list for the connection |
| 2887 | * |
| 2888 | * Return: None |
| 2889 | */ |
| 2890 | static void csr_remove_ap_with_assoc_disallowed(struct mac_context *mac_ctx, |
| 2891 | struct scan_result_list *scan_list) |
| 2892 | { |
| 2893 | tListElem *cur_entry; |
| 2894 | tListElem *next_entry; |
| 2895 | struct tag_csrscan_result *scan_res; |
| 2896 | |
| 2897 | if (!scan_list) |
| 2898 | return; |
| 2899 | |
| 2900 | cur_entry = csr_ll_peek_head(&scan_list->List, LL_ACCESS_NOLOCK); |
| 2901 | while (cur_entry) { |
| 2902 | scan_res = GET_BASE_ADDR(cur_entry, struct tag_csrscan_result, |
| 2903 | Link); |
| 2904 | next_entry = csr_ll_next(&scan_list->List, cur_entry, |
| 2905 | LL_ACCESS_NOLOCK); |
| 2906 | |
| 2907 | if (!mac_ctx->ignore_assoc_disallowed && |
| 2908 | scan_res->Result.BssDescriptor.assoc_disallowed) { |
| 2909 | csr_ll_remove_entry(&scan_list->List, cur_entry, |
| 2910 | LL_ACCESS_NOLOCK); |
| 2911 | csr_free_scan_result_entry(mac_ctx, scan_res); |
| 2912 | } |
| 2913 | cur_entry = next_entry; |
| 2914 | next_entry = NULL; |
| 2915 | } |
| 2916 | } |
| 2917 | |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 2918 | QDF_STATUS csr_scan_get_result(struct mac_context *mac_ctx, |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2919 | tCsrScanResultFilter *pFilter, |
| 2920 | tScanResultHandle *results) |
| 2921 | { |
| 2922 | QDF_STATUS status; |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 2923 | struct scan_result_list *ret_list = NULL; |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2924 | qdf_list_t *list = NULL; |
Sandeep Puligilla | 8345f3d | 2018-10-22 15:43:48 -0700 | [diff] [blame] | 2925 | struct scan_filter *filter = NULL; |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2926 | struct wlan_objmgr_pdev *pdev = NULL; |
Yeshwanth Sriram Guntuka | a6c3d27 | 2019-04-13 12:25:53 +0530 | [diff] [blame] | 2927 | uint32_t num_bss; |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2928 | |
| 2929 | if (results) |
| 2930 | *results = CSR_INVALID_SCANRESULT_HANDLE; |
| 2931 | |
| 2932 | pdev = wlan_objmgr_get_pdev_by_id(mac_ctx->psoc, |
| 2933 | 0, WLAN_LEGACY_MAC_ID); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2934 | if (!pdev) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 2935 | sme_err("pdev is NULL"); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2936 | return QDF_STATUS_E_INVAL; |
| 2937 | } |
| 2938 | |
| 2939 | if (pFilter) { |
Sandeep Puligilla | 8345f3d | 2018-10-22 15:43:48 -0700 | [diff] [blame] | 2940 | filter = qdf_mem_malloc(sizeof(*filter)); |
| 2941 | if (!filter) { |
| 2942 | status = QDF_STATUS_E_NOMEM; |
| 2943 | goto error; |
| 2944 | } |
| 2945 | |
| 2946 | status = csr_prepare_scan_filter(mac_ctx, pFilter, filter); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2947 | if (QDF_IS_STATUS_ERROR(status)) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 2948 | sme_err("Prepare filter failed"); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2949 | goto error; |
| 2950 | } |
| 2951 | } |
| 2952 | |
| 2953 | list = ucfg_scan_get_result(pdev, |
Sandeep Puligilla | 8345f3d | 2018-10-22 15:43:48 -0700 | [diff] [blame] | 2954 | pFilter ? filter : NULL); |
Krunal Soni | 35a9453 | 2018-01-09 10:54:31 -0800 | [diff] [blame] | 2955 | if (list) |
| 2956 | sme_debug("num_entries %d", qdf_list_size(list)); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2957 | |
Krunal Soni | 35a9453 | 2018-01-09 10:54:31 -0800 | [diff] [blame] | 2958 | if (!list || (list && !qdf_list_size(list))) { |
Jianmin Zhu | cc6b3d0 | 2019-03-07 14:19:34 +0800 | [diff] [blame] | 2959 | sme_debug("get scan result failed"); |
Abhishek Singh | d1d10b4 | 2017-06-07 16:12:01 +0530 | [diff] [blame] | 2960 | status = QDF_STATUS_E_NULL_VALUE; |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2961 | goto error; |
| 2962 | } |
| 2963 | |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 2964 | ret_list = qdf_mem_malloc(sizeof(struct scan_result_list)); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2965 | if (!ret_list) { |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2966 | status = QDF_STATUS_E_NOMEM; |
| 2967 | goto error; |
| 2968 | } |
| 2969 | |
Jeff Johnson | 616417f | 2018-06-27 10:20:53 -0700 | [diff] [blame] | 2970 | csr_ll_open(&ret_list->List); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2971 | ret_list->pCurEntry = NULL; |
| 2972 | status = csr_parse_scan_list(mac_ctx, |
| 2973 | ret_list, list); |
Yeshwanth Sriram Guntuka | a6c3d27 | 2019-04-13 12:25:53 +0530 | [diff] [blame] | 2974 | num_bss = csr_ll_count(&ret_list->List); |
Vignesh Viswanathan | 9dd88d3 | 2017-11-22 14:22:03 +0530 | [diff] [blame] | 2975 | sme_debug("status: %d No of BSS: %d", |
Yeshwanth Sriram Guntuka | a6c3d27 | 2019-04-13 12:25:53 +0530 | [diff] [blame] | 2976 | status, num_bss); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2977 | if (QDF_IS_STATUS_ERROR(status) || !results) |
| 2978 | /* Fail or No one wants the result. */ |
| 2979 | csr_scan_result_purge(mac_ctx, (tScanResultHandle) ret_list); |
| 2980 | else { |
Yeshwanth Sriram Guntuka | a6c3d27 | 2019-04-13 12:25:53 +0530 | [diff] [blame] | 2981 | if (pFilter) { |
Abhishek Singh | f3756fc | 2017-06-28 16:04:06 +0530 | [diff] [blame] | 2982 | csr_filter_ap_due_to_rssi_reject(mac_ctx, ret_list); |
Yeshwanth Sriram Guntuka | a6c3d27 | 2019-04-13 12:25:53 +0530 | [diff] [blame] | 2983 | csr_remove_ap_with_assoc_disallowed(mac_ctx, ret_list); |
| 2984 | } |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2985 | if (!csr_ll_count(&ret_list->List)) { |
| 2986 | /* This mean that there is no match */ |
| 2987 | csr_ll_close(&ret_list->List); |
| 2988 | qdf_mem_free(ret_list); |
Yeshwanth Sriram Guntuka | a6c3d27 | 2019-04-13 12:25:53 +0530 | [diff] [blame] | 2989 | /* |
| 2990 | * Do not trigger scan for ssid if the scan entries |
| 2991 | * are removed either due to rssi reject or assoc |
| 2992 | * disallowed. |
| 2993 | */ |
| 2994 | if (num_bss) |
| 2995 | status = QDF_STATUS_E_EXISTS; |
| 2996 | else |
| 2997 | status = QDF_STATUS_E_NULL_VALUE; |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 2998 | } else if (results) { |
| 2999 | *results = ret_list; |
| 3000 | } |
| 3001 | } |
| 3002 | |
| 3003 | error: |
Sandeep Puligilla | 8345f3d | 2018-10-22 15:43:48 -0700 | [diff] [blame] | 3004 | if (filter) |
| 3005 | qdf_mem_free(filter); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 3006 | if (list) |
| 3007 | ucfg_scan_purge_results(list); |
| 3008 | if (pdev) |
| 3009 | wlan_objmgr_pdev_release_ref(pdev, WLAN_LEGACY_MAC_ID); |
| 3010 | |
| 3011 | return status; |
| 3012 | } |
| 3013 | |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 3014 | QDF_STATUS csr_scan_get_result_for_bssid(struct mac_context *mac_ctx, |
Jeff Johnson | 8c3ecdd | 2018-12-05 08:48:54 -0800 | [diff] [blame] | 3015 | struct qdf_mac_addr *bssid, |
| 3016 | tCsrScanResultInfo *res) |
Vignesh Viswanathan | 9dd88d3 | 2017-11-22 14:22:03 +0530 | [diff] [blame] | 3017 | { |
| 3018 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
| 3019 | tCsrScanResultFilter *scan_filter = NULL; |
| 3020 | tScanResultHandle filtered_scan_result = NULL; |
| 3021 | tCsrScanResultInfo *scan_result; |
| 3022 | |
| 3023 | if (!mac_ctx) { |
| 3024 | QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, |
| 3025 | FL("mac_ctx is NULL")); |
| 3026 | return QDF_STATUS_E_FAILURE; |
| 3027 | } |
| 3028 | |
| 3029 | scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter)); |
Arif Hussain | 0ef7708 | 2018-10-10 16:42:53 -0700 | [diff] [blame] | 3030 | if (!scan_filter) |
Vignesh Viswanathan | 9dd88d3 | 2017-11-22 14:22:03 +0530 | [diff] [blame] | 3031 | return QDF_STATUS_E_NOMEM; |
Vignesh Viswanathan | 9dd88d3 | 2017-11-22 14:22:03 +0530 | [diff] [blame] | 3032 | |
Krunal Soni | 3fa80e2 | 2018-01-09 14:16:02 -0800 | [diff] [blame] | 3033 | scan_filter->BSSIDs.bssid = qdf_mem_malloc(sizeof(*bssid)); |
Vignesh Viswanathan | 9dd88d3 | 2017-11-22 14:22:03 +0530 | [diff] [blame] | 3034 | if (!scan_filter->BSSIDs.bssid) { |
Vignesh Viswanathan | 9dd88d3 | 2017-11-22 14:22:03 +0530 | [diff] [blame] | 3035 | status = QDF_STATUS_E_FAILURE; |
| 3036 | goto free_filter; |
| 3037 | } |
| 3038 | |
| 3039 | scan_filter->BSSIDs.numOfBSSIDs = 1; |
Krunal Soni | 3fa80e2 | 2018-01-09 14:16:02 -0800 | [diff] [blame] | 3040 | qdf_mem_copy(scan_filter->BSSIDs.bssid, bssid, sizeof(*bssid)); |
Vignesh Viswanathan | 9dd88d3 | 2017-11-22 14:22:03 +0530 | [diff] [blame] | 3041 | |
| 3042 | status = csr_scan_get_result(mac_ctx, scan_filter, |
| 3043 | &filtered_scan_result); |
| 3044 | |
| 3045 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 3046 | sme_err("Failed to get scan result"); |
| 3047 | goto free_filter; |
| 3048 | } |
| 3049 | |
| 3050 | scan_result = csr_scan_result_get_first(mac_ctx, filtered_scan_result); |
| 3051 | |
| 3052 | if (scan_result) { |
| 3053 | res->pvIes = NULL; |
| 3054 | res->ssId.length = scan_result->ssId.length; |
| 3055 | qdf_mem_copy(&res->ssId.ssId, &scan_result->ssId.ssId, |
| 3056 | res->ssId.length); |
| 3057 | res->timer = scan_result->timer; |
| 3058 | qdf_mem_copy(&res->BssDescriptor, &scan_result->BssDescriptor, |
| 3059 | sizeof(tSirBssDescription)); |
| 3060 | status = QDF_STATUS_SUCCESS; |
| 3061 | } else { |
| 3062 | status = QDF_STATUS_E_FAILURE; |
| 3063 | } |
| 3064 | |
| 3065 | csr_scan_result_purge(mac_ctx, filtered_scan_result); |
| 3066 | |
| 3067 | free_filter: |
| 3068 | csr_free_scan_filter(mac_ctx, scan_filter); |
| 3069 | if (scan_filter) |
| 3070 | qdf_mem_free(scan_filter); |
| 3071 | |
| 3072 | return status; |
| 3073 | } |
| 3074 | |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 3075 | static inline QDF_STATUS |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 3076 | csr_flush_scan_results(struct mac_context *mac_ctx, |
Jeff Johnson | 8c3ecdd | 2018-12-05 08:48:54 -0800 | [diff] [blame] | 3077 | struct scan_filter *filter) |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 3078 | { |
| 3079 | struct wlan_objmgr_pdev *pdev = NULL; |
| 3080 | QDF_STATUS status; |
| 3081 | |
| 3082 | pdev = wlan_objmgr_get_pdev_by_id(mac_ctx->psoc, |
| 3083 | 0, WLAN_LEGACY_MAC_ID); |
| 3084 | if (!pdev) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 3085 | sme_err("pdev is NULL"); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 3086 | return QDF_STATUS_E_INVAL; |
| 3087 | } |
| 3088 | status = ucfg_scan_flush_results(pdev, filter); |
| 3089 | |
| 3090 | wlan_objmgr_pdev_release_ref(pdev, WLAN_LEGACY_MAC_ID); |
| 3091 | return status; |
| 3092 | } |
| 3093 | |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 3094 | QDF_STATUS csr_scan_flush_result(struct mac_context *mac_ctx) |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 3095 | { |
| 3096 | |
| 3097 | if (csr_scan_flush_denied(mac_ctx)) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 3098 | sme_err("scan flush denied in roam state"); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 3099 | return QDF_STATUS_E_FAILURE; |
| 3100 | } |
| 3101 | |
| 3102 | return csr_flush_scan_results(mac_ctx, NULL); |
| 3103 | } |
| 3104 | |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 3105 | static inline void csr_flush_bssid(struct mac_context *mac_ctx, |
Jeff Johnson | 8c3ecdd | 2018-12-05 08:48:54 -0800 | [diff] [blame] | 3106 | uint8_t *bssid) |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 3107 | { |
Sandeep Puligilla | 8345f3d | 2018-10-22 15:43:48 -0700 | [diff] [blame] | 3108 | struct scan_filter *filter; |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 3109 | |
Sandeep Puligilla | 8345f3d | 2018-10-22 15:43:48 -0700 | [diff] [blame] | 3110 | filter = qdf_mem_malloc(sizeof(*filter)); |
| 3111 | if (!filter) |
| 3112 | return; |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 3113 | |
Sandeep Puligilla | 8345f3d | 2018-10-22 15:43:48 -0700 | [diff] [blame] | 3114 | filter->num_of_bssid = 1; |
| 3115 | qdf_mem_copy(filter->bssid_list[0].bytes, |
| 3116 | bssid, QDF_MAC_ADDR_SIZE); |
| 3117 | |
| 3118 | csr_flush_scan_results(mac_ctx, filter); |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 3119 | sme_debug("Removed BSS entry:%pM", bssid); |
Sandeep Puligilla | 8345f3d | 2018-10-22 15:43:48 -0700 | [diff] [blame] | 3120 | if (filter) |
| 3121 | qdf_mem_free(filter); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 3122 | } |
| 3123 | |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 3124 | void csr_remove_bssid_from_scan_list(struct mac_context *mac_ctx, |
Jeff Johnson | 8c3ecdd | 2018-12-05 08:48:54 -0800 | [diff] [blame] | 3125 | tSirMacAddr bssid) |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 3126 | { |
| 3127 | csr_flush_bssid(mac_ctx, bssid); |
| 3128 | } |
| 3129 | |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 3130 | void csr_init_occupied_channels_list(struct mac_context *mac_ctx, |
Jeff Johnson | 8c3ecdd | 2018-12-05 08:48:54 -0800 | [diff] [blame] | 3131 | uint8_t sessionId) |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 3132 | { |
Jianmin Zhu | 5b8c5ca | 2019-04-15 20:02:01 +0800 | [diff] [blame] | 3133 | qdf_list_t *list = NULL; |
| 3134 | struct wlan_objmgr_pdev *pdev = NULL; |
| 3135 | qdf_list_node_t *cur_lst = NULL; |
| 3136 | qdf_list_node_t *next_lst = NULL; |
| 3137 | struct scan_cache_node *cur_node = NULL; |
| 3138 | struct scan_filter *filter; |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 3139 | tpCsrNeighborRoamControlInfo neighbor_roam_info = |
| 3140 | &mac_ctx->roam.neighborRoamInfo[sessionId]; |
Jianmin Zhu | 5b8c5ca | 2019-04-15 20:02:01 +0800 | [diff] [blame] | 3141 | tCsrRoamConnectedProfile *profile = NULL; |
Jianmin Zhu | 8d7afc2 | 2019-04-17 13:10:22 +0800 | [diff] [blame] | 3142 | uint8_t ch; |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 3143 | |
Jianmin Zhu | 5b8c5ca | 2019-04-15 20:02:01 +0800 | [diff] [blame] | 3144 | if (!(mac_ctx && mac_ctx->roam.roamSession && |
| 3145 | CSR_IS_SESSION_VALID(mac_ctx, sessionId))) { |
| 3146 | sme_debug("Invalid session"); |
| 3147 | return; |
| 3148 | } |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 3149 | if (neighbor_roam_info->cfgParams.channelInfo.numOfChannels) { |
| 3150 | /* |
| 3151 | * Ini file contains neighbor scan channel list, hence NO need |
| 3152 | * to build occupied channel list" |
| 3153 | */ |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 3154 | sme_debug("Ini contains neighbor scan ch list"); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 3155 | return; |
| 3156 | } |
| 3157 | |
| 3158 | if (!csr_neighbor_roam_is_new_connected_profile(mac_ctx, sessionId)) { |
| 3159 | /* |
| 3160 | * Do not flush occupied list since current roam profile matches |
| 3161 | * previous |
| 3162 | */ |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 3163 | sme_debug("Current roam profile matches prev"); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 3164 | return; |
| 3165 | } |
| 3166 | |
Jianmin Zhu | 5b8c5ca | 2019-04-15 20:02:01 +0800 | [diff] [blame] | 3167 | profile = &mac_ctx->roam.roamSession[sessionId].connectedProfile; |
| 3168 | if (!profile) |
| 3169 | return; |
| 3170 | |
| 3171 | filter = qdf_mem_malloc(sizeof(*filter)); |
| 3172 | if (!filter) { |
| 3173 | sme_err("filter is NULL"); |
| 3174 | return; |
| 3175 | } |
| 3176 | |
| 3177 | filter->num_of_auth = 1; |
| 3178 | filter->auth_type[0] = csr_covert_auth_type_new(profile->AuthType); |
| 3179 | filter->num_of_enc_type = 1; |
| 3180 | filter->enc_type[0] = csr_covert_enc_type_new(profile->EncryptionType); |
| 3181 | filter->num_of_mc_enc_type = 1; |
| 3182 | filter->mc_enc_type[0] = |
| 3183 | csr_covert_enc_type_new(profile->mcEncryptionType); |
| 3184 | filter->num_of_ssid = 1; |
| 3185 | filter->ssid_list[0].length = profile->SSID.length; |
| 3186 | qdf_mem_copy(filter->ssid_list[0].ssid, profile->SSID.ssId, |
| 3187 | profile->SSID.length); |
| 3188 | |
| 3189 | pdev = wlan_objmgr_get_pdev_by_id(mac_ctx->psoc, 0, WLAN_LEGACY_MAC_ID); |
| 3190 | |
| 3191 | if (!pdev) { |
| 3192 | sme_err("pdev is NULL"); |
| 3193 | qdf_mem_free(filter); |
| 3194 | return; |
| 3195 | } |
| 3196 | |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 3197 | /* Empty occupied channels here */ |
| 3198 | mac_ctx->scan.occupiedChannels[sessionId].numChannels = 0; |
| 3199 | mac_ctx->scan.roam_candidate_count[sessionId] = 0; |
Jianmin Zhu | 8d7afc2 | 2019-04-17 13:10:22 +0800 | [diff] [blame] | 3200 | |
| 3201 | csr_add_to_occupied_channels( |
| 3202 | mac_ctx, profile->operationChannel, |
| 3203 | sessionId, |
| 3204 | &mac_ctx->scan.occupiedChannels[sessionId], |
| 3205 | true); |
Jianmin Zhu | 5b8c5ca | 2019-04-15 20:02:01 +0800 | [diff] [blame] | 3206 | list = ucfg_scan_get_result(pdev, filter); |
| 3207 | if (list) |
| 3208 | sme_debug("num_entries %d", qdf_list_size(list)); |
| 3209 | if (!list || (list && !qdf_list_size(list))) { |
| 3210 | sme_err("get scan result failed"); |
| 3211 | wlan_objmgr_pdev_release_ref(pdev, WLAN_LEGACY_MAC_ID); |
| 3212 | qdf_mem_free(filter); |
| 3213 | if (list) |
| 3214 | ucfg_scan_purge_results(list); |
| 3215 | return; |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 3216 | } |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 3217 | |
Jianmin Zhu | 5b8c5ca | 2019-04-15 20:02:01 +0800 | [diff] [blame] | 3218 | qdf_list_peek_front(list, &cur_lst); |
| 3219 | while (cur_lst) { |
| 3220 | cur_node = qdf_container_of(cur_lst, struct scan_cache_node, |
| 3221 | node); |
Jianmin Zhu | 8d7afc2 | 2019-04-17 13:10:22 +0800 | [diff] [blame] | 3222 | ch = cur_node->entry->channel.chan_idx; |
| 3223 | csr_add_to_occupied_channels( |
| 3224 | mac_ctx, ch, |
Jianmin Zhu | 5b8c5ca | 2019-04-15 20:02:01 +0800 | [diff] [blame] | 3225 | sessionId, |
| 3226 | &mac_ctx->scan.occupiedChannels[sessionId], |
| 3227 | true); |
| 3228 | qdf_list_peek_next(list, cur_lst, &next_lst); |
| 3229 | cur_lst = next_lst; |
| 3230 | next_lst = NULL; |
| 3231 | } |
| 3232 | |
| 3233 | qdf_mem_free(filter); |
| 3234 | ucfg_scan_purge_results(list); |
| 3235 | wlan_objmgr_pdev_release_ref(pdev, WLAN_LEGACY_MAC_ID); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 3236 | } |
| 3237 | |
| 3238 | /** |
| 3239 | * csr_scan_filter_results: filter scan result based |
| 3240 | * on valid channel list number. |
| 3241 | * @mac_ctx: mac context |
| 3242 | * |
| 3243 | * Get scan result from scan list and Check Scan result channel number |
| 3244 | * with 11d channel list if channel number is found in 11d channel list |
| 3245 | * then do not remove scan result entry from scan list |
| 3246 | * |
| 3247 | * return: QDF Status |
| 3248 | */ |
Jeff Johnson | edece84 | 2018-12-02 11:13:52 -0800 | [diff] [blame] | 3249 | QDF_STATUS csr_scan_filter_results(struct mac_context *mac_ctx) |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 3250 | { |
| 3251 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
| 3252 | uint32_t len = sizeof(mac_ctx->roam.validChannelList); |
| 3253 | struct wlan_objmgr_pdev *pdev = NULL; |
| 3254 | |
| 3255 | pdev = wlan_objmgr_get_pdev_by_id(mac_ctx->psoc, |
| 3256 | 0, WLAN_LEGACY_MAC_ID); |
| 3257 | if (!pdev) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 3258 | sme_err("pdev is NULL"); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 3259 | return QDF_STATUS_E_INVAL; |
| 3260 | } |
| 3261 | status = csr_get_cfg_valid_channels(mac_ctx, |
| 3262 | mac_ctx->roam.validChannelList, |
| 3263 | &len); |
| 3264 | |
| 3265 | /* Get valid channels list from CFG */ |
| 3266 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3267 | wlan_objmgr_pdev_release_ref(pdev, WLAN_LEGACY_MAC_ID); |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 3268 | sme_err("Failed to get Channel list from CFG"); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 3269 | return status; |
| 3270 | } |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 3271 | sme_debug("No of valid channel %d", len); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 3272 | |
| 3273 | ucfg_scan_filter_valid_channel(pdev, |
| 3274 | mac_ctx->roam.validChannelList, len); |
| 3275 | wlan_objmgr_pdev_release_ref(pdev, WLAN_LEGACY_MAC_ID); |
| 3276 | return QDF_STATUS_SUCCESS; |
| 3277 | } |