Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
gaurank kathpalia | 5efa73b | 2017-12-29 10:55:16 +0530 | [diff] [blame] | 2 | * Copyright (c) 2011-2018 The Linux Foundation. All rights reserved. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | |
| 22 | /* |
| 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
| 26 | */ |
| 27 | |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 28 | /* |
| 29 | * DOC: csr_api_scan.c |
| 30 | * |
| 31 | * Implementation for the Common Scan interfaces. |
| 32 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 33 | |
| 34 | #include "ani_global.h" |
| 35 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 36 | #include "csr_inside_api.h" |
| 37 | #include "sme_inside.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 38 | |
| 39 | #include "csr_support.h" |
| 40 | |
| 41 | #include "host_diag_core_log.h" |
| 42 | #include "host_diag_core_event.h" |
| 43 | |
| 44 | #include "cds_reg_service.h" |
| 45 | #include "wma_types.h" |
| 46 | #include "cds_utils.h" |
| 47 | #include "cfg_api.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 48 | #include "wma.h" |
| 49 | |
Tushnim Bhattacharyya | 0c4ad2d | 2017-03-09 15:59:03 -0800 | [diff] [blame] | 50 | #include "wlan_policy_mgr_api.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 51 | #include "wlan_hdd_main.h" |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 52 | #include "pld_common.h" |
yeshwanth sriram guntuka | db50122 | 2017-01-24 15:21:31 +0530 | [diff] [blame] | 53 | #include "csr_internal.h" |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 54 | #include <wlan_scan_ucfg_api.h> |
Abhishek Singh | 6f56d21 | 2017-04-12 14:31:57 +0530 | [diff] [blame] | 55 | #include <wlan_scan_tgt_api.h> |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 56 | #include <wlan_scan_utils_api.h> |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 57 | #include <wlan_objmgr_vdev_obj.h> |
| 58 | #include <wlan_objmgr_pdev_obj.h> |
| 59 | #include <wlan_utility.h> |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 60 | #include "wlan_reg_services_api.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 61 | |
| 62 | #define MIN_CHN_TIME_TO_FIND_GO 100 |
| 63 | #define MAX_CHN_TIME_TO_FIND_GO 100 |
| 64 | #define DIRECT_SSID_LEN 7 |
| 65 | |
| 66 | /* Purpose of HIDDEN_TIMER |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 67 | * When we remove hidden ssid from the profile i.e., forget the SSID via GUI |
| 68 | * that SSID shouldn't see in the profile For above requirement we used timer |
| 69 | * limit, logic is explained below Timer value is initialsed to current time |
| 70 | * when it receives corresponding probe response of hidden SSID (The probe |
| 71 | * request is received regularly till SSID in the profile. Once it is removed |
| 72 | * from profile probe request is not sent.) when we receive probe response for |
| 73 | * broadcast probe request, during update SSID with saved SSID we will diff |
| 74 | * current time with saved SSID time if it is greater than 1 min then we are |
| 75 | * not updating with old one |
| 76 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 77 | |
| 78 | #define HIDDEN_TIMER (1*60*1000) |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 79 | /* must be less than 100, represent the persentage of new RSSI */ |
| 80 | #define CSR_SCAN_RESULT_RSSI_WEIGHT 80 |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 81 | #define MAX_ACTIVE_SCAN_FOR_ONE_CHANNEL 140 |
| 82 | #define MIN_ACTIVE_SCAN_FOR_ONE_CHANNEL 120 |
| 83 | |
| 84 | #define MAX_ACTIVE_SCAN_FOR_ONE_CHANNEL_FASTREASSOC 30 |
| 85 | #define MIN_ACTIVE_SCAN_FOR_ONE_CHANNEL_FASTREASSOC 20 |
| 86 | |
| 87 | #define PCL_ADVANTAGE 30 |
| 88 | #define PCL_RSSI_THRESHOLD -75 |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 89 | #define CSR_SCAN_IS_OVER_BSS_LIMIT(pMac) \ |
| 90 | ((pMac)->scan.nBssLimit <= (csr_ll_count(&(pMac)->scan.scanResultList))) |
| 91 | |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 92 | static void csr_set_default_scan_timing(tpAniSirGlobal pMac, |
| 93 | tSirScanType scanType, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 94 | tCsrScanRequest *pScanRequest); |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 95 | static QDF_STATUS csr_scan_channels(tpAniSirGlobal pMac, tSmeCmd *pCommand); |
| 96 | static void csr_set_cfg_valid_channel_list(tpAniSirGlobal pMac, uint8_t |
| 97 | *pChannelList, uint8_t NumChannels); |
| 98 | static void csr_save_tx_power_to_cfg(tpAniSirGlobal pMac, tDblLinkList *pList, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 99 | uint32_t cfgId); |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 100 | static void csr_set_cfg_country_code(tpAniSirGlobal pMac, uint8_t *countryCode); |
| 101 | static void csr_purge_channel_power(tpAniSirGlobal pMac, tDblLinkList |
| 102 | *pChannelList); |
| 103 | static bool csr_roam_is_valid_channel(tpAniSirGlobal pMac, uint8_t channel); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 104 | |
| 105 | #define CSR_IS_SOCIAL_CHANNEL(channel) \ |
| 106 | (((channel) == 1) || ((channel) == 6) || ((channel) == 11)) |
| 107 | |
| 108 | static void csr_release_scan_cmd_pending_list(tpAniSirGlobal pMac) |
| 109 | { |
| 110 | tListElem *pEntry; |
| 111 | tSmeCmd *pCommand; |
| 112 | |
| 113 | while ((pEntry = |
| 114 | csr_ll_remove_head(&pMac->scan.scanCmdPendingList, |
| 115 | LL_ACCESS_LOCK)) != NULL) { |
| 116 | pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link); |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 117 | if (eSmeCsrCommandMask & pCommand->command) |
Krunal Soni | 81f068c | 2017-02-23 19:51:55 -0800 | [diff] [blame] | 118 | csr_release_command(pMac, pCommand); |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 119 | else |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 120 | sme_err("Received command: %d", pCommand->command); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 121 | } |
| 122 | } |
| 123 | |
| 124 | /* pResult is invalid calling this function. */ |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 125 | void csr_free_scan_result_entry(tpAniSirGlobal pMac, struct tag_csrscan_result |
| 126 | *pResult) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 127 | { |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 128 | if (NULL != pResult->Result.pvIes) |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 129 | qdf_mem_free(pResult->Result.pvIes); |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 130 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 131 | qdf_mem_free(pResult); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 132 | } |
| 133 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 134 | static QDF_STATUS csr_ll_scan_purge_result(tpAniSirGlobal pMac, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 135 | tDblLinkList *pList) |
| 136 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 137 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 138 | tListElem *pEntry; |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 139 | struct tag_csrscan_result *pBssDesc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 140 | |
| 141 | csr_ll_lock(pList); |
| 142 | |
| 143 | while ((pEntry = csr_ll_remove_head(pList, LL_ACCESS_NOLOCK)) != NULL) { |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 144 | pBssDesc = GET_BASE_ADDR(pEntry, struct tag_csrscan_result, |
| 145 | Link); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 146 | csr_free_scan_result_entry(pMac, pBssDesc); |
| 147 | } |
| 148 | |
| 149 | csr_ll_unlock(pList); |
| 150 | |
| 151 | return status; |
| 152 | } |
| 153 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 154 | QDF_STATUS csr_scan_open(tpAniSirGlobal mac_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 155 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 156 | csr_ll_open(mac_ctx->hHdd, &mac_ctx->scan.channelPowerInfoList24); |
| 157 | csr_ll_open(mac_ctx->hHdd, &mac_ctx->scan.channelPowerInfoList5G); |
| 158 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 159 | csr_ll_open(mac_ctx->hHdd, &mac_ctx->scan.scanCmdPendingList); |
| 160 | #endif |
| 161 | mac_ctx->scan.fFullScanIssued = false; |
| 162 | mac_ctx->scan.nBssLimit = CSR_MAX_BSS_SUPPORT; |
yeshwanth sriram guntuka | 4c9a669 | 2017-03-13 12:44:59 +0530 | [diff] [blame] | 163 | |
| 164 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 165 | } |
| 166 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 167 | QDF_STATUS csr_scan_close(tpAniSirGlobal pMac) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 168 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 169 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 170 | csr_release_scan_cmd_pending_list(pMac); |
| 171 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 172 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 173 | csr_ll_close(&pMac->scan.scanCmdPendingList); |
| 174 | #endif |
| 175 | csr_purge_channel_power(pMac, &pMac->scan.channelPowerInfoList24); |
| 176 | csr_purge_channel_power(pMac, &pMac->scan.channelPowerInfoList5G); |
| 177 | csr_ll_close(&pMac->scan.channelPowerInfoList24); |
| 178 | csr_ll_close(&pMac->scan.channelPowerInfoList5G); |
| 179 | csr_scan_disable(pMac); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 180 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 181 | } |
| 182 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 183 | QDF_STATUS csr_scan_enable(tpAniSirGlobal pMac) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 184 | { |
| 185 | |
| 186 | pMac->scan.fScanEnable = true; |
| 187 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 188 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 189 | } |
| 190 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 191 | QDF_STATUS csr_scan_disable(tpAniSirGlobal pMac) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 192 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 193 | pMac->scan.fScanEnable = false; |
| 194 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 195 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 196 | } |
| 197 | |
| 198 | /* Set scan timing parameters according to state of other driver sessions */ |
| 199 | /* No validation of the parameters is performed. */ |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 200 | static void csr_set_default_scan_timing(tpAniSirGlobal pMac, |
| 201 | tSirScanType scanType, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 202 | tCsrScanRequest *pScanRequest) |
| 203 | { |
| 204 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 205 | if (csr_is_any_session_connected(pMac)) { |
| 206 | /* Reset passive scan time as per ini parameter. */ |
| 207 | cfg_set_int(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, |
| 208 | pMac->roam.configParam.nPassiveMaxChnTimeConc); |
| 209 | /* If multi-session, use the appropriate default scan times */ |
| 210 | if (scanType == eSIR_ACTIVE_SCAN) { |
| 211 | pScanRequest->maxChnTime = |
| 212 | pMac->roam.configParam.nActiveMaxChnTimeConc; |
| 213 | pScanRequest->minChnTime = |
| 214 | pMac->roam.configParam.nActiveMinChnTimeConc; |
| 215 | } else { |
| 216 | pScanRequest->maxChnTime = |
| 217 | pMac->roam.configParam.nPassiveMaxChnTimeConc; |
| 218 | pScanRequest->minChnTime = |
| 219 | pMac->roam.configParam.nPassiveMinChnTimeConc; |
| 220 | } |
| 221 | pScanRequest->restTime = pMac->roam.configParam.nRestTimeConc; |
| 222 | |
Agrawal Ashish | 17bb390 | 2016-05-05 13:29:40 +0530 | [diff] [blame] | 223 | pScanRequest->min_rest_time = |
| 224 | pMac->roam.configParam.min_rest_time_conc; |
| 225 | pScanRequest->idle_time = |
| 226 | pMac->roam.configParam.idle_time_conc; |
| 227 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 228 | /* Return so that fields set above will not be overwritten. */ |
| 229 | return; |
| 230 | } |
| 231 | #endif |
| 232 | |
| 233 | /* This portion of the code executed if multi-session not supported */ |
| 234 | /* (WLAN_AP_STA_CONCURRENCY not defined) or no multi-session. */ |
| 235 | /* Use the "regular" (non-concurrency) default scan timing. */ |
| 236 | cfg_set_int(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, |
| 237 | pMac->roam.configParam.nPassiveMaxChnTime); |
| 238 | if (pScanRequest->scanType == eSIR_ACTIVE_SCAN) { |
| 239 | pScanRequest->maxChnTime = |
| 240 | pMac->roam.configParam.nActiveMaxChnTime; |
| 241 | pScanRequest->minChnTime = |
| 242 | pMac->roam.configParam.nActiveMinChnTime; |
| 243 | } else { |
| 244 | pScanRequest->maxChnTime = |
| 245 | pMac->roam.configParam.nPassiveMaxChnTime; |
| 246 | pScanRequest->minChnTime = |
| 247 | pMac->roam.configParam.nPassiveMinChnTime; |
| 248 | } |
| 249 | #ifdef WLAN_AP_STA_CONCURRENCY |
Agrawal Ashish | 17bb390 | 2016-05-05 13:29:40 +0530 | [diff] [blame] | 250 | |
| 251 | /* No rest time/Idle time if no sessions are connected. */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 252 | pScanRequest->restTime = 0; |
Agrawal Ashish | 17bb390 | 2016-05-05 13:29:40 +0530 | [diff] [blame] | 253 | pScanRequest->min_rest_time = 0; |
| 254 | pScanRequest->idle_time = 0; |
| 255 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 256 | #endif |
| 257 | } |
| 258 | |
| 259 | /** |
| 260 | * csr_scan_2g_only_request() - This function will update the scan request with |
| 261 | * only 2.4GHz valid channel list. |
| 262 | * @mac_ctx: Pointer to Global MAC structure |
| 263 | * @scan_cmd scan cmd |
| 264 | * @scan_req scan req |
| 265 | * |
| 266 | * This function will update the scan request with only 2.4GHz valid channel |
| 267 | * list. |
| 268 | * |
| 269 | * @Return: status of operation |
| 270 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 271 | static QDF_STATUS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 272 | csr_scan_2g_only_request(tpAniSirGlobal mac_ctx, |
| 273 | tSmeCmd *scan_cmd, |
| 274 | tCsrScanRequest *scan_req) |
| 275 | { |
| 276 | uint8_t idx, lst_sz = 0; |
| 277 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 278 | QDF_ASSERT(scan_cmd && scan_req); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 279 | /* To silence the KW tool null check is added */ |
| 280 | if ((scan_cmd == NULL) || (scan_req == NULL)) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 281 | sme_err("Scan Cmd or Scan Request is NULL"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 282 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 283 | } |
| 284 | |
| 285 | if (eCSR_SCAN_REQUEST_FULL_SCAN != scan_req->requestType) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 286 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 287 | |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 288 | sme_debug("Scanning only 2G Channels during first scan"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 289 | |
| 290 | /* Contsruct valid Supported 2.4 GHz Channel List */ |
| 291 | if (NULL == scan_req->ChannelInfo.ChannelList) { |
| 292 | scan_req->ChannelInfo.ChannelList = |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 293 | qdf_mem_malloc(NUM_24GHZ_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 294 | if (NULL == scan_req->ChannelInfo.ChannelList) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 295 | sme_err("Memory allocation failed"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 296 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 297 | } |
| 298 | for (idx = 1; idx <= NUM_24GHZ_CHANNELS; idx++) { |
| 299 | if (csr_is_supported_channel(mac_ctx, idx)) { |
| 300 | scan_req->ChannelInfo.ChannelList[lst_sz] = idx; |
| 301 | lst_sz++; |
| 302 | } |
| 303 | } |
| 304 | } else { |
| 305 | for (idx = 0; |
| 306 | idx < scan_req->ChannelInfo.numOfChannels; |
| 307 | idx++) { |
| 308 | if (scan_req->ChannelInfo.ChannelList[idx] <= |
| 309 | CDS_24_GHZ_CHANNEL_14 |
| 310 | && csr_is_supported_channel(mac_ctx, |
| 311 | scan_req->ChannelInfo.ChannelList[idx])) { |
| 312 | scan_req->ChannelInfo.ChannelList[lst_sz] = |
| 313 | scan_req->ChannelInfo.ChannelList[idx]; |
| 314 | lst_sz++; |
| 315 | } |
| 316 | } |
| 317 | } |
| 318 | scan_req->ChannelInfo.numOfChannels = lst_sz; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 319 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 320 | } |
| 321 | |
| 322 | static void |
| 323 | csr_set_scan_reason(tSmeCmd *scan_cmd, eCsrRequestType req_type) |
| 324 | { |
| 325 | switch (req_type) { |
| 326 | case eCSR_SCAN_REQUEST_11D_SCAN: |
| 327 | scan_cmd->u.scanCmd.reason = eCsrScan11d1; |
| 328 | break; |
| 329 | #ifdef SOFTAP_CHANNEL_RANGE |
| 330 | case eCSR_SCAN_SOFTAP_CHANNEL_RANGE: |
| 331 | #endif |
| 332 | case eCSR_SCAN_REQUEST_FULL_SCAN: |
| 333 | case eCSR_SCAN_P2P_DISCOVERY: |
| 334 | scan_cmd->u.scanCmd.reason = eCsrScanUserRequest; |
| 335 | break; |
| 336 | case eCSR_SCAN_HO_PROBE_SCAN: |
| 337 | scan_cmd->u.scanCmd.reason = eCsrScanProbeBss; |
| 338 | break; |
| 339 | case eCSR_SCAN_P2P_FIND_PEER: |
| 340 | scan_cmd->u.scanCmd.reason = eCsrScanP2PFindPeer; |
| 341 | break; |
| 342 | default: |
| 343 | break; |
| 344 | } |
| 345 | } |
| 346 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 347 | static QDF_STATUS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 348 | csr_issue_11d_scan(tpAniSirGlobal mac_ctx, tSmeCmd *scan_cmd, |
| 349 | tCsrScanRequest *scan_req, uint16_t session_id) |
| 350 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 351 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 352 | tSmeCmd *scan_11d_cmd = NULL; |
| 353 | tCsrScanRequest tmp_rq; |
Naveen Rawat | d4c0c54 | 2016-11-17 11:49:17 -0800 | [diff] [blame] | 354 | tCsrChannelInfo *chn_info = &tmp_rq.ChannelInfo; |
| 355 | uint32_t num_chn = mac_ctx->scan.base_channels.numChannels; |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 356 | struct csr_roam_session *csr_session = CSR_GET_SESSION(mac_ctx, |
| 357 | session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 358 | |
| 359 | if (csr_session == NULL) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 360 | sme_err("session %d not found", session_id); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 361 | QDF_ASSERT(0); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 362 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 363 | } |
| 364 | |
Naveen Rawat | d4c0c54 | 2016-11-17 11:49:17 -0800 | [diff] [blame] | 365 | if (num_chn > WNI_CFG_VALID_CHANNEL_LIST_LEN) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 366 | sme_err("invalid number of channels: %d", num_chn); |
Naveen Rawat | d4c0c54 | 2016-11-17 11:49:17 -0800 | [diff] [blame] | 367 | return QDF_STATUS_E_FAILURE; |
| 368 | } |
| 369 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 370 | if (!(((false == mac_ctx->first_scan_done) |
| 371 | && (eCSR_SCAN_REQUEST_11D_SCAN != scan_req->requestType)) |
| 372 | #ifdef SOFTAP_CHANNEL_RANGE |
| 373 | && (eCSR_SCAN_SOFTAP_CHANNEL_RANGE != scan_req->requestType) |
| 374 | #endif |
| 375 | && (false == mac_ctx->scan.fEnableBypass11d))) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 376 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 377 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 378 | qdf_mem_set(&tmp_rq, sizeof(tCsrScanRequest), 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 379 | scan_11d_cmd = csr_get_command_buffer(mac_ctx); |
| 380 | if (!scan_11d_cmd) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 381 | sme_err("scan_11d_cmd failed"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 382 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 383 | } |
| 384 | |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 385 | qdf_mem_set(&scan_11d_cmd->u.scanCmd, sizeof(struct scan_cmd), 0); |
Naveen Rawat | d4c0c54 | 2016-11-17 11:49:17 -0800 | [diff] [blame] | 386 | chn_info->ChannelList = qdf_mem_malloc(num_chn); |
| 387 | if (NULL == chn_info->ChannelList) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 388 | sme_err("Failed to allocate memory"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 389 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 390 | } |
Naveen Rawat | d4c0c54 | 2016-11-17 11:49:17 -0800 | [diff] [blame] | 391 | qdf_mem_copy(chn_info->ChannelList, |
| 392 | mac_ctx->scan.base_channels.channelList, num_chn); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 393 | |
Naveen Rawat | d4c0c54 | 2016-11-17 11:49:17 -0800 | [diff] [blame] | 394 | chn_info->numOfChannels = (uint8_t) num_chn; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 395 | scan_11d_cmd->command = eSmeCommandScan; |
| 396 | scan_11d_cmd->u.scanCmd.callback = mac_ctx->scan.callback11dScanDone; |
| 397 | scan_11d_cmd->u.scanCmd.pContext = NULL; |
| 398 | wma_get_scan_id(&scan_11d_cmd->u.scanCmd.scanID); |
| 399 | tmp_rq.BSSType = eCSR_BSS_TYPE_ANY; |
| 400 | tmp_rq.scan_id = scan_11d_cmd->u.scanCmd.scanID; |
| 401 | |
Abhinav Kumar | 37ad327 | 2017-11-17 17:20:14 +0530 | [diff] [blame] | 402 | status = qdf_mc_timer_init(&scan_11d_cmd->u.scanCmd.csr_scan_timer, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 403 | QDF_TIMER_TYPE_SW, |
Selvaraj, Sridhar | 2eed393 | 2016-11-15 16:29:59 +0530 | [diff] [blame] | 404 | csr_scan_active_list_timeout_handle, scan_11d_cmd); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 405 | |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 406 | if (wlan_reg_11d_enabled_on_host(mac_ctx->psoc)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 407 | tmp_rq.bcnRptReqScan = scan_req->bcnRptReqScan; |
| 408 | if (scan_req->bcnRptReqScan) |
| 409 | tmp_rq.scanType = scan_req->scanType ? |
| 410 | eSIR_PASSIVE_SCAN : scan_req->scanType; |
| 411 | else |
| 412 | tmp_rq.scanType = eSIR_PASSIVE_SCAN; |
| 413 | tmp_rq.requestType = eCSR_SCAN_REQUEST_11D_SCAN; |
| 414 | scan_11d_cmd->u.scanCmd.reason = eCsrScan11d1; |
| 415 | tmp_rq.maxChnTime = |
| 416 | mac_ctx->roam.configParam.nPassiveMaxChnTime; |
| 417 | tmp_rq.minChnTime = |
| 418 | mac_ctx->roam.configParam.nPassiveMinChnTime; |
| 419 | } else { |
| 420 | tmp_rq.bcnRptReqScan = scan_req->bcnRptReqScan; |
| 421 | if (scan_req->bcnRptReqScan) |
| 422 | tmp_rq.scanType = scan_req->scanType; |
| 423 | else |
| 424 | tmp_rq.scanType = eSIR_ACTIVE_SCAN; |
| 425 | tmp_rq.requestType = scan_req->requestType; |
| 426 | scan_11d_cmd->u.scanCmd.reason = scan_cmd->u.scanCmd.reason; |
| 427 | tmp_rq.maxChnTime = mac_ctx->roam.configParam.nActiveMaxChnTime; |
| 428 | tmp_rq.minChnTime = mac_ctx->roam.configParam.nActiveMinChnTime; |
| 429 | } |
| 430 | if (mac_ctx->roam.configParam.nInitialDwellTime) { |
| 431 | tmp_rq.maxChnTime = mac_ctx->roam.configParam.nInitialDwellTime; |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 432 | sme_debug("11d scan, updating dwell time for first scan %u", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 433 | tmp_rq.maxChnTime); |
| 434 | } |
| 435 | |
| 436 | status = csr_scan_copy_request(mac_ctx, |
| 437 | &scan_11d_cmd->u.scanCmd.u.scanRequest, &tmp_rq); |
| 438 | /* Free the channel list */ |
Naveen Rawat | d4c0c54 | 2016-11-17 11:49:17 -0800 | [diff] [blame] | 439 | qdf_mem_free(chn_info->ChannelList); |
| 440 | chn_info->ChannelList = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 441 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 442 | sme_err("csr_scan_copy_request failed"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 443 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 444 | } |
| 445 | |
| 446 | mac_ctx->scan.scanProfile.numOfChannels = |
| 447 | scan_11d_cmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels; |
| 448 | |
| 449 | |
| 450 | status = csr_queue_sme_command(mac_ctx, scan_11d_cmd, false); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 451 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 452 | sme_err("Failed to send message status = %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 453 | status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 454 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 455 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 456 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 457 | } |
| 458 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 459 | QDF_STATUS csr_scan_request(tpAniSirGlobal pMac, uint16_t sessionId, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 460 | tCsrScanRequest *scan_req, |
| 461 | csr_scan_completeCallback callback, void *pContext) |
| 462 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 463 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 464 | tSmeCmd *scan_cmd = NULL; |
| 465 | tCsrScanRequest *pTempScanReq = NULL; |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 466 | struct csr_config *cfg_prm = &pMac->roam.configParam; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 467 | |
| 468 | if (scan_req == NULL) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 469 | sme_err("scan_req is NULL"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 470 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 471 | return status; |
| 472 | } |
| 473 | |
| 474 | /* |
| 475 | * During group formation, the P2P client scans for GO with the specific |
| 476 | * SSID. There will be chances of GO switching to other channels because |
| 477 | * of scan or to STA channel in case of STA+GO MCC scenario. So to |
| 478 | * increase the possibility of client to find the GO, the dwell time of |
| 479 | * scan is increased to 100ms. |
| 480 | * If the scan request is for specific SSId the length of SSID will be |
| 481 | * greater than 7 as SSID for p2p search contains "DIRECT-") |
| 482 | */ |
| 483 | if (scan_req->p2pSearch |
| 484 | && scan_req->SSIDs.numOfSSIDs |
| 485 | && (NULL != scan_req->SSIDs.SSIDList) |
| 486 | && (scan_req->SSIDs.SSIDList->SSID.length > DIRECT_SSID_LEN)) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 487 | sme_debug("P2P: Increasing the min and max Dwell time to %d for specific SSID scan %.*s", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 488 | MAX_CHN_TIME_TO_FIND_GO, |
| 489 | scan_req->SSIDs.SSIDList->SSID.length, |
| 490 | scan_req->SSIDs.SSIDList->SSID.ssId); |
| 491 | scan_req->maxChnTime = MAX_CHN_TIME_TO_FIND_GO; |
| 492 | scan_req->minChnTime = MIN_CHN_TIME_TO_FIND_GO; |
| 493 | } |
| 494 | |
| 495 | if (!pMac->scan.fScanEnable) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 496 | sme_err("SId: %d Scanning not enabled Scan type=%u, numOfSSIDs=%d P2P search=%d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 497 | sessionId, scan_req->requestType, |
| 498 | scan_req->SSIDs.numOfSSIDs, |
| 499 | scan_req->p2pSearch); |
| 500 | goto release_cmd; |
| 501 | } |
| 502 | |
| 503 | scan_cmd = csr_get_command_buffer(pMac); |
| 504 | if (!scan_cmd) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 505 | sme_err("scan_cmd is NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 506 | goto release_cmd; |
| 507 | } |
| 508 | |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 509 | qdf_mem_set(&scan_cmd->u.scanCmd, sizeof(struct scan_cmd), 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 510 | scan_cmd->command = eSmeCommandScan; |
| 511 | scan_cmd->sessionId = sessionId; |
| 512 | if (scan_cmd->sessionId >= CSR_ROAM_SESSION_MAX) |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 513 | sme_err("Invalid Sme SessionID: %d", sessionId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 514 | scan_cmd->u.scanCmd.callback = callback; |
| 515 | scan_cmd->u.scanCmd.pContext = pContext; |
| 516 | csr_set_scan_reason(scan_cmd, scan_req->requestType); |
| 517 | if (scan_req->minChnTime == 0 && scan_req->maxChnTime == 0) { |
| 518 | /* The caller doesn't set the time correctly. Set it here */ |
| 519 | csr_set_default_scan_timing(pMac, scan_req->scanType, scan_req); |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 520 | sme_debug("Setting default min %d and max %d ChnTime", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 521 | scan_req->minChnTime, scan_req->maxChnTime); |
| 522 | } |
| 523 | #ifdef WLAN_AP_STA_CONCURRENCY |
Agrawal Ashish | 17bb390 | 2016-05-05 13:29:40 +0530 | [diff] [blame] | 524 | /* |
| 525 | * Need to set restTime/min_Ret_time/idle_time |
| 526 | * only if at least one session is connected |
| 527 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 528 | if (scan_req->restTime == 0 && csr_is_any_session_connected(pMac)) { |
| 529 | scan_req->restTime = cfg_prm->nRestTimeConc; |
Agrawal Ashish | 17bb390 | 2016-05-05 13:29:40 +0530 | [diff] [blame] | 530 | scan_req->min_rest_time = cfg_prm->min_rest_time_conc; |
| 531 | scan_req->idle_time = cfg_prm->idle_time_conc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 532 | if (scan_req->scanType == eSIR_ACTIVE_SCAN) { |
| 533 | scan_req->maxChnTime = cfg_prm->nActiveMaxChnTimeConc; |
| 534 | scan_req->minChnTime = cfg_prm->nActiveMinChnTimeConc; |
| 535 | } else { |
| 536 | scan_req->maxChnTime = cfg_prm->nPassiveMaxChnTimeConc; |
| 537 | scan_req->minChnTime = cfg_prm->nPassiveMinChnTimeConc; |
| 538 | } |
| 539 | } |
| 540 | #endif |
| 541 | /* Increase dwell time in case P2P Search and Miracast is not present */ |
| 542 | if (scan_req->p2pSearch && scan_req->ChannelInfo.numOfChannels |
| 543 | == P2P_SOCIAL_CHANNELS && (!(pMac->sme.miracast_value))) { |
| 544 | scan_req->maxChnTime += P2P_SEARCH_DWELL_TIME_INCREASE; |
| 545 | } |
| 546 | scan_cmd->u.scanCmd.scanID = scan_req->scan_id; |
| 547 | /* |
| 548 | * If it is the first scan request from HDD, CSR checks if it is for 11d |
| 549 | * If it is not, CSR will save the scan request in the pending cmd queue |
| 550 | * & issue an 11d scan request to PE. |
| 551 | */ |
| 552 | status = csr_issue_11d_scan(pMac, scan_cmd, scan_req, sessionId); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 553 | if (status != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 554 | goto release_cmd; |
| 555 | |
| 556 | /* |
| 557 | * Scan only 2G Channels if set in ini file. This is mainly to reduce |
| 558 | * the First Scan duration once we turn on Wifi |
| 559 | */ |
| 560 | if (pMac->scan.fFirstScanOnly2GChnl |
| 561 | && false == pMac->first_scan_done) { |
| 562 | csr_scan_2g_only_request(pMac, scan_cmd, scan_req); |
| 563 | pMac->first_scan_done = true; |
| 564 | } |
| 565 | |
| 566 | |
| 567 | if (cfg_prm->nInitialDwellTime) { |
| 568 | scan_req->maxChnTime = cfg_prm->nInitialDwellTime; |
| 569 | cfg_prm->nInitialDwellTime = 0; |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 570 | sme_debug("updating dwell time for first scan %u", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 571 | scan_req->maxChnTime); |
| 572 | } |
Paul Zhang | 72697bd | 2017-12-20 09:24:25 +0800 | [diff] [blame] | 573 | |
| 574 | if (csr_is_conn_state_disconnected(pMac, sessionId)) |
| 575 | scan_req->scan_adaptive_dwell_mode = |
| 576 | cfg_prm->scan_adaptive_dwell_mode_nc; |
| 577 | else |
| 578 | scan_req->scan_adaptive_dwell_mode = |
| 579 | cfg_prm->scan_adaptive_dwell_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 580 | |
| 581 | status = csr_scan_copy_request(pMac, &scan_cmd->u.scanCmd.u.scanRequest, |
| 582 | scan_req); |
| 583 | /* |
| 584 | * Reset the variable after the first scan is queued after loading the |
| 585 | * driver. The purpose of this parameter is that DFS channels are |
| 586 | * skipped during the first scan after loading the driver. The above API |
| 587 | * builds the target scan request in which this variable is used. |
| 588 | */ |
| 589 | cfg_prm->initial_scan_no_dfs_chnl = 0; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 590 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 591 | sme_err("fail to copy request status: %d", status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 592 | goto release_cmd; |
| 593 | } |
| 594 | |
| 595 | pTempScanReq = &scan_cmd->u.scanCmd.u.scanRequest; |
| 596 | pMac->scan.scanProfile.numOfChannels = |
| 597 | pTempScanReq->ChannelInfo.numOfChannels; |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 598 | status = qdf_mc_timer_init(&scan_cmd->u.scanCmd.csr_scan_timer, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 599 | QDF_TIMER_TYPE_SW, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 600 | csr_scan_active_list_timeout_handle, scan_cmd); |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 601 | sme_debug( |
| 602 | "SId=%d scanId=%d Scan reason=%u numSSIDs=%d numChan=%d P2P search=%d minCT=%d maxCT=%d uIEFieldLen=%d BSSID: " MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 603 | sessionId, scan_cmd->u.scanCmd.scanID, |
| 604 | scan_cmd->u.scanCmd.reason, pTempScanReq->SSIDs.numOfSSIDs, |
| 605 | pTempScanReq->ChannelInfo.numOfChannels, |
| 606 | pTempScanReq->p2pSearch, pTempScanReq->minChnTime, |
Sreelakshmi Konamki | 8b8257c | 2016-12-12 15:44:54 +0530 | [diff] [blame] | 607 | pTempScanReq->maxChnTime, pTempScanReq->uIEFieldLen, |
| 608 | MAC_ADDR_ARRAY(scan_cmd->u.scanCmd.u.scanRequest.bssid.bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 609 | |
| 610 | status = csr_queue_sme_command(pMac, scan_cmd, false); |
Krunal Soni | aa179db | 2017-10-13 19:28:17 -0700 | [diff] [blame] | 611 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 612 | sme_err("fail to send message status: %d", status); |
Krunal Soni | aa179db | 2017-10-13 19:28:17 -0700 | [diff] [blame] | 613 | return status; |
| 614 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 615 | |
| 616 | release_cmd: |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 617 | if (!QDF_IS_STATUS_SUCCESS(status) && scan_cmd) { |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 618 | sme_err(" SId: %d Failed with status=%d Scan reason=%u numOfSSIDs=%d P2P search=%d scanId=%d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 619 | sessionId, status, scan_cmd->u.scanCmd.reason, |
| 620 | scan_req->SSIDs.numOfSSIDs, scan_req->p2pSearch, |
| 621 | scan_cmd->u.scanCmd.scanID); |
Krunal Soni | aa179db | 2017-10-13 19:28:17 -0700 | [diff] [blame] | 622 | csr_release_command_buffer(pMac, scan_cmd); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 623 | } |
| 624 | |
| 625 | return status; |
| 626 | } |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 627 | #ifndef NAPIER_SCAN |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 628 | static QDF_STATUS csr_issue_roam_after_lostlink_scan( |
| 629 | tpAniSirGlobal pMac, uint32_t sessionId, |
| 630 | enum csr_roam_reason reason) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 631 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 632 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 633 | tScanResultHandle hBSSList = NULL; |
| 634 | tCsrScanResultFilter *pScanFilter = NULL; |
| 635 | uint32_t roamId = 0; |
| 636 | tCsrRoamProfile *pProfile = NULL; |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 637 | struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 638 | |
| 639 | if (!pSession) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 640 | sme_err("session %d not found", sessionId); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 641 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 642 | } |
| 643 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 644 | if (pSession->fCancelRoaming) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 645 | sme_debug("lost link roaming canceled"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 646 | status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 647 | goto free_filter; |
| 648 | } |
| 649 | /* Here is the profile we need to connect to */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 650 | pScanFilter = qdf_mem_malloc(sizeof(tCsrScanResultFilter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 651 | if (NULL == pScanFilter) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 652 | status = QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 653 | goto free_filter; |
| 654 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 655 | if (NULL == pSession->pCurRoamProfile) { |
| 656 | pScanFilter->EncryptionType.numEntries = 1; |
| 657 | pScanFilter->EncryptionType.encryptionType[0] = |
| 658 | eCSR_ENCRYPT_TYPE_NONE; |
| 659 | } else { |
| 660 | /* |
| 661 | * We have to make a copy of pCurRoamProfile because it will |
| 662 | * be free inside csr_roam_issue_connect |
| 663 | */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 664 | pProfile = qdf_mem_malloc(sizeof(tCsrRoamProfile)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 665 | if (NULL == pProfile) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 666 | status = QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 667 | goto free_filter; |
| 668 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 669 | status = csr_roam_copy_profile(pMac, pProfile, |
| 670 | pSession->pCurRoamProfile); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 671 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 672 | goto free_filter; |
| 673 | status = csr_roam_prepare_filter_from_profile(pMac, pProfile, |
| 674 | pScanFilter); |
| 675 | } /* We have a profile */ |
| 676 | roamId = GET_NEXT_ROAM_ID(&pMac->roam); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 677 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 678 | goto free_filter; |
| 679 | |
| 680 | status = csr_scan_get_result(pMac, pScanFilter, &hBSSList); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 681 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 682 | goto free_filter; |
| 683 | |
| 684 | if (eCsrLostLink1 == reason) { |
| 685 | /* if possible put the last connected BSS in beginning */ |
| 686 | csr_move_bss_to_head_from_bssid(pMac, |
| 687 | &pSession->connectedProfile.bssid, hBSSList); |
| 688 | } |
| 689 | status = csr_roam_issue_connect(pMac, sessionId, pProfile, hBSSList, |
| 690 | reason, roamId, true, true); |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 691 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 692 | csr_scan_result_purge(pMac, hBSSList); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 693 | |
| 694 | free_filter: |
| 695 | if (pScanFilter) { |
| 696 | /* we need to free memory for filter if profile exists */ |
| 697 | csr_free_scan_filter(pMac, pScanFilter); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 698 | qdf_mem_free(pScanFilter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 699 | } |
| 700 | if (NULL != pProfile) { |
| 701 | csr_release_profile(pMac, pProfile); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 702 | qdf_mem_free(pProfile); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 703 | } |
| 704 | return status; |
| 705 | } |
| 706 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 707 | QDF_STATUS csr_scan_handle_failed_lostlink1(tpAniSirGlobal pMac, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 708 | uint32_t sessionId) |
| 709 | { |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 710 | struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 711 | |
| 712 | if (!pSession) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 713 | sme_err("session %d not found", sessionId); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 714 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 715 | } |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 716 | sme_debug("Lost link scan 1 failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 717 | if (pSession->fCancelRoaming) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 718 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 719 | if (!pSession->pCurRoamProfile) |
| 720 | return csr_scan_request_lost_link3(pMac, sessionId); |
| 721 | /* |
| 722 | * We fail lostlink1 but there may be other BSS in the cached result |
| 723 | * fit the profile. Give it a try first |
| 724 | */ |
| 725 | if (pSession->pCurRoamProfile->SSIDs.numOfSSIDs == 0 || |
| 726 | pSession->pCurRoamProfile->SSIDs.numOfSSIDs > 1) |
| 727 | /* try lostlink scan2 */ |
| 728 | return csr_scan_request_lost_link2(pMac, sessionId); |
| 729 | if (!pSession->pCurRoamProfile->ChannelInfo.ChannelList |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 730 | || pSession->pCurRoamProfile->ChannelInfo.ChannelList[0] == 0) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 731 | /* go straight to lostlink scan3 */ |
| 732 | return csr_scan_request_lost_link3(pMac, sessionId); |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 733 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 734 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 735 | } |
| 736 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 737 | QDF_STATUS csr_scan_handle_failed_lostlink2(tpAniSirGlobal pMac, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 738 | uint32_t sessionId) |
| 739 | { |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 740 | struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 741 | |
| 742 | if (!pSession) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 743 | sme_err("session %d not found", sessionId); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 744 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 745 | } |
| 746 | |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 747 | sme_debug("Lost link scan 2 failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 748 | if (pSession->fCancelRoaming) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 749 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 750 | |
| 751 | if (!pSession->pCurRoamProfile |
| 752 | || !pSession->pCurRoamProfile->ChannelInfo.ChannelList |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 753 | || pSession->pCurRoamProfile->ChannelInfo.ChannelList[0] == 0) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 754 | /* try lostlink scan3 */ |
| 755 | return csr_scan_request_lost_link3(pMac, sessionId); |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 756 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 757 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 758 | } |
| 759 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 760 | QDF_STATUS csr_scan_handle_failed_lostlink3(tpAniSirGlobal pMac, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 761 | uint32_t sessionId) |
| 762 | { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 763 | sme_debug("Lost link scan 3 failed"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 764 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 765 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 766 | static QDF_STATUS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 767 | csr_update_lost_link1_cmd(tpAniSirGlobal mac_ctx, tSmeCmd *cmd, |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 768 | struct csr_roam_session *pSession, uint32_t session_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 769 | { |
| 770 | uint8_t i, num_ch = 0; |
| 771 | tScanResultHandle bss_lst = NULL; |
| 772 | tCsrScanResultInfo *scan_result = NULL; |
| 773 | tCsrScanResultFilter *scan_filter = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 774 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 775 | tCsrSSIDs *ssid_list = &cmd->u.scanCmd.u.scanRequest.SSIDs; |
| 776 | tCsrChannelInfo *ch_info = &cmd->u.scanCmd.u.scanRequest.ChannelInfo; |
| 777 | |
| 778 | cmd->command = eSmeCommandScan; |
| 779 | cmd->sessionId = (uint8_t) session_id; |
| 780 | cmd->u.scanCmd.reason = eCsrScanLostLink1; |
| 781 | cmd->u.scanCmd.callback = NULL; |
| 782 | cmd->u.scanCmd.pContext = NULL; |
| 783 | cmd->u.scanCmd.u.scanRequest.maxChnTime = |
| 784 | mac_ctx->roam.configParam.nActiveMaxChnTime; |
| 785 | cmd->u.scanCmd.u.scanRequest.minChnTime = |
| 786 | mac_ctx->roam.configParam.nActiveMinChnTime; |
| 787 | cmd->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 788 | wma_get_scan_id(&cmd->u.scanCmd.scanID); |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 789 | status = qdf_mc_timer_init(&cmd->u.scanCmd.csr_scan_timer, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 790 | QDF_TIMER_TYPE_SW, |
Selvaraj, Sridhar | 2eed393 | 2016-11-15 16:29:59 +0530 | [diff] [blame] | 791 | csr_scan_active_list_timeout_handle, cmd); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 792 | cmd->u.scanCmd.u.scanRequest.scan_id = |
| 793 | cmd->u.scanCmd.scanID; |
| 794 | |
| 795 | if (pSession->connectedProfile.SSID.length) { |
| 796 | /* |
| 797 | * on error: following memory will be released by call to |
| 798 | * csr_release_command_scan in the end |
| 799 | */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 800 | ssid_list->SSIDList = qdf_mem_malloc(sizeof(tCsrSSIDInfo)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 801 | if (NULL == ssid_list->SSIDList) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 802 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 803 | ssid_list->numOfSSIDs = 1; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 804 | qdf_mem_copy(&ssid_list->SSIDList[0].SSID, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 805 | &pSession->connectedProfile.SSID, |
| 806 | sizeof(tSirMacSSid)); |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 807 | } else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 808 | ssid_list->numOfSSIDs = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 809 | |
| 810 | if (!pSession->pCurRoamProfile) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 811 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 812 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 813 | scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 814 | if (NULL == scan_filter) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 815 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 816 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 817 | status = csr_roam_prepare_filter_from_profile(mac_ctx, |
| 818 | pSession->pCurRoamProfile, scan_filter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 819 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 820 | goto free_lost_link1_local_mem; |
| 821 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 822 | if (!(QDF_IS_STATUS_SUCCESS(csr_scan_get_result(mac_ctx, scan_filter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 823 | &bss_lst)) && bss_lst)) { |
| 824 | if (csr_roam_is_channel_valid(mac_ctx, |
| 825 | pSession->connectedProfile.operationChannel)) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 826 | ch_info->ChannelList = qdf_mem_malloc(1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 827 | if (NULL == ch_info->ChannelList) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 828 | status = QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 829 | goto free_lost_link1_local_mem; |
| 830 | } |
| 831 | ch_info->ChannelList[0] = |
| 832 | pSession->connectedProfile.operationChannel; |
| 833 | ch_info->numOfChannels = 1; |
| 834 | } |
Arif Hussain | d3bf111 | 2016-07-29 10:16:53 -0700 | [diff] [blame] | 835 | csr_free_scan_filter(mac_ctx, scan_filter); |
| 836 | qdf_mem_free(scan_filter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 837 | return status; |
| 838 | } |
| 839 | |
| 840 | /* on error: this mem will be released by csr_release_command_scan */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 841 | ch_info->ChannelList = qdf_mem_malloc(WNI_CFG_VALID_CHANNEL_LIST_LEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 842 | if (NULL == ch_info->ChannelList) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 843 | status = QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 844 | goto free_lost_link1_local_mem; |
| 845 | } |
| 846 | |
| 847 | scan_result = csr_scan_result_get_next(mac_ctx, bss_lst); |
| 848 | while (scan_result != NULL && num_ch < WNI_CFG_VALID_CHANNEL_LIST_LEN) { |
| 849 | for (i = 0; i < num_ch; i++) { |
| 850 | if (ch_info->ChannelList[i] == |
| 851 | scan_result->BssDescriptor.channelId) |
| 852 | break; |
| 853 | } |
| 854 | if (i == num_ch) |
| 855 | ch_info->ChannelList[num_ch++] = |
| 856 | scan_result->BssDescriptor.channelId; |
| 857 | scan_result = csr_scan_result_get_next(mac_ctx, bss_lst); |
| 858 | } |
| 859 | /* Include the last connected BSS' channel */ |
| 860 | if (csr_roam_is_channel_valid(mac_ctx, |
| 861 | pSession->connectedProfile.operationChannel)) { |
| 862 | for (i = 0; i < num_ch; i++) { |
| 863 | if (ch_info->ChannelList[i] == |
| 864 | pSession->connectedProfile.operationChannel) |
| 865 | break; |
| 866 | } |
| 867 | if (i == num_ch) |
| 868 | ch_info->ChannelList[num_ch++] = |
| 869 | pSession->connectedProfile.operationChannel; |
| 870 | } |
| 871 | ch_info->numOfChannels = num_ch; |
| 872 | free_lost_link1_local_mem: |
| 873 | if (scan_filter) { |
| 874 | csr_free_scan_filter(mac_ctx, scan_filter); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 875 | qdf_mem_free(scan_filter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 876 | } |
| 877 | if (bss_lst) |
| 878 | csr_scan_result_purge(mac_ctx, bss_lst); |
| 879 | return status; |
| 880 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 881 | /** |
| 882 | * csr_scan_request_lost_link1() - start scan on link lost 1 |
| 883 | * @mac_ctx: mac global context |
| 884 | * @session_id: session id |
| 885 | * |
| 886 | * Lostlink1 scan is to actively scan the last connected profile's SSID on all |
| 887 | * matched BSS channels. If no roam profile (it should not), it is like |
| 888 | * lostlinkscan3 |
| 889 | * |
| 890 | * Return: status of operation |
| 891 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 892 | QDF_STATUS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 893 | csr_scan_request_lost_link1(tpAniSirGlobal mac_ctx, uint32_t session_id) |
| 894 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 895 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 896 | tSmeCmd *cmd = NULL; |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 897 | struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 898 | |
| 899 | if (!session) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 900 | sme_err("session %d not found", session_id); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 901 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 902 | } |
| 903 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 904 | cmd = csr_get_command_buffer(mac_ctx); |
| 905 | if (!cmd) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 906 | status = QDF_STATUS_E_RESOURCES; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 907 | goto release_lost_link1_cmd; |
| 908 | } |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 909 | qdf_mem_set(&cmd->u.scanCmd, sizeof(struct scan_cmd), 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 910 | status = csr_update_lost_link1_cmd(mac_ctx, cmd, session, session_id); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 911 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 912 | goto release_lost_link1_cmd; |
| 913 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 914 | qdf_mem_set(&cmd->u.scanCmd.u.scanRequest.bssid, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 915 | sizeof(struct qdf_mac_addr), 0xFF); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 916 | status = csr_queue_sme_command(mac_ctx, cmd, false); |
Krunal Soni | aa179db | 2017-10-13 19:28:17 -0700 | [diff] [blame] | 917 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 918 | sme_err("fail to send message status: %d", status); |
Krunal Soni | aa179db | 2017-10-13 19:28:17 -0700 | [diff] [blame] | 919 | return status; |
| 920 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 921 | |
| 922 | release_lost_link1_cmd: |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 923 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 924 | sme_warn("failed with status %d", status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 925 | if (cmd) |
Krunal Soni | aa179db | 2017-10-13 19:28:17 -0700 | [diff] [blame] | 926 | csr_release_command_buffer(mac_ctx, cmd); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 927 | status = csr_scan_handle_failed_lostlink1(mac_ctx, session_id); |
| 928 | } |
| 929 | return status; |
| 930 | } |
| 931 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 932 | static QDF_STATUS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 933 | csr_update_lost_link2_cmd(tpAniSirGlobal mac_ctx, tSmeCmd *cmd, |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 934 | uint32_t session_id, struct csr_roam_session *session) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 935 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 936 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 937 | uint8_t i, num_ch = 0; |
| 938 | tScanResultHandle bss_lst = NULL; |
| 939 | tCsrScanResultInfo *scan_result = NULL; |
| 940 | tCsrScanResultFilter *scan_fltr = NULL; |
| 941 | tCsrChannelInfo *ch_info = &cmd->u.scanCmd.u.scanRequest.ChannelInfo; |
| 942 | |
| 943 | cmd->command = eSmeCommandScan; |
| 944 | cmd->sessionId = (uint8_t) session_id; |
| 945 | cmd->u.scanCmd.reason = eCsrScanLostLink2; |
| 946 | cmd->u.scanCmd.callback = NULL; |
| 947 | cmd->u.scanCmd.pContext = NULL; |
| 948 | cmd->u.scanCmd.u.scanRequest.maxChnTime = |
| 949 | mac_ctx->roam.configParam.nActiveMaxChnTime; |
| 950 | cmd->u.scanCmd.u.scanRequest.minChnTime = |
| 951 | mac_ctx->roam.configParam.nActiveMinChnTime; |
| 952 | cmd->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 953 | wma_get_scan_id(&cmd->u.scanCmd.scanID); |
| 954 | cmd->u.scanCmd.u.scanRequest.scan_id = |
| 955 | cmd->u.scanCmd.scanID; |
| 956 | if (!session->pCurRoamProfile) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 957 | return QDF_STATUS_SUCCESS; |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 958 | status = qdf_mc_timer_init(&cmd->u.scanCmd.csr_scan_timer, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 959 | QDF_TIMER_TYPE_SW, |
Selvaraj, Sridhar | 2eed393 | 2016-11-15 16:29:59 +0530 | [diff] [blame] | 960 | csr_scan_active_list_timeout_handle, cmd); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 961 | scan_fltr = qdf_mem_malloc(sizeof(tCsrScanResultFilter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 962 | if (NULL == scan_fltr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 963 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 964 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 965 | qdf_mem_set(scan_fltr, sizeof(tCsrScanResultFilter), 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 966 | status = csr_roam_prepare_filter_from_profile(mac_ctx, |
| 967 | session->pCurRoamProfile, scan_fltr); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 968 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 969 | goto free_lost_link2_local_mem; |
| 970 | |
| 971 | status = csr_scan_get_result(mac_ctx, scan_fltr, &bss_lst); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 972 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 973 | goto free_lost_link2_local_mem; |
| 974 | |
| 975 | if (!bss_lst) |
| 976 | goto free_lost_link2_local_mem; |
| 977 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 978 | ch_info->ChannelList = qdf_mem_malloc(WNI_CFG_VALID_CHANNEL_LIST_LEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 979 | if (NULL == ch_info->ChannelList) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 980 | status = QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 981 | goto free_lost_link2_local_mem; |
| 982 | } |
| 983 | scan_result = csr_scan_result_get_next(mac_ctx, bss_lst); |
| 984 | while (scan_result != NULL && num_ch < WNI_CFG_VALID_CHANNEL_LIST_LEN) { |
| 985 | for (i = 0; i < num_ch; i++) { |
| 986 | if (ch_info->ChannelList[i] == |
| 987 | scan_result->BssDescriptor.channelId) |
| 988 | break; |
| 989 | } |
| 990 | if (i == num_ch) |
| 991 | ch_info->ChannelList[num_ch++] = |
| 992 | scan_result->BssDescriptor.channelId; |
| 993 | scan_result = csr_scan_result_get_next(mac_ctx, bss_lst); |
| 994 | } |
| 995 | ch_info->numOfChannels = num_ch; |
| 996 | |
| 997 | free_lost_link2_local_mem: |
| 998 | if (scan_fltr) { |
| 999 | csr_free_scan_filter(mac_ctx, scan_fltr); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1000 | qdf_mem_free(scan_fltr); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1001 | } |
| 1002 | if (bss_lst) |
| 1003 | csr_scan_result_purge(mac_ctx, bss_lst); |
| 1004 | return status; |
| 1005 | } |
| 1006 | |
| 1007 | /** |
| 1008 | * csr_scan_request_lost_link2() - start scan on link lost 2 |
| 1009 | * @mac_ctx: mac global context |
| 1010 | * @session_id: session id |
| 1011 | * |
| 1012 | * Lostlink2 scan is to actively scan the all SSIDs of the last roaming |
| 1013 | * profile's on all matched BSS channels. Since MAC doesn't support multiple |
| 1014 | * SSID, we scan all SSIDs and filter them afterwards |
| 1015 | * |
| 1016 | * Return: status of operation |
| 1017 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1018 | QDF_STATUS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1019 | csr_scan_request_lost_link2(tpAniSirGlobal mac_ctx, uint32_t session_id) |
| 1020 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1021 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1022 | tSmeCmd *cmd = NULL; |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 1023 | struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1024 | |
| 1025 | if (!session) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1026 | sme_err("session %d not found", session_id); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1027 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1028 | } |
| 1029 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1030 | cmd = csr_get_command_buffer(mac_ctx); |
| 1031 | if (!cmd) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1032 | status = QDF_STATUS_E_RESOURCES; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1033 | goto release_lost_link2_cmd; |
| 1034 | } |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 1035 | qdf_mem_set(&cmd->u.scanCmd, sizeof(struct scan_cmd), 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1036 | status = csr_update_lost_link2_cmd(mac_ctx, cmd, session_id, session); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1037 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1038 | goto release_lost_link2_cmd; |
| 1039 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1040 | qdf_mem_set(&cmd->u.scanCmd.u.scanRequest.bssid, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1041 | sizeof(struct qdf_mac_addr), 0xFF); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1042 | /* Put to the head in pending queue */ |
| 1043 | status = csr_queue_sme_command(mac_ctx, cmd, true); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1044 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1045 | sme_err("fail to send message status: %d", status); |
Krunal Soni | aa179db | 2017-10-13 19:28:17 -0700 | [diff] [blame] | 1046 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1047 | } |
| 1048 | |
| 1049 | release_lost_link2_cmd: |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1050 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1051 | sme_warn("failed with status %d", status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1052 | if (cmd) |
Krunal Soni | aa179db | 2017-10-13 19:28:17 -0700 | [diff] [blame] | 1053 | csr_release_command_buffer(mac_ctx, cmd); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1054 | status = csr_scan_handle_failed_lostlink2(mac_ctx, session_id); |
| 1055 | } |
| 1056 | return status; |
| 1057 | } |
| 1058 | |
| 1059 | /** |
| 1060 | * csr_scan_request_lost_link3() - To actively scan all valid channels |
| 1061 | * @mac_ctx: mac global context |
| 1062 | * @session_id: session id |
| 1063 | * |
| 1064 | * Return: status of operation |
| 1065 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1066 | QDF_STATUS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1067 | csr_scan_request_lost_link3(tpAniSirGlobal mac_ctx, uint32_t session_id) |
| 1068 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1069 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1070 | tSmeCmd *cmd; |
| 1071 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1072 | do { |
| 1073 | cmd = csr_get_command_buffer(mac_ctx); |
| 1074 | if (!cmd) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1075 | status = QDF_STATUS_E_RESOURCES; |
Krunal Soni | aa179db | 2017-10-13 19:28:17 -0700 | [diff] [blame] | 1076 | sme_warn("failed with status %d", status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1077 | break; |
| 1078 | } |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 1079 | qdf_mem_set(&cmd->u.scanCmd, sizeof(struct scan_cmd), 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1080 | cmd->command = eSmeCommandScan; |
| 1081 | cmd->sessionId = (uint8_t) session_id; |
| 1082 | cmd->u.scanCmd.reason = eCsrScanLostLink3; |
| 1083 | cmd->u.scanCmd.callback = NULL; |
| 1084 | cmd->u.scanCmd.pContext = NULL; |
| 1085 | cmd->u.scanCmd.u.scanRequest.maxChnTime = |
| 1086 | mac_ctx->roam.configParam.nActiveMaxChnTime; |
| 1087 | cmd->u.scanCmd.u.scanRequest.minChnTime = |
| 1088 | mac_ctx->roam.configParam.nActiveMinChnTime; |
| 1089 | cmd->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 1090 | wma_get_scan_id(&cmd->u.scanCmd.scanID); |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 1091 | status = qdf_mc_timer_init(&cmd->u.scanCmd.csr_scan_timer, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1092 | QDF_TIMER_TYPE_SW, |
Selvaraj, Sridhar | 2eed393 | 2016-11-15 16:29:59 +0530 | [diff] [blame] | 1093 | csr_scan_active_list_timeout_handle, cmd); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1094 | cmd->u.scanCmd.u.scanRequest.scan_id = |
| 1095 | cmd->u.scanCmd.scanID; |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 1096 | qdf_set_macaddr_broadcast(&cmd->u.scanCmd.u.scanRequest.bssid); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1097 | /* Put to the head of pending queue */ |
| 1098 | status = csr_queue_sme_command(mac_ctx, cmd, true); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1099 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1100 | sme_err("fail to send message status: %d", status); |
Krunal Soni | aa179db | 2017-10-13 19:28:17 -0700 | [diff] [blame] | 1101 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1102 | } |
| 1103 | } while (0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1104 | |
| 1105 | return status; |
| 1106 | } |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1107 | #else |
| 1108 | QDF_STATUS |
| 1109 | csr_scan_request_lost_link1(tpAniSirGlobal mac_ctx, uint32_t session_id) |
| 1110 | { |
| 1111 | return QDF_STATUS_E_FAILURE; |
| 1112 | } |
| 1113 | QDF_STATUS |
| 1114 | csr_scan_request_lost_link3(tpAniSirGlobal mac_ctx, uint32_t session_id) |
| 1115 | { |
| 1116 | return QDF_STATUS_E_FAILURE; |
| 1117 | } |
| 1118 | QDF_STATUS |
| 1119 | csr_scan_request_lost_link2(tpAniSirGlobal mac_ctx, uint32_t session_id) |
| 1120 | { |
| 1121 | return QDF_STATUS_E_FAILURE; |
| 1122 | } |
| 1123 | QDF_STATUS csr_scan_handle_failed_lostlink3(tpAniSirGlobal pMac, |
| 1124 | uint32_t sessionId) |
| 1125 | { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1126 | sme_debug("Lost link scan 3 failed"); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1127 | return QDF_STATUS_SUCCESS; |
| 1128 | } |
| 1129 | #endif |
Sandeep Puligilla | 344d725 | 2017-09-15 16:23:33 -0700 | [diff] [blame] | 1130 | |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1131 | QDF_STATUS csr_scan_handle_search_for_ssid(tpAniSirGlobal mac_ctx, |
| 1132 | uint32_t session_id) |
| 1133 | { |
| 1134 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
| 1135 | tScanResultHandle hBSSList = CSR_INVALID_SCANRESULT_HANDLE; |
| 1136 | tCsrScanResultFilter *pScanFilter = NULL; |
| 1137 | tCsrRoamProfile *profile; |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 1138 | struct csr_roam_session *session; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1139 | |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1140 | session = CSR_GET_SESSION(mac_ctx, session_id); |
| 1141 | if (!session) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1142 | sme_err("session %d not found", session_id); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1143 | return QDF_STATUS_E_FAILURE; |
| 1144 | } |
| 1145 | profile = session->scan_info.profile; |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1146 | sme_debug("session %d", session_id); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1147 | do { |
| 1148 | /* |
| 1149 | * If there is roam command waiting, ignore this roam because |
| 1150 | * the newer roam command is the one to execute |
| 1151 | */ |
| 1152 | if (csr_is_roam_command_waiting_for_session(mac_ctx, session_id)) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1153 | sme_warn("aborts because roam command waiting"); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1154 | break; |
| 1155 | } |
| 1156 | if (profile == NULL) |
| 1157 | break; |
| 1158 | pScanFilter = qdf_mem_malloc(sizeof(tCsrScanResultFilter)); |
| 1159 | if (NULL == pScanFilter) { |
| 1160 | status = QDF_STATUS_E_NOMEM; |
| 1161 | break; |
| 1162 | } |
| 1163 | status = csr_roam_prepare_filter_from_profile(mac_ctx, profile, |
| 1164 | pScanFilter); |
| 1165 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1166 | break; |
| 1167 | status = csr_scan_get_result(mac_ctx, pScanFilter, &hBSSList); |
| 1168 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1169 | break; |
| 1170 | if (mac_ctx->roam.roamSession[session_id].connectState == |
| 1171 | eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTING) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1172 | sme_err("upper layer issued disconnetion"); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1173 | status = QDF_STATUS_E_FAILURE; |
| 1174 | break; |
| 1175 | } |
| 1176 | status = csr_roam_issue_connect(mac_ctx, session_id, profile, |
| 1177 | hBSSList, eCsrHddIssued, |
| 1178 | session->scan_info.roam_id, |
| 1179 | true, true); |
| 1180 | } while (0); |
| 1181 | |
| 1182 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 1183 | if (CSR_INVALID_SCANRESULT_HANDLE != hBSSList) { |
| 1184 | csr_scan_result_purge(mac_ctx, hBSSList); |
| 1185 | } |
| 1186 | /* We haven't done anything to this profile */ |
| 1187 | csr_roam_call_callback(mac_ctx, session_id, NULL, |
| 1188 | session->scan_info.roam_id, |
| 1189 | eCSR_ROAM_ASSOCIATION_FAILURE, |
| 1190 | eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE); |
| 1191 | } |
| 1192 | if (pScanFilter) { |
| 1193 | csr_free_scan_filter(mac_ctx, pScanFilter); |
| 1194 | qdf_mem_free(pScanFilter); |
| 1195 | } |
| 1196 | return status; |
| 1197 | } |
| 1198 | |
Vignesh Viswanathan | 014096a | 2017-12-07 01:24:44 +0530 | [diff] [blame] | 1199 | /** |
| 1200 | * csr_handle_fils_scan_for_ssid_failure() - Checks and fills FILS seq number |
| 1201 | * in roam_info structure to send to hdd |
| 1202 | * |
| 1203 | * @roam_profile: Pointer to current roam_profile structure |
| 1204 | * @roam_info: Pointer to roam_info strucure to be filled |
| 1205 | * |
| 1206 | * Return: true for FILS connection else false |
| 1207 | */ |
| 1208 | #ifdef WLAN_FEATURE_FILS_SK |
| 1209 | static |
| 1210 | bool csr_handle_fils_scan_for_ssid_failure(tCsrRoamProfile *roam_profile, |
| 1211 | struct csr_roam_info *roam_info) |
| 1212 | { |
| 1213 | if (roam_profile && roam_profile->fils_con_info && |
| 1214 | roam_profile->fils_con_info->is_fils_connection) { |
| 1215 | sme_debug("send roam_info for FILS connection failure, seq %d", |
| 1216 | roam_profile->fils_con_info->sequence_number); |
| 1217 | roam_info->is_fils_connection = true; |
| 1218 | roam_info->fils_seq_num = |
| 1219 | roam_profile->fils_con_info->sequence_number; |
| 1220 | return true; |
| 1221 | } |
| 1222 | |
| 1223 | return false; |
| 1224 | } |
| 1225 | #else |
| 1226 | static |
| 1227 | bool csr_handle_fils_scan_for_ssid_failure(tCsrRoamProfile *roam_profile, |
| 1228 | struct csr_roam_info *roam_info) |
| 1229 | { |
| 1230 | return false; |
| 1231 | } |
| 1232 | #endif |
| 1233 | |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1234 | QDF_STATUS csr_scan_handle_search_for_ssid_failure(tpAniSirGlobal mac_ctx, |
| 1235 | uint32_t session_id) |
| 1236 | { |
| 1237 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
| 1238 | tCsrRoamProfile *profile; |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 1239 | struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, session_id); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1240 | eCsrRoamResult roam_result; |
Vignesh Viswanathan | 014096a | 2017-12-07 01:24:44 +0530 | [diff] [blame] | 1241 | struct csr_roam_info *roam_info = NULL; |
| 1242 | struct tag_csrscan_result *scan_result; |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1243 | |
| 1244 | if (!session) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1245 | sme_err("session %d not found", session_id); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1246 | return QDF_STATUS_E_FAILURE; |
| 1247 | } |
| 1248 | profile = session->scan_info.profile; |
| 1249 | |
| 1250 | /* |
| 1251 | * Check whether it is for start ibss. No need to do anything if it |
| 1252 | * is a JOIN request |
| 1253 | */ |
| 1254 | if (profile && CSR_IS_START_IBSS(profile)) { |
| 1255 | status = csr_roam_issue_connect(mac_ctx, session_id, profile, NULL, |
| 1256 | eCsrHddIssued, session->scan_info.roam_id, |
| 1257 | true, true); |
| 1258 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1259 | 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] | 1260 | session_id, status, session->scan_info.roam_id); |
| 1261 | csr_roam_call_callback(mac_ctx, session_id, NULL, |
| 1262 | session->scan_info.roam_id, eCSR_ROAM_FAILED, |
| 1263 | eCSR_ROAM_RESULT_FAILURE); |
| 1264 | } |
| 1265 | return status; |
| 1266 | } |
| 1267 | roam_result = eCSR_ROAM_RESULT_FAILURE; |
| 1268 | if (NULL != profile && csr_is_bss_type_ibss(profile->BSSType)) { |
| 1269 | roam_result = eCSR_ROAM_RESULT_IBSS_START_FAILED; |
| 1270 | goto roam_completion; |
| 1271 | } |
Vignesh Viswanathan | 014096a | 2017-12-07 01:24:44 +0530 | [diff] [blame] | 1272 | |
| 1273 | roam_info = qdf_mem_malloc(sizeof(struct csr_roam_info)); |
| 1274 | if (!roam_info) { |
| 1275 | sme_err("Failed to allocate memory for roam_info"); |
| 1276 | goto roam_completion; |
| 1277 | } |
| 1278 | |
| 1279 | if (session->scan_info.roambssentry) { |
| 1280 | scan_result = GET_BASE_ADDR(session->scan_info.roambssentry, |
| 1281 | struct tag_csrscan_result, Link); |
| 1282 | roam_info->pBssDesc = &scan_result->Result.BssDescriptor; |
| 1283 | } |
| 1284 | roam_info->statusCode = session->joinFailStatusCode.statusCode; |
| 1285 | roam_info->reasonCode = session->joinFailStatusCode.reasonCode; |
| 1286 | |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1287 | /* Only indicate assoc_completion if we indicate assoc_start. */ |
| 1288 | if (session->bRefAssocStartCnt > 0) { |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1289 | session->bRefAssocStartCnt--; |
Jeff Johnson | eddf544 | 2017-10-04 10:55:53 -0700 | [diff] [blame] | 1290 | csr_roam_call_callback(mac_ctx, session_id, roam_info, |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1291 | session->scan_info.roam_id, |
| 1292 | eCSR_ROAM_ASSOCIATION_COMPLETION, |
| 1293 | eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE); |
| 1294 | } else { |
Vignesh Viswanathan | 014096a | 2017-12-07 01:24:44 +0530 | [diff] [blame] | 1295 | if (!csr_handle_fils_scan_for_ssid_failure( |
| 1296 | profile, roam_info)) { |
| 1297 | qdf_mem_free(roam_info); |
| 1298 | roam_info = NULL; |
| 1299 | } |
| 1300 | csr_roam_call_callback(mac_ctx, session_id, roam_info, |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1301 | session->scan_info.roam_id, |
| 1302 | eCSR_ROAM_ASSOCIATION_FAILURE, |
| 1303 | eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE); |
| 1304 | } |
Vignesh Viswanathan | 014096a | 2017-12-07 01:24:44 +0530 | [diff] [blame] | 1305 | |
| 1306 | if (roam_info) |
| 1307 | qdf_mem_free(roam_info); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 1308 | roam_completion: |
| 1309 | csr_roam_completion(mac_ctx, session_id, NULL, NULL, roam_result, |
| 1310 | false); |
| 1311 | return status; |
| 1312 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1313 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1314 | QDF_STATUS csr_scan_result_purge(tpAniSirGlobal pMac, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1315 | tScanResultHandle hScanList) |
| 1316 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1317 | QDF_STATUS status = QDF_STATUS_E_INVAL; |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 1318 | struct scan_result_list *pScanList = |
| 1319 | (struct scan_result_list *) hScanList; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1320 | |
| 1321 | if (pScanList) { |
| 1322 | status = csr_ll_scan_purge_result(pMac, &pScanList->List); |
| 1323 | csr_ll_close(&pScanList->List); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1324 | qdf_mem_free(pScanList); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1325 | } |
| 1326 | return status; |
| 1327 | } |
| 1328 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1329 | /* Add the channel to the occupiedChannels array */ |
| 1330 | static void csr_scan_add_to_occupied_channels(tpAniSirGlobal pMac, |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 1331 | struct tag_csrscan_result *pResult, |
Kapil Gupta | 0a2477b | 2016-08-23 18:00:34 +0530 | [diff] [blame] | 1332 | uint8_t sessionId, |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 1333 | struct csr_channel *occupied_ch, |
Kapil Gupta | 0a2477b | 2016-08-23 18:00:34 +0530 | [diff] [blame] | 1334 | tDot11fBeaconIEs *pIes, |
| 1335 | bool is_init_list) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1336 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1337 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1338 | uint8_t ch; |
| 1339 | uint8_t num_occupied_ch = occupied_ch->numChannels; |
| 1340 | uint8_t *occupied_ch_lst = occupied_ch->channelList; |
| 1341 | |
| 1342 | ch = pResult->Result.BssDescriptor.channelId; |
Kapil Gupta | 0a2477b | 2016-08-23 18:00:34 +0530 | [diff] [blame] | 1343 | if (!csr_neighbor_roam_connected_profile_match(pMac, |
| 1344 | sessionId, pResult, pIes)) |
| 1345 | return; |
| 1346 | |
| 1347 | if (is_init_list) |
| 1348 | pMac->scan.roam_candidate_count[sessionId]++; |
| 1349 | |
| 1350 | if (csr_is_channel_present_in_list(occupied_ch_lst, |
| 1351 | num_occupied_ch, ch)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1352 | return; |
| 1353 | |
| 1354 | status = csr_add_to_channel_list_front(occupied_ch_lst, |
| 1355 | num_occupied_ch, ch); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1356 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1357 | occupied_ch->numChannels++; |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1358 | sme_debug("Added channel %d to the list (count=%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1359 | ch, occupied_ch->numChannels); |
| 1360 | if (occupied_ch->numChannels > |
| 1361 | CSR_BG_SCAN_OCCUPIED_CHANNEL_LIST_LEN) |
| 1362 | occupied_ch->numChannels = |
| 1363 | CSR_BG_SCAN_OCCUPIED_CHANNEL_LIST_LEN; |
| 1364 | } |
| 1365 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1366 | |
| 1367 | /* Put the BSS into the scan result list */ |
| 1368 | /* pIes can not be NULL */ |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 1369 | static void csr_scan_add_result(tpAniSirGlobal mac_ctx, |
| 1370 | struct tag_csrscan_result *pResult, |
| 1371 | tDot11fBeaconIEs *pIes, |
| 1372 | uint32_t sessionId) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1373 | { |
Abhishek Singh | 6f56d21 | 2017-04-12 14:31:57 +0530 | [diff] [blame] | 1374 | qdf_nbuf_t buf; |
| 1375 | uint8_t *data; |
| 1376 | struct mgmt_rx_event_params rx_param = {0}; |
| 1377 | struct wlan_frame_hdr *hdr; |
| 1378 | struct wlan_bcn_frame *fixed_frame; |
| 1379 | uint32_t buf_len; |
| 1380 | tSirBssDescription *bss_desc; |
| 1381 | enum mgmt_frame_type frm_type = MGMT_BEACON; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1382 | |
Abhishek Singh | 6f56d21 | 2017-04-12 14:31:57 +0530 | [diff] [blame] | 1383 | bss_desc = &pResult->Result.BssDescriptor; |
| 1384 | if (bss_desc->fProbeRsp) |
| 1385 | frm_type = MGMT_PROBE_RESP; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1386 | |
Abhishek Singh | 6f56d21 | 2017-04-12 14:31:57 +0530 | [diff] [blame] | 1387 | rx_param.pdev_id = 0; |
| 1388 | rx_param.channel = bss_desc->channelId; |
| 1389 | rx_param.rssi = bss_desc->rssi; |
| 1390 | rx_param.tsf_delta = bss_desc->tsf_delta; |
| 1391 | buf_len = GET_IE_LEN_IN_BSS(bss_desc->length) + |
| 1392 | + offsetof(struct wlan_bcn_frame, ie) + sizeof(*hdr); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1393 | |
Abhishek Singh | 6f56d21 | 2017-04-12 14:31:57 +0530 | [diff] [blame] | 1394 | buf = qdf_nbuf_alloc(NULL, qdf_roundup(buf_len, 4), |
| 1395 | 0, 4, false); |
| 1396 | if (!buf) { |
Srinivas Girigowda | 2c26335 | 2017-03-17 17:49:53 -0700 | [diff] [blame] | 1397 | sme_err("Failed to allocate wbuf for mgmt rx len (%u)", |
Abhishek Singh | 6f56d21 | 2017-04-12 14:31:57 +0530 | [diff] [blame] | 1398 | buf_len); |
Abhishek Singh | a92cf1e | 2017-11-02 17:04:11 +0530 | [diff] [blame] | 1399 | csr_free_scan_result_entry(mac_ctx, pResult); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1400 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1401 | } |
Abhishek Singh | 6f56d21 | 2017-04-12 14:31:57 +0530 | [diff] [blame] | 1402 | qdf_nbuf_put_tail(buf, buf_len); |
| 1403 | qdf_nbuf_set_protocol(buf, ETH_P_CONTROL); |
| 1404 | |
| 1405 | data = qdf_nbuf_data(buf); |
| 1406 | hdr = (struct wlan_frame_hdr *) data; |
| 1407 | qdf_mem_copy(hdr->i_addr3, bss_desc->bssId, QDF_MAC_ADDR_SIZE); |
| 1408 | qdf_mem_copy(hdr->i_addr2, bss_desc->bssId, QDF_MAC_ADDR_SIZE); |
| 1409 | qdf_mem_copy(hdr->i_seq, |
| 1410 | &bss_desc->seq_ctrl, sizeof(uint16_t)); |
| 1411 | |
| 1412 | data += sizeof(*hdr); |
| 1413 | fixed_frame = (struct wlan_bcn_frame *)data; |
| 1414 | qdf_mem_copy(fixed_frame->timestamp, |
| 1415 | bss_desc->timeStamp, 8); |
| 1416 | fixed_frame->beacon_interval = bss_desc->beaconInterval; |
| 1417 | fixed_frame->capability.value = bss_desc->capabilityInfo; |
| 1418 | data += offsetof(struct wlan_bcn_frame, ie); |
| 1419 | |
| 1420 | qdf_mem_copy(data, bss_desc->ieFields, |
| 1421 | GET_IE_LEN_IN_BSS(bss_desc->length)); |
| 1422 | tgt_scan_bcn_probe_rx_callback(mac_ctx->psoc, NULL, buf, &rx_param, |
| 1423 | frm_type); |
Abhishek Singh | a92cf1e | 2017-11-02 17:04:11 +0530 | [diff] [blame] | 1424 | csr_free_scan_result_entry(mac_ctx, pResult); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1425 | } |
| 1426 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1427 | /* |
| 1428 | * NOTE: This routine is being added to make |
| 1429 | * sure that scan results are not being flushed |
| 1430 | * while roaming. If the scan results are flushed, |
| 1431 | * we are unable to recover from |
| 1432 | * csr_roam_roaming_state_disassoc_rsp_processor. |
| 1433 | * If it is needed to remove this routine, |
| 1434 | * first ensure that we recover gracefully from |
| 1435 | * csr_roam_roaming_state_disassoc_rsp_processor if |
| 1436 | * csr_scan_get_result returns with a failure because |
| 1437 | * of not being able to find the roaming BSS. |
| 1438 | */ |
Jeff Johnson | 00fa67d | 2016-10-14 08:07:36 -0700 | [diff] [blame] | 1439 | static bool csr_scan_flush_denied(tpAniSirGlobal pMac) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1440 | { |
| 1441 | uint8_t sessionId; |
| 1442 | |
| 1443 | for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++) { |
| 1444 | if (CSR_IS_SESSION_VALID(pMac, sessionId)) { |
| 1445 | if (csr_neighbor_middle_of_roaming(pMac, sessionId)) |
| 1446 | return 1; |
| 1447 | } |
| 1448 | } |
| 1449 | return 0; |
| 1450 | } |
| 1451 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1452 | QDF_STATUS csr_scanning_state_msg_processor(tpAniSirGlobal pMac, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1453 | void *pMsgBuf) |
| 1454 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1455 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1456 | tSirMbMsg *pMsg = (tSirMbMsg *) pMsgBuf; |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 1457 | struct csr_roam_session *pSession; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1458 | tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf; |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 1459 | struct csr_roam_info roamInfo; |
| 1460 | struct csr_roam_info *roam_info = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1461 | uint32_t sessionId; |
| 1462 | |
| 1463 | if (eWNI_SME_SCAN_RSP == pMsg->type) |
| 1464 | return csr_scan_sme_scan_response(pMac, pMsgBuf); |
| 1465 | |
| 1466 | if (pMsg->type != eWNI_SME_UPPER_LAYER_ASSOC_CNF) { |
| 1467 | if (csr_is_any_session_in_connect_state(pMac)) { |
| 1468 | /* |
| 1469 | * In case of we are connected, we need to check whether |
| 1470 | * connect status changes because scan may also run |
| 1471 | * while connected. |
| 1472 | */ |
| 1473 | csr_roam_check_for_link_status_change(pMac, |
| 1474 | (tSirSmeRsp *) pMsgBuf); |
| 1475 | } else { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1476 | sme_warn("Message [0x%04x] received in wrong state", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1477 | pMsg->type); |
| 1478 | } |
| 1479 | return status; |
| 1480 | } |
| 1481 | |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1482 | sme_debug("Scanning: ASSOC cnf can be given to upper layer"); |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 1483 | qdf_mem_set(&roamInfo, sizeof(struct csr_roam_info), 0); |
Jeff Johnson | eddf544 | 2017-10-04 10:55:53 -0700 | [diff] [blame] | 1484 | roam_info = &roamInfo; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1485 | pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *) pMsgBuf; |
| 1486 | status = csr_roam_get_session_id_from_bssid(pMac, |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 1487 | (struct qdf_mac_addr *)pUpperLayerAssocCnf->bssId, |
| 1488 | &sessionId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1489 | pSession = CSR_GET_SESSION(pMac, sessionId); |
| 1490 | |
| 1491 | if (!pSession) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1492 | sme_err("session %d not found", sessionId); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1493 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1494 | } |
| 1495 | |
| 1496 | /* send the status code as Success */ |
Jeff Johnson | eddf544 | 2017-10-04 10:55:53 -0700 | [diff] [blame] | 1497 | roam_info->statusCode = eSIR_SME_SUCCESS; |
| 1498 | roam_info->u.pConnectedProfile = &pSession->connectedProfile; |
| 1499 | roam_info->staId = (uint8_t) pUpperLayerAssocCnf->aid; |
| 1500 | roam_info->rsnIELen = (uint8_t) pUpperLayerAssocCnf->rsnIE.length; |
| 1501 | roam_info->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata; |
| 1502 | roam_info->addIELen = (uint8_t) pUpperLayerAssocCnf->addIE.length; |
| 1503 | roam_info->paddIE = pUpperLayerAssocCnf->addIE.addIEdata; |
| 1504 | qdf_mem_copy(roam_info->peerMac.bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1505 | pUpperLayerAssocCnf->peerMacAddr, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1506 | QDF_MAC_ADDR_SIZE); |
Jeff Johnson | eddf544 | 2017-10-04 10:55:53 -0700 | [diff] [blame] | 1507 | qdf_mem_copy(&roam_info->bssid.bytes, pUpperLayerAssocCnf->bssId, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1508 | QDF_MAC_ADDR_SIZE); |
Jeff Johnson | eddf544 | 2017-10-04 10:55:53 -0700 | [diff] [blame] | 1509 | roam_info->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta; |
| 1510 | if (CSR_IS_INFRA_AP(roam_info->u.pConnectedProfile)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1511 | pMac->roam.roamSession[sessionId].connectState = |
| 1512 | eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED; |
Jeff Johnson | eddf544 | 2017-10-04 10:55:53 -0700 | [diff] [blame] | 1513 | roam_info->fReassocReq = pUpperLayerAssocCnf->reassocReq; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1514 | status = csr_roam_call_callback(pMac, sessionId, |
Jeff Johnson | eddf544 | 2017-10-04 10:55:53 -0700 | [diff] [blame] | 1515 | roam_info, 0, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1516 | eCSR_ROAM_INFRA_IND, |
| 1517 | eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF); |
| 1518 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1519 | return status; |
| 1520 | } |
| 1521 | |
Jeff Johnson | 00fa67d | 2016-10-14 08:07:36 -0700 | [diff] [blame] | 1522 | static QDF_STATUS csr_add_pmkid_candidate_list(tpAniSirGlobal pMac, |
| 1523 | uint32_t sessionId, |
| 1524 | tSirBssDescription *pBssDesc, |
| 1525 | tDot11fBeaconIEs *pIes) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1526 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1527 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 1528 | struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1529 | tPmkidCandidateInfo *pmkid_info = NULL; |
| 1530 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 1531 | WLAN_HOST_DIAG_EVENT_DEF(secEvent, |
| 1532 | host_event_wlan_security_payload_type); |
| 1533 | #endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */ |
| 1534 | if (!pSession) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1535 | sme_err("session %d not found", sessionId); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1536 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1537 | } |
| 1538 | |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1539 | sme_debug("NumPmkidCandidate: %d", pSession->NumPmkidCandidate); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1540 | if (!pIes) |
| 1541 | return status; |
| 1542 | /* check if this is a RSN BSS */ |
| 1543 | if (!pIes->RSN.present) |
| 1544 | return status; |
| 1545 | |
| 1546 | if (pSession->NumPmkidCandidate >= CSR_MAX_PMKID_ALLOWED) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1547 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1548 | |
| 1549 | /* BSS is capable of doing pre-authentication */ |
| 1550 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1551 | qdf_mem_set(&secEvent, sizeof(host_event_wlan_security_payload_type), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1552 | 0); |
| 1553 | secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_CANDIDATE_FOUND; |
| 1554 | secEvent.encryptionModeMulticast = (uint8_t)diag_enc_type_from_csr_type( |
| 1555 | pSession->connectedProfile.mcEncryptionType); |
| 1556 | secEvent.encryptionModeUnicast = (uint8_t)diag_enc_type_from_csr_type( |
| 1557 | pSession->connectedProfile.EncryptionType); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1558 | qdf_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1559 | QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1560 | secEvent.authMode = (uint8_t)diag_auth_type_from_csr_type( |
| 1561 | pSession->connectedProfile.AuthType); |
| 1562 | WLAN_HOST_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY); |
| 1563 | #endif /* #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR */ |
| 1564 | |
| 1565 | pmkid_info = &pSession->PmkidCandidateInfo[pSession->NumPmkidCandidate]; |
| 1566 | /* if yes, then add to PMKIDCandidateList */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1567 | qdf_mem_copy(pmkid_info->BSSID.bytes, pBssDesc->bssId, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1568 | QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1569 | /* Bit 0 offirst byte - PreAuthentication Capability */ |
| 1570 | if ((pIes->RSN.RSN_Cap[0] >> 0) & 0x1) |
| 1571 | pmkid_info->preAuthSupported = true; |
| 1572 | else |
| 1573 | pmkid_info->preAuthSupported = false; |
| 1574 | pSession->NumPmkidCandidate++; |
| 1575 | return status; |
| 1576 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1577 | /* |
| 1578 | * This function checks whether new AP is found for the current connected |
| 1579 | * profile. If it is found, it return the sessionId, else it return invalid |
| 1580 | * sessionID |
| 1581 | */ |
Jeff Johnson | 00fa67d | 2016-10-14 08:07:36 -0700 | [diff] [blame] | 1582 | static QDF_STATUS csr_process_bss_desc_for_pmkid_list(tpAniSirGlobal pMac, |
| 1583 | tSirBssDescription *pBssDesc, |
| 1584 | tDot11fBeaconIEs *pIes, |
| 1585 | uint8_t sessionId) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1586 | { |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 1587 | struct csr_roam_session *pSession; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1588 | tDot11fBeaconIEs *pIesLocal = pIes; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1589 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1590 | |
| 1591 | if (!(pIesLocal || |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1592 | QDF_IS_STATUS_SUCCESS( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1593 | csr_get_parsed_bss_description_ies(pMac, pBssDesc, |
| 1594 | &pIesLocal)))) |
| 1595 | return status; |
| 1596 | |
| 1597 | if (!CSR_IS_SESSION_VALID(pMac, sessionId)) { |
| 1598 | if (!pIes) |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1599 | qdf_mem_free(pIesLocal); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1600 | return status; |
| 1601 | } |
| 1602 | |
| 1603 | pSession = CSR_GET_SESSION(pMac, sessionId); |
| 1604 | if (csr_is_conn_state_connected_infra(pMac, sessionId) |
| 1605 | && (eCSR_AUTH_TYPE_RSN == pSession->connectedProfile.AuthType) |
| 1606 | && csr_match_bss_to_connect_profile(pMac, |
| 1607 | &pSession->connectedProfile, |
| 1608 | pBssDesc, pIesLocal)) { |
| 1609 | /* This new BSS fits the current profile connected */ |
| 1610 | status = csr_add_pmkid_candidate_list(pMac, sessionId, |
| 1611 | pBssDesc, pIesLocal); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1612 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1613 | sme_err("csr_add_pmkid_candidate_list failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1614 | else |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1615 | status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1616 | } |
| 1617 | |
| 1618 | if (!pIes) |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1619 | qdf_mem_free(pIesLocal); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1620 | |
| 1621 | return status; |
| 1622 | } |
| 1623 | |
| 1624 | #ifdef FEATURE_WLAN_WAPI |
Jeff Johnson | 00fa67d | 2016-10-14 08:07:36 -0700 | [diff] [blame] | 1625 | static QDF_STATUS csr_add_bkid_candidate_list(tpAniSirGlobal pMac, |
| 1626 | uint32_t sessionId, |
| 1627 | tSirBssDescription *pBssDesc, |
| 1628 | tDot11fBeaconIEs *pIes) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1629 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1630 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 1631 | struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1632 | |
| 1633 | if (!pSession) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1634 | sme_err("session %d not found", sessionId); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1635 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1636 | } |
| 1637 | |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 1638 | sme_debug("csr_add_bkid_candidate_list called pMac->scan.NumBkidCandidate: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1639 | pSession->NumBkidCandidate); |
| 1640 | if (pIes) { |
| 1641 | /* check if this is a WAPI BSS */ |
| 1642 | if (pIes->WAPI.present) { |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 1643 | /* Check if the BSS is capable of doing |
| 1644 | * pre-authentication |
| 1645 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1646 | if (pSession->NumBkidCandidate < CSR_MAX_BKID_ALLOWED) { |
| 1647 | |
| 1648 | /* if yes, then add to BKIDCandidateList */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1649 | qdf_mem_copy(pSession-> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1650 | BkidCandidateInfo[pSession-> |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 1651 | NumBkidCandidate]. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1652 | BSSID.bytes, pBssDesc->bssId, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1653 | QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1654 | if (pIes->WAPI.preauth) { |
| 1655 | pSession->BkidCandidateInfo[pSession-> |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 1656 | NumBkidCandidate]. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1657 | preAuthSupported = true; |
| 1658 | } else { |
| 1659 | pSession->BkidCandidateInfo[pSession-> |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 1660 | NumBkidCandidate]. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1661 | preAuthSupported = false; |
| 1662 | } |
| 1663 | pSession->NumBkidCandidate++; |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 1664 | } else |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1665 | status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1666 | } |
| 1667 | } |
| 1668 | |
| 1669 | return status; |
| 1670 | } |
| 1671 | |
| 1672 | /* |
| 1673 | * This function checks whether new AP is found for the current connected |
| 1674 | * profile, if so add to BKIDCandidateList |
| 1675 | */ |
Jeff Johnson | 00fa67d | 2016-10-14 08:07:36 -0700 | [diff] [blame] | 1676 | static bool csr_process_bss_desc_for_bkid_list(tpAniSirGlobal pMac, |
| 1677 | tSirBssDescription *pBssDesc, |
| 1678 | tDot11fBeaconIEs *pIes) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1679 | { |
| 1680 | bool fRC = false; |
| 1681 | tDot11fBeaconIEs *pIesLocal = pIes; |
| 1682 | uint32_t sessionId; |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 1683 | struct csr_roam_session *pSession; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1684 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1685 | |
| 1686 | if (!(pIesLocal || |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1687 | QDF_IS_STATUS_SUCCESS( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1688 | csr_get_parsed_bss_description_ies(pMac, pBssDesc, |
| 1689 | &pIesLocal)))) |
| 1690 | return fRC; |
| 1691 | |
| 1692 | for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++) { |
| 1693 | if (!CSR_IS_SESSION_VALID(pMac, sessionId)) |
| 1694 | continue; |
| 1695 | pSession = CSR_GET_SESSION(pMac, sessionId); |
| 1696 | if (csr_is_conn_state_connected_infra(pMac, sessionId) |
| 1697 | && (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == |
| 1698 | pSession->connectedProfile.AuthType) |
| 1699 | && csr_match_bss_to_connect_profile(pMac, |
| 1700 | &pSession->connectedProfile, |
| 1701 | pBssDesc, pIesLocal)) { |
| 1702 | /* this new BSS fits the current profile connected */ |
| 1703 | status = csr_add_bkid_candidate_list(pMac, sessionId, |
| 1704 | pBssDesc, pIesLocal); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1705 | if (QDF_IS_STATUS_SUCCESS(status)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1706 | fRC = true; |
| 1707 | } |
| 1708 | } |
| 1709 | if (!pIes) |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1710 | qdf_mem_free(pIesLocal); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1711 | return fRC; |
| 1712 | } |
| 1713 | |
| 1714 | #endif |
| 1715 | |
Abhishek Singh | a92cf1e | 2017-11-02 17:04:11 +0530 | [diff] [blame] | 1716 | static bool csr_scan_save_bss_description(tpAniSirGlobal |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 1717 | pMac, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1718 | tSirBssDescription * |
| 1719 | pBSSDescription, |
| 1720 | tDot11fBeaconIEs *pIes, |
| 1721 | uint8_t sessionId) |
| 1722 | { |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 1723 | struct tag_csrscan_result *pCsrBssDescription = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1724 | uint32_t cbBSSDesc; |
| 1725 | uint32_t cbAllocated; |
| 1726 | |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 1727 | /* figure out how big the BSS description is (the BSSDesc->length does |
| 1728 | * NOT include the size of the length field itself). |
| 1729 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1730 | cbBSSDesc = pBSSDescription->length + sizeof(pBSSDescription->length); |
| 1731 | |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 1732 | cbAllocated = sizeof(struct tag_csrscan_result) + cbBSSDesc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1733 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1734 | pCsrBssDescription = qdf_mem_malloc(cbAllocated); |
Abhishek Singh | a92cf1e | 2017-11-02 17:04:11 +0530 | [diff] [blame] | 1735 | if (!pCsrBssDescription) { |
| 1736 | sme_err(" Failed to allocate memory for pCsrBssDescription"); |
| 1737 | return false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1738 | } |
| 1739 | |
Abhishek Singh | a92cf1e | 2017-11-02 17:04:11 +0530 | [diff] [blame] | 1740 | pCsrBssDescription->AgingCount = |
| 1741 | (int32_t) pMac->roam.configParam.agingCount; |
| 1742 | sme_debug( |
| 1743 | "Set Aging Count = %d for BSS " MAC_ADDRESS_STR " ", |
| 1744 | pCsrBssDescription->AgingCount, |
| 1745 | MAC_ADDR_ARRAY(pCsrBssDescription->Result.BssDescriptor. |
| 1746 | bssId)); |
| 1747 | qdf_mem_copy(&pCsrBssDescription->Result.BssDescriptor, |
| 1748 | pBSSDescription, cbBSSDesc); |
| 1749 | csr_scan_add_result(pMac, pCsrBssDescription, pIes, sessionId); |
| 1750 | |
| 1751 | return true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1752 | } |
| 1753 | |
| 1754 | /* Append a Bss Description... */ |
Abhishek Singh | a92cf1e | 2017-11-02 17:04:11 +0530 | [diff] [blame] | 1755 | bool csr_scan_append_bss_description(tpAniSirGlobal pMac, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1756 | tSirBssDescription * |
| 1757 | pSirBssDescription, |
| 1758 | tDot11fBeaconIEs *pIes, |
| 1759 | bool fForced, uint8_t sessionId) |
| 1760 | { |
Abhishek Singh | a92cf1e | 2017-11-02 17:04:11 +0530 | [diff] [blame] | 1761 | return csr_scan_save_bss_description(pMac, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1762 | pSirBssDescription, pIes, sessionId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1763 | } |
| 1764 | |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 1765 | static void csr_purge_channel_power(tpAniSirGlobal pMac, tDblLinkList |
| 1766 | *pChannelList) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1767 | { |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 1768 | struct csr_channel_powerinfo *pChannelSet; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1769 | tListElem *pEntry; |
| 1770 | |
| 1771 | csr_ll_lock(pChannelList); |
| 1772 | /* |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 1773 | * Remove the channel sets from the learned list and put them |
| 1774 | * in the free list |
| 1775 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1776 | while ((pEntry = csr_ll_remove_head(pChannelList, |
| 1777 | LL_ACCESS_NOLOCK)) != NULL) { |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 1778 | pChannelSet = GET_BASE_ADDR(pEntry, |
| 1779 | struct csr_channel_powerinfo, link); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1780 | if (pChannelSet) |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1781 | qdf_mem_free(pChannelSet); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1782 | } |
| 1783 | csr_ll_unlock(pChannelList); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1784 | } |
| 1785 | |
| 1786 | /* |
| 1787 | * Save the channelList into the ultimate storage as the final stage of channel |
| 1788 | * Input: pCountryInfo -- the country code (e.g. "USI"), channel list, and power |
| 1789 | * limit are all stored inside this data structure |
| 1790 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1791 | QDF_STATUS csr_save_to_channel_power2_g_5_g(tpAniSirGlobal pMac, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1792 | uint32_t tableSize, |
| 1793 | tSirMacChanInfo *channelTable) |
| 1794 | { |
| 1795 | uint32_t i = tableSize / sizeof(tSirMacChanInfo); |
| 1796 | tSirMacChanInfo *pChannelInfo; |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 1797 | struct csr_channel_powerinfo *pChannelSet; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1798 | bool f2GHzInfoFound = false; |
| 1799 | bool f2GListPurged = false, f5GListPurged = false; |
| 1800 | |
| 1801 | pChannelInfo = channelTable; |
| 1802 | /* atleast 3 bytes have to be remaining -- from "countryString" */ |
| 1803 | while (i--) { |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 1804 | pChannelSet = qdf_mem_malloc(sizeof(struct csr_channel_powerinfo)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1805 | if (NULL == pChannelSet) { |
| 1806 | pChannelInfo++; |
| 1807 | continue; |
| 1808 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1809 | pChannelSet->firstChannel = pChannelInfo->firstChanNum; |
| 1810 | pChannelSet->numChannels = pChannelInfo->numChannels; |
| 1811 | /* |
| 1812 | * Now set the inter-channel offset based on the frequency band |
| 1813 | * the channel set lies in |
| 1814 | */ |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1815 | if ((WLAN_REG_IS_24GHZ_CH(pChannelSet->firstChannel)) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1816 | ((pChannelSet->firstChannel + |
| 1817 | (pChannelSet->numChannels - 1)) <= |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1818 | WLAN_REG_MAX_24GHZ_CH_NUM)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1819 | pChannelSet->interChannelOffset = 1; |
| 1820 | f2GHzInfoFound = true; |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1821 | } else if ((WLAN_REG_IS_5GHZ_CH(pChannelSet->firstChannel)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1822 | && ((pChannelSet->firstChannel + |
| 1823 | ((pChannelSet->numChannels - 1) * 4)) <= |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1824 | WLAN_REG_MAX_5GHZ_CH_NUM)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1825 | pChannelSet->interChannelOffset = 4; |
| 1826 | f2GHzInfoFound = false; |
| 1827 | } else { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1828 | sme_warn("Invalid Channel %d Present in Country IE", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1829 | pChannelSet->firstChannel); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1830 | qdf_mem_free(pChannelSet); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1831 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1832 | } |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1833 | pChannelSet->txPower = QDF_MIN(pChannelInfo->maxTxPower, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1834 | pMac->roam.configParam.nTxPowerCap); |
| 1835 | if (f2GHzInfoFound) { |
| 1836 | if (!f2GListPurged) { |
| 1837 | /* purge previous results if found new */ |
| 1838 | csr_purge_channel_power(pMac, |
| 1839 | &pMac->scan. |
| 1840 | channelPowerInfoList24); |
| 1841 | f2GListPurged = true; |
| 1842 | } |
| 1843 | if (CSR_IS_OPERATING_BG_BAND(pMac)) { |
| 1844 | /* add to the list of 2.4 GHz channel sets */ |
| 1845 | csr_ll_insert_tail(&pMac->scan. |
| 1846 | channelPowerInfoList24, |
| 1847 | &pChannelSet->link, |
| 1848 | LL_ACCESS_LOCK); |
| 1849 | } else { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1850 | sme_debug( |
| 1851 | "Adding 11B/G ch in 11A. 1st ch %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1852 | pChannelSet->firstChannel); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1853 | qdf_mem_free(pChannelSet); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1854 | } |
| 1855 | } else { |
| 1856 | /* 5GHz info found */ |
| 1857 | if (!f5GListPurged) { |
| 1858 | /* purge previous results if found new */ |
| 1859 | csr_purge_channel_power(pMac, |
| 1860 | &pMac->scan. |
| 1861 | channelPowerInfoList5G); |
| 1862 | f5GListPurged = true; |
| 1863 | } |
| 1864 | if (CSR_IS_OPERATING_A_BAND(pMac)) { |
| 1865 | /* add to the list of 5GHz channel sets */ |
| 1866 | csr_ll_insert_tail(&pMac->scan. |
| 1867 | channelPowerInfoList5G, |
| 1868 | &pChannelSet->link, |
| 1869 | LL_ACCESS_LOCK); |
| 1870 | } else { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1871 | sme_debug( |
| 1872 | "Adding 11A ch in B/G. 1st ch %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1873 | pChannelSet->firstChannel); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1874 | qdf_mem_free(pChannelSet); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1875 | } |
| 1876 | } |
| 1877 | pChannelInfo++; /* move to next entry */ |
| 1878 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1879 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1880 | } |
| 1881 | |
| 1882 | static void csr_clear_dfs_channel_list(tpAniSirGlobal pMac) |
| 1883 | { |
| 1884 | tSirMbMsg *pMsg; |
| 1885 | uint16_t msgLen; |
| 1886 | |
| 1887 | msgLen = (uint16_t) (sizeof(tSirMbMsg)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1888 | pMsg = qdf_mem_malloc(msgLen); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1889 | if (NULL != pMsg) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1890 | pMsg->type = eWNI_SME_CLEAR_DFS_CHANNEL_LIST; |
| 1891 | pMsg->msgLen = msgLen; |
Rajeev Kumar | d138ac5 | 2017-01-30 18:38:37 -0800 | [diff] [blame] | 1892 | umac_send_mb_message_to_mac(pMsg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1893 | } |
| 1894 | } |
| 1895 | |
| 1896 | void csr_apply_power2_current(tpAniSirGlobal pMac) |
| 1897 | { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1898 | sme_debug("Updating Cfg with power settings"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1899 | csr_save_tx_power_to_cfg(pMac, &pMac->scan.channelPowerInfoList24, |
| 1900 | WNI_CFG_MAX_TX_POWER_2_4); |
| 1901 | csr_save_tx_power_to_cfg(pMac, &pMac->scan.channelPowerInfoList5G, |
| 1902 | WNI_CFG_MAX_TX_POWER_5); |
| 1903 | } |
| 1904 | |
| 1905 | void csr_apply_channel_power_info_to_fw(tpAniSirGlobal mac_ctx, |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 1906 | struct csr_channel *ch_lst, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1907 | uint8_t *countryCode) |
| 1908 | { |
| 1909 | int i; |
| 1910 | uint8_t num_ch = 0; |
| 1911 | uint8_t tempNumChannels = 0; |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 1912 | struct csr_channel tmp_ch_lst; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1913 | |
| 1914 | if (ch_lst->numChannels) { |
| 1915 | tempNumChannels = CSR_MIN(ch_lst->numChannels, |
| 1916 | WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 1917 | for (i = 0; i < tempNumChannels; i++) { |
| 1918 | tmp_ch_lst.channelList[num_ch] = ch_lst->channelList[i]; |
| 1919 | num_ch++; |
| 1920 | } |
| 1921 | tmp_ch_lst.numChannels = num_ch; |
| 1922 | /* Store the channel+power info in the global place: Cfg */ |
| 1923 | csr_apply_power2_current(mac_ctx); |
| 1924 | csr_set_cfg_valid_channel_list(mac_ctx, tmp_ch_lst.channelList, |
| 1925 | tmp_ch_lst.numChannels); |
| 1926 | /* |
| 1927 | * extend scan capability, build a scan list based on the |
| 1928 | * channel list : channel# + active/passive scan |
| 1929 | */ |
| 1930 | csr_set_cfg_scan_control_list(mac_ctx, countryCode, |
| 1931 | &tmp_ch_lst); |
| 1932 | /* Send msg to Lim to clear DFS channel list */ |
| 1933 | csr_clear_dfs_channel_list(mac_ctx); |
| 1934 | } else { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 1935 | sme_err("11D channel list is empty"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1936 | } |
| 1937 | csr_set_cfg_country_code(mac_ctx, countryCode); |
| 1938 | } |
| 1939 | |
| 1940 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 1941 | static void csr_diag_reset_country_information(tpAniSirGlobal pMac) |
| 1942 | { |
| 1943 | |
| 1944 | host_log_802_11d_pkt_type *p11dLog; |
| 1945 | int Index; |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 1946 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1947 | WLAN_HOST_DIAG_LOG_ALLOC(p11dLog, host_log_802_11d_pkt_type, |
| 1948 | LOG_WLAN_80211D_C); |
| 1949 | if (!p11dLog) |
| 1950 | return; |
| 1951 | |
| 1952 | p11dLog->eventId = WLAN_80211D_EVENT_RESET; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1953 | qdf_mem_copy(p11dLog->countryCode, pMac->scan.countryCodeCurrent, 3); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1954 | p11dLog->numChannel = pMac->scan.base_channels.numChannels; |
| 1955 | if (p11dLog->numChannel <= HOST_LOG_MAX_NUM_CHANNEL) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1956 | qdf_mem_copy(p11dLog->Channels, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1957 | pMac->scan.base_channels.channelList, |
| 1958 | p11dLog->numChannel); |
| 1959 | for (Index = 0; |
| 1960 | Index < pMac->scan.base_channels.numChannels; |
| 1961 | Index++) { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1962 | p11dLog->TxPwr[Index] = QDF_MIN( |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 1963 | pMac->scan.defaultPowerTable[Index].tx_power, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1964 | pMac->roam.configParam.nTxPowerCap); |
| 1965 | } |
| 1966 | } |
| 1967 | if (!pMac->roam.configParam.Is11dSupportEnabled) |
| 1968 | p11dLog->supportMultipleDomain = WLAN_80211D_DISABLED; |
| 1969 | else |
| 1970 | p11dLog->supportMultipleDomain = |
| 1971 | WLAN_80211D_SUPPORT_MULTI_DOMAIN; |
| 1972 | WLAN_HOST_DIAG_LOG_REPORT(p11dLog); |
| 1973 | } |
| 1974 | #endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */ |
| 1975 | |
| 1976 | /** |
| 1977 | * csr_apply_channel_power_info_wrapper() - sends channel info to fw |
| 1978 | * @pMac: main MAC data structure |
| 1979 | * |
| 1980 | * This function sends the channel power info to firmware |
| 1981 | * |
| 1982 | * Return: none |
| 1983 | */ |
| 1984 | void csr_apply_channel_power_info_wrapper(tpAniSirGlobal pMac) |
| 1985 | { |
| 1986 | |
| 1987 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 1988 | csr_diag_reset_country_information(pMac); |
| 1989 | #endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */ |
| 1990 | csr_prune_channel_list_for_mode(pMac, &pMac->scan.base_channels); |
| 1991 | csr_save_channel_power_for_band(pMac, false); |
| 1992 | csr_save_channel_power_for_band(pMac, true); |
| 1993 | /* apply the channel list, power settings, and the country code. */ |
| 1994 | csr_apply_channel_power_info_to_fw(pMac, |
| 1995 | &pMac->scan.base_channels, pMac->scan.countryCodeCurrent); |
| 1996 | /* clear the 11d channel list */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1997 | qdf_mem_set(&pMac->scan.channels11d, sizeof(pMac->scan.channels11d), 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1998 | } |
| 1999 | |
| 2000 | void csr_clear_votes_for_country_info(tpAniSirGlobal pMac) |
| 2001 | { |
| 2002 | pMac->scan.countryCodeCount = 0; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2003 | qdf_mem_set(pMac->scan.votes11d, |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 2004 | sizeof(struct csr_votes11d) * CSR_MAX_NUM_COUNTRY_CODE, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2005 | } |
| 2006 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2007 | /** |
| 2008 | * csr_set_country_code() - Set country code |
| 2009 | * @pMac: main MAC data structure |
| 2010 | * @pCountry: ptr to Country Code |
| 2011 | * |
| 2012 | * This function sends the channel power info to firmware |
| 2013 | * |
| 2014 | * Return: none |
| 2015 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2016 | QDF_STATUS csr_set_country_code(tpAniSirGlobal pMac, uint8_t *pCountry) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2017 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2018 | QDF_STATUS status = QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2019 | v_REGDOMAIN_t domainId; |
| 2020 | |
| 2021 | if (pCountry) { |
| 2022 | |
| 2023 | status = csr_get_regulatory_domain_for_country(pMac, pCountry, |
Amar Singhal | a297bfa | 2015-10-15 15:07:29 -0700 | [diff] [blame] | 2024 | &domainId, |
| 2025 | SOURCE_USERSPACE); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2026 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2027 | qdf_mem_copy(pMac->scan.countryCodeCurrent, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2028 | pCountry, |
| 2029 | WNI_CFG_COUNTRY_CODE_LEN); |
| 2030 | csr_set_cfg_country_code(pMac, pCountry); |
| 2031 | } |
| 2032 | } |
| 2033 | return status; |
| 2034 | } |
| 2035 | |
| 2036 | /* caller allocated memory for pNumChn and pChnPowerInfo */ |
| 2037 | /* As input, *pNumChn has the size of the array of pChnPowerInfo */ |
| 2038 | /* Upon return, *pNumChn has the number of channels assigned. */ |
Jeff Johnson | 00fa67d | 2016-10-14 08:07:36 -0700 | [diff] [blame] | 2039 | static void csr_get_channel_power_info(tpAniSirGlobal pMac, tDblLinkList *list, |
| 2040 | uint32_t *num_ch, |
| 2041 | struct channel_power *chn_pwr_info) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2042 | { |
| 2043 | tListElem *entry; |
| 2044 | uint32_t chn_idx = 0, idx; |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 2045 | struct csr_channel_powerinfo *ch_set; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2046 | |
| 2047 | /* Get 2.4Ghz first */ |
| 2048 | entry = csr_ll_peek_head(list, LL_ACCESS_LOCK); |
| 2049 | while (entry && (chn_idx < *num_ch)) { |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 2050 | ch_set = GET_BASE_ADDR(entry, |
| 2051 | struct csr_channel_powerinfo, link); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2052 | for (idx = 0; (idx < ch_set->numChannels) |
| 2053 | && (chn_idx < *num_ch); idx++) { |
Amar Singhal | a297bfa | 2015-10-15 15:07:29 -0700 | [diff] [blame] | 2054 | chn_pwr_info[chn_idx].chan_num = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2055 | (uint8_t) (ch_set->firstChannel |
| 2056 | + (idx * ch_set->interChannelOffset)); |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 2057 | chn_pwr_info[chn_idx++].tx_power = ch_set->txPower; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2058 | } |
| 2059 | entry = csr_ll_next(list, entry, LL_ACCESS_LOCK); |
| 2060 | } |
| 2061 | *num_ch = chn_idx; |
| 2062 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2063 | } |
| 2064 | |
| 2065 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
Jeff Johnson | 00fa67d | 2016-10-14 08:07:36 -0700 | [diff] [blame] | 2066 | static void csr_diag_apply_country_info(tpAniSirGlobal mac_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2067 | { |
| 2068 | host_log_802_11d_pkt_type *p11dLog; |
Amar Singhal | a297bfa | 2015-10-15 15:07:29 -0700 | [diff] [blame] | 2069 | struct channel_power chnPwrInfo[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2070 | uint32_t nChnInfo = WNI_CFG_VALID_CHANNEL_LIST_LEN, nTmp; |
| 2071 | |
| 2072 | WLAN_HOST_DIAG_LOG_ALLOC(p11dLog, host_log_802_11d_pkt_type, |
| 2073 | LOG_WLAN_80211D_C); |
| 2074 | if (!p11dLog) |
| 2075 | return; |
| 2076 | |
| 2077 | p11dLog->eventId = WLAN_80211D_EVENT_COUNTRY_SET; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2078 | qdf_mem_copy(p11dLog->countryCode, mac_ctx->scan.countryCode11d, 3); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2079 | p11dLog->numChannel = mac_ctx->scan.channels11d.numChannels; |
| 2080 | if (p11dLog->numChannel > HOST_LOG_MAX_NUM_CHANNEL) |
| 2081 | goto diag_end; |
| 2082 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2083 | qdf_mem_copy(p11dLog->Channels, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2084 | mac_ctx->scan.channels11d.channelList, |
| 2085 | p11dLog->numChannel); |
| 2086 | csr_get_channel_power_info(mac_ctx, |
| 2087 | &mac_ctx->scan.channelPowerInfoList24, |
| 2088 | &nChnInfo, chnPwrInfo); |
| 2089 | nTmp = nChnInfo; |
| 2090 | nChnInfo = WNI_CFG_VALID_CHANNEL_LIST_LEN - nTmp; |
| 2091 | csr_get_channel_power_info(mac_ctx, |
| 2092 | &mac_ctx->scan.channelPowerInfoList5G, |
| 2093 | &nChnInfo, &chnPwrInfo[nTmp]); |
| 2094 | for (nTmp = 0; nTmp < p11dLog->numChannel; nTmp++) { |
| 2095 | for (nChnInfo = 0; |
| 2096 | nChnInfo < WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 2097 | nChnInfo++) { |
| 2098 | if (p11dLog->Channels[nTmp] == |
Amar Singhal | a297bfa | 2015-10-15 15:07:29 -0700 | [diff] [blame] | 2099 | chnPwrInfo[nChnInfo].chan_num) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2100 | p11dLog->TxPwr[nTmp] = |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 2101 | chnPwrInfo[nChnInfo].tx_power; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2102 | break; |
| 2103 | } |
| 2104 | } |
| 2105 | } |
| 2106 | diag_end: |
| 2107 | if (!mac_ctx->roam.configParam.Is11dSupportEnabled) |
| 2108 | p11dLog->supportMultipleDomain = WLAN_80211D_DISABLED; |
| 2109 | else |
| 2110 | p11dLog->supportMultipleDomain = |
| 2111 | WLAN_80211D_SUPPORT_MULTI_DOMAIN; |
| 2112 | WLAN_HOST_DIAG_LOG_REPORT(p11dLog); |
| 2113 | } |
| 2114 | #endif /* #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR */ |
| 2115 | |
| 2116 | /** |
| 2117 | * csr_apply_country_information() - apply country code information |
| 2118 | * @pMac: core MAC data structure |
| 2119 | * |
| 2120 | * This function programs the new country code |
| 2121 | * |
| 2122 | * Return: none |
| 2123 | */ |
| 2124 | void csr_apply_country_information(tpAniSirGlobal pMac) |
| 2125 | { |
| 2126 | v_REGDOMAIN_t domainId; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2127 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2128 | |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 2129 | if (!wlan_reg_11d_enabled_on_host(pMac->psoc) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2130 | || 0 == pMac->scan.channelOf11dInfo) |
| 2131 | return; |
| 2132 | status = csr_get_regulatory_domain_for_country(pMac, |
Amar Singhal | a297bfa | 2015-10-15 15:07:29 -0700 | [diff] [blame] | 2133 | pMac->scan.countryCode11d, &domainId, SOURCE_QUERY); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2134 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2135 | return; |
| 2136 | /* Check whether we need to enforce default domain */ |
| 2137 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 2138 | csr_diag_apply_country_info(pMac); |
| 2139 | #endif /* #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR */ |
| 2140 | |
| 2141 | if (pMac->scan.domainIdCurrent != domainId) |
| 2142 | return; |
| 2143 | if (pMac->scan.domainIdCurrent != domainId) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 2144 | sme_debug("Domain Changed Old %d, new %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2145 | pMac->scan.domainIdCurrent, domainId); |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 2146 | if (domainId >= REGDOMAIN_COUNT) |
| 2147 | sme_err("fail to set regId %d", domainId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2148 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2149 | pMac->scan.domainIdCurrent = domainId; |
| 2150 | /* switch to active scans using this new channel list */ |
| 2151 | pMac->scan.curScanType = eSIR_ACTIVE_SCAN; |
| 2152 | } |
| 2153 | |
| 2154 | void csr_save_channel_power_for_band(tpAniSirGlobal pMac, bool fill_5f) |
| 2155 | { |
| 2156 | uint32_t idx, count = 0; |
| 2157 | tSirMacChanInfo *chan_info; |
| 2158 | tSirMacChanInfo *ch_info_start; |
| 2159 | int32_t max_ch_idx; |
| 2160 | bool tmp_bool; |
| 2161 | uint8_t ch = 0; |
| 2162 | |
| 2163 | max_ch_idx = |
| 2164 | (pMac->scan.base_channels.numChannels < |
| 2165 | WNI_CFG_VALID_CHANNEL_LIST_LEN) ? |
| 2166 | pMac->scan.base_channels.numChannels : |
| 2167 | WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 2168 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2169 | chan_info = qdf_mem_malloc(sizeof(tSirMacChanInfo) * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2170 | WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 2171 | if (NULL == chan_info) |
| 2172 | return; |
| 2173 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2174 | ch_info_start = chan_info; |
| 2175 | for (idx = 0; idx < max_ch_idx; idx++) { |
Amar Singhal | a297bfa | 2015-10-15 15:07:29 -0700 | [diff] [blame] | 2176 | ch = pMac->scan.defaultPowerTable[idx].chan_num; |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 2177 | tmp_bool = (fill_5f && WLAN_REG_IS_5GHZ_CH(ch)) || |
| 2178 | (!fill_5f && WLAN_REG_IS_24GHZ_CH(ch)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2179 | if (!tmp_bool) |
| 2180 | continue; |
| 2181 | |
| 2182 | if (count >= WNI_CFG_VALID_CHANNEL_LIST_LEN) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 2183 | sme_warn("count: %d exceeded", count); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2184 | break; |
| 2185 | } |
| 2186 | |
| 2187 | chan_info->firstChanNum = |
Amar Singhal | a297bfa | 2015-10-15 15:07:29 -0700 | [diff] [blame] | 2188 | pMac->scan.defaultPowerTable[idx].chan_num; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2189 | chan_info->numChannels = 1; |
| 2190 | chan_info->maxTxPower = |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 2191 | QDF_MIN(pMac->scan.defaultPowerTable[idx].tx_power, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2192 | pMac->roam.configParam.nTxPowerCap); |
| 2193 | chan_info++; |
| 2194 | count++; |
| 2195 | } |
| 2196 | if (count) { |
| 2197 | csr_save_to_channel_power2_g_5_g(pMac, |
| 2198 | count * sizeof(tSirMacChanInfo), ch_info_start); |
| 2199 | } |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2200 | qdf_mem_free(ch_info_start); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2201 | } |
| 2202 | |
| 2203 | bool csr_is_supported_channel(tpAniSirGlobal pMac, uint8_t channelId) |
| 2204 | { |
| 2205 | bool fRet = false; |
| 2206 | uint32_t i; |
| 2207 | |
| 2208 | for (i = 0; i < pMac->scan.base_channels.numChannels; i++) { |
| 2209 | if (channelId == |
| 2210 | pMac->scan.base_channels.channelList[i]) { |
| 2211 | fRet = true; |
| 2212 | break; |
| 2213 | } |
| 2214 | } |
| 2215 | |
| 2216 | return fRet; |
| 2217 | } |
| 2218 | |
| 2219 | /* |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 2220 | * 802.11D only: Gather 11d IE via beacon or Probe response and store them in |
| 2221 | * pAdapter->channels11d |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2222 | */ |
| 2223 | bool csr_learn_11dcountry_information(tpAniSirGlobal pMac, |
| 2224 | tSirBssDescription *pSirBssDesc, |
| 2225 | tDot11fBeaconIEs *pIes, bool fForce) |
| 2226 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2227 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2228 | uint8_t *pCountryCodeSelected; |
| 2229 | bool fRet = false; |
| 2230 | v_REGDOMAIN_t domainId; |
| 2231 | tDot11fBeaconIEs *pIesLocal = pIes; |
| 2232 | bool useVoting = false; |
| 2233 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2234 | if ((NULL == pSirBssDesc) && (NULL == pIes)) |
| 2235 | useVoting = true; |
| 2236 | |
| 2237 | /* check if .11d support is enabled */ |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 2238 | if (!wlan_reg_11d_enabled_on_host(pMac->psoc)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2239 | goto free_ie; |
| 2240 | |
| 2241 | if (false == useVoting) { |
| 2242 | if (!pIesLocal && |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2243 | (!QDF_IS_STATUS_SUCCESS( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2244 | csr_get_parsed_bss_description_ies( |
| 2245 | pMac, pSirBssDesc, &pIesLocal)))) |
| 2246 | goto free_ie; |
| 2247 | /* check if country information element is present */ |
| 2248 | if (!pIesLocal->Country.present) |
| 2249 | /* No country info */ |
| 2250 | goto free_ie; |
| 2251 | status = csr_get_regulatory_domain_for_country(pMac, |
| 2252 | pIesLocal->Country.country, &domainId, |
Amar Singhal | a297bfa | 2015-10-15 15:07:29 -0700 | [diff] [blame] | 2253 | SOURCE_QUERY); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2254 | if (QDF_IS_STATUS_SUCCESS(status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2255 | && (domainId == REGDOMAIN_WORLD)) |
| 2256 | goto free_ie; |
| 2257 | } /* useVoting == false */ |
| 2258 | |
| 2259 | if (false == useVoting) |
| 2260 | pCountryCodeSelected = pIesLocal->Country.country; |
| 2261 | else |
| 2262 | pCountryCodeSelected = pMac->scan.countryCodeElected; |
| 2263 | |
Amar Singhal | b6d0dc4 | 2016-10-19 09:45:05 -0700 | [diff] [blame] | 2264 | if (qdf_mem_cmp(pCountryCodeSelected, pMac->scan.countryCodeCurrent, |
| 2265 | CDS_COUNTRY_CODE_LEN) == 0) { |
| 2266 | qdf_mem_copy(pMac->scan.countryCode11d, |
| 2267 | pMac->scan.countryCodeCurrent, |
| 2268 | CDS_COUNTRY_CODE_LEN); |
Amar Singhal | 9d5b1fe | 2016-10-16 20:16:05 -0700 | [diff] [blame] | 2269 | goto free_ie; |
Amar Singhal | b6d0dc4 | 2016-10-19 09:45:05 -0700 | [diff] [blame] | 2270 | } |
Amar Singhal | 9d5b1fe | 2016-10-16 20:16:05 -0700 | [diff] [blame] | 2271 | |
Amar Singhal | 6edf973 | 2016-11-20 21:43:40 -0800 | [diff] [blame] | 2272 | pMac->reg_hint_src = SOURCE_11D; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2273 | status = csr_get_regulatory_domain_for_country(pMac, |
Amar Singhal | a297bfa | 2015-10-15 15:07:29 -0700 | [diff] [blame] | 2274 | pCountryCodeSelected, &domainId, SOURCE_11D); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2275 | if (status != QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 2276 | sme_err("fail to get regId %d", domainId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2277 | fRet = false; |
| 2278 | goto free_ie; |
| 2279 | } |
| 2280 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2281 | fRet = true; |
| 2282 | free_ie: |
| 2283 | if (!pIes && pIesLocal) { |
| 2284 | /* locally allocated */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2285 | qdf_mem_free(pIesLocal); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2286 | } |
| 2287 | return fRet; |
| 2288 | } |
| 2289 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2290 | void csr_reinit_scan_cmd(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
| 2291 | { |
| 2292 | switch (pCommand->u.scanCmd.reason) { |
| 2293 | case eCsrScanAbortNormalScan: |
| 2294 | default: |
| 2295 | csr_scan_free_request(pMac, &pCommand->u.scanCmd.u.scanRequest); |
| 2296 | break; |
| 2297 | } |
| 2298 | if (pCommand->u.scanCmd.pToRoamProfile) { |
| 2299 | csr_release_profile(pMac, pCommand->u.scanCmd.pToRoamProfile); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2300 | qdf_mem_free(pCommand->u.scanCmd.pToRoamProfile); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2301 | } |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 2302 | qdf_mem_set(&pCommand->u.scanCmd, sizeof(struct scan_cmd), 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2303 | } |
| 2304 | |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2305 | #ifdef NAPIER_SCAN |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 2306 | static enum csr_scancomplete_nextcommand csr_scan_get_next_command_state( |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2307 | tpAniSirGlobal mac_ctx, |
| 2308 | uint32_t session_id, |
| 2309 | eCsrScanStatus scan_status, |
| 2310 | uint8_t *chan) |
| 2311 | { |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 2312 | enum csr_scancomplete_nextcommand NextCommand = eCsrNextScanNothing; |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2313 | int8_t channel; |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 2314 | struct csr_roam_session *session; |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2315 | |
Krunal Soni | 35a9453 | 2018-01-09 10:54:31 -0800 | [diff] [blame] | 2316 | if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) { |
| 2317 | sme_err("session %d is invalid", session_id); |
| 2318 | return NextCommand; |
| 2319 | } |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2320 | session = CSR_GET_SESSION(mac_ctx, session_id); |
| 2321 | switch (session->scan_info.scan_reason) { |
| 2322 | case eCsrScanForSsid: |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 2323 | sme_debug("Resp for Scan For Ssid"); |
Tushnim Bhattacharyya | 0c4ad2d | 2017-03-09 15:59:03 -0800 | [diff] [blame] | 2324 | channel = policy_mgr_search_and_check_for_session_conc( |
| 2325 | mac_ctx->psoc, |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2326 | session_id, |
| 2327 | session->scan_info.profile); |
| 2328 | if ((!channel) || scan_status) { |
| 2329 | NextCommand = eCsrNexteScanForSsidFailure; |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 2330 | sme_err("next Scan For Ssid Failure %d %d", |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2331 | channel, scan_status); |
| 2332 | } else { |
| 2333 | NextCommand = eCsrNextCheckAllowConc; |
| 2334 | *chan = channel; |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 2335 | sme_debug("next CheckAllowConc"); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2336 | } |
| 2337 | break; |
| 2338 | default: |
| 2339 | NextCommand = eCsrNextScanNothing; |
| 2340 | break; |
| 2341 | } |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 2342 | sme_debug("Next Command %d", NextCommand); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2343 | return NextCommand; |
| 2344 | } |
| 2345 | #else |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 2346 | static enum csr_scancomplete_nextcommand csr_scan_get_next_command_state( |
Jeff Johnson | 00fa67d | 2016-10-14 08:07:36 -0700 | [diff] [blame] | 2347 | tpAniSirGlobal pMac, |
| 2348 | tSmeCmd *pCommand, |
| 2349 | bool fSuccess, |
| 2350 | uint8_t *chan) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2351 | { |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 2352 | enum csr_scancomplete_nextcommand NextCommand = eCsrNextScanNothing; |
Chandrasekaran, Manishekar | ef70c0d | 2015-10-20 19:54:55 +0530 | [diff] [blame] | 2353 | int8_t channel; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2354 | |
| 2355 | switch (pCommand->u.scanCmd.reason) { |
| 2356 | case eCsrScan11d1: |
| 2357 | NextCommand = |
| 2358 | (fSuccess) ? eCsrNext11dScan1Success : |
| 2359 | eCsrNext11dScan1Failure; |
| 2360 | break; |
| 2361 | case eCsrScan11d2: |
| 2362 | NextCommand = |
| 2363 | (fSuccess) ? eCsrNext11dScan2Success : |
| 2364 | eCsrNext11dScan2Failure; |
| 2365 | break; |
| 2366 | case eCsrScan11dDone: |
| 2367 | NextCommand = eCsrNext11dScanComplete; |
| 2368 | break; |
| 2369 | case eCsrScanLostLink1: |
| 2370 | NextCommand = |
| 2371 | (fSuccess) ? eCsrNextLostLinkScan1Success : |
| 2372 | eCsrNextLostLinkScan1Failed; |
| 2373 | break; |
| 2374 | case eCsrScanLostLink2: |
| 2375 | NextCommand = |
| 2376 | (fSuccess) ? eCsrNextLostLinkScan2Success : |
| 2377 | eCsrNextLostLinkScan2Failed; |
| 2378 | break; |
| 2379 | case eCsrScanLostLink3: |
| 2380 | NextCommand = |
| 2381 | (fSuccess) ? eCsrNextLostLinkScan3Success : |
| 2382 | eCsrNextLostLinkScan3Failed; |
| 2383 | break; |
| 2384 | case eCsrScanForSsid: |
Krunal Soni | 3091bcc | 2016-06-23 12:28:21 -0700 | [diff] [blame] | 2385 | /* success: |
Chandrasekaran, Manishekar | ef70c0d | 2015-10-20 19:54:55 +0530 | [diff] [blame] | 2386 | * set hw_mode success -> csr_scan_handle_search_for_ssid |
| 2387 | * set hw_mode fail -> csr_scan_handle_search_for_ssid_failure |
| 2388 | * failure: csr_scan_handle_search_for_ssid_failure |
| 2389 | */ |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 2390 | sme_debug("Resp for eCsrScanForSsid"); |
Tushnim Bhattacharyya | 0c4ad2d | 2017-03-09 15:59:03 -0800 | [diff] [blame] | 2391 | channel = policy_mgr_search_and_check_for_session_conc( |
| 2392 | pMac->psoc, |
Krunal Soni | 3091bcc | 2016-06-23 12:28:21 -0700 | [diff] [blame] | 2393 | pCommand->sessionId, |
| 2394 | pCommand->u.scanCmd.pToRoamProfile); |
| 2395 | if ((!channel) || !fSuccess) { |
| 2396 | NextCommand = eCsrNexteScanForSsidFailure; |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 2397 | sme_debug("next ScanForSsidFailure %d %d", |
Krunal Soni | 3091bcc | 2016-06-23 12:28:21 -0700 | [diff] [blame] | 2398 | channel, fSuccess); |
| 2399 | } else { |
| 2400 | NextCommand = eCsrNextCheckAllowConc; |
| 2401 | *chan = channel; |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 2402 | sme_debug("next CheckAllowConc"); |
Chandrasekaran, Manishekar | ef70c0d | 2015-10-20 19:54:55 +0530 | [diff] [blame] | 2403 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2404 | break; |
| 2405 | default: |
| 2406 | NextCommand = eCsrNextScanNothing; |
| 2407 | break; |
| 2408 | } |
| 2409 | return NextCommand; |
| 2410 | } |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2411 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2412 | |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2413 | #ifndef NAPIER_SCAN |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2414 | /* Return whether the pCommand is finished. */ |
Jeff Johnson | 00fa67d | 2016-10-14 08:07:36 -0700 | [diff] [blame] | 2415 | static bool csr_handle_scan11d1_failure(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2416 | { |
| 2417 | bool fRet = true; |
| 2418 | |
| 2419 | /* Apply back the default setting and passively scan one more time. */ |
| 2420 | csr_apply_channel_power_info_wrapper(pMac); |
| 2421 | pCommand->u.scanCmd.reason = eCsrScan11d2; |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 2422 | if (QDF_IS_STATUS_SUCCESS(csr_scan_channels(pMac, pCommand))) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2423 | fRet = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2424 | |
| 2425 | return fRet; |
| 2426 | } |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2427 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2428 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 2429 | static void |
Abhishek Singh | 6f56d21 | 2017-04-12 14:31:57 +0530 | [diff] [blame] | 2430 | csr_diag_scan_complete(tpAniSirGlobal mac_ctx, |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2431 | eCsrScanStatus scan_status) |
| 2432 | { |
| 2433 | host_log_scan_pkt_type *pScanLog = NULL; |
Abhishek Singh | 6f56d21 | 2017-04-12 14:31:57 +0530 | [diff] [blame] | 2434 | qdf_list_t *list = NULL; |
| 2435 | struct wlan_objmgr_pdev *pdev = NULL; |
| 2436 | struct scan_cache_node *cur_node = NULL; |
| 2437 | struct scan_cache_node *next_node = NULL; |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2438 | int n = 0, c = 0; |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2439 | |
| 2440 | WLAN_HOST_DIAG_LOG_ALLOC(pScanLog, |
| 2441 | host_log_scan_pkt_type, |
| 2442 | LOG_WLAN_SCAN_C); |
| 2443 | if (!pScanLog) |
| 2444 | return; |
| 2445 | |
| 2446 | pScanLog->eventId = WLAN_SCAN_EVENT_ACTIVE_SCAN_RSP; |
| 2447 | |
| 2448 | if (eCSR_SCAN_SUCCESS != scan_status) { |
| 2449 | pScanLog->status = WLAN_SCAN_STATUS_FAILURE; |
| 2450 | WLAN_HOST_DIAG_LOG_REPORT(pScanLog); |
| 2451 | return; |
| 2452 | } |
Abhishek Singh | 6f56d21 | 2017-04-12 14:31:57 +0530 | [diff] [blame] | 2453 | pdev = wlan_objmgr_get_pdev_by_id(mac_ctx->psoc, |
| 2454 | 0, WLAN_LEGACY_MAC_ID); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2455 | |
Abhishek Singh | 6f56d21 | 2017-04-12 14:31:57 +0530 | [diff] [blame] | 2456 | if (!pdev) { |
| 2457 | sme_err("pdev is NULL"); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2458 | return; |
| 2459 | } |
| 2460 | |
Abhishek Singh | 6f56d21 | 2017-04-12 14:31:57 +0530 | [diff] [blame] | 2461 | list = ucfg_scan_get_result(pdev, NULL); |
Krunal Soni | 35a9453 | 2018-01-09 10:54:31 -0800 | [diff] [blame] | 2462 | if (list) |
| 2463 | sme_debug("num_entries %d", qdf_list_size(list)); |
| 2464 | if (!list || (list && !qdf_list_size(list))) { |
Abhishek Singh | 6f56d21 | 2017-04-12 14:31:57 +0530 | [diff] [blame] | 2465 | sme_err("get scan result failed"); |
| 2466 | WLAN_HOST_DIAG_LOG_REPORT(pScanLog); |
| 2467 | wlan_objmgr_pdev_release_ref(pdev, WLAN_LEGACY_MAC_ID); |
Sandeep Puligilla | 2e233c6 | 2017-11-07 12:45:57 -0800 | [diff] [blame] | 2468 | if (list) |
| 2469 | ucfg_scan_purge_results(list); |
Abhishek Singh | 6f56d21 | 2017-04-12 14:31:57 +0530 | [diff] [blame] | 2470 | return; |
| 2471 | } |
| 2472 | |
| 2473 | qdf_list_peek_front(list, |
| 2474 | (qdf_list_node_t **) &cur_node); |
| 2475 | while (cur_node) { |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2476 | if (n < HOST_LOG_MAX_NUM_BSSID) { |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2477 | qdf_mem_copy(pScanLog->bssid[n], |
Abhishek Singh | 6f56d21 | 2017-04-12 14:31:57 +0530 | [diff] [blame] | 2478 | cur_node->entry->bssid.bytes, |
| 2479 | QDF_MAC_ADDR_SIZE); |
| 2480 | if (cur_node->entry->ssid.length > |
| 2481 | WLAN_SSID_MAX_LEN) |
| 2482 | cur_node->entry->ssid.length = |
| 2483 | WLAN_SSID_MAX_LEN; |
| 2484 | qdf_mem_copy(pScanLog->ssid[n], |
| 2485 | cur_node->entry->ssid.ssid, |
| 2486 | cur_node->entry->ssid.length); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2487 | n++; |
| 2488 | } |
| 2489 | c++; |
Abhishek Singh | 6f56d21 | 2017-04-12 14:31:57 +0530 | [diff] [blame] | 2490 | qdf_list_peek_next( |
| 2491 | list, |
| 2492 | (qdf_list_node_t *) cur_node, |
| 2493 | (qdf_list_node_t **) &next_node); |
| 2494 | cur_node = next_node; |
| 2495 | next_node = NULL; |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2496 | } |
| 2497 | pScanLog->numSsid = (uint8_t) n; |
| 2498 | pScanLog->totalSsid = (uint8_t) c; |
Abhishek Singh | 6f56d21 | 2017-04-12 14:31:57 +0530 | [diff] [blame] | 2499 | ucfg_scan_purge_results(list); |
| 2500 | wlan_objmgr_pdev_release_ref(pdev, WLAN_LEGACY_MAC_ID); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2501 | WLAN_HOST_DIAG_LOG_REPORT(pScanLog); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2502 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2503 | #endif /* #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR */ |
| 2504 | |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2505 | #ifdef NAPIER_SCAN |
| 2506 | /** |
Deepak Dhamdhere | 6f7fbbe | 2017-02-28 13:35:52 -0800 | [diff] [blame] | 2507 | * csr_saved_scan_cmd_free_fields() - Free internal fields of scan command |
| 2508 | * |
| 2509 | * @mac_ctx: Global MAC context |
| 2510 | * @saved_scan_cmd: Pointer to scan command |
| 2511 | * |
| 2512 | * Frees data structures allocated inside saved_scan_cmd and releases |
| 2513 | * the profile. |
| 2514 | * Return: None |
| 2515 | */ |
| 2516 | |
| 2517 | void csr_saved_scan_cmd_free_fields(tpAniSirGlobal mac_ctx, |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 2518 | struct csr_roam_session *session) |
Deepak Dhamdhere | 6f7fbbe | 2017-02-28 13:35:52 -0800 | [diff] [blame] | 2519 | { |
| 2520 | if (session->scan_info.profile) { |
| 2521 | csr_release_profile(mac_ctx, |
| 2522 | session->scan_info.profile); |
| 2523 | qdf_mem_free(session->scan_info.profile); |
| 2524 | session->scan_info.profile = NULL; |
| 2525 | } |
| 2526 | |
| 2527 | if (session->scan_info.roambssentry) { |
| 2528 | qdf_mem_free(session->scan_info.roambssentry); |
| 2529 | session->scan_info.roambssentry = NULL; |
| 2530 | } |
| 2531 | } |
| 2532 | /** |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2533 | * csr_save_profile() - Save the profile info from sme command |
| 2534 | * @mac_ctx: Global MAC context |
| 2535 | * @save_cmd: Pointer where the command will be saved |
| 2536 | * @command: Command from which the profile will be saved |
| 2537 | * |
| 2538 | * Saves the profile information from the SME's scan command |
| 2539 | * |
| 2540 | * Return: QDF_STATUS |
| 2541 | */ |
| 2542 | static QDF_STATUS csr_save_profile(tpAniSirGlobal mac_ctx, |
| 2543 | uint32_t session_id) |
| 2544 | { |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 2545 | struct tag_csrscan_result *scan_result; |
| 2546 | struct tag_csrscan_result *temp; |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2547 | uint32_t bss_len; |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 2548 | struct csr_roam_session *session; |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2549 | |
Krunal Soni | 35a9453 | 2018-01-09 10:54:31 -0800 | [diff] [blame] | 2550 | /* |
| 2551 | * check the session's validity first, if session itself |
| 2552 | * is not valid then there is no point of releasing the memory |
| 2553 | * for invalid session (i.e. "goto error" case) |
| 2554 | */ |
| 2555 | if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) { |
| 2556 | sme_err("session %d is invalid", session_id); |
| 2557 | return QDF_STATUS_E_FAILURE; |
| 2558 | } |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2559 | session = CSR_GET_SESSION(mac_ctx, session_id); |
| 2560 | if (!session->scan_info.roambssentry) |
| 2561 | return QDF_STATUS_SUCCESS; |
| 2562 | |
| 2563 | scan_result = GET_BASE_ADDR(session->scan_info.roambssentry, |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 2564 | struct tag_csrscan_result, Link); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2565 | |
| 2566 | bss_len = scan_result->Result.BssDescriptor.length + |
| 2567 | sizeof(scan_result->Result.BssDescriptor.length); |
| 2568 | |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 2569 | temp = qdf_mem_malloc(sizeof(struct tag_csrscan_result) + bss_len); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2570 | if (!temp) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 2571 | sme_err("bss mem fail"); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2572 | goto error; |
| 2573 | } |
| 2574 | |
| 2575 | temp->AgingCount = scan_result->AgingCount; |
| 2576 | temp->preferValue = scan_result->preferValue; |
| 2577 | temp->capValue = scan_result->capValue; |
| 2578 | temp->ucEncryptionType = scan_result->ucEncryptionType; |
| 2579 | temp->mcEncryptionType = scan_result->mcEncryptionType; |
| 2580 | temp->authType = scan_result->authType; |
| 2581 | /* pvIes is unsued in success/failure */ |
| 2582 | temp->Result.pvIes = NULL; |
| 2583 | |
| 2584 | qdf_mem_copy(temp->Result.pvIes, |
| 2585 | scan_result->Result.pvIes, |
| 2586 | sizeof(*scan_result->Result.pvIes)); |
| 2587 | temp->Result.ssId.length = scan_result->Result.ssId.length; |
| 2588 | qdf_mem_copy(temp->Result.ssId.ssId, |
| 2589 | scan_result->Result.ssId.ssId, |
| 2590 | sizeof(scan_result->Result.ssId.ssId)); |
| 2591 | temp->Result.timer = scan_result->Result.timer; |
| 2592 | qdf_mem_copy(&temp->Result.BssDescriptor, |
| 2593 | &scan_result->Result.BssDescriptor, |
| 2594 | sizeof(temp->Result.BssDescriptor)); |
| 2595 | temp->Link.last = temp->Link.next = NULL; |
| 2596 | session->scan_info.roambssentry = (tListElem *)temp; |
| 2597 | |
| 2598 | return QDF_STATUS_SUCCESS; |
| 2599 | error: |
| 2600 | csr_scan_handle_search_for_ssid_failure(mac_ctx, |
| 2601 | session_id); |
Deepak Dhamdhere | 6f7fbbe | 2017-02-28 13:35:52 -0800 | [diff] [blame] | 2602 | csr_saved_scan_cmd_free_fields(mac_ctx, session); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2603 | |
| 2604 | return QDF_STATUS_E_FAILURE; |
| 2605 | } |
| 2606 | |
| 2607 | static void csr_handle_nxt_cmd(tpAniSirGlobal mac_ctx, |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 2608 | enum csr_scancomplete_nextcommand nxt_cmd, |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2609 | uint32_t session_id, |
| 2610 | uint8_t chan) |
| 2611 | { |
| 2612 | QDF_STATUS status, ret; |
| 2613 | |
| 2614 | switch (nxt_cmd) { |
| 2615 | |
| 2616 | case eCsrNexteScanForSsidSuccess: |
| 2617 | csr_scan_handle_search_for_ssid(mac_ctx, session_id); |
| 2618 | break; |
| 2619 | case eCsrNexteScanForSsidFailure: |
| 2620 | csr_scan_handle_search_for_ssid_failure(mac_ctx, session_id); |
| 2621 | break; |
| 2622 | case eCsrNextCheckAllowConc: |
Tushnim Bhattacharyya | 0c4ad2d | 2017-03-09 15:59:03 -0800 | [diff] [blame] | 2623 | ret = policy_mgr_current_connections_update(mac_ctx->psoc, |
| 2624 | session_id, chan, |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2625 | SIR_UPDATE_REASON_HIDDEN_STA); |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 2626 | sme_debug("chan: %d session: %d status: %d", |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2627 | chan, session_id, ret); |
| 2628 | |
| 2629 | status = csr_save_profile(mac_ctx, session_id); |
| 2630 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 2631 | /* csr_save_profile should report error */ |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 2632 | sme_err("profile save failed %d", status); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2633 | return; |
| 2634 | } |
| 2635 | |
| 2636 | if (QDF_STATUS_E_FAILURE == ret) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 2637 | sme_err("conn update fail %d", chan); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2638 | csr_scan_handle_search_for_ssid_failure(mac_ctx, |
| 2639 | session_id); |
| 2640 | } else if ((QDF_STATUS_E_NOSUPPORT == ret) || |
| 2641 | (QDF_STATUS_E_ALREADY == ret)) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 2642 | sme_err("conn update ret %d", ret); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2643 | csr_scan_handle_search_for_ssid(mac_ctx, session_id); |
| 2644 | } |
| 2645 | /* Else: Set hw mode was issued and the saved connect would |
| 2646 | * be issued after set hw mode response |
| 2647 | */ |
| 2648 | break; |
| 2649 | default: |
| 2650 | break; |
| 2651 | } |
| 2652 | } |
| 2653 | #else |
Chandrasekaran, Manishekar | ef70c0d | 2015-10-20 19:54:55 +0530 | [diff] [blame] | 2654 | /** |
Deepak Dhamdhere | 6f7fbbe | 2017-02-28 13:35:52 -0800 | [diff] [blame] | 2655 | * csr_saved_scan_cmd_free_fields() - Free internal fields of scan command |
| 2656 | * |
| 2657 | * @mac_ctx: Global MAC context |
| 2658 | * @saved_scan_cmd: Pointer to scan command |
| 2659 | * |
| 2660 | * Frees data structures allocated inside saved_scan_cmd and releases |
| 2661 | * the profile. |
| 2662 | * Return: None |
| 2663 | */ |
| 2664 | |
| 2665 | void csr_saved_scan_cmd_free_fields(tpAniSirGlobal mac_ctx, |
| 2666 | tSmeCmd *saved_scan_cmd) |
| 2667 | { |
| 2668 | if (saved_scan_cmd->u.scanCmd.pToRoamProfile) { |
| 2669 | csr_release_profile(mac_ctx, |
| 2670 | saved_scan_cmd->u.scanCmd.pToRoamProfile); |
| 2671 | qdf_mem_free(saved_scan_cmd->u.scanCmd.pToRoamProfile); |
| 2672 | saved_scan_cmd->u.scanCmd.pToRoamProfile = NULL; |
| 2673 | } |
| 2674 | if (saved_scan_cmd->u.scanCmd.u.scanRequest.SSIDs.SSIDList) { |
| 2675 | qdf_mem_free(saved_scan_cmd->u.scanCmd.u. |
| 2676 | scanRequest.SSIDs.SSIDList); |
| 2677 | saved_scan_cmd->u.scanCmd.u.scanRequest.SSIDs.SSIDList = NULL; |
| 2678 | } |
| 2679 | if (saved_scan_cmd->u.roamCmd.pRoamBssEntry) { |
| 2680 | qdf_mem_free(saved_scan_cmd->u.roamCmd.pRoamBssEntry); |
| 2681 | saved_scan_cmd->u.roamCmd.pRoamBssEntry = NULL; |
| 2682 | } |
| 2683 | } |
| 2684 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2685 | static void |
| 2686 | csr_handle_nxt_cmd(tpAniSirGlobal mac_ctx, tSmeCmd *pCommand, |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 2687 | enum csr_scancomplete_nextcommand *nxt_cmd, |
Chandrasekaran, Manishekar | ef70c0d | 2015-10-20 19:54:55 +0530 | [diff] [blame] | 2688 | bool *remove_cmd, uint32_t session_id, |
| 2689 | uint8_t chan) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2690 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2691 | QDF_STATUS status, ret; |
Chandrasekaran, Manishekar | ef70c0d | 2015-10-20 19:54:55 +0530 | [diff] [blame] | 2692 | tSmeCmd *save_cmd = NULL; |
Naveen Rawat | 90542b3 | 2017-01-27 16:54:57 -0800 | [diff] [blame] | 2693 | tSmeCmd *saved_scan_cmd; |
Chandrasekaran, Manishekar | ef70c0d | 2015-10-20 19:54:55 +0530 | [diff] [blame] | 2694 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2695 | switch (*nxt_cmd) { |
| 2696 | case eCsrNext11dScan1Success: |
| 2697 | case eCsrNext11dScan2Success: |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 2698 | sme_debug( |
| 2699 | "11dScan1/3 produced results. Reissue Active scan"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2700 | /* |
| 2701 | * if we found country information, no need to continue scanning |
| 2702 | * further, bail out |
| 2703 | */ |
| 2704 | *remove_cmd = true; |
| 2705 | *nxt_cmd = eCsrNext11dScanComplete; |
| 2706 | break; |
| 2707 | case eCsrNext11dScan1Failure: |
| 2708 | /* |
| 2709 | * We are not done yet. 11d scan fail once. We will try to reset |
| 2710 | * anything and do it over again. The only meaningful thing for |
| 2711 | * this retry is that we cannot find 11d information after a |
| 2712 | * reset so we clear the "old" 11d info and give it once more |
| 2713 | * chance |
| 2714 | */ |
| 2715 | *remove_cmd = csr_handle_scan11d1_failure(mac_ctx, pCommand); |
| 2716 | if (*remove_cmd) |
| 2717 | *nxt_cmd = eCsrNext11dScanComplete; |
| 2718 | break; |
| 2719 | case eCsrNextLostLinkScan1Success: |
| 2720 | status = csr_issue_roam_after_lostlink_scan(mac_ctx, session_id, |
| 2721 | eCsrLostLink1); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2722 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2723 | csr_scan_handle_failed_lostlink1(mac_ctx, session_id); |
| 2724 | break; |
| 2725 | case eCsrNextLostLinkScan2Success: |
| 2726 | status = csr_issue_roam_after_lostlink_scan(mac_ctx, session_id, |
| 2727 | eCsrLostLink2); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2728 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2729 | csr_scan_handle_failed_lostlink2(mac_ctx, session_id); |
| 2730 | break; |
| 2731 | case eCsrNextLostLinkScan3Success: |
| 2732 | status = csr_issue_roam_after_lostlink_scan(mac_ctx, session_id, |
| 2733 | eCsrLostLink3); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2734 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2735 | csr_scan_handle_failed_lostlink3(mac_ctx, session_id); |
| 2736 | break; |
| 2737 | case eCsrNextLostLinkScan1Failed: |
| 2738 | csr_scan_handle_failed_lostlink1(mac_ctx, session_id); |
| 2739 | break; |
| 2740 | case eCsrNextLostLinkScan2Failed: |
| 2741 | csr_scan_handle_failed_lostlink2(mac_ctx, session_id); |
| 2742 | break; |
| 2743 | case eCsrNextLostLinkScan3Failed: |
| 2744 | csr_scan_handle_failed_lostlink3(mac_ctx, session_id); |
| 2745 | break; |
| 2746 | case eCsrNexteScanForSsidSuccess: |
| 2747 | csr_scan_handle_search_for_ssid(mac_ctx, pCommand); |
| 2748 | break; |
| 2749 | case eCsrNexteScanForSsidFailure: |
| 2750 | csr_scan_handle_search_for_ssid_failure(mac_ctx, pCommand); |
| 2751 | break; |
Chandrasekaran, Manishekar | ef70c0d | 2015-10-20 19:54:55 +0530 | [diff] [blame] | 2752 | case eCsrNextCheckAllowConc: |
Tushnim Bhattacharyya | 0c4ad2d | 2017-03-09 15:59:03 -0800 | [diff] [blame] | 2753 | ret = policy_mgr_current_connections_update(mac_ctx->psoc, |
| 2754 | pCommand->sessionId, chan, |
Chandrasekaran, Manishekar | ce2172e | 2016-02-18 16:12:43 +0530 | [diff] [blame] | 2755 | SIR_UPDATE_REASON_HIDDEN_STA); |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 2756 | sme_debug("chan: %d session: %d status: %d", |
Chandrasekaran, Manishekar | ef70c0d | 2015-10-20 19:54:55 +0530 | [diff] [blame] | 2757 | chan, pCommand->sessionId, ret); |
Naveen Rawat | 90542b3 | 2017-01-27 16:54:57 -0800 | [diff] [blame] | 2758 | saved_scan_cmd = (tSmeCmd *)mac_ctx->sme.saved_scan_cmd; |
| 2759 | if (saved_scan_cmd) { |
Deepak Dhamdhere | 6f7fbbe | 2017-02-28 13:35:52 -0800 | [diff] [blame] | 2760 | csr_saved_scan_cmd_free_fields(mac_ctx, |
| 2761 | saved_scan_cmd); |
Naveen Rawat | 90542b3 | 2017-01-27 16:54:57 -0800 | [diff] [blame] | 2762 | qdf_mem_free(saved_scan_cmd); |
| 2763 | saved_scan_cmd = NULL; |
| 2764 | sme_err(FL("memory should have been free. Check!")); |
Chandrasekaran, Manishekar | ef70c0d | 2015-10-20 19:54:55 +0530 | [diff] [blame] | 2765 | } |
| 2766 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2767 | save_cmd = (tSmeCmd *) qdf_mem_malloc(sizeof(*pCommand)); |
Chandrasekaran, Manishekar | ef70c0d | 2015-10-20 19:54:55 +0530 | [diff] [blame] | 2768 | if (!save_cmd) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 2769 | sme_err("save_cmd mem fail"); |
Chandrasekaran, Manishekar | ef70c0d | 2015-10-20 19:54:55 +0530 | [diff] [blame] | 2770 | goto error; |
| 2771 | } |
| 2772 | |
| 2773 | status = csr_save_profile(mac_ctx, save_cmd, pCommand); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2774 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 2775 | sme_err("profile save failed %d", status); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2776 | qdf_mem_free(save_cmd); |
Chandrasekaran, Manishekar | ef70c0d | 2015-10-20 19:54:55 +0530 | [diff] [blame] | 2777 | return; |
| 2778 | } |
| 2779 | |
| 2780 | mac_ctx->sme.saved_scan_cmd = (void *)save_cmd; |
| 2781 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2782 | if (QDF_STATUS_E_FAILURE == ret) { |
Chandrasekaran, Manishekar | ef70c0d | 2015-10-20 19:54:55 +0530 | [diff] [blame] | 2783 | error: |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 2784 | sme_err("conn update fail %d", chan); |
Chandrasekaran, Manishekar | ef70c0d | 2015-10-20 19:54:55 +0530 | [diff] [blame] | 2785 | csr_scan_handle_search_for_ssid_failure(mac_ctx, |
| 2786 | pCommand); |
| 2787 | if (mac_ctx->sme.saved_scan_cmd) { |
Deepak Dhamdhere | 6f7fbbe | 2017-02-28 13:35:52 -0800 | [diff] [blame] | 2788 | csr_saved_scan_cmd_free_fields(mac_ctx, |
| 2789 | mac_ctx->sme.saved_scan_cmd); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2790 | qdf_mem_free(mac_ctx->sme.saved_scan_cmd); |
Chandrasekaran, Manishekar | ef70c0d | 2015-10-20 19:54:55 +0530 | [diff] [blame] | 2791 | mac_ctx->sme.saved_scan_cmd = NULL; |
| 2792 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2793 | } else if ((QDF_STATUS_E_NOSUPPORT == ret) || |
| 2794 | (QDF_STATUS_E_ALREADY == ret)) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 2795 | sme_err("conn update ret %d", ret); |
Chandrasekaran, Manishekar | ef70c0d | 2015-10-20 19:54:55 +0530 | [diff] [blame] | 2796 | csr_scan_handle_search_for_ssid(mac_ctx, pCommand); |
| 2797 | if (mac_ctx->sme.saved_scan_cmd) { |
Deepak Dhamdhere | 6f7fbbe | 2017-02-28 13:35:52 -0800 | [diff] [blame] | 2798 | csr_saved_scan_cmd_free_fields(mac_ctx, |
| 2799 | mac_ctx->sme.saved_scan_cmd); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2800 | qdf_mem_free(mac_ctx->sme.saved_scan_cmd); |
Chandrasekaran, Manishekar | ef70c0d | 2015-10-20 19:54:55 +0530 | [diff] [blame] | 2801 | mac_ctx->sme.saved_scan_cmd = NULL; |
| 2802 | } |
| 2803 | } |
Chandrasekaran, Manishekar | 78b9826 | 2015-11-06 15:22:46 +0530 | [diff] [blame] | 2804 | /* Else: Set hw mode was issued and the saved connect would |
| 2805 | * be issued after set hw mode response |
| 2806 | */ |
Chandrasekaran, Manishekar | ef70c0d | 2015-10-20 19:54:55 +0530 | [diff] [blame] | 2807 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2808 | default: |
| 2809 | break; |
| 2810 | } |
| 2811 | } |
| 2812 | |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2813 | #endif |
Abhishek Singh | e685781 | 2017-03-10 18:20:06 +0530 | [diff] [blame] | 2814 | |
| 2815 | /* API will be removed after p2p component L0 */ |
| 2816 | QDF_STATUS csr_get_active_scan_entry(tpAniSirGlobal mac_ctx, |
| 2817 | uint32_t scan_id, tListElem **entry) |
| 2818 | { |
| 2819 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
| 2820 | struct wlan_serialization_command *cmn_cmd; |
| 2821 | tSmeCmd *sme_cmd; |
| 2822 | uint32_t cmd_scan_id = 0; |
| 2823 | |
Abhishek Singh | e685781 | 2017-03-10 18:20:06 +0530 | [diff] [blame] | 2824 | csr_scan_active_ll_lock(mac_ctx); |
| 2825 | |
| 2826 | if (csr_scan_active_ll_is_list_empty(mac_ctx, LL_ACCESS_NOLOCK)) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 2827 | sme_err("Active list Empty scanId: %d", scan_id); |
Abhishek Singh | e685781 | 2017-03-10 18:20:06 +0530 | [diff] [blame] | 2828 | csr_scan_active_ll_unlock(mac_ctx); |
| 2829 | return QDF_STATUS_SUCCESS; |
| 2830 | } |
| 2831 | cmn_cmd = wlan_serialization_peek_head_active_cmd_using_psoc( |
| 2832 | mac_ctx->psoc, true); |
| 2833 | while (cmn_cmd) { |
| 2834 | sme_cmd = cmn_cmd->umac_cmd; |
| 2835 | if (cmn_cmd->cmd_type == WLAN_SER_CMD_SCAN) |
| 2836 | cmd_scan_id = cmn_cmd->cmd_id; |
| 2837 | else if (cmn_cmd->cmd_type == WLAN_SER_CMD_REMAIN_ON_CHANNEL) |
| 2838 | cmd_scan_id = sme_cmd->u.remainChlCmd.scan_id; |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 2839 | sme_debug("cmd_scan_id %d", cmd_scan_id); |
Abhishek Singh | e685781 | 2017-03-10 18:20:06 +0530 | [diff] [blame] | 2840 | if ((cmn_cmd->cmd_type == WLAN_SER_CMD_REMAIN_ON_CHANNEL) && |
| 2841 | (cmd_scan_id == scan_id)) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 2842 | sme_debug("scanId Matched %d", scan_id); |
Abhishek Singh | e685781 | 2017-03-10 18:20:06 +0530 | [diff] [blame] | 2843 | *entry = &sme_cmd->Link; |
| 2844 | csr_scan_active_ll_unlock(mac_ctx); |
| 2845 | return QDF_STATUS_SUCCESS; |
| 2846 | } |
| 2847 | cmn_cmd = |
| 2848 | wlan_serialization_get_active_list_next_node_using_psoc( |
| 2849 | mac_ctx->psoc, cmn_cmd, true); |
| 2850 | } |
| 2851 | csr_scan_active_ll_unlock(mac_ctx); |
Abhishek Singh | e685781 | 2017-03-10 18:20:06 +0530 | [diff] [blame] | 2852 | |
| 2853 | return status; |
| 2854 | } |
Abhishek Singh | e685781 | 2017-03-10 18:20:06 +0530 | [diff] [blame] | 2855 | |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2856 | void csr_scan_callback(struct wlan_objmgr_vdev *vdev, |
| 2857 | struct scan_event *event, void *arg) |
| 2858 | { |
| 2859 | eCsrScanStatus scan_status = eCSR_SCAN_FAILURE; |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 2860 | enum csr_scancomplete_nextcommand NextCommand = eCsrNextScanNothing; |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2861 | tpAniSirGlobal mac_ctx; |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 2862 | struct csr_roam_session *session; |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2863 | uint32_t session_id = 0; |
| 2864 | uint8_t chan = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2865 | |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2866 | mac_ctx = (tpAniSirGlobal)arg; |
| 2867 | if ((event->type == SCAN_EVENT_TYPE_COMPLETED) && |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 2868 | ((event->reason == SCAN_REASON_CANCELLED) || |
| 2869 | (event->reason == SCAN_REASON_TIMEDOUT) || |
| 2870 | (event->reason == SCAN_REASON_INTERNAL_FAILURE))) |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2871 | scan_status = eCSR_SCAN_FAILURE; |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 2872 | else if ((event->type == SCAN_EVENT_TYPE_COMPLETED) && |
| 2873 | (event->reason == SCAN_REASON_COMPLETED)) |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2874 | scan_status = eCSR_SCAN_SUCCESS; |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 2875 | else |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2876 | return; |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 2877 | |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2878 | session_id = wlan_vdev_get_id(vdev); |
Krunal Soni | 35a9453 | 2018-01-09 10:54:31 -0800 | [diff] [blame] | 2879 | if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) { |
| 2880 | sme_err("session %d is invalid", session_id); |
| 2881 | return; |
| 2882 | } |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2883 | session = CSR_GET_SESSION(mac_ctx, session_id); |
| 2884 | |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 2885 | sme_debug("Scan Completion: status %d session %d scan_id %d", |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2886 | scan_status, session_id, event->scan_id); |
| 2887 | |
| 2888 | /* verify whether scan event is related to scan interested by CSR */ |
| 2889 | if (session->scan_info.scan_id != event->scan_id) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 2890 | sme_debug("Scan Completion on wrong scan_id %d, expected %d", |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2891 | session->scan_info.scan_id, event->scan_id); |
| 2892 | return; |
| 2893 | } |
| 2894 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 2895 | csr_diag_scan_complete(mac_ctx, scan_status); |
| 2896 | #endif |
| 2897 | NextCommand = csr_scan_get_next_command_state(mac_ctx, |
| 2898 | session_id, scan_status, |
| 2899 | &chan); |
| 2900 | /* We reuse the command here instead reissue a new command */ |
| 2901 | csr_handle_nxt_cmd(mac_ctx, NextCommand, |
| 2902 | session_id, chan); |
Sandeep Puligilla | b0e017c | 2017-06-09 18:09:55 -0700 | [diff] [blame] | 2903 | |
| 2904 | if (session->scan_info.profile != NULL) { |
| 2905 | sme_debug("Free the profile scan_id %d", event->scan_id); |
| 2906 | csr_release_profile(mac_ctx, session->scan_info.profile); |
| 2907 | qdf_mem_free(session->scan_info.profile); |
| 2908 | session->scan_info.profile = NULL; |
| 2909 | } |
| 2910 | |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 2911 | } |
| 2912 | bool csr_scan_complete(tpAniSirGlobal pMac, tSirSmeScanRsp *pScanRsp) |
| 2913 | { |
| 2914 | return true; |
| 2915 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2916 | |
| 2917 | /* Return whether last scan result is received */ |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 2918 | static bool csr_scan_process_scan_results(tpAniSirGlobal pMac, tSmeCmd |
| 2919 | *pCommand, tSirSmeScanRsp *pScanRsp, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2920 | bool *pfRemoveCommand) |
| 2921 | { |
| 2922 | bool fRet = false, fRemoveCommand = false; |
Amar Singhal | 83a047a | 2016-05-19 15:56:11 -0700 | [diff] [blame] | 2923 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2924 | |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 2925 | sme_debug("scan reason = %d, response status code = %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2926 | pCommand->u.scanCmd.reason, pScanRsp->statusCode); |
| 2927 | fRemoveCommand = csr_scan_complete(pMac, pScanRsp); |
| 2928 | fRet = true; |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 2929 | if (pfRemoveCommand) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2930 | *pfRemoveCommand = fRemoveCommand; |
Amar Singhal | 83a047a | 2016-05-19 15:56:11 -0700 | [diff] [blame] | 2931 | |
| 2932 | /* |
| 2933 | * Currently SET_FCC_CHANNEL issues updated channel list to fw. |
| 2934 | * At the time of driver load, if scan is issued followed with |
| 2935 | * SET_FCC_CHANNEL, driver will send update channel list to fw. |
| 2936 | * Fw will stop ongoing scan because of that GUI will have very less |
| 2937 | * scan list. |
| 2938 | * Update channel list should be sent to fw once scan is done |
| 2939 | */ |
| 2940 | if (pMac->scan.defer_update_channel_list) { |
| 2941 | status = csr_update_channel_list(pMac); |
| 2942 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 2943 | sme_err("failed to update the supported channel list"); |
Amar Singhal | 83a047a | 2016-05-19 15:56:11 -0700 | [diff] [blame] | 2944 | pMac->scan.defer_update_channel_list = false; |
| 2945 | } |
| 2946 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2947 | return fRet; |
| 2948 | } |
| 2949 | |
Jeff Johnson | 00fa67d | 2016-10-14 08:07:36 -0700 | [diff] [blame] | 2950 | static bool csr_scan_is_wild_card_scan(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2951 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2952 | uint8_t bssid[QDF_MAC_ADDR_SIZE] = {0}; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2953 | /* |
| 2954 | * It is not a wild card scan if the bssid is not broadcast and |
| 2955 | * the number of SSID is 1. |
| 2956 | */ |
Ankit Gupta | a507601 | 2016-09-14 11:32:19 -0700 | [diff] [blame] | 2957 | return ((!qdf_mem_cmp(pCommand->u.scanCmd.u.scanRequest.bssid.bytes, |
| 2958 | bssid, sizeof(struct qdf_mac_addr))) |
| 2959 | || (0xff == pCommand->u.scanCmd.u.scanRequest.bssid.bytes[0])) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2960 | && (pCommand->u.scanCmd.u.scanRequest.SSIDs.numOfSSIDs != 1); |
| 2961 | } |
| 2962 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2963 | QDF_STATUS csr_scan_sme_scan_response(tpAniSirGlobal pMac, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2964 | void *pMsgBuf) |
| 2965 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2966 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2967 | tListElem *pEntry = NULL; |
| 2968 | tSmeCmd *pCommand; |
| 2969 | eCsrScanStatus scanStatus; |
| 2970 | tSirSmeScanRsp *pScanRsp = (tSirSmeScanRsp *)pMsgBuf; |
| 2971 | bool fRemoveCommand = true; |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 2972 | enum csr_scan_reason reason = eCsrScanOther; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2973 | |
| 2974 | csr_get_active_scan_entry(pMac, pScanRsp->scan_id, &pEntry); |
| 2975 | if (!pEntry) |
| 2976 | goto error_handling; |
| 2977 | |
Jeff Johnson | c83eca9 | 2017-09-18 08:13:39 -0700 | [diff] [blame] | 2978 | sme_debug("Scan completion called:scan_id %d, entry = %pK", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2979 | pScanRsp->scan_id, pEntry); |
| 2980 | |
| 2981 | pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link); |
| 2982 | if (eSmeCommandScan != pCommand->command) |
| 2983 | goto error_handling; |
| 2984 | |
| 2985 | scanStatus = (eSIR_SME_SUCCESS == pScanRsp->statusCode) ? |
| 2986 | eCSR_SCAN_SUCCESS : eCSR_SCAN_FAILURE; |
| 2987 | reason = pCommand->u.scanCmd.reason; |
| 2988 | switch (pCommand->u.scanCmd.reason) { |
| 2989 | case eCsrScanAbortNormalScan: |
| 2990 | break; |
| 2991 | case eCsrScanP2PFindPeer: |
| 2992 | scanStatus = (eSIR_SME_SUCCESS == pScanRsp->statusCode) ? |
| 2993 | eCSR_SCAN_FOUND_PEER : eCSR_SCAN_FAILURE; |
| 2994 | csr_scan_process_scan_results(pMac, pCommand, pScanRsp, NULL); |
| 2995 | break; |
| 2996 | default: |
| 2997 | if (csr_scan_process_scan_results(pMac, pCommand, pScanRsp, |
| 2998 | &fRemoveCommand) |
| 2999 | && csr_scan_is_wild_card_scan(pMac, pCommand) |
| 3000 | && !pCommand->u.scanCmd.u.scanRequest.p2pSearch) { |
| 3001 | |
| 3002 | /* Age out logic will be taken care by the age out timer */ |
| 3003 | } |
| 3004 | break; |
| 3005 | } |
Krunal Soni | 81f068c | 2017-02-23 19:51:55 -0800 | [diff] [blame] | 3006 | if (fRemoveCommand) { |
| 3007 | pCommand->u.scanCmd.status = scanStatus; |
| 3008 | csr_release_command(pMac, pCommand); |
| 3009 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3010 | return status; |
| 3011 | |
| 3012 | error_handling: |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 3013 | sme_err("Scan completion called, but no active SCAN command"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3014 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3015 | } |
| 3016 | |
| 3017 | tCsrScanResultInfo *csr_scan_result_get_first(tpAniSirGlobal pMac, |
| 3018 | tScanResultHandle hScanResult) |
| 3019 | { |
| 3020 | tListElem *pEntry; |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 3021 | struct tag_csrscan_result *pResult; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3022 | tCsrScanResultInfo *pRet = NULL; |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 3023 | struct scan_result_list *pResultList = |
| 3024 | (struct scan_result_list *) hScanResult; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3025 | |
| 3026 | if (pResultList) { |
| 3027 | csr_ll_lock(&pResultList->List); |
| 3028 | pEntry = csr_ll_peek_head(&pResultList->List, LL_ACCESS_NOLOCK); |
| 3029 | if (pEntry) { |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 3030 | pResult = GET_BASE_ADDR(pEntry, struct |
| 3031 | tag_csrscan_result, Link); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3032 | pRet = &pResult->Result; |
| 3033 | } |
| 3034 | pResultList->pCurEntry = pEntry; |
| 3035 | csr_ll_unlock(&pResultList->List); |
| 3036 | } |
| 3037 | |
| 3038 | return pRet; |
| 3039 | } |
| 3040 | |
| 3041 | tCsrScanResultInfo *csr_scan_result_get_next(tpAniSirGlobal pMac, |
| 3042 | tScanResultHandle hScanResult) |
| 3043 | { |
| 3044 | tListElem *pEntry = NULL; |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 3045 | struct tag_csrscan_result *pResult = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3046 | tCsrScanResultInfo *pRet = NULL; |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 3047 | struct scan_result_list *pResultList = |
| 3048 | (struct scan_result_list *) hScanResult; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3049 | |
| 3050 | if (!pResultList) |
| 3051 | return NULL; |
| 3052 | |
| 3053 | csr_ll_lock(&pResultList->List); |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 3054 | if (NULL == pResultList->pCurEntry) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3055 | pEntry = csr_ll_peek_head(&pResultList->List, LL_ACCESS_NOLOCK); |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 3056 | else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3057 | pEntry = csr_ll_next(&pResultList->List, pResultList->pCurEntry, |
| 3058 | LL_ACCESS_NOLOCK); |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 3059 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3060 | if (pEntry) { |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 3061 | pResult = GET_BASE_ADDR(pEntry, struct tag_csrscan_result, |
| 3062 | Link); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3063 | pRet = &pResult->Result; |
| 3064 | } |
| 3065 | pResultList->pCurEntry = pEntry; |
| 3066 | csr_ll_unlock(&pResultList->List); |
| 3067 | return pRet; |
| 3068 | } |
| 3069 | |
| 3070 | /* |
| 3071 | * This function moves the first BSS that matches the bssid to the |
| 3072 | * head of the result |
| 3073 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3074 | QDF_STATUS csr_move_bss_to_head_from_bssid(tpAniSirGlobal pMac, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3075 | struct qdf_mac_addr *bssid, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3076 | tScanResultHandle hScanResult) |
| 3077 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3078 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 3079 | struct scan_result_list *pResultList = |
| 3080 | (struct scan_result_list *) hScanResult; |
| 3081 | struct tag_csrscan_result *pResult = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3082 | tListElem *pEntry = NULL; |
| 3083 | |
| 3084 | if (!(pResultList && bssid)) |
| 3085 | return status; |
| 3086 | |
| 3087 | csr_ll_lock(&pResultList->List); |
| 3088 | pEntry = csr_ll_peek_head(&pResultList->List, LL_ACCESS_NOLOCK); |
| 3089 | while (pEntry) { |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 3090 | pResult = GET_BASE_ADDR(pEntry, struct tag_csrscan_result, |
| 3091 | Link); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3092 | if (!qdf_mem_cmp(bssid, pResult->Result.BssDescriptor.bssId, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3093 | sizeof(struct qdf_mac_addr))) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3094 | status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3095 | csr_ll_remove_entry(&pResultList->List, pEntry, |
| 3096 | LL_ACCESS_NOLOCK); |
| 3097 | csr_ll_insert_head(&pResultList->List, pEntry, |
| 3098 | LL_ACCESS_NOLOCK); |
| 3099 | break; |
| 3100 | } |
| 3101 | pEntry = csr_ll_next(&pResultList->List, pResultList->pCurEntry, |
| 3102 | LL_ACCESS_NOLOCK); |
| 3103 | } |
| 3104 | csr_ll_unlock(&pResultList->List); |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 3105 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3106 | return status; |
| 3107 | } |
| 3108 | |
Jeff Johnson | 00fa67d | 2016-10-14 08:07:36 -0700 | [diff] [blame] | 3109 | static QDF_STATUS csr_send_mb_scan_req(tpAniSirGlobal pMac, uint16_t sessionId, |
| 3110 | tCsrScanRequest *pScanReq, |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 3111 | struct tag_scanreq_param *pScanReqParam) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3112 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3113 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3114 | tSirSmeScanReq *pMsg; |
| 3115 | uint16_t msgLen; |
| 3116 | tSirScanType scanType = pScanReq->scanType; |
| 3117 | uint32_t minChnTime; /* in units of milliseconds */ |
| 3118 | uint32_t maxChnTime; /* in units of milliseconds */ |
| 3119 | uint32_t i; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3120 | struct qdf_mac_addr selfmac; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3121 | |
| 3122 | msgLen = (uint16_t) (sizeof(tSirSmeScanReq) - |
| 3123 | sizeof(pMsg->channelList.channelNumber) + |
| 3124 | (sizeof(pMsg->channelList.channelNumber) * |
| 3125 | pScanReq->ChannelInfo.numOfChannels)) + |
| 3126 | (pScanReq->uIEFieldLen); |
| 3127 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3128 | pMsg = qdf_mem_malloc(msgLen); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3129 | if (NULL == pMsg) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 3130 | sme_err("memory allocation failed"); |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 3131 | sme_debug("Failed: SId: %d FirstMatch: %d UniqueResult: %d freshScan: %d hiddenSsid: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3132 | sessionId, pScanReqParam->bReturnAfter1stMatch, |
| 3133 | pScanReqParam->fUniqueResult, pScanReqParam->freshScan, |
| 3134 | pScanReqParam->hiddenSsid); |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 3135 | sme_debug("scanType: %s (%u) BSSType: %s (%u) numOfSSIDs: %d numOfChannels: %d requestType: %s (%d) p2pSearch: %d", |
Rajeev Kumar | 43e25b1 | 2016-04-15 16:26:36 -0700 | [diff] [blame] | 3136 | sme_scan_type_to_string(pScanReq->scanType), |
Sreelakshmi Konamki | 39acb13 | 2015-12-16 13:06:22 +0530 | [diff] [blame] | 3137 | pScanReq->scanType, |
Rajeev Kumar | 43e25b1 | 2016-04-15 16:26:36 -0700 | [diff] [blame] | 3138 | sme_bss_type_to_string(pScanReq->BSSType), |
Sreelakshmi Konamki | 39acb13 | 2015-12-16 13:06:22 +0530 | [diff] [blame] | 3139 | pScanReq->BSSType, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3140 | pScanReq->SSIDs.numOfSSIDs, |
| 3141 | pScanReq->ChannelInfo.numOfChannels, |
Sreelakshmi Konamki | 39acb13 | 2015-12-16 13:06:22 +0530 | [diff] [blame] | 3142 | sme_request_type_to_string(pScanReq->requestType), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3143 | pScanReq->requestType, pScanReq->p2pSearch); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3144 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3145 | } |
| 3146 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3147 | pMsg->messageType = eWNI_SME_SCAN_REQ; |
| 3148 | pMsg->length = msgLen; |
| 3149 | /* ToDO: Fill in session info when we need to do scan base on session */ |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 3150 | if (sessionId != CSR_SESSION_ID_INVALID) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3151 | pMsg->sessionId = sessionId; |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 3152 | else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3153 | /* if sessionId == CSR_SESSION_ID_INVALID, then send the scan |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 3154 | * request on first available session |
| 3155 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3156 | pMsg->sessionId = 0; |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 3157 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3158 | if (pMsg->sessionId >= CSR_ROAM_SESSION_MAX) |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 3159 | sme_err("Invalid Sme Session ID: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3160 | pMsg->sessionId); |
| 3161 | pMsg->transactionId = 0; |
| 3162 | pMsg->dot11mode = (uint8_t) csr_translate_to_wni_cfg_dot11_mode(pMac, |
| 3163 | csr_find_best_phy_mode(pMac, |
| 3164 | pMac->roam.configParam.phyMode)); |
| 3165 | pMsg->bssType = csr_translate_bsstype_to_mac_type(pScanReq->BSSType); |
| 3166 | |
| 3167 | if (CSR_IS_SESSION_VALID(pMac, sessionId)) { |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 3168 | qdf_copy_macaddr(&selfmac, |
Srinivas Girigowda | 2c6bf00 | 2015-09-24 11:43:31 -0700 | [diff] [blame] | 3169 | &pMac->roam.roamSession[sessionId].selfMacAddr); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3170 | } else { |
| 3171 | /* |
| 3172 | * Since we don't have session for the scanning, we find a valid |
| 3173 | * session. In case we fail to do so, get the WNI_CFG_STA_ID |
| 3174 | */ |
| 3175 | for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { |
| 3176 | if (CSR_IS_SESSION_VALID(pMac, i)) { |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 3177 | qdf_copy_macaddr(&selfmac, |
Srinivas Girigowda | 2c6bf00 | 2015-09-24 11:43:31 -0700 | [diff] [blame] | 3178 | &pMac->roam.roamSession[i].selfMacAddr); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3179 | break; |
| 3180 | } |
| 3181 | } |
| 3182 | if (CSR_ROAM_SESSION_MAX == i) { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3183 | uint32_t len = QDF_MAC_ADDR_SIZE; |
Varun Reddy Yeturu | 7b2a657 | 2017-06-15 11:07:28 -0700 | [diff] [blame] | 3184 | tSirRetStatus sir_status; |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 3185 | |
Varun Reddy Yeturu | 7b2a657 | 2017-06-15 11:07:28 -0700 | [diff] [blame] | 3186 | sir_status = wlan_cfg_get_str(pMac, WNI_CFG_STA_ID, |
Srinivas Girigowda | 2c6bf00 | 2015-09-24 11:43:31 -0700 | [diff] [blame] | 3187 | selfmac.bytes, &len); |
Varun Reddy Yeturu | 7b2a657 | 2017-06-15 11:07:28 -0700 | [diff] [blame] | 3188 | if ((sir_status != eSIR_SUCCESS) |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3189 | || (len < QDF_MAC_ADDR_SIZE)) { |
Varun Reddy Yeturu | 7b2a657 | 2017-06-15 11:07:28 -0700 | [diff] [blame] | 3190 | sme_err("Can't get self MAC: status:%d len:%d", |
| 3191 | sir_status, len); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3192 | status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3193 | goto send_scan_req; |
| 3194 | } |
| 3195 | } |
| 3196 | } |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 3197 | qdf_copy_macaddr(&pMsg->selfMacAddr, &selfmac); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3198 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 3199 | qdf_copy_macaddr(&pMsg->bssId, &pScanReq->bssid); |
| 3200 | if (qdf_is_macaddr_zero(&pScanReq->bssid)) |
| 3201 | qdf_set_macaddr_broadcast(&pMsg->bssId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3202 | else |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 3203 | qdf_copy_macaddr(&pMsg->bssId, &pScanReq->bssid); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3204 | minChnTime = pScanReq->minChnTime; |
| 3205 | maxChnTime = pScanReq->maxChnTime; |
| 3206 | |
| 3207 | /* |
| 3208 | * Verify the scan type first, if the scan is active scan, we need to |
| 3209 | * make sure we are allowed to do so. if 11d is enabled & we don't see |
| 3210 | * any beacon around, scan type falls back to passive. But in BT AMP STA |
| 3211 | * mode we need to send out a directed probe |
| 3212 | */ |
| 3213 | if ((eSIR_PASSIVE_SCAN != scanType) |
Sandeep Puligilla | ee029ad | 2015-10-26 18:58:00 -0700 | [diff] [blame] | 3214 | && (eCSR_SCAN_P2P_DISCOVERY != pScanReq->requestType) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3215 | && (false == pMac->scan.fEnableBypass11d)) { |
| 3216 | scanType = pMac->scan.curScanType; |
| 3217 | if (eSIR_PASSIVE_SCAN == pMac->scan.curScanType) { |
| 3218 | if (minChnTime < |
| 3219 | pMac->roam.configParam.nPassiveMinChnTime) { |
| 3220 | minChnTime = |
| 3221 | pMac->roam.configParam.nPassiveMinChnTime; |
| 3222 | } |
| 3223 | if (maxChnTime < |
| 3224 | pMac->roam.configParam.nPassiveMaxChnTime) { |
| 3225 | maxChnTime = |
| 3226 | pMac->roam.configParam.nPassiveMaxChnTime; |
| 3227 | } |
| 3228 | } |
| 3229 | } |
| 3230 | pMsg->scanType = scanType; |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 3231 | pMsg->scan_adaptive_dwell_mode = pScanReq->scan_adaptive_dwell_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3232 | |
| 3233 | pMsg->numSsid = (pScanReq->SSIDs.numOfSSIDs < SIR_SCAN_MAX_NUM_SSID) ? |
| 3234 | pScanReq->SSIDs.numOfSSIDs : SIR_SCAN_MAX_NUM_SSID; |
| 3235 | if ((pScanReq->SSIDs.numOfSSIDs != 0) |
| 3236 | && (eSIR_PASSIVE_SCAN != scanType)) { |
| 3237 | for (i = 0; i < pMsg->numSsid; i++) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3238 | qdf_mem_copy(&pMsg->ssId[i], |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3239 | &pScanReq->SSIDs.SSIDList[i].SSID, |
| 3240 | sizeof(tSirMacSSid)); |
| 3241 | } |
| 3242 | } else { |
| 3243 | /* Otherwise we scan all SSID and let the result filter later */ |
| 3244 | for (i = 0; i < SIR_SCAN_MAX_NUM_SSID; i++) |
| 3245 | pMsg->ssId[i].length = 0; |
| 3246 | } |
| 3247 | |
| 3248 | pMsg->minChannelTime = minChnTime; |
| 3249 | pMsg->maxChannelTime = maxChnTime; |
| 3250 | /* hidden SSID option */ |
| 3251 | pMsg->hiddenSsid = pScanReqParam->hiddenSsid; |
Agrawal Ashish | 17bb390 | 2016-05-05 13:29:40 +0530 | [diff] [blame] | 3252 | /* maximum rest time */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3253 | pMsg->restTime = pScanReq->restTime; |
Agrawal Ashish | 17bb390 | 2016-05-05 13:29:40 +0530 | [diff] [blame] | 3254 | /* Minimum rest time */ |
| 3255 | pMsg->min_rest_time = pScanReq->min_rest_time; |
| 3256 | /* Idle time */ |
| 3257 | pMsg->idle_time = pScanReq->idle_time; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3258 | pMsg->returnAfterFirstMatch = pScanReqParam->bReturnAfter1stMatch; |
| 3259 | /* All the scan results caching will be done by Roaming */ |
| 3260 | /* We do not want LIM to do any caching of scan results, */ |
| 3261 | /* so delete the LIM cache on all scan requests */ |
| 3262 | pMsg->returnFreshResults = pScanReqParam->freshScan; |
| 3263 | /* Always ask for unique result */ |
| 3264 | pMsg->returnUniqueResults = pScanReqParam->fUniqueResult; |
| 3265 | pMsg->channelList.numChannels = |
| 3266 | (uint8_t) pScanReq->ChannelInfo.numOfChannels; |
| 3267 | if (pScanReq->ChannelInfo.numOfChannels) { |
| 3268 | /* Assuming the channelNumber is uint8_t (1 byte) */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3269 | qdf_mem_copy(pMsg->channelList.channelNumber, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3270 | pScanReq->ChannelInfo.ChannelList, |
| 3271 | pScanReq->ChannelInfo.numOfChannels); |
| 3272 | } |
| 3273 | |
| 3274 | pMsg->uIEFieldLen = (uint16_t) pScanReq->uIEFieldLen; |
| 3275 | pMsg->uIEFieldOffset = (uint16_t) (sizeof(tSirSmeScanReq) - |
| 3276 | sizeof(pMsg->channelList.channelNumber) + |
| 3277 | (sizeof(pMsg->channelList.channelNumber) * |
| 3278 | pScanReq->ChannelInfo.numOfChannels)); |
| 3279 | if (pScanReq->uIEFieldLen != 0) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3280 | qdf_mem_copy((uint8_t *) pMsg + pMsg->uIEFieldOffset, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3281 | pScanReq->pIEField, pScanReq->uIEFieldLen); |
| 3282 | } |
| 3283 | pMsg->p2pSearch = pScanReq->p2pSearch; |
| 3284 | pMsg->scan_id = pScanReq->scan_id; |
| 3285 | |
| 3286 | send_scan_req: |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 3287 | sme_debug( |
| 3288 | "scanId %d domainIdCurrent %d scanType %s (%d) bssType %s (%d) requestType %s (%d) numChannels %d", |
Sreelakshmi Konamki | 39acb13 | 2015-12-16 13:06:22 +0530 | [diff] [blame] | 3289 | pMsg->scan_id, pMac->scan.domainIdCurrent, |
Rajeev Kumar | 43e25b1 | 2016-04-15 16:26:36 -0700 | [diff] [blame] | 3290 | sme_scan_type_to_string(pMsg->scanType), pMsg->scanType, |
| 3291 | sme_bss_type_to_string(pMsg->bssType), pMsg->bssType, |
Sreelakshmi Konamki | 39acb13 | 2015-12-16 13:06:22 +0530 | [diff] [blame] | 3292 | sme_request_type_to_string(pScanReq->requestType), |
| 3293 | pScanReq->requestType, pMsg->channelList.numChannels); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3294 | |
| 3295 | for (i = 0; i < pMsg->channelList.numChannels; i++) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 3296 | sme_debug("channelNumber[%d]= %d", i, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3297 | pMsg->channelList.channelNumber[i]); |
| 3298 | } |
| 3299 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3300 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Rajeev Kumar | d138ac5 | 2017-01-30 18:38:37 -0800 | [diff] [blame] | 3301 | status = umac_send_mb_message_to_mac(pMsg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3302 | } else { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 3303 | sme_err( |
| 3304 | "failed to send down scan req with status: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3305 | status); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3306 | qdf_mem_free(pMsg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3307 | } |
| 3308 | return status; |
| 3309 | } |
| 3310 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3311 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 3312 | static void csr_diag_scan_channels(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
| 3313 | { |
| 3314 | host_log_scan_pkt_type *pScanLog = NULL; |
| 3315 | |
| 3316 | WLAN_HOST_DIAG_LOG_ALLOC(pScanLog, |
| 3317 | host_log_scan_pkt_type, |
| 3318 | LOG_WLAN_SCAN_C); |
| 3319 | if (!pScanLog) |
| 3320 | return; |
| 3321 | |
| 3322 | if (eCsrScanProbeBss == pCommand->u.scanCmd.reason) { |
| 3323 | pScanLog->eventId = WLAN_SCAN_EVENT_HO_SCAN_REQ; |
| 3324 | } else { |
| 3325 | if ((eSIR_PASSIVE_SCAN != |
| 3326 | pCommand->u.scanCmd.u.scanRequest.scanType) |
| 3327 | && (eSIR_PASSIVE_SCAN != pMac->scan.curScanType)) { |
| 3328 | pScanLog->eventId = WLAN_SCAN_EVENT_ACTIVE_SCAN_REQ; |
| 3329 | } else { |
| 3330 | pScanLog->eventId = WLAN_SCAN_EVENT_PASSIVE_SCAN_REQ; |
| 3331 | } |
| 3332 | } |
| 3333 | pScanLog->minChnTime = |
| 3334 | (uint8_t) pCommand->u.scanCmd.u.scanRequest.minChnTime; |
| 3335 | pScanLog->maxChnTime = |
| 3336 | (uint8_t) pCommand->u.scanCmd.u.scanRequest.maxChnTime; |
| 3337 | pScanLog->numChannel = |
| 3338 | (uint8_t) pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels; |
| 3339 | if (pScanLog->numChannel && |
| 3340 | (pScanLog->numChannel < HOST_LOG_MAX_NUM_CHANNEL)) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3341 | qdf_mem_copy(pScanLog->channels, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3342 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList, |
| 3343 | pScanLog->numChannel); |
| 3344 | } |
| 3345 | WLAN_HOST_DIAG_LOG_REPORT(pScanLog); |
| 3346 | } |
| 3347 | #else |
| 3348 | #define csr_diag_scan_channels(tpAniSirGlobal pMac, tSmeCmd *pCommand) (void)0; |
| 3349 | #endif /* #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR */ |
| 3350 | |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 3351 | static QDF_STATUS csr_scan_channels(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3352 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3353 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 3354 | struct tag_scanreq_param scanReq; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3355 | |
| 3356 | /* |
| 3357 | * Don't delete cached results. Rome rssi based scan candidates may land |
| 3358 | * up in scan cache instead of LFR cache. They will be deleted upon |
| 3359 | * query |
| 3360 | */ |
| 3361 | scanReq.freshScan = SIR_BG_SCAN_RETURN_FRESH_RESULTS; |
| 3362 | scanReq.fUniqueResult = true; |
| 3363 | scanReq.hiddenSsid = SIR_SCAN_NO_HIDDEN_SSID; |
| 3364 | if (eCsrScanForSsid == pCommand->u.scanCmd.reason) { |
| 3365 | scanReq.bReturnAfter1stMatch = |
| 3366 | CSR_SCAN_RETURN_AFTER_FIRST_MATCH; |
| 3367 | } else { |
| 3368 | /* |
| 3369 | * Basically do scan on all channels even for 11D 1st scan case |
| 3370 | */ |
| 3371 | scanReq.bReturnAfter1stMatch = |
| 3372 | CSR_SCAN_RETURN_AFTER_ALL_CHANNELS; |
| 3373 | } |
| 3374 | if (eCsrScanProbeBss == pCommand->u.scanCmd.reason) |
| 3375 | scanReq.hiddenSsid = SIR_SCAN_HIDDEN_SSID_PE_DECISION; |
| 3376 | csr_diag_scan_channels(pMac, pCommand); |
| 3377 | csr_clear_votes_for_country_info(pMac); |
| 3378 | status = csr_send_mb_scan_req(pMac, pCommand->sessionId, |
| 3379 | &pCommand->u.scanCmd.u.scanRequest, |
| 3380 | &scanReq); |
| 3381 | return status; |
| 3382 | } |
| 3383 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3384 | static QDF_STATUS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3385 | csr_issue_user_scan(tpAniSirGlobal mac_ctx, tSmeCmd *cmd) |
| 3386 | { |
| 3387 | int i, j; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3388 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3389 | uint32_t len = 0; |
| 3390 | uint8_t *ch_lst = NULL; |
| 3391 | tCsrChannelInfo new_ch_info = { 0, NULL }; |
| 3392 | |
| 3393 | if (!mac_ctx->roam.configParam.fScanTwice) |
| 3394 | return csr_scan_channels(mac_ctx, cmd); |
| 3395 | |
| 3396 | /* We scan 2.4 channel twice */ |
| 3397 | if (cmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels |
| 3398 | && (NULL != cmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList)) { |
| 3399 | len = cmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels; |
| 3400 | /* allocate twice the channel */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3401 | new_ch_info.ChannelList = (uint8_t *) qdf_mem_malloc(len * 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3402 | ch_lst = cmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList; |
| 3403 | } else { |
| 3404 | /* get the valid channel list to scan all. */ |
| 3405 | len = sizeof(mac_ctx->roam.validChannelList); |
| 3406 | status = csr_get_cfg_valid_channels(mac_ctx, |
| 3407 | (uint8_t *) mac_ctx->roam.validChannelList, &len); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3408 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3409 | /* allocate twice the channel */ |
| 3410 | new_ch_info.ChannelList = |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3411 | (uint8_t *) qdf_mem_malloc(len * 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3412 | ch_lst = mac_ctx->roam.validChannelList; |
| 3413 | } |
| 3414 | } |
| 3415 | if (NULL == new_ch_info.ChannelList) { |
| 3416 | new_ch_info.numOfChannels = 0; |
| 3417 | } else { |
| 3418 | j = 0; |
| 3419 | for (i = 0; i < len; i++) { |
| 3420 | new_ch_info.ChannelList[j++] = ch_lst[i]; |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 3421 | if (WLAN_REG_MAX_24GHZ_CH_NUM >= ch_lst[i]) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3422 | new_ch_info.ChannelList[j++] = ch_lst[i]; |
| 3423 | } |
| 3424 | if (NULL != |
| 3425 | cmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList) { |
| 3426 | /* |
| 3427 | * ch_lst points to the channellist from the command, |
| 3428 | * free it. |
| 3429 | */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3430 | qdf_mem_free( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3431 | cmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList); |
| 3432 | cmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = |
| 3433 | NULL; |
| 3434 | } |
| 3435 | cmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = j; |
| 3436 | cmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = |
| 3437 | new_ch_info.ChannelList; |
| 3438 | } |
| 3439 | |
| 3440 | return csr_scan_channels(mac_ctx, cmd); |
| 3441 | } |
| 3442 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3443 | QDF_STATUS csr_process_scan_command(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3444 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3445 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3446 | |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 3447 | sme_debug("starting SCAN cmd in %d state. reason %d", |
| 3448 | pCommand->u.scanCmd.lastRoamState[pCommand->sessionId], |
| 3449 | pCommand->u.scanCmd.reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3450 | |
| 3451 | switch (pCommand->u.scanCmd.reason) { |
| 3452 | case eCsrScanUserRequest: |
| 3453 | status = csr_issue_user_scan(pMac, pCommand); |
| 3454 | break; |
| 3455 | default: |
| 3456 | status = csr_scan_channels(pMac, pCommand); |
| 3457 | break; |
| 3458 | } |
| 3459 | |
Krunal Soni | 81f068c | 2017-02-23 19:51:55 -0800 | [diff] [blame] | 3460 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 3461 | pCommand->u.scanCmd.status = eCSR_SCAN_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3462 | |
| 3463 | return status; |
| 3464 | } |
| 3465 | |
| 3466 | /** |
| 3467 | * csr_scan_copy_request_valid_channels_only() - scan request of valid channels |
| 3468 | * @mac_ctx : pointer to Global Mac Structure |
| 3469 | * @dst_req: pointer to tCsrScanRequest |
| 3470 | * @skip_dfs_chnl: 1 - skip dfs channel, 0 - don't skip dfs channel |
| 3471 | * @src_req: pointer to tCsrScanRequest |
| 3472 | * |
| 3473 | * This function makes a copy of scan request with valid channels |
| 3474 | * |
| 3475 | * Return: none |
| 3476 | */ |
| 3477 | static void csr_scan_copy_request_valid_channels_only(tpAniSirGlobal mac_ctx, |
| 3478 | tCsrScanRequest *dst_req, uint8_t skip_dfs_chnl, |
| 3479 | tCsrScanRequest *src_req) |
| 3480 | { |
| 3481 | uint32_t index = 0; |
| 3482 | uint32_t new_index = 0; |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 3483 | uint16_t unsafe_chan[NUM_CHANNELS]; |
| 3484 | uint16_t unsafe_chan_cnt = 0; |
| 3485 | uint16_t cnt = 0; |
| 3486 | bool is_unsafe_chan; |
| 3487 | qdf_device_t qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 3488 | |
| 3489 | if (!qdf_ctx) { |
| 3490 | cds_err("qdf_ctx is NULL"); |
| 3491 | return; |
| 3492 | } |
| 3493 | pld_get_wlan_unsafe_channel(qdf_ctx->dev, unsafe_chan, |
| 3494 | &unsafe_chan_cnt, |
| 3495 | sizeof(unsafe_chan)); |
| 3496 | |
| 3497 | if (mac_ctx->roam.configParam.sta_roam_policy.dfs_mode == |
| 3498 | CSR_STA_ROAM_POLICY_DFS_DISABLED) |
| 3499 | skip_dfs_chnl = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3500 | |
| 3501 | for (index = 0; index < src_req->ChannelInfo.numOfChannels; index++) { |
| 3502 | /* Allow scan on valid channels only. |
| 3503 | * If it is p2p scan and valid channel list doesnt contain |
| 3504 | * social channels, enforce scan on social channels because |
| 3505 | * that is the only way to find p2p peers. |
| 3506 | * This can happen only if band is set to 5Ghz mode. |
| 3507 | */ |
Amar Singhal | 7a1726a | 2015-10-14 16:28:11 -0700 | [diff] [blame] | 3508 | if (src_req->ChannelInfo.ChannelList[index] < |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 3509 | WLAN_REG_MIN_11P_CH_NUM && |
| 3510 | ((csr_roam_is_valid_channel(mac_ctx, |
| 3511 | src_req->ChannelInfo.ChannelList[index])) || |
| 3512 | ((eCSR_SCAN_P2P_DISCOVERY == src_req->requestType) && |
| 3513 | CSR_IS_SOCIAL_CHANNEL( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3514 | src_req->ChannelInfo.ChannelList[index])))) { |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 3515 | if (((src_req->skipDfsChnlInP2pSearch || |
| 3516 | skip_dfs_chnl) && (CHANNEL_STATE_DFS == |
| 3517 | wlan_reg_get_channel_state(mac_ctx->pdev, |
Nishank Aggarwal | d18b6f4 | 2017-04-28 11:58:04 +0530 | [diff] [blame] | 3518 | src_req->ChannelInfo.ChannelList[index]))) && |
| 3519 | (src_req->ChannelInfo.numOfChannels > 1)) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 3520 | sme_debug( |
| 3521 | "reqType= %s (%d), numOfChannels=%d, ignoring DFS channel %d", |
Sreelakshmi Konamki | 39acb13 | 2015-12-16 13:06:22 +0530 | [diff] [blame] | 3522 | sme_request_type_to_string( |
| 3523 | src_req->requestType), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3524 | src_req->requestType, |
| 3525 | src_req->ChannelInfo.numOfChannels, |
| 3526 | src_req->ChannelInfo.ChannelList |
| 3527 | [index]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3528 | continue; |
| 3529 | } |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 3530 | if (mac_ctx->roam.configParam. |
| 3531 | sta_roam_policy.skip_unsafe_channels && |
| 3532 | unsafe_chan_cnt) { |
| 3533 | is_unsafe_chan = false; |
| 3534 | for (cnt = 0; cnt < unsafe_chan_cnt; cnt++) { |
| 3535 | if (unsafe_chan[cnt] == |
| 3536 | src_req->ChannelInfo. |
| 3537 | ChannelList[index]) { |
| 3538 | is_unsafe_chan = true; |
| 3539 | break; |
| 3540 | } |
| 3541 | } |
Agrawal, Ashish | 9f84c40 | 2016-11-30 16:19:44 +0530 | [diff] [blame] | 3542 | if (is_unsafe_chan && |
| 3543 | ((CSR_IS_CHANNEL_24GHZ( |
| 3544 | src_req->ChannelInfo. |
| 3545 | ChannelList[index]) && |
| 3546 | mac_ctx->roam.configParam. |
| 3547 | sta_roam_policy.sap_operating_band == |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 3548 | BAND_2G) || |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 3549 | (WLAN_REG_IS_5GHZ_CH( |
Agrawal, Ashish | 9f84c40 | 2016-11-30 16:19:44 +0530 | [diff] [blame] | 3550 | src_req->ChannelInfo. |
| 3551 | ChannelList[index]) && |
| 3552 | mac_ctx->roam.configParam. |
| 3553 | sta_roam_policy.sap_operating_band == |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 3554 | BAND_5G))) { |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 3555 | QDF_TRACE(QDF_MODULE_ID_SME, |
Abhishek Singh | 438cd7e | 2017-08-11 12:21:06 +0530 | [diff] [blame] | 3556 | QDF_TRACE_LEVEL_DEBUG, |
Agrawal Ashish | 21ba257 | 2016-09-03 16:40:10 +0530 | [diff] [blame] | 3557 | FL("ignoring unsafe channel %d"), |
| 3558 | src_req->ChannelInfo. |
| 3559 | ChannelList[index]); |
| 3560 | continue; |
| 3561 | } |
| 3562 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3563 | |
| 3564 | dst_req->ChannelInfo.ChannelList[new_index] = |
| 3565 | src_req->ChannelInfo.ChannelList[index]; |
| 3566 | new_index++; |
| 3567 | } |
| 3568 | } |
| 3569 | dst_req->ChannelInfo.numOfChannels = new_index; |
| 3570 | } |
| 3571 | |
| 3572 | /** |
Krunal Soni | 4274f36 | 2016-12-14 19:55:25 -0800 | [diff] [blame] | 3573 | * csr_scan_filter_given_chnl_band() - filter all channels which matches given |
Krunal Soni | 80aabd4 | 2015-12-21 12:17:16 -0800 | [diff] [blame] | 3574 | * channel's band |
| 3575 | * @mac_ctx: pointer to mac context |
Krunal Soni | 4274f36 | 2016-12-14 19:55:25 -0800 | [diff] [blame] | 3576 | * @channel: Given channel |
Krunal Soni | 80aabd4 | 2015-12-21 12:17:16 -0800 | [diff] [blame] | 3577 | * @dst_req: destination scan request |
| 3578 | * |
Krunal Soni | 4274f36 | 2016-12-14 19:55:25 -0800 | [diff] [blame] | 3579 | * when ever particular connection already exist, STA should not scan the |
| 3580 | * channels which fall under same band as given channel's band. |
| 3581 | * this routine will filter out those channels |
Krunal Soni | 80aabd4 | 2015-12-21 12:17:16 -0800 | [diff] [blame] | 3582 | * |
| 3583 | * Return: true if success otherwise false for any failure |
| 3584 | */ |
Krunal Soni | 4274f36 | 2016-12-14 19:55:25 -0800 | [diff] [blame] | 3585 | static bool csr_scan_filter_given_chnl_band(tpAniSirGlobal mac_ctx, |
| 3586 | uint8_t channel, tCsrScanRequest *dst_req) { |
Krunal Soni | 80aabd4 | 2015-12-21 12:17:16 -0800 | [diff] [blame] | 3587 | uint8_t valid_chnl_list[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}; |
Krunal Soni | 80aabd4 | 2015-12-21 12:17:16 -0800 | [diff] [blame] | 3588 | uint32_t filter_chnl_len = 0, i = 0; |
| 3589 | uint32_t valid_chnl_len = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 3590 | |
Krunal Soni | 4274f36 | 2016-12-14 19:55:25 -0800 | [diff] [blame] | 3591 | if (!channel) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 3592 | sme_debug("Nothing to filter as no IBSS session"); |
Krunal Soni | 80aabd4 | 2015-12-21 12:17:16 -0800 | [diff] [blame] | 3593 | return true; |
| 3594 | } |
| 3595 | |
| 3596 | if (!dst_req) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 3597 | sme_err("No valid scan requests"); |
Krunal Soni | 80aabd4 | 2015-12-21 12:17:16 -0800 | [diff] [blame] | 3598 | return false; |
| 3599 | } |
| 3600 | /* |
| 3601 | * In case of concurrent IBSS session exist, scan only |
| 3602 | * those channels which are not in IBSS channel's band. |
| 3603 | * In case if no-concurrent IBSS session exist then scan |
| 3604 | * full band |
| 3605 | */ |
Srinivas Girigowda | f326dfe | 2017-08-03 11:28:32 -0700 | [diff] [blame] | 3606 | if (dst_req->ChannelInfo.numOfChannels == 0) { |
Krunal Soni | 80aabd4 | 2015-12-21 12:17:16 -0800 | [diff] [blame] | 3607 | csr_get_cfg_valid_channels(mac_ctx, valid_chnl_list, |
| 3608 | &valid_chnl_len); |
| 3609 | } else { |
| 3610 | valid_chnl_len = (WNI_CFG_VALID_CHANNEL_LIST_LEN > |
| 3611 | dst_req->ChannelInfo.numOfChannels) ? |
| 3612 | dst_req->ChannelInfo.numOfChannels : |
| 3613 | WNI_CFG_VALID_CHANNEL_LIST_LEN; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3614 | qdf_mem_copy(valid_chnl_list, dst_req->ChannelInfo.ChannelList, |
Krunal Soni | 80aabd4 | 2015-12-21 12:17:16 -0800 | [diff] [blame] | 3615 | valid_chnl_len); |
| 3616 | } |
| 3617 | for (i = 0; i < valid_chnl_len; i++) { |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 3618 | if (valid_chnl_list[i] >= WLAN_REG_MIN_11P_CH_NUM) |
Krunal Soni | 80aabd4 | 2015-12-21 12:17:16 -0800 | [diff] [blame] | 3619 | continue; |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 3620 | if (WLAN_REG_IS_5GHZ_CH(channel) && |
| 3621 | WLAN_REG_IS_24GHZ_CH(valid_chnl_list[i])) { |
Krunal Soni | 03a882b | 2016-01-13 15:59:52 -0800 | [diff] [blame] | 3622 | valid_chnl_list[filter_chnl_len] = |
Krunal Soni | 80aabd4 | 2015-12-21 12:17:16 -0800 | [diff] [blame] | 3623 | valid_chnl_list[i]; |
| 3624 | filter_chnl_len++; |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 3625 | } else if (WLAN_REG_IS_24GHZ_CH(channel) && |
| 3626 | WLAN_REG_IS_5GHZ_CH(valid_chnl_list[i])) { |
Krunal Soni | 03a882b | 2016-01-13 15:59:52 -0800 | [diff] [blame] | 3627 | valid_chnl_list[filter_chnl_len] = |
Krunal Soni | 80aabd4 | 2015-12-21 12:17:16 -0800 | [diff] [blame] | 3628 | valid_chnl_list[i]; |
| 3629 | filter_chnl_len++; |
| 3630 | } |
| 3631 | } |
| 3632 | if (filter_chnl_len == 0) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 3633 | sme_err("there no channels to scan due to IBSS session"); |
Krunal Soni | 80aabd4 | 2015-12-21 12:17:16 -0800 | [diff] [blame] | 3634 | return false; |
| 3635 | } |
| 3636 | |
| 3637 | if (dst_req->ChannelInfo.ChannelList) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3638 | qdf_mem_free(dst_req->ChannelInfo.ChannelList); |
Krunal Soni | 80aabd4 | 2015-12-21 12:17:16 -0800 | [diff] [blame] | 3639 | dst_req->ChannelInfo.ChannelList = NULL; |
| 3640 | dst_req->ChannelInfo.numOfChannels = 0; |
| 3641 | } |
| 3642 | |
| 3643 | dst_req->ChannelInfo.ChannelList = |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3644 | qdf_mem_malloc(filter_chnl_len * |
Krunal Soni | 80aabd4 | 2015-12-21 12:17:16 -0800 | [diff] [blame] | 3645 | sizeof(*dst_req->ChannelInfo.ChannelList)); |
| 3646 | dst_req->ChannelInfo.numOfChannels = filter_chnl_len; |
| 3647 | if (NULL == dst_req->ChannelInfo.ChannelList) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 3648 | sme_err("Memory allocation failed"); |
Krunal Soni | 80aabd4 | 2015-12-21 12:17:16 -0800 | [diff] [blame] | 3649 | return false; |
| 3650 | } |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3651 | qdf_mem_copy(dst_req->ChannelInfo.ChannelList, valid_chnl_list, |
Krunal Soni | 80aabd4 | 2015-12-21 12:17:16 -0800 | [diff] [blame] | 3652 | filter_chnl_len); |
| 3653 | return true; |
| 3654 | } |
| 3655 | |
| 3656 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3657 | * csr_scan_copy_request() - Function to copy scan request |
| 3658 | * @mac_ctx : pointer to Global Mac Structure |
| 3659 | * @dst_req: pointer to tCsrScanRequest |
| 3660 | * @src_req: pointer to tCsrScanRequest |
| 3661 | * |
| 3662 | * This function makes a copy of scan request |
| 3663 | * |
| 3664 | * Return: 0 - Success, Error number - Failure |
| 3665 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3666 | QDF_STATUS csr_scan_copy_request(tpAniSirGlobal mac_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3667 | tCsrScanRequest *dst_req, |
| 3668 | tCsrScanRequest *src_req) |
| 3669 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3670 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3671 | uint32_t len = sizeof(mac_ctx->roam.validChannelList); |
| 3672 | uint32_t index = 0; |
| 3673 | uint32_t new_index = 0; |
Amar Singhal | a297bfa | 2015-10-15 15:07:29 -0700 | [diff] [blame] | 3674 | enum channel_state channel_state; |
Krunal Soni | 4274f36 | 2016-12-14 19:55:25 -0800 | [diff] [blame] | 3675 | uint8_t channel = 0; |
Amar Singhal | a297bfa | 2015-10-15 15:07:29 -0700 | [diff] [blame] | 3676 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3677 | bool skip_dfs_chnl = |
| 3678 | mac_ctx->roam.configParam.initial_scan_no_dfs_chnl || |
| 3679 | !mac_ctx->scan.fEnableDFSChnlScan; |
| 3680 | |
| 3681 | status = csr_scan_free_request(mac_ctx, dst_req); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3682 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3683 | goto complete; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3684 | qdf_mem_copy(dst_req, src_req, sizeof(tCsrScanRequest)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3685 | /* Re-initialize the pointers to NULL since we did a copy */ |
| 3686 | dst_req->pIEField = NULL; |
| 3687 | dst_req->ChannelInfo.ChannelList = NULL; |
| 3688 | dst_req->SSIDs.SSIDList = NULL; |
| 3689 | |
| 3690 | if (src_req->uIEFieldLen) { |
| 3691 | dst_req->pIEField = |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3692 | qdf_mem_malloc(src_req->uIEFieldLen); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3693 | if (NULL == dst_req->pIEField) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3694 | status = QDF_STATUS_E_NOMEM; |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 3695 | sme_err("No memory for scanning IE fields"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3696 | goto complete; |
| 3697 | } else { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3698 | status = QDF_STATUS_SUCCESS; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3699 | qdf_mem_copy(dst_req->pIEField, src_req->pIEField, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3700 | src_req->uIEFieldLen); |
| 3701 | dst_req->uIEFieldLen = src_req->uIEFieldLen; |
| 3702 | } |
| 3703 | } |
| 3704 | |
| 3705 | /* Allocate memory for IE field */ |
| 3706 | if (src_req->ChannelInfo.numOfChannels == 0) { |
| 3707 | dst_req->ChannelInfo.ChannelList = NULL; |
| 3708 | dst_req->ChannelInfo.numOfChannels = 0; |
| 3709 | } else { |
| 3710 | dst_req->ChannelInfo.ChannelList = |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3711 | qdf_mem_malloc(src_req->ChannelInfo.numOfChannels * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3712 | sizeof(*dst_req->ChannelInfo.ChannelList)); |
| 3713 | if (NULL == dst_req->ChannelInfo.ChannelList) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3714 | status = QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3715 | dst_req->ChannelInfo.numOfChannels = 0; |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 3716 | sme_err("No memory for scanning Channel List"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3717 | goto complete; |
| 3718 | } |
| 3719 | |
| 3720 | if ((src_req->scanType == eSIR_PASSIVE_SCAN) && |
| 3721 | (src_req->requestType == eCSR_SCAN_REQUEST_11D_SCAN)) { |
| 3722 | for (index = 0; index < src_req->ChannelInfo. |
| 3723 | numOfChannels; index++) { |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 3724 | channel_state = wlan_reg_get_channel_state( |
| 3725 | mac_ctx->pdev, |
| 3726 | src_req->ChannelInfo. |
| 3727 | ChannelList[index]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3728 | if (src_req->ChannelInfo.ChannelList[index] < |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 3729 | WLAN_REG_MIN_11P_CH_NUM && |
| 3730 | ((CHANNEL_STATE_ENABLE == |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 3731 | channel_state) || |
| 3732 | ((CHANNEL_STATE_DFS == channel_state) && |
| 3733 | !skip_dfs_chnl))) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3734 | dst_req->ChannelInfo.ChannelList |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 3735 | [new_index] = |
| 3736 | src_req-> |
| 3737 | ChannelInfo. |
| 3738 | ChannelList |
| 3739 | [index]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3740 | new_index++; |
| 3741 | } |
| 3742 | } |
| 3743 | dst_req->ChannelInfo.numOfChannels = new_index; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3744 | } else if (QDF_IS_STATUS_SUCCESS( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3745 | csr_get_cfg_valid_channels(mac_ctx, |
| 3746 | mac_ctx->roam.validChannelList, |
| 3747 | &len))) { |
| 3748 | new_index = 0; |
| 3749 | mac_ctx->roam.numValidChannels = len; |
| 3750 | csr_scan_copy_request_valid_channels_only(mac_ctx, |
| 3751 | dst_req, skip_dfs_chnl, |
| 3752 | src_req); |
| 3753 | } else { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 3754 | sme_err( |
| 3755 | "Couldn't get the valid Channel List, keeping requester's list"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3756 | new_index = 0; |
| 3757 | for (index = 0; index < src_req->ChannelInfo. |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 3758 | numOfChannels; index++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3759 | if (src_req->ChannelInfo.ChannelList[index] < |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 3760 | WLAN_REG_MIN_11P_CH_NUM) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3761 | dst_req->ChannelInfo. |
| 3762 | ChannelList[new_index] = |
| 3763 | src_req->ChannelInfo. |
| 3764 | ChannelList[index]; |
| 3765 | new_index++; |
| 3766 | } |
| 3767 | } |
| 3768 | dst_req->ChannelInfo.numOfChannels = |
| 3769 | new_index; |
| 3770 | } |
| 3771 | } /* Allocate memory for Channel List */ |
Krunal Soni | 80aabd4 | 2015-12-21 12:17:16 -0800 | [diff] [blame] | 3772 | |
| 3773 | /* |
| 3774 | * If IBSS concurrent connection exist, and if the scan |
| 3775 | * request comes from STA adapter then we need to filter |
| 3776 | * out IBSS channel's band otherwise it will cause issue |
| 3777 | * in IBSS+STA concurrency |
Krunal Soni | 4274f36 | 2016-12-14 19:55:25 -0800 | [diff] [blame] | 3778 | * |
| 3779 | * If DFS SAP/GO concurrent connection exist, and if the scan |
| 3780 | * request comes from STA adapter then we need to filter |
| 3781 | * out SAP/GO channel's band otherwise it will cause issue in |
| 3782 | * SAP+STA concurrency |
Krunal Soni | 80aabd4 | 2015-12-21 12:17:16 -0800 | [diff] [blame] | 3783 | */ |
Tushnim Bhattacharyya | 0c4ad2d | 2017-03-09 15:59:03 -0800 | [diff] [blame] | 3784 | if (policy_mgr_is_ibss_conn_exist(mac_ctx->psoc, &channel)) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 3785 | sme_debug("Conc IBSS exist, channel list will be modified"); |
Tushnim Bhattacharyya | 0c4ad2d | 2017-03-09 15:59:03 -0800 | [diff] [blame] | 3786 | } else if (policy_mgr_is_any_dfs_beaconing_session_present( |
| 3787 | mac_ctx->psoc, &channel)) { |
Krunal Soni | 4274f36 | 2016-12-14 19:55:25 -0800 | [diff] [blame] | 3788 | /* |
| 3789 | * 1) if agile & DFS scans are supported |
| 3790 | * 2) if hardware is DBS capable |
| 3791 | * 3) if current hw mode is non-dbs |
| 3792 | * if all above 3 conditions are true then don't skip any |
| 3793 | * channel from scan list |
| 3794 | */ |
Tushnim Bhattacharyya | 0c4ad2d | 2017-03-09 15:59:03 -0800 | [diff] [blame] | 3795 | if (true != policy_mgr_is_current_hwmode_dbs(mac_ctx->psoc) && |
| 3796 | policy_mgr_get_dbs_plus_agile_scan_config(mac_ctx->psoc) && |
| 3797 | policy_mgr_get_single_mac_scan_with_dfs_config( |
| 3798 | mac_ctx->psoc)) |
Krunal Soni | 4274f36 | 2016-12-14 19:55:25 -0800 | [diff] [blame] | 3799 | channel = 0; |
| 3800 | else |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 3801 | sme_debug( |
| 3802 | "Conc DFS SAP/GO exist, channel list will be modified"); |
Krunal Soni | 80aabd4 | 2015-12-21 12:17:16 -0800 | [diff] [blame] | 3803 | } |
| 3804 | |
Krunal Soni | 4274f36 | 2016-12-14 19:55:25 -0800 | [diff] [blame] | 3805 | if ((channel > 0) && |
| 3806 | (!csr_scan_filter_given_chnl_band(mac_ctx, channel, dst_req))) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 3807 | sme_err("Can't filter channels due to IBSS/SAP DFS"); |
Krunal Soni | 80aabd4 | 2015-12-21 12:17:16 -0800 | [diff] [blame] | 3808 | goto complete; |
| 3809 | } |
| 3810 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3811 | if (src_req->SSIDs.numOfSSIDs == 0) { |
| 3812 | dst_req->SSIDs.numOfSSIDs = 0; |
| 3813 | dst_req->SSIDs.SSIDList = NULL; |
| 3814 | } else { |
| 3815 | dst_req->SSIDs.SSIDList = |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3816 | qdf_mem_malloc(src_req->SSIDs.numOfSSIDs * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3817 | sizeof(*dst_req->SSIDs.SSIDList)); |
| 3818 | if (NULL == dst_req->SSIDs.SSIDList) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3819 | status = QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3820 | else |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3821 | status = QDF_STATUS_SUCCESS; |
| 3822 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3823 | dst_req->SSIDs.numOfSSIDs = |
| 3824 | src_req->SSIDs.numOfSSIDs; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3825 | qdf_mem_copy(dst_req->SSIDs.SSIDList, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3826 | src_req->SSIDs.SSIDList, |
| 3827 | src_req->SSIDs.numOfSSIDs * |
| 3828 | sizeof(*dst_req->SSIDs.SSIDList)); |
| 3829 | } else { |
| 3830 | dst_req->SSIDs.numOfSSIDs = 0; |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 3831 | sme_err("No memory for scanning SSID List"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3832 | goto complete; |
| 3833 | } |
| 3834 | } /* Allocate memory for SSID List */ |
Sreelakshmi Konamki | 8b8257c | 2016-12-12 15:44:54 +0530 | [diff] [blame] | 3835 | qdf_mem_copy(&dst_req->bssid, &src_req->bssid, |
| 3836 | sizeof(struct qdf_mac_addr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3837 | dst_req->p2pSearch = src_req->p2pSearch; |
| 3838 | dst_req->skipDfsChnlInP2pSearch = |
| 3839 | src_req->skipDfsChnlInP2pSearch; |
| 3840 | dst_req->scan_id = src_req->scan_id; |
| 3841 | dst_req->timestamp = src_req->timestamp; |
| 3842 | |
| 3843 | complete: |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 3844 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3845 | csr_scan_free_request(mac_ctx, dst_req); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3846 | |
| 3847 | return status; |
| 3848 | } |
| 3849 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3850 | QDF_STATUS csr_scan_free_request(tpAniSirGlobal pMac, tCsrScanRequest *pReq) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3851 | { |
| 3852 | |
| 3853 | if (pReq->ChannelInfo.ChannelList) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3854 | qdf_mem_free(pReq->ChannelInfo.ChannelList); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3855 | pReq->ChannelInfo.ChannelList = NULL; |
| 3856 | } |
| 3857 | pReq->ChannelInfo.numOfChannels = 0; |
| 3858 | if (pReq->pIEField) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3859 | qdf_mem_free(pReq->pIEField); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3860 | pReq->pIEField = NULL; |
| 3861 | } |
| 3862 | pReq->uIEFieldLen = 0; |
| 3863 | if (pReq->SSIDs.SSIDList) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3864 | qdf_mem_free(pReq->SSIDs.SSIDList); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3865 | pReq->SSIDs.SSIDList = NULL; |
| 3866 | } |
| 3867 | pReq->SSIDs.numOfSSIDs = 0; |
| 3868 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3869 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3870 | } |
| 3871 | |
| 3872 | void csr_scan_call_callback(tpAniSirGlobal pMac, tSmeCmd *pCommand, |
| 3873 | eCsrScanStatus scanStatus) |
| 3874 | { |
| 3875 | if (pCommand->u.scanCmd.callback) { |
Ratnam Rachuri | b7595a3 | 2016-11-04 16:58:53 +0530 | [diff] [blame] | 3876 | if (pCommand->u.scanCmd.abort_scan_indication) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 3877 | sme_debug("scanDone due to abort"); |
Ratnam Rachuri | b7595a3 | 2016-11-04 16:58:53 +0530 | [diff] [blame] | 3878 | scanStatus = eCSR_SCAN_ABORT; |
| 3879 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3880 | pCommand->u.scanCmd.callback(pMac, pCommand->u.scanCmd.pContext, |
| 3881 | pCommand->sessionId, |
| 3882 | pCommand->u.scanCmd.scanID, |
| 3883 | scanStatus); |
| 3884 | } else { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 3885 | sme_debug("Callback NULL!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3886 | } |
| 3887 | } |
| 3888 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3889 | bool csr_scan_remove_fresh_scan_command(tpAniSirGlobal pMac, uint8_t sessionId) |
| 3890 | { |
| 3891 | bool fRet = false; |
| 3892 | tListElem *pEntry, *pEntryTmp; |
| 3893 | tSmeCmd *pCommand; |
| 3894 | tDblLinkList localList; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3895 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3896 | qdf_mem_zero(&localList, sizeof(tDblLinkList)); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3897 | if (!QDF_IS_STATUS_SUCCESS(csr_ll_open(pMac->hHdd, &localList))) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 3898 | sme_err("failed to open list"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3899 | return fRet; |
| 3900 | } |
| 3901 | |
Krunal Soni | 81f068c | 2017-02-23 19:51:55 -0800 | [diff] [blame] | 3902 | csr_scan_pending_ll_lock(pMac); |
| 3903 | pEntry = csr_scan_pending_ll_peek_head(pMac, LL_ACCESS_NOLOCK); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3904 | while (pEntry) { |
Krunal Soni | 81f068c | 2017-02-23 19:51:55 -0800 | [diff] [blame] | 3905 | pEntryTmp = csr_scan_pending_ll_next(pMac, pEntry, |
| 3906 | LL_ACCESS_NOLOCK); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3907 | pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link); |
| 3908 | if (!((eSmeCommandScan == pCommand->command) |
| 3909 | && (sessionId == pCommand->sessionId))) { |
| 3910 | pEntry = pEntryTmp; |
| 3911 | continue; |
| 3912 | } |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 3913 | sme_debug("-------- abort scan command reason = %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3914 | pCommand->u.scanCmd.reason); |
| 3915 | /* The rest are fresh scan requests */ |
Krunal Soni | 81f068c | 2017-02-23 19:51:55 -0800 | [diff] [blame] | 3916 | if (csr_scan_pending_ll_remove_entry(pMac, pEntry, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3917 | LL_ACCESS_NOLOCK)) { |
| 3918 | csr_ll_insert_tail(&localList, pEntry, |
| 3919 | LL_ACCESS_NOLOCK); |
| 3920 | } |
| 3921 | fRet = true; |
| 3922 | pEntry = pEntryTmp; |
| 3923 | } |
| 3924 | |
Krunal Soni | 81f068c | 2017-02-23 19:51:55 -0800 | [diff] [blame] | 3925 | csr_scan_pending_ll_unlock(pMac); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3926 | |
| 3927 | while ((pEntry = csr_ll_remove_head(&localList, LL_ACCESS_NOLOCK))) { |
| 3928 | pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link); |
| 3929 | if (pCommand->u.scanCmd.callback) { |
| 3930 | /* |
| 3931 | * User scan request is pending, send response with |
| 3932 | * status eCSR_SCAN_ABORT |
| 3933 | */ |
| 3934 | pCommand->u.scanCmd.callback(pMac, |
| 3935 | pCommand->u.scanCmd.pContext, sessionId, |
| 3936 | pCommand->u.scanCmd.scanID, eCSR_SCAN_ABORT); |
| 3937 | } |
Krunal Soni | dea4595 | 2017-02-15 11:58:15 -0800 | [diff] [blame] | 3938 | csr_release_command(pMac, pCommand); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3939 | } |
| 3940 | csr_ll_close(&localList); |
| 3941 | |
| 3942 | return fRet; |
| 3943 | } |
| 3944 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3945 | QDF_STATUS csr_scan_get_pmkid_candidate_list(tpAniSirGlobal pMac, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3946 | uint32_t sessionId, |
| 3947 | tPmkidCandidateInfo *pPmkidList, |
| 3948 | uint32_t *pNumItems) |
| 3949 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3950 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 3951 | struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3952 | tCsrScanResultFilter *pScanFilter; |
| 3953 | tCsrScanResultInfo *pScanResult; |
| 3954 | tScanResultHandle hBSSList; |
| 3955 | uint32_t nItems = *pNumItems; |
| 3956 | |
| 3957 | if (!pSession) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 3958 | sme_err("session %d not found", sessionId); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3959 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3960 | } |
| 3961 | |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 3962 | sme_debug("pMac->scan.NumPmkidCandidate = %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3963 | pSession->NumPmkidCandidate); |
| 3964 | csr_reset_pmkid_candidate_list(pMac, sessionId); |
| 3965 | if (!(csr_is_conn_state_connected(pMac, sessionId) |
| 3966 | && pSession->pCurRoamProfile)) |
| 3967 | return status; |
| 3968 | |
| 3969 | *pNumItems = 0; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3970 | pScanFilter = qdf_mem_malloc(sizeof(tCsrScanResultFilter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3971 | if (NULL == pScanFilter) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3972 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3973 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3974 | /* Here is the profile we need to connect to */ |
| 3975 | status = csr_roam_prepare_filter_from_profile(pMac, |
| 3976 | pSession->pCurRoamProfile, pScanFilter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3977 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3978 | qdf_mem_free(pScanFilter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3979 | return status; |
| 3980 | } |
| 3981 | |
| 3982 | status = csr_scan_get_result(pMac, pScanFilter, &hBSSList); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3983 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3984 | csr_free_scan_filter(pMac, pScanFilter); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3985 | qdf_mem_free(pScanFilter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3986 | return status; |
| 3987 | } |
| 3988 | |
| 3989 | if (pSession->NumPmkidCandidate < nItems) { |
| 3990 | pScanResult = csr_scan_result_get_next(pMac, hBSSList); |
| 3991 | while (pScanResult != NULL) { |
| 3992 | /* NumPmkidCandidate adds up here */ |
| 3993 | csr_process_bss_desc_for_pmkid_list(pMac, |
| 3994 | &pScanResult->BssDescriptor, |
| 3995 | (tDot11fBeaconIEs *)(pScanResult->pvIes), |
| 3996 | sessionId); |
| 3997 | pScanResult = csr_scan_result_get_next(pMac, hBSSList); |
| 3998 | } |
| 3999 | } |
| 4000 | |
| 4001 | if (pSession->NumPmkidCandidate) { |
| 4002 | *pNumItems = pSession->NumPmkidCandidate; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4003 | qdf_mem_copy(pPmkidList, pSession->PmkidCandidateInfo, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4004 | pSession->NumPmkidCandidate * |
| 4005 | sizeof(tPmkidCandidateInfo)); |
| 4006 | } |
| 4007 | |
| 4008 | csr_scan_result_purge(pMac, hBSSList); |
| 4009 | csr_free_scan_filter(pMac, pScanFilter); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4010 | qdf_mem_free(pScanFilter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4011 | return status; |
| 4012 | } |
| 4013 | |
| 4014 | #ifdef FEATURE_WLAN_WAPI |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4015 | QDF_STATUS csr_scan_get_bkid_candidate_list(tpAniSirGlobal pMac, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4016 | uint32_t sessionId, |
| 4017 | tBkidCandidateInfo *pBkidList, |
| 4018 | uint32_t *pNumItems) |
| 4019 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4020 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 4021 | struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4022 | tCsrScanResultFilter *pScanFilter; |
| 4023 | tCsrScanResultInfo *pScanResult; |
| 4024 | tScanResultHandle hBSSList; |
| 4025 | uint32_t nItems = *pNumItems; |
| 4026 | |
| 4027 | if (!pSession) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 4028 | sme_err("session %d not found", sessionId); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4029 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4030 | } |
| 4031 | |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 4032 | sme_debug("pMac->scan.NumBkidCandidate = %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4033 | pSession->NumBkidCandidate); |
| 4034 | csr_reset_bkid_candidate_list(pMac, sessionId); |
| 4035 | if (!(csr_is_conn_state_connected(pMac, sessionId) |
| 4036 | && pSession->pCurRoamProfile)) |
| 4037 | return status; |
| 4038 | |
| 4039 | *pNumItems = 0; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4040 | pScanFilter = qdf_mem_malloc(sizeof(tCsrScanResultFilter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4041 | if (NULL == pScanFilter) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4042 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4043 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4044 | /* Here is the profile we need to connect to */ |
| 4045 | status = csr_roam_prepare_filter_from_profile(pMac, |
| 4046 | pSession->pCurRoamProfile, pScanFilter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4047 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4048 | qdf_mem_free(pScanFilter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4049 | return status; |
| 4050 | } |
| 4051 | |
| 4052 | status = csr_scan_get_result(pMac, pScanFilter, &hBSSList); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4053 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4054 | csr_free_scan_filter(pMac, pScanFilter); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4055 | qdf_mem_free(pScanFilter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4056 | return status; |
| 4057 | } |
| 4058 | |
| 4059 | if (pSession->NumBkidCandidate < nItems) { |
| 4060 | pScanResult = csr_scan_result_get_next(pMac, hBSSList); |
| 4061 | while (pScanResult != NULL) { |
| 4062 | /* pMac->scan.NumBkidCandidate adds up here */ |
| 4063 | csr_process_bss_desc_for_bkid_list(pMac, |
| 4064 | &pScanResult->BssDescriptor, |
| 4065 | (tDot11fBeaconIEs *)(pScanResult->pvIes)); |
| 4066 | pScanResult = csr_scan_result_get_next(pMac, hBSSList); |
| 4067 | } |
| 4068 | } |
| 4069 | |
| 4070 | if (pSession->NumBkidCandidate) { |
| 4071 | *pNumItems = pSession->NumBkidCandidate; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4072 | qdf_mem_copy(pBkidList, pSession->BkidCandidateInfo, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4073 | pSession->NumBkidCandidate * |
| 4074 | sizeof(tBkidCandidateInfo)); |
| 4075 | } |
| 4076 | |
| 4077 | csr_scan_result_purge(pMac, hBSSList); |
| 4078 | csr_free_scan_filter(pMac, pScanFilter); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4079 | qdf_mem_free(pScanFilter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4080 | return status; |
| 4081 | } |
| 4082 | #endif /* FEATURE_WLAN_WAPI */ |
| 4083 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4084 | /** |
| 4085 | * csr_scan_for_ssid() - Function usually used for BSSs that suppresses SSID |
| 4086 | * @mac_ctx: Pointer to Global Mac structure |
| 4087 | * @profile: pointer to tCsrRoamProfile |
| 4088 | * @roam_id: variable representing roam id |
| 4089 | * @notify: boolean variable |
| 4090 | * |
| 4091 | * Function is usually used for BSSs that suppresses SSID so the profile |
| 4092 | * shall have one and only one SSID. |
| 4093 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4094 | * Return: Success - QDF_STATUS_SUCCESS, Failure - error number |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4095 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4096 | QDF_STATUS csr_scan_for_ssid(tpAniSirGlobal mac_ctx, uint32_t session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4097 | tCsrRoamProfile *profile, uint32_t roam_id, |
| 4098 | bool notify) |
| 4099 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4100 | QDF_STATUS status = QDF_STATUS_E_INVAL; |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 4101 | uint32_t num_ssid = profile->SSIDs.numOfSSIDs; |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 4102 | struct scan_start_request *req; |
| 4103 | struct wlan_objmgr_vdev *vdev; |
Himanshu Agarwal | 12445c1 | 2017-11-07 14:56:09 +0530 | [diff] [blame] | 4104 | uint8_t i, chan, num_chan = 0; |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 4105 | wlan_scan_id scan_id; |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 4106 | struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4107 | |
Krunal Soni | 35a9453 | 2018-01-09 10:54:31 -0800 | [diff] [blame] | 4108 | if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) { |
| 4109 | sme_err("session %d is invalid", session_id); |
| 4110 | return status; |
| 4111 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4112 | if (!(mac_ctx->scan.fScanEnable) && (num_ssid != 1)) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 4113 | sme_err( |
| 4114 | "cannot scan because scanEnable (%d) or numSSID (%d) is invalid", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4115 | mac_ctx->scan.fScanEnable, profile->SSIDs.numOfSSIDs); |
| 4116 | return status; |
| 4117 | } |
| 4118 | |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 4119 | session->scan_info.profile = |
| 4120 | qdf_mem_malloc(sizeof(tCsrRoamProfile)); |
| 4121 | if (!session->scan_info.profile) |
| 4122 | status = QDF_STATUS_E_NOMEM; |
| 4123 | else |
| 4124 | status = csr_roam_copy_profile(mac_ctx, |
| 4125 | session->scan_info.profile, |
| 4126 | profile); |
| 4127 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 4128 | goto error; |
| 4129 | scan_id = ucfg_scan_get_scan_id(mac_ctx->psoc); |
| 4130 | session->scan_info.scan_id = scan_id; |
| 4131 | session->scan_info.scan_reason = eCsrScanForSsid; |
| 4132 | session->scan_info.roam_id = roam_id; |
| 4133 | req = qdf_mem_malloc(sizeof(*req)); |
| 4134 | if (!req) { |
| 4135 | QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, |
| 4136 | FL("Failed to allocate memory")); |
| 4137 | goto error; |
| 4138 | } |
| 4139 | vdev = wlan_objmgr_get_vdev_by_macaddr_from_psoc(mac_ctx->psoc, |
| 4140 | session->selfMacAddr.bytes, |
| 4141 | WLAN_LEGACY_SME_ID); |
| 4142 | ucfg_scan_init_default_params(vdev, req); |
| 4143 | req->scan_req.dwell_time_active = 0; |
| 4144 | req->scan_req.scan_id = scan_id; |
| 4145 | req->scan_req.vdev_id = session_id; |
| 4146 | req->scan_req.scan_req_id = mac_ctx->scan.requester_id; |
Deepak Dhamdhere | ca7315c | 2017-10-20 13:05:56 -0700 | [diff] [blame] | 4147 | req->scan_req.scan_f_passive = false; |
| 4148 | req->scan_req.scan_f_bcast_probe = false; |
| 4149 | |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 4150 | |
| 4151 | if (QDF_P2P_CLIENT_MODE == profile->csrPersona) |
| 4152 | req->scan_req.scan_priority = SCAN_PRIORITY_HIGH; |
| 4153 | |
| 4154 | /* Allocate memory for IE field */ |
| 4155 | if (profile->pAddIEScan) { |
| 4156 | req->scan_req.extraie.ptr = |
| 4157 | qdf_mem_malloc(profile->nAddIEScanLength); |
| 4158 | |
| 4159 | if (NULL == req->scan_req.extraie.ptr) |
| 4160 | status = QDF_STATUS_E_NOMEM; |
| 4161 | else |
| 4162 | status = QDF_STATUS_SUCCESS; |
| 4163 | |
| 4164 | if (QDF_IS_STATUS_SUCCESS(status)) { |
| 4165 | qdf_mem_copy(req->scan_req.extraie.ptr, |
| 4166 | profile->pAddIEScan, |
| 4167 | profile->nAddIEScanLength); |
| 4168 | req->scan_req.extraie.len = profile->nAddIEScanLength; |
| 4169 | } else { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 4170 | sme_err("No memory for scanning IE fields"); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 4171 | } |
| 4172 | } |
| 4173 | |
| 4174 | req->scan_req.num_bssid = 1; |
| 4175 | if (profile->BSSIDs.numOfBSSIDs == 1) |
| 4176 | qdf_copy_macaddr(&req->scan_req.bssid_list[0], |
| 4177 | profile->BSSIDs.bssid); |
| 4178 | else |
| 4179 | qdf_set_macaddr_broadcast(&req->scan_req.bssid_list[0]); |
| 4180 | |
| 4181 | if (profile->ChannelInfo.numOfChannels) { |
| 4182 | for (i = 0; i < profile->ChannelInfo.numOfChannels; i++) { |
| 4183 | if (csr_roam_is_valid_channel(mac_ctx, |
| 4184 | profile->ChannelInfo.ChannelList[i])) { |
| 4185 | chan = profile->ChannelInfo.ChannelList[i]; |
Abhishek Singh | a394b6c | 2017-11-03 17:14:58 +0530 | [diff] [blame] | 4186 | req->scan_req.chan_list.chan[num_chan].freq = |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 4187 | wlan_chan_to_freq(chan); |
| 4188 | num_chan++; |
| 4189 | } |
| 4190 | } |
Abhishek Singh | a394b6c | 2017-11-03 17:14:58 +0530 | [diff] [blame] | 4191 | req->scan_req.chan_list.num_chan = num_chan; |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 4192 | } |
| 4193 | |
| 4194 | /* Extend it for multiple SSID */ |
| 4195 | if (profile->SSIDs.numOfSSIDs) { |
Sandeep Puligilla | c0f7744 | 2017-11-07 01:20:32 -0800 | [diff] [blame] | 4196 | if (profile->SSIDs.SSIDList[0].SSID.length > MAX_SSID_LEN) { |
| 4197 | sme_debug("wrong ssid length = %d", |
| 4198 | profile->SSIDs.SSIDList[0].SSID.length); |
| 4199 | status = QDF_STATUS_E_INVAL; |
| 4200 | goto error; |
| 4201 | } |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 4202 | req->scan_req.num_ssids = 1; |
| 4203 | qdf_mem_copy(&req->scan_req.ssid[0].ssid, |
| 4204 | &profile->SSIDs.SSIDList[0].SSID.ssId, |
| 4205 | profile->SSIDs.SSIDList[0].SSID.length); |
| 4206 | req->scan_req.ssid[0].length = |
| 4207 | profile->SSIDs.SSIDList[0].SSID.length; |
Himanshu Agarwal | 12445c1 | 2017-11-07 14:56:09 +0530 | [diff] [blame] | 4208 | sme_debug("scan for SSID = %.*s", req->scan_req.ssid[0].length, |
| 4209 | req->scan_req.ssid[0].ssid); |
Sandeep Puligilla | a330c8c | 2017-03-09 18:03:21 -0800 | [diff] [blame] | 4210 | } |
| 4211 | status = ucfg_scan_start(req); |
| 4212 | wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_SME_ID); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4213 | error: |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4214 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 4215 | sme_err("failed to initiate scan with status: %d", status); |
Sandeep Puligilla | b0e017c | 2017-06-09 18:09:55 -0700 | [diff] [blame] | 4216 | csr_release_profile(mac_ctx, session->scan_info.profile); |
| 4217 | qdf_mem_free(session->scan_info.profile); |
| 4218 | session->scan_info.profile = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4219 | if (notify) |
| 4220 | csr_roam_call_callback(mac_ctx, session_id, NULL, |
| 4221 | roam_id, eCSR_ROAM_FAILED, |
| 4222 | eCSR_ROAM_RESULT_FAILURE); |
| 4223 | } |
| 4224 | return status; |
| 4225 | } |
| 4226 | |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 4227 | static void csr_set_cfg_valid_channel_list(tpAniSirGlobal pMac, |
| 4228 | uint8_t *pChannelList, uint8_t NumChannels) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4229 | { |
| 4230 | uint32_t dataLen = sizeof(uint8_t) * NumChannels; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4231 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4232 | |
Abhishek Singh | 438cd7e | 2017-08-11 12:21:06 +0530 | [diff] [blame] | 4233 | QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4234 | "%s: dump valid channel list(NumChannels(%d))", |
| 4235 | __func__, NumChannels); |
Abhishek Singh | 438cd7e | 2017-08-11 12:21:06 +0530 | [diff] [blame] | 4236 | QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4237 | pChannelList, NumChannels); |
| 4238 | cfg_set_str(pMac, WNI_CFG_VALID_CHANNEL_LIST, pChannelList, |
| 4239 | dataLen); |
| 4240 | |
Abhishek Singh | 438cd7e | 2017-08-11 12:21:06 +0530 | [diff] [blame] | 4241 | QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4242 | "Scan offload is enabled, update default chan list"); |
| 4243 | /* |
| 4244 | * disable fcc constraint since new country code |
| 4245 | * is being set |
| 4246 | */ |
| 4247 | pMac->scan.fcc_constraint = false; |
| 4248 | status = csr_update_channel_list(pMac); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4249 | if (QDF_STATUS_SUCCESS != status) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4250 | QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4251 | "failed to update the supported channel list"); |
| 4252 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4253 | } |
| 4254 | |
| 4255 | /* |
| 4256 | * The Tx power limits are saved in the cfg for future usage. |
| 4257 | */ |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 4258 | static void csr_save_tx_power_to_cfg(tpAniSirGlobal pMac, tDblLinkList *pList, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4259 | uint32_t cfgId) |
| 4260 | { |
| 4261 | tListElem *pEntry; |
| 4262 | uint32_t cbLen = 0, dataLen, tmp_len; |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 4263 | struct csr_channel_powerinfo *ch_set; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4264 | uint32_t idx; |
| 4265 | tSirMacChanInfo *ch_pwr_set; |
| 4266 | uint8_t *pBuf = NULL; |
| 4267 | |
| 4268 | /* allocate maximum space for all channels */ |
| 4269 | dataLen = WNI_CFG_VALID_CHANNEL_LIST_LEN * sizeof(tSirMacChanInfo); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4270 | pBuf = qdf_mem_malloc(dataLen); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4271 | if (pBuf == NULL) |
| 4272 | return; |
| 4273 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4274 | ch_pwr_set = (tSirMacChanInfo *) (pBuf); |
| 4275 | pEntry = csr_ll_peek_head(pList, LL_ACCESS_LOCK); |
| 4276 | /* |
| 4277 | * write the tuples (startChan, numChan, txPower) for each channel found |
| 4278 | * in the channel power list. |
| 4279 | */ |
| 4280 | while (pEntry) { |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 4281 | ch_set = GET_BASE_ADDR(pEntry, |
| 4282 | struct csr_channel_powerinfo, link); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4283 | if (1 != ch_set->interChannelOffset) { |
| 4284 | /* |
| 4285 | * we keep the 5G channel sets internally with an |
| 4286 | * interchannel offset of 4. Expand these to the right |
| 4287 | * format. (inter channel offset of 1 is the only option |
| 4288 | * for the triplets that 11d advertises. |
| 4289 | */ |
| 4290 | tmp_len = cbLen + (ch_set->numChannels * |
| 4291 | sizeof(tSirMacChanInfo)); |
| 4292 | if (tmp_len >= dataLen) { |
| 4293 | /* |
| 4294 | * expanding this entry will overflow our |
| 4295 | * allocation |
| 4296 | */ |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 4297 | sme_err( |
| 4298 | "Buffer overflow, start %d, num %d, offset %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4299 | ch_set->firstChannel, |
| 4300 | ch_set->numChannels, |
| 4301 | ch_set->interChannelOffset); |
| 4302 | break; |
| 4303 | } |
| 4304 | |
| 4305 | for (idx = 0; idx < ch_set->numChannels; idx++) { |
| 4306 | ch_pwr_set->firstChanNum = (tSirMacChanNum) |
| 4307 | (ch_set->firstChannel + (idx * |
| 4308 | ch_set->interChannelOffset)); |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 4309 | sme_debug( |
| 4310 | "Setting Channel Number %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4311 | ch_pwr_set->firstChanNum); |
| 4312 | ch_pwr_set->numChannels = 1; |
| 4313 | ch_pwr_set->maxTxPower = |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4314 | QDF_MIN(ch_set->txPower, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4315 | pMac->roam.configParam.nTxPowerCap); |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 4316 | sme_debug( |
| 4317 | "Setting Max Transmit Power %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4318 | ch_pwr_set->maxTxPower); |
| 4319 | cbLen += sizeof(tSirMacChanInfo); |
| 4320 | ch_pwr_set++; |
| 4321 | } |
| 4322 | } else { |
| 4323 | if (cbLen >= dataLen) { |
| 4324 | /* this entry will overflow our allocation */ |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 4325 | sme_err( |
| 4326 | "Buffer overflow, start %d, num %d, offset %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4327 | ch_set->firstChannel, |
| 4328 | ch_set->numChannels, |
| 4329 | ch_set->interChannelOffset); |
| 4330 | break; |
| 4331 | } |
| 4332 | ch_pwr_set->firstChanNum = ch_set->firstChannel; |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 4333 | sme_debug("Setting Channel Number %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4334 | ch_pwr_set->firstChanNum); |
| 4335 | ch_pwr_set->numChannels = ch_set->numChannels; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4336 | ch_pwr_set->maxTxPower = QDF_MIN(ch_set->txPower, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4337 | pMac->roam.configParam.nTxPowerCap); |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 4338 | sme_debug( |
| 4339 | "Setting Max Tx Power %d, nTxPower %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4340 | ch_pwr_set->maxTxPower, |
| 4341 | pMac->roam.configParam.nTxPowerCap); |
| 4342 | cbLen += sizeof(tSirMacChanInfo); |
| 4343 | ch_pwr_set++; |
| 4344 | } |
| 4345 | pEntry = csr_ll_next(pList, pEntry, LL_ACCESS_LOCK); |
| 4346 | } |
| 4347 | if (cbLen) |
| 4348 | cfg_set_str(pMac, cfgId, (uint8_t *) pBuf, cbLen); |
| 4349 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4350 | qdf_mem_free(pBuf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4351 | } |
| 4352 | |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 4353 | static void csr_set_cfg_country_code(tpAniSirGlobal pMac, uint8_t *countryCode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4354 | { |
| 4355 | uint8_t cc[WNI_CFG_COUNTRY_CODE_LEN]; |
| 4356 | /* v_REGDOMAIN_t DomainId */ |
| 4357 | |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 4358 | sme_debug("Setting Country Code in Cfg %s", countryCode); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4359 | qdf_mem_copy(cc, countryCode, WNI_CFG_COUNTRY_CODE_LEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4360 | |
| 4361 | /* |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 4362 | * Don't program the bogus country codes that we created for Korea in |
| 4363 | * the MAC. if we see the bogus country codes, program the MAC with |
| 4364 | * the right country code. |
| 4365 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4366 | if (('K' == countryCode[0] && '1' == countryCode[1]) || |
| 4367 | ('K' == countryCode[0] && '2' == countryCode[1]) || |
| 4368 | ('K' == countryCode[0] && '3' == countryCode[1]) || |
| 4369 | ('K' == countryCode[0] && '4' == countryCode[1])) { |
| 4370 | /* |
| 4371 | * replace the alternate Korea country codes, 'K1', 'K2', .. |
| 4372 | * with 'KR' for Korea |
| 4373 | */ |
| 4374 | cc[1] = 'R'; |
| 4375 | } |
| 4376 | cfg_set_str(pMac, WNI_CFG_COUNTRY_CODE, cc, WNI_CFG_COUNTRY_CODE_LEN); |
| 4377 | |
| 4378 | /* |
| 4379 | * Need to let HALPHY know about the current domain so it can apply some |
| 4380 | * domain-specific settings (TX filter...) |
| 4381 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4382 | } |
| 4383 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4384 | QDF_STATUS csr_get_country_code(tpAniSirGlobal pMac, uint8_t *pBuf, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4385 | uint8_t *pbLen) |
| 4386 | { |
Varun Reddy Yeturu | 7b2a657 | 2017-06-15 11:07:28 -0700 | [diff] [blame] | 4387 | tSirRetStatus status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4388 | uint32_t len; |
| 4389 | |
| 4390 | if (pBuf && pbLen && (*pbLen >= WNI_CFG_COUNTRY_CODE_LEN)) { |
| 4391 | len = *pbLen; |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 4392 | status = wlan_cfg_get_str(pMac, WNI_CFG_COUNTRY_CODE, pBuf, |
| 4393 | &len); |
Varun Reddy Yeturu | 7b2a657 | 2017-06-15 11:07:28 -0700 | [diff] [blame] | 4394 | if (status == eSIR_SUCCESS) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4395 | *pbLen = (uint8_t) len; |
Varun Reddy Yeturu | 7b2a657 | 2017-06-15 11:07:28 -0700 | [diff] [blame] | 4396 | return QDF_STATUS_SUCCESS; |
| 4397 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4398 | } |
| 4399 | |
Varun Reddy Yeturu | 7b2a657 | 2017-06-15 11:07:28 -0700 | [diff] [blame] | 4400 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4401 | } |
| 4402 | |
| 4403 | void csr_set_cfg_scan_control_list(tpAniSirGlobal pMac, uint8_t *countryCode, |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 4404 | struct csr_channel *pChannelList) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4405 | { |
| 4406 | uint8_t i, j; |
| 4407 | bool found = false; |
| 4408 | uint8_t *pControlList = NULL; |
| 4409 | uint32_t len = WNI_CFG_SCAN_CONTROL_LIST_LEN; |
| 4410 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4411 | pControlList = qdf_mem_malloc(WNI_CFG_SCAN_CONTROL_LIST_LEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4412 | if (pControlList != NULL) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4413 | if (IS_SIR_STATUS_SUCCESS(wlan_cfg_get_str(pMac, |
| 4414 | WNI_CFG_SCAN_CONTROL_LIST, |
| 4415 | pControlList, &len))) { |
| 4416 | for (i = 0; i < pChannelList->numChannels; i++) { |
| 4417 | for (j = 0; j < len; j += 2) { |
| 4418 | if (pControlList[j] == |
| 4419 | pChannelList->channelList[i]) { |
| 4420 | found = true; |
| 4421 | break; |
| 4422 | } |
| 4423 | } |
| 4424 | |
| 4425 | if (found) { |
| 4426 | /* insert a pair(channel#, flag) */ |
| 4427 | pControlList[j + 1] = |
| 4428 | csr_get_scan_type(pMac, |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 4429 | pControlList[j]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4430 | found = false; /* reset the flag */ |
| 4431 | } |
| 4432 | |
| 4433 | } |
Abhishek Singh | 438cd7e | 2017-08-11 12:21:06 +0530 | [diff] [blame] | 4434 | QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4435 | "%s: dump scan control list", __func__); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4436 | QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_SME, |
Abhishek Singh | 438cd7e | 2017-08-11 12:21:06 +0530 | [diff] [blame] | 4437 | QDF_TRACE_LEVEL_DEBUG, pControlList, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4438 | len); |
| 4439 | |
| 4440 | cfg_set_str(pMac, WNI_CFG_SCAN_CONTROL_LIST, |
| 4441 | pControlList, len); |
| 4442 | } /* Successfully getting scan control list */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4443 | qdf_mem_free(pControlList); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4444 | } /* AllocateMemory */ |
| 4445 | } |
| 4446 | |
Sandeep Puligilla | df6454a | 2016-10-21 16:10:59 -0700 | [diff] [blame] | 4447 | |
| 4448 | /** |
| 4449 | * csr_scan_abort_all_scans() - Abort scan on all Sessions |
| 4450 | * @mac_ctx: pointer to Global Mac structure |
| 4451 | * @reason: reason for cancelling scan |
| 4452 | * |
| 4453 | * Abort scan on all Sessions |
| 4454 | * |
| 4455 | * Return: QDF_STATUS |
| 4456 | */ |
| 4457 | QDF_STATUS csr_scan_abort_all_scans(tpAniSirGlobal mac_ctx, |
| 4458 | eCsrAbortReason reason) |
| 4459 | { |
| 4460 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
| 4461 | uint8_t session_id; |
| 4462 | |
| 4463 | mac_ctx->scan.fDropScanCmd = true; |
| 4464 | for (session_id = 0; session_id < CSR_ROAM_SESSION_MAX; session_id++) { |
| 4465 | if (CSR_IS_SESSION_VALID(mac_ctx, session_id)) { |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 4466 | csr_remove_cmd_from_pending_list( |
Sandeep Puligilla | df6454a | 2016-10-21 16:10:59 -0700 | [diff] [blame] | 4467 | mac_ctx, |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 4468 | session_id, INVALID_SCAN_ID, |
Sandeep Puligilla | df6454a | 2016-10-21 16:10:59 -0700 | [diff] [blame] | 4469 | eSmeCommandScan); |
| 4470 | csr_abort_scan_from_active_list(mac_ctx, |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 4471 | session_id, INVALID_SCAN_ID, eSmeCommandScan, |
| 4472 | reason); |
Sandeep Puligilla | df6454a | 2016-10-21 16:10:59 -0700 | [diff] [blame] | 4473 | } |
| 4474 | } |
| 4475 | mac_ctx->scan.fDropScanCmd = false; |
| 4476 | |
| 4477 | return status; |
| 4478 | } |
| 4479 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4480 | QDF_STATUS csr_scan_abort_mac_scan(tpAniSirGlobal pMac, uint8_t sessionId, |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 4481 | uint32_t scan_id, eCsrAbortReason reason) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4482 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4483 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 4484 | QDF_STATUS ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4485 | |
| 4486 | pMac->scan.fDropScanCmd = true; |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 4487 | ret = csr_remove_cmd_from_pending_list(pMac, |
Krunal Soni | 81f068c | 2017-02-23 19:51:55 -0800 | [diff] [blame] | 4488 | sessionId, scan_id, eSmeCommandScan); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4489 | pMac->scan.fDropScanCmd = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4490 | |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 4491 | /* |
| 4492 | * If we are not able to find command for scan id in |
| 4493 | * pending list, check active list. Also if the session |
| 4494 | * id is valid then we have to check below active list. |
| 4495 | */ |
| 4496 | if (ret != QDF_STATUS_SUCCESS || |
| 4497 | sessionId != CSR_SESSION_ID_INVALID) { |
| 4498 | status = csr_abort_scan_from_active_list(pMac, |
Krunal Soni | 81f068c | 2017-02-23 19:51:55 -0800 | [diff] [blame] | 4499 | sessionId, scan_id, |
| 4500 | eSmeCommandScan, reason); |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 4501 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4502 | return status; |
| 4503 | } |
Krunal Soni | 72dba66 | 2017-02-15 20:13:17 -0800 | [diff] [blame] | 4504 | QDF_STATUS csr_remove_nonscan_cmd_from_pending_list(tpAniSirGlobal pMac, |
| 4505 | uint8_t sessionId, |
| 4506 | eSmeCommandType commandType) |
| 4507 | { |
| 4508 | tDblLinkList localList; |
| 4509 | tListElem *pEntry; |
| 4510 | tSmeCmd *pCommand; |
| 4511 | tListElem *pEntryToRemove; |
| 4512 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
| 4513 | |
| 4514 | qdf_mem_zero(&localList, sizeof(tDblLinkList)); |
| 4515 | if (!QDF_IS_STATUS_SUCCESS(csr_ll_open(pMac->hHdd, &localList))) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 4516 | sme_err("failed to open list"); |
Krunal Soni | 72dba66 | 2017-02-15 20:13:17 -0800 | [diff] [blame] | 4517 | return status; |
| 4518 | } |
| 4519 | |
| 4520 | csr_nonscan_pending_ll_lock(pMac); |
Krunal Soni | a8270f5 | 2017-02-23 19:51:25 -0800 | [diff] [blame] | 4521 | pEntry = csr_nonscan_pending_ll_peek_head(pMac, LL_ACCESS_NOLOCK); |
Krunal Soni | 72dba66 | 2017-02-15 20:13:17 -0800 | [diff] [blame] | 4522 | |
| 4523 | /* |
| 4524 | * Have to make sure we don't loop back to the head of the list, |
| 4525 | * which will happen if the entry is NOT on the list |
| 4526 | */ |
| 4527 | while (pEntry) { |
| 4528 | pEntryToRemove = pEntry; |
| 4529 | pEntry = csr_nonscan_pending_ll_next(pMac, |
| 4530 | pEntry, LL_ACCESS_NOLOCK); |
| 4531 | pCommand = GET_BASE_ADDR(pEntryToRemove, tSmeCmd, Link); |
| 4532 | |
| 4533 | if ((pCommand->command == commandType) && |
| 4534 | (pCommand->sessionId == sessionId)) { |
| 4535 | /* Remove that entry only */ |
| 4536 | if (csr_nonscan_pending_ll_remove_entry(pMac, |
| 4537 | pEntryToRemove, |
| 4538 | LL_ACCESS_NOLOCK)) { |
| 4539 | csr_ll_insert_tail(&localList, pEntryToRemove, |
| 4540 | LL_ACCESS_NOLOCK); |
| 4541 | status = QDF_STATUS_SUCCESS; |
| 4542 | } |
| 4543 | } |
| 4544 | } |
| 4545 | csr_nonscan_pending_ll_unlock(pMac); |
| 4546 | |
| 4547 | while ((pEntry = csr_ll_remove_head(&localList, LL_ACCESS_NOLOCK))) { |
| 4548 | pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link); |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 4549 | sme_debug("Sending abort for command ID %d", |
Krunal Soni | 72dba66 | 2017-02-15 20:13:17 -0800 | [diff] [blame] | 4550 | (commandType == eSmeCommandScan) ? pCommand->u. |
| 4551 | scanCmd.scanID : sessionId); |
Krunal Soni | 81f068c | 2017-02-23 19:51:55 -0800 | [diff] [blame] | 4552 | csr_release_command(pMac, pCommand); |
Krunal Soni | 72dba66 | 2017-02-15 20:13:17 -0800 | [diff] [blame] | 4553 | } |
| 4554 | |
| 4555 | csr_ll_close(&localList); |
| 4556 | return status; |
| 4557 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4558 | |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 4559 | QDF_STATUS csr_remove_cmd_from_pending_list(tpAniSirGlobal pMac, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4560 | uint8_t sessionId, |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 4561 | uint32_t scan_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4562 | eSmeCommandType commandType) |
| 4563 | { |
| 4564 | tDblLinkList localList; |
| 4565 | tListElem *pEntry; |
| 4566 | tSmeCmd *pCommand; |
| 4567 | tListElem *pEntryToRemove; |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 4568 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4569 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4570 | qdf_mem_zero(&localList, sizeof(tDblLinkList)); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4571 | if (!QDF_IS_STATUS_SUCCESS(csr_ll_open(pMac->hHdd, &localList))) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 4572 | sme_err("failed to open list"); |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 4573 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4574 | } |
| 4575 | |
Krunal Soni | 81f068c | 2017-02-23 19:51:55 -0800 | [diff] [blame] | 4576 | csr_scan_pending_ll_lock(pMac); |
| 4577 | pEntry = csr_scan_pending_ll_peek_head(pMac, LL_ACCESS_NOLOCK); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4578 | |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 4579 | /* |
| 4580 | * Have to make sure we don't loop back to the head of the list, |
| 4581 | * which will happen if the entry is NOT on the list |
| 4582 | */ |
| 4583 | while (pEntry) { |
| 4584 | pEntryToRemove = pEntry; |
Krunal Soni | 81f068c | 2017-02-23 19:51:55 -0800 | [diff] [blame] | 4585 | pEntry = csr_scan_pending_ll_next(pMac, pEntry, |
| 4586 | LL_ACCESS_NOLOCK); |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 4587 | pCommand = GET_BASE_ADDR(pEntryToRemove, tSmeCmd, Link); |
| 4588 | |
| 4589 | if ((pCommand->command == commandType) && |
| 4590 | (((commandType == eSmeCommandScan) && |
| 4591 | (pCommand->u.scanCmd.scanID == scan_id)) || |
| 4592 | (pCommand->sessionId == sessionId))) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4593 | /* Remove that entry only */ |
Krunal Soni | 81f068c | 2017-02-23 19:51:55 -0800 | [diff] [blame] | 4594 | if (csr_scan_pending_ll_remove_entry(pMac, |
| 4595 | pEntryToRemove, LL_ACCESS_NOLOCK)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4596 | csr_ll_insert_tail(&localList, pEntryToRemove, |
| 4597 | LL_ACCESS_NOLOCK); |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 4598 | status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4599 | } |
| 4600 | } |
| 4601 | } |
Krunal Soni | 81f068c | 2017-02-23 19:51:55 -0800 | [diff] [blame] | 4602 | csr_scan_pending_ll_unlock(pMac); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4603 | |
| 4604 | while ((pEntry = csr_ll_remove_head(&localList, LL_ACCESS_NOLOCK))) { |
| 4605 | pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link); |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 4606 | sme_debug("Sending abort for command ID %d", |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 4607 | (commandType == eSmeCommandScan) ? pCommand->u. |
| 4608 | scanCmd.scanID : sessionId); |
Krunal Soni | 81f068c | 2017-02-23 19:51:55 -0800 | [diff] [blame] | 4609 | csr_release_command(pMac, pCommand); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4610 | } |
| 4611 | |
| 4612 | csr_ll_close(&localList); |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 4613 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4614 | } |
| 4615 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4616 | QDF_STATUS csr_scan_abort_scan_for_ssid(tpAniSirGlobal pMac, uint32_t sessionId) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4617 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4618 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4619 | |
| 4620 | pMac->scan.fDropScanCmd = true; |
Krunal Soni | 81f068c | 2017-02-23 19:51:55 -0800 | [diff] [blame] | 4621 | csr_remove_scan_for_ssid_from_pending_list(pMac, sessionId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4622 | pMac->scan.fDropScanCmd = false; |
Krunal Soni | 81f068c | 2017-02-23 19:51:55 -0800 | [diff] [blame] | 4623 | csr_abort_scan_from_active_list(pMac, |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 4624 | sessionId, INVALID_SCAN_ID, eSmeCommandScan, |
| 4625 | eCSR_SCAN_ABORT_SSID_ONLY); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4626 | return status; |
| 4627 | } |
| 4628 | |
| 4629 | void csr_remove_scan_for_ssid_from_pending_list(tpAniSirGlobal pMac, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4630 | uint32_t sessionId) |
| 4631 | { |
| 4632 | tDblLinkList localList; |
| 4633 | tListElem *pEntry; |
| 4634 | tSmeCmd *pCommand; |
| 4635 | tListElem *pEntryToRemove; |
| 4636 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4637 | qdf_mem_zero(&localList, sizeof(tDblLinkList)); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4638 | if (!QDF_IS_STATUS_SUCCESS(csr_ll_open(pMac->hHdd, &localList))) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 4639 | sme_err("failed to open list"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4640 | return; |
| 4641 | } |
Krunal Soni | 81f068c | 2017-02-23 19:51:55 -0800 | [diff] [blame] | 4642 | csr_scan_pending_ll_lock(pMac); |
| 4643 | if (!csr_scan_pending_ll_is_list_empty(pMac, LL_ACCESS_NOLOCK)) { |
| 4644 | pEntry = csr_scan_pending_ll_peek_head(pMac, LL_ACCESS_NOLOCK); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4645 | /* |
| 4646 | * Have to make sure we don't loop back to the head of the list, |
| 4647 | * which will happen if the entry is NOT on the list... |
| 4648 | */ |
| 4649 | while (pEntry) { |
| 4650 | pEntryToRemove = pEntry; |
Krunal Soni | 81f068c | 2017-02-23 19:51:55 -0800 | [diff] [blame] | 4651 | pEntry = csr_scan_pending_ll_next(pMac, pEntry, |
| 4652 | LL_ACCESS_NOLOCK); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4653 | pCommand = GET_BASE_ADDR(pEntryToRemove, tSmeCmd, Link); |
| 4654 | |
| 4655 | if (!((eSmeCommandScan == pCommand->command) && |
| 4656 | (sessionId == pCommand->sessionId))) |
| 4657 | continue; |
| 4658 | if (eCsrScanForSsid != pCommand->u.scanCmd.reason) |
| 4659 | continue; |
| 4660 | /* Remove that entry only */ |
Krunal Soni | 81f068c | 2017-02-23 19:51:55 -0800 | [diff] [blame] | 4661 | if (csr_scan_pending_ll_remove_entry(pMac, |
| 4662 | pEntryToRemove, LL_ACCESS_NOLOCK)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4663 | csr_ll_insert_tail(&localList, pEntryToRemove, |
| 4664 | LL_ACCESS_NOLOCK); |
| 4665 | } |
| 4666 | } |
| 4667 | } |
Krunal Soni | 81f068c | 2017-02-23 19:51:55 -0800 | [diff] [blame] | 4668 | csr_scan_pending_ll_unlock(pMac); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4669 | while ((pEntry = csr_ll_remove_head(&localList, LL_ACCESS_NOLOCK))) { |
| 4670 | pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link); |
Krunal Soni | 81f068c | 2017-02-23 19:51:55 -0800 | [diff] [blame] | 4671 | csr_release_command(pMac, pCommand); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4672 | } |
| 4673 | csr_ll_close(&localList); |
| 4674 | } |
| 4675 | |
| 4676 | |
| 4677 | /** |
| 4678 | * csr_send_scan_abort() - Sends scan abort command to firmware |
| 4679 | * @mac_ctx: Pointer to Global Mac structure |
| 4680 | * @session_id: CSR session identification |
| 4681 | * @scan_id: scan identifier |
| 4682 | * |
| 4683 | * .Sends scan abort command to firmware |
| 4684 | * |
| 4685 | * Return: None |
| 4686 | */ |
| 4687 | static void csr_send_scan_abort(tpAniSirGlobal mac_ctx, |
| 4688 | uint32_t session_id, uint32_t scan_id) |
| 4689 | { |
| 4690 | tSirSmeScanAbortReq *msg; |
| 4691 | uint16_t msg_len; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4692 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4693 | |
| 4694 | msg_len = (uint16_t)(sizeof(tSirSmeScanAbortReq)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4695 | msg = qdf_mem_malloc(msg_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4696 | if (NULL == msg) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 4697 | sme_err("Failed to alloc memory for SmeScanAbortReq"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4698 | return; |
| 4699 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4700 | msg->type = eWNI_SME_SCAN_ABORT_IND; |
| 4701 | msg->msgLen = msg_len; |
| 4702 | msg->sessionId = session_id; |
| 4703 | msg->scan_id = scan_id; |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 4704 | sme_debug( |
| 4705 | "Abort scan sent to Firmware scan_id %d session %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4706 | scan_id, session_id); |
Rajeev Kumar | d138ac5 | 2017-01-30 18:38:37 -0800 | [diff] [blame] | 4707 | status = umac_send_mb_message_to_mac(msg); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4708 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 4709 | sme_err("Failed to send abort scan.scan_id %d session %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4710 | scan_id, session_id); |
| 4711 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4712 | } |
| 4713 | |
| 4714 | /** |
| 4715 | * csr_abort_scan_from_active_list() - Remove Scan command from active list |
| 4716 | * @mac_ctx: Pointer to Global Mac structure |
| 4717 | * @list: pointer to scan active list |
| 4718 | * @session_id: CSR session identification |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 4719 | * @scan_id: scan id |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4720 | * @scan_cmd_type: scan command type |
| 4721 | * @abort_reason: abort reason |
| 4722 | * |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 4723 | * Remove Scan command from active scan list by matching either the scan id |
| 4724 | * or session id. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4725 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4726 | * Return: Success - QDF_STATUS_SUCCESS, Failure - error number |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4727 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4728 | QDF_STATUS csr_abort_scan_from_active_list(tpAniSirGlobal mac_ctx, |
Krunal Soni | 81f068c | 2017-02-23 19:51:55 -0800 | [diff] [blame] | 4729 | uint32_t session_id, uint32_t scan_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4730 | eSmeCommandType scan_cmd_type, eCsrAbortReason abort_reason) |
| 4731 | { |
| 4732 | tListElem *entry; |
| 4733 | tSmeCmd *cmd; |
| 4734 | tListElem *entry_remove; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4735 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4736 | |
Krunal Soni | 81f068c | 2017-02-23 19:51:55 -0800 | [diff] [blame] | 4737 | csr_scan_active_ll_lock(mac_ctx); |
| 4738 | if (!csr_scan_active_ll_is_list_empty(mac_ctx, LL_ACCESS_NOLOCK)) { |
| 4739 | entry = csr_scan_active_ll_peek_head(mac_ctx, LL_ACCESS_NOLOCK); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4740 | while (entry) { |
| 4741 | entry_remove = entry; |
Krunal Soni | 81f068c | 2017-02-23 19:51:55 -0800 | [diff] [blame] | 4742 | entry = csr_scan_active_ll_next(mac_ctx, entry, |
| 4743 | LL_ACCESS_NOLOCK); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4744 | cmd = GET_BASE_ADDR(entry_remove, tSmeCmd, Link); |
| 4745 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4746 | /*skip if abort reason is for SSID*/ |
| 4747 | if ((abort_reason == eCSR_SCAN_ABORT_SSID_ONLY) && |
| 4748 | (eCsrScanForSsid != cmd->u.scanCmd.reason)) |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 4749 | continue; |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 4750 | /* |
| 4751 | * Do not skip if command and either session id |
| 4752 | * or scan id is matched |
| 4753 | */ |
| 4754 | if ((cmd->command == scan_cmd_type) && |
| 4755 | ((cmd->u.scanCmd.scanID == scan_id) || |
| 4756 | (cmd->sessionId == session_id))) { |
| 4757 | if (abort_reason == |
| 4758 | eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE) |
| 4759 | cmd->u.scanCmd.abort_scan_indication = |
Ratnam Rachuri | b7595a3 | 2016-11-04 16:58:53 +0530 | [diff] [blame] | 4760 | eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE; |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 4761 | |
| 4762 | csr_send_scan_abort(mac_ctx, cmd->sessionId, |
| 4763 | cmd->u.scanCmd.scanID); |
| 4764 | |
| 4765 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4766 | } |
| 4767 | } |
Krunal Soni | 81f068c | 2017-02-23 19:51:55 -0800 | [diff] [blame] | 4768 | csr_scan_active_ll_unlock(mac_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4769 | |
| 4770 | return status; |
| 4771 | } |
| 4772 | |
| 4773 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4774 | QDF_STATUS csr_scan_abort_mac_scan_not_for_connect(tpAniSirGlobal pMac, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4775 | uint8_t sessionId) |
| 4776 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4777 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Srinivas Girigowda | 4d65ebe | 2017-10-13 21:41:42 -0700 | [diff] [blame] | 4778 | |
Krunal Soni | f358302 | 2017-02-10 17:18:10 -0800 | [diff] [blame] | 4779 | if (!csr_is_scan_for_roam_command_active(pMac, sessionId)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4780 | /* |
| 4781 | * Only abort the scan if it is not used for other roam/connect |
| 4782 | * purpose |
| 4783 | */ |
| 4784 | status = csr_scan_abort_mac_scan(pMac, sessionId, |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 4785 | INVALID_SCAN_ID, eCSR_SCAN_ABORT_DEFAULT); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4786 | } |
| 4787 | return status; |
| 4788 | } |
| 4789 | bool csr_roam_is_valid_channel(tpAniSirGlobal pMac, uint8_t channel) |
| 4790 | { |
| 4791 | bool fValid = false; |
| 4792 | uint32_t idx_valid_ch; |
| 4793 | uint32_t len = pMac->roam.numValidChannels; |
| 4794 | |
| 4795 | for (idx_valid_ch = 0; (idx_valid_ch < len); idx_valid_ch++) { |
| 4796 | if (channel == pMac->roam.validChannelList[idx_valid_ch]) { |
| 4797 | fValid = true; |
| 4798 | break; |
| 4799 | } |
| 4800 | } |
| 4801 | return fValid; |
| 4802 | } |
| 4803 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4804 | QDF_STATUS csr_scan_create_entry_in_scan_cache(tpAniSirGlobal pMac, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4805 | uint32_t sessionId, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4806 | struct qdf_mac_addr bssid, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4807 | uint8_t channel) |
| 4808 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4809 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4810 | tDot11fBeaconIEs *pNewIes = NULL; |
gaurank kathpalia | 14e2f91 | 2017-08-31 14:51:45 +0530 | [diff] [blame] | 4811 | struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4812 | tSirBssDescription *pNewBssDescriptor = NULL; |
| 4813 | uint32_t size = 0; |
| 4814 | |
| 4815 | if (NULL == pSession) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4816 | status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4817 | return status; |
| 4818 | } |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 4819 | sme_debug("Current bssid::"MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4820 | MAC_ADDR_ARRAY(pSession->pConnectBssDesc->bssId)); |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 4821 | sme_debug("My bssid::"MAC_ADDRESS_STR" channel %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4822 | MAC_ADDR_ARRAY(bssid.bytes), channel); |
| 4823 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4824 | if (!QDF_IS_STATUS_SUCCESS(csr_get_parsed_bss_description_ies( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4825 | pMac, pSession->pConnectBssDesc, |
| 4826 | &pNewIes))) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 4827 | sme_err("Failed to parse IEs"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4828 | status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4829 | goto free_mem; |
| 4830 | } |
| 4831 | size = pSession->pConnectBssDesc->length + |
| 4832 | sizeof(pSession->pConnectBssDesc->length); |
| 4833 | if (!size) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 4834 | sme_err("length of bss descriptor is 0"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4835 | status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4836 | goto free_mem; |
| 4837 | } |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4838 | pNewBssDescriptor = qdf_mem_malloc(size); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4839 | if (NULL == pNewBssDescriptor) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 4840 | sme_err("memory allocation failed"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4841 | status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4842 | goto free_mem; |
| 4843 | } |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4844 | qdf_mem_copy(pNewBssDescriptor, pSession->pConnectBssDesc, size); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4845 | /* change the BSSID & channel as passed */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4846 | qdf_mem_copy(pNewBssDescriptor->bssId, bssid.bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4847 | sizeof(tSirMacAddr)); |
| 4848 | pNewBssDescriptor->channelId = channel; |
Abhishek Singh | a92cf1e | 2017-11-02 17:04:11 +0530 | [diff] [blame] | 4849 | if (!csr_scan_append_bss_description(pMac, pNewBssDescriptor, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4850 | pNewIes, true, sessionId)) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 4851 | sme_err("csr_scan_append_bss_description failed"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4852 | status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4853 | goto free_mem; |
| 4854 | } |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 4855 | sme_err("entry successfully added in scan cache"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4856 | |
| 4857 | free_mem: |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 4858 | if (pNewIes) |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4859 | qdf_mem_free(pNewIes); |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 4860 | |
| 4861 | if (pNewBssDescriptor) |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4862 | qdf_mem_free(pNewBssDescriptor); |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 4863 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4864 | return status; |
| 4865 | } |
| 4866 | |
| 4867 | #ifdef FEATURE_WLAN_ESE |
| 4868 | /* Update the TSF with the difference in system time */ |
| 4869 | void update_cckmtsf(uint32_t *timeStamp0, uint32_t *timeStamp1, |
Arun Khandavalli | 8a711cb | 2017-01-03 20:23:56 +0530 | [diff] [blame] | 4870 | uint64_t *incr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4871 | { |
| 4872 | uint64_t timeStamp64 = ((uint64_t) *timeStamp1 << 32) | (*timeStamp0); |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 4873 | |
Arun Khandavalli | 8a711cb | 2017-01-03 20:23:56 +0530 | [diff] [blame] | 4874 | timeStamp64 = (uint64_t)(timeStamp64 + (*incr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4875 | *timeStamp0 = (uint32_t) (timeStamp64 & 0xffffffff); |
| 4876 | *timeStamp1 = (uint32_t) ((timeStamp64 >> 32) & 0xffffffff); |
| 4877 | } |
| 4878 | #endif |
| 4879 | |
| 4880 | /** |
| 4881 | * csr_scan_save_roam_offload_ap_to_scan_cache |
| 4882 | * This function parses the received beacon/probe response |
| 4883 | * from the firmware as part of the roam synch indication. |
| 4884 | * The beacon or the probe response is parsed and is also |
| 4885 | * saved into the scan cache |
| 4886 | * |
| 4887 | * @param pMac Pointer to Global Mac |
| 4888 | * @param roam_sync_ind_ptr Roam Synch Indication from |
| 4889 | * firmware which also contains the beacon/probe |
| 4890 | * response |
| 4891 | * @return Status |
| 4892 | */ |
| 4893 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4894 | QDF_STATUS csr_scan_save_roam_offload_ap_to_scan_cache(tpAniSirGlobal pMac, |
Varun Reddy Yeturu | d5939f8 | 2015-12-24 18:14:02 -0800 | [diff] [blame] | 4895 | roam_offload_synch_ind *roam_sync_ind_ptr, |
| 4896 | tpSirBssDescription bss_desc_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4897 | { |
| 4898 | uint32_t length = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4899 | tDot11fBeaconIEs *ies_local_ptr = NULL; |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 4900 | struct tag_csrscan_result *scan_res_ptr = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4901 | uint8_t session_id = roam_sync_ind_ptr->roamedVdevId; |
| 4902 | |
| 4903 | length = roam_sync_ind_ptr->beaconProbeRespLength - |
| 4904 | (SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_SSID_OFFSET); |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 4905 | scan_res_ptr = qdf_mem_malloc(sizeof(struct tag_csrscan_result) + |
| 4906 | length); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4907 | if (scan_res_ptr == NULL) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4908 | QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4909 | " fail to allocate memory for frame"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4910 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4911 | } |
| 4912 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4913 | qdf_mem_copy(&scan_res_ptr->Result.BssDescriptor, |
Varun Reddy Yeturu | d5939f8 | 2015-12-24 18:14:02 -0800 | [diff] [blame] | 4914 | bss_desc_ptr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4915 | (sizeof(tSirBssDescription) + length)); |
| 4916 | ies_local_ptr = (tDot11fBeaconIEs *)(scan_res_ptr->Result.pvIes); |
| 4917 | if (!ies_local_ptr && |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4918 | (!QDF_IS_STATUS_SUCCESS(csr_get_parsed_bss_description_ies( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4919 | pMac, &scan_res_ptr->Result. |
| 4920 | BssDescriptor, |
| 4921 | &ies_local_ptr)))) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4922 | QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4923 | "%s:Cannot Parse IEs", __func__); |
| 4924 | csr_free_scan_result_entry(pMac, scan_res_ptr); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4925 | return QDF_STATUS_E_RESOURCES; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4926 | } |
| 4927 | |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 4928 | sme_debug("LFR3:Add BSSID to scan cache" MAC_ADDRESS_STR, |
Padma, Santhosh Kumar | cd35f53 | 2016-12-27 12:07:39 +0530 | [diff] [blame] | 4929 | MAC_ADDR_ARRAY(scan_res_ptr->Result.BssDescriptor.bssId)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4930 | csr_scan_add_result(pMac, scan_res_ptr, ies_local_ptr, session_id); |
yeshwanth sriram guntuka | 6751663 | 2017-01-30 16:05:00 +0530 | [diff] [blame] | 4931 | if ((scan_res_ptr->Result.pvIes == NULL) && ies_local_ptr) |
| 4932 | qdf_mem_free(ies_local_ptr); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4933 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4934 | } |
| 4935 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4936 | /** |
Naveen Rawat | 664a7cb | 2017-01-19 17:58:14 -0800 | [diff] [blame] | 4937 | * csr_get_fst_bssdescr_ptr() - This function returns the pointer to first bss |
| 4938 | * description from scan handle |
| 4939 | * @result_handle: an object for the result. |
| 4940 | * |
| 4941 | * Return: first bss descriptor from the scan handle. |
| 4942 | */ |
| 4943 | tpSirBssDescription csr_get_fst_bssdescr_ptr(tScanResultHandle result_handle) |
| 4944 | { |
| 4945 | tListElem *first_element = NULL; |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 4946 | struct tag_csrscan_result *scan_result = NULL; |
| 4947 | struct scan_result_list *bss_list = |
| 4948 | (struct scan_result_list *)result_handle; |
Naveen Rawat | 664a7cb | 2017-01-19 17:58:14 -0800 | [diff] [blame] | 4949 | |
| 4950 | if (NULL == bss_list) { |
| 4951 | QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, |
| 4952 | FL("Empty bss_list")); |
| 4953 | return NULL; |
| 4954 | } |
| 4955 | if (csr_ll_is_list_empty(&bss_list->List, LL_ACCESS_NOLOCK)) { |
| 4956 | QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, |
| 4957 | FL("bss_list->List is empty")); |
Naveen Rawat | 664a7cb | 2017-01-19 17:58:14 -0800 | [diff] [blame] | 4958 | return NULL; |
| 4959 | } |
| 4960 | first_element = csr_ll_peek_head(&bss_list->List, LL_ACCESS_NOLOCK); |
| 4961 | if (NULL == first_element) { |
| 4962 | QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, |
| 4963 | FL("peer head return NULL")); |
| 4964 | return NULL; |
| 4965 | } |
| 4966 | |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 4967 | scan_result = GET_BASE_ADDR(first_element, struct tag_csrscan_result, |
| 4968 | Link); |
Naveen Rawat | 664a7cb | 2017-01-19 17:58:14 -0800 | [diff] [blame] | 4969 | |
| 4970 | return &scan_result->Result.BssDescriptor; |
| 4971 | } |
| 4972 | |
| 4973 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4974 | * csr_get_bssdescr_from_scan_handle() - This function to extract |
| 4975 | * first bss description from scan handle |
| 4976 | * @result_handle: an object for the result. |
| 4977 | * |
| 4978 | * This function is written to extract first bss from scan handle. |
| 4979 | * |
| 4980 | * Return: first bss descriptor from the scan handle. |
| 4981 | */ |
| 4982 | tSirBssDescription* |
| 4983 | csr_get_bssdescr_from_scan_handle(tScanResultHandle result_handle, |
| 4984 | tSirBssDescription *bss_descr) |
| 4985 | { |
| 4986 | tListElem *first_element = NULL; |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 4987 | struct tag_csrscan_result *scan_result = NULL; |
| 4988 | struct scan_result_list *bss_list = |
| 4989 | (struct scan_result_list *)result_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4990 | |
| 4991 | if (NULL == bss_list) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4992 | QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4993 | FL("Empty bss_list")); |
| 4994 | return NULL; |
| 4995 | } |
| 4996 | if (csr_ll_is_list_empty(&bss_list->List, LL_ACCESS_NOLOCK)) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4997 | QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4998 | FL("bss_list->List is empty")); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4999 | qdf_mem_free(bss_list); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5000 | return NULL; |
| 5001 | } |
| 5002 | first_element = csr_ll_peek_head(&bss_list->List, LL_ACCESS_NOLOCK); |
| 5003 | if (first_element) { |
| 5004 | scan_result = GET_BASE_ADDR(first_element, |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 5005 | struct tag_csrscan_result, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5006 | Link); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 5007 | qdf_mem_copy(bss_descr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5008 | &scan_result->Result.BssDescriptor, |
| 5009 | sizeof(tSirBssDescription)); |
| 5010 | } |
| 5011 | return bss_descr; |
| 5012 | } |
| 5013 | |
| 5014 | /** |
| 5015 | * scan_active_list_cmd_timeout_handle() - To handle scan active command timeout |
| 5016 | * @userData: scan context |
| 5017 | * |
| 5018 | * This routine is to handle scan active command timeout |
| 5019 | * |
| 5020 | * Return: None |
| 5021 | */ |
| 5022 | void csr_scan_active_list_timeout_handle(void *userData) |
| 5023 | { |
| 5024 | tSmeCmd *scan_cmd = (tSmeCmd *) userData; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5025 | tHalHandle *hal_ctx = cds_get_context(QDF_MODULE_ID_PE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5026 | tpAniSirGlobal mac_ctx; |
| 5027 | uint16_t scan_id; |
| 5028 | tSirSmeScanAbortReq *msg; |
| 5029 | uint16_t msg_len; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5030 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5031 | |
| 5032 | if (scan_cmd == NULL) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 5033 | QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5034 | FL("Scan Timeout: Scan command is NULL")); |
| 5035 | return; |
| 5036 | } |
Varun Reddy Yeturu | f76f6de | 2015-11-17 21:33:53 -0800 | [diff] [blame] | 5037 | if (hal_ctx == NULL) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 5038 | QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, |
Varun Reddy Yeturu | f76f6de | 2015-11-17 21:33:53 -0800 | [diff] [blame] | 5039 | FL("HAL Context is NULL")); |
| 5040 | return; |
| 5041 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5042 | mac_ctx = PMAC_STRUCT(hal_ctx); |
| 5043 | scan_id = scan_cmd->u.scanCmd.scanID; |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 5044 | sme_err("Scan Timeout:Sending abort to Firmware ID %d session %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5045 | scan_id, scan_cmd->sessionId); |
| 5046 | msg_len = (uint16_t)(sizeof(tSirSmeScanAbortReq)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 5047 | msg = qdf_mem_malloc(msg_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5048 | if (NULL == msg) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 5049 | sme_err("Failed to alloc memory for SmeScanAbortReq"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5050 | return; |
| 5051 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5052 | msg->type = eWNI_SME_SCAN_ABORT_IND; |
| 5053 | msg->msgLen = msg_len; |
| 5054 | msg->sessionId = scan_cmd->sessionId; |
| 5055 | msg->scan_id = scan_id; |
Rajeev Kumar | d138ac5 | 2017-01-30 18:38:37 -0800 | [diff] [blame] | 5056 | status = umac_send_mb_message_to_mac(msg); |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 5057 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 5058 | sme_err("Failed to post message to LIM"); |
Nishank Aggarwal | 778bf5d | 2017-04-01 17:07:56 +0530 | [diff] [blame] | 5059 | |
Krunal Soni | 81f068c | 2017-02-23 19:51:55 -0800 | [diff] [blame] | 5060 | scan_cmd->u.scanCmd.status = eCSR_SCAN_FAILURE; |
| 5061 | csr_release_command(mac_ctx, scan_cmd); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5062 | } |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5063 | |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5064 | static enum wlan_auth_type csr_covert_auth_type_new(eCsrAuthType auth) |
| 5065 | { |
| 5066 | switch (auth) { |
| 5067 | case eCSR_AUTH_TYPE_NONE: |
| 5068 | case eCSR_AUTH_TYPE_OPEN_SYSTEM: |
| 5069 | return WLAN_AUTH_TYPE_OPEN_SYSTEM; |
| 5070 | case eCSR_AUTH_TYPE_SHARED_KEY: |
| 5071 | return WLAN_AUTH_TYPE_SHARED_KEY; |
| 5072 | case eCSR_AUTH_TYPE_AUTOSWITCH: |
| 5073 | return WLAN_AUTH_TYPE_AUTOSWITCH; |
| 5074 | case eCSR_AUTH_TYPE_WPA: |
| 5075 | return WLAN_AUTH_TYPE_WPA; |
| 5076 | case eCSR_AUTH_TYPE_WPA_PSK: |
| 5077 | return WLAN_AUTH_TYPE_WPA_PSK; |
| 5078 | case eCSR_AUTH_TYPE_WPA_NONE: |
| 5079 | return WLAN_AUTH_TYPE_WPA_NONE; |
| 5080 | case eCSR_AUTH_TYPE_RSN: |
| 5081 | return WLAN_AUTH_TYPE_RSN; |
| 5082 | case eCSR_AUTH_TYPE_RSN_PSK: |
| 5083 | return WLAN_AUTH_TYPE_RSN_PSK; |
| 5084 | case eCSR_AUTH_TYPE_FT_RSN: |
| 5085 | return WLAN_AUTH_TYPE_FT_RSN; |
| 5086 | case eCSR_AUTH_TYPE_FT_RSN_PSK: |
| 5087 | return WLAN_AUTH_TYPE_FT_RSN_PSK; |
| 5088 | case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE: |
| 5089 | return WLAN_AUTH_TYPE_WAPI_WAI_CERTIFICATE; |
| 5090 | case eCSR_AUTH_TYPE_WAPI_WAI_PSK: |
| 5091 | return WLAN_AUTH_TYPE_WAPI_WAI_PSK; |
| 5092 | case eCSR_AUTH_TYPE_CCKM_WPA: |
| 5093 | return WLAN_AUTH_TYPE_CCKM_WPA; |
| 5094 | case eCSR_AUTH_TYPE_CCKM_RSN: |
| 5095 | return WLAN_AUTH_TYPE_CCKM_RSN; |
| 5096 | case eCSR_AUTH_TYPE_RSN_PSK_SHA256: |
| 5097 | return WLAN_AUTH_TYPE_RSN_PSK_SHA256; |
| 5098 | case eCSR_AUTH_TYPE_RSN_8021X_SHA256: |
| 5099 | return WLAN_AUTH_TYPE_RSN_8021X_SHA256; |
Sridhar Selvaraj | 6cf642f | 2017-08-21 14:28:10 +0530 | [diff] [blame] | 5100 | case eCSR_AUTH_TYPE_FILS_SHA256: |
| 5101 | return WLAN_AUTH_TYPE_FILS_SHA256; |
| 5102 | case eCSR_AUTH_TYPE_FILS_SHA384: |
| 5103 | return WLAN_AUTH_TYPE_FILS_SHA384; |
| 5104 | case eCSR_AUTH_TYPE_FT_FILS_SHA256: |
| 5105 | return WLAN_AUTH_TYPE_FT_FILS_SHA256; |
| 5106 | case eCSR_AUTH_TYPE_FT_FILS_SHA384: |
| 5107 | return WLAN_AUTH_TYPE_FT_FILS_SHA384; |
Abhishek Singh | 02cb9e0 | 2017-08-30 17:39:50 +0530 | [diff] [blame] | 5108 | case eCSR_AUTH_TYPE_DPP_RSN: |
| 5109 | return WLAN_AUTH_TYPE_DPP_RSN; |
Padma, Santhosh Kumar | c69ce07 | 2017-11-06 18:21:05 +0530 | [diff] [blame] | 5110 | case eCSR_AUTH_TYPE_OWE: |
| 5111 | return WLAN_AUTH_TYPE_OWE; |
Padma, Santhosh Kumar | e587a5c | 2017-12-21 12:44:46 +0530 | [diff] [blame] | 5112 | case eCSR_AUTH_TYPE_SUITEB_EAP_SHA256: |
| 5113 | return WLAN_AUTH_TYPE_SUITEB_EAP_SHA256; |
| 5114 | case eCSR_AUTH_TYPE_SUITEB_EAP_SHA384: |
| 5115 | return WLAN_AUTH_TYPE_SUITEB_EAP_SHA384; |
Padma, Santhosh Kumar | 07eb80b | 2017-07-05 16:10:06 +0530 | [diff] [blame^] | 5116 | case eCSR_AUTH_TYPE_SAE: |
| 5117 | return WLAN_AUTH_TYPE_SAE; |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5118 | case eCSR_NUM_OF_SUPPORT_AUTH_TYPE: |
| 5119 | default: |
| 5120 | return WLAN_AUTH_TYPE_OPEN_SYSTEM; |
| 5121 | } |
| 5122 | } |
| 5123 | |
| 5124 | static eCsrAuthType csr_covert_auth_type_old(enum wlan_auth_type auth) |
| 5125 | { |
| 5126 | switch (auth) { |
| 5127 | case WLAN_AUTH_TYPE_OPEN_SYSTEM: |
| 5128 | return eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 5129 | case WLAN_AUTH_TYPE_SHARED_KEY: |
| 5130 | return eCSR_AUTH_TYPE_SHARED_KEY; |
| 5131 | case WLAN_AUTH_TYPE_AUTOSWITCH: |
| 5132 | return eCSR_AUTH_TYPE_AUTOSWITCH; |
| 5133 | case WLAN_AUTH_TYPE_WPA: |
| 5134 | return eCSR_AUTH_TYPE_WPA; |
| 5135 | case WLAN_AUTH_TYPE_WPA_PSK: |
| 5136 | return eCSR_AUTH_TYPE_WPA_PSK; |
| 5137 | case WLAN_AUTH_TYPE_WPA_NONE: |
| 5138 | return eCSR_AUTH_TYPE_WPA_NONE; |
| 5139 | case WLAN_AUTH_TYPE_RSN: |
| 5140 | return eCSR_AUTH_TYPE_RSN; |
| 5141 | case WLAN_AUTH_TYPE_RSN_PSK: |
| 5142 | return eCSR_AUTH_TYPE_RSN_PSK; |
| 5143 | case WLAN_AUTH_TYPE_FT_RSN: |
| 5144 | return eCSR_AUTH_TYPE_FT_RSN; |
| 5145 | case WLAN_AUTH_TYPE_FT_RSN_PSK: |
| 5146 | return eCSR_AUTH_TYPE_FT_RSN_PSK; |
| 5147 | case WLAN_AUTH_TYPE_WAPI_WAI_CERTIFICATE: |
| 5148 | return eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE; |
| 5149 | case WLAN_AUTH_TYPE_WAPI_WAI_PSK: |
| 5150 | return eCSR_AUTH_TYPE_WAPI_WAI_PSK; |
| 5151 | case WLAN_AUTH_TYPE_CCKM_WPA: |
| 5152 | return eCSR_AUTH_TYPE_CCKM_WPA; |
| 5153 | case WLAN_AUTH_TYPE_CCKM_RSN: |
| 5154 | return eCSR_AUTH_TYPE_CCKM_RSN; |
| 5155 | case WLAN_AUTH_TYPE_RSN_PSK_SHA256: |
| 5156 | return eCSR_AUTH_TYPE_RSN_PSK_SHA256; |
| 5157 | case WLAN_AUTH_TYPE_RSN_8021X_SHA256: |
| 5158 | return eCSR_AUTH_TYPE_RSN_8021X_SHA256; |
Sridhar Selvaraj | 6cf642f | 2017-08-21 14:28:10 +0530 | [diff] [blame] | 5159 | case WLAN_AUTH_TYPE_FILS_SHA256: |
| 5160 | return eCSR_AUTH_TYPE_FILS_SHA256; |
| 5161 | case WLAN_AUTH_TYPE_FILS_SHA384: |
| 5162 | return eCSR_AUTH_TYPE_FILS_SHA384; |
| 5163 | case WLAN_AUTH_TYPE_FT_FILS_SHA256: |
| 5164 | return eCSR_AUTH_TYPE_FT_FILS_SHA256; |
| 5165 | case WLAN_AUTH_TYPE_FT_FILS_SHA384: |
| 5166 | return eCSR_AUTH_TYPE_FT_FILS_SHA384; |
Abhishek Singh | 02cb9e0 | 2017-08-30 17:39:50 +0530 | [diff] [blame] | 5167 | case WLAN_AUTH_TYPE_DPP_RSN: |
| 5168 | return eCSR_AUTH_TYPE_DPP_RSN; |
Padma, Santhosh Kumar | c69ce07 | 2017-11-06 18:21:05 +0530 | [diff] [blame] | 5169 | case WLAN_AUTH_TYPE_OWE: |
| 5170 | return eCSR_AUTH_TYPE_OWE; |
Padma, Santhosh Kumar | e587a5c | 2017-12-21 12:44:46 +0530 | [diff] [blame] | 5171 | case WLAN_AUTH_TYPE_SUITEB_EAP_SHA256: |
| 5172 | return eCSR_AUTH_TYPE_SUITEB_EAP_SHA256; |
| 5173 | case WLAN_AUTH_TYPE_SUITEB_EAP_SHA384: |
| 5174 | return eCSR_AUTH_TYPE_SUITEB_EAP_SHA384; |
Padma, Santhosh Kumar | 07eb80b | 2017-07-05 16:10:06 +0530 | [diff] [blame^] | 5175 | case WLAN_AUTH_TYPE_SAE: |
| 5176 | return eCSR_AUTH_TYPE_SAE; |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5177 | case WLAN_NUM_OF_SUPPORT_AUTH_TYPE: |
| 5178 | default: |
| 5179 | return eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 5180 | } |
| 5181 | } |
| 5182 | |
| 5183 | static enum wlan_enc_type csr_covert_enc_type_new(eCsrEncryptionType enc) |
| 5184 | { |
| 5185 | switch (enc) { |
| 5186 | case eCSR_ENCRYPT_TYPE_NONE: |
| 5187 | return WLAN_ENCRYPT_TYPE_NONE; |
| 5188 | case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY: |
| 5189 | return WLAN_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 5190 | case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY: |
| 5191 | return WLAN_ENCRYPT_TYPE_WEP104_STATICKEY; |
| 5192 | case eCSR_ENCRYPT_TYPE_WEP40: |
| 5193 | return WLAN_ENCRYPT_TYPE_WEP40; |
| 5194 | case eCSR_ENCRYPT_TYPE_WEP104: |
| 5195 | return WLAN_ENCRYPT_TYPE_WEP104; |
| 5196 | case eCSR_ENCRYPT_TYPE_TKIP: |
| 5197 | return WLAN_ENCRYPT_TYPE_TKIP; |
| 5198 | case eCSR_ENCRYPT_TYPE_AES: |
| 5199 | return WLAN_ENCRYPT_TYPE_AES; |
| 5200 | case eCSR_ENCRYPT_TYPE_WPI: |
| 5201 | return WLAN_ENCRYPT_TYPE_WPI; |
| 5202 | case eCSR_ENCRYPT_TYPE_KRK: |
| 5203 | return WLAN_ENCRYPT_TYPE_KRK; |
| 5204 | case eCSR_ENCRYPT_TYPE_BTK: |
| 5205 | return WLAN_ENCRYPT_TYPE_BTK; |
| 5206 | case eCSR_ENCRYPT_TYPE_AES_CMAC: |
| 5207 | return WLAN_ENCRYPT_TYPE_AES_CMAC; |
Mukul Sharma | 05504ac | 2017-06-08 12:35:53 +0530 | [diff] [blame] | 5208 | case eCSR_ENCRYPT_TYPE_AES_GCMP: |
| 5209 | return WLAN_ENCRYPT_TYPE_AES_GCMP; |
| 5210 | case eCSR_ENCRYPT_TYPE_AES_GCMP_256: |
| 5211 | return WLAN_ENCRYPT_TYPE_AES_GCMP_256; |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5212 | case eCSR_ENCRYPT_TYPE_ANY: |
| 5213 | default: |
| 5214 | return WLAN_ENCRYPT_TYPE_NONE; |
| 5215 | } |
| 5216 | } |
| 5217 | |
| 5218 | static eCsrEncryptionType csr_covert_enc_type_old(enum wlan_enc_type enc) |
| 5219 | { |
| 5220 | switch (enc) { |
| 5221 | case WLAN_ENCRYPT_TYPE_NONE: |
| 5222 | return eCSR_ENCRYPT_TYPE_NONE; |
| 5223 | case WLAN_ENCRYPT_TYPE_WEP40_STATICKEY: |
| 5224 | return eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 5225 | case WLAN_ENCRYPT_TYPE_WEP104_STATICKEY: |
| 5226 | return eCSR_ENCRYPT_TYPE_WEP104_STATICKEY; |
| 5227 | case WLAN_ENCRYPT_TYPE_WEP40: |
| 5228 | return eCSR_ENCRYPT_TYPE_WEP40; |
| 5229 | case WLAN_ENCRYPT_TYPE_WEP104: |
| 5230 | return eCSR_ENCRYPT_TYPE_WEP104; |
| 5231 | case WLAN_ENCRYPT_TYPE_TKIP: |
| 5232 | return eCSR_ENCRYPT_TYPE_TKIP; |
| 5233 | case WLAN_ENCRYPT_TYPE_AES: |
| 5234 | return eCSR_ENCRYPT_TYPE_AES; |
| 5235 | case WLAN_ENCRYPT_TYPE_WPI: |
| 5236 | return eCSR_ENCRYPT_TYPE_WPI; |
| 5237 | case WLAN_ENCRYPT_TYPE_KRK: |
| 5238 | return eCSR_ENCRYPT_TYPE_KRK; |
| 5239 | case WLAN_ENCRYPT_TYPE_BTK: |
| 5240 | return eCSR_ENCRYPT_TYPE_BTK; |
| 5241 | case WLAN_ENCRYPT_TYPE_AES_CMAC: |
| 5242 | return eCSR_ENCRYPT_TYPE_AES_CMAC; |
Mukul Sharma | 05504ac | 2017-06-08 12:35:53 +0530 | [diff] [blame] | 5243 | case WLAN_ENCRYPT_TYPE_AES_GCMP: |
| 5244 | return eCSR_ENCRYPT_TYPE_AES_GCMP; |
| 5245 | case WLAN_ENCRYPT_TYPE_AES_GCMP_256: |
| 5246 | return eCSR_ENCRYPT_TYPE_AES_GCMP_256; |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5247 | case WLAN_ENCRYPT_TYPE_ANY: |
| 5248 | default: |
| 5249 | return eCSR_ENCRYPT_TYPE_NONE; |
| 5250 | } |
| 5251 | } |
| 5252 | |
Padma, Santhosh Kumar | 4117d7a | 2017-12-20 17:39:33 +0530 | [diff] [blame] | 5253 | #ifdef WLAN_FEATURE_11W |
| 5254 | /** |
| 5255 | * csr_update_pmf_cap: Updates PMF cap |
| 5256 | * @src_filter: Source filter |
| 5257 | * @dst_filter: Destination filter |
| 5258 | * |
| 5259 | * Return: None |
| 5260 | */ |
| 5261 | static void csr_update_pmf_cap(tCsrScanResultFilter *src_filter, |
| 5262 | struct scan_filter *dst_filter) { |
| 5263 | |
| 5264 | if (src_filter->MFPCapable || src_filter->MFPEnabled) |
| 5265 | dst_filter->pmf_cap = WLAN_PMF_CAPABLE; |
| 5266 | if (src_filter->MFPRequired) |
| 5267 | dst_filter->pmf_cap = WLAN_PMF_REQUIRED; |
| 5268 | } |
| 5269 | #else |
| 5270 | static inline void csr_update_pmf_cap(tCsrScanResultFilter *src_filter, |
| 5271 | struct scan_filter *dst_filter) |
| 5272 | {} |
| 5273 | #endif |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5274 | |
| 5275 | static QDF_STATUS csr_prepare_scan_filter(tpAniSirGlobal mac_ctx, |
| 5276 | tCsrScanResultFilter *pFilter, struct scan_filter *filter) |
| 5277 | { |
| 5278 | int i; |
| 5279 | uint32_t len = 0; |
| 5280 | QDF_STATUS status; |
Tushnim Bhattacharyya | 0c4ad2d | 2017-03-09 15:59:03 -0800 | [diff] [blame] | 5281 | enum policy_mgr_con_mode new_mode; |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5282 | |
| 5283 | filter->num_of_bssid = pFilter->BSSIDs.numOfBSSIDs; |
| 5284 | if (filter->num_of_bssid > WLAN_SCAN_FILTER_NUM_BSSID) |
| 5285 | filter->num_of_bssid = WLAN_SCAN_FILTER_NUM_BSSID; |
| 5286 | for (i = 0; i < filter->num_of_bssid; i++) |
| 5287 | qdf_mem_copy(filter->bssid_list[i].bytes, |
| 5288 | pFilter->BSSIDs.bssid[i].bytes, |
| 5289 | QDF_MAC_ADDR_SIZE); |
| 5290 | |
| 5291 | filter->num_of_ssid = pFilter->SSIDs.numOfSSIDs; |
| 5292 | if (filter->num_of_ssid > WLAN_SCAN_FILTER_NUM_SSID) |
| 5293 | filter->num_of_ssid = WLAN_SCAN_FILTER_NUM_SSID; |
| 5294 | for (i = 0; i < filter->num_of_ssid; i++) { |
| 5295 | filter->ssid_list[i].length = |
| 5296 | pFilter->SSIDs.SSIDList[i].SSID.length; |
| 5297 | qdf_mem_copy(filter->ssid_list[i].ssid, |
| 5298 | pFilter->SSIDs.SSIDList[i].SSID.ssId, |
| 5299 | filter->ssid_list[i].length); |
| 5300 | } |
| 5301 | |
| 5302 | filter->num_of_channels = |
| 5303 | pFilter->ChannelInfo.numOfChannels; |
| 5304 | if (filter->num_of_channels > QDF_MAX_NUM_CHAN) |
| 5305 | filter->num_of_channels = QDF_MAX_NUM_CHAN; |
| 5306 | qdf_mem_copy(filter->channel_list, |
| 5307 | pFilter->ChannelInfo.ChannelList, |
| 5308 | filter->num_of_channels); |
| 5309 | |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 5310 | if (pFilter->realm_check) { |
| 5311 | filter->fils_scan_filter.realm_check = true; |
| 5312 | qdf_mem_copy(filter->fils_scan_filter.fils_realm, |
| 5313 | pFilter->fils_realm, REAM_HASH_LEN); |
| 5314 | } |
| 5315 | |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5316 | filter->num_of_auth = |
| 5317 | pFilter->authType.numEntries; |
| 5318 | if (filter->num_of_auth > WLAN_NUM_OF_SUPPORT_AUTH_TYPE) |
| 5319 | filter->num_of_auth = WLAN_NUM_OF_SUPPORT_AUTH_TYPE; |
| 5320 | for (i = 0; i < filter->num_of_auth; i++) |
| 5321 | filter->auth_type[i] = |
| 5322 | csr_covert_auth_type_new(pFilter->authType.authType[i]); |
| 5323 | filter->num_of_enc_type = |
| 5324 | pFilter->EncryptionType.numEntries; |
| 5325 | if (filter->num_of_enc_type > WLAN_NUM_OF_ENCRYPT_TYPE) |
| 5326 | filter->num_of_enc_type = WLAN_NUM_OF_ENCRYPT_TYPE; |
| 5327 | for (i = 0; i < filter->num_of_enc_type; i++) |
| 5328 | filter->enc_type[i] = |
| 5329 | csr_covert_enc_type_new( |
| 5330 | pFilter->EncryptionType.encryptionType[i]); |
| 5331 | filter->num_of_mc_enc_type = |
| 5332 | pFilter->mcEncryptionType.numEntries; |
| 5333 | if (filter->num_of_mc_enc_type > WLAN_NUM_OF_ENCRYPT_TYPE) |
| 5334 | filter->num_of_mc_enc_type = WLAN_NUM_OF_ENCRYPT_TYPE; |
| 5335 | for (i = 0; i < filter->num_of_mc_enc_type; i++) |
| 5336 | filter->mc_enc_type[i] = |
| 5337 | csr_covert_enc_type_new( |
| 5338 | pFilter->mcEncryptionType.encryptionType[i]); |
| 5339 | |
| 5340 | qdf_mem_copy(filter->country, |
| 5341 | pFilter->countryCode, WNI_CFG_COUNTRY_CODE_LEN); |
| 5342 | |
gaurank kathpalia | 2690098 | 2017-12-19 13:57:48 +0530 | [diff] [blame] | 5343 | if (pFilter->bWPSAssociation || pFilter->bOSENAssociation) |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5344 | filter->ignore_auth_enc_type = true; |
| 5345 | |
| 5346 | filter->rrm_measurement_filter = pFilter->fMeasurement; |
| 5347 | |
| 5348 | filter->mobility_domain = pFilter->MDID.mobilityDomain; |
| 5349 | |
| 5350 | filter->p2p_results = pFilter->p2pResult; |
| 5351 | |
Padma, Santhosh Kumar | 4117d7a | 2017-12-20 17:39:33 +0530 | [diff] [blame] | 5352 | csr_update_pmf_cap(pFilter, filter); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5353 | |
| 5354 | if (pFilter->BSSType == eCSR_BSS_TYPE_INFRASTRUCTURE) |
| 5355 | filter->bss_type = WLAN_TYPE_BSS; |
| 5356 | else if (pFilter->BSSType == eCSR_BSS_TYPE_IBSS || |
| 5357 | pFilter->BSSType == eCSR_BSS_TYPE_START_IBSS) |
| 5358 | filter->bss_type = WLAN_TYPE_IBSS; |
| 5359 | else |
| 5360 | filter->bss_type = WLAN_TYPE_ANY; |
| 5361 | |
| 5362 | filter->dot11_mode = pFilter->phyMode; |
| 5363 | |
gaurank kathpalia | 5efa73b | 2017-12-29 10:55:16 +0530 | [diff] [blame] | 5364 | // enable bss scoring for only STA mode |
| 5365 | if (pFilter->csrPersona == QDF_STA_MODE) |
| 5366 | filter->bss_scoring_required = true; |
| 5367 | else |
| 5368 | filter->bss_scoring_required = false; |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5369 | if (!pFilter->BSSIDs.numOfBSSIDs) { |
Tushnim Bhattacharyya | 0c4ad2d | 2017-03-09 15:59:03 -0800 | [diff] [blame] | 5370 | if (policy_mgr_map_concurrency_mode( |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5371 | &pFilter->csrPersona, &new_mode)) { |
Tushnim Bhattacharyya | 0c4ad2d | 2017-03-09 15:59:03 -0800 | [diff] [blame] | 5372 | status = policy_mgr_get_pcl(mac_ctx->psoc, new_mode, |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5373 | filter->pcl_channel_list, &len, |
Abhishek Singh | b58164a | 2017-07-19 18:47:23 +0530 | [diff] [blame] | 5374 | filter->pcl_weight_list, QDF_MAX_NUM_CHAN); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5375 | filter->num_of_pcl_channels = (uint8_t)len; |
| 5376 | } |
| 5377 | } |
Abhishek Singh | b58164a | 2017-07-19 18:47:23 +0530 | [diff] [blame] | 5378 | qdf_mem_copy(filter->bssid_hint.bytes, |
| 5379 | pFilter->bssid_hint.bytes, |
| 5380 | QDF_MAC_ADDR_SIZE); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5381 | |
| 5382 | return QDF_STATUS_SUCCESS; |
| 5383 | } |
| 5384 | |
Sridhar Selvaraj | a44c19e | 2017-08-21 14:20:20 +0530 | [diff] [blame] | 5385 | #ifdef WLAN_FEATURE_FILS_SK |
| 5386 | /** |
| 5387 | * csr_update_bss_with_fils_data: Fill FILS params in bss desc from scan entry |
| 5388 | * @mac_ctx: mac context |
| 5389 | * @scan_entry: scan entry |
| 5390 | * @bss_descr: bss description |
| 5391 | */ |
| 5392 | static void csr_update_bss_with_fils_data(tpAniSirGlobal mac_ctx, |
| 5393 | struct scan_cache_entry *scan_entry, |
| 5394 | tSirBssDescription *bss_descr) |
| 5395 | { |
Krunal Soni | 35a9453 | 2018-01-09 10:54:31 -0800 | [diff] [blame] | 5396 | tDot11fIEfils_indication fils_indication = {0}; |
Sridhar Selvaraj | a44c19e | 2017-08-21 14:20:20 +0530 | [diff] [blame] | 5397 | struct sir_fils_indication fils_ind; |
| 5398 | |
| 5399 | if (!scan_entry->ie_list.fils_indication) |
| 5400 | return; |
| 5401 | |
| 5402 | dot11f_unpack_ie_fils_indication(mac_ctx, |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 5403 | scan_entry->ie_list.fils_indication + |
| 5404 | SIR_FILS_IND_ELEM_OFFSET, |
Sridhar Selvaraj | a44c19e | 2017-08-21 14:20:20 +0530 | [diff] [blame] | 5405 | *(scan_entry->ie_list.fils_indication + 1), |
| 5406 | &fils_indication, false); |
| 5407 | |
| 5408 | update_fils_data(&fils_ind, &fils_indication); |
| 5409 | if (fils_ind.realm_identifier.realm_cnt > SIR_MAX_REALM_COUNT) |
| 5410 | fils_ind.realm_identifier.realm_cnt = SIR_MAX_REALM_COUNT; |
| 5411 | |
| 5412 | bss_descr->fils_info_element.realm_cnt = |
| 5413 | fils_ind.realm_identifier.realm_cnt; |
| 5414 | qdf_mem_copy(bss_descr->fils_info_element.realm, |
| 5415 | fils_ind.realm_identifier.realm, |
| 5416 | bss_descr->fils_info_element.realm_cnt * SIR_REALM_LEN); |
| 5417 | if (fils_ind.cache_identifier.is_present) { |
| 5418 | bss_descr->fils_info_element.is_cache_id_present = true; |
| 5419 | qdf_mem_copy(bss_descr->fils_info_element.cache_id, |
| 5420 | fils_ind.cache_identifier.identifier, CACHE_ID_LEN); |
| 5421 | } |
| 5422 | if (fils_ind.is_fils_sk_auth_supported) |
| 5423 | bss_descr->fils_info_element.is_fils_sk_supported = true; |
| 5424 | } |
| 5425 | #else |
| 5426 | static void csr_update_bss_with_fils_data(tpAniSirGlobal mac_ctx, |
| 5427 | struct scan_cache_entry *scan_entry, |
| 5428 | tSirBssDescription *bss_descr) |
| 5429 | { } |
| 5430 | #endif |
| 5431 | |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5432 | static QDF_STATUS csr_fill_bss_from_scan_entry(tpAniSirGlobal mac_ctx, |
| 5433 | struct scan_cache_entry *scan_entry, |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 5434 | struct tag_csrscan_result **p_result) |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5435 | { |
| 5436 | tDot11fBeaconIEs *bcn_ies; |
| 5437 | tSirBssDescription *bss_desc; |
| 5438 | tCsrScanResultInfo *result_info; |
| 5439 | tpSirMacMgmtHdr hdr; |
| 5440 | uint8_t *ie_ptr; |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 5441 | struct tag_csrscan_result *bss; |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5442 | uint32_t bss_len, alloc_len, ie_len; |
| 5443 | QDF_STATUS status; |
| 5444 | |
| 5445 | ie_len = util_scan_entry_ie_len(scan_entry); |
| 5446 | ie_ptr = util_scan_entry_ie_data(scan_entry); |
| 5447 | |
| 5448 | hdr = (tpSirMacMgmtHdr)scan_entry->raw_frame.ptr; |
| 5449 | |
| 5450 | bss_len = (uint16_t)(offsetof(tSirBssDescription, |
| 5451 | ieFields[0]) + ie_len); |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 5452 | alloc_len = sizeof(struct tag_csrscan_result) + bss_len; |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5453 | bss = qdf_mem_malloc(alloc_len); |
| 5454 | |
| 5455 | if (!bss) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 5456 | sme_err("could not allocate bss"); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5457 | return QDF_STATUS_E_NOMEM; |
| 5458 | } |
| 5459 | |
| 5460 | bss->AgingCount = |
| 5461 | (int32_t) mac_ctx->roam.configParam.agingCount; |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5462 | bss->ucEncryptionType = |
| 5463 | csr_covert_enc_type_old(scan_entry->neg_sec_info.uc_enc); |
| 5464 | bss->mcEncryptionType = |
| 5465 | csr_covert_enc_type_old(scan_entry->neg_sec_info.mc_enc); |
| 5466 | bss->authType = |
| 5467 | csr_covert_auth_type_old(scan_entry->neg_sec_info.auth_type); |
Abhishek Singh | b58164a | 2017-07-19 18:47:23 +0530 | [diff] [blame] | 5468 | bss->bss_score = scan_entry->bss_score; |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5469 | |
| 5470 | result_info = &bss->Result; |
| 5471 | result_info->ssId.length = scan_entry->ssid.length; |
| 5472 | qdf_mem_copy(result_info->ssId.ssId, |
| 5473 | scan_entry->ssid.ssid, |
| 5474 | result_info->ssId.length); |
| 5475 | result_info->timer = scan_entry->hidden_ssid_timestamp; |
| 5476 | |
| 5477 | bss_desc = &result_info->BssDescriptor; |
| 5478 | |
| 5479 | bss_desc->length = (uint16_t) (offsetof(tSirBssDescription, |
| 5480 | ieFields[0]) - sizeof(bss_desc->length) + ie_len); |
| 5481 | |
| 5482 | qdf_mem_copy(bss_desc->bssId, |
| 5483 | scan_entry->bssid.bytes, |
| 5484 | QDF_MAC_ADDR_SIZE); |
Sandeep Puligilla | 1fcdb77 | 2017-02-22 21:14:59 -0800 | [diff] [blame] | 5485 | bss_desc->scansystimensec = scan_entry->scan_entry_time; |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5486 | qdf_mem_copy(bss_desc->timeStamp, |
| 5487 | scan_entry->tsf_info.data, 8); |
| 5488 | |
| 5489 | bss_desc->beaconInterval = scan_entry->bcn_int; |
| 5490 | bss_desc->capabilityInfo = scan_entry->cap_info.value; |
| 5491 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 5492 | if (WLAN_REG_IS_5GHZ_CH(scan_entry->channel.chan_idx)) |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5493 | bss_desc->nwType = eSIR_11A_NW_TYPE; |
| 5494 | else if (scan_entry->phy_mode == WLAN_PHYMODE_11B) |
| 5495 | bss_desc->nwType = eSIR_11B_NW_TYPE; |
| 5496 | else |
| 5497 | bss_desc->nwType = eSIR_11G_NW_TYPE; |
| 5498 | |
| 5499 | bss_desc->rssi = scan_entry->rssi_raw; |
| 5500 | bss_desc->rssi_raw = scan_entry->rssi_raw; |
| 5501 | |
| 5502 | /* channelId what peer sent in beacon/probersp. */ |
| 5503 | bss_desc->channelId = |
| 5504 | scan_entry->channel.chan_idx; |
| 5505 | /* channelId on which we are parked at. */ |
| 5506 | /* used only in scan case. */ |
| 5507 | bss_desc->channelIdSelf = |
| 5508 | scan_entry->channel.chan_idx; |
| 5509 | bss_desc->rx_channel = bss_desc->channelIdSelf; |
| 5510 | bss_desc->received_time = |
| 5511 | scan_entry->scan_entry_time; |
| 5512 | bss_desc->startTSF[0] = |
| 5513 | mac_ctx->rrm.rrmPEContext.startTSF[0]; |
| 5514 | bss_desc->startTSF[1] = |
| 5515 | mac_ctx->rrm.rrmPEContext.startTSF[1]; |
| 5516 | bss_desc->parentTSF = |
| 5517 | scan_entry->rrm_parent_tsf; |
| 5518 | bss_desc->fProbeRsp = (scan_entry->frm_subtype == |
| 5519 | IEEE80211_FC0_SUBTYPE_PROBE_RESP); |
| 5520 | bss_desc->seq_ctrl = hdr->seqControl; |
| 5521 | bss_desc->tsf_delta = scan_entry->tsf_delta; |
| 5522 | |
| 5523 | qdf_mem_copy((uint8_t *) &bss_desc->ieFields, |
| 5524 | ie_ptr, ie_len); |
| 5525 | |
| 5526 | status = csr_get_parsed_bss_description_ies(mac_ctx, |
| 5527 | bss_desc, &bcn_ies); |
| 5528 | if (QDF_IS_STATUS_ERROR(status)) { |
| 5529 | qdf_mem_free(bss); |
| 5530 | return status; |
| 5531 | } |
| 5532 | result_info->pvIes = bcn_ies; |
| 5533 | |
| 5534 | if (bcn_ies->MobilityDomain.present) { |
| 5535 | bss_desc->mdiePresent = true; |
| 5536 | qdf_mem_copy((uint8_t *)&(bss_desc->mdie[0]), |
| 5537 | (uint8_t *)&(bcn_ies->MobilityDomain.MDID), |
| 5538 | sizeof(uint16_t)); |
| 5539 | bss_desc->mdie[2] = |
| 5540 | ((bcn_ies->MobilityDomain.overDSCap << 0) | |
| 5541 | (bcn_ies->MobilityDomain.resourceReqCap << 1)); |
| 5542 | } |
| 5543 | #ifdef FEATURE_WLAN_ESE |
| 5544 | if (bcn_ies->QBSSLoad.present) { |
| 5545 | bss_desc->QBSSLoad_present = true; |
| 5546 | bss_desc->QBSSLoad_avail = |
| 5547 | bcn_ies->QBSSLoad.avail; |
| 5548 | } |
| 5549 | #endif |
Sridhar Selvaraj | a44c19e | 2017-08-21 14:20:20 +0530 | [diff] [blame] | 5550 | csr_update_bss_with_fils_data(mac_ctx, scan_entry, bss_desc); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5551 | if (scan_entry->alt_wcn_ie.ptr) { |
| 5552 | bss_desc->WscIeLen = scan_entry->alt_wcn_ie.len; |
| 5553 | qdf_mem_copy(bss_desc->WscIeProbeRsp, |
| 5554 | scan_entry->alt_wcn_ie.ptr, |
| 5555 | scan_entry->alt_wcn_ie.len); |
| 5556 | } |
| 5557 | |
| 5558 | *p_result = bss; |
| 5559 | return QDF_STATUS_SUCCESS; |
| 5560 | } |
| 5561 | |
| 5562 | static QDF_STATUS csr_parse_scan_list(tpAniSirGlobal mac_ctx, |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 5563 | struct scan_result_list *ret_list, |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5564 | qdf_list_t *scan_list) |
| 5565 | { |
| 5566 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 5567 | struct tag_csrscan_result *pResult = NULL; |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5568 | struct scan_cache_node *cur_node = NULL; |
| 5569 | struct scan_cache_node *next_node = NULL; |
| 5570 | |
| 5571 | status = |
| 5572 | qdf_list_peek_front(scan_list, |
| 5573 | (qdf_list_node_t **) &cur_node); |
| 5574 | |
| 5575 | while (cur_node) { |
| 5576 | qdf_list_peek_next( |
| 5577 | scan_list, |
| 5578 | (qdf_list_node_t *) cur_node, |
| 5579 | (qdf_list_node_t **) &next_node); |
| 5580 | status = csr_fill_bss_from_scan_entry(mac_ctx, |
| 5581 | cur_node->entry, &pResult); |
| 5582 | if (QDF_IS_STATUS_ERROR(status)) |
| 5583 | return status; |
| 5584 | if (pResult) |
| 5585 | csr_ll_insert_tail(&ret_list->List, &pResult->Link, |
| 5586 | LL_ACCESS_NOLOCK); |
| 5587 | cur_node = next_node; |
| 5588 | next_node = NULL; |
| 5589 | } |
| 5590 | |
| 5591 | return status; |
| 5592 | } |
Abhishek Singh | f3756fc | 2017-06-28 16:04:06 +0530 | [diff] [blame] | 5593 | |
| 5594 | /** |
| 5595 | * csr_remove_ap_due_to_rssi() - check if bss is present in |
| 5596 | * list of BSSID which rejected Assoc due to RSSI |
| 5597 | * @list: rssi based rejected BSS list |
| 5598 | * @bss_descr: pointer to bss description |
| 5599 | * |
| 5600 | * Check if the time interval indicated in last Assoc reject |
| 5601 | * has expired OR rssi has improved by margin indicated |
| 5602 | * in last Assoc reject. If any of the condition match remove |
| 5603 | * the AP from the avoid list, else do not try to conenct |
| 5604 | * to the AP |
| 5605 | * |
| 5606 | * Return: true if connection cannot be tried with AP else false |
| 5607 | */ |
| 5608 | static bool csr_remove_ap_due_to_rssi(qdf_list_t *list, |
| 5609 | tSirBssDescription *bss_descr) |
| 5610 | { |
| 5611 | QDF_STATUS status; |
| 5612 | struct sir_rssi_disallow_lst *cur_node = NULL; |
| 5613 | qdf_list_node_t *cur_lst = NULL, *next_lst = NULL; |
| 5614 | qdf_time_t cur_time; |
| 5615 | uint32_t time_diff; |
| 5616 | |
| 5617 | if (!qdf_list_size(list)) |
| 5618 | return false; |
| 5619 | |
| 5620 | cur_time = qdf_do_div(qdf_get_monotonic_boottime(), |
| 5621 | QDF_MC_TIMER_TO_MS_UNIT); |
| 5622 | |
| 5623 | qdf_list_peek_front(list, &cur_lst); |
| 5624 | while (cur_lst) { |
| 5625 | cur_node = qdf_container_of(cur_lst, |
| 5626 | struct sir_rssi_disallow_lst, node); |
| 5627 | |
| 5628 | qdf_list_peek_next(list, cur_lst, &next_lst); |
| 5629 | |
| 5630 | time_diff = cur_time - cur_node->time_during_rejection; |
| 5631 | if ((time_diff > cur_node->retry_delay)) { |
| 5632 | sme_debug("Remove %pM as time diff %d is greater retry delay %d", |
| 5633 | cur_node->bssid.bytes, time_diff, |
| 5634 | cur_node->retry_delay); |
| 5635 | status = qdf_list_remove_node(list, cur_lst); |
| 5636 | if (QDF_IS_STATUS_SUCCESS(status)) |
| 5637 | qdf_mem_free(cur_node); |
| 5638 | cur_lst = next_lst; |
| 5639 | next_lst = NULL; |
| 5640 | cur_node = NULL; |
| 5641 | continue; |
| 5642 | } |
| 5643 | |
| 5644 | if (!qdf_mem_cmp(cur_node->bssid.bytes, |
| 5645 | bss_descr->bssId, QDF_MAC_ADDR_SIZE)) |
| 5646 | break; |
| 5647 | cur_lst = next_lst; |
| 5648 | next_lst = NULL; |
| 5649 | cur_node = NULL; |
| 5650 | } |
| 5651 | |
| 5652 | if (cur_node) { |
| 5653 | time_diff = cur_time - cur_node->time_during_rejection; |
| 5654 | if (!(time_diff > cur_node->retry_delay || |
| 5655 | bss_descr->rssi_raw >= cur_node->expected_rssi)) { |
| 5656 | sme_err("Don't Attempt to connect %pM (time diff %d retry delay %d rssi %d expected rssi %d)", |
| 5657 | cur_node->bssid.bytes, time_diff, |
| 5658 | cur_node->retry_delay, bss_descr->rssi_raw, |
| 5659 | cur_node->expected_rssi); |
| 5660 | return true; |
| 5661 | } |
| 5662 | sme_debug("Remove %pM as time diff %d is greater retry delay %d or RSSI %d is greater than expected %d", |
| 5663 | cur_node->bssid.bytes, time_diff, |
| 5664 | cur_node->retry_delay, |
| 5665 | bss_descr->rssi_raw, |
| 5666 | cur_node->expected_rssi); |
| 5667 | status = qdf_list_remove_node(list, cur_lst); |
| 5668 | if (QDF_IS_STATUS_SUCCESS(status)) |
| 5669 | qdf_mem_free(cur_node); |
| 5670 | } |
| 5671 | |
| 5672 | return false; |
| 5673 | } |
| 5674 | |
| 5675 | /** |
| 5676 | * csr_filter_ap_due_to_rssi_reject() - filter the AP who has sent |
| 5677 | * assoc reject due to RSSI if condition has not improved |
| 5678 | * @mac_ctx: mac context |
| 5679 | * @scan_list: candidate list for the connection |
| 5680 | * |
| 5681 | * Return: void |
| 5682 | */ |
| 5683 | static void csr_filter_ap_due_to_rssi_reject(tpAniSirGlobal mac_ctx, |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 5684 | struct scan_result_list *scan_list) |
Abhishek Singh | f3756fc | 2017-06-28 16:04:06 +0530 | [diff] [blame] | 5685 | { |
| 5686 | tListElem *cur_entry; |
| 5687 | tListElem *next_entry; |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 5688 | struct tag_csrscan_result *scan_res; |
Abhishek Singh | f3756fc | 2017-06-28 16:04:06 +0530 | [diff] [blame] | 5689 | bool remove; |
| 5690 | |
| 5691 | if (!scan_list || |
| 5692 | !qdf_list_size(&mac_ctx->roam.rssi_disallow_bssid)) |
| 5693 | return; |
| 5694 | |
| 5695 | csr_ll_lock(&scan_list->List); |
| 5696 | |
| 5697 | cur_entry = csr_ll_peek_head(&scan_list->List, LL_ACCESS_NOLOCK); |
| 5698 | while (cur_entry) { |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 5699 | scan_res = GET_BASE_ADDR(cur_entry, struct tag_csrscan_result, |
Abhishek Singh | f3756fc | 2017-06-28 16:04:06 +0530 | [diff] [blame] | 5700 | Link); |
| 5701 | next_entry = csr_ll_next(&scan_list->List, |
| 5702 | cur_entry, LL_ACCESS_NOLOCK); |
| 5703 | remove = csr_remove_ap_due_to_rssi( |
| 5704 | &mac_ctx->roam.rssi_disallow_bssid, |
| 5705 | &scan_res->Result.BssDescriptor); |
| 5706 | if (remove) { |
| 5707 | csr_ll_remove_entry(&scan_list->List, |
| 5708 | cur_entry, LL_ACCESS_NOLOCK); |
| 5709 | csr_free_scan_result_entry(mac_ctx, scan_res); |
| 5710 | } |
| 5711 | cur_entry = next_entry; |
| 5712 | next_entry = NULL; |
| 5713 | } |
| 5714 | csr_ll_unlock(&scan_list->List); |
| 5715 | |
| 5716 | } |
| 5717 | |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5718 | QDF_STATUS csr_scan_get_result(tpAniSirGlobal mac_ctx, |
| 5719 | tCsrScanResultFilter *pFilter, |
| 5720 | tScanResultHandle *results) |
| 5721 | { |
| 5722 | QDF_STATUS status; |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 5723 | struct scan_result_list *ret_list = NULL; |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5724 | qdf_list_t *list = NULL; |
| 5725 | struct scan_filter filter = {0}; |
| 5726 | struct wlan_objmgr_pdev *pdev = NULL; |
| 5727 | |
| 5728 | if (results) |
| 5729 | *results = CSR_INVALID_SCANRESULT_HANDLE; |
| 5730 | |
| 5731 | pdev = wlan_objmgr_get_pdev_by_id(mac_ctx->psoc, |
| 5732 | 0, WLAN_LEGACY_MAC_ID); |
| 5733 | |
| 5734 | if (!pdev) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 5735 | sme_err("pdev is NULL"); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5736 | return QDF_STATUS_E_INVAL; |
| 5737 | } |
| 5738 | |
| 5739 | if (pFilter) { |
| 5740 | status = csr_prepare_scan_filter(mac_ctx, pFilter, &filter); |
| 5741 | if (QDF_IS_STATUS_ERROR(status)) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 5742 | sme_err("Prepare filter failed"); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5743 | goto error; |
| 5744 | } |
| 5745 | } |
| 5746 | |
| 5747 | list = ucfg_scan_get_result(pdev, |
| 5748 | pFilter ? &filter : NULL); |
Krunal Soni | 35a9453 | 2018-01-09 10:54:31 -0800 | [diff] [blame] | 5749 | if (list) |
| 5750 | sme_debug("num_entries %d", qdf_list_size(list)); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5751 | |
Krunal Soni | 35a9453 | 2018-01-09 10:54:31 -0800 | [diff] [blame] | 5752 | if (!list || (list && !qdf_list_size(list))) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 5753 | sme_err("get scan result failed"); |
Abhishek Singh | d1d10b4 | 2017-06-07 16:12:01 +0530 | [diff] [blame] | 5754 | status = QDF_STATUS_E_NULL_VALUE; |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5755 | goto error; |
| 5756 | } |
| 5757 | |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 5758 | ret_list = qdf_mem_malloc(sizeof(struct scan_result_list)); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5759 | if (!ret_list) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 5760 | sme_err("pRetList is NULL"); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5761 | status = QDF_STATUS_E_NOMEM; |
| 5762 | goto error; |
| 5763 | } |
| 5764 | |
| 5765 | csr_ll_open(mac_ctx->hHdd, &ret_list->List); |
| 5766 | ret_list->pCurEntry = NULL; |
| 5767 | status = csr_parse_scan_list(mac_ctx, |
| 5768 | ret_list, list); |
Vignesh Viswanathan | 9dd88d3 | 2017-11-22 14:22:03 +0530 | [diff] [blame] | 5769 | sme_debug("status: %d No of BSS: %d", |
| 5770 | status, csr_ll_count(&ret_list->List)); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5771 | if (QDF_IS_STATUS_ERROR(status) || !results) |
| 5772 | /* Fail or No one wants the result. */ |
| 5773 | csr_scan_result_purge(mac_ctx, (tScanResultHandle) ret_list); |
| 5774 | else { |
Abhishek Singh | f3756fc | 2017-06-28 16:04:06 +0530 | [diff] [blame] | 5775 | if (pFilter) |
| 5776 | csr_filter_ap_due_to_rssi_reject(mac_ctx, ret_list); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5777 | if (!csr_ll_count(&ret_list->List)) { |
| 5778 | /* This mean that there is no match */ |
| 5779 | csr_ll_close(&ret_list->List); |
| 5780 | qdf_mem_free(ret_list); |
| 5781 | status = QDF_STATUS_E_NULL_VALUE; |
| 5782 | } else if (results) { |
| 5783 | *results = ret_list; |
| 5784 | } |
| 5785 | } |
| 5786 | |
| 5787 | error: |
| 5788 | if (list) |
| 5789 | ucfg_scan_purge_results(list); |
| 5790 | if (pdev) |
| 5791 | wlan_objmgr_pdev_release_ref(pdev, WLAN_LEGACY_MAC_ID); |
| 5792 | |
| 5793 | return status; |
| 5794 | } |
| 5795 | |
Vignesh Viswanathan | 9dd88d3 | 2017-11-22 14:22:03 +0530 | [diff] [blame] | 5796 | QDF_STATUS csr_scan_get_result_for_bssid(tpAniSirGlobal mac_ctx, |
| 5797 | struct qdf_mac_addr *bssid, |
| 5798 | tCsrScanResultInfo *res) |
| 5799 | { |
| 5800 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
| 5801 | tCsrScanResultFilter *scan_filter = NULL; |
| 5802 | tScanResultHandle filtered_scan_result = NULL; |
| 5803 | tCsrScanResultInfo *scan_result; |
| 5804 | |
| 5805 | if (!mac_ctx) { |
| 5806 | QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, |
| 5807 | FL("mac_ctx is NULL")); |
| 5808 | return QDF_STATUS_E_FAILURE; |
| 5809 | } |
| 5810 | |
| 5811 | scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter)); |
| 5812 | if (!scan_filter) { |
| 5813 | sme_err("Failed to allocated memory for scan_filter"); |
| 5814 | return QDF_STATUS_E_NOMEM; |
| 5815 | } |
| 5816 | |
Krunal Soni | 3fa80e2 | 2018-01-09 14:16:02 -0800 | [diff] [blame] | 5817 | scan_filter->BSSIDs.bssid = qdf_mem_malloc(sizeof(*bssid)); |
Vignesh Viswanathan | 9dd88d3 | 2017-11-22 14:22:03 +0530 | [diff] [blame] | 5818 | if (!scan_filter->BSSIDs.bssid) { |
| 5819 | sme_err("Failed to allocate memory for BSSIDs"); |
| 5820 | status = QDF_STATUS_E_FAILURE; |
| 5821 | goto free_filter; |
| 5822 | } |
| 5823 | |
| 5824 | scan_filter->BSSIDs.numOfBSSIDs = 1; |
Krunal Soni | 3fa80e2 | 2018-01-09 14:16:02 -0800 | [diff] [blame] | 5825 | qdf_mem_copy(scan_filter->BSSIDs.bssid, bssid, sizeof(*bssid)); |
Vignesh Viswanathan | 9dd88d3 | 2017-11-22 14:22:03 +0530 | [diff] [blame] | 5826 | |
| 5827 | status = csr_scan_get_result(mac_ctx, scan_filter, |
| 5828 | &filtered_scan_result); |
| 5829 | |
| 5830 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 5831 | sme_err("Failed to get scan result"); |
| 5832 | goto free_filter; |
| 5833 | } |
| 5834 | |
| 5835 | scan_result = csr_scan_result_get_first(mac_ctx, filtered_scan_result); |
| 5836 | |
| 5837 | if (scan_result) { |
| 5838 | res->pvIes = NULL; |
| 5839 | res->ssId.length = scan_result->ssId.length; |
| 5840 | qdf_mem_copy(&res->ssId.ssId, &scan_result->ssId.ssId, |
| 5841 | res->ssId.length); |
| 5842 | res->timer = scan_result->timer; |
| 5843 | qdf_mem_copy(&res->BssDescriptor, &scan_result->BssDescriptor, |
| 5844 | sizeof(tSirBssDescription)); |
| 5845 | status = QDF_STATUS_SUCCESS; |
| 5846 | } else { |
| 5847 | status = QDF_STATUS_E_FAILURE; |
| 5848 | } |
| 5849 | |
| 5850 | csr_scan_result_purge(mac_ctx, filtered_scan_result); |
| 5851 | |
| 5852 | free_filter: |
| 5853 | csr_free_scan_filter(mac_ctx, scan_filter); |
| 5854 | if (scan_filter) |
| 5855 | qdf_mem_free(scan_filter); |
| 5856 | |
| 5857 | return status; |
| 5858 | } |
| 5859 | |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5860 | static inline QDF_STATUS |
| 5861 | csr_flush_scan_results(tpAniSirGlobal mac_ctx, |
| 5862 | struct scan_filter *filter) |
| 5863 | { |
| 5864 | struct wlan_objmgr_pdev *pdev = NULL; |
| 5865 | QDF_STATUS status; |
| 5866 | |
| 5867 | pdev = wlan_objmgr_get_pdev_by_id(mac_ctx->psoc, |
| 5868 | 0, WLAN_LEGACY_MAC_ID); |
| 5869 | if (!pdev) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 5870 | sme_err("pdev is NULL"); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5871 | return QDF_STATUS_E_INVAL; |
| 5872 | } |
| 5873 | status = ucfg_scan_flush_results(pdev, filter); |
| 5874 | |
| 5875 | wlan_objmgr_pdev_release_ref(pdev, WLAN_LEGACY_MAC_ID); |
| 5876 | return status; |
| 5877 | } |
| 5878 | |
| 5879 | QDF_STATUS csr_scan_flush_result(tpAniSirGlobal mac_ctx) |
| 5880 | { |
| 5881 | |
| 5882 | if (csr_scan_flush_denied(mac_ctx)) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 5883 | sme_err("scan flush denied in roam state"); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5884 | return QDF_STATUS_E_FAILURE; |
| 5885 | } |
| 5886 | |
| 5887 | return csr_flush_scan_results(mac_ctx, NULL); |
| 5888 | } |
| 5889 | |
| 5890 | QDF_STATUS csr_scan_flush_selective_result(tpAniSirGlobal mac_ctx, |
| 5891 | bool flush_p2p) |
| 5892 | { |
| 5893 | struct scan_filter filter = {0}; |
| 5894 | |
| 5895 | filter.p2p_results = flush_p2p; |
| 5896 | return csr_flush_scan_results(mac_ctx, &filter); |
| 5897 | } |
| 5898 | |
| 5899 | static inline void csr_flush_bssid(tpAniSirGlobal mac_ctx, |
| 5900 | uint8_t *bssid) |
| 5901 | { |
| 5902 | struct scan_filter filter = {0}; |
| 5903 | |
| 5904 | filter.num_of_bssid = 1; |
| 5905 | qdf_mem_copy(filter.bssid_list[0].bytes, |
| 5906 | bssid, QDF_MAC_ADDR_SIZE); |
| 5907 | |
| 5908 | csr_flush_scan_results(mac_ctx, &filter); |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 5909 | sme_debug("Removed BSS entry:%pM", bssid); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5910 | } |
| 5911 | |
| 5912 | void csr_scan_flush_bss_entry(tpAniSirGlobal mac_ctx, |
| 5913 | tpSmeCsaOffloadInd csa_off_ind) |
| 5914 | { |
| 5915 | csr_flush_bssid(mac_ctx, |
| 5916 | csa_off_ind->bssid.bytes); |
| 5917 | } |
| 5918 | |
| 5919 | void csr_remove_bssid_from_scan_list(tpAniSirGlobal mac_ctx, |
| 5920 | tSirMacAddr bssid) |
| 5921 | { |
| 5922 | csr_flush_bssid(mac_ctx, bssid); |
| 5923 | } |
| 5924 | |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5925 | QDF_STATUS csr_scan_process_single_bssdescr(tpAniSirGlobal mac_ctx, |
| 5926 | tSirBssDescription *bssdescr, |
| 5927 | uint32_t scan_id, uint32_t flags) |
| 5928 | { |
| 5929 | /* Not needed now as scan module handle this*/ |
| 5930 | return QDF_STATUS_SUCCESS; |
| 5931 | } |
| 5932 | |
| 5933 | void csr_init_occupied_channels_list(tpAniSirGlobal mac_ctx, |
| 5934 | uint8_t sessionId) |
| 5935 | { |
| 5936 | tScanResultHandle results; |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 5937 | struct scan_result_list *scan_list = NULL; |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5938 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
| 5939 | tListElem *scan_entry = NULL; |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 5940 | struct tag_csrscan_result *bss_desc = NULL; |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5941 | tDot11fBeaconIEs *ie_ptr = NULL; |
| 5942 | tpCsrNeighborRoamControlInfo neighbor_roam_info = |
| 5943 | &mac_ctx->roam.neighborRoamInfo[sessionId]; |
| 5944 | |
| 5945 | if (neighbor_roam_info->cfgParams.channelInfo.numOfChannels) { |
| 5946 | /* |
| 5947 | * Ini file contains neighbor scan channel list, hence NO need |
| 5948 | * to build occupied channel list" |
| 5949 | */ |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 5950 | sme_debug("Ini contains neighbor scan ch list"); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5951 | return; |
| 5952 | } |
| 5953 | |
| 5954 | if (!csr_neighbor_roam_is_new_connected_profile(mac_ctx, sessionId)) { |
| 5955 | /* |
| 5956 | * Do not flush occupied list since current roam profile matches |
| 5957 | * previous |
| 5958 | */ |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 5959 | sme_debug("Current roam profile matches prev"); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5960 | return; |
| 5961 | } |
| 5962 | |
| 5963 | /* Empty occupied channels here */ |
| 5964 | mac_ctx->scan.occupiedChannels[sessionId].numChannels = 0; |
| 5965 | mac_ctx->scan.roam_candidate_count[sessionId] = 0; |
| 5966 | |
| 5967 | status = csr_scan_get_result(mac_ctx, NULL, &results); |
| 5968 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 5969 | return; |
| 5970 | scan_list = results; |
| 5971 | csr_ll_lock(&scan_list->List); |
| 5972 | scan_entry = csr_ll_peek_head(&scan_list->List, LL_ACCESS_NOLOCK); |
| 5973 | while (scan_entry) { |
Yeshwanth Sriram Guntuka | 36c0990 | 2017-09-26 11:34:26 +0530 | [diff] [blame] | 5974 | bss_desc = GET_BASE_ADDR(scan_entry, struct tag_csrscan_result, |
| 5975 | Link); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5976 | ie_ptr = (tDot11fBeaconIEs *) (bss_desc->Result.pvIes); |
| 5977 | if (!ie_ptr && !QDF_IS_STATUS_SUCCESS( |
| 5978 | csr_get_parsed_bss_description_ies(mac_ctx, |
Ravi Joshi | b228f09 | 2017-05-04 19:54:45 -0700 | [diff] [blame] | 5979 | &bss_desc->Result.BssDescriptor, &ie_ptr))) { |
| 5980 | /* Pick next bss entry before continuing */ |
| 5981 | scan_entry = csr_ll_next(&scan_list->List, scan_entry, |
| 5982 | LL_ACCESS_NOLOCK); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5983 | continue; |
Ravi Joshi | b228f09 | 2017-05-04 19:54:45 -0700 | [diff] [blame] | 5984 | } |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 5985 | csr_scan_add_to_occupied_channels(mac_ctx, bss_desc, sessionId, |
| 5986 | &mac_ctx->scan.occupiedChannels[sessionId], ie_ptr, |
| 5987 | true); |
| 5988 | /* |
| 5989 | * Free the memory allocated for pIes in |
| 5990 | * csr_get_parsed_bss_description_ies |
| 5991 | */ |
| 5992 | if ((bss_desc->Result.pvIes == NULL) && ie_ptr) |
| 5993 | qdf_mem_free(ie_ptr); |
| 5994 | scan_entry = csr_ll_next(&scan_list->List, scan_entry, |
| 5995 | LL_ACCESS_NOLOCK); |
| 5996 | } |
| 5997 | csr_ll_unlock(&scan_list->List); |
| 5998 | |
| 5999 | csr_scan_result_purge(mac_ctx, scan_list); |
| 6000 | } |
| 6001 | |
| 6002 | /** |
| 6003 | * csr_scan_filter_results: filter scan result based |
| 6004 | * on valid channel list number. |
| 6005 | * @mac_ctx: mac context |
| 6006 | * |
| 6007 | * Get scan result from scan list and Check Scan result channel number |
| 6008 | * with 11d channel list if channel number is found in 11d channel list |
| 6009 | * then do not remove scan result entry from scan list |
| 6010 | * |
| 6011 | * return: QDF Status |
| 6012 | */ |
| 6013 | QDF_STATUS csr_scan_filter_results(tpAniSirGlobal mac_ctx) |
| 6014 | { |
| 6015 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
| 6016 | uint32_t len = sizeof(mac_ctx->roam.validChannelList); |
| 6017 | struct wlan_objmgr_pdev *pdev = NULL; |
| 6018 | |
| 6019 | pdev = wlan_objmgr_get_pdev_by_id(mac_ctx->psoc, |
| 6020 | 0, WLAN_LEGACY_MAC_ID); |
| 6021 | if (!pdev) { |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 6022 | sme_err("pdev is NULL"); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 6023 | return QDF_STATUS_E_INVAL; |
| 6024 | } |
| 6025 | status = csr_get_cfg_valid_channels(mac_ctx, |
| 6026 | mac_ctx->roam.validChannelList, |
| 6027 | &len); |
| 6028 | |
| 6029 | /* Get valid channels list from CFG */ |
| 6030 | if (QDF_IS_STATUS_ERROR(status)) { |
| 6031 | wlan_objmgr_pdev_release_ref(pdev, WLAN_LEGACY_MAC_ID); |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 6032 | sme_err("Failed to get Channel list from CFG"); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 6033 | return status; |
| 6034 | } |
Srinivas Girigowda | a454cfb | 2017-03-17 11:17:28 -0700 | [diff] [blame] | 6035 | sme_debug("No of valid channel %d", len); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 6036 | |
| 6037 | ucfg_scan_filter_valid_channel(pdev, |
| 6038 | mac_ctx->roam.validChannelList, len); |
| 6039 | wlan_objmgr_pdev_release_ref(pdev, WLAN_LEGACY_MAC_ID); |
| 6040 | return QDF_STATUS_SUCCESS; |
| 6041 | } |