Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Abhishek Singh | b3e376c | 2017-01-04 15:27:13 +0530 | [diff] [blame] | 2 | * Copyright (c) 2011-2017 The Linux Foundation. All rights reserved. |
Kiet Lam | 0fb93dd | 2014-02-19 00:32:59 -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. |
Gopichand Nakkala | 92f07d8 | 2013-01-08 21:16:34 -0800 | [diff] [blame] | 20 | */ |
Kiet Lam | 0fb93dd | 2014-02-19 00:32:59 -0800 | [diff] [blame] | 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 | |
Jeff Johnson | 40b59aa | 2013-03-19 14:43:18 -0700 | [diff] [blame] | 28 | /** ------------------------------------------------------------------------- * |
| 29 | ------------------------------------------------------------------------- * |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 30 | |
Jeff Johnson | 40b59aa | 2013-03-19 14:43:18 -0700 | [diff] [blame] | 31 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 32 | \file csrApiScan.c |
Jeff Johnson | 40b59aa | 2013-03-19 14:43:18 -0700 | [diff] [blame] | 33 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 34 | Implementation for the Common Scan interfaces. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 35 | ========================================================================== */ |
| 36 | |
| 37 | #include "aniGlobal.h" |
| 38 | |
| 39 | #include "palApi.h" |
| 40 | #include "csrInsideApi.h" |
| 41 | #include "smeInside.h" |
| 42 | #include "smsDebug.h" |
| 43 | |
| 44 | #include "csrSupport.h" |
| 45 | #include "wlan_qct_tl.h" |
| 46 | |
| 47 | #include "vos_diag_core_log.h" |
| 48 | #include "vos_diag_core_event.h" |
| 49 | |
| 50 | #include "vos_nvitem.h" |
Rajesh Babu Prathipati | 20cdffa | 2014-07-01 22:24:59 +0530 | [diff] [blame] | 51 | #include "vos_memory.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 52 | #include "wlan_qct_wda.h" |
Abhishek Singh | e3fa11f | 2014-05-13 11:11:10 +0530 | [diff] [blame] | 53 | #include "vos_utils.h" |
Jeff Johnson | 40b59aa | 2013-03-19 14:43:18 -0700 | [diff] [blame] | 54 | |
Kiet Lam | d1f3dc8 | 2013-11-05 20:45:04 +0530 | [diff] [blame] | 55 | #define MIN_CHN_TIME_TO_FIND_GO 100 |
| 56 | #define MAX_CHN_TIME_TO_FIND_GO 100 |
| 57 | #define DIRECT_SSID_LEN 7 |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 58 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 59 | |
| 60 | /* Purpose of HIDDEN_TIMER |
| 61 | ** When we remove hidden ssid from the profile i.e., forget the SSID via GUI that SSID shouldn't see in the profile |
| 62 | ** For above requirement we used timer limit, logic is explained below |
| 63 | ** Timer value is initialsed to current time when it receives corresponding probe response of hidden SSID (The probe request is |
| 64 | ** received regularly till SSID in the profile. Once it is removed from profile probe request is not sent.) when we receive probe response |
| 65 | ** for broadcast probe request, during update SSID with saved SSID we will diff current time with saved SSID time if it is greater than 1 min |
| 66 | ** then we are not updating with old one |
| 67 | */ |
| 68 | |
| 69 | #define HIDDEN_TIMER (1*60*1000) |
| 70 | #define CSR_SCAN_RESULT_RSSI_WEIGHT 80 // must be less than 100, represent the persentage of new RSSI |
| 71 | |
| 72 | /*--------------------------------------------------------------------------- |
| 73 | PER filter constant fraction: it is a % |
| 74 | ---------------------------------------------------------------------------*/ |
| 75 | #define CSR_SCAN_PER_FILTER_FRAC 100 |
| 76 | |
| 77 | /*--------------------------------------------------------------------------- |
| 78 | RSSI filter constant fraction: it is a % |
| 79 | ---------------------------------------------------------------------------*/ |
| 80 | #define CSR_SCAN_RSSI_FILTER_FRAC 100 |
| 81 | |
| 82 | /*--------------------------------------------------------------------------- |
| 83 | Convert RSSI into overall score: Since RSSI is in -dBm values, and the |
| 84 | overall needs to be weighted inversely (where greater value means better |
| 85 | system), we convert. |
| 86 | RSSI *cannot* be more than 0xFF or less than 0 for meaningful WLAN operation |
| 87 | ---------------------------------------------------------------------------*/ |
| 88 | #define CSR_SCAN_MAX_SCORE_VAL 0xFF |
| 89 | #define CSR_SCAN_MIN_SCORE_VAL 0x0 |
| 90 | #define CSR_SCAN_HANDOFF_DELTA 10 |
Abhishek Singh | 5deecd1 | 2017-06-12 11:08:40 +0530 | [diff] [blame] | 91 | |
| 92 | #define CSR_PURGE_RSSI_THRESHOLD -70 |
| 93 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 94 | #define MAX_ACTIVE_SCAN_FOR_ONE_CHANNEL 140 |
| 95 | #define MIN_ACTIVE_SCAN_FOR_ONE_CHANNEL 120 |
Selvaraj, Sridhar | 32417ed | 2016-06-22 15:19:12 +0530 | [diff] [blame] | 96 | |
| 97 | #ifndef QCA_WIFI_ISOC |
| 98 | #define MAX_ACTIVE_SCAN_FOR_ONE_CHANNEL_FASTREASSOC 30 |
| 99 | #define MIN_ACTIVE_SCAN_FOR_ONE_CHANNEL_FASTREASSOC 20 |
| 100 | #endif |
| 101 | |
Madan Mohan Koyyalamudi | a53c4dc | 2012-11-13 10:35:42 -0800 | [diff] [blame] | 102 | #define CSR_SCAN_OVERALL_SCORE( rssi ) \ |
| 103 | (( rssi < CSR_SCAN_MAX_SCORE_VAL ) \ |
| 104 | ? (CSR_SCAN_MAX_SCORE_VAL-rssi) : CSR_SCAN_MIN_SCORE_VAL) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 105 | |
| 106 | |
| 107 | #define CSR_SCAN_IS_OVER_BSS_LIMIT(pMac) \ |
| 108 | ( (pMac)->scan.nBssLimit <= (csrLLCount(&(pMac)->scan.scanResultList)) ) |
| 109 | |
Sushant Kaushik | f4e085e | 2014-06-17 16:07:33 +0530 | [diff] [blame] | 110 | #define THIRTY_PERCENT(x) (x*30/100); |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 111 | |
krunal soni | 5f112f0 | 2013-11-25 15:00:11 -0800 | [diff] [blame] | 112 | #define MANDATORY_BG_CHANNEL 11 |
| 113 | |
Tushnim Bhattacharyya | 582ac1d | 2013-11-07 23:44:09 -0800 | [diff] [blame] | 114 | #ifndef CONFIG_ENABLE_LINUX_REG |
Sushant Kaushik | f4e085e | 2014-06-17 16:07:33 +0530 | [diff] [blame] | 115 | tCsrIgnoreChannels countryIgnoreList[MAX_COUNTRY_IGNORE] = { |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 116 | { {'U','A'}, { 136, 140}, 2}, |
| 117 | { {'T','W'}, { 36, 40, 44, 48, 52}, 5}, |
Madan Mohan Koyyalamudi | 28dd042 | 2013-08-12 15:06:21 +0530 | [diff] [blame] | 118 | { {'I','D'}, { 165}, 1 }, |
Wilson Yang | e3d2b29 | 2013-10-09 00:35:43 -0700 | [diff] [blame] | 119 | { {'A','U'}, { 120, 124, 128}, 3 }, |
Wilson Yang | ce31eaf | 2013-11-11 14:40:34 -0800 | [diff] [blame] | 120 | { {'A','R'}, { 120, 124, 128}, 3 } |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 121 | }; |
Tushnim Bhattacharyya | 582ac1d | 2013-11-07 23:44:09 -0800 | [diff] [blame] | 122 | #else |
Sushant Kaushik | f4e085e | 2014-06-17 16:07:33 +0530 | [diff] [blame] | 123 | tCsrIgnoreChannels countryIgnoreList[MAX_COUNTRY_IGNORE] = { }; |
Tushnim Bhattacharyya | 582ac1d | 2013-11-07 23:44:09 -0800 | [diff] [blame] | 124 | #endif //CONFIG_ENABLE_LINUX_REG |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 125 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 126 | //*** This is temporary work around. It need to call CCM api to get to CFG later |
| 127 | /// Get string parameter value |
| 128 | extern tSirRetStatus wlan_cfgGetStr(tpAniSirGlobal, tANI_U16, tANI_U8*, tANI_U32*); |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 129 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 130 | void csrScanGetResultTimerHandler(void *); |
Padma, Santhosh Kumar | 3618335 | 2016-11-08 17:48:34 +0530 | [diff] [blame] | 131 | void csr_handle_disable_scan(void *pv); |
Deepthi Gowri | 6a08e31 | 2016-03-31 19:10:14 +0530 | [diff] [blame] | 132 | static void csrPurgeScanResultByAge(void *pv); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 133 | void csrScanIdleScanTimerHandler(void *); |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 134 | static void csrSetDefaultScanTiming( tpAniSirGlobal pMac, tSirScanType scanType, tCsrScanRequest *pScanRequest); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 135 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 136 | static void csrStaApConcTimerHandler(void *); |
| 137 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 138 | tANI_BOOLEAN csrIsSupportedChannel(tpAniSirGlobal pMac, tANI_U8 channelId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 139 | eHalStatus csrScanChannels( tpAniSirGlobal pMac, tSmeCmd *pCommand ); |
| 140 | void csrSetCfgValidChannelList( tpAniSirGlobal pMac, tANI_U8 *pChannelList, tANI_U8 NumChannels ); |
| 141 | void csrSaveTxPowerToCfg( tpAniSirGlobal pMac, tDblLinkList *pList, tANI_U32 cfgId ); |
| 142 | void csrSetCfgCountryCode( tpAniSirGlobal pMac, tANI_U8 *countryCode ); |
| 143 | void csrPurgeChannelPower( tpAniSirGlobal pMac, tDblLinkList *pChannelList ); |
| 144 | //if bgPeriod is 0, background scan is disabled. It is in millisecond units |
| 145 | eHalStatus csrSetCfgBackgroundScanPeriod(tpAniSirGlobal pMac, tANI_U32 bgPeriod); |
| 146 | eHalStatus csrProcessSetBGScanParam(tpAniSirGlobal pMac, tSmeCmd *pCommand); |
| 147 | void csrReleaseScanCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand, eCsrScanStatus scanStatus); |
| 148 | static tANI_BOOLEAN csrScanValidateScanResult( tpAniSirGlobal pMac, tANI_U8 *pChannels, |
| 149 | tANI_U8 numChn, tSirBssDescription *pBssDesc, |
| 150 | tDot11fBeaconIEs **ppIes ); |
| 151 | eHalStatus csrSetBGScanChannelList( tpAniSirGlobal pMac, tANI_U8 *pAdjustChannels, tANI_U8 NumAdjustChannels); |
| 152 | void csrReleaseCmdSingle(tpAniSirGlobal pMac, tSmeCmd *pCommand); |
| 153 | tANI_BOOLEAN csrRoamIsValidChannel( tpAniSirGlobal pMac, tANI_U8 channel ); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 154 | void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList ); |
Abhishek Singh | 5deecd1 | 2017-06-12 11:08:40 +0530 | [diff] [blame] | 155 | void csrPurgeScanResults(tpAniSirGlobal pMac); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 156 | |
Madan Mohan Koyyalamudi | 783b236 | 2012-10-21 11:54:41 -0700 | [diff] [blame] | 157 | |
Madan Mohan Koyyalamudi | 783b236 | 2012-10-21 11:54:41 -0700 | [diff] [blame] | 158 | |
Madan Mohan Koyyalamudi | 783b236 | 2012-10-21 11:54:41 -0700 | [diff] [blame] | 159 | |
Madan Mohan Koyyalamudi | 923c1e1 | 2012-11-30 17:53:27 -0800 | [diff] [blame] | 160 | static void csrReleaseScanCmdPendingList(tpAniSirGlobal pMac) |
| 161 | { |
| 162 | tListElem *pEntry; |
| 163 | tSmeCmd *pCommand; |
| 164 | |
| 165 | while((pEntry = csrLLRemoveHead( &pMac->scan.scanCmdPendingList, LL_ACCESS_LOCK)) != NULL) |
| 166 | { |
| 167 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 168 | if ( eSmeCsrCommandMask & pCommand->command ) |
| 169 | { |
| 170 | csrAbortCommand( pMac, pCommand, eANI_BOOLEAN_TRUE ); |
| 171 | } |
| 172 | else |
| 173 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 174 | smsLog(pMac, LOGE, FL("Error: Received command : %d"),pCommand->command); |
Madan Mohan Koyyalamudi | 923c1e1 | 2012-11-30 17:53:27 -0800 | [diff] [blame] | 175 | } |
| 176 | } |
| 177 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 178 | //pResult is invalid calling this function. |
| 179 | void csrFreeScanResultEntry( tpAniSirGlobal pMac, tCsrScanResult *pResult ) |
| 180 | { |
| 181 | if( NULL != pResult->Result.pvIes ) |
| 182 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 183 | vos_mem_free(pResult->Result.pvIes); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 184 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 185 | vos_mem_free(pResult); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 186 | } |
| 187 | |
| 188 | |
| 189 | static eHalStatus csrLLScanPurgeResult(tpAniSirGlobal pMac, tDblLinkList *pList) |
| 190 | { |
| 191 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 192 | tListElem *pEntry; |
| 193 | tCsrScanResult *pBssDesc; |
| 194 | |
| 195 | csrLLLock(pList); |
| 196 | |
| 197 | while((pEntry = csrLLRemoveHead(pList, LL_ACCESS_NOLOCK)) != NULL) |
| 198 | { |
| 199 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 200 | csrFreeScanResultEntry( pMac, pBssDesc ); |
| 201 | } |
| 202 | |
| 203 | csrLLUnlock(pList); |
| 204 | |
| 205 | return (status); |
| 206 | } |
| 207 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 208 | eHalStatus csrScanOpen( tpAniSirGlobal pMac ) |
| 209 | { |
| 210 | eHalStatus status; |
| 211 | |
| 212 | do |
| 213 | { |
| 214 | csrLLOpen(pMac->hHdd, &pMac->scan.scanResultList); |
| 215 | csrLLOpen(pMac->hHdd, &pMac->scan.tempScanResults); |
| 216 | csrLLOpen(pMac->hHdd, &pMac->scan.channelPowerInfoList24); |
| 217 | csrLLOpen(pMac->hHdd, &pMac->scan.channelPowerInfoList5G); |
| 218 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 219 | csrLLOpen(pMac->hHdd, &pMac->scan.scanCmdPendingList); |
| 220 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 221 | pMac->scan.fFullScanIssued = eANI_BOOLEAN_FALSE; |
| 222 | pMac->scan.nBssLimit = CSR_MAX_BSS_SUPPORT; |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 223 | status = vos_timer_init(&pMac->scan.hTimerGetResult, VOS_TIMER_TYPE_SW, csrScanGetResultTimerHandler, pMac); |
| 224 | if (!HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 225 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 226 | smsLog(pMac, LOGE, FL("cannot allocate memory for getResult timer")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 227 | break; |
| 228 | } |
| 229 | #ifdef WLAN_AP_STA_CONCURRENCY |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 230 | status = vos_timer_init(&pMac->scan.hTimerStaApConcTimer, VOS_TIMER_TYPE_SW, csrStaApConcTimerHandler, pMac); |
| 231 | if (!HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 232 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 233 | smsLog(pMac, LOGE, FL("cannot allocate memory for hTimerStaApConcTimer timer")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 234 | break; |
| 235 | } |
| 236 | #endif |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 237 | status = vos_timer_init(&pMac->scan.hTimerIdleScan, VOS_TIMER_TYPE_SW, csrScanIdleScanTimerHandler, pMac); |
| 238 | if (!HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 239 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 240 | smsLog(pMac, LOGE, FL("cannot allocate memory for idleScan timer")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 241 | break; |
| 242 | } |
Padma, Santhosh Kumar | 3618335 | 2016-11-08 17:48:34 +0530 | [diff] [blame] | 243 | status = vos_timer_init(&pMac->scan.disable_scan_during_sco_timer, |
| 244 | VOS_TIMER_TYPE_SW, |
| 245 | csr_handle_disable_scan, |
| 246 | pMac); |
| 247 | if (!HAL_STATUS_SUCCESS(status)) { |
| 248 | smsLog(pMac, LOGE, |
| 249 | FL("cannot allocate memory for disable_scan_during_sco_timer")); |
| 250 | break; |
| 251 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 252 | }while(0); |
| 253 | |
| 254 | return (status); |
| 255 | } |
| 256 | |
| 257 | |
| 258 | eHalStatus csrScanClose( tpAniSirGlobal pMac ) |
| 259 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 260 | csrLLScanPurgeResult(pMac, &pMac->scan.tempScanResults); |
| 261 | csrLLScanPurgeResult(pMac, &pMac->scan.scanResultList); |
| 262 | #ifdef WLAN_AP_STA_CONCURRENCY |
Madan Mohan Koyyalamudi | 923c1e1 | 2012-11-30 17:53:27 -0800 | [diff] [blame] | 263 | csrReleaseScanCmdPendingList(pMac); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 264 | #endif |
| 265 | csrLLClose(&pMac->scan.scanResultList); |
| 266 | csrLLClose(&pMac->scan.tempScanResults); |
| 267 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 268 | csrLLClose(&pMac->scan.scanCmdPendingList); |
| 269 | #endif |
| 270 | csrPurgeChannelPower(pMac, &pMac->scan.channelPowerInfoList24); |
| 271 | csrPurgeChannelPower(pMac, &pMac->scan.channelPowerInfoList5G); |
| 272 | csrLLClose(&pMac->scan.channelPowerInfoList24); |
| 273 | csrLLClose(&pMac->scan.channelPowerInfoList5G); |
| 274 | csrScanDisable(pMac); |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 275 | vos_timer_destroy(&pMac->scan.hTimerGetResult); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 276 | #ifdef WLAN_AP_STA_CONCURRENCY |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 277 | vos_timer_destroy(&pMac->scan.hTimerStaApConcTimer); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 278 | #endif |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 279 | vos_timer_destroy(&pMac->scan.hTimerIdleScan); |
Padma, Santhosh Kumar | 3618335 | 2016-11-08 17:48:34 +0530 | [diff] [blame] | 280 | vos_timer_destroy(&pMac->scan.disable_scan_during_sco_timer); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 281 | return eHAL_STATUS_SUCCESS; |
| 282 | } |
| 283 | |
| 284 | |
| 285 | eHalStatus csrScanEnable( tpAniSirGlobal pMac ) |
| 286 | { |
| 287 | |
| 288 | pMac->scan.fScanEnable = eANI_BOOLEAN_TRUE; |
| 289 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 290 | |
| 291 | return eHAL_STATUS_SUCCESS; |
| 292 | } |
| 293 | |
| 294 | |
| 295 | eHalStatus csrScanDisable( tpAniSirGlobal pMac ) |
| 296 | { |
| 297 | |
| 298 | csrScanStopTimers(pMac); |
| 299 | pMac->scan.fScanEnable = eANI_BOOLEAN_FALSE; |
| 300 | |
| 301 | return eHAL_STATUS_SUCCESS; |
| 302 | } |
| 303 | |
| 304 | |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 305 | //Set scan timing parameters according to state of other driver sessions |
| 306 | //No validation of the parameters is performed. |
| 307 | static void csrSetDefaultScanTiming( tpAniSirGlobal pMac, tSirScanType scanType, tCsrScanRequest *pScanRequest) |
| 308 | { |
| 309 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 310 | if(csrIsAnySessionConnected(pMac)) |
| 311 | { |
Sushant Kaushik | a6fef4b | 2014-09-24 16:17:08 +0530 | [diff] [blame] | 312 | //Reset passive scan time as per ini parameter. |
Abhishek Singh | 7fb7dc1 | 2014-11-06 17:44:05 +0530 | [diff] [blame] | 313 | ccmCfgSetInt(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, |
Sushant Kaushik | a6fef4b | 2014-09-24 16:17:08 +0530 | [diff] [blame] | 314 | pMac->roam.configParam.nPassiveMaxChnTimeConc, |
| 315 | NULL,eANI_BOOLEAN_FALSE); |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 316 | //If multi-session, use the appropriate default scan times |
| 317 | if(scanType == eSIR_ACTIVE_SCAN) |
| 318 | { |
| 319 | pScanRequest->maxChnTime = pMac->roam.configParam.nActiveMaxChnTimeConc; |
| 320 | pScanRequest->minChnTime = pMac->roam.configParam.nActiveMinChnTimeConc; |
| 321 | } |
| 322 | else |
| 323 | { |
| 324 | pScanRequest->maxChnTime = pMac->roam.configParam.nPassiveMaxChnTimeConc; |
| 325 | pScanRequest->minChnTime = pMac->roam.configParam.nPassiveMinChnTimeConc; |
| 326 | } |
Abhishek Singh | add1358 | 2016-09-29 17:00:03 +0530 | [diff] [blame] | 327 | pScanRequest->max_chntime_btc_esco = |
| 328 | pMac->roam.configParam.max_chntime_btc_esco; |
| 329 | pScanRequest->min_chntime_btc_esco = |
| 330 | pMac->roam.configParam.min_chntime_btc_esco; |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 331 | |
| 332 | pScanRequest->restTime = pMac->roam.configParam.nRestTimeConc; |
| 333 | |
| 334 | //Return so that fields set above will not be overwritten. |
| 335 | return; |
| 336 | } |
| 337 | #endif |
| 338 | |
| 339 | //This portion of the code executed if multi-session not supported |
| 340 | //(WLAN_AP_STA_CONCURRENCY not defined) or no multi-session. |
| 341 | //Use the "regular" (non-concurrency) default scan timing. |
Abhishek Singh | 7fb7dc1 | 2014-11-06 17:44:05 +0530 | [diff] [blame] | 342 | ccmCfgSetInt(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, |
Kaushik, Sushant | 49758c1 | 2014-09-26 11:25:38 +0530 | [diff] [blame] | 343 | pMac->roam.configParam.nPassiveMaxChnTime, |
| 344 | NULL,eANI_BOOLEAN_FALSE); |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 345 | if(pScanRequest->scanType == eSIR_ACTIVE_SCAN) |
| 346 | { |
| 347 | pScanRequest->maxChnTime = pMac->roam.configParam.nActiveMaxChnTime; |
| 348 | pScanRequest->minChnTime = pMac->roam.configParam.nActiveMinChnTime; |
| 349 | } |
| 350 | else |
| 351 | { |
| 352 | pScanRequest->maxChnTime = pMac->roam.configParam.nPassiveMaxChnTime; |
| 353 | pScanRequest->minChnTime = pMac->roam.configParam.nPassiveMinChnTime; |
| 354 | } |
Abhishek Singh | add1358 | 2016-09-29 17:00:03 +0530 | [diff] [blame] | 355 | pScanRequest->max_chntime_btc_esco = |
| 356 | pMac->roam.configParam.max_chntime_btc_esco; |
| 357 | pScanRequest->min_chntime_btc_esco = |
| 358 | pMac->roam.configParam.min_chntime_btc_esco; |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 359 | |
| 360 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 361 | //No rest time if no sessions are connected. |
| 362 | pScanRequest->restTime = 0; |
| 363 | #endif |
| 364 | } |
| 365 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 366 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 367 | //Return SUCCESS is the command is queued, else returns eHAL_STATUS_FAILURE |
| 368 | eHalStatus csrQueueScanRequest( tpAniSirGlobal pMac, tSmeCmd *pScanCmd ) |
| 369 | { |
| 370 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 371 | |
| 372 | tANI_BOOLEAN fNoCmdPending; |
| 373 | tSmeCmd *pQueueScanCmd=NULL; |
| 374 | tSmeCmd *pSendScanCmd=NULL; |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 375 | tANI_U8 nNumChanCombinedConc = 0; |
Gopichand Nakkala | 114718f | 2013-03-25 19:19:46 -0700 | [diff] [blame] | 376 | if (NULL == pScanCmd) |
| 377 | { |
| 378 | smsLog (pMac, LOGE, FL("Scan Req cmd is NULL")); |
| 379 | return eHAL_STATUS_FAILURE; |
| 380 | } |
Madan Mohan Koyyalamudi | 48081ef | 2012-12-04 16:49:55 -0800 | [diff] [blame] | 381 | /* split scan if any one of the following: |
| 382 | * - STA session is connected and the scan is not a P2P search |
| 383 | * - any P2P session is connected |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 384 | * Do not split scans if no concurrent infra connections are |
| 385 | * active and if the scan is a BG scan triggered by LFR (OR) |
| 386 | * any scan if LFR is in the middle of a BG scan. Splitting |
| 387 | * the scan is delaying the time it takes for LFR to find |
| 388 | * candidates and resulting in disconnects. |
Madan Mohan Koyyalamudi | 48081ef | 2012-12-04 16:49:55 -0800 | [diff] [blame] | 389 | */ |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 390 | |
| 391 | if(csrIsStaSessionConnected(pMac) && |
| 392 | !csrIsP2pSessionConnected(pMac)) |
| 393 | { |
| 394 | nNumChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc; |
| 395 | } |
| 396 | else if(csrIsP2pSessionConnected(pMac)) |
| 397 | { |
| 398 | nNumChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc; |
| 399 | } |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 400 | if ( (csrIsStaSessionConnected(pMac) && |
| 401 | #ifdef FEATURE_WLAN_LFR |
| 402 | (csrIsConcurrentInfraConnected(pMac) || |
| 403 | ((pScanCmd->u.scanCmd.reason != eCsrScanBgScan) && |
| 404 | (pMac->roam.neighborRoamInfo.neighborRoamState != |
| 405 | eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN))) && |
| 406 | #endif |
| 407 | (pScanCmd->u.scanCmd.u.scanRequest.p2pSearch != 1)) || |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 408 | (csrIsP2pSessionConnected(pMac)) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 409 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 410 | tCsrScanRequest scanReq; |
| 411 | tANI_U8 numChn = pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels; |
| 412 | tCsrChannelInfo *pChnInfo = &scanReq.ChannelInfo; |
| 413 | tANI_U8 channelToScan[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 414 | tANI_BOOLEAN bMemAlloc = eANI_BOOLEAN_FALSE; |
| 415 | |
| 416 | if (numChn == 0) |
| 417 | { |
| 418 | |
| 419 | numChn = pMac->scan.baseChannels.numChannels; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 420 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 421 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = vos_mem_malloc(numChn); |
| 422 | if ( NULL == pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 423 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 424 | smsLog( pMac, LOGE, FL(" Failed to get memory for channel list ") ); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 425 | return eHAL_STATUS_FAILURE; |
| 426 | } |
| 427 | bMemAlloc = eANI_BOOLEAN_TRUE; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 428 | vos_mem_copy(pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList, |
| 429 | pMac->scan.baseChannels.channelList, numChn); |
| 430 | status = eHAL_STATUS_SUCCESS; |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 431 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 432 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 433 | vos_mem_free(pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 434 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = NULL; |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 435 | smsLog( pMac, LOGE, FL(" Failed to copy memory to channel list ") ); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 436 | return eHAL_STATUS_FAILURE; |
| 437 | } |
| 438 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = numChn; |
| 439 | } |
Sushant Kaushik | 826de80 | 2014-05-08 18:04:11 +0530 | [diff] [blame] | 440 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, |
| 441 | "%s: Total Number of channels to scan : %d " |
| 442 | "Splitted in group of %d ", __func__, numChn, |
| 443 | nNumChanCombinedConc); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 444 | //Whenever we get a scan request with multiple channels we break it up into 2 requests |
| 445 | //First request for first channel to scan and second request to scan remaining channels |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 446 | if ( numChn > nNumChanCombinedConc) |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 447 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 448 | vos_mem_set(&scanReq, sizeof(tCsrScanRequest), 0); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 449 | |
| 450 | pQueueScanCmd = csrGetCommandBuffer(pMac); //optimize this to use 2 command buffer only |
| 451 | if (!pQueueScanCmd) |
| 452 | { |
| 453 | if (bMemAlloc) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 454 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 455 | vos_mem_free(pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 456 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = NULL; |
| 457 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 458 | } |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 459 | smsLog( pMac, LOGE, FL(" Failed to get Queue command buffer") ); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 460 | return eHAL_STATUS_FAILURE; |
| 461 | } |
| 462 | pQueueScanCmd->command = pScanCmd->command; |
| 463 | pQueueScanCmd->sessionId = pScanCmd->sessionId; |
| 464 | pQueueScanCmd->u.scanCmd.callback = pScanCmd->u.scanCmd.callback; |
| 465 | pQueueScanCmd->u.scanCmd.pContext = pScanCmd->u.scanCmd.pContext; |
| 466 | pQueueScanCmd->u.scanCmd.reason = pScanCmd->u.scanCmd.reason; |
| 467 | pQueueScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 468 | |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 469 | /* First copy all the parameters to local variable of scan request */ |
| 470 | csrScanCopyRequest(pMac, &scanReq, &pScanCmd->u.scanCmd.u.scanRequest); |
Madan Mohan Koyyalamudi | af2a8b9 | 2012-10-09 14:58:07 -0700 | [diff] [blame] | 471 | |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 472 | /* Now modify the elements of local var scan request required to be modified for split scan */ |
| 473 | if(scanReq.ChannelInfo.ChannelList != NULL) |
| 474 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 475 | vos_mem_free(scanReq.ChannelInfo.ChannelList); |
Madan Mohan Koyyalamudi | 0c626f3 | 2012-11-30 15:10:25 -0800 | [diff] [blame] | 476 | scanReq.ChannelInfo.ChannelList = NULL; |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 477 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 478 | |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 479 | pChnInfo->numOfChannels = pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels - nNumChanCombinedConc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 480 | |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 481 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN, |
Jeff Johnson | 8947750 | 2017-09-19 08:35:23 -0700 | [diff] [blame] | 482 | FL(" &channelToScan %pK pScanCmd(%pK) pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList(%pK)numChn(%d)"), |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 483 | &channelToScan[0], pScanCmd, |
| 484 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList, numChn); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 485 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 486 | vos_mem_copy(&channelToScan[0], |
| 487 | &pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[ |
| 488 | nNumChanCombinedConc], |
| 489 | pChnInfo->numOfChannels * sizeof(tANI_U8)); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 490 | |
| 491 | pChnInfo->ChannelList = &channelToScan[0]; |
| 492 | |
| 493 | scanReq.BSSType = eCSR_BSS_TYPE_ANY; |
c_hpothu | dbefd3e | 2014-04-28 15:59:47 +0530 | [diff] [blame] | 494 | |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 495 | //Use concurrency values for min/maxChnTime. |
| 496 | //We know csrIsAnySessionConnected(pMac) returns TRUE here |
| 497 | csrSetDefaultScanTiming(pMac, scanReq.scanType, &scanReq); |
| 498 | |
| 499 | status = csrScanCopyRequest(pMac, &pQueueScanCmd->u.scanCmd.u.scanRequest, &scanReq); |
| 500 | |
| 501 | if(!HAL_STATUS_SUCCESS(status)) |
| 502 | { |
| 503 | if (bMemAlloc) |
| 504 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 505 | vos_mem_free(pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 506 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = NULL; |
| 507 | |
| 508 | } |
| 509 | if( scanReq.pIEField != NULL) |
| 510 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 511 | vos_mem_free(scanReq.pIEField); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 512 | scanReq.pIEField = NULL; |
| 513 | } |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 514 | smsLog( pMac, LOGE, FL(" Failed to get copy csrScanRequest = %d"), status ); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 515 | return eHAL_STATUS_FAILURE; |
| 516 | } |
| 517 | /* Clean the local scan variable */ |
| 518 | scanReq.ChannelInfo.ChannelList = NULL; |
| 519 | scanReq.ChannelInfo.numOfChannels = 0; |
| 520 | csrScanFreeRequest(pMac, &scanReq); |
| 521 | |
| 522 | /* setup the command to scan 2 channels */ |
| 523 | pSendScanCmd = pScanCmd; |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 524 | pSendScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = nNumChanCombinedConc; |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 525 | pSendScanCmd->u.scanCmd.u.scanRequest.BSSType = eCSR_BSS_TYPE_ANY; |
c_hpothu | dbefd3e | 2014-04-28 15:59:47 +0530 | [diff] [blame] | 526 | |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 527 | //Use concurrency values for min/maxChnTime. |
| 528 | //We know csrIsAnySessionConnected(pMac) returns TRUE here |
| 529 | csrSetDefaultScanTiming(pMac, pSendScanCmd->u.scanCmd.u.scanRequest.scanType, &pSendScanCmd->u.scanCmd.u.scanRequest); |
| 530 | pSendScanCmd->u.scanCmd.callback = NULL; |
| 531 | } else { |
| 532 | pSendScanCmd = pScanCmd; |
| 533 | pSendScanCmd->u.scanCmd.u.scanRequest.BSSType = eCSR_BSS_TYPE_ANY; |
c_hpothu | dbefd3e | 2014-04-28 15:59:47 +0530 | [diff] [blame] | 534 | |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 535 | //Use concurrency values for min/maxChnTime. |
| 536 | //We know csrIsAnySessionConnected(pMac) returns TRUE here |
| 537 | csrSetDefaultScanTiming(pMac, pSendScanCmd->u.scanCmd.u.scanRequest.scanType, &pSendScanCmd->u.scanCmd.u.scanRequest); |
| 538 | } |
| 539 | |
| 540 | fNoCmdPending = csrLLIsListEmpty( &pMac->scan.scanCmdPendingList, LL_ACCESS_LOCK ); |
| 541 | |
| 542 | //Logic Below is as follows |
| 543 | // If the scanCmdPendingList is empty then we directly send that command |
| 544 | // to smeCommandQueue else we buffer it in our scanCmdPendingList Queue |
| 545 | if( fNoCmdPending ) |
| 546 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 547 | if (pQueueScanCmd != NULL) |
| 548 | { |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 549 | csrLLInsertTail( &pMac->scan.scanCmdPendingList, &pQueueScanCmd->Link, LL_ACCESS_LOCK ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 550 | } |
| 551 | |
| 552 | if (pSendScanCmd != NULL) |
| 553 | { |
| 554 | return csrQueueSmeCommand(pMac, pSendScanCmd, eANI_BOOLEAN_FALSE); |
| 555 | } |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 556 | } |
| 557 | else |
| 558 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 559 | if (pSendScanCmd != NULL) |
| 560 | { |
| 561 | csrLLInsertTail( &pMac->scan.scanCmdPendingList, &pSendScanCmd->Link, LL_ACCESS_LOCK ); |
| 562 | } |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 563 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 564 | if (pQueueScanCmd != NULL) |
| 565 | { |
| 566 | csrLLInsertTail( &pMac->scan.scanCmdPendingList, &pQueueScanCmd->Link, LL_ACCESS_LOCK ); |
| 567 | } |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 568 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 569 | } |
| 570 | else |
| 571 | { //No concurrency case |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 572 | smsLog( pMac, LOG2, FL("Queuing scan command (reason=%d, roamState=%d" |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 573 | " numOfChannels=%d)"), |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 574 | pScanCmd->u.scanCmd.reason, |
| 575 | pMac->roam.neighborRoamInfo.neighborRoamState, |
| 576 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 577 | return csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_FALSE); |
| 578 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 579 | |
| 580 | return ( status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 581 | } |
| 582 | #endif |
| 583 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 584 | /* --------------------------------------------------------------------------- |
| 585 | \fn csrScan2GOnyRequest |
| 586 | \brief This function will update the scan request with only |
Jeff Johnson | b88db98 | 2012-12-10 13:34:59 -0800 | [diff] [blame] | 587 | 2.4GHz valid channel list. |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 588 | \param pMac |
| 589 | \param pScanCmd |
| 590 | \param pScanRequest |
| 591 | \return None |
| 592 | -------------------------------------------------------------------------------*/ |
| 593 | static void csrScan2GOnyRequest(tpAniSirGlobal pMac,tSmeCmd *pScanCmd, |
| 594 | tCsrScanRequest *pScanRequest) |
| 595 | { |
| 596 | tANI_U8 index, channelId, channelListSize = 0; |
| 597 | tANI_U8 channelList2G[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}; |
| 598 | static tANI_U8 validchannelList[CSR_MAX_2_4_GHZ_SUPPORTED_CHANNELS] = {0}; |
| 599 | |
| 600 | VOS_ASSERT(pScanCmd && pScanRequest); |
Madan Mohan Koyyalamudi | 33ef6a2 | 2012-10-30 17:44:43 -0700 | [diff] [blame] | 601 | /* To silence the KW tool null check is added */ |
| 602 | if((pScanCmd == NULL) || (pScanRequest == NULL)) |
| 603 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 604 | smsLog( pMac, LOGE, FL(" pScanCmd or pScanRequest is NULL ")); |
Madan Mohan Koyyalamudi | 33ef6a2 | 2012-10-30 17:44:43 -0700 | [diff] [blame] | 605 | return; |
| 606 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 607 | |
| 608 | if (pScanCmd->u.scanCmd.scanID || |
| 609 | (eCSR_SCAN_REQUEST_FULL_SCAN != pScanRequest->requestType)) |
| 610 | return; |
| 611 | |
| 612 | //Contsruct valid Supported 2.4 GHz Channel List |
| 613 | for( index = 0; index < ARRAY_SIZE(channelList2G); index++ ) |
| 614 | { |
| 615 | channelId = channelList2G[index]; |
| 616 | if ( csrIsSupportedChannel( pMac, channelId ) ) |
| 617 | { |
| 618 | validchannelList[channelListSize++] = channelId; |
| 619 | } |
| 620 | } |
| 621 | |
| 622 | pScanRequest->ChannelInfo.numOfChannels = channelListSize; |
| 623 | pScanRequest->ChannelInfo.ChannelList = validchannelList; |
| 624 | } |
| 625 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 626 | eHalStatus csrScanRequest(tpAniSirGlobal pMac, tANI_U16 sessionId, |
| 627 | tCsrScanRequest *pScanRequest, tANI_U32 *pScanRequestID, |
| 628 | csrScanCompleteCallback callback, void *pContext) |
| 629 | { |
| 630 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 631 | tSmeCmd *pScanCmd = NULL; |
Madan Mohan Koyyalamudi | cb90bb2 | 2012-10-30 18:24:43 -0700 | [diff] [blame] | 632 | eCsrConnectState ConnectState; |
Deepthi Gowri | e11da8c | 2016-02-04 18:18:39 +0530 | [diff] [blame] | 633 | |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 634 | if(pScanRequest == NULL) |
| 635 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 636 | smsLog( pMac, LOGE, FL(" pScanRequest is NULL")); |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 637 | VOS_ASSERT(0); |
Kaushik, Sushant | 488df38 | 2014-03-05 11:43:47 +0530 | [diff] [blame] | 638 | return eHAL_STATUS_FAILURE ; |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 639 | } |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 640 | |
Kiet Lam | d1f3dc8 | 2013-11-05 20:45:04 +0530 | [diff] [blame] | 641 | /* During group formation, the P2P client scans for GO with the specific SSID. |
| 642 | * There will be chances of GO switching to other channels because of scan or |
| 643 | * to STA channel in case of STA+GO MCC scenario. So to increase the possibility |
| 644 | * of client to find the GO, the dwell time of scan is increased to 100ms. |
| 645 | */ |
| 646 | if(pScanRequest->p2pSearch) |
| 647 | { |
Rashmi Ramanna | 6f7931c | 2013-12-20 09:04:12 +0530 | [diff] [blame] | 648 | if(pScanRequest->SSIDs.numOfSSIDs) |
Kiet Lam | d1f3dc8 | 2013-11-05 20:45:04 +0530 | [diff] [blame] | 649 | { |
Rashmi Ramanna | 6f7931c | 2013-12-20 09:04:12 +0530 | [diff] [blame] | 650 | //If the scan request is for specific SSId the length of SSID will be |
| 651 | //greater than 7 as SSID for p2p search contains "DIRECT-") |
| 652 | if(pScanRequest->SSIDs.SSIDList->SSID.length > DIRECT_SSID_LEN) |
| 653 | { |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 654 | smsLog( pMac, LOG1, FL("P2P: Increasing the min and max Dwell" |
| 655 | " time to %d for specific SSID scan %.*s"), |
| 656 | MAX_CHN_TIME_TO_FIND_GO, |
| 657 | pScanRequest->SSIDs.SSIDList->SSID.length, |
| 658 | pScanRequest->SSIDs.SSIDList->SSID.ssId); |
Rashmi Ramanna | 6f7931c | 2013-12-20 09:04:12 +0530 | [diff] [blame] | 659 | pScanRequest->maxChnTime = MAX_CHN_TIME_TO_FIND_GO; |
| 660 | pScanRequest->minChnTime = MIN_CHN_TIME_TO_FIND_GO; |
| 661 | } |
Kiet Lam | d1f3dc8 | 2013-11-05 20:45:04 +0530 | [diff] [blame] | 662 | } |
| 663 | } |
| 664 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 665 | do |
| 666 | { |
| 667 | if(pMac->scan.fScanEnable) |
| 668 | { |
| 669 | pScanCmd = csrGetCommandBuffer(pMac); |
| 670 | if(pScanCmd) |
| 671 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 672 | vos_mem_set(&pScanCmd->u.scanCmd, sizeof(tScanCmd), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 673 | pScanCmd->command = eSmeCommandScan; |
| 674 | pScanCmd->sessionId = sessionId; |
| 675 | pScanCmd->u.scanCmd.callback = callback; |
| 676 | pScanCmd->u.scanCmd.pContext = pContext; |
| 677 | if(eCSR_SCAN_REQUEST_11D_SCAN == pScanRequest->requestType) |
| 678 | { |
| 679 | pScanCmd->u.scanCmd.reason = eCsrScan11d1; |
| 680 | } |
| 681 | else if((eCSR_SCAN_REQUEST_FULL_SCAN == pScanRequest->requestType) || |
| 682 | (eCSR_SCAN_P2P_DISCOVERY == pScanRequest->requestType) |
| 683 | #ifdef SOFTAP_CHANNEL_RANGE |
| 684 | ||(eCSR_SCAN_SOFTAP_CHANNEL_RANGE == pScanRequest->requestType) |
| 685 | #endif |
| 686 | ) |
| 687 | { |
| 688 | pScanCmd->u.scanCmd.reason = eCsrScanUserRequest; |
| 689 | } |
| 690 | else if(eCSR_SCAN_HO_BG_SCAN == pScanRequest->requestType) |
| 691 | { |
| 692 | pScanCmd->u.scanCmd.reason = eCsrScanBgScan; |
| 693 | } |
| 694 | else if(eCSR_SCAN_HO_PROBE_SCAN == pScanRequest->requestType) |
| 695 | { |
| 696 | pScanCmd->u.scanCmd.reason = eCsrScanProbeBss; |
| 697 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 698 | else if(eCSR_SCAN_P2P_FIND_PEER == pScanRequest->requestType) |
| 699 | { |
| 700 | pScanCmd->u.scanCmd.reason = eCsrScanP2PFindPeer; |
| 701 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 702 | else |
| 703 | { |
| 704 | pScanCmd->u.scanCmd.reason = eCsrScanIdleScan; |
| 705 | } |
| 706 | if(pScanRequest->minChnTime == 0 && pScanRequest->maxChnTime == 0) |
| 707 | { |
| 708 | //The caller doesn't set the time correctly. Set it here |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 709 | csrSetDefaultScanTiming(pMac, pScanRequest->scanType, |
| 710 | pScanRequest); |
| 711 | smsLog(pMac, LOG1, FL("Setting default min %d and max %d" |
| 712 | " ChnTime"), pScanRequest->minChnTime, |
| 713 | pScanRequest->maxChnTime); |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 714 | } |
| 715 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 716 | if(pScanRequest->restTime == 0) |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 717 | { |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 718 | //Need to set restTime only if at least one session is connected |
| 719 | if(csrIsAnySessionConnected(pMac)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 720 | { |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 721 | pScanRequest->restTime = pMac->roam.configParam.nRestTimeConc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 722 | } |
| 723 | } |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 724 | #endif |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 725 | /*For Standalone wlan : channel time will remain the same. |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 726 | For BTC with A2DP up: Channel time = Channel time * 2, if station is not already associated. |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 727 | This has been done to provide a larger scan window for faster connection during btc.Else Scan is seen |
| 728 | to take a long time. |
| 729 | For BTC with A2DP up: Channel time will not be doubled, if station is already associated. |
| 730 | */ |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 731 | status = csrRoamGetConnectState(pMac,sessionId,&ConnectState); |
Srinivas Girigowda | c84c57c | 2013-02-19 17:41:56 -0800 | [diff] [blame] | 732 | if (HAL_STATUS_SUCCESS(status) && |
| 733 | pMac->btc.fA2DPUp && |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 734 | (eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED != ConnectState) && |
| 735 | (eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED != ConnectState)) |
| 736 | { |
| 737 | pScanRequest->maxChnTime = pScanRequest->maxChnTime << 1; |
| 738 | pScanRequest->minChnTime = pScanRequest->minChnTime << 1; |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 739 | smsLog( pMac, LOG1, FL("BTC A2DP up, doubling max and min" |
| 740 | " ChnTime (Max=%d Min=%d)"), |
| 741 | pScanRequest->maxChnTime, |
| 742 | pScanRequest->minChnTime); |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 743 | } |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 744 | |
Abhishek Singh | add1358 | 2016-09-29 17:00:03 +0530 | [diff] [blame] | 745 | pScanRequest->max_chntime_btc_esco = |
| 746 | pMac->roam.configParam.max_chntime_btc_esco; |
| 747 | pScanRequest->min_chntime_btc_esco = |
| 748 | pMac->roam.configParam.min_chntime_btc_esco; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 749 | //Need to make the following atomic |
| 750 | pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around |
| 751 | |
| 752 | if(pScanRequestID) |
| 753 | { |
| 754 | *pScanRequestID = pScanCmd->u.scanCmd.scanID; |
| 755 | } |
| 756 | |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 757 | // If it is the first scan request from HDD, CSR checks if it is for 11d. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 758 | // If it is not, CSR will save the scan request in the pending cmd queue |
| 759 | // & issue an 11d scan request to PE. |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 760 | if (((0 == pScanCmd->u.scanCmd.scanID) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 761 | && (eCSR_SCAN_REQUEST_11D_SCAN != pScanRequest->requestType)) |
| 762 | #ifdef SOFTAP_CHANNEL_RANGE |
| 763 | && (eCSR_SCAN_SOFTAP_CHANNEL_RANGE != pScanRequest->requestType) |
| 764 | #endif |
| 765 | && (eANI_BOOLEAN_FALSE == pMac->scan.fEnableBypass11d) |
| 766 | ) |
| 767 | { |
| 768 | tSmeCmd *p11dScanCmd; |
| 769 | tCsrScanRequest scanReq; |
| 770 | tCsrChannelInfo *pChnInfo = &scanReq.ChannelInfo; |
| 771 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 772 | vos_mem_set(&scanReq, sizeof(tCsrScanRequest), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 773 | |
| 774 | p11dScanCmd = csrGetCommandBuffer(pMac); |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 775 | if (p11dScanCmd) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 776 | { |
| 777 | tANI_U32 numChn = pMac->scan.baseChannels.numChannels; |
| 778 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 779 | vos_mem_set(&p11dScanCmd->u.scanCmd, sizeof(tScanCmd), 0); |
| 780 | pChnInfo->ChannelList = vos_mem_malloc(numChn); |
| 781 | if ( NULL == pChnInfo->ChannelList ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 782 | { |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 783 | smsLog(pMac, LOGE, FL("Failed to allocate memory")); |
| 784 | status = eHAL_STATUS_FAILURE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 785 | break; |
| 786 | } |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 787 | vos_mem_copy(pChnInfo->ChannelList, |
| 788 | pMac->scan.baseChannels.channelList, |
| 789 | numChn); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 790 | pChnInfo->numOfChannels = (tANI_U8)numChn; |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 791 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 792 | p11dScanCmd->command = eSmeCommandScan; |
Mihir Shete | fc7ff5b | 2014-01-27 11:30:05 +0530 | [diff] [blame] | 793 | p11dScanCmd->u.scanCmd.callback = pMac->scan.callback11dScanDone; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 794 | p11dScanCmd->u.scanCmd.pContext = NULL; |
c_hpothu | 0d5a735 | 2014-03-22 12:30:25 +0530 | [diff] [blame] | 795 | p11dScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 796 | scanReq.BSSType = eCSR_BSS_TYPE_ANY; |
| 797 | |
| 798 | if ( csrIs11dSupported(pMac) ) |
| 799 | { |
c_hpothu | dbefd3e | 2014-04-28 15:59:47 +0530 | [diff] [blame] | 800 | scanReq.scanType = eSIR_PASSIVE_SCAN; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 801 | scanReq.requestType = eCSR_SCAN_REQUEST_11D_SCAN; |
| 802 | p11dScanCmd->u.scanCmd.reason = eCsrScan11d1; |
| 803 | scanReq.maxChnTime = pMac->roam.configParam.nPassiveMaxChnTime; |
| 804 | scanReq.minChnTime = pMac->roam.configParam.nPassiveMinChnTime; |
| 805 | } |
| 806 | else |
| 807 | { |
c_hpothu | dbefd3e | 2014-04-28 15:59:47 +0530 | [diff] [blame] | 808 | scanReq.scanType = pScanRequest->scanType; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 809 | scanReq.requestType = eCSR_SCAN_IDLE_MODE_SCAN; |
| 810 | p11dScanCmd->u.scanCmd.reason = eCsrScanIdleScan; |
| 811 | scanReq.maxChnTime = pMac->roam.configParam.nActiveMaxChnTime; |
| 812 | scanReq.minChnTime = pMac->roam.configParam.nActiveMinChnTime; |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 813 | |
Abhishek Singh | add1358 | 2016-09-29 17:00:03 +0530 | [diff] [blame] | 814 | scanReq.max_chntime_btc_esco = |
| 815 | pMac->roam.configParam.max_chntime_btc_esco; |
| 816 | scanReq.min_chntime_btc_esco = |
| 817 | pMac->roam.configParam.min_chntime_btc_esco; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 818 | } |
c_hpothu | 059edb0 | 2014-03-12 21:44:28 +0530 | [diff] [blame] | 819 | if (pMac->roam.configParam.nInitialDwellTime) |
| 820 | { |
| 821 | scanReq.maxChnTime = |
| 822 | pMac->roam.configParam.nInitialDwellTime; |
| 823 | smsLog(pMac, LOG1, FL("11d scan, updating" |
| 824 | "dwell time for first scan %u"), |
| 825 | scanReq.maxChnTime); |
| 826 | } |
Deepthi Gowri | e11da8c | 2016-02-04 18:18:39 +0530 | [diff] [blame] | 827 | if ((pScanCmd->u.scanCmd.reason == eCsrScanUserRequest) |
| 828 | && !(pScanRequest->p2pSearch) |
Gupta, Kapil | b79cda3 | 2015-12-30 20:36:33 +0530 | [diff] [blame] | 829 | &&(pScanRequest->ChannelInfo.numOfChannels |
| 830 | < pMac->roam.configParam. |
| 831 | max_chan_for_dwell_time_cfg)) |
| 832 | { |
| 833 | pScanRequest->maxChnTime = |
| 834 | pScanRequest->maxChnTime << 1; |
| 835 | pScanRequest->minChnTime = |
| 836 | pScanRequest->minChnTime << 1; |
| 837 | smsLog(pMac, LOG1, |
| 838 | FL("Double ChnTime (Max=%d Min=%d) numOfChannels=%d max_chan_for_dwell_time_cfg=%d"), |
| 839 | pScanRequest->maxChnTime, |
| 840 | pScanRequest->minChnTime, |
| 841 | pScanRequest->ChannelInfo.numOfChannels, |
| 842 | pMac->roam.configParam. |
| 843 | max_chan_for_dwell_time_cfg); |
| 844 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 845 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 846 | status = csrScanCopyRequest(pMac, &p11dScanCmd->u.scanCmd.u.scanRequest, &scanReq); |
| 847 | //Free the channel list |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 848 | vos_mem_free(pChnInfo->ChannelList); |
James Zmuda | 9ea1edd | 2013-04-18 18:20:54 -0700 | [diff] [blame] | 849 | pChnInfo->ChannelList = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 850 | |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 851 | if (HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 852 | { |
krunal soni | 5f112f0 | 2013-11-25 15:00:11 -0800 | [diff] [blame] | 853 | pMac->scan.scanProfile.numOfChannels = |
| 854 | p11dScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 855 | //Start process the command |
| 856 | #ifdef WLAN_AP_STA_CONCURRENCY |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 857 | if (!pMac->fScanOffload) |
| 858 | status = csrQueueScanRequest(pMac, p11dScanCmd); |
| 859 | else |
| 860 | status = csrQueueSmeCommand(pMac, p11dScanCmd, |
| 861 | eANI_BOOLEAN_FALSE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 862 | #else |
| 863 | status = csrQueueSmeCommand(pMac, p11dScanCmd, eANI_BOOLEAN_FALSE); |
| 864 | #endif |
| 865 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 866 | { |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 867 | smsLog(pMac, LOGE, FL("Failed to send message" |
| 868 | " status = %d"), status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 869 | break; |
| 870 | } |
| 871 | } |
| 872 | else |
| 873 | { |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 874 | smsLog(pMac, LOGE, FL("csrScanCopyRequest failed")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 875 | break; |
| 876 | } |
| 877 | } |
| 878 | else |
| 879 | { |
| 880 | //error |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 881 | smsLog( pMac, LOGE, FL("p11dScanCmd failed") ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 882 | break; |
| 883 | } |
| 884 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 885 | |
| 886 | //Scan only 2G Channels if set in ini file |
| 887 | //This is mainly to reduce the First Scan duration |
| 888 | //Once we turn on Wifi |
| 889 | if(pMac->scan.fFirstScanOnly2GChnl) |
| 890 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 891 | smsLog( pMac, LOG1, FL("Scanning only 2G Channels during first scan")); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 892 | csrScan2GOnyRequest(pMac, pScanCmd, pScanRequest); |
| 893 | } |
| 894 | |
c_hpothu | 059edb0 | 2014-03-12 21:44:28 +0530 | [diff] [blame] | 895 | if (pMac->roam.configParam.nInitialDwellTime) |
| 896 | { |
| 897 | pScanRequest->maxChnTime = |
| 898 | pMac->roam.configParam.nInitialDwellTime; |
| 899 | pMac->roam.configParam.nInitialDwellTime = 0; |
| 900 | smsLog(pMac, LOG1, |
| 901 | FL("updating dwell time for first scan %u"), |
| 902 | pScanRequest->maxChnTime); |
| 903 | } |
| 904 | |
Deepthi Gowri | e11da8c | 2016-02-04 18:18:39 +0530 | [diff] [blame] | 905 | if ((pScanCmd->u.scanCmd.reason == eCsrScanUserRequest) |
| 906 | && !(pScanRequest->p2pSearch) |
Gupta, Kapil | b79cda3 | 2015-12-30 20:36:33 +0530 | [diff] [blame] | 907 | && (pScanRequest->ChannelInfo.numOfChannels |
| 908 | < pMac->roam.configParam.max_chan_for_dwell_time_cfg)) |
| 909 | { |
| 910 | pScanRequest->maxChnTime = pScanRequest->maxChnTime << 1; |
| 911 | pScanRequest->minChnTime = pScanRequest->minChnTime << 1; |
| 912 | smsLog(pMac, LOG1, |
| 913 | FL("Double ChnTime (Max=%d Min=%d) numOfChannels=%d max_chan_for_dwell_time_cfg=%d"), |
| 914 | pScanRequest->maxChnTime, |
| 915 | pScanRequest->minChnTime, |
| 916 | pScanRequest->ChannelInfo.numOfChannels, |
| 917 | pMac->roam.configParam.max_chan_for_dwell_time_cfg); |
| 918 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 919 | status = csrScanCopyRequest(pMac, &pScanCmd->u.scanCmd.u.scanRequest, pScanRequest); |
| 920 | if(HAL_STATUS_SUCCESS(status)) |
| 921 | { |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 922 | tCsrScanRequest *pTempScanReq = |
| 923 | &pScanCmd->u.scanCmd.u.scanRequest; |
krunal soni | 5f112f0 | 2013-11-25 15:00:11 -0800 | [diff] [blame] | 924 | pMac->scan.scanProfile.numOfChannels = |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 925 | pTempScanReq->ChannelInfo.numOfChannels; |
krunal soni | 5f112f0 | 2013-11-25 15:00:11 -0800 | [diff] [blame] | 926 | |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 927 | smsLog( pMac, LOG1, FL(" SId=%d scanId=%d" |
| 928 | " Scan reason=%u numSSIDs=%d" |
| 929 | " numChan=%d P2P search=%d minCT=%d maxCT=%d" |
| 930 | " minCBtc=%d maxCBtx=%d"), |
| 931 | sessionId, pScanCmd->u.scanCmd.scanID, |
| 932 | pScanCmd->u.scanCmd.reason, |
| 933 | pTempScanReq->SSIDs.numOfSSIDs, |
| 934 | pTempScanReq->ChannelInfo.numOfChannels, |
| 935 | pTempScanReq->p2pSearch, |
| 936 | pTempScanReq->minChnTime, |
| 937 | pTempScanReq->maxChnTime, |
Abhishek Singh | add1358 | 2016-09-29 17:00:03 +0530 | [diff] [blame] | 938 | pTempScanReq->min_chntime_btc_esco, |
| 939 | pTempScanReq->max_chntime_btc_esco); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 940 | //Start process the command |
| 941 | #ifdef WLAN_AP_STA_CONCURRENCY |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 942 | if (!pMac->fScanOffload) |
| 943 | status = csrQueueScanRequest(pMac,pScanCmd); |
| 944 | else |
| 945 | status = csrQueueSmeCommand(pMac, pScanCmd, |
| 946 | eANI_BOOLEAN_FALSE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 947 | #else |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 948 | status = csrQueueSmeCommand(pMac, pScanCmd, |
| 949 | eANI_BOOLEAN_FALSE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 950 | #endif |
| 951 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 952 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 953 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 954 | break; |
| 955 | } |
| 956 | } |
| 957 | else |
| 958 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 959 | smsLog( pMac, LOGE, FL(" fail to copy request status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 960 | break; |
| 961 | } |
| 962 | } |
| 963 | else |
| 964 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 965 | smsLog( pMac, LOGE, FL(" pScanCmd is NULL")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 966 | break; |
| 967 | } |
| 968 | } |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 969 | else |
| 970 | { |
| 971 | smsLog( pMac, LOGE, FL("SId: %d Scanning not enabled" |
| 972 | " Scan type=%u, numOfSSIDs=%d P2P search=%d"), |
| 973 | sessionId, pScanRequest->requestType, |
| 974 | pScanRequest->SSIDs.numOfSSIDs, |
| 975 | pScanRequest->p2pSearch ); |
| 976 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 977 | } while(0); |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 978 | |
| 979 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 980 | if(!HAL_STATUS_SUCCESS(status) && pScanCmd) |
| 981 | { |
| 982 | if( eCsrScanIdleScan == pScanCmd->u.scanCmd.reason ) |
| 983 | { |
| 984 | //Set the flag back for restarting idle scan |
| 985 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 986 | } |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 987 | smsLog( pMac, LOGE, FL(" SId: %d Failed with status=%d" |
| 988 | " Scan reason=%u numOfSSIDs=%d" |
| 989 | " P2P search=%d scanId=%d"), |
| 990 | sessionId, status, pScanCmd->u.scanCmd.reason, |
| 991 | pScanRequest->SSIDs.numOfSSIDs, pScanRequest->p2pSearch, |
| 992 | pScanCmd->u.scanCmd.scanID ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 993 | csrReleaseCommandScan(pMac, pScanCmd); |
| 994 | } |
| 995 | |
| 996 | return (status); |
| 997 | } |
| 998 | |
| 999 | |
| 1000 | eHalStatus csrScanRequestResult(tpAniSirGlobal pMac) |
| 1001 | { |
| 1002 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1003 | tSmeCmd *pScanCmd; |
| 1004 | |
| 1005 | if(pMac->scan.fScanEnable) |
| 1006 | { |
| 1007 | pScanCmd = csrGetCommandBuffer(pMac); |
| 1008 | if(pScanCmd) |
| 1009 | { |
| 1010 | pScanCmd->command = eSmeCommandScan; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1011 | vos_mem_set(&pScanCmd->u.scanCmd, sizeof(tScanCmd), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1012 | pScanCmd->u.scanCmd.callback = NULL; |
| 1013 | pScanCmd->u.scanCmd.pContext = NULL; |
| 1014 | pScanCmd->u.scanCmd.reason = eCsrScanGetResult; |
| 1015 | //Need to make the following atomic |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 1016 | pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID; //let it wrap around |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1017 | status = csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_FALSE); |
| 1018 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 1019 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1020 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1021 | csrReleaseCommandScan(pMac, pScanCmd); |
| 1022 | } |
| 1023 | } |
| 1024 | else |
| 1025 | { |
| 1026 | //log error |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1027 | smsLog(pMac, LOGE, FL("can not obtain a common buffer")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1028 | status = eHAL_STATUS_RESOURCES; |
| 1029 | } |
| 1030 | } |
| 1031 | |
| 1032 | return (status); |
| 1033 | } |
| 1034 | |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 1035 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 1036 | eHalStatus csrScanRequestLfrResult(tpAniSirGlobal pMac, tANI_U32 sessionId, |
| 1037 | csrScanCompleteCallback callback, void *pContext) |
| 1038 | { |
| 1039 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1040 | tSmeCmd *pScanCmd; |
| 1041 | |
| 1042 | if (pMac->scan.fScanEnable) |
| 1043 | { |
| 1044 | pScanCmd = csrGetCommandBuffer(pMac); |
| 1045 | if (pScanCmd) |
| 1046 | { |
| 1047 | pScanCmd->command = eSmeCommandScan; |
| 1048 | pScanCmd->sessionId = sessionId; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1049 | vos_mem_set(&pScanCmd->u.scanCmd, sizeof(tScanCmd), 0); |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 1050 | pScanCmd->u.scanCmd.callback = callback; |
| 1051 | pScanCmd->u.scanCmd.pContext = pContext; |
| 1052 | pScanCmd->u.scanCmd.reason = eCsrScanGetLfrResult; |
| 1053 | //Need to make the following atomic |
| 1054 | pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID; //let it wrap around |
| 1055 | status = csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_TRUE); |
| 1056 | if ( !HAL_STATUS_SUCCESS( status ) ) |
| 1057 | { |
| 1058 | smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status ); |
| 1059 | csrReleaseCommandScan(pMac, pScanCmd); |
| 1060 | } |
| 1061 | } |
| 1062 | else |
| 1063 | { |
| 1064 | //log error |
| 1065 | smsLog(pMac, LOGE, FL("can not obtain a common buffer\n")); |
| 1066 | status = eHAL_STATUS_RESOURCES; |
| 1067 | } |
| 1068 | } |
| 1069 | |
| 1070 | return (status); |
| 1071 | } |
| 1072 | #endif //WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1073 | |
| 1074 | eHalStatus csrScanAllChannels(tpAniSirGlobal pMac, eCsrRequestType reqType) |
| 1075 | { |
| 1076 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1077 | tANI_U32 scanId; |
| 1078 | tCsrScanRequest scanReq; |
| 1079 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1080 | vos_mem_set(&scanReq, sizeof(tCsrScanRequest), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1081 | scanReq.BSSType = eCSR_BSS_TYPE_ANY; |
| 1082 | scanReq.scanType = eSIR_ACTIVE_SCAN; |
| 1083 | scanReq.requestType = reqType; |
| 1084 | scanReq.maxChnTime = pMac->roam.configParam.nActiveMaxChnTime; |
| 1085 | scanReq.minChnTime = pMac->roam.configParam.nActiveMinChnTime; |
Abhishek Singh | add1358 | 2016-09-29 17:00:03 +0530 | [diff] [blame] | 1086 | scanReq.max_chntime_btc_esco = |
| 1087 | pMac->roam.configParam.max_chntime_btc_esco; |
| 1088 | scanReq.min_chntime_btc_esco = |
| 1089 | pMac->roam.configParam.min_chntime_btc_esco; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1090 | //Scan with invalid sessionId. |
| 1091 | //This results in SME using the first available session to scan. |
| 1092 | status = csrScanRequest(pMac, CSR_SESSION_ID_INVALID, &scanReq, |
| 1093 | &scanId, NULL, NULL); |
| 1094 | |
| 1095 | return (status); |
| 1096 | } |
| 1097 | |
| 1098 | |
| 1099 | |
| 1100 | |
| 1101 | eHalStatus csrIssueRoamAfterLostlinkScan(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamReason reason) |
| 1102 | { |
| 1103 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 1104 | tScanResultHandle hBSSList = NULL; |
| 1105 | tCsrScanResultFilter *pScanFilter = NULL; |
| 1106 | tANI_U32 roamId = 0; |
| 1107 | tCsrRoamProfile *pProfile = NULL; |
| 1108 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 1109 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1110 | if(!pSession) |
| 1111 | { |
| 1112 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 1113 | return eHAL_STATUS_FAILURE; |
| 1114 | } |
| 1115 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1116 | do |
| 1117 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1118 | smsLog(pMac, LOG1, " csrIssueRoamAfterLostlinkScan called"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1119 | if(pSession->fCancelRoaming) |
| 1120 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1121 | smsLog(pMac, LOGW, " lostlink roaming is cancelled"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1122 | csrScanStartIdleScan(pMac); |
| 1123 | status = eHAL_STATUS_SUCCESS; |
| 1124 | break; |
| 1125 | } |
| 1126 | //Here is the profile we need to connect to |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1127 | pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter)); |
| 1128 | if ( NULL == pScanFilter) |
| 1129 | status = eHAL_STATUS_FAILURE; |
| 1130 | else |
| 1131 | status = eHAL_STATUS_SUCCESS; |
| 1132 | if (!HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1133 | break; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1134 | vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1135 | if(NULL == pSession->pCurRoamProfile) |
| 1136 | { |
| 1137 | pScanFilter->EncryptionType.numEntries = 1; |
| 1138 | pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE; |
| 1139 | } |
| 1140 | else |
| 1141 | { |
| 1142 | //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1143 | pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile)); |
| 1144 | if ( NULL == pProfile ) |
| 1145 | status = eHAL_STATUS_FAILURE; |
| 1146 | else |
| 1147 | status = eHAL_STATUS_SUCCESS; |
| 1148 | if (!HAL_STATUS_SUCCESS(status)) |
| 1149 | break; |
| 1150 | vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1151 | status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile); |
| 1152 | if(!HAL_STATUS_SUCCESS(status)) |
| 1153 | break; |
| 1154 | status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter); |
| 1155 | }//We have a profile |
| 1156 | roamId = GET_NEXT_ROAM_ID(&pMac->roam); |
| 1157 | if(HAL_STATUS_SUCCESS(status)) |
| 1158 | { |
| 1159 | status = csrScanGetResult(pMac, pScanFilter, &hBSSList); |
| 1160 | if(HAL_STATUS_SUCCESS(status)) |
| 1161 | { |
| 1162 | if(eCsrLostLink1 == reason) |
| 1163 | { |
| 1164 | //we want to put the last connected BSS to the very beginning, if possible |
| 1165 | csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList); |
| 1166 | } |
| 1167 | status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, reason, |
| 1168 | roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE); |
| 1169 | if(!HAL_STATUS_SUCCESS(status)) |
| 1170 | { |
| 1171 | csrScanResultPurge(pMac, hBSSList); |
| 1172 | } |
| 1173 | }//Have scan result |
| 1174 | } |
| 1175 | }while(0); |
| 1176 | if(pScanFilter) |
| 1177 | { |
| 1178 | //we need to free memory for filter if profile exists |
| 1179 | csrFreeScanFilter(pMac, pScanFilter); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1180 | vos_mem_free(pScanFilter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1181 | } |
| 1182 | if(NULL != pProfile) |
| 1183 | { |
| 1184 | csrReleaseProfile(pMac, pProfile); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1185 | vos_mem_free(pProfile); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1186 | } |
| 1187 | |
| 1188 | return (status); |
| 1189 | } |
| 1190 | |
| 1191 | |
Ratheesh S P | ece1f83 | 2015-07-25 15:50:25 +0530 | [diff] [blame] | 1192 | eHalStatus csrScanGetScanChnInfo(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1193 | { |
| 1194 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1195 | tSmeCmd *pScanCmd; |
| 1196 | |
| 1197 | if(pMac->scan.fScanEnable) |
| 1198 | { |
| 1199 | pScanCmd = csrGetCommandBuffer(pMac); |
| 1200 | if(pScanCmd) |
| 1201 | { |
| 1202 | pScanCmd->command = eSmeCommandScan; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1203 | vos_mem_set(&pScanCmd->u.scanCmd, sizeof(tScanCmd), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1204 | pScanCmd->u.scanCmd.reason = eCsrScanGetScanChnInfo; |
| 1205 | //Need to make the following atomic |
| 1206 | pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around |
Ratheesh S P | ece1f83 | 2015-07-25 15:50:25 +0530 | [diff] [blame] | 1207 | pScanCmd->sessionId = pCommand->sessionId; |
| 1208 | if( pCommand->u.scanCmd.reason == eCsrScanUserRequest) |
| 1209 | { |
| 1210 | pScanCmd->u.scanCmd.callback = NULL; |
| 1211 | pScanCmd->u.scanCmd.pContext = NULL; |
| 1212 | } else { |
| 1213 | pScanCmd->u.scanCmd.callback = pCommand->u.scanCmd.callback; |
| 1214 | pScanCmd->u.scanCmd.pContext = pCommand->u.scanCmd.pContext; |
| 1215 | pScanCmd->u.scanCmd.abortScanIndication = |
| 1216 | pCommand->u.scanCmd.abortScanIndication; |
| 1217 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1218 | status = csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_FALSE); |
| 1219 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 1220 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1221 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1222 | csrReleaseCommandScan(pMac, pScanCmd); |
| 1223 | } |
| 1224 | } |
| 1225 | else |
| 1226 | { |
| 1227 | //log error |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1228 | smsLog(pMac, LOGE, FL("can not obtain a common buffer")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1229 | status = eHAL_STATUS_RESOURCES; |
| 1230 | } |
| 1231 | } |
| 1232 | |
| 1233 | return (status); |
| 1234 | } |
| 1235 | |
| 1236 | |
| 1237 | eHalStatus csrScanHandleFailedLostlink1(tpAniSirGlobal pMac, tANI_U32 sessionId) |
| 1238 | { |
| 1239 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 1240 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 1241 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1242 | if(!pSession) |
| 1243 | { |
| 1244 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 1245 | return eHAL_STATUS_FAILURE; |
| 1246 | } |
| 1247 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1248 | smsLog(pMac, LOGW, " Lostlink scan 1 failed"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1249 | if(pSession->fCancelRoaming) |
| 1250 | { |
| 1251 | csrScanStartIdleScan(pMac); |
| 1252 | } |
| 1253 | else if(pSession->pCurRoamProfile) |
| 1254 | { |
| 1255 | //We fail lostlink1 but there may be other BSS in the cached result fit the profile. Give it a try first |
| 1256 | if(pSession->pCurRoamProfile->SSIDs.numOfSSIDs == 0 || |
| 1257 | pSession->pCurRoamProfile->SSIDs.numOfSSIDs > 1) |
| 1258 | { |
| 1259 | //try lostlink scan2 |
| 1260 | status = csrScanRequestLostLink2(pMac, sessionId); |
| 1261 | } |
| 1262 | else if(!pSession->pCurRoamProfile->ChannelInfo.ChannelList || |
| 1263 | pSession->pCurRoamProfile->ChannelInfo.ChannelList[0] == 0) |
| 1264 | { |
| 1265 | //go straight to lostlink scan3 |
| 1266 | status = csrScanRequestLostLink3(pMac, sessionId); |
| 1267 | } |
| 1268 | else |
| 1269 | { |
| 1270 | //we are done with lostlink |
| 1271 | if(csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_FALSE, eCSR_ROAM_RESULT_FAILURE)) |
| 1272 | { |
| 1273 | csrScanStartIdleScan(pMac); |
| 1274 | } |
| 1275 | status = eHAL_STATUS_SUCCESS; |
| 1276 | } |
| 1277 | } |
| 1278 | else |
| 1279 | { |
| 1280 | status = csrScanRequestLostLink3(pMac, sessionId); |
| 1281 | } |
| 1282 | |
| 1283 | return (status); |
| 1284 | } |
| 1285 | |
| 1286 | |
| 1287 | |
| 1288 | eHalStatus csrScanHandleFailedLostlink2(tpAniSirGlobal pMac, tANI_U32 sessionId) |
| 1289 | { |
| 1290 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 1291 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 1292 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1293 | if(!pSession) |
| 1294 | { |
| 1295 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 1296 | return eHAL_STATUS_FAILURE; |
| 1297 | } |
| 1298 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1299 | smsLog(pMac, LOGW, " Lostlink scan 2 failed"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1300 | if(pSession->fCancelRoaming) |
| 1301 | { |
| 1302 | csrScanStartIdleScan(pMac); |
| 1303 | } |
| 1304 | else if(!pSession->pCurRoamProfile || !pSession->pCurRoamProfile->ChannelInfo.ChannelList || |
| 1305 | pSession->pCurRoamProfile->ChannelInfo.ChannelList[0] == 0) |
| 1306 | { |
| 1307 | //try lostlink scan3 |
| 1308 | status = csrScanRequestLostLink3(pMac, sessionId); |
| 1309 | } |
| 1310 | else |
| 1311 | { |
| 1312 | //we are done with lostlink |
| 1313 | if(csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_FALSE, eCSR_ROAM_RESULT_FAILURE)) |
| 1314 | { |
| 1315 | csrScanStartIdleScan(pMac); |
| 1316 | } |
| 1317 | } |
| 1318 | |
| 1319 | return (status); |
| 1320 | } |
| 1321 | |
| 1322 | |
| 1323 | |
| 1324 | eHalStatus csrScanHandleFailedLostlink3(tpAniSirGlobal pMac, tANI_U32 sessionId) |
| 1325 | { |
| 1326 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1327 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1328 | smsLog(pMac, LOGW, " Lostlink scan 3 failed"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1329 | if(eANI_BOOLEAN_TRUE == csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_FALSE, eCSR_ROAM_RESULT_FAILURE)) |
| 1330 | { |
| 1331 | //we are done with lostlink |
| 1332 | csrScanStartIdleScan(pMac); |
| 1333 | } |
| 1334 | |
| 1335 | return (status); |
| 1336 | } |
| 1337 | |
| 1338 | |
| 1339 | |
| 1340 | |
| 1341 | //Lostlink1 scan is to actively scan the last connected profile's SSID on all matched BSS channels. |
| 1342 | //If no roam profile (it should not), it is like lostlinkscan3 |
| 1343 | eHalStatus csrScanRequestLostLink1( tpAniSirGlobal pMac, tANI_U32 sessionId ) |
| 1344 | { |
| 1345 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1346 | tSmeCmd *pCommand = NULL; |
| 1347 | tANI_U8 bAddr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; |
| 1348 | tCsrScanResultFilter *pScanFilter = NULL; |
| 1349 | tScanResultHandle hBSSList = NULL; |
| 1350 | tCsrScanResultInfo *pScanResult = NULL; |
| 1351 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 1352 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1353 | if(!pSession) |
| 1354 | { |
| 1355 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 1356 | return eHAL_STATUS_FAILURE; |
| 1357 | } |
| 1358 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1359 | smsLog(pMac, LOGW, FL(" called")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1360 | do |
| 1361 | { |
| 1362 | pCommand = csrGetCommandBuffer(pMac); |
| 1363 | if(!pCommand) |
| 1364 | { |
| 1365 | status = eHAL_STATUS_RESOURCES; |
| 1366 | break; |
| 1367 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1368 | vos_mem_set(&pCommand->u.scanCmd, sizeof(tScanCmd), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1369 | pCommand->command = eSmeCommandScan; |
| 1370 | pCommand->sessionId = (tANI_U8)sessionId; |
| 1371 | pCommand->u.scanCmd.reason = eCsrScanLostLink1; |
| 1372 | pCommand->u.scanCmd.callback = NULL; |
| 1373 | pCommand->u.scanCmd.pContext = NULL; |
| 1374 | pCommand->u.scanCmd.u.scanRequest.maxChnTime = pMac->roam.configParam.nActiveMaxChnTime; |
| 1375 | pCommand->u.scanCmd.u.scanRequest.minChnTime = pMac->roam.configParam.nActiveMinChnTime; |
Abhishek Singh | add1358 | 2016-09-29 17:00:03 +0530 | [diff] [blame] | 1376 | pCommand->u.scanCmd.u.scanRequest.max_chntime_btc_esco = |
| 1377 | pMac->roam.configParam.max_chntime_btc_esco; |
| 1378 | pCommand->u.scanCmd.u.scanRequest.min_chntime_btc_esco = |
| 1379 | pMac->roam.configParam.min_chntime_btc_esco; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1380 | pCommand->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 1381 | if(pSession->connectedProfile.SSID.length) |
| 1382 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1383 | pCommand->u.scanCmd.u.scanRequest.SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo)); |
| 1384 | if ( NULL == pCommand->u.scanCmd.u.scanRequest.SSIDs.SSIDList ) |
| 1385 | status = eHAL_STATUS_FAILURE; |
| 1386 | else |
| 1387 | status = eHAL_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1388 | if(!HAL_STATUS_SUCCESS(status)) |
| 1389 | { |
| 1390 | break; |
| 1391 | } |
| 1392 | pCommand->u.scanCmd.u.scanRequest.SSIDs.numOfSSIDs = 1; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1393 | vos_mem_copy(&pCommand->u.scanCmd.u.scanRequest.SSIDs.SSIDList[0].SSID, |
| 1394 | &pSession->connectedProfile.SSID, sizeof(tSirMacSSid)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1395 | } |
| 1396 | else |
| 1397 | { |
| 1398 | pCommand->u.scanCmd.u.scanRequest.SSIDs.numOfSSIDs = 0; |
| 1399 | } |
| 1400 | if(pSession->pCurRoamProfile) |
| 1401 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1402 | pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter)); |
| 1403 | if ( NULL == pScanFilter ) |
| 1404 | status = eHAL_STATUS_FAILURE; |
| 1405 | else |
| 1406 | status = eHAL_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1407 | if(!HAL_STATUS_SUCCESS(status)) |
| 1408 | { |
| 1409 | break; |
| 1410 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1411 | vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1412 | status = csrRoamPrepareFilterFromProfile(pMac, pSession->pCurRoamProfile, pScanFilter); |
| 1413 | if(!HAL_STATUS_SUCCESS(status)) |
| 1414 | { |
| 1415 | break; |
| 1416 | } |
| 1417 | //Don't change variable status here because whether we can get result or not, the command goes to PE. |
| 1418 | //The status is also used to indicate whether the command is queued. Not success meaning not queue |
| 1419 | if(HAL_STATUS_SUCCESS((csrScanGetResult(pMac, pScanFilter, &hBSSList))) && hBSSList) |
| 1420 | { |
| 1421 | tANI_U8 i, nChn = 0; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1422 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = |
| 1423 | vos_mem_malloc(WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 1424 | if ( NULL == pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList ) |
| 1425 | status = eHAL_STATUS_FAILURE; |
| 1426 | else |
| 1427 | status = eHAL_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1428 | if(!HAL_STATUS_SUCCESS(status)) |
| 1429 | { |
| 1430 | break; |
| 1431 | } |
| 1432 | while(((pScanResult = csrScanResultGetNext(pMac, hBSSList)) != NULL) && |
| 1433 | nChn < WNI_CFG_VALID_CHANNEL_LIST_LEN) |
| 1434 | { |
| 1435 | for(i = 0; i < nChn; i++) |
| 1436 | { |
| 1437 | if(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[i] == |
| 1438 | pScanResult->BssDescriptor.channelId) |
| 1439 | { |
| 1440 | break; |
| 1441 | } |
| 1442 | } |
| 1443 | if(i == nChn) |
| 1444 | { |
| 1445 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[nChn++] = pScanResult->BssDescriptor.channelId; |
| 1446 | } |
| 1447 | } |
| 1448 | //Include the last connected BSS' channel |
| 1449 | if(csrRoamIsChannelValid(pMac, pSession->connectedProfile.operationChannel)) |
| 1450 | { |
| 1451 | for(i = 0; i < nChn; i++) |
| 1452 | { |
| 1453 | if(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[i] == |
| 1454 | pSession->connectedProfile.operationChannel) |
| 1455 | { |
| 1456 | break; |
| 1457 | } |
| 1458 | } |
| 1459 | if(i == nChn) |
| 1460 | { |
| 1461 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[nChn++] = pSession->connectedProfile.operationChannel; |
| 1462 | } |
| 1463 | } |
| 1464 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = nChn; |
| 1465 | } |
| 1466 | else |
| 1467 | { |
| 1468 | if(csrRoamIsChannelValid(pMac, pSession->connectedProfile.operationChannel)) |
| 1469 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1470 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = vos_mem_malloc(1); |
| 1471 | if ( NULL == pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList ) |
| 1472 | status = eHAL_STATUS_FAILURE; |
| 1473 | else |
| 1474 | status = eHAL_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1475 | //just try the last connected channel |
| 1476 | if(HAL_STATUS_SUCCESS(status)) |
| 1477 | { |
| 1478 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[0] = pSession->connectedProfile.operationChannel; |
| 1479 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = 1; |
| 1480 | } |
| 1481 | else |
| 1482 | { |
| 1483 | break; |
| 1484 | } |
| 1485 | } |
| 1486 | } |
| 1487 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1488 | vos_mem_copy(&pCommand->u.scanCmd.u.scanRequest.bssid, bAddr, sizeof(tCsrBssid)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1489 | status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE); |
| 1490 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 1491 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1492 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1493 | break; |
| 1494 | } |
| 1495 | } while( 0 ); |
| 1496 | |
| 1497 | if(!HAL_STATUS_SUCCESS(status)) |
| 1498 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1499 | smsLog(pMac, LOGW, " csrScanRequestLostLink1 failed with status %d", status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1500 | if(pCommand) |
| 1501 | { |
| 1502 | csrReleaseCommandScan(pMac, pCommand); |
| 1503 | } |
| 1504 | status = csrScanHandleFailedLostlink1( pMac, sessionId ); |
| 1505 | } |
| 1506 | if(pScanFilter) |
| 1507 | { |
| 1508 | csrFreeScanFilter(pMac, pScanFilter); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1509 | vos_mem_free(pScanFilter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1510 | } |
| 1511 | if(hBSSList) |
| 1512 | { |
| 1513 | csrScanResultPurge(pMac, hBSSList); |
| 1514 | } |
| 1515 | |
| 1516 | return( status ); |
| 1517 | } |
| 1518 | |
| 1519 | |
| 1520 | //Lostlink2 scan is to actively scan the all SSIDs of the last roaming profile's on all matched BSS channels. |
| 1521 | //Since MAC doesn't support multiple SSID, we scan all SSIDs and filter them afterwards |
| 1522 | eHalStatus csrScanRequestLostLink2( tpAniSirGlobal pMac, tANI_U32 sessionId ) |
| 1523 | { |
| 1524 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1525 | tANI_U8 bAddr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; |
| 1526 | tCsrScanResultFilter *pScanFilter = NULL; |
| 1527 | tScanResultHandle hBSSList = NULL; |
| 1528 | tCsrScanResultInfo *pScanResult = NULL; |
| 1529 | tSmeCmd *pCommand = NULL; |
| 1530 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 1531 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1532 | if(!pSession) |
| 1533 | { |
| 1534 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 1535 | return eHAL_STATUS_FAILURE; |
| 1536 | } |
| 1537 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1538 | smsLog(pMac, LOGW, FL(" called")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1539 | do |
| 1540 | { |
| 1541 | pCommand = csrGetCommandBuffer(pMac); |
| 1542 | if(!pCommand) |
| 1543 | { |
| 1544 | status = eHAL_STATUS_RESOURCES; |
| 1545 | break; |
| 1546 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1547 | vos_mem_set(&pCommand->u.scanCmd, sizeof(tScanCmd), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1548 | pCommand->command = eSmeCommandScan; |
| 1549 | pCommand->sessionId = (tANI_U8)sessionId; |
| 1550 | pCommand->u.scanCmd.reason = eCsrScanLostLink2; |
| 1551 | pCommand->u.scanCmd.callback = NULL; |
| 1552 | pCommand->u.scanCmd.pContext = NULL; |
| 1553 | pCommand->u.scanCmd.u.scanRequest.maxChnTime = pMac->roam.configParam.nActiveMaxChnTime; |
| 1554 | pCommand->u.scanCmd.u.scanRequest.minChnTime = pMac->roam.configParam.nActiveMinChnTime; |
Abhishek Singh | add1358 | 2016-09-29 17:00:03 +0530 | [diff] [blame] | 1555 | pCommand->u.scanCmd.u.scanRequest.max_chntime_btc_esco = |
| 1556 | pMac->roam.configParam.max_chntime_btc_esco; |
| 1557 | pCommand->u.scanCmd.u.scanRequest.min_chntime_btc_esco = |
| 1558 | pMac->roam.configParam.min_chntime_btc_esco; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1559 | pCommand->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 1560 | if(pSession->pCurRoamProfile) |
| 1561 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1562 | pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter)); |
| 1563 | if ( NULL == pScanFilter ) |
| 1564 | status = eHAL_STATUS_FAILURE; |
| 1565 | else |
| 1566 | status = eHAL_STATUS_SUCCESS; |
| 1567 | if (!HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1568 | { |
| 1569 | break; |
| 1570 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1571 | vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1572 | status = csrRoamPrepareFilterFromProfile(pMac, pSession->pCurRoamProfile, pScanFilter); |
| 1573 | if(!HAL_STATUS_SUCCESS(status)) |
| 1574 | { |
| 1575 | break; |
| 1576 | } |
| 1577 | status = csrScanGetResult(pMac, pScanFilter, &hBSSList); |
| 1578 | if(!HAL_STATUS_SUCCESS(status)) |
| 1579 | { |
| 1580 | break; |
| 1581 | } |
| 1582 | if(hBSSList) |
| 1583 | { |
| 1584 | tANI_U8 i, nChn = 0; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1585 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = |
| 1586 | vos_mem_malloc(WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 1587 | if ( NULL == pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList ) |
| 1588 | status = eHAL_STATUS_FAILURE; |
| 1589 | else |
| 1590 | status = eHAL_STATUS_SUCCESS; |
| 1591 | if (!HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1592 | { |
| 1593 | break; |
| 1594 | } |
| 1595 | while(((pScanResult = csrScanResultGetNext(pMac, hBSSList)) != NULL) && |
| 1596 | nChn < WNI_CFG_VALID_CHANNEL_LIST_LEN) |
| 1597 | { |
| 1598 | for(i = 0; i < nChn; i++) |
| 1599 | { |
| 1600 | if(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[i] == |
| 1601 | pScanResult->BssDescriptor.channelId) |
| 1602 | { |
| 1603 | break; |
| 1604 | } |
| 1605 | } |
| 1606 | if(i == nChn) |
| 1607 | { |
| 1608 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[nChn++] = pScanResult->BssDescriptor.channelId; |
| 1609 | } |
| 1610 | } |
| 1611 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = nChn; |
| 1612 | } |
| 1613 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1614 | vos_mem_copy(&pCommand->u.scanCmd.u.scanRequest.bssid, bAddr, sizeof(tCsrBssid)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1615 | //Put to the head in pending queue |
| 1616 | status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE); |
| 1617 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 1618 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1619 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1620 | break; |
| 1621 | } |
| 1622 | } while( 0 ); |
| 1623 | |
| 1624 | if(!HAL_STATUS_SUCCESS(status)) |
| 1625 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1626 | smsLog(pMac, LOGW, " csrScanRequestLostLink2 failed with status %d", status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1627 | if(pCommand) |
| 1628 | { |
| 1629 | csrReleaseCommandScan(pMac, pCommand); |
| 1630 | } |
| 1631 | status = csrScanHandleFailedLostlink2( pMac, sessionId ); |
| 1632 | } |
| 1633 | if(pScanFilter) |
| 1634 | { |
| 1635 | csrFreeScanFilter(pMac, pScanFilter); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1636 | vos_mem_free(pScanFilter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1637 | } |
| 1638 | if(hBSSList) |
| 1639 | { |
| 1640 | csrScanResultPurge(pMac, hBSSList); |
| 1641 | } |
| 1642 | |
| 1643 | return( status ); |
| 1644 | } |
| 1645 | |
| 1646 | |
| 1647 | //To actively scan all valid channels |
| 1648 | eHalStatus csrScanRequestLostLink3( tpAniSirGlobal pMac, tANI_U32 sessionId ) |
| 1649 | { |
| 1650 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1651 | tSmeCmd *pCommand; |
| 1652 | tANI_U8 bAddr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; |
| 1653 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1654 | smsLog(pMac, LOGW, FL(" called")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1655 | do |
| 1656 | { |
| 1657 | pCommand = csrGetCommandBuffer(pMac); |
| 1658 | if(!pCommand) |
| 1659 | { |
| 1660 | status = eHAL_STATUS_RESOURCES; |
| 1661 | break; |
| 1662 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1663 | vos_mem_set(&pCommand->u.scanCmd, sizeof(tScanCmd), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1664 | pCommand->command = eSmeCommandScan; |
| 1665 | pCommand->sessionId = (tANI_U8)sessionId; |
| 1666 | pCommand->u.scanCmd.reason = eCsrScanLostLink3; |
| 1667 | pCommand->u.scanCmd.callback = NULL; |
| 1668 | pCommand->u.scanCmd.pContext = NULL; |
| 1669 | pCommand->u.scanCmd.u.scanRequest.maxChnTime = pMac->roam.configParam.nActiveMaxChnTime; |
| 1670 | pCommand->u.scanCmd.u.scanRequest.minChnTime = pMac->roam.configParam.nActiveMinChnTime; |
Abhishek Singh | add1358 | 2016-09-29 17:00:03 +0530 | [diff] [blame] | 1671 | pCommand->u.scanCmd.u.scanRequest.max_chntime_btc_esco = |
| 1672 | pMac->roam.configParam.max_chntime_btc_esco; |
| 1673 | pCommand->u.scanCmd.u.scanRequest.min_chntime_btc_esco = |
| 1674 | pMac->roam.configParam.min_chntime_btc_esco; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1675 | pCommand->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1676 | vos_mem_copy(&pCommand->u.scanCmd.u.scanRequest.bssid, bAddr, sizeof(tCsrBssid)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1677 | //Put to the head of pending queue |
| 1678 | status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE); |
| 1679 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 1680 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1681 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1682 | break; |
| 1683 | } |
| 1684 | } while( 0 ); |
| 1685 | if(!HAL_STATUS_SUCCESS(status)) |
| 1686 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1687 | smsLog(pMac, LOGW, " csrScanRequestLostLink3 failed with status %d", status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1688 | if(csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_FALSE, eCSR_ROAM_RESULT_FAILURE)) |
| 1689 | { |
| 1690 | csrScanStartIdleScan(pMac); |
| 1691 | } |
| 1692 | if(pCommand) |
| 1693 | { |
| 1694 | csrReleaseCommandScan(pMac, pCommand); |
| 1695 | } |
| 1696 | } |
| 1697 | |
| 1698 | return( status ); |
| 1699 | } |
| 1700 | |
| 1701 | |
| 1702 | eHalStatus csrScanHandleSearchForSSID(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
| 1703 | { |
| 1704 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 1705 | tScanResultHandle hBSSList = CSR_INVALID_SCANRESULT_HANDLE; |
| 1706 | tCsrScanResultFilter *pScanFilter = NULL; |
| 1707 | tCsrRoamProfile *pProfile = pCommand->u.scanCmd.pToRoamProfile; |
| 1708 | tANI_U32 sessionId = pCommand->sessionId; |
Abhishek Singh | d61b97a | 2015-12-17 15:23:52 +0530 | [diff] [blame] | 1709 | tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId); |
| 1710 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1711 | do |
| 1712 | { |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 1713 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 1714 | //if this scan is for LFR |
| 1715 | if(pMac->roam.neighborRoamInfo.uOsRequestedHandoff) |
| 1716 | { |
| 1717 | //notify LFR state m/c |
| 1718 | if(eHAL_STATUS_SUCCESS != csrNeighborRoamSssidScanDone(pMac, eHAL_STATUS_SUCCESS)) |
| 1719 | { |
Mukul Sharma | 20aa658 | 2014-08-07 21:36:12 +0530 | [diff] [blame] | 1720 | csrNeighborRoamStartLfrScan(pMac, REASON_OS_REQUESTED_ROAMING_NOW); |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 1721 | } |
| 1722 | status = eHAL_STATUS_SUCCESS; |
| 1723 | break; |
| 1724 | } |
| 1725 | #endif |
Abhishek Singh | d61b97a | 2015-12-17 15:23:52 +0530 | [diff] [blame] | 1726 | if (!pSession) |
| 1727 | { |
| 1728 | smsLog(pMac, LOGE, FL("session %d not found"), sessionId); |
| 1729 | break; |
| 1730 | } |
Abhishek Singh | 5de9efd | 2017-06-15 10:22:39 +0530 | [diff] [blame] | 1731 | /* If Disconnect is already issued from HDD no need to issue connect */ |
| 1732 | if (pSession->abortConnection) |
Abhishek Singh | d61b97a | 2015-12-17 15:23:52 +0530 | [diff] [blame] | 1733 | { |
| 1734 | smsLog(pMac, LOGE, |
| 1735 | FL("Disconnect in progress, no need to issue connect")); |
| 1736 | break; |
| 1737 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1738 | //If there is roam command waiting, ignore this roam because the newer roam command is the one to execute |
| 1739 | if(csrIsRoamCommandWaitingForSession(pMac, sessionId)) |
| 1740 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1741 | smsLog(pMac, LOGW, FL(" aborts because roam command waiting")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1742 | break; |
| 1743 | } |
| 1744 | if(pProfile == NULL) |
| 1745 | break; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1746 | pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter)); |
| 1747 | if ( NULL == pScanFilter ) |
| 1748 | status = eHAL_STATUS_FAILURE; |
| 1749 | else |
| 1750 | status = eHAL_STATUS_SUCCESS; |
| 1751 | if (!HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1752 | break; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1753 | vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1754 | status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter); |
| 1755 | if(!HAL_STATUS_SUCCESS(status)) |
| 1756 | break; |
| 1757 | status = csrScanGetResult(pMac, pScanFilter, &hBSSList); |
| 1758 | if(!HAL_STATUS_SUCCESS(status)) |
| 1759 | break; |
| 1760 | status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued, |
| 1761 | pCommand->u.scanCmd.roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE); |
| 1762 | if(!HAL_STATUS_SUCCESS(status)) |
| 1763 | { |
| 1764 | break; |
| 1765 | } |
| 1766 | }while(0); |
| 1767 | if(!HAL_STATUS_SUCCESS(status)) |
| 1768 | { |
| 1769 | if(CSR_INVALID_SCANRESULT_HANDLE != hBSSList) |
| 1770 | { |
| 1771 | csrScanResultPurge(pMac, hBSSList); |
| 1772 | } |
| 1773 | //We haven't done anything to this profile |
Abhishek Singh | 72c2f4e | 2016-07-22 11:25:43 +0530 | [diff] [blame] | 1774 | csrRoamCallCallback(pMac, sessionId, NULL, |
| 1775 | pCommand->u.scanCmd.roamId, |
| 1776 | eCSR_ROAM_ASSOCIATION_FAILURE, |
| 1777 | eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1778 | //In case we have nothing else to do, restart idle scan |
| 1779 | if(csrIsConnStateDisconnected(pMac, sessionId) && !csrIsRoamCommandWaiting(pMac)) |
| 1780 | { |
| 1781 | status = csrScanStartIdleScan(pMac); |
| 1782 | } |
| 1783 | #ifdef FEATURE_WLAN_BTAMP_UT_RF |
| 1784 | //In case of WDS station, let it retry. |
| 1785 | if( CSR_IS_WDS_STA(pProfile) ) |
| 1786 | { |
| 1787 | //Save the roma profile so we can retry |
| 1788 | csrFreeRoamProfile( pMac, sessionId ); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1789 | pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile)); |
| 1790 | if ( NULL != pSession->pCurRoamProfile ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1791 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1792 | vos_mem_set(pSession->pCurRoamProfilee, sizeof(tCsrRoamProfile), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1793 | csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile); |
| 1794 | } |
| 1795 | csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD); |
| 1796 | } |
| 1797 | #endif |
| 1798 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1799 | if (pScanFilter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1800 | { |
| 1801 | csrFreeScanFilter(pMac, pScanFilter); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1802 | vos_mem_free(pScanFilter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1803 | } |
| 1804 | |
| 1805 | return (status); |
| 1806 | } |
| 1807 | |
| 1808 | |
| 1809 | eHalStatus csrScanHandleSearchForSSIDFailure(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
| 1810 | { |
| 1811 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1812 | tANI_U32 sessionId = pCommand->sessionId; |
| 1813 | tCsrRoamProfile *pProfile = pCommand->u.scanCmd.pToRoamProfile; |
| 1814 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 1815 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 1816 | //if this scan is for LFR |
| 1817 | if(pMac->roam.neighborRoamInfo.uOsRequestedHandoff) |
| 1818 | { |
| 1819 | //notify LFR state m/c |
| 1820 | if(eHAL_STATUS_SUCCESS != csrNeighborRoamSssidScanDone(pMac, eHAL_STATUS_FAILURE)) |
| 1821 | { |
Mukul Sharma | 20aa658 | 2014-08-07 21:36:12 +0530 | [diff] [blame] | 1822 | csrNeighborRoamStartLfrScan(pMac, REASON_OS_REQUESTED_ROAMING_NOW); |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 1823 | } |
| 1824 | return eHAL_STATUS_SUCCESS; |
| 1825 | } |
| 1826 | #endif |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1827 | if(!pSession) |
| 1828 | { |
| 1829 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 1830 | return eHAL_STATUS_FAILURE; |
| 1831 | } |
| 1832 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1833 | #if defined(WLAN_DEBUG) |
| 1834 | if(pCommand->u.scanCmd.u.scanRequest.SSIDs.numOfSSIDs == 1) |
| 1835 | { |
| 1836 | char str[36]; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1837 | vos_mem_copy(str, |
| 1838 | pCommand->u.scanCmd.u.scanRequest.SSIDs.SSIDList[0].SSID.ssId, |
| 1839 | pCommand->u.scanCmd.u.scanRequest.SSIDs.SSIDList[0].SSID.length); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1840 | str[pCommand->u.scanCmd.u.scanRequest.SSIDs.SSIDList[0].SSID.length] = 0; |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1841 | smsLog(pMac, LOGW, FL(" SSID = %s"), str); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1842 | } |
| 1843 | #endif |
| 1844 | //Check whether it is for start ibss. No need to do anything if it is a JOIN request |
| 1845 | if(pProfile && CSR_IS_START_IBSS(pProfile)) |
| 1846 | { |
| 1847 | status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued, |
| 1848 | pCommand->u.scanCmd.roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE); |
| 1849 | if(!HAL_STATUS_SUCCESS(status)) |
| 1850 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1851 | smsLog(pMac, LOGE, FL("failed to issue startIBSS command with status = 0x%08X"), status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1852 | csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.scanCmd.roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE); |
| 1853 | } |
| 1854 | } |
| 1855 | else |
| 1856 | { |
| 1857 | eCsrRoamResult roamResult = eCSR_ROAM_RESULT_FAILURE; |
| 1858 | |
| 1859 | if(csrIsConnStateDisconnected(pMac, sessionId) && |
| 1860 | !csrIsRoamCommandWaitingForSession(pMac, sessionId)) |
| 1861 | { |
| 1862 | status = csrScanStartIdleScan(pMac); |
| 1863 | } |
| 1864 | if((NULL == pProfile) || !csrIsBssTypeIBSS(pProfile->BSSType)) |
| 1865 | { |
| 1866 | //Only indicate assoc_completion if we indicate assoc_start. |
| 1867 | if(pSession->bRefAssocStartCnt > 0) |
| 1868 | { |
| 1869 | tCsrRoamInfo *pRoamInfo = NULL, roamInfo; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1870 | vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1871 | pRoamInfo = &roamInfo; |
| 1872 | if(pCommand->u.roamCmd.pRoamBssEntry) |
| 1873 | { |
| 1874 | tCsrScanResult *pScanResult = |
| 1875 | GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, |
| 1876 | tCsrScanResult, Link); |
| 1877 | roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor; |
| 1878 | } |
| 1879 | roamInfo.statusCode = pSession->joinFailStatusCode.statusCode; |
| 1880 | roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode; |
| 1881 | pSession->bRefAssocStartCnt--; |
| 1882 | csrRoamCallCallback(pMac, sessionId, pRoamInfo, |
| 1883 | pCommand->u.scanCmd.roamId, |
| 1884 | eCSR_ROAM_ASSOCIATION_COMPLETION, |
Abhishek Singh | 72c2f4e | 2016-07-22 11:25:43 +0530 | [diff] [blame] | 1885 | eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1886 | } |
Madan Mohan Koyyalamudi | ee255f1 | 2012-09-28 15:41:19 -0700 | [diff] [blame] | 1887 | else |
| 1888 | { |
| 1889 | csrRoamCallCallback(pMac, sessionId, NULL, |
| 1890 | pCommand->u.scanCmd.roamId, |
| 1891 | eCSR_ROAM_ASSOCIATION_FAILURE, |
Abhishek Singh | 72c2f4e | 2016-07-22 11:25:43 +0530 | [diff] [blame] | 1892 | eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE); |
Madan Mohan Koyyalamudi | ee255f1 | 2012-09-28 15:41:19 -0700 | [diff] [blame] | 1893 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1894 | #ifdef FEATURE_WLAN_BTAMP_UT_RF |
| 1895 | //In case of WDS station, let it retry. |
| 1896 | if( CSR_IS_WDS_STA(pProfile) ) |
| 1897 | { |
| 1898 | //Save the roma profile so we can retry |
| 1899 | csrFreeRoamProfile( pMac, sessionId ); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1900 | pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile)); |
| 1901 | if ( NULL != pSession->pCurRoamProfile ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1902 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1903 | vos_mem_set(pSession->pCurRoamProfile, sizeof(tCsrRoamProfile), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1904 | csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile); |
| 1905 | } |
| 1906 | csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD); |
| 1907 | } |
| 1908 | #endif |
| 1909 | } |
| 1910 | else |
| 1911 | { |
| 1912 | roamResult = eCSR_ROAM_RESULT_IBSS_START_FAILED; |
| 1913 | } |
| 1914 | csrRoamCompletion(pMac, sessionId, NULL, pCommand, roamResult, eANI_BOOLEAN_FALSE); |
| 1915 | } |
| 1916 | |
| 1917 | return (status); |
| 1918 | } |
| 1919 | |
| 1920 | |
| 1921 | //After scan for cap changes, issue a roaming command to either reconnect to the AP or pick another one to connect |
| 1922 | eHalStatus csrScanHandleCapChangeScanComplete(tpAniSirGlobal pMac, tANI_U32 sessionId) |
| 1923 | { |
| 1924 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 1925 | tScanResultHandle hBSSList = NULL; |
| 1926 | tCsrScanResultFilter *pScanFilter = NULL; |
| 1927 | tANI_U32 roamId = 0; |
| 1928 | tCsrRoamProfile *pProfile = NULL; |
| 1929 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 1930 | |
| 1931 | do |
| 1932 | { |
| 1933 | //Here is the profile we need to connect to |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1934 | pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter)); |
| 1935 | if ( NULL == pScanFilter ) |
| 1936 | status = eHAL_STATUS_FAILURE; |
| 1937 | else |
| 1938 | status = eHAL_STATUS_SUCCESS; |
| 1939 | if (!HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1940 | break; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1941 | vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0); |
| 1942 | if (NULL == pSession) break; |
| 1943 | if (NULL == pSession->pCurRoamProfile) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1944 | { |
| 1945 | pScanFilter->EncryptionType.numEntries = 1; |
| 1946 | pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE; |
| 1947 | } |
| 1948 | else |
| 1949 | { |
| 1950 | //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1951 | pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile)); |
| 1952 | if ( NULL == pProfile ) |
| 1953 | status = eHAL_STATUS_FAILURE; |
| 1954 | else |
| 1955 | status = eHAL_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1956 | if(!HAL_STATUS_SUCCESS(status)) |
| 1957 | break; |
| 1958 | status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile); |
| 1959 | if(!HAL_STATUS_SUCCESS(status)) |
| 1960 | break; |
| 1961 | status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter); |
| 1962 | }//We have a profile |
| 1963 | roamId = GET_NEXT_ROAM_ID(&pMac->roam); |
| 1964 | if(HAL_STATUS_SUCCESS(status)) |
| 1965 | { |
| 1966 | status = csrScanGetResult(pMac, pScanFilter, &hBSSList); |
| 1967 | if(HAL_STATUS_SUCCESS(status)) |
| 1968 | { |
| 1969 | //we want to put the last connected BSS to the very beginning, if possible |
| 1970 | csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList); |
| 1971 | status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, |
| 1972 | eCsrCapsChange, 0, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE); |
| 1973 | if(!HAL_STATUS_SUCCESS(status)) |
| 1974 | { |
| 1975 | csrScanResultPurge(pMac, hBSSList); |
| 1976 | } |
| 1977 | }//Have scan result |
| 1978 | else |
| 1979 | { |
Arif Hussain | a7c8e41 | 2013-11-20 11:06:42 -0800 | [diff] [blame] | 1980 | smsLog(pMac, LOGW, FL("cannot find matching BSS of " |
| 1981 | MAC_ADDRESS_STR), |
| 1982 | MAC_ADDR_ARRAY(pSession->connectedProfile.bssid)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1983 | //Disconnect |
| 1984 | csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED); |
| 1985 | } |
| 1986 | } |
| 1987 | }while(0); |
| 1988 | if(pScanFilter) |
| 1989 | { |
| 1990 | csrFreeScanFilter(pMac, pScanFilter); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1991 | vos_mem_free(pScanFilter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1992 | } |
| 1993 | if(NULL != pProfile) |
| 1994 | { |
| 1995 | csrReleaseProfile(pMac, pProfile); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1996 | vos_mem_free(pProfile); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1997 | } |
| 1998 | |
| 1999 | return (status); |
| 2000 | } |
| 2001 | |
| 2002 | |
| 2003 | |
| 2004 | eHalStatus csrScanResultPurge(tpAniSirGlobal pMac, tScanResultHandle hScanList) |
| 2005 | { |
| 2006 | eHalStatus status = eHAL_STATUS_INVALID_PARAMETER; |
| 2007 | tScanResultList *pScanList = (tScanResultList *)hScanList; |
| 2008 | |
| 2009 | if(pScanList) |
| 2010 | { |
| 2011 | status = csrLLScanPurgeResult(pMac, &pScanList->List); |
| 2012 | csrLLClose(&pScanList->List); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2013 | vos_mem_free(pScanList); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2014 | } |
| 2015 | return (status); |
| 2016 | } |
| 2017 | |
| 2018 | |
| 2019 | static tANI_U32 csrGetBssPreferValue(tpAniSirGlobal pMac, int rssi) |
| 2020 | { |
| 2021 | tANI_U32 ret = 0; |
| 2022 | int i = CSR_NUM_RSSI_CAT - 1; |
| 2023 | |
| 2024 | while(i >= 0) |
| 2025 | { |
| 2026 | if(rssi >= pMac->roam.configParam.RSSICat[i]) |
| 2027 | { |
| 2028 | ret = pMac->roam.configParam.BssPreferValue[i]; |
| 2029 | break; |
| 2030 | } |
| 2031 | i--; |
| 2032 | }; |
| 2033 | |
| 2034 | return (ret); |
| 2035 | } |
| 2036 | |
| 2037 | |
| 2038 | //Return a CapValue base on the capabilities of a BSS |
| 2039 | static tANI_U32 csrGetBssCapValue(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes) |
| 2040 | { |
| 2041 | tANI_U32 ret = CSR_BSS_CAP_VALUE_NONE; |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2042 | #if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR) |
Madan Mohan Koyyalamudi | d502607 | 2012-11-30 14:56:21 -0800 | [diff] [blame] | 2043 | if(CSR_IS_ROAM_PREFER_5GHZ(pMac)) |
| 2044 | { |
| 2045 | if((pBssDesc) && CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId)) |
| 2046 | { |
| 2047 | ret += CSR_BSS_CAP_VALUE_5GHZ; |
| 2048 | } |
| 2049 | } |
| 2050 | #endif |
Srinivas Girigowda | 41c7c5f | 2013-10-21 19:01:38 -0700 | [diff] [blame] | 2051 | /* if strict select 5GHz is non-zero then ignore the capability checking */ |
| 2052 | if (pIes && !CSR_IS_SELECT_5GHZ_MARGIN(pMac)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2053 | { |
| 2054 | //We only care about 11N capability |
| 2055 | if(pIes->HTCaps.present) |
| 2056 | { |
| 2057 | ret += CSR_BSS_CAP_VALUE_HT; |
| 2058 | } |
| 2059 | if(CSR_IS_QOS_BSS(pIes)) |
| 2060 | { |
| 2061 | ret += CSR_BSS_CAP_VALUE_WMM; |
| 2062 | //Give advantage to UAPSD |
| 2063 | if(CSR_IS_UAPSD_BSS(pIes)) |
| 2064 | { |
| 2065 | ret += CSR_BSS_CAP_VALUE_UAPSD; |
| 2066 | } |
| 2067 | } |
| 2068 | } |
| 2069 | |
| 2070 | return (ret); |
| 2071 | } |
| 2072 | |
Kapil Gupta | b3a981b | 2016-06-26 13:36:51 +0530 | [diff] [blame] | 2073 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 2074 | |
| 2075 | /* Calculate channel weight based on other APs RSSI and count for |
| 2076 | * PER based roaming */ |
| 2077 | static tANI_U32 GetPERRoamRssiCountWeight(tANI_S32 rssi, tANI_S32 count) |
| 2078 | { |
| 2079 | tANI_S32 rssiWeight=0; |
| 2080 | tANI_S32 countWeight=0; |
| 2081 | tANI_S32 rssicountWeight=0; |
| 2082 | |
| 2083 | rssiWeight = ROAMING_RSSI_WEIGHT * (rssi - MIN_RSSI) |
| 2084 | /(MAX_RSSI - MIN_RSSI); |
| 2085 | |
| 2086 | if(rssiWeight > ROAMING_RSSI_WEIGHT) |
| 2087 | rssiWeight = ROAMING_RSSI_WEIGHT; |
| 2088 | else if (rssiWeight < 0) |
| 2089 | rssiWeight = 0; |
| 2090 | |
| 2091 | countWeight = ROAM_AP_COUNT_WEIGHT * (count + ROAM_MIN_COUNT) |
| 2092 | /(ROAM_MAX_COUNT + ROAM_MIN_COUNT); |
| 2093 | |
| 2094 | if(countWeight > ROAM_AP_COUNT_WEIGHT) |
| 2095 | countWeight = ROAM_AP_COUNT_WEIGHT; |
| 2096 | |
| 2097 | rssicountWeight = ROAM_MAX_WEIGHT - (rssiWeight + countWeight); |
| 2098 | |
| 2099 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, |
| 2100 | FL("rssiWeight=%d, countWeight=%d, rssicountWeight=%d rssi=%d count=%d"), |
| 2101 | rssiWeight, countWeight, rssicountWeight, rssi, count); |
| 2102 | |
| 2103 | return rssicountWeight; |
| 2104 | } |
| 2105 | |
| 2106 | /* Calculate BSS score based on AP capabilty and channel condition |
| 2107 | * for PER based roaming */ |
| 2108 | static tANI_U32 calculateBssScore(tSirBssDescription *bssInfo, |
| 2109 | tANI_S32 best_rssi, tANI_S32 ap_cnt, tANI_S32 cca) |
| 2110 | { |
| 2111 | tANI_S32 score = 0; |
| 2112 | tANI_S32 ap_load = 0; |
| 2113 | tANI_S32 normalised_width = PER_ROAM_20MHZ; |
Sen, Devendra | 6940d0c | 2016-09-07 12:42:46 +0530 | [diff] [blame] | 2114 | tANI_S32 normalised_rssi = 0; |
Kapil Gupta | b3a981b | 2016-06-26 13:36:51 +0530 | [diff] [blame] | 2115 | tANI_S32 channel_weight; |
| 2116 | if (bssInfo->rssi) { |
| 2117 | /* Calculate % of rssi we are getting |
| 2118 | * max = 100 |
| 2119 | * min = 0 |
| 2120 | * less than -40 = 100% |
| 2121 | * -40 - -55 = 80% |
| 2122 | * -55 - -65 = 60% |
| 2123 | * below that = 100 - value |
| 2124 | * TODO: a linear decrement function after PER_ROAM_GOOD_RSSI_WEIGHT |
| 2125 | * since throughput decrements linearly after PER_ROAM_GOOD_RSSI_WEIGHT |
| 2126 | **/ |
| 2127 | if (bssInfo->rssi >= PER_EXCELENT_RSSI) |
| 2128 | normalised_rssi = PER_ROAM_EXCELLENT_RSSI_WEIGHT; |
| 2129 | else if (bssInfo->rssi >= PER_GOOD_RSSI) |
| 2130 | normalised_rssi = PER_ROAM_GOOD_RSSI_WEIGHT; |
| 2131 | else if (bssInfo->rssi >= PER_POOR_RSSI) |
| 2132 | normalised_rssi = PER_ROAM_BAD_RSSI_WEIGHT; |
| 2133 | else |
| 2134 | normalised_rssi = bssInfo->rssi - MIN_RSSI; |
| 2135 | |
| 2136 | /* Calculate score part for rssi */ |
| 2137 | score += (normalised_rssi * RSSI_WEIGHTAGE); |
| 2138 | } |
| 2139 | |
| 2140 | if (bssInfo->HTCapsPresent) { |
| 2141 | score += PER_ROAM_MAX_WEIGHT * HT_CAPABILITY_WEIGHTAGE; |
| 2142 | } |
| 2143 | /* VHT caps are available */ |
| 2144 | if (bssInfo->vhtCapsPresent) { |
| 2145 | score += PER_ROAM_MAX_WEIGHT * VHT_CAP_WEIGHTAGE; |
| 2146 | } |
| 2147 | |
| 2148 | if (bssInfo->beacomformingCapable) |
| 2149 | score += PER_ROAM_MAX_WEIGHT * BEAMFORMING_CAP_WEIGHTAGE; |
| 2150 | |
| 2151 | /* Channel width 20Mhz=30, 40Mhz=70, 80Mhz=100 */ |
| 2152 | if (bssInfo->chanWidth == eHT_CHANNEL_WIDTH_80MHZ) |
| 2153 | normalised_width = PER_ROAM_80MHZ; |
| 2154 | else if (bssInfo->chanWidth == eHT_CHANNEL_WIDTH_40MHZ) |
| 2155 | normalised_width = PER_ROAM_40MHZ; |
| 2156 | else |
| 2157 | normalised_width = PER_ROAM_20MHZ; |
| 2158 | score += normalised_width * CHAN_WIDTH_WEIGHTAGE; |
| 2159 | |
| 2160 | /* Channel Band, Channel Number */ |
| 2161 | if (GetRFBand(bssInfo->channelId) == SIR_BAND_5_GHZ) |
| 2162 | score += PER_ROAM_MAX_WEIGHT * CHAN_BAND_WEIGHTAGE; |
| 2163 | |
| 2164 | /* WMM emabled */ |
| 2165 | if (bssInfo->wmeInfoPresent) |
| 2166 | score += PER_ROAM_MAX_WEIGHT * WMM_WEIGHTAGE; |
| 2167 | |
| 2168 | #if defined(FEATURE_WLAN_ESE) || defined(WLAN_FEATURE_ROAM_SCAN_OFFLOAD) |
| 2169 | /* AP load Ie */ |
| 2170 | if (bssInfo->QBSSLoad_present) { |
| 2171 | /* calculate value in % */ |
| 2172 | ap_load = (bssInfo->QBSS_ChanLoad * PER_ROAM_MAX_WEIGHT) / MAX_AP_LOAD; |
| 2173 | } |
| 2174 | #endif |
Kapil Gupta | b3a981b | 2016-06-26 13:36:51 +0530 | [diff] [blame] | 2175 | /* if CCA consideration is off in configuration, FW will send 50% for |
| 2176 | every channel which should be considered as it is */ |
| 2177 | if (ap_load) |
| 2178 | score += (100 - ap_load) * CCA_WEIGHTAGE; |
| 2179 | else |
| 2180 | score += (100 - cca) * CCA_WEIGHTAGE; |
| 2181 | |
| 2182 | channel_weight = GetPERRoamRssiCountWeight(best_rssi, ap_cnt); |
| 2183 | |
| 2184 | score += channel_weight * OTHER_AP_WEIGHT; |
| 2185 | |
| 2186 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_LOW, |
| 2187 | FL("rssi=%d normalized_rssi=%d htcaps=%d vht=%d bw=%d channel=%d wmm=%d beamforming=%d ap_load=%d channel_weight=%d"), |
| 2188 | bssInfo->rssi, normalised_rssi, bssInfo->HTCapsPresent, |
| 2189 | bssInfo->vhtCapsPresent, bssInfo->chanWidth, |
| 2190 | bssInfo->channelId, bssInfo->wmeInfoPresent, |
| 2191 | bssInfo->beacomformingCapable, ap_load, channel_weight); |
| 2192 | return score; |
| 2193 | } |
| 2194 | |
| 2195 | /* Calculate candidate AP score for PER based roaming */ |
| 2196 | static tANI_S32 csrFindCongestionScore (tpAniSirGlobal pMac, tCsrScanResult *pBss) |
| 2197 | { |
| 2198 | tANI_S32 score = 0; |
| 2199 | tANI_S32 i; |
| 2200 | tANI_S32 candidateApCnt, best_rssi, other_ap_cnt; |
| 2201 | tANI_U32 current_timestamp; |
| 2202 | tpCsrNeighborRoamControlInfo pNeighborRoamInfo = |
| 2203 | &pMac->roam.neighborRoamInfo; |
| 2204 | |
| 2205 | tSirBssDescription *bssInfo = &(pBss->Result.BssDescriptor); |
| 2206 | pBss->congestionScore = 0; |
| 2207 | for (i = 0; i < pMac->PERroamCandidatesCnt; i++) |
| 2208 | if (pMac->candidateChannelInfo[i].channelNumber == |
| 2209 | pBss->Result.BssDescriptor.channelId) |
| 2210 | break; |
| 2211 | |
| 2212 | if (i == SIR_PER_ROAM_MAX_CANDIDATE_CNT) { |
| 2213 | smsLog(pMac, LOGE, |
| 2214 | FL("candidate chan info not found for channel %d bssid " |
| 2215 | MAC_ADDRESS_STR), pBss->Result.BssDescriptor.channelId, |
| 2216 | MAC_ADDR_ARRAY(pBss->Result.BssDescriptor.bssId)); |
| 2217 | return -1; |
| 2218 | } |
| 2219 | |
Kapil Gupta | 192d9d4 | 2016-11-25 16:24:13 +0530 | [diff] [blame] | 2220 | if (bssInfo->rssi < pMac->roam.configParam.PERMinRssiThresholdForRoam) { |
Kapil Gupta | a040e77 | 2016-09-15 19:03:45 +0530 | [diff] [blame] | 2221 | smsLog(pMac, LOG1, |
Kapil Gupta | e2b5c09 | 2017-02-06 15:04:47 +0530 | [diff] [blame] | 2222 | FL("discarding candidate due to low rssi=%d than %d, bssid " |
Kapil Gupta | a040e77 | 2016-09-15 19:03:45 +0530 | [diff] [blame] | 2223 | MAC_ADDRESS_STR), bssInfo->rssi, |
Kapil Gupta | e2b5c09 | 2017-02-06 15:04:47 +0530 | [diff] [blame] | 2224 | pMac->roam.configParam.PERMinRssiThresholdForRoam, |
Kapil Gupta | a040e77 | 2016-09-15 19:03:45 +0530 | [diff] [blame] | 2225 | MAC_ADDR_ARRAY(pBss->Result.BssDescriptor.bssId)); |
| 2226 | return 0; |
| 2227 | } |
Kapil Gupta | b3a981b | 2016-06-26 13:36:51 +0530 | [diff] [blame] | 2228 | /* find best RSSI of other AP in this channel */ |
| 2229 | best_rssi = MIN_RSSI; |
| 2230 | for (other_ap_cnt = 0; other_ap_cnt < |
| 2231 | pMac->candidateChannelInfo[i].otherApCount; other_ap_cnt++) { |
| 2232 | if (pMac->candidateChannelInfo[i].otherApRssi[other_ap_cnt] > best_rssi) |
| 2233 | best_rssi = pMac->candidateChannelInfo[i].otherApRssi[other_ap_cnt]; |
| 2234 | } |
| 2235 | |
| 2236 | score = calculateBssScore(bssInfo, best_rssi, |
| 2237 | pMac->candidateChannelInfo[i].otherApCount, |
| 2238 | pMac->candidateChannelInfo[i].channelCCA); |
| 2239 | current_timestamp = jiffies_to_msecs(jiffies); |
| 2240 | |
| 2241 | /* penalty logic */ |
| 2242 | |
| 2243 | /* In the previous list */ |
| 2244 | for (candidateApCnt = 0; candidateApCnt < |
| 2245 | SIR_PER_ROAM_MAX_CANDIDATE_CNT; candidateApCnt++) { |
| 2246 | if (sirCompareMacAddr(pMac->previousRoamApInfo[candidateApCnt].bssAddr, |
| 2247 | pBss->Result.BssDescriptor.bssId) && |
| 2248 | ((current_timestamp - pMac->previousRoamApInfo[candidateApCnt].timeStamp) < |
| 2249 | PENALTY_TIMEOUT)) { |
| 2250 | score = (score * PENALTY_REMAINING_SCORE)/PENALTY_TOTAL_SCORE; |
| 2251 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, |
| 2252 | FL("AP BSSID " MAC_ADDRESS_STR "adding penalty(in previous list)new score %d"), |
| 2253 | MAC_ADDR_ARRAY(pBss->Result.BssDescriptor.bssId), |
| 2254 | score); |
| 2255 | break; |
| 2256 | } |
| 2257 | } |
| 2258 | /* preauth failed last time */ |
| 2259 | for (candidateApCnt = 0; candidateApCnt < |
| 2260 | MAX_NUM_PREAUTH_FAIL_LIST_ADDRESS; candidateApCnt++) { |
| 2261 | if (sirCompareMacAddr(pNeighborRoamInfo->FTRoamInfo. |
| 2262 | preAuthFailList.macAddress[candidateApCnt], |
| 2263 | pBss->Result.BssDescriptor.bssId)) { |
| 2264 | score = (score * PENALTY_REMAINING_SCORE)/PENALTY_TOTAL_SCORE; |
| 2265 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, |
| 2266 | FL("AP BSSID " MAC_ADDRESS_STR "adding penalty(previously auth failed)new score %d"), |
| 2267 | MAC_ADDR_ARRAY(pBss->Result.BssDescriptor.bssId), |
| 2268 | score); |
| 2269 | break; |
| 2270 | } |
| 2271 | } |
| 2272 | pBss->congestionScore = score; |
| 2273 | |
| 2274 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, |
| 2275 | FL("AP BSSID " MAC_ADDRESS_STR " score %d channel %d"), |
| 2276 | MAC_ADDR_ARRAY(pBss->Result.BssDescriptor.bssId), |
| 2277 | score, pBss->Result.BssDescriptor.channelId); |
| 2278 | return 0; |
| 2279 | } |
| 2280 | |
| 2281 | /* Calculate current AP score for PER based roaming */ |
| 2282 | static tANI_S32 csrFindSelfCongestionScore(tpAniSirGlobal pMac, |
| 2283 | tSirBssDescription *bssInfo) |
| 2284 | { |
| 2285 | tANI_S32 i, best_rssi, other_ap_cnt; |
| 2286 | tANI_S32 score = 0; |
Kapil Gupta | c6ac477 | 2016-08-05 20:25:16 +0530 | [diff] [blame] | 2287 | tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, |
| 2288 | pMac->roam.roamSession->sessionId); |
| 2289 | |
| 2290 | if (pSession == NULL) |
| 2291 | return -1; |
Kapil Gupta | b3a981b | 2016-06-26 13:36:51 +0530 | [diff] [blame] | 2292 | |
Kapil Gupta | c3c4826 | 2017-03-09 18:05:51 +0530 | [diff] [blame] | 2293 | if (bssInfo->rssi < pMac->roam.configParam.PERMinRssiThresholdForRoam) { |
| 2294 | smsLog(pMac, LOG1, |
| 2295 | FL("Current AP has low rssi=%d than %d"), bssInfo->rssi, |
| 2296 | pMac->roam.configParam.PERMinRssiThresholdForRoam); |
| 2297 | /* |
| 2298 | * Make Current candidate score as zero which will cause roaming |
| 2299 | * in low RSSI scenarios |
| 2300 | */ |
| 2301 | pMac->currentBssScore = 0; |
| 2302 | return 0; |
| 2303 | } |
| 2304 | |
Kapil Gupta | b3a981b | 2016-06-26 13:36:51 +0530 | [diff] [blame] | 2305 | for (i = 0; i <= pMac->PERroamCandidatesCnt; i++) |
| 2306 | if (pMac->candidateChannelInfo[i].channelNumber == bssInfo->channelId) |
| 2307 | break; |
| 2308 | if (i > pMac->PERroamCandidatesCnt) { |
| 2309 | /* home channel info is not present, no need to roam */ |
| 2310 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, |
| 2311 | FL("home channel %d congestion info not present"), |
| 2312 | bssInfo->channelId); |
| 2313 | pMac->currentBssScore = PER_ROAM_MAX_BSS_SCORE; |
| 2314 | return -1; |
| 2315 | } |
| 2316 | |
| 2317 | /* find best RSSI of other AP in this channel */ |
| 2318 | best_rssi = MIN_RSSI; |
| 2319 | for (other_ap_cnt = 0; other_ap_cnt < |
| 2320 | pMac->candidateChannelInfo[i].otherApCount; other_ap_cnt++) { |
| 2321 | if (pMac->candidateChannelInfo[i].otherApRssi[other_ap_cnt] > best_rssi) |
| 2322 | best_rssi = pMac->candidateChannelInfo[i].otherApRssi[other_ap_cnt]; |
| 2323 | } |
| 2324 | |
Kapil Gupta | c6ac477 | 2016-08-05 20:25:16 +0530 | [diff] [blame] | 2325 | /* update latest RSSI for current AP */ |
| 2326 | WLANTL_GetRssi(vos_get_global_context(VOS_MODULE_ID_SME, NULL), |
| 2327 | pSession->connectedInfo.staId, |
| 2328 | &bssInfo->rssi); |
| 2329 | |
Kapil Gupta | b3a981b | 2016-06-26 13:36:51 +0530 | [diff] [blame] | 2330 | score = calculateBssScore(bssInfo, best_rssi, |
| 2331 | pMac->candidateChannelInfo[i].otherApCount, |
| 2332 | pMac->candidateChannelInfo[i].channelCCA); |
| 2333 | pMac->currentBssScore = score; |
| 2334 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, |
| 2335 | FL("PER Roam Current AP score %d channel %d"), |
| 2336 | score, bssInfo->channelId); |
| 2337 | return 0; |
| 2338 | } |
| 2339 | |
Kapil Gupta | b79e76f | 2016-09-12 20:04:37 +0530 | [diff] [blame] | 2340 | |
Kapil Gupta | b3a981b | 2016-06-26 13:36:51 +0530 | [diff] [blame] | 2341 | static tANI_BOOLEAN csrIsBetterBssInCongestion(tCsrScanResult *pBss1, |
| 2342 | tCsrScanResult *pBss2) |
| 2343 | { |
| 2344 | tANI_BOOLEAN ret; |
| 2345 | |
| 2346 | if(CSR_IS_BETTER_PREFER_VALUE(pBss1->congestionScore, |
| 2347 | pBss2->congestionScore)) |
| 2348 | ret = eANI_BOOLEAN_TRUE; |
| 2349 | else |
| 2350 | ret = eANI_BOOLEAN_FALSE; |
| 2351 | |
| 2352 | return (ret); |
| 2353 | } |
| 2354 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2355 | |
| 2356 | //To check whther pBss1 is better than pBss2 |
| 2357 | static tANI_BOOLEAN csrIsBetterBss(tCsrScanResult *pBss1, tCsrScanResult *pBss2) |
| 2358 | { |
| 2359 | tANI_BOOLEAN ret; |
| 2360 | |
| 2361 | if(CSR_IS_BETTER_PREFER_VALUE(pBss1->preferValue, pBss2->preferValue)) |
| 2362 | { |
| 2363 | ret = eANI_BOOLEAN_TRUE; |
| 2364 | } |
| 2365 | else if(CSR_IS_EQUAL_PREFER_VALUE(pBss1->preferValue, pBss2->preferValue)) |
| 2366 | { |
| 2367 | if(CSR_IS_BETTER_CAP_VALUE(pBss1->capValue, pBss2->capValue)) |
| 2368 | { |
| 2369 | ret = eANI_BOOLEAN_TRUE; |
| 2370 | } |
| 2371 | else |
| 2372 | { |
| 2373 | ret = eANI_BOOLEAN_FALSE; |
| 2374 | } |
| 2375 | } |
| 2376 | else |
| 2377 | { |
| 2378 | ret = eANI_BOOLEAN_FALSE; |
| 2379 | } |
| 2380 | |
| 2381 | return (ret); |
| 2382 | } |
| 2383 | |
| 2384 | |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 2385 | #ifdef FEATURE_WLAN_LFR |
Madan Mohan Koyyalamudi | 470d2cf | 2012-09-28 14:43:44 -0700 | [diff] [blame] | 2386 | //Add the channel to the occupiedChannels array |
| 2387 | static void csrScanAddToOccupiedChannels( |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 2388 | tpAniSirGlobal pMac, |
| 2389 | tCsrScanResult *pResult, |
| 2390 | tCsrChannel *pOccupiedChannels, |
Madan Mohan Koyyalamudi | 470d2cf | 2012-09-28 14:43:44 -0700 | [diff] [blame] | 2391 | tDot11fBeaconIEs *pIes) |
| 2392 | { |
| 2393 | eHalStatus status; |
| 2394 | tANI_U8 channel; |
| 2395 | tANI_U8 numOccupiedChannels = pOccupiedChannels->numChannels; |
| 2396 | tANI_U8 *pOccupiedChannelList = pOccupiedChannels->channelList; |
| 2397 | |
| 2398 | channel = pResult->Result.BssDescriptor.channelId; |
| 2399 | |
| 2400 | if (!csrIsChannelPresentInList(pOccupiedChannelList, numOccupiedChannels, channel) |
Madan Mohan Koyyalamudi | dd3c966 | 2012-11-09 17:39:30 -0800 | [diff] [blame] | 2401 | && csrNeighborRoamConnectedProfileMatch(pMac, pResult, pIes)) |
Madan Mohan Koyyalamudi | 470d2cf | 2012-09-28 14:43:44 -0700 | [diff] [blame] | 2402 | { |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 2403 | status = csrAddToChannelListFront(pOccupiedChannelList, numOccupiedChannels, channel); |
Madan Mohan Koyyalamudi | 470d2cf | 2012-09-28 14:43:44 -0700 | [diff] [blame] | 2404 | if(HAL_STATUS_SUCCESS(status)) |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 2405 | { |
Madan Mohan Koyyalamudi | 470d2cf | 2012-09-28 14:43:44 -0700 | [diff] [blame] | 2406 | pOccupiedChannels->numChannels++; |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 2407 | smsLog(pMac, LOG2, FL("%s: added channel %d to the list (count=%d)"), |
Madan Mohan Koyyalamudi | dd3c966 | 2012-11-09 17:39:30 -0800 | [diff] [blame] | 2408 | __func__, channel, pOccupiedChannels->numChannels); |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 2409 | if (pOccupiedChannels->numChannels > CSR_BG_SCAN_OCCUPIED_CHANNEL_LIST_LEN) |
| 2410 | pOccupiedChannels->numChannels = CSR_BG_SCAN_OCCUPIED_CHANNEL_LIST_LEN; |
| 2411 | } |
Madan Mohan Koyyalamudi | 470d2cf | 2012-09-28 14:43:44 -0700 | [diff] [blame] | 2412 | } |
| 2413 | } |
Mukul Sharma | 9e4e0f9 | 2015-02-13 18:45:20 +0530 | [diff] [blame] | 2414 | |
| 2415 | void csrAddChannelToOccupiedChannelList(tpAniSirGlobal pMac, |
| 2416 | tANI_U8 channel) |
| 2417 | { |
| 2418 | eHalStatus status; |
| 2419 | tCsrChannel *pOccupiedChannels = &pMac->scan.occupiedChannels; |
| 2420 | tANI_U8 numOccupiedChannels = pOccupiedChannels->numChannels; |
| 2421 | tANI_U8 *pOccupiedChannelList = pOccupiedChannels->channelList; |
| 2422 | if (!csrIsChannelPresentInList(pOccupiedChannelList, |
| 2423 | numOccupiedChannels, channel)) |
| 2424 | { |
| 2425 | status = csrAddToChannelListFront(pOccupiedChannelList, |
| 2426 | numOccupiedChannels, channel); |
| 2427 | if(HAL_STATUS_SUCCESS(status)) |
| 2428 | { |
| 2429 | pOccupiedChannels->numChannels++; |
| 2430 | smsLog(pMac, LOG2, FL("added channel %d to the list (count=%d)"), |
| 2431 | channel, pOccupiedChannels->numChannels); |
| 2432 | if (pOccupiedChannels->numChannels > |
| 2433 | CSR_BG_SCAN_OCCUPIED_CHANNEL_LIST_LEN) |
| 2434 | { |
| 2435 | pOccupiedChannels->numChannels = |
| 2436 | CSR_BG_SCAN_OCCUPIED_CHANNEL_LIST_LEN; |
| 2437 | smsLog(pMac, LOG2, |
| 2438 | FL("trim no of Channels for Occ channel list")); |
| 2439 | } |
| 2440 | } |
| 2441 | } |
| 2442 | } |
Madan Mohan Koyyalamudi | 470d2cf | 2012-09-28 14:43:44 -0700 | [diff] [blame] | 2443 | #endif |
| 2444 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2445 | //Put the BSS into the scan result list |
| 2446 | //pIes can not be NULL |
| 2447 | static void csrScanAddResult(tpAniSirGlobal pMac, tCsrScanResult *pResult, tDot11fBeaconIEs *pIes) |
| 2448 | { |
Srinivas | 28b5b4e | 2012-12-12 13:07:53 -0800 | [diff] [blame] | 2449 | #ifdef FEATURE_WLAN_LFR |
| 2450 | tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo; |
| 2451 | #endif |
| 2452 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2453 | pResult->preferValue = csrGetBssPreferValue(pMac, (int)pResult->Result.BssDescriptor.rssi); |
| 2454 | pResult->capValue = csrGetBssCapValue(pMac, &pResult->Result.BssDescriptor, pIes); |
| 2455 | csrLLInsertTail( &pMac->scan.scanResultList, &pResult->Link, LL_ACCESS_LOCK ); |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 2456 | #ifdef FEATURE_WLAN_LFR |
Srinivas | 28b5b4e | 2012-12-12 13:07:53 -0800 | [diff] [blame] | 2457 | if(0 == pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels) |
| 2458 | { |
| 2459 | /* Build the occupied channel list, only if "gNeighborScanChannelList" is |
| 2460 | NOT set in the cfg.ini file */ |
| 2461 | csrScanAddToOccupiedChannels(pMac, pResult, &pMac->scan.occupiedChannels, pIes); |
| 2462 | } |
Madan Mohan Koyyalamudi | 470d2cf | 2012-09-28 14:43:44 -0700 | [diff] [blame] | 2463 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2464 | } |
| 2465 | |
| 2466 | |
| 2467 | eHalStatus csrScanGetResult(tpAniSirGlobal pMac, tCsrScanResultFilter *pFilter, tScanResultHandle *phResult) |
| 2468 | { |
| 2469 | eHalStatus status; |
| 2470 | tScanResultList *pRetList; |
| 2471 | tCsrScanResult *pResult, *pBssDesc; |
| 2472 | tANI_U32 count = 0; |
| 2473 | tListElem *pEntry; |
| 2474 | tANI_U32 bssLen, allocLen; |
| 2475 | eCsrEncryptionType uc = eCSR_ENCRYPT_TYPE_NONE, mc = eCSR_ENCRYPT_TYPE_NONE; |
| 2476 | eCsrAuthType auth = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 2477 | tDot11fBeaconIEs *pIes, *pNewIes; |
| 2478 | tANI_BOOLEAN fMatch; |
Srinivas Girigowda | 8e7e105 | 2013-11-13 18:53:14 -0800 | [diff] [blame] | 2479 | tANI_U16 i = 0; |
Kapil Gupta | b3a981b | 2016-06-26 13:36:51 +0530 | [diff] [blame] | 2480 | tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, |
| 2481 | pMac->roam.roamSession->sessionId); |
| 2482 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2483 | if(phResult) |
| 2484 | { |
| 2485 | *phResult = CSR_INVALID_SCANRESULT_HANDLE; |
| 2486 | } |
Srinivas Girigowda | 41c7c5f | 2013-10-21 19:01:38 -0700 | [diff] [blame] | 2487 | |
| 2488 | if (pMac->roam.configParam.nSelect5GHzMargin) |
| 2489 | { |
| 2490 | pMac->scan.inScanResultBestAPRssi = -128; |
| 2491 | csrLLLock(&pMac->scan.scanResultList); |
| 2492 | |
| 2493 | /* Find out the best AP Rssi going thru the scan results */ |
| 2494 | pEntry = csrLLPeekHead(&pMac->scan.scanResultList, LL_ACCESS_NOLOCK); |
| 2495 | while ( NULL != pEntry) |
| 2496 | { |
| 2497 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
Srinivas Girigowda | 8e7e105 | 2013-11-13 18:53:14 -0800 | [diff] [blame] | 2498 | fMatch = FALSE; |
| 2499 | |
| 2500 | if (pFilter) |
| 2501 | for(i = 0; i < pFilter->SSIDs.numOfSSIDs; i++) |
Srinivas Girigowda | 41c7c5f | 2013-10-21 19:01:38 -0700 | [diff] [blame] | 2502 | { |
Srinivas Girigowda | 8e7e105 | 2013-11-13 18:53:14 -0800 | [diff] [blame] | 2503 | fMatch = csrIsSsidMatch( pMac, pFilter->SSIDs.SSIDList[i].SSID.ssId, pFilter->SSIDs.SSIDList[i].SSID.length, |
| 2504 | pBssDesc->Result.ssId.ssId, |
| 2505 | pBssDesc->Result.ssId.length, eANI_BOOLEAN_TRUE ); |
| 2506 | if (fMatch) |
| 2507 | { |
| 2508 | pIes = (tDot11fBeaconIEs *)( pBssDesc->Result.pvIes ); |
| 2509 | |
| 2510 | //At this time, pBssDescription->Result.pvIes may be NULL |
| 2511 | if( !pIes && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, |
| 2512 | &pBssDesc->Result.BssDescriptor, &pIes))) ) |
| 2513 | { |
| 2514 | continue; |
| 2515 | } |
| 2516 | |
| 2517 | smsLog(pMac, LOG1, FL("SSID Matched")); |
Leela Venkata Kiran Kumar Reddy Chirala | e208a83 | 2014-04-27 22:34:25 -0700 | [diff] [blame] | 2518 | |
Leela Venkata Kiran Kumar Reddy Chirala | f257bef | 2014-04-11 18:48:12 -0700 | [diff] [blame] | 2519 | if ( pFilter->bOSENAssociation ) |
| 2520 | { |
| 2521 | fMatch = TRUE; |
| 2522 | } |
Leela Venkata Kiran Kumar Reddy Chirala | e208a83 | 2014-04-27 22:34:25 -0700 | [diff] [blame] | 2523 | else |
| 2524 | { |
Abhishek Singh | 658d4de | 2014-06-26 10:53:15 +0530 | [diff] [blame] | 2525 | #ifdef WLAN_FEATURE_11W |
Abhishek Singh | 3b56d3a | 2014-06-25 12:37:39 +0530 | [diff] [blame] | 2526 | fMatch = csrIsSecurityMatch(pMac, &pFilter->authType, |
| 2527 | &pFilter->EncryptionType, |
| 2528 | &pFilter->mcEncryptionType, |
| 2529 | &pFilter->MFPEnabled, |
| 2530 | &pFilter->MFPRequired, |
| 2531 | &pFilter->MFPCapable, |
| 2532 | &pBssDesc->Result.BssDescriptor, |
| 2533 | pIes, NULL, NULL, NULL ); |
Abhishek Singh | 658d4de | 2014-06-26 10:53:15 +0530 | [diff] [blame] | 2534 | #else |
| 2535 | fMatch = csrIsSecurityMatch(pMac, &pFilter->authType, |
| 2536 | &pFilter->EncryptionType, |
| 2537 | &pFilter->mcEncryptionType, |
| 2538 | NULL, NULL, NULL, |
| 2539 | &pBssDesc->Result.BssDescriptor, |
| 2540 | pIes, NULL, NULL, NULL ); |
| 2541 | #endif |
Leela Venkata Kiran Kumar Reddy Chirala | e208a83 | 2014-04-27 22:34:25 -0700 | [diff] [blame] | 2542 | } |
| 2543 | if ((pBssDesc->Result.pvIes == NULL) && pIes) |
| 2544 | vos_mem_free(pIes); |
Srinivas Girigowda | 8e7e105 | 2013-11-13 18:53:14 -0800 | [diff] [blame] | 2545 | |
| 2546 | if (fMatch) |
| 2547 | smsLog(pMac, LOG1, FL(" Security Matched")); |
| 2548 | } |
| 2549 | } |
| 2550 | |
| 2551 | if (fMatch && (pBssDesc->Result.BssDescriptor.rssi > pMac->scan.inScanResultBestAPRssi)) |
| 2552 | { |
| 2553 | smsLog(pMac, LOG1, FL("Best AP Rssi changed from %d to %d"), |
| 2554 | pMac->scan.inScanResultBestAPRssi, |
| 2555 | pBssDesc->Result.BssDescriptor.rssi); |
Srinivas Girigowda | 41c7c5f | 2013-10-21 19:01:38 -0700 | [diff] [blame] | 2556 | pMac->scan.inScanResultBestAPRssi = pBssDesc->Result.BssDescriptor.rssi; |
| 2557 | } |
| 2558 | pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK); |
| 2559 | } |
| 2560 | |
Srinivas Girigowda | 8e7e105 | 2013-11-13 18:53:14 -0800 | [diff] [blame] | 2561 | if ( -128 != pMac->scan.inScanResultBestAPRssi) |
Srinivas Girigowda | 41c7c5f | 2013-10-21 19:01:38 -0700 | [diff] [blame] | 2562 | { |
Srinivas Girigowda | 8e7e105 | 2013-11-13 18:53:14 -0800 | [diff] [blame] | 2563 | smsLog(pMac, LOG1, FL("Best AP Rssi is %d"), pMac->scan.inScanResultBestAPRssi); |
| 2564 | /* Modify Rssi category based on best AP Rssi */ |
| 2565 | csrAssignRssiForCategory(pMac, pMac->scan.inScanResultBestAPRssi, pMac->roam.configParam.bCatRssiOffset); |
| 2566 | pEntry = csrLLPeekHead(&pMac->scan.scanResultList, LL_ACCESS_NOLOCK); |
| 2567 | while ( NULL != pEntry) |
| 2568 | { |
| 2569 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
Srinivas Girigowda | 41c7c5f | 2013-10-21 19:01:38 -0700 | [diff] [blame] | 2570 | |
Srinivas Girigowda | 8e7e105 | 2013-11-13 18:53:14 -0800 | [diff] [blame] | 2571 | /* re-assign preference value based on modified rssi bucket */ |
| 2572 | pBssDesc->preferValue = csrGetBssPreferValue(pMac, (int)pBssDesc->Result.BssDescriptor.rssi); |
Srinivas Girigowda | 41c7c5f | 2013-10-21 19:01:38 -0700 | [diff] [blame] | 2573 | |
Arif Hussain | a7c8e41 | 2013-11-20 11:06:42 -0800 | [diff] [blame] | 2574 | smsLog(pMac, LOG2, FL("BSSID("MAC_ADDRESS_STR |
Jeff Johnson | 123ed00 | 2013-11-22 17:39:55 -0800 | [diff] [blame] | 2575 | ") Rssi(%d) Chnl(%d) PrefVal(%u) SSID=%.*s"), |
Arif Hussain | a7c8e41 | 2013-11-20 11:06:42 -0800 | [diff] [blame] | 2576 | MAC_ADDR_ARRAY(pBssDesc->Result.BssDescriptor.bssId), |
| 2577 | pBssDesc->Result.BssDescriptor.rssi, |
| 2578 | pBssDesc->Result.BssDescriptor.channelId, |
| 2579 | pBssDesc->preferValue, |
| 2580 | pBssDesc->Result.ssId.length, pBssDesc->Result.ssId.ssId); |
Srinivas Girigowda | 8e7e105 | 2013-11-13 18:53:14 -0800 | [diff] [blame] | 2581 | |
| 2582 | pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK); |
| 2583 | } |
Srinivas Girigowda | 41c7c5f | 2013-10-21 19:01:38 -0700 | [diff] [blame] | 2584 | } |
| 2585 | |
| 2586 | csrLLUnlock(&pMac->scan.scanResultList); |
| 2587 | } |
| 2588 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2589 | pRetList = vos_mem_malloc(sizeof(tScanResultList)); |
| 2590 | if ( NULL == pRetList ) |
| 2591 | status = eHAL_STATUS_FAILURE; |
| 2592 | else |
| 2593 | status = eHAL_STATUS_SUCCESS; |
Srinivas Girigowda | 41c7c5f | 2013-10-21 19:01:38 -0700 | [diff] [blame] | 2594 | if(HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2595 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2596 | vos_mem_set(pRetList, sizeof(tScanResultList), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2597 | csrLLOpen(pMac->hHdd, &pRetList->List); |
| 2598 | pRetList->pCurEntry = NULL; |
Kapil Gupta | b3a981b | 2016-06-26 13:36:51 +0530 | [diff] [blame] | 2599 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 2600 | if (pFilter && pFilter->isPERRoamScan) |
| 2601 | if (pSession && pSession->pConnectBssDesc) |
| 2602 | csrFindSelfCongestionScore(pMac, |
| 2603 | pSession->pConnectBssDesc); |
| 2604 | #endif |
| 2605 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2606 | csrLLLock(&pMac->scan.scanResultList); |
| 2607 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK ); |
| 2608 | while( pEntry ) |
| 2609 | { |
| 2610 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 2611 | pIes = (tDot11fBeaconIEs *)( pBssDesc->Result.pvIes ); |
| 2612 | //if pBssDesc->Result.pvIes is NULL, we need to free any memory allocated by csrMatchBSS |
| 2613 | //for any error condition, otherwiase, it will be freed later. |
| 2614 | //reset |
| 2615 | fMatch = eANI_BOOLEAN_FALSE; |
| 2616 | pNewIes = NULL; |
| 2617 | |
| 2618 | if(pFilter) |
| 2619 | { |
| 2620 | fMatch = csrMatchBSS(pMac, &pBssDesc->Result.BssDescriptor, pFilter, &auth, &uc, &mc, &pIes); |
| 2621 | if( NULL != pIes ) |
| 2622 | { |
| 2623 | //Only save it when matching |
| 2624 | if(fMatch) |
| 2625 | { |
| 2626 | if( !pBssDesc->Result.pvIes ) |
| 2627 | { |
| 2628 | //csrMatchBSS allocates the memory. Simply pass it and it is freed later |
| 2629 | pNewIes = pIes; |
| 2630 | } |
| 2631 | else |
| 2632 | { |
| 2633 | //The pIes is allocated by someone else. make a copy |
| 2634 | //Only to save parsed IEs if caller provides a filter. Most likely the caller |
| 2635 | //is using to for association, hence save the parsed IEs |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2636 | pNewIes = vos_mem_malloc(sizeof(tDot11fBeaconIEs)); |
| 2637 | if ( NULL == pNewIes ) |
| 2638 | status = eHAL_STATUS_FAILURE; |
| 2639 | else |
| 2640 | status = eHAL_STATUS_SUCCESS; |
| 2641 | if ( HAL_STATUS_SUCCESS( status ) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2642 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2643 | vos_mem_copy(pNewIes, pIes, sizeof( tDot11fBeaconIEs )); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2644 | } |
| 2645 | else |
| 2646 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 2647 | smsLog(pMac, LOGE, FL(" fail to allocate memory for IEs")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2648 | //Need to free memory allocated by csrMatchBSS |
| 2649 | if( !pBssDesc->Result.pvIes ) |
| 2650 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2651 | vos_mem_free(pIes); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2652 | } |
| 2653 | break; |
| 2654 | } |
| 2655 | } |
| 2656 | }//fMatch |
| 2657 | else if( !pBssDesc->Result.pvIes ) |
| 2658 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2659 | vos_mem_free(pIes); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2660 | } |
| 2661 | } |
| 2662 | } |
| 2663 | if(NULL == pFilter || fMatch) |
| 2664 | { |
| 2665 | bssLen = pBssDesc->Result.BssDescriptor.length + sizeof(pBssDesc->Result.BssDescriptor.length); |
| 2666 | allocLen = sizeof( tCsrScanResult ) + bssLen; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2667 | pResult = vos_mem_malloc(allocLen); |
| 2668 | if ( NULL == pResult ) |
| 2669 | status = eHAL_STATUS_FAILURE; |
| 2670 | else |
| 2671 | status = eHAL_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2672 | if(!HAL_STATUS_SUCCESS(status)) |
| 2673 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 2674 | smsLog(pMac, LOGE, FL(" fail to allocate memory for scan result, len=%d"), allocLen); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2675 | if(pNewIes) |
| 2676 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2677 | vos_mem_free(pNewIes); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2678 | } |
| 2679 | break; |
| 2680 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2681 | vos_mem_set(pResult, allocLen, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2682 | pResult->capValue = pBssDesc->capValue; |
| 2683 | pResult->preferValue = pBssDesc->preferValue; |
| 2684 | pResult->ucEncryptionType = uc; |
| 2685 | pResult->mcEncryptionType = mc; |
| 2686 | pResult->authType = auth; |
| 2687 | pResult->Result.ssId = pBssDesc->Result.ssId; |
Padma, Santhosh Kumar | e12fd98 | 2016-03-21 13:07:52 +0530 | [diff] [blame] | 2688 | pResult->Result.timer = pBssDesc->Result.timer; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2689 | //save the pIes for later use |
| 2690 | pResult->Result.pvIes = pNewIes; |
| 2691 | //save bss description |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2692 | vos_mem_copy(&pResult->Result.BssDescriptor, |
| 2693 | &pBssDesc->Result.BssDescriptor, bssLen); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2694 | //No need to lock pRetList because it is locally allocated and no outside can access it at this time |
| 2695 | if(csrLLIsListEmpty(&pRetList->List, LL_ACCESS_NOLOCK)) |
| 2696 | { |
Kapil Gupta | b3a981b | 2016-06-26 13:36:51 +0530 | [diff] [blame] | 2697 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 2698 | if (pFilter && pFilter->isPERRoamScan) { |
| 2699 | csrFindCongestionScore(pMac, pResult); |
| 2700 | if (pResult->congestionScore > pMac->currentBssScore) { |
| 2701 | csrLLInsertTail(&pRetList->List, &pResult->Link, |
| 2702 | LL_ACCESS_NOLOCK); |
| 2703 | smsLog(pMac, LOGW, |
| 2704 | FL("added one entry in LL in PER Roam list")); |
| 2705 | } |
| 2706 | } |
| 2707 | else |
| 2708 | #endif |
| 2709 | { |
| 2710 | csrLLInsertTail(&pRetList->List, &pResult->Link, |
| 2711 | LL_ACCESS_NOLOCK); |
| 2712 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2713 | } |
Abhishek Singh | b3e376c | 2017-01-04 15:27:13 +0530 | [diff] [blame] | 2714 | /* bssid hint AP should be on head */ |
| 2715 | else if (pFilter && |
| 2716 | vos_mem_compare(pResult->Result.BssDescriptor.bssId, |
| 2717 | pFilter->bssid_hint, VOS_MAC_ADDR_SIZE)) |
| 2718 | { |
| 2719 | csrLLInsertHead(&pRetList->List, |
| 2720 | &pResult->Link, LL_ACCESS_NOLOCK); |
| 2721 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2722 | else |
| 2723 | { |
| 2724 | //To sort the list |
| 2725 | tListElem *pTmpEntry; |
| 2726 | tCsrScanResult *pTmpResult; |
| 2727 | |
| 2728 | pTmpEntry = csrLLPeekHead(&pRetList->List, LL_ACCESS_NOLOCK); |
| 2729 | while(pTmpEntry) |
| 2730 | { |
| 2731 | pTmpResult = GET_BASE_ADDR( pTmpEntry, tCsrScanResult, Link ); |
Abhishek Singh | b3e376c | 2017-01-04 15:27:13 +0530 | [diff] [blame] | 2732 | /* Skip the bssid hint AP, as it should be on head */ |
Abhishek Singh | 78f494b | 2017-01-24 10:07:08 +0530 | [diff] [blame] | 2733 | if (pFilter && vos_mem_compare( |
| 2734 | pTmpResult->Result.BssDescriptor.bssId, |
Abhishek Singh | b3e376c | 2017-01-04 15:27:13 +0530 | [diff] [blame] | 2735 | pFilter->bssid_hint, VOS_MAC_ADDR_SIZE)) { |
| 2736 | pTmpEntry = csrLLNext(&pRetList->List, |
| 2737 | pTmpEntry, LL_ACCESS_NOLOCK); |
| 2738 | continue; |
| 2739 | } |
Kapil Gupta | b3a981b | 2016-06-26 13:36:51 +0530 | [diff] [blame] | 2740 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 2741 | if (pFilter && pFilter->isPERRoamScan) { |
| 2742 | csrFindCongestionScore(pMac, pResult); |
| 2743 | if(csrIsBetterBssInCongestion(pResult, pTmpResult)&& |
| 2744 | (pResult->congestionScore > pMac->currentBssScore)) |
| 2745 | { |
| 2746 | csrLLInsertEntry(&pRetList->List, pTmpEntry, |
| 2747 | &pResult->Link, LL_ACCESS_NOLOCK); |
| 2748 | smsLog(pMac, LOGW, |
| 2749 | FL("added another entry in LL in PER Roam list")); |
| 2750 | pResult = NULL; |
| 2751 | break; |
| 2752 | } |
| 2753 | pTmpEntry = csrLLNext(&pRetList->List, |
| 2754 | pTmpEntry, LL_ACCESS_NOLOCK); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2755 | } |
Kapil Gupta | b3a981b | 2016-06-26 13:36:51 +0530 | [diff] [blame] | 2756 | else |
| 2757 | #endif |
| 2758 | { |
| 2759 | if(csrIsBetterBss(pResult, pTmpResult)) |
| 2760 | { |
| 2761 | csrLLInsertEntry(&pRetList->List, pTmpEntry, |
| 2762 | &pResult->Link, LL_ACCESS_NOLOCK); |
| 2763 | //To indicate we are done |
| 2764 | pResult = NULL; |
| 2765 | break; |
| 2766 | } |
| 2767 | pTmpEntry = csrLLNext(&pRetList->List, |
| 2768 | pTmpEntry, LL_ACCESS_NOLOCK); |
| 2769 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2770 | } |
| 2771 | if(pResult != NULL) |
Kapil Gupta | b3a981b | 2016-06-26 13:36:51 +0530 | [diff] [blame] | 2772 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 2773 | if ((pFilter && !pFilter->isPERRoamScan) || |
| 2774 | (pFilter == NULL) || |
| 2775 | (pResult->congestionScore > pMac->currentBssScore)) |
| 2776 | #endif |
| 2777 | { |
| 2778 | //This one is not better than any one |
| 2779 | csrLLInsertTail(&pRetList->List, |
| 2780 | &pResult->Link, LL_ACCESS_NOLOCK); |
| 2781 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2782 | } |
| 2783 | count++; |
| 2784 | } |
| 2785 | pEntry = csrLLNext( &pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK ); |
| 2786 | }//while |
| 2787 | csrLLUnlock(&pMac->scan.scanResultList); |
| 2788 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 2789 | smsLog(pMac, LOG2, FL("return %d BSS"), csrLLCount(&pRetList->List)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2790 | |
| 2791 | if( !HAL_STATUS_SUCCESS(status) || (phResult == NULL) ) |
| 2792 | { |
| 2793 | //Fail or No one wants the result. |
| 2794 | csrScanResultPurge(pMac, (tScanResultHandle)pRetList); |
| 2795 | } |
| 2796 | else |
| 2797 | { |
| 2798 | if(0 == count) |
| 2799 | { |
| 2800 | //We are here meaning the there is no match |
| 2801 | csrLLClose(&pRetList->List); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2802 | vos_mem_free(pRetList); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2803 | status = eHAL_STATUS_E_NULL_VALUE; |
Kapil Gupta | b3a981b | 2016-06-26 13:36:51 +0530 | [diff] [blame] | 2804 | smsLog(pMac, LOGW, |
| 2805 | FL("Nil scan results or no matching AP found")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2806 | } |
| 2807 | else if(phResult) |
| 2808 | { |
| 2809 | *phResult = pRetList; |
| 2810 | } |
| 2811 | } |
| 2812 | }//Allocated pRetList |
| 2813 | |
| 2814 | return (status); |
| 2815 | } |
| 2816 | |
Madan Mohan Koyyalamudi | ab41d0f | 2012-10-31 17:17:10 -0700 | [diff] [blame] | 2817 | /* |
| 2818 | * NOTE: This routine is being added to make |
| 2819 | * sure that scan results are not being flushed |
| 2820 | * while roaming. If the scan results are flushed, |
| 2821 | * we are unable to recover from |
| 2822 | * csrRoamRoamingStateDisassocRspProcessor. |
| 2823 | * If it is needed to remove this routine, |
| 2824 | * first ensure that we recover gracefully from |
| 2825 | * csrRoamRoamingStateDisassocRspProcessor if |
| 2826 | * csrScanGetResult returns with a failure because |
| 2827 | * of not being able to find the roaming BSS. |
| 2828 | */ |
| 2829 | tANI_U8 csrScanFlushDenied(tpAniSirGlobal pMac) |
| 2830 | { |
| 2831 | switch(pMac->roam.neighborRoamInfo.neighborRoamState) { |
| 2832 | case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN: |
| 2833 | case eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING: |
| 2834 | case eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE: |
| 2835 | case eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING: |
| 2836 | return (pMac->roam.neighborRoamInfo.neighborRoamState); |
| 2837 | default: |
| 2838 | return 0; |
| 2839 | } |
| 2840 | } |
| 2841 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2842 | eHalStatus csrScanFlushResult(tpAniSirGlobal pMac) |
| 2843 | { |
Madan Mohan Koyyalamudi | ab41d0f | 2012-10-31 17:17:10 -0700 | [diff] [blame] | 2844 | tANI_U8 isFlushDenied = csrScanFlushDenied(pMac); |
Srinivas, Dasari | 42bf770 | 2014-02-07 11:29:53 +0530 | [diff] [blame] | 2845 | eHalStatus status = eHAL_STATUS_SUCCESS; |
Madan Mohan Koyyalamudi | ab41d0f | 2012-10-31 17:17:10 -0700 | [diff] [blame] | 2846 | if (isFlushDenied) { |
| 2847 | smsLog(pMac, LOGW, "%s: scan flush denied in roam state %d", |
| 2848 | __func__, isFlushDenied); |
| 2849 | return eHAL_STATUS_FAILURE; |
| 2850 | } |
Srinivas, Dasari | 42bf770 | 2014-02-07 11:29:53 +0530 | [diff] [blame] | 2851 | csrLLScanPurgeResult( pMac, &pMac->scan.tempScanResults ); |
| 2852 | csrLLScanPurgeResult( pMac, &pMac->scan.scanResultList ); |
| 2853 | return( status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2854 | } |
| 2855 | |
Mukul Sharma | 20aa658 | 2014-08-07 21:36:12 +0530 | [diff] [blame] | 2856 | eHalStatus csrScanFlushSelectiveResultForBand(tpAniSirGlobal pMac, v_BOOL_t flushP2P, tSirRFBand band) |
| 2857 | { |
| 2858 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2859 | tListElem *pEntry,*pFreeElem; |
| 2860 | tCsrScanResult *pBssDesc; |
| 2861 | tDblLinkList *pList = &pMac->scan.scanResultList; |
| 2862 | |
| 2863 | csrLLLock(pList); |
| 2864 | |
| 2865 | pEntry = csrLLPeekHead( pList, LL_ACCESS_NOLOCK ); |
| 2866 | while( pEntry != NULL) |
| 2867 | { |
| 2868 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 2869 | if( (flushP2P == vos_mem_compare( pBssDesc->Result.ssId.ssId, |
| 2870 | "DIRECT-", 7)) && |
| 2871 | (GetRFBand(pBssDesc->Result.BssDescriptor.channelId) == band) |
| 2872 | ) |
| 2873 | { |
| 2874 | pFreeElem = pEntry; |
| 2875 | pEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK); |
| 2876 | csrLLRemoveEntry(pList, pFreeElem, LL_ACCESS_NOLOCK); |
| 2877 | csrFreeScanResultEntry( pMac, pBssDesc ); |
| 2878 | continue; |
| 2879 | } |
| 2880 | pEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK); |
| 2881 | } |
| 2882 | |
| 2883 | csrLLUnlock(pList); |
| 2884 | |
| 2885 | return (status); |
| 2886 | } |
| 2887 | |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2888 | eHalStatus csrScanFlushSelectiveResult(tpAniSirGlobal pMac, v_BOOL_t flushP2P) |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2889 | { |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2890 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2891 | tListElem *pEntry,*pFreeElem; |
| 2892 | tCsrScanResult *pBssDesc; |
| 2893 | tDblLinkList *pList = &pMac->scan.scanResultList; |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2894 | |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2895 | csrLLLock(pList); |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2896 | |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2897 | pEntry = csrLLPeekHead( pList, LL_ACCESS_NOLOCK ); |
| 2898 | while( pEntry != NULL) |
| 2899 | { |
| 2900 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 2901 | if( flushP2P == vos_mem_compare( pBssDesc->Result.ssId.ssId, |
| 2902 | "DIRECT-", 7) ) |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2903 | { |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2904 | pFreeElem = pEntry; |
| 2905 | pEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK); |
| 2906 | csrLLRemoveEntry(pList, pFreeElem, LL_ACCESS_NOLOCK); |
| 2907 | csrFreeScanResultEntry( pMac, pBssDesc ); |
| 2908 | continue; |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2909 | } |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2910 | pEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK); |
| 2911 | } |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2912 | |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2913 | csrLLUnlock(pList); |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2914 | |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2915 | return (status); |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2916 | } |
| 2917 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2918 | /** |
| 2919 | * csrCheck11dChannel |
| 2920 | * |
| 2921 | *FUNCTION: |
Srinivas, Dasari | 42bf770 | 2014-02-07 11:29:53 +0530 | [diff] [blame] | 2922 | * This function is called from csrScanFilterResults function and |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2923 | * compare channel number with given channel list. |
| 2924 | * |
| 2925 | *LOGIC: |
| 2926 | * Check Scan result channel number with CFG channel list |
| 2927 | * |
| 2928 | *ASSUMPTIONS: |
| 2929 | * |
| 2930 | * |
| 2931 | *NOTE: |
| 2932 | * |
| 2933 | * @param channelId channel number |
| 2934 | * @param pChannelList Pointer to channel list |
| 2935 | * @param numChannels Number of channel in channel list |
| 2936 | * |
| 2937 | * @return Status |
| 2938 | */ |
| 2939 | |
| 2940 | eHalStatus csrCheck11dChannel(tANI_U8 channelId, tANI_U8 *pChannelList, tANI_U32 numChannels) |
| 2941 | { |
| 2942 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 2943 | tANI_U8 i = 0; |
| 2944 | |
| 2945 | for (i = 0; i < numChannels; i++) |
| 2946 | { |
| 2947 | if(pChannelList[ i ] == channelId) |
| 2948 | { |
| 2949 | status = eHAL_STATUS_SUCCESS; |
| 2950 | break; |
| 2951 | } |
| 2952 | } |
| 2953 | return status; |
| 2954 | } |
| 2955 | |
| 2956 | /** |
Srinivas, Dasari | 42bf770 | 2014-02-07 11:29:53 +0530 | [diff] [blame] | 2957 | * csrScanFilterResults |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2958 | * |
| 2959 | *FUNCTION: |
| 2960 | * This function is called from csrApplyCountryInformation function and |
| 2961 | * filter scan result based on valid channel list number. |
| 2962 | * |
| 2963 | *LOGIC: |
| 2964 | * Get scan result from scan list and Check Scan result channel number |
| 2965 | * with 11d channel list if channel number is found in 11d channel list |
| 2966 | * then do not remove scan result entry from scan list |
| 2967 | * |
| 2968 | *ASSUMPTIONS: |
| 2969 | * |
| 2970 | * |
| 2971 | *NOTE: |
| 2972 | * |
| 2973 | * @param pMac Pointer to Global MAC structure |
| 2974 | * |
| 2975 | * @return Status |
| 2976 | */ |
| 2977 | |
Srinivas, Dasari | 42bf770 | 2014-02-07 11:29:53 +0530 | [diff] [blame] | 2978 | eHalStatus csrScanFilterResults(tpAniSirGlobal pMac) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2979 | { |
| 2980 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2981 | tListElem *pEntry,*pTempEntry; |
| 2982 | tCsrScanResult *pBssDesc; |
| 2983 | tANI_U32 len = sizeof(pMac->roam.validChannelList); |
| 2984 | |
| 2985 | /* Get valid channels list from CFG */ |
| 2986 | if (!HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, |
| 2987 | pMac->roam.validChannelList, &len))) |
| 2988 | { |
Agarwal Ashish | e3cca2a | 2013-07-21 03:01:48 +0530 | [diff] [blame] | 2989 | smsLog( pMac, LOGE, "Failed to get Channel list from CFG"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2990 | } |
| 2991 | |
| 2992 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_LOCK ); |
| 2993 | while( pEntry ) |
| 2994 | { |
| 2995 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
Srinivas, Dasari | 42bf770 | 2014-02-07 11:29:53 +0530 | [diff] [blame] | 2996 | pTempEntry = csrLLNext( &pMac->scan.scanResultList, pEntry, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2997 | LL_ACCESS_LOCK ); |
| 2998 | if(csrCheck11dChannel(pBssDesc->Result.BssDescriptor.channelId, |
Srinivas, Dasari | 42bf770 | 2014-02-07 11:29:53 +0530 | [diff] [blame] | 2999 | pMac->roam.validChannelList, len)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3000 | { |
| 3001 | /* Remove Scan result which does not have 11d channel */ |
| 3002 | if( csrLLRemoveEntry( &pMac->scan.scanResultList, pEntry, |
| 3003 | LL_ACCESS_LOCK )) |
| 3004 | { |
| 3005 | csrFreeScanResultEntry( pMac, pBssDesc ); |
| 3006 | } |
| 3007 | } |
Srinivas, Dasari | 42bf770 | 2014-02-07 11:29:53 +0530 | [diff] [blame] | 3008 | pEntry = pTempEntry; |
| 3009 | } |
| 3010 | |
| 3011 | pEntry = csrLLPeekHead( &pMac->scan.tempScanResults, LL_ACCESS_LOCK ); |
| 3012 | while( pEntry ) |
| 3013 | { |
| 3014 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 3015 | pTempEntry = csrLLNext( &pMac->scan.tempScanResults, pEntry, |
| 3016 | LL_ACCESS_LOCK ); |
| 3017 | if(csrCheck11dChannel(pBssDesc->Result.BssDescriptor.channelId, |
| 3018 | pMac->roam.validChannelList, len)) |
| 3019 | { |
| 3020 | /* Remove Scan result which does not have 11d channel */ |
| 3021 | if( csrLLRemoveEntry( &pMac->scan.tempScanResults, pEntry, |
| 3022 | LL_ACCESS_LOCK )) |
| 3023 | { |
| 3024 | csrFreeScanResultEntry( pMac, pBssDesc ); |
| 3025 | } |
| 3026 | } |
| 3027 | else |
| 3028 | { |
| 3029 | smsLog( pMac, LOG1, FL("%d is a Valid channel"), |
| 3030 | pBssDesc->Result.BssDescriptor.channelId); |
| 3031 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3032 | pEntry = pTempEntry; |
| 3033 | } |
| 3034 | return status; |
| 3035 | } |
| 3036 | |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 3037 | /** |
| 3038 | * csrScanFilterDFSResults |
| 3039 | * |
| 3040 | *FUNCTION: |
| 3041 | * This function filter BSSIDs on DFS channels from the scan results. |
| 3042 | * |
| 3043 | *LOGIC: |
| 3044 | * Get scan result from scan list and Check Scan result channel number |
| 3045 | * with 11d channel list if channel number is found in 11d channel list |
| 3046 | * and if fEnableDFSChnlScan is zero and if channel is DFS, then |
| 3047 | * remove scan result entry from scan list |
| 3048 | * |
| 3049 | *ASSUMPTIONS: |
| 3050 | * |
| 3051 | *NOTE: |
| 3052 | * |
| 3053 | * @param pMac Pointer to Global MAC structure |
| 3054 | * |
| 3055 | * @return Status |
| 3056 | */ |
| 3057 | |
| 3058 | eHalStatus csrScanFilterDFSResults(tpAniSirGlobal pMac) |
| 3059 | { |
| 3060 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 3061 | tListElem *pEntry,*pTempEntry; |
| 3062 | tCsrScanResult *pBssDesc; |
| 3063 | |
| 3064 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_LOCK ); |
| 3065 | while( pEntry ) |
| 3066 | { |
| 3067 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 3068 | pTempEntry = csrLLNext( &pMac->scan.scanResultList, pEntry, |
| 3069 | LL_ACCESS_LOCK ); |
| 3070 | if((pMac->scan.fEnableDFSChnlScan == DFS_CHNL_SCAN_DISABLED) && |
| 3071 | CSR_IS_CHANNEL_DFS(pBssDesc->Result.BssDescriptor.channelId)) |
| 3072 | { |
| 3073 | smsLog( pMac, LOG1, FL("%d is a DFS ch filtered from scan list"), |
| 3074 | pBssDesc->Result.BssDescriptor.channelId); |
| 3075 | /* Remove Scan result which does not have 11d channel */ |
| 3076 | if( csrLLRemoveEntry( &pMac->scan.scanResultList, pEntry, |
| 3077 | LL_ACCESS_LOCK )) |
| 3078 | { |
| 3079 | csrFreeScanResultEntry( pMac, pBssDesc ); |
| 3080 | } |
| 3081 | } |
| 3082 | else |
| 3083 | { |
| 3084 | smsLog( pMac, LOG1, FL("%d is a Valid channel"), |
| 3085 | pBssDesc->Result.BssDescriptor.channelId); |
| 3086 | } |
| 3087 | pEntry = pTempEntry; |
| 3088 | } |
| 3089 | |
| 3090 | pEntry = csrLLPeekHead( &pMac->scan.tempScanResults, LL_ACCESS_LOCK ); |
| 3091 | while( pEntry ) |
| 3092 | { |
| 3093 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 3094 | pTempEntry = csrLLNext( &pMac->scan.tempScanResults, pEntry, |
| 3095 | LL_ACCESS_LOCK ); |
| 3096 | |
| 3097 | if((pMac->scan.fEnableDFSChnlScan == DFS_CHNL_SCAN_DISABLED) && |
| 3098 | CSR_IS_CHANNEL_DFS(pBssDesc->Result.BssDescriptor.channelId)) |
| 3099 | { |
| 3100 | smsLog( pMac, LOG1, FL("%d is a DFS ch filtered from scan list"), |
| 3101 | pBssDesc->Result.BssDescriptor.channelId); |
| 3102 | /* Remove Scan result which does not have 11d channel */ |
| 3103 | if( csrLLRemoveEntry( &pMac->scan.tempScanResults, pEntry, |
| 3104 | LL_ACCESS_LOCK )) |
| 3105 | { |
| 3106 | csrFreeScanResultEntry( pMac, pBssDesc ); |
| 3107 | } |
| 3108 | } |
| 3109 | else |
| 3110 | { |
| 3111 | smsLog( pMac, LOG1, FL("%d is a Valid channel"), |
| 3112 | pBssDesc->Result.BssDescriptor.channelId); |
| 3113 | } |
| 3114 | pEntry = pTempEntry; |
| 3115 | } |
| 3116 | return status; |
| 3117 | } |
| 3118 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3119 | |
| 3120 | eHalStatus csrScanCopyResultList(tpAniSirGlobal pMac, tScanResultHandle hIn, tScanResultHandle *phResult) |
| 3121 | { |
| 3122 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 3123 | tScanResultList *pRetList, *pInList = (tScanResultList *)hIn; |
| 3124 | tCsrScanResult *pResult, *pScanResult; |
| 3125 | tANI_U32 count = 0; |
| 3126 | tListElem *pEntry; |
| 3127 | tANI_U32 bssLen, allocLen; |
| 3128 | |
| 3129 | if(phResult) |
| 3130 | { |
| 3131 | *phResult = CSR_INVALID_SCANRESULT_HANDLE; |
| 3132 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3133 | pRetList = vos_mem_malloc(sizeof(tScanResultList)); |
| 3134 | if ( NULL == pRetList ) |
| 3135 | status = eHAL_STATUS_FAILURE; |
| 3136 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3137 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3138 | vos_mem_set(pRetList, sizeof(tScanResultList), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3139 | csrLLOpen(pMac->hHdd, &pRetList->List); |
| 3140 | pRetList->pCurEntry = NULL; |
| 3141 | csrLLLock(&pMac->scan.scanResultList); |
| 3142 | csrLLLock(&pInList->List); |
| 3143 | |
| 3144 | pEntry = csrLLPeekHead( &pInList->List, LL_ACCESS_NOLOCK ); |
| 3145 | while( pEntry ) |
| 3146 | { |
| 3147 | pScanResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 3148 | bssLen = pScanResult->Result.BssDescriptor.length + sizeof(pScanResult->Result.BssDescriptor.length); |
| 3149 | allocLen = sizeof( tCsrScanResult ) + bssLen; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3150 | pResult = vos_mem_malloc(allocLen); |
| 3151 | if ( NULL == pResult ) |
| 3152 | status = eHAL_STATUS_FAILURE; |
| 3153 | else |
| 3154 | status = eHAL_STATUS_SUCCESS; |
| 3155 | if (!HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3156 | { |
| 3157 | csrScanResultPurge(pMac, (tScanResultHandle *)pRetList); |
| 3158 | count = 0; |
| 3159 | break; |
| 3160 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3161 | vos_mem_set(pResult, allocLen , 0); |
| 3162 | vos_mem_copy(&pResult->Result.BssDescriptor, &pScanResult->Result.BssDescriptor, bssLen); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3163 | if( pScanResult->Result.pvIes ) |
| 3164 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3165 | pResult->Result.pvIes = vos_mem_malloc(sizeof( tDot11fBeaconIEs )); |
| 3166 | if ( NULL == pResult->Result.pvIes ) |
| 3167 | status = eHAL_STATUS_FAILURE; |
| 3168 | else |
| 3169 | status = eHAL_STATUS_SUCCESS; |
| 3170 | if (!HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3171 | { |
| 3172 | //Free the memory we allocate above first |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3173 | vos_mem_free(pResult); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3174 | csrScanResultPurge(pMac, (tScanResultHandle *)pRetList); |
| 3175 | count = 0; |
| 3176 | break; |
| 3177 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3178 | vos_mem_copy(pResult->Result.pvIes, pScanResult->Result.pvIes, |
| 3179 | sizeof( tDot11fBeaconIEs )); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3180 | } |
| 3181 | csrLLInsertTail(&pRetList->List, &pResult->Link, LL_ACCESS_LOCK); |
| 3182 | count++; |
| 3183 | pEntry = csrLLNext( &pInList->List, pEntry, LL_ACCESS_NOLOCK ); |
| 3184 | }//while |
| 3185 | csrLLUnlock(&pInList->List); |
| 3186 | csrLLUnlock(&pMac->scan.scanResultList); |
| 3187 | |
| 3188 | if(HAL_STATUS_SUCCESS(status)) |
| 3189 | { |
| 3190 | if(0 == count) |
| 3191 | { |
| 3192 | csrLLClose(&pRetList->List); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3193 | vos_mem_free(pRetList); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3194 | status = eHAL_STATUS_E_NULL_VALUE; |
| 3195 | } |
| 3196 | else if(phResult) |
| 3197 | { |
| 3198 | *phResult = pRetList; |
| 3199 | } |
| 3200 | } |
| 3201 | }//Allocated pRetList |
| 3202 | |
| 3203 | return (status); |
| 3204 | } |
| 3205 | |
| 3206 | |
| 3207 | |
| 3208 | eHalStatus csrScanningStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf ) |
| 3209 | { |
| 3210 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 3211 | tSirMbMsg *pMsg = (tSirMbMsg *)pMsgBuf; |
Hanumantha Reddy Pothula | dc095f3 | 2015-11-30 20:50:23 +0530 | [diff] [blame] | 3212 | tSirSmeDisConDoneInd *pDisConDoneInd; |
Abhishek Singh | f52182c | 2016-08-24 11:15:23 +0530 | [diff] [blame] | 3213 | tCsrRoamSession *pSession; |
Hanumantha Reddy Pothula | dc095f3 | 2015-11-30 20:50:23 +0530 | [diff] [blame] | 3214 | tCsrRoamInfo roamInfo = {0}; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3215 | |
Hanumantha Reddy Pothula | dc095f3 | 2015-11-30 20:50:23 +0530 | [diff] [blame] | 3216 | if((eWNI_SME_SCAN_RSP == pMsg->type) || |
| 3217 | (eWNI_SME_GET_SCANNED_CHANNEL_RSP == pMsg->type)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3218 | { |
| 3219 | status = csrScanSmeScanResponse( pMac, pMsgBuf ); |
| 3220 | } |
| 3221 | else |
| 3222 | { |
Hanumantha Reddy Pothula | dc095f3 | 2015-11-30 20:50:23 +0530 | [diff] [blame] | 3223 | switch (pMsg->type) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3224 | { |
Hanumantha Reddy Pothula | dc095f3 | 2015-11-30 20:50:23 +0530 | [diff] [blame] | 3225 | case eWNI_SME_UPPER_LAYER_ASSOC_CNF: |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 3226 | { |
Hanumantha Reddy Pothula | dc095f3 | 2015-11-30 20:50:23 +0530 | [diff] [blame] | 3227 | tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf; |
| 3228 | tCsrRoamInfo *pRoamInfo = NULL; |
| 3229 | tANI_U32 sessionId; |
| 3230 | eHalStatus status; |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 3231 | |
Hanumantha Reddy Pothula | dc095f3 | 2015-11-30 20:50:23 +0530 | [diff] [blame] | 3232 | smsLog( pMac, LOG1, |
| 3233 | FL("Scanning : ASSOCIATION confirmation can be given to upper layer ")); |
| 3234 | pRoamInfo = &roamInfo; |
| 3235 | pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf; |
| 3236 | status = csrRoamGetSessionIdFromBSSID( pMac, |
| 3237 | (tCsrBssid *)pUpperLayerAssocCnf->bssId, |
| 3238 | &sessionId ); |
| 3239 | pSession = CSR_GET_SESSION(pMac, sessionId); |
| 3240 | |
| 3241 | if(!pSession) |
| 3242 | { |
| 3243 | smsLog(pMac, LOGE, FL("session %d not found "), sessionId); |
| 3244 | return eHAL_STATUS_FAILURE; |
| 3245 | } |
| 3246 | |
| 3247 | //send the status code as Success |
| 3248 | pRoamInfo->statusCode = eSIR_SME_SUCCESS; |
| 3249 | pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile; |
| 3250 | pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid; |
| 3251 | pRoamInfo->rsnIELen = |
| 3252 | (tANI_U8)pUpperLayerAssocCnf->rsnIE.length; |
| 3253 | pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata; |
| 3254 | pRoamInfo->addIELen = |
| 3255 | (tANI_U8)pUpperLayerAssocCnf->addIE.length; |
| 3256 | pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata; |
| 3257 | vos_mem_copy(pRoamInfo->peerMac, |
| 3258 | pUpperLayerAssocCnf->peerMacAddr, |
| 3259 | sizeof(tSirMacAddr)); |
| 3260 | vos_mem_copy(&pRoamInfo->bssid, |
| 3261 | pUpperLayerAssocCnf->bssId, |
| 3262 | sizeof(tCsrBssid)); |
| 3263 | pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta; |
Hardik Kantilal Patel | 1ba630f | 2014-11-21 04:32:05 +0530 | [diff] [blame] | 3264 | #ifdef WLAN_FEATURE_AP_HT40_24G |
Hanumantha Reddy Pothula | dc095f3 | 2015-11-30 20:50:23 +0530 | [diff] [blame] | 3265 | pRoamInfo->HT40MHzIntoEnabledSta = |
| 3266 | pUpperLayerAssocCnf->HT40MHzIntoEnabledSta; |
Hardik Kantilal Patel | 1ba630f | 2014-11-21 04:32:05 +0530 | [diff] [blame] | 3267 | #endif |
Hanumantha Reddy Pothula | dc095f3 | 2015-11-30 20:50:23 +0530 | [diff] [blame] | 3268 | if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) ) |
| 3269 | { |
| 3270 | pMac->roam.roamSession[sessionId].connectState = |
| 3271 | eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED; |
| 3272 | pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq; |
| 3273 | status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, |
| 3274 | 0, eCSR_ROAM_INFRA_IND, |
| 3275 | eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF); |
| 3276 | } |
| 3277 | if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile)) |
| 3278 | { |
| 3279 | vos_sleep( 100 ); |
| 3280 | pMac->roam.roamSession[sessionId].connectState = |
| 3281 | eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta |
| 3282 | status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, |
| 3283 | eCSR_ROAM_WDS_IND, |
| 3284 | eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta |
| 3285 | } |
| 3286 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3287 | } |
Hanumantha Reddy Pothula | dc095f3 | 2015-11-30 20:50:23 +0530 | [diff] [blame] | 3288 | case eWNI_SME_DISCONNECT_DONE_IND: |
| 3289 | pDisConDoneInd = (tSirSmeDisConDoneInd *)(pMsg); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 3290 | |
Hanumantha Reddy Pothula | dc095f3 | 2015-11-30 20:50:23 +0530 | [diff] [blame] | 3291 | smsLog( pMac, LOG1, |
| 3292 | FL("eWNI_SME_DISCONNECT_DONE_IND RC:%d"), |
| 3293 | pDisConDoneInd->reasonCode); |
Sreelakshmi Konamki | 033cf60 | 2016-10-12 15:30:14 +0530 | [diff] [blame] | 3294 | pSession = CSR_GET_SESSION(pMac,pDisConDoneInd->sessionId); |
| 3295 | if (pSession) |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 3296 | { |
Sreelakshmi Konamki | 033cf60 | 2016-10-12 15:30:14 +0530 | [diff] [blame] | 3297 | if( CSR_IS_SESSION_VALID(pMac, pDisConDoneInd->sessionId)) |
| 3298 | { |
| 3299 | roamInfo.reasonCode = pDisConDoneInd->reasonCode; |
| 3300 | roamInfo.statusCode = eSIR_SME_STA_DISASSOCIATED; |
| 3301 | vos_mem_copy(roamInfo.peerMac, pDisConDoneInd->peerMacAddr, |
| 3302 | sizeof(tSirMacAddr)); |
| 3303 | status = csrRoamCallCallback(pMac, |
| 3304 | pDisConDoneInd->sessionId, |
| 3305 | &roamInfo, 0, |
| 3306 | eCSR_ROAM_LOSTLINK, |
| 3307 | eCSR_ROAM_RESULT_DISASSOC_IND); |
| 3308 | /* |
| 3309 | * Update the previous state if |
| 3310 | * previous state was eCSR_ROAMING_STATE_JOINED |
| 3311 | * as we are disconnected and |
| 3312 | * currunt state is scanning |
| 3313 | */ |
| 3314 | if (!CSR_IS_INFRA_AP(&pSession->connectedProfile) |
| 3315 | && (eCSR_ROAMING_STATE_IDLE != |
| 3316 | pMac->roam.prev_state[pDisConDoneInd->sessionId])) |
| 3317 | pMac->roam.prev_state[pDisConDoneInd->sessionId] = |
| 3318 | eCSR_ROAMING_STATE_IDLE; |
| 3319 | } |
| 3320 | else |
| 3321 | { |
| 3322 | smsLog(pMac, LOGE, FL("Inactive session %d"), |
Abhishek Singh | f52182c | 2016-08-24 11:15:23 +0530 | [diff] [blame] | 3323 | pDisConDoneInd->sessionId); |
Sreelakshmi Konamki | 033cf60 | 2016-10-12 15:30:14 +0530 | [diff] [blame] | 3324 | status = eHAL_STATUS_FAILURE; |
| 3325 | } |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 3326 | } |
| 3327 | else |
| 3328 | { |
Sreelakshmi Konamki | 033cf60 | 2016-10-12 15:30:14 +0530 | [diff] [blame] | 3329 | smsLog(pMac, LOGE, FL("Invalid session")); |
Hanumantha Reddy Pothula | dc095f3 | 2015-11-30 20:50:23 +0530 | [diff] [blame] | 3330 | status = eHAL_STATUS_FAILURE; |
| 3331 | } |
| 3332 | break; |
| 3333 | |
| 3334 | default : |
| 3335 | if( csrIsAnySessionInConnectState( pMac ) ) |
| 3336 | { |
| 3337 | /*In case of we are connected, we need to check whether connect |
| 3338 | * status changes because scan may also run while connected. |
| 3339 | */ |
| 3340 | csrRoamCheckForLinkStatusChange( pMac, (tSirSmeRsp *)pMsgBuf ); |
| 3341 | } |
| 3342 | else |
| 3343 | { |
| 3344 | smsLog( pMac, LOGW, |
| 3345 | "Message [0x%04x] received in state, when expecting Scan Response", |
| 3346 | pMsg->type ); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 3347 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3348 | } |
| 3349 | } |
| 3350 | |
| 3351 | return (status); |
| 3352 | } |
| 3353 | |
| 3354 | |
| 3355 | |
| 3356 | void csrCheckNSaveWscIe(tpAniSirGlobal pMac, tSirBssDescription *pNewBssDescr, tSirBssDescription *pOldBssDescr) |
| 3357 | { |
| 3358 | int idx, len; |
| 3359 | tANI_U8 *pbIe; |
| 3360 | |
| 3361 | //If failed to remove, assuming someone else got it. |
| 3362 | if((pNewBssDescr->fProbeRsp != pOldBssDescr->fProbeRsp) && |
| 3363 | (0 == pNewBssDescr->WscIeLen)) |
| 3364 | { |
| 3365 | idx = 0; |
Abhishek Singh | bad2b32 | 2016-10-21 11:22:33 +0530 | [diff] [blame] | 3366 | len = GET_IE_LEN_IN_BSS(pOldBssDescr->length) |
| 3367 | - DOT11F_IE_WSCPROBERES_MIN_LEN - 2; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3368 | pbIe = (tANI_U8 *)pOldBssDescr->ieFields; |
| 3369 | //Save WPS IE if it exists |
| 3370 | pNewBssDescr->WscIeLen = 0; |
| 3371 | while(idx < len) |
| 3372 | { |
| 3373 | if((DOT11F_EID_WSCPROBERES == pbIe[0]) && |
| 3374 | (0x00 == pbIe[2]) && (0x50 == pbIe[3]) && (0xf2 == pbIe[4]) && (0x04 == pbIe[5])) |
| 3375 | { |
| 3376 | //Founrd it |
| 3377 | if((DOT11F_IE_WSCPROBERES_MAX_LEN - 2) >= pbIe[1]) |
| 3378 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3379 | vos_mem_copy(pNewBssDescr->WscIeProbeRsp, pbIe, pbIe[1] + 2); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3380 | pNewBssDescr->WscIeLen = pbIe[1] + 2; |
| 3381 | } |
| 3382 | break; |
| 3383 | } |
| 3384 | idx += pbIe[1] + 2; |
| 3385 | pbIe += pbIe[1] + 2; |
| 3386 | } |
| 3387 | } |
| 3388 | } |
| 3389 | |
| 3390 | |
| 3391 | |
| 3392 | //pIes may be NULL |
| 3393 | tANI_BOOLEAN csrRemoveDupBssDescription( tpAniSirGlobal pMac, tSirBssDescription *pSirBssDescr, |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 3394 | tDot11fBeaconIEs *pIes, tAniSSID *pSsid, v_TIME_t *timer, tANI_BOOLEAN fForced ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3395 | { |
| 3396 | tListElem *pEntry; |
| 3397 | |
| 3398 | tCsrScanResult *pBssDesc; |
| 3399 | tANI_BOOLEAN fRC = FALSE; |
Abhishek Singh | 56c2981 | 2018-06-12 14:07:52 +0530 | [diff] [blame^] | 3400 | tDot11fBeaconIEs *temp_ie = pIes; |
| 3401 | |
| 3402 | if (!temp_ie) |
| 3403 | csrGetParsedBssDescriptionIEs(pMac, pSirBssDescr, &temp_ie); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3404 | |
| 3405 | // Walk through all the chained BssDescriptions. If we find a chained BssDescription that |
| 3406 | // matches the BssID of the BssDescription passed in, then these must be duplicate scan |
| 3407 | // results for this Bss. In that case, remove the 'old' Bss description from the linked list. |
| 3408 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_LOCK ); |
| 3409 | |
| 3410 | while( pEntry ) |
| 3411 | { |
| 3412 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 3413 | |
| 3414 | // we have a duplicate scan results only when BSSID, SSID, Channel and NetworkType |
| 3415 | // matches |
Abhishek Singh | 56c2981 | 2018-06-12 14:07:52 +0530 | [diff] [blame^] | 3416 | if (csrIsDuplicateBssDescription(pMac, &pBssDesc->Result.BssDescriptor, |
| 3417 | pSirBssDescr, temp_ie, fForced)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3418 | { |
Abhishek Singh | 56c2981 | 2018-06-12 14:07:52 +0530 | [diff] [blame^] | 3419 | /* |
| 3420 | * Due to Rx sensitivity issue, sometime beacons are seen on |
| 3421 | * adjacent channel so workaround in software is needed. If DS |
| 3422 | * params or HT info are present driver can get proper channel |
| 3423 | * info from these IEs and the older RSSI values are used in new |
| 3424 | * entry. |
| 3425 | * |
| 3426 | * For the cases where DS params and HT info is not present, |
| 3427 | * driver needs to check below conditions to update proper |
| 3428 | * channel so that the older RSSI and channel values are used in |
| 3429 | * new entry: |
| 3430 | * -- The old entry channel and new entry channel are not same |
| 3431 | * -- RSSI is below 15db or more from old value, this indicate |
| 3432 | * that the signal has leaked in adjacent channel |
| 3433 | */ |
| 3434 | if (!pSirBssDescr->fProbeRsp && |
| 3435 | (temp_ie && !temp_ie->DSParams.present && |
| 3436 | !temp_ie->HTInfo.present) && |
| 3437 | (pSirBssDescr->channelId != |
| 3438 | pBssDesc->Result.BssDescriptor.channelId) && |
| 3439 | ((pBssDesc->Result.BssDescriptor.rssi - pSirBssDescr->rssi) > |
| 3440 | SIR_ADJACENT_CHANNEL_RSSI_DIFF_THRESHOLD)) { |
| 3441 | pSirBssDescr->channelId = |
| 3442 | pBssDesc->Result.BssDescriptor.channelId; |
| 3443 | pSirBssDescr->rssi = |
| 3444 | pBssDesc->Result.BssDescriptor.rssi; |
| 3445 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3446 | pSirBssDescr->rssi = (tANI_S8)( (((tANI_S32)pSirBssDescr->rssi * CSR_SCAN_RESULT_RSSI_WEIGHT ) + |
| 3447 | ((tANI_S32)pBssDesc->Result.BssDescriptor.rssi * (100 - CSR_SCAN_RESULT_RSSI_WEIGHT) )) / 100 ); |
| 3448 | // Remove the 'old' entry from the list.... |
| 3449 | if( csrLLRemoveEntry( &pMac->scan.scanResultList, pEntry, LL_ACCESS_LOCK ) ) |
| 3450 | { |
| 3451 | // !we need to free the memory associated with this node |
| 3452 | //If failed to remove, assuming someone else got it. |
| 3453 | *pSsid = pBssDesc->Result.ssId; |
| 3454 | *timer = pBssDesc->Result.timer; |
| 3455 | csrCheckNSaveWscIe(pMac, pSirBssDescr, &pBssDesc->Result.BssDescriptor); |
| 3456 | |
| 3457 | csrFreeScanResultEntry( pMac, pBssDesc ); |
| 3458 | } |
| 3459 | else |
| 3460 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 3461 | smsLog( pMac, LOGW, FL( " fail to remove entry" ) ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3462 | } |
| 3463 | fRC = TRUE; |
| 3464 | |
| 3465 | // If we found a match, we can stop looking through the list. |
| 3466 | break; |
| 3467 | } |
| 3468 | |
| 3469 | pEntry = csrLLNext( &pMac->scan.scanResultList, pEntry, LL_ACCESS_LOCK ); |
| 3470 | } |
| 3471 | |
Abhishek Singh | 56c2981 | 2018-06-12 14:07:52 +0530 | [diff] [blame^] | 3472 | if (!pIes && temp_ie) |
| 3473 | vos_mem_free(temp_ie); |
| 3474 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3475 | return fRC; |
| 3476 | } |
| 3477 | |
| 3478 | |
| 3479 | eHalStatus csrAddPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId, |
| 3480 | tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes ) |
| 3481 | { |
| 3482 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 3483 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 3484 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 3485 | if(!pSession) |
| 3486 | { |
| 3487 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 3488 | return eHAL_STATUS_FAILURE; |
| 3489 | } |
| 3490 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 3491 | smsLog(pMac, LOGW, "csrAddPMKIDCandidateList called pMac->scan.NumPmkidCandidate = %d", pSession->NumPmkidCandidate); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3492 | if( pIes ) |
| 3493 | { |
| 3494 | // check if this is a RSN BSS |
| 3495 | if( pIes->RSN.present ) |
| 3496 | { |
| 3497 | // Check if the BSS is capable of doing pre-authentication |
| 3498 | if( pSession->NumPmkidCandidate < CSR_MAX_PMKID_ALLOWED ) |
| 3499 | { |
| 3500 | |
| 3501 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 3502 | { |
| 3503 | WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3504 | vos_mem_set(&secEvent, sizeof(vos_event_wlan_security_payload_type), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3505 | secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_CANDIDATE_FOUND; |
| 3506 | secEvent.encryptionModeMulticast = |
| 3507 | (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType); |
| 3508 | secEvent.encryptionModeUnicast = |
| 3509 | (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3510 | vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3511 | secEvent.authMode = |
| 3512 | (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType); |
| 3513 | WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY); |
| 3514 | } |
| 3515 | #endif//#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 3516 | |
| 3517 | // if yes, then add to PMKIDCandidateList |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3518 | vos_mem_copy(pSession->PmkidCandidateInfo[pSession->NumPmkidCandidate].BSSID, |
| 3519 | pBssDesc->bssId, WNI_CFG_BSSID_LEN); |
| 3520 | // Bit 0 offirst byte - PreAuthentication Capability |
| 3521 | if ( (pIes->RSN.RSN_Cap[0] >> 0) & 0x1 ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3522 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3523 | pSession->PmkidCandidateInfo[pSession->NumPmkidCandidate].preAuthSupported |
| 3524 | = eANI_BOOLEAN_TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3525 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3526 | else |
| 3527 | { |
| 3528 | pSession->PmkidCandidateInfo[pSession->NumPmkidCandidate].preAuthSupported |
| 3529 | = eANI_BOOLEAN_FALSE; |
| 3530 | } |
| 3531 | pSession->NumPmkidCandidate++; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3532 | } |
| 3533 | else |
| 3534 | { |
| 3535 | status = eHAL_STATUS_FAILURE; |
| 3536 | } |
| 3537 | } |
| 3538 | } |
| 3539 | |
| 3540 | return (status); |
| 3541 | } |
| 3542 | |
| 3543 | //This function checks whether new AP is found for the current connected profile |
| 3544 | //If it is found, it return the sessionId, else it return invalid sessionID |
| 3545 | tANI_U32 csrProcessBSSDescForPMKIDList(tpAniSirGlobal pMac, |
| 3546 | tSirBssDescription *pBssDesc, |
| 3547 | tDot11fBeaconIEs *pIes) |
| 3548 | { |
| 3549 | tANI_U32 i, bRet = CSR_SESSION_ID_INVALID; |
| 3550 | tCsrRoamSession *pSession; |
| 3551 | tDot11fBeaconIEs *pIesLocal = pIes; |
| 3552 | |
| 3553 | if( pIesLocal || HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal)) ) |
| 3554 | { |
| 3555 | for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ ) |
| 3556 | { |
| 3557 | if( CSR_IS_SESSION_VALID( pMac, i ) ) |
| 3558 | { |
| 3559 | pSession = CSR_GET_SESSION( pMac, i ); |
| 3560 | if( csrIsConnStateConnectedInfra( pMac, i ) && |
| 3561 | ( eCSR_AUTH_TYPE_RSN == pSession->connectedProfile.AuthType ) ) |
| 3562 | { |
| 3563 | if(csrMatchBSSToConnectProfile(pMac, &pSession->connectedProfile, pBssDesc, pIesLocal)) |
| 3564 | { |
| 3565 | //this new BSS fits the current profile connected |
| 3566 | if(HAL_STATUS_SUCCESS(csrAddPMKIDCandidateList(pMac, i, pBssDesc, pIesLocal))) |
| 3567 | { |
| 3568 | bRet = i; |
| 3569 | } |
| 3570 | break; |
| 3571 | } |
| 3572 | } |
| 3573 | } |
| 3574 | } |
| 3575 | if( !pIes ) |
| 3576 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3577 | vos_mem_free(pIesLocal); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3578 | } |
| 3579 | } |
| 3580 | |
| 3581 | return (tANI_U8)bRet; |
| 3582 | } |
| 3583 | |
| 3584 | #ifdef FEATURE_WLAN_WAPI |
| 3585 | eHalStatus csrAddBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId, |
| 3586 | tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes ) |
| 3587 | { |
| 3588 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 3589 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 3590 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 3591 | if(!pSession) |
| 3592 | { |
| 3593 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 3594 | return eHAL_STATUS_FAILURE; |
| 3595 | } |
| 3596 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3597 | smsLog(pMac, LOGW, "csrAddBKIDCandidateList called pMac->scan.NumBkidCandidate = %d", |
| 3598 | pSession->NumBkidCandidate); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3599 | if( pIes ) |
| 3600 | { |
| 3601 | // check if this is a WAPI BSS |
| 3602 | if( pIes->WAPI.present ) |
| 3603 | { |
| 3604 | // Check if the BSS is capable of doing pre-authentication |
| 3605 | if( pSession->NumBkidCandidate < CSR_MAX_BKID_ALLOWED ) |
| 3606 | { |
| 3607 | |
| 3608 | // if yes, then add to BKIDCandidateList |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3609 | vos_mem_copy(pSession->BkidCandidateInfo[pSession->NumBkidCandidate].BSSID, |
| 3610 | pBssDesc->bssId, WNI_CFG_BSSID_LEN); |
| 3611 | if ( pIes->WAPI.preauth ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3612 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3613 | pSession->BkidCandidateInfo[pSession->NumBkidCandidate].preAuthSupported |
| 3614 | = eANI_BOOLEAN_TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3615 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3616 | else |
| 3617 | { |
| 3618 | pSession->BkidCandidateInfo[pSession->NumBkidCandidate].preAuthSupported |
| 3619 | = eANI_BOOLEAN_FALSE; |
| 3620 | } |
| 3621 | pSession->NumBkidCandidate++; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3622 | } |
| 3623 | else |
| 3624 | { |
| 3625 | status = eHAL_STATUS_FAILURE; |
| 3626 | } |
| 3627 | } |
| 3628 | } |
| 3629 | |
| 3630 | return (status); |
| 3631 | } |
| 3632 | |
| 3633 | //This function checks whether new AP is found for the current connected profile |
| 3634 | //if so add to BKIDCandidateList |
| 3635 | tANI_BOOLEAN csrProcessBSSDescForBKIDList(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc, |
| 3636 | tDot11fBeaconIEs *pIes) |
| 3637 | { |
| 3638 | tANI_BOOLEAN fRC = FALSE; |
| 3639 | tDot11fBeaconIEs *pIesLocal = pIes; |
| 3640 | tANI_U32 sessionId; |
| 3641 | tCsrRoamSession *pSession; |
| 3642 | |
| 3643 | if( pIesLocal || HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal)) ) |
| 3644 | { |
| 3645 | for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ ) |
| 3646 | { |
| 3647 | if( CSR_IS_SESSION_VALID( pMac, sessionId) ) |
| 3648 | { |
| 3649 | pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 3650 | if( csrIsConnStateConnectedInfra( pMac, sessionId ) && |
| 3651 | eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == pSession->connectedProfile.AuthType) |
| 3652 | { |
| 3653 | if(csrMatchBSSToConnectProfile(pMac, &pSession->connectedProfile,pBssDesc, pIesLocal)) |
| 3654 | { |
| 3655 | //this new BSS fits the current profile connected |
| 3656 | if(HAL_STATUS_SUCCESS(csrAddBKIDCandidateList(pMac, sessionId, pBssDesc, pIesLocal))) |
| 3657 | { |
| 3658 | fRC = TRUE; |
| 3659 | } |
| 3660 | } |
| 3661 | } |
| 3662 | } |
| 3663 | } |
| 3664 | if(!pIes) |
| 3665 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3666 | vos_mem_free(pIesLocal); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3667 | } |
| 3668 | |
| 3669 | } |
| 3670 | return fRC; |
| 3671 | } |
| 3672 | |
| 3673 | #endif |
| 3674 | |
| 3675 | |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 3676 | static void csrMoveTempScanResultsToMainList( tpAniSirGlobal pMac, tANI_U8 reason ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3677 | { |
| 3678 | tListElem *pEntry; |
| 3679 | tCsrScanResult *pBssDescription; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3680 | tANI_BOOLEAN fDupBss; |
| 3681 | #ifdef FEATURE_WLAN_WAPI |
| 3682 | tANI_BOOLEAN fNewWapiBSSForCurConnection = eANI_BOOLEAN_FALSE; |
| 3683 | #endif /* FEATURE_WLAN_WAPI */ |
| 3684 | tDot11fBeaconIEs *pIesLocal = NULL; |
| 3685 | tANI_U32 sessionId = CSR_SESSION_ID_INVALID; |
| 3686 | tAniSSID tmpSsid; |
| 3687 | v_TIME_t timer=0; |
Kapil Gupta | 2f2fae4 | 2016-09-15 15:29:47 +0530 | [diff] [blame] | 3688 | tANI_U8 occupied_chan_count = pMac->scan.occupiedChannels.numChannels; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3689 | |
| 3690 | tmpSsid.length = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3691 | |
| 3692 | // remove the BSS descriptions from temporary list |
| 3693 | while( ( pEntry = csrLLRemoveTail( &pMac->scan.tempScanResults, LL_ACCESS_LOCK ) ) != NULL) |
| 3694 | { |
| 3695 | pBssDescription = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 3696 | |
Vinay Krishna Eranna | 566365f | 2015-03-09 12:34:13 +0530 | [diff] [blame] | 3697 | smsLog( pMac, LOG2, "...Bssid= "MAC_ADDRESS_STR" chan= %d, rssi = -%d", |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 3698 | MAC_ADDR_ARRAY(pBssDescription->Result.BssDescriptor.bssId), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3699 | pBssDescription->Result.BssDescriptor.channelId, |
| 3700 | pBssDescription->Result.BssDescriptor.rssi * (-1) ); |
| 3701 | |
| 3702 | //At this time, pBssDescription->Result.pvIes may be NULL |
| 3703 | pIesLocal = (tDot11fBeaconIEs *)( pBssDescription->Result.pvIes ); |
| 3704 | if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pBssDescription->Result.BssDescriptor, &pIesLocal))) ) |
| 3705 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 3706 | smsLog(pMac, LOGE, FL(" Cannot pared IEs")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3707 | csrFreeScanResultEntry(pMac, pBssDescription); |
| 3708 | continue; |
| 3709 | } |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 3710 | fDupBss = csrRemoveDupBssDescription( pMac, &pBssDescription->Result.BssDescriptor, pIesLocal, &tmpSsid, &timer, FALSE ); |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 3711 | //Check whether we have reach out limit, but don't lose the LFR candidates came from FW |
| 3712 | if( CSR_SCAN_IS_OVER_BSS_LIMIT(pMac) |
| 3713 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 3714 | && !( eCsrScanGetLfrResult == reason ) |
| 3715 | #endif |
| 3716 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3717 | { |
Deepthi Gowri | 50e2fa5 | 2016-03-17 15:30:53 +0530 | [diff] [blame] | 3718 | smsLog(pMac, LOG1, FL("########## BSS Limit reached ###########")); |
Abhishek Singh | 5deecd1 | 2017-06-12 11:08:40 +0530 | [diff] [blame] | 3719 | csrPurgeScanResults(pMac); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3720 | } |
| 3721 | // check for duplicate scan results |
| 3722 | if ( !fDupBss ) |
| 3723 | { |
| 3724 | //Found a new BSS |
| 3725 | sessionId = csrProcessBSSDescForPMKIDList(pMac, |
| 3726 | &pBssDescription->Result.BssDescriptor, pIesLocal); |
| 3727 | if( CSR_SESSION_ID_INVALID != sessionId) |
| 3728 | { |
| 3729 | csrRoamCallCallback(pMac, sessionId, NULL, 0, |
| 3730 | eCSR_ROAM_SCAN_FOUND_NEW_BSS, eCSR_ROAM_RESULT_NONE); |
| 3731 | } |
| 3732 | } |
| 3733 | else |
| 3734 | { |
| 3735 | //Check if the new one has SSID it it, if not, use the older SSID if it exists. |
| 3736 | if( (0 == pBssDescription->Result.ssId.length) && tmpSsid.length ) |
| 3737 | { |
| 3738 | //New BSS has a hidden SSID and old one has the SSID. Keep the SSID only |
| 3739 | //if diff of saved SSID time and current time is less than 1 min to avoid |
| 3740 | //side effect of saving SSID with old one is that if AP changes its SSID while remain |
| 3741 | //hidden, we may never see it and also to address the requirement of |
| 3742 | //When we remove hidden ssid from the profile i.e., forget the SSID via |
| 3743 | // GUI that SSID shouldn't see in the profile |
| 3744 | if( (vos_timer_get_system_time() - timer) <= HIDDEN_TIMER) |
| 3745 | { |
| 3746 | pBssDescription->Result.timer = timer; |
| 3747 | pBssDescription->Result.ssId = tmpSsid; |
| 3748 | } |
| 3749 | } |
| 3750 | } |
| 3751 | |
Agarwal Ashish | d9d7260 | 2013-09-13 00:06:17 +0530 | [diff] [blame] | 3752 | //Find a good AP for 11d info |
| 3753 | if ( csrIs11dSupported( pMac ) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3754 | { |
Agrawal Ashish | 0b6984f | 2014-04-05 18:35:45 +0530 | [diff] [blame] | 3755 | // check if country information element is present |
| 3756 | if (pIesLocal->Country.present) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3757 | { |
Agrawal Ashish | 0b6984f | 2014-04-05 18:35:45 +0530 | [diff] [blame] | 3758 | csrAddVoteForCountryInfo(pMac, pIesLocal->Country.country); |
| 3759 | smsLog(pMac, LOGW, FL("11d AP Bssid " MAC_ADDRESS_STR |
| 3760 | " chan= %d, rssi = -%d, countryCode %c%c"), |
| 3761 | MAC_ADDR_ARRAY( pBssDescription->Result.BssDescriptor.bssId), |
| 3762 | pBssDescription->Result.BssDescriptor.channelId, |
| 3763 | pBssDescription->Result.BssDescriptor.rssi * (-1), |
| 3764 | pIesLocal->Country.country[0],pIesLocal->Country.country[1] ); |
| 3765 | } |
Agarwal Ashish | d9d7260 | 2013-09-13 00:06:17 +0530 | [diff] [blame] | 3766 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3767 | } |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 3768 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3769 | // append to main list |
| 3770 | csrScanAddResult(pMac, pBssDescription, pIesLocal); |
Agarwal Ashish | d9d7260 | 2013-09-13 00:06:17 +0530 | [diff] [blame] | 3771 | if ( (pBssDescription->Result.pvIes == NULL) && pIesLocal ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3772 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3773 | vos_mem_free(pIesLocal); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3774 | } |
| 3775 | } |
| 3776 | |
Kapil Gupta | 2f2fae4 | 2016-09-15 15:29:47 +0530 | [diff] [blame] | 3777 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 3778 | if (sme_IsFeatureSupportedByFW(PER_BASED_ROAMING) && |
| 3779 | (csrGetInfraSessionId(pMac) != -1) && |
| 3780 | (pMac->scan.occupiedChannels.numChannels != occupied_chan_count)) |
| 3781 | { |
| 3782 | /* Update FW with new list */ |
| 3783 | smsLog(pMac, LOGW, |
| 3784 | FL("Updating occupied channel list, new chanNum %d"), |
| 3785 | pMac->scan.occupiedChannels.numChannels); |
| 3786 | csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG, |
| 3787 | REASON_CHANNEL_LIST_CHANGED); |
| 3788 | } |
| 3789 | #endif |
Sushant Kaushik | 6274de6 | 2015-05-01 16:31:23 +0530 | [diff] [blame] | 3790 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_LOCK ); |
Tushnim Bhattacharyya | ae31777 | 2013-10-23 18:55:38 -0700 | [diff] [blame] | 3791 | //we don't need to update CC while connected to an AP which is advertising CC already |
| 3792 | if (csrIs11dSupported(pMac)) |
| 3793 | { |
| 3794 | tANI_U32 i; |
| 3795 | tCsrRoamSession *pSession; |
| 3796 | |
| 3797 | for (i = 0; i < CSR_ROAM_SESSION_MAX; i++ ) |
| 3798 | { |
| 3799 | if (CSR_IS_SESSION_VALID( pMac, i ) ) |
| 3800 | { |
| 3801 | pSession = CSR_GET_SESSION( pMac, i ); |
| 3802 | if (csrIsConnStateConnected(pMac, i)) |
| 3803 | { |
Agrawal Ashish | 0b6984f | 2014-04-05 18:35:45 +0530 | [diff] [blame] | 3804 | smsLog(pMac, LOGW, FL("No need for updating CC in" |
| 3805 | "connected state")); |
| 3806 | goto end; |
Tushnim Bhattacharyya | ae31777 | 2013-10-23 18:55:38 -0700 | [diff] [blame] | 3807 | } |
| 3808 | } |
| 3809 | } |
Agrawal Ashish | bd3a593 | 2016-04-12 16:22:39 +0530 | [diff] [blame] | 3810 | if (csrElectedCountryInfo(pMac)) |
| 3811 | csrLearnCountryInformation(pMac, NULL, NULL, |
| 3812 | eANI_BOOLEAN_TRUE); |
Agarwal Ashish | d9d7260 | 2013-09-13 00:06:17 +0530 | [diff] [blame] | 3813 | } |
| 3814 | |
Tushnim Bhattacharyya | ae31777 | 2013-10-23 18:55:38 -0700 | [diff] [blame] | 3815 | end: |
| 3816 | //If we can find the current 11d info in any of the scan results, or |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3817 | // a good enough AP with the 11d info from the scan results then no need to |
| 3818 | // get into ambiguous state |
| 3819 | if(pMac->scan.fAmbiguous11dInfoFound) |
| 3820 | { |
Agrawal Ashish | 0b6984f | 2014-04-05 18:35:45 +0530 | [diff] [blame] | 3821 | if((pMac->scan.fCurrent11dInfoMatch)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3822 | { |
| 3823 | pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE; |
| 3824 | } |
| 3825 | } |
| 3826 | |
| 3827 | #ifdef FEATURE_WLAN_WAPI |
| 3828 | if(fNewWapiBSSForCurConnection) |
| 3829 | { |
| 3830 | //remember it first |
| 3831 | csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_SCAN_FOUND_NEW_BSS, eCSR_ROAM_RESULT_NEW_WAPI_BSS); |
| 3832 | } |
| 3833 | #endif /* FEATURE_WLAN_WAPI */ |
| 3834 | |
| 3835 | return; |
| 3836 | } |
| 3837 | |
Abhishek Singh | 5deecd1 | 2017-06-12 11:08:40 +0530 | [diff] [blame] | 3838 | /** |
| 3839 | * csrPurgeScanResults() - This function removes scan entry based |
| 3840 | * on RSSI or AGE |
| 3841 | * @pMac: pointer to Global MAC structure |
| 3842 | * |
| 3843 | * This function removes scan entry based on RSSI or AGE. |
| 3844 | * If an scan entry with RSSI less than CSR_PURGE_RSSI_THRESHOLD, |
| 3845 | * the scan entry is removed else oldest entry is removed. |
| 3846 | * |
| 3847 | * Return: None |
| 3848 | */ |
| 3849 | void csrPurgeScanResults(tpAniSirGlobal pMac) |
Deepthi Gowri | 50e2fa5 | 2016-03-17 15:30:53 +0530 | [diff] [blame] | 3850 | { |
| 3851 | tListElem *pEntry, *tmpEntry; |
Abhishek Singh | 5deecd1 | 2017-06-12 11:08:40 +0530 | [diff] [blame] | 3852 | tCsrScanResult *pResult, *oldest_bss = NULL, *weakest_bss = NULL; |
Deepthi Gowri | 4480a3f | 2016-05-18 19:30:17 +0530 | [diff] [blame] | 3853 | v_TIME_t oldest_entry = 0; |
| 3854 | v_TIME_t curTime = vos_timer_get_system_time(); |
Abhishek Singh | 5deecd1 | 2017-06-12 11:08:40 +0530 | [diff] [blame] | 3855 | tANI_S8 weakest_rssi = 0; |
Deepthi Gowri | 50e2fa5 | 2016-03-17 15:30:53 +0530 | [diff] [blame] | 3856 | |
| 3857 | csrLLLock(&pMac->scan.scanResultList); |
| 3858 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK ); |
Abhishek Singh | 5deecd1 | 2017-06-12 11:08:40 +0530 | [diff] [blame] | 3859 | while(pEntry) |
Deepthi Gowri | 50e2fa5 | 2016-03-17 15:30:53 +0530 | [diff] [blame] | 3860 | { |
| 3861 | tmpEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, |
| 3862 | LL_ACCESS_NOLOCK); |
| 3863 | pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 3864 | if((curTime - |
| 3865 | pResult->Result.BssDescriptor.nReceivedTime) > oldest_entry) |
| 3866 | { |
| 3867 | oldest_entry = curTime - |
| 3868 | pResult->Result.BssDescriptor.nReceivedTime; |
| 3869 | oldest_bss = pResult; |
| 3870 | } |
Abhishek Singh | 5deecd1 | 2017-06-12 11:08:40 +0530 | [diff] [blame] | 3871 | if (pResult->Result.BssDescriptor.rssi < weakest_rssi) |
| 3872 | { |
| 3873 | weakest_rssi = pResult->Result.BssDescriptor.rssi; |
| 3874 | weakest_bss = pResult; |
| 3875 | } |
Deepthi Gowri | 50e2fa5 | 2016-03-17 15:30:53 +0530 | [diff] [blame] | 3876 | pEntry = tmpEntry; |
| 3877 | } |
| 3878 | if (oldest_bss) |
| 3879 | { |
Abhishek Singh | 5deecd1 | 2017-06-12 11:08:40 +0530 | [diff] [blame] | 3880 | tCsrScanResult *bss_to_remove; |
| 3881 | |
| 3882 | if (weakest_rssi < CSR_PURGE_RSSI_THRESHOLD) |
| 3883 | bss_to_remove = weakest_bss; |
| 3884 | else |
| 3885 | bss_to_remove = oldest_bss; |
| 3886 | |
Deepthi Gowri | 50e2fa5 | 2016-03-17 15:30:53 +0530 | [diff] [blame] | 3887 | //Free the old BSS Entries |
Abhishek Singh | 5deecd1 | 2017-06-12 11:08:40 +0530 | [diff] [blame] | 3888 | if(csrLLRemoveEntry(&pMac->scan.scanResultList, |
| 3889 | &bss_to_remove->Link, LL_ACCESS_NOLOCK)) |
Deepthi Gowri | 50e2fa5 | 2016-03-17 15:30:53 +0530 | [diff] [blame] | 3890 | { |
Abhishek Singh | 5deecd1 | 2017-06-12 11:08:40 +0530 | [diff] [blame] | 3891 | smsLog(pMac, LOG1, |
| 3892 | FL("BSSID: "MAC_ADDRESS_STR" Removed, time delta (%lu) RSSI %d"), |
| 3893 | MAC_ADDR_ARRAY( |
| 3894 | bss_to_remove->Result.BssDescriptor.bssId), |
| 3895 | (curTime - |
| 3896 | bss_to_remove->Result.BssDescriptor.nReceivedTime), |
| 3897 | bss_to_remove->Result.BssDescriptor.rssi); |
| 3898 | csrFreeScanResultEntry(pMac, bss_to_remove); |
Deepthi Gowri | 50e2fa5 | 2016-03-17 15:30:53 +0530 | [diff] [blame] | 3899 | } |
| 3900 | } |
| 3901 | csrLLUnlock(&pMac->scan.scanResultList); |
| 3902 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3903 | |
| 3904 | static tCsrScanResult *csrScanSaveBssDescription( tpAniSirGlobal pMac, tSirBssDescription *pBSSDescription, |
| 3905 | tDot11fBeaconIEs *pIes) |
| 3906 | { |
| 3907 | tCsrScanResult *pCsrBssDescription = NULL; |
| 3908 | tANI_U32 cbBSSDesc; |
| 3909 | tANI_U32 cbAllocated; |
Sushant Kaushik | 6274de6 | 2015-05-01 16:31:23 +0530 | [diff] [blame] | 3910 | tListElem *pEntry; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3911 | |
| 3912 | // figure out how big the BSS description is (the BSSDesc->length does NOT |
| 3913 | // include the size of the length field itself). |
| 3914 | cbBSSDesc = pBSSDescription->length + sizeof( pBSSDescription->length ); |
| 3915 | |
| 3916 | cbAllocated = sizeof( tCsrScanResult ) + cbBSSDesc; |
| 3917 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3918 | pCsrBssDescription = vos_mem_malloc(cbAllocated); |
| 3919 | if ( NULL != pCsrBssDescription ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3920 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3921 | vos_mem_set(pCsrBssDescription, cbAllocated, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3922 | pCsrBssDescription->AgingCount = (tANI_S32)pMac->roam.configParam.agingCount; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3923 | vos_mem_copy(&pCsrBssDescription->Result.BssDescriptor, pBSSDescription, cbBSSDesc); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3924 | #if defined(VOSS_ENSBALED) |
| 3925 | VOS_ASSERT( pCsrBssDescription->Result.pvIes == NULL ); |
| 3926 | #endif |
| 3927 | csrScanAddResult(pMac, pCsrBssDescription, pIes); |
Sushant Kaushik | 6274de6 | 2015-05-01 16:31:23 +0530 | [diff] [blame] | 3928 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_LOCK ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3929 | } |
| 3930 | |
| 3931 | return( pCsrBssDescription ); |
| 3932 | } |
| 3933 | |
| 3934 | // Append a Bss Description... |
| 3935 | tCsrScanResult *csrScanAppendBssDescription( tpAniSirGlobal pMac, |
| 3936 | tSirBssDescription *pSirBssDescription, |
Tushnim Bhattacharyya | 5128d75 | 2013-06-26 23:23:18 -0700 | [diff] [blame] | 3937 | tDot11fBeaconIEs *pIes, tANI_BOOLEAN fForced ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3938 | { |
| 3939 | tCsrScanResult *pCsrBssDescription = NULL; |
| 3940 | tAniSSID tmpSsid; |
| 3941 | v_TIME_t timer = 0; |
| 3942 | int result; |
| 3943 | |
| 3944 | tmpSsid.length = 0; |
Tushnim Bhattacharyya | 5128d75 | 2013-06-26 23:23:18 -0700 | [diff] [blame] | 3945 | result = csrRemoveDupBssDescription( pMac, pSirBssDescription, pIes, &tmpSsid, &timer, fForced ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3946 | pCsrBssDescription = csrScanSaveBssDescription( pMac, pSirBssDescription, pIes ); |
| 3947 | if (result && (pCsrBssDescription != NULL)) |
| 3948 | { |
| 3949 | //Check if the new one has SSID it it, if not, use the older SSID if it exists. |
| 3950 | if( (0 == pCsrBssDescription->Result.ssId.length) && tmpSsid.length ) |
| 3951 | { |
| 3952 | //New BSS has a hidden SSID and old one has the SSID. Keep the SSID only |
| 3953 | //if diff of saved SSID time and current time is less than 1 min to avoid |
| 3954 | //side effect of saving SSID with old one is that if AP changes its SSID while remain |
| 3955 | //hidden, we may never see it and also to address the requirement of |
| 3956 | //When we remove hidden ssid from the profile i.e., forget the SSID via |
| 3957 | // GUI that SSID shouldn't see in the profile |
| 3958 | if((vos_timer_get_system_time()-timer) <= HIDDEN_TIMER) |
| 3959 | { |
| 3960 | pCsrBssDescription->Result.ssId = tmpSsid; |
| 3961 | pCsrBssDescription->Result.timer = timer; |
| 3962 | } |
| 3963 | } |
| 3964 | } |
| 3965 | |
| 3966 | |
| 3967 | return( pCsrBssDescription ); |
| 3968 | } |
| 3969 | |
| 3970 | |
| 3971 | |
| 3972 | void csrPurgeChannelPower( tpAniSirGlobal pMac, tDblLinkList *pChannelList ) |
| 3973 | { |
| 3974 | tCsrChannelPowerInfo *pChannelSet; |
| 3975 | tListElem *pEntry; |
| 3976 | |
| 3977 | csrLLLock(pChannelList); |
| 3978 | // Remove the channel sets from the learned list and put them in the free list |
| 3979 | while( ( pEntry = csrLLRemoveHead( pChannelList, LL_ACCESS_NOLOCK ) ) != NULL) |
| 3980 | { |
| 3981 | pChannelSet = GET_BASE_ADDR( pEntry, tCsrChannelPowerInfo, link ); |
| 3982 | if( pChannelSet ) |
| 3983 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3984 | vos_mem_free(pChannelSet); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3985 | } |
| 3986 | } |
| 3987 | csrLLUnlock(pChannelList); |
| 3988 | return; |
| 3989 | } |
| 3990 | |
| 3991 | |
| 3992 | /* |
| 3993 | * Save the channelList into the ultimate storage as the final stage of channel |
| 3994 | * Input: pCountryInfo -- the country code (e.g. "USI"), channel list, and power limit are all stored inside this data structure |
| 3995 | */ |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3996 | eHalStatus csrSaveToChannelPower2G_5G( tpAniSirGlobal pMac, tANI_U32 tableSize, tSirMacChanInfo *channelTable ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3997 | { |
| 3998 | tANI_U32 i = tableSize / sizeof( tSirMacChanInfo ); |
| 3999 | tSirMacChanInfo *pChannelInfo; |
| 4000 | tCsrChannelPowerInfo *pChannelSet; |
| 4001 | tANI_BOOLEAN f2GHzInfoFound = FALSE; |
| 4002 | tANI_BOOLEAN f2GListPurged = FALSE, f5GListPurged = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4003 | |
| 4004 | pChannelInfo = channelTable; |
| 4005 | // atleast 3 bytes have to be remaining -- from "countryString" |
| 4006 | while ( i-- ) |
| 4007 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4008 | pChannelSet = vos_mem_malloc(sizeof(tCsrChannelPowerInfo)); |
| 4009 | if ( NULL != pChannelSet ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4010 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4011 | vos_mem_set(pChannelSet, sizeof(tCsrChannelPowerInfo), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4012 | pChannelSet->firstChannel = pChannelInfo->firstChanNum; |
| 4013 | pChannelSet->numChannels = pChannelInfo->numChannels; |
| 4014 | |
| 4015 | // Now set the inter-channel offset based on the frequency band the channel set lies in |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4016 | if( (CSR_IS_CHANNEL_24GHZ(pChannelSet->firstChannel)) && |
Madan Mohan Koyyalamudi | 5904d7c | 2012-09-24 13:49:03 -0700 | [diff] [blame] | 4017 | ((pChannelSet->firstChannel + (pChannelSet->numChannels - 1)) <= CSR_MAX_24GHz_CHANNEL_NUMBER) ) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4018 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4019 | { |
| 4020 | pChannelSet->interChannelOffset = 1; |
| 4021 | f2GHzInfoFound = TRUE; |
| 4022 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4023 | else if ( (CSR_IS_CHANNEL_5GHZ(pChannelSet->firstChannel)) && |
Madan Mohan Koyyalamudi | 5904d7c | 2012-09-24 13:49:03 -0700 | [diff] [blame] | 4024 | ((pChannelSet->firstChannel + ((pChannelSet->numChannels - 1) * 4)) <= CSR_MAX_5GHz_CHANNEL_NUMBER) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4025 | { |
| 4026 | pChannelSet->interChannelOffset = 4; |
| 4027 | f2GHzInfoFound = FALSE; |
| 4028 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4029 | else |
| 4030 | { |
Madan Mohan Koyyalamudi | 5904d7c | 2012-09-24 13:49:03 -0700 | [diff] [blame] | 4031 | smsLog( pMac, LOGW, FL("Invalid Channel %d Present in Country IE"), |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4032 | pChannelSet->firstChannel); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4033 | vos_mem_free(pChannelSet); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4034 | return eHAL_STATUS_FAILURE; |
| 4035 | } |
| 4036 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4037 | pChannelSet->txPower = CSR_ROAM_MIN( pChannelInfo->maxTxPower, pMac->roam.configParam.nTxPowerCap ); |
| 4038 | |
| 4039 | if( f2GHzInfoFound ) |
| 4040 | { |
| 4041 | if( !f2GListPurged ) |
| 4042 | { |
| 4043 | // purge previous results if found new |
| 4044 | csrPurgeChannelPower( pMac, &pMac->scan.channelPowerInfoList24 ); |
| 4045 | f2GListPurged = TRUE; |
| 4046 | } |
| 4047 | |
| 4048 | if(CSR_IS_OPERATING_BG_BAND(pMac)) |
| 4049 | { |
| 4050 | // add to the list of 2.4 GHz channel sets |
| 4051 | csrLLInsertTail( &pMac->scan.channelPowerInfoList24, &pChannelSet->link, LL_ACCESS_LOCK ); |
| 4052 | } |
| 4053 | else { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 4054 | smsLog( pMac, LOGW, FL("Adding 11B/G channels in 11A mode -- First Channel is %d"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4055 | pChannelSet->firstChannel); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4056 | vos_mem_free(pChannelSet); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4057 | } |
| 4058 | } |
| 4059 | else |
| 4060 | { |
| 4061 | // 5GHz info found |
| 4062 | if( !f5GListPurged ) |
| 4063 | { |
| 4064 | // purge previous results if found new |
| 4065 | csrPurgeChannelPower( pMac, &pMac->scan.channelPowerInfoList5G ); |
| 4066 | f5GListPurged = TRUE; |
| 4067 | } |
| 4068 | |
| 4069 | if(CSR_IS_OPERATING_A_BAND(pMac)) |
| 4070 | { |
| 4071 | // add to the list of 5GHz channel sets |
| 4072 | csrLLInsertTail( &pMac->scan.channelPowerInfoList5G, &pChannelSet->link, LL_ACCESS_LOCK ); |
| 4073 | } |
| 4074 | else { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 4075 | smsLog( pMac, LOGW, FL("Adding 11A channels in B/G mode -- First Channel is %d"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4076 | pChannelSet->firstChannel); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4077 | vos_mem_free(pChannelSet); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4078 | } |
| 4079 | } |
| 4080 | } |
| 4081 | |
| 4082 | pChannelInfo++; // move to next entry |
| 4083 | } |
| 4084 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4085 | return eHAL_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4086 | } |
| 4087 | |
Gopichand Nakkala | c178ac8 | 2013-05-30 19:53:39 +0530 | [diff] [blame] | 4088 | static void csrClearDfsChannelList( tpAniSirGlobal pMac ) |
| 4089 | { |
| 4090 | tSirMbMsg *pMsg; |
| 4091 | tANI_U16 msgLen; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4092 | |
Gopichand Nakkala | c178ac8 | 2013-05-30 19:53:39 +0530 | [diff] [blame] | 4093 | msgLen = (tANI_U16)(sizeof( tSirMbMsg )); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4094 | pMsg = vos_mem_malloc(msgLen); |
| 4095 | if ( NULL != pMsg ) |
Gopichand Nakkala | c178ac8 | 2013-05-30 19:53:39 +0530 | [diff] [blame] | 4096 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4097 | vos_mem_set((void *)pMsg, msgLen, 0); |
Gopichand Nakkala | c178ac8 | 2013-05-30 19:53:39 +0530 | [diff] [blame] | 4098 | pMsg->type = pal_cpu_to_be16((tANI_U16)eWNI_SME_CLEAR_DFS_CHANNEL_LIST); |
| 4099 | pMsg->msgLen = pal_cpu_to_be16(msgLen); |
| 4100 | palSendMBMessage(pMac->hHdd, pMsg); |
| 4101 | } |
| 4102 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4103 | |
| 4104 | void csrApplyPower2Current( tpAniSirGlobal pMac ) |
| 4105 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 4106 | smsLog( pMac, LOG3, FL(" Updating Cfg with power settings")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4107 | csrSaveTxPowerToCfg( pMac, &pMac->scan.channelPowerInfoList24, WNI_CFG_MAX_TX_POWER_2_4 ); |
| 4108 | csrSaveTxPowerToCfg( pMac, &pMac->scan.channelPowerInfoList5G, WNI_CFG_MAX_TX_POWER_5 ); |
| 4109 | } |
| 4110 | |
| 4111 | |
Gopichand Nakkala | b9185f2 | 2012-12-21 08:03:42 -0800 | [diff] [blame] | 4112 | void csrApplyChannelPowerCountryInfo( tpAniSirGlobal pMac, tCsrChannel *pChannelList, tANI_U8 *countryCode, tANI_BOOLEAN updateRiva) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4113 | { |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 4114 | int i, j, count, countryIndex = -1; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4115 | tANI_U8 numChannels = 0; |
| 4116 | tANI_U8 tempNumChannels = 0; |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 4117 | tANI_U8 channelIgnore = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4118 | tCsrChannel ChannelList; |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 4119 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4120 | if( pChannelList->numChannels ) |
| 4121 | { |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 4122 | for(count=0; count < MAX_COUNTRY_IGNORE; count++) |
| 4123 | { |
| 4124 | if(vos_mem_compare(countryCode, countryIgnoreList[count].countryCode, |
| 4125 | VOS_COUNTRY_CODE_LEN)) |
| 4126 | { |
| 4127 | countryIndex = count; |
| 4128 | break; |
| 4129 | } |
| 4130 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4131 | tempNumChannels = CSR_MIN(pChannelList->numChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN); |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 4132 | |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 4133 | for(i=0; i < tempNumChannels; i++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4134 | { |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 4135 | channelIgnore = FALSE; |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 4136 | if( countryIndex != -1 ) |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 4137 | { |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 4138 | for(j=0; j < countryIgnoreList[countryIndex].channelCount; j++) |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 4139 | { |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 4140 | if( pChannelList->channelList[i] == |
| 4141 | countryIgnoreList[countryIndex].channelList[j] ) |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 4142 | { |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 4143 | channelIgnore = TRUE; |
| 4144 | break; |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 4145 | } |
| 4146 | } |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 4147 | } |
| 4148 | if( FALSE == channelIgnore ) |
| 4149 | { |
| 4150 | ChannelList.channelList[numChannels] = pChannelList->channelList[i]; |
| 4151 | numChannels++; |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 4152 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4153 | } |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 4154 | ChannelList.numChannels = numChannels; |
Mahesh A Saptasagar | 1ed5958 | 2014-06-04 18:45:07 +0530 | [diff] [blame] | 4155 | csrApplyPower2Current( pMac ); // Store the channel+power info in the global place: Cfg |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4156 | csrSetCfgValidChannelList(pMac, ChannelList.channelList, ChannelList.numChannels); |
| 4157 | // extend scan capability |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 4158 | // build a scan list based on the channel list : channel# + active/passive scan |
| 4159 | csrSetCfgScanControlList(pMac, countryCode, &ChannelList); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4160 | #ifdef FEATURE_WLAN_SCAN_PNO |
Gopichand Nakkala | b9185f2 | 2012-12-21 08:03:42 -0800 | [diff] [blame] | 4161 | if (updateRiva) |
| 4162 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 4163 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, FL(" Sending 11d PNO info to Riva")); |
Gopichand Nakkala | b9185f2 | 2012-12-21 08:03:42 -0800 | [diff] [blame] | 4164 | // Send HAL UpdateScanParams message |
| 4165 | pmcUpdateScanParams(pMac, &(pMac->roam.configParam), &ChannelList, TRUE); |
| 4166 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4167 | #endif // FEATURE_WLAN_SCAN_PNO |
| 4168 | } |
| 4169 | else |
| 4170 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 4171 | smsLog( pMac, LOGE, FL(" 11D channel list is empty")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4172 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4173 | csrSetCfgCountryCode(pMac, countryCode); |
| 4174 | } |
| 4175 | |
Sourav Mohapatra | 3dd5dba | 2018-03-26 15:12:47 +0530 | [diff] [blame] | 4176 | void csrUpdateFCCChannelList(tpAniSirGlobal pMac) |
| 4177 | { |
| 4178 | tCsrChannel ChannelList; |
| 4179 | tANI_U8 chnlIndx = 0; |
| 4180 | int i; |
| 4181 | |
| 4182 | for ( i = 0; i < pMac->scan.base20MHzChannels.numChannels; i++ ) |
| 4183 | { |
| 4184 | if (pMac->scan.fcc_constraint && |
| 4185 | ((pMac->scan.base20MHzChannels.channelList[i] == 12) || |
| 4186 | (pMac->scan.base20MHzChannels.channelList[i] == 13))) |
| 4187 | { |
| 4188 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, |
| 4189 | FL("removing channel %d"), |
| 4190 | pMac->scan.base20MHzChannels.channelList[i]); |
| 4191 | continue; |
| 4192 | } |
| 4193 | ChannelList.channelList[chnlIndx] = |
| 4194 | pMac->scan.base20MHzChannels.channelList[i]; |
| 4195 | chnlIndx++; |
| 4196 | } |
| 4197 | csrSetCfgValidChannelList(pMac, ChannelList.channelList, chnlIndx); |
| 4198 | csrScanFilterResults(pMac); |
| 4199 | } |
| 4200 | |
Gopichand Nakkala | b9185f2 | 2012-12-21 08:03:42 -0800 | [diff] [blame] | 4201 | void csrResetCountryInformation( tpAniSirGlobal pMac, tANI_BOOLEAN fForce, tANI_BOOLEAN updateRiva ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4202 | { |
| 4203 | if( fForce || (csrIs11dSupported( pMac ) && (!pMac->scan.f11dInfoReset))) |
| 4204 | { |
| 4205 | |
| 4206 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 4207 | { |
| 4208 | vos_log_802_11d_pkt_type *p11dLog; |
| 4209 | int Index; |
| 4210 | |
| 4211 | WLAN_VOS_DIAG_LOG_ALLOC(p11dLog, vos_log_802_11d_pkt_type, LOG_WLAN_80211D_C); |
| 4212 | if(p11dLog) |
| 4213 | { |
| 4214 | p11dLog->eventId = WLAN_80211D_EVENT_RESET; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4215 | vos_mem_copy(p11dLog->countryCode, pMac->scan.countryCodeCurrent, 3); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4216 | p11dLog->numChannel = pMac->scan.base20MHzChannels.numChannels; |
| 4217 | if(p11dLog->numChannel <= VOS_LOG_MAX_NUM_CHANNEL) |
| 4218 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4219 | vos_mem_copy(p11dLog->Channels, |
| 4220 | pMac->scan.base20MHzChannels.channelList, |
| 4221 | p11dLog->numChannel); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4222 | for (Index=0; Index < pMac->scan.base20MHzChannels.numChannels; Index++) |
| 4223 | { |
| 4224 | p11dLog->TxPwr[Index] = CSR_ROAM_MIN( pMac->scan.defaultPowerTable[Index].pwr, pMac->roam.configParam.nTxPowerCap ); |
| 4225 | } |
| 4226 | } |
| 4227 | if(!pMac->roam.configParam.Is11dSupportEnabled) |
| 4228 | { |
| 4229 | p11dLog->supportMultipleDomain = WLAN_80211D_DISABLED; |
| 4230 | } |
| 4231 | else if(pMac->roam.configParam.fEnforceDefaultDomain) |
| 4232 | { |
| 4233 | p11dLog->supportMultipleDomain = WLAN_80211D_NOT_SUPPORT_MULTI_DOMAIN; |
| 4234 | } |
| 4235 | else |
| 4236 | { |
| 4237 | p11dLog->supportMultipleDomain = WLAN_80211D_SUPPORT_MULTI_DOMAIN; |
| 4238 | } |
| 4239 | WLAN_VOS_DIAG_LOG_REPORT(p11dLog); |
| 4240 | } |
| 4241 | } |
| 4242 | #endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 4243 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4244 | csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels); |
| 4245 | csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels); |
| 4246 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4247 | csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE); |
| 4248 | csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE); |
| 4249 | // ... and apply the channel list, power settings, and the country code. |
Gopichand Nakkala | b9185f2 | 2012-12-21 08:03:42 -0800 | [diff] [blame] | 4250 | csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, updateRiva ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4251 | // clear the 11d channel list |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4252 | vos_mem_set(&pMac->scan.channels11d, sizeof(pMac->scan.channels11d), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4253 | pMac->scan.f11dInfoReset = eANI_BOOLEAN_TRUE; |
| 4254 | pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE; |
| 4255 | } |
| 4256 | |
| 4257 | return; |
| 4258 | } |
| 4259 | |
| 4260 | |
| 4261 | eHalStatus csrResetCountryCodeInformation(tpAniSirGlobal pMac, tANI_BOOLEAN *pfRestartNeeded) |
| 4262 | { |
| 4263 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 4264 | tANI_BOOLEAN fRestart = eANI_BOOLEAN_FALSE; |
| 4265 | |
| 4266 | //Use the Country code and domain from EEPROM |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4267 | vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault, |
| 4268 | WNI_CFG_COUNTRY_CODE_LEN); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4269 | csrSetRegulatoryDomain(pMac, pMac->scan.domainIdCurrent, &fRestart); |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 4270 | if( ((eANI_BOOLEAN_FALSE == fRestart) || (pfRestartNeeded == NULL) ) |
| 4271 | && !csrIsInfraConnected(pMac)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4272 | { |
| 4273 | //Only reset the country info if we don't need to restart |
Gopichand Nakkala | b9185f2 | 2012-12-21 08:03:42 -0800 | [diff] [blame] | 4274 | csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4275 | } |
| 4276 | if(pfRestartNeeded) |
| 4277 | { |
| 4278 | *pfRestartNeeded = fRestart; |
| 4279 | } |
| 4280 | |
| 4281 | return (status); |
| 4282 | } |
| 4283 | |
Agrawal Ashish | 0b6984f | 2014-04-05 18:35:45 +0530 | [diff] [blame] | 4284 | void csrClearVotesForCountryInfo(tpAniSirGlobal pMac) |
| 4285 | { |
| 4286 | pMac->scan.countryCodeCount = 0; |
| 4287 | vos_mem_set(pMac->scan.votes11d, |
| 4288 | sizeof(tCsrVotes11d) * CSR_MAX_NUM_COUNTRY_CODE, 0); |
| 4289 | } |
| 4290 | |
| 4291 | void csrAddVoteForCountryInfo(tpAniSirGlobal pMac, tANI_U8 *pCountryCode) |
| 4292 | { |
| 4293 | tANI_BOOLEAN match = FALSE; |
| 4294 | tANI_U8 i; |
| 4295 | |
| 4296 | /* convert to UPPER here so we are assured |
| 4297 | * the strings are always in upper case. |
| 4298 | */ |
| 4299 | for( i = 0; i < 3; i++ ) |
| 4300 | { |
| 4301 | pCountryCode[ i ] = (tANI_U8)csrToUpper( pCountryCode[ i ] ); |
| 4302 | } |
| 4303 | |
| 4304 | /* Some of the 'old' Cisco 350 series AP's advertise NA as the |
| 4305 | * country code (for North America ??). NA is not a valid country code |
| 4306 | * or domain so let's allow this by changing it to the proper |
| 4307 | * country code (which is US). We've also seen some NETGEAR AP's |
| 4308 | * that have "XX " as the country code with valid 2.4 GHz US channel |
| 4309 | * information. If we cannot find the country code advertised in the |
| 4310 | * 11d information element, let's default to US. |
| 4311 | */ |
| 4312 | |
| 4313 | if ( !HAL_STATUS_SUCCESS(csrGetRegulatoryDomainForCountry( pMac, |
| 4314 | pCountryCode, NULL,COUNTRY_QUERY ) ) ) |
| 4315 | { |
| 4316 | pCountryCode[ 0 ] = '0'; |
| 4317 | pCountryCode[ 1 ] = '0'; |
| 4318 | } |
| 4319 | |
| 4320 | /* We've seen some of the AP's improperly put a 0 for the |
| 4321 | * third character of the country code. spec says valid charcters are |
| 4322 | * 'O' (for outdoor), 'I' for Indoor, or ' ' (space; for either). |
| 4323 | * if we see a 0 in this third character, let's change it to a ' '. |
| 4324 | */ |
| 4325 | if ( 0 == pCountryCode[ 2 ] ) |
| 4326 | { |
| 4327 | pCountryCode[ 2 ] = ' '; |
| 4328 | } |
| 4329 | |
| 4330 | for (i = 0; i < pMac->scan.countryCodeCount; i++) |
| 4331 | { |
| 4332 | match = (vos_mem_compare(pMac->scan.votes11d[i].countryCode, |
| 4333 | pCountryCode, 2)); |
| 4334 | if(match) |
| 4335 | { |
| 4336 | break; |
| 4337 | } |
| 4338 | } |
| 4339 | |
| 4340 | if (match) |
| 4341 | { |
| 4342 | pMac->scan.votes11d[i].votes++; |
| 4343 | } |
| 4344 | else |
| 4345 | { |
| 4346 | vos_mem_copy( pMac->scan.votes11d[pMac->scan.countryCodeCount].countryCode, |
| 4347 | pCountryCode, 3 ); |
| 4348 | pMac->scan.votes11d[pMac->scan.countryCodeCount].votes = 1; |
| 4349 | pMac->scan.countryCodeCount++; |
| 4350 | } |
| 4351 | |
| 4352 | return; |
| 4353 | } |
| 4354 | |
| 4355 | tANI_BOOLEAN csrElectedCountryInfo(tpAniSirGlobal pMac) |
| 4356 | { |
| 4357 | tANI_BOOLEAN fRet = FALSE; |
| 4358 | tANI_U8 maxVotes = 0; |
| 4359 | tANI_U8 i, j=0; |
| 4360 | |
| 4361 | if (!pMac->scan.countryCodeCount) |
| 4362 | { |
Agrawal Ashish | bd3a593 | 2016-04-12 16:22:39 +0530 | [diff] [blame] | 4363 | VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN, |
| 4364 | "No AP with 11d Country code is present in scan list"); |
Agrawal Ashish | 0b6984f | 2014-04-05 18:35:45 +0530 | [diff] [blame] | 4365 | return fRet; |
| 4366 | } |
| 4367 | maxVotes = pMac->scan.votes11d[0].votes; |
| 4368 | fRet = TRUE; |
| 4369 | |
| 4370 | for(i = 1; i < pMac->scan.countryCodeCount; i++) |
| 4371 | { |
| 4372 | /* If we have a tie for max votes for 2 different country codes, |
| 4373 | * pick random.we can put some more intelligence - TBD |
| 4374 | */ |
| 4375 | if (maxVotes < pMac->scan.votes11d[i].votes) |
| 4376 | { |
| 4377 | VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, |
| 4378 | " Votes for Country %c%c : %d\n", |
| 4379 | pMac->scan.votes11d[i].countryCode[0], |
| 4380 | pMac->scan.votes11d[i].countryCode[1], |
| 4381 | pMac->scan.votes11d[i].votes); |
| 4382 | |
| 4383 | maxVotes = pMac->scan.votes11d[i].votes; |
| 4384 | j = i; |
| 4385 | fRet = TRUE; |
| 4386 | } |
| 4387 | |
| 4388 | } |
| 4389 | if (fRet) |
| 4390 | { |
Rajesh Babu Prathipati | 20cdffa | 2014-07-01 22:24:59 +0530 | [diff] [blame] | 4391 | vos_mem_copy(pMac->scan.countryCodeElected, |
Agrawal Ashish | 0b6984f | 2014-04-05 18:35:45 +0530 | [diff] [blame] | 4392 | pMac->scan.votes11d[j].countryCode, WNI_CFG_COUNTRY_CODE_LEN); |
Rajesh Babu Prathipati | 20cdffa | 2014-07-01 22:24:59 +0530 | [diff] [blame] | 4393 | vos_mem_copy(pMac->scan.countryCode11d, |
Agarwal Ashish | 852b2c3 | 2014-05-23 17:13:25 +0530 | [diff] [blame] | 4394 | pMac->scan.votes11d[j].countryCode, WNI_CFG_COUNTRY_CODE_LEN); |
Agrawal Ashish | 0b6984f | 2014-04-05 18:35:45 +0530 | [diff] [blame] | 4395 | VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, |
| 4396 | "Selected Country is %c%c With count %d\n", |
| 4397 | pMac->scan.votes11d[j].countryCode[0], |
| 4398 | pMac->scan.votes11d[j].countryCode[1], |
| 4399 | pMac->scan.votes11d[j].votes); |
| 4400 | } |
| 4401 | return fRet; |
| 4402 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4403 | |
| 4404 | eHalStatus csrSetCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry, tANI_BOOLEAN *pfRestartNeeded) |
| 4405 | { |
| 4406 | eHalStatus status = eHAL_STATUS_INVALID_PARAMETER; |
| 4407 | v_REGDOMAIN_t domainId; |
| 4408 | |
| 4409 | if(pCountry) |
| 4410 | { |
Kiet Lam | 6c58333 | 2013-10-14 05:37:09 +0530 | [diff] [blame] | 4411 | status = csrGetRegulatoryDomainForCountry(pMac, pCountry, &domainId, COUNTRY_USER); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4412 | if(HAL_STATUS_SUCCESS(status)) |
| 4413 | { |
| 4414 | status = csrSetRegulatoryDomain(pMac, domainId, pfRestartNeeded); |
| 4415 | if(HAL_STATUS_SUCCESS(status)) |
| 4416 | { |
| 4417 | //We don't need to check the pMac->roam.configParam.fEnforceDefaultDomain flag here, |
| 4418 | //csrSetRegulatoryDomain will fail if the country doesn't fit our domain criteria. |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4419 | vos_mem_copy(pMac->scan.countryCodeCurrent, pCountry, WNI_CFG_COUNTRY_CODE_LEN); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4420 | if((pfRestartNeeded == NULL) || !(*pfRestartNeeded)) |
| 4421 | { |
| 4422 | //Simply set it to cfg. If we need to restart, restart will apply it to the CFG |
| 4423 | csrSetCfgCountryCode(pMac, pCountry); |
| 4424 | } |
| 4425 | } |
| 4426 | } |
| 4427 | } |
| 4428 | |
| 4429 | return (status); |
| 4430 | } |
| 4431 | |
| 4432 | |
| 4433 | |
| 4434 | //caller allocated memory for pNumChn and pChnPowerInfo |
| 4435 | //As input, *pNumChn has the size of the array of pChnPowerInfo |
| 4436 | //Upon return, *pNumChn has the number of channels assigned. |
| 4437 | void csrGetChannelPowerInfo( tpAniSirGlobal pMac, tDblLinkList *pList, |
| 4438 | tANI_U32 *pNumChn, tChannelListWithPower *pChnPowerInfo) |
| 4439 | { |
| 4440 | tListElem *pEntry; |
| 4441 | tANI_U32 chnIdx = 0, idx; |
| 4442 | tCsrChannelPowerInfo *pChannelSet; |
| 4443 | |
| 4444 | //Get 2.4Ghz first |
| 4445 | pEntry = csrLLPeekHead( pList, LL_ACCESS_LOCK ); |
| 4446 | while( pEntry && (chnIdx < *pNumChn) ) |
| 4447 | { |
| 4448 | pChannelSet = GET_BASE_ADDR( pEntry, tCsrChannelPowerInfo, link ); |
| 4449 | if ( 1 != pChannelSet->interChannelOffset ) |
| 4450 | { |
| 4451 | for( idx = 0; (idx < pChannelSet->numChannels) && (chnIdx < *pNumChn); idx++ ) |
| 4452 | { |
| 4453 | pChnPowerInfo[chnIdx].chanId = (tANI_U8)(pChannelSet->firstChannel + ( idx * pChannelSet->interChannelOffset )); |
| 4454 | pChnPowerInfo[chnIdx++].pwr = pChannelSet->txPower; |
| 4455 | } |
| 4456 | } |
| 4457 | else |
| 4458 | { |
| 4459 | for( idx = 0; (idx < pChannelSet->numChannels) && (chnIdx < *pNumChn); idx++ ) |
| 4460 | { |
| 4461 | pChnPowerInfo[chnIdx].chanId = (tANI_U8)(pChannelSet->firstChannel + idx); |
| 4462 | pChnPowerInfo[chnIdx++].pwr = pChannelSet->txPower; |
| 4463 | } |
| 4464 | } |
| 4465 | |
| 4466 | pEntry = csrLLNext( pList, pEntry, LL_ACCESS_LOCK ); |
| 4467 | } |
| 4468 | *pNumChn = chnIdx; |
| 4469 | |
| 4470 | return ; |
| 4471 | } |
| 4472 | |
| 4473 | |
| 4474 | |
| 4475 | void csrApplyCountryInformation( tpAniSirGlobal pMac, tANI_BOOLEAN fForce ) |
| 4476 | { |
| 4477 | v_REGDOMAIN_t domainId; |
| 4478 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 4479 | |
| 4480 | do |
| 4481 | { |
| 4482 | if( !csrIs11dSupported( pMac ) || 0 == pMac->scan.channelOf11dInfo) break; |
| 4483 | if( pMac->scan.fAmbiguous11dInfoFound ) |
| 4484 | { |
| 4485 | // ambiguous info found |
| 4486 | //Restore te default domain as well |
Kiet Lam | 6c58333 | 2013-10-14 05:37:09 +0530 | [diff] [blame] | 4487 | if(HAL_STATUS_SUCCESS(csrGetRegulatoryDomainForCountry( |
| 4488 | pMac, pMac->scan.countryCodeCurrent, |
| 4489 | &domainId, COUNTRY_QUERY))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4490 | { |
| 4491 | pMac->scan.domainIdCurrent = domainId; |
| 4492 | } |
| 4493 | else |
| 4494 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 4495 | smsLog(pMac, LOGE, FL(" failed to get domain from currentCountryCode %02X%02X"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4496 | pMac->scan.countryCodeCurrent[0], pMac->scan.countryCodeCurrent[1]); |
| 4497 | } |
Gopichand Nakkala | b9185f2 | 2012-12-21 08:03:42 -0800 | [diff] [blame] | 4498 | csrResetCountryInformation( pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_TRUE ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4499 | break; |
| 4500 | } |
| 4501 | if ( pMac->scan.f11dInfoApplied && !fForce ) break; |
Kiet Lam | 6c58333 | 2013-10-14 05:37:09 +0530 | [diff] [blame] | 4502 | if(HAL_STATUS_SUCCESS(csrGetRegulatoryDomainForCountry( |
| 4503 | pMac, pMac->scan.countryCode11d, |
| 4504 | &domainId, COUNTRY_QUERY))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4505 | { |
| 4506 | //Check whether we need to enforce default domain |
| 4507 | if( ( !pMac->roam.configParam.fEnforceDefaultDomain ) || |
| 4508 | (pMac->scan.domainIdCurrent == domainId) ) |
| 4509 | { |
| 4510 | |
| 4511 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 4512 | { |
| 4513 | vos_log_802_11d_pkt_type *p11dLog; |
| 4514 | tChannelListWithPower chnPwrInfo[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 4515 | tANI_U32 nChnInfo = WNI_CFG_VALID_CHANNEL_LIST_LEN, nTmp; |
| 4516 | |
| 4517 | WLAN_VOS_DIAG_LOG_ALLOC(p11dLog, vos_log_802_11d_pkt_type, LOG_WLAN_80211D_C); |
| 4518 | if(p11dLog) |
| 4519 | { |
| 4520 | p11dLog->eventId = WLAN_80211D_EVENT_COUNTRY_SET; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4521 | vos_mem_copy(p11dLog->countryCode, pMac->scan.countryCode11d, 3); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4522 | p11dLog->numChannel = pMac->scan.channels11d.numChannels; |
| 4523 | if(p11dLog->numChannel <= VOS_LOG_MAX_NUM_CHANNEL) |
| 4524 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4525 | vos_mem_copy(p11dLog->Channels, |
| 4526 | pMac->scan.channels11d.channelList, |
| 4527 | p11dLog->numChannel); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4528 | csrGetChannelPowerInfo(pMac, &pMac->scan.channelPowerInfoList24, |
| 4529 | &nChnInfo, chnPwrInfo); |
| 4530 | nTmp = nChnInfo; |
| 4531 | nChnInfo = WNI_CFG_VALID_CHANNEL_LIST_LEN - nTmp; |
| 4532 | csrGetChannelPowerInfo(pMac, &pMac->scan.channelPowerInfoList5G, |
| 4533 | &nChnInfo, &chnPwrInfo[nTmp]); |
| 4534 | for(nTmp = 0; nTmp < p11dLog->numChannel; nTmp++) |
| 4535 | { |
| 4536 | for(nChnInfo = 0; nChnInfo < WNI_CFG_VALID_CHANNEL_LIST_LEN; nChnInfo++) |
| 4537 | { |
| 4538 | if(p11dLog->Channels[nTmp] == chnPwrInfo[nChnInfo].chanId) |
| 4539 | { |
| 4540 | p11dLog->TxPwr[nTmp] = chnPwrInfo[nChnInfo].pwr; |
| 4541 | break; |
| 4542 | } |
| 4543 | } |
| 4544 | } |
| 4545 | } |
| 4546 | if(!pMac->roam.configParam.Is11dSupportEnabled) |
| 4547 | { |
| 4548 | p11dLog->supportMultipleDomain = WLAN_80211D_DISABLED; |
| 4549 | } |
| 4550 | else if(pMac->roam.configParam.fEnforceDefaultDomain) |
| 4551 | { |
| 4552 | p11dLog->supportMultipleDomain = WLAN_80211D_NOT_SUPPORT_MULTI_DOMAIN; |
| 4553 | } |
| 4554 | else |
| 4555 | { |
| 4556 | p11dLog->supportMultipleDomain = WLAN_80211D_SUPPORT_MULTI_DOMAIN; |
| 4557 | } |
| 4558 | WLAN_VOS_DIAG_LOG_REPORT(p11dLog); |
| 4559 | } |
| 4560 | } |
| 4561 | #endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 4562 | if(pMac->scan.domainIdCurrent != domainId) |
| 4563 | { |
Sushant Kaushik | e0d2cce | 2014-04-10 14:36:07 +0530 | [diff] [blame] | 4564 | smsLog(pMac, LOGW, FL("Domain Changed Old %s (%d), new %s"), |
| 4565 | voss_DomainIdtoString(pMac->scan.domainIdCurrent), |
| 4566 | pMac->scan.domainIdCurrent, |
| 4567 | voss_DomainIdtoString(domainId)); |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 4568 | status = WDA_SetRegDomain(pMac, domainId, eSIR_TRUE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4569 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4570 | if (status != eHAL_STATUS_SUCCESS) |
| 4571 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 4572 | smsLog( pMac, LOGE, FL(" fail to set regId %d"), domainId ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4573 | } |
| 4574 | pMac->scan.domainIdCurrent = domainId; |
Kiet Lam | 6c58333 | 2013-10-14 05:37:09 +0530 | [diff] [blame] | 4575 | #ifndef CONFIG_ENABLE_LINUX_REG |
Kiet Lam | bb14e95 | 2013-11-19 14:58:29 +0530 | [diff] [blame] | 4576 | csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, |
| 4577 | pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE ); |
Kiet Lam | 6c58333 | 2013-10-14 05:37:09 +0530 | [diff] [blame] | 4578 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4579 | // switch to active scans using this new channel list |
| 4580 | pMac->scan.curScanType = eSIR_ACTIVE_SCAN; |
| 4581 | pMac->scan.f11dInfoApplied = eANI_BOOLEAN_TRUE; |
| 4582 | pMac->scan.f11dInfoReset = eANI_BOOLEAN_FALSE; |
| 4583 | } |
| 4584 | } |
| 4585 | |
| 4586 | } while( 0 ); |
| 4587 | |
| 4588 | return; |
| 4589 | } |
| 4590 | |
| 4591 | |
| 4592 | |
| 4593 | tANI_BOOLEAN csrSave11dCountryString( tpAniSirGlobal pMac, tANI_U8 *pCountryCode, |
| 4594 | tANI_BOOLEAN fForce) |
| 4595 | { |
| 4596 | tANI_BOOLEAN fCountryStringChanged = FALSE, fUnknownCountryCode = FALSE; |
| 4597 | tANI_U32 i; |
Kiet Lam | 6c58333 | 2013-10-14 05:37:09 +0530 | [diff] [blame] | 4598 | v_REGDOMAIN_t regd; |
Tushnim Bhattacharyya | 582ac1d | 2013-11-07 23:44:09 -0800 | [diff] [blame] | 4599 | tANI_BOOLEAN fCountryNotPresentInDriver = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4600 | |
| 4601 | // convert to UPPER here so we are assured the strings are always in upper case. |
| 4602 | for( i = 0; i < 3; i++ ) |
| 4603 | { |
| 4604 | pCountryCode[ i ] = (tANI_U8)csrToUpper( pCountryCode[ i ] ); |
| 4605 | } |
| 4606 | |
| 4607 | // Some of the 'old' Cisco 350 series AP's advertise NA as the country code (for North America ??). |
| 4608 | // NA is not a valid country code or domain so let's allow this by changing it to the proper |
| 4609 | // country code (which is US). We've also seen some NETGEAR AP's that have "XX " as the country code |
| 4610 | // with valid 2.4 GHz US channel information. If we cannot find the country code advertised in the |
| 4611 | // 11d information element, let's default to US. |
Kiet Lam | 6c58333 | 2013-10-14 05:37:09 +0530 | [diff] [blame] | 4612 | if ( !HAL_STATUS_SUCCESS(csrGetRegulatoryDomainForCountry(pMac, |
| 4613 | pCountryCode, |
| 4614 | ®d, |
| 4615 | COUNTRY_QUERY) ) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4616 | { |
| 4617 | // Check the enforcement first |
| 4618 | if( pMac->roam.configParam.fEnforceDefaultDomain || pMac->roam.configParam.fEnforceCountryCodeMatch ) |
| 4619 | { |
| 4620 | fUnknownCountryCode = TRUE; |
| 4621 | } |
| 4622 | else |
| 4623 | { |
Tushnim Bhattacharyya | 582ac1d | 2013-11-07 23:44:09 -0800 | [diff] [blame] | 4624 | fCountryNotPresentInDriver = TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4625 | } |
| 4626 | } |
Tushnim Bhattacharyya | c3c1e8e | 2013-10-29 17:27:43 -0700 | [diff] [blame] | 4627 | //right now, even if we don't find the CC in driver we set to world. Making |
| 4628 | //sure countryCode11d doesn't get updated with the invalid CC, instead |
| 4629 | //reflect the world CC |
| 4630 | else if (REGDOMAIN_WORLD == regd) |
| 4631 | { |
Tushnim Bhattacharyya | 582ac1d | 2013-11-07 23:44:09 -0800 | [diff] [blame] | 4632 | fCountryNotPresentInDriver = TRUE; |
Tushnim Bhattacharyya | c3c1e8e | 2013-10-29 17:27:43 -0700 | [diff] [blame] | 4633 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4634 | |
| 4635 | // We've seen some of the AP's improperly put a 0 for the third character of the country code. |
| 4636 | // spec says valid charcters are 'O' (for outdoor), 'I' for Indoor, or ' ' (space; for either). |
| 4637 | // if we see a 0 in this third character, let's change it to a ' '. |
| 4638 | if ( 0 == pCountryCode[ 2 ] ) |
| 4639 | { |
| 4640 | pCountryCode[ 2 ] = ' '; |
| 4641 | } |
| 4642 | |
| 4643 | if( !fUnknownCountryCode ) |
| 4644 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4645 | fCountryStringChanged = (!vos_mem_compare(pMac->scan.countryCode11d, pCountryCode, 2)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4646 | |
| 4647 | |
| 4648 | if(( 0 == pMac->scan.countryCode11d[ 0 ] && 0 == pMac->scan.countryCode11d[ 1 ] ) |
| 4649 | || (fForce)) |
| 4650 | { |
Tushnim Bhattacharyya | 582ac1d | 2013-11-07 23:44:09 -0800 | [diff] [blame] | 4651 | if (!fCountryNotPresentInDriver) |
| 4652 | { |
| 4653 | // this is the first .11d information |
| 4654 | vos_mem_copy(pMac->scan.countryCode11d, pCountryCode, |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4655 | sizeof( pMac->scan.countryCode11d )); |
Tushnim Bhattacharyya | 582ac1d | 2013-11-07 23:44:09 -0800 | [diff] [blame] | 4656 | |
| 4657 | } |
| 4658 | else |
| 4659 | { |
| 4660 | pMac->scan.countryCode11d[0] = '0'; |
| 4661 | pMac->scan.countryCode11d[1] = '0'; |
| 4662 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4663 | } |
| 4664 | } |
| 4665 | |
| 4666 | return( fCountryStringChanged ); |
| 4667 | } |
| 4668 | |
| 4669 | |
| 4670 | void csrSaveChannelPowerForBand( tpAniSirGlobal pMac, tANI_BOOLEAN fPopulate5GBand ) |
| 4671 | { |
| 4672 | tANI_U32 Index, count=0; |
| 4673 | tSirMacChanInfo *pChanInfo; |
| 4674 | tSirMacChanInfo *pChanInfoStart; |
Leela V Kiran Kumar Reddy Chirala | 6a45875 | 2013-02-16 15:41:27 -0800 | [diff] [blame] | 4675 | tANI_S32 maxChannelIndex; |
| 4676 | |
| 4677 | maxChannelIndex = ( pMac->scan.base20MHzChannels.numChannels < WNI_CFG_VALID_CHANNEL_LIST_LEN ) ? |
| 4678 | pMac->scan.base20MHzChannels.numChannels : WNI_CFG_VALID_CHANNEL_LIST_LEN ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4679 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4680 | pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 4681 | if ( NULL != pChanInfo ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4682 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4683 | vos_mem_set(pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4684 | pChanInfoStart = pChanInfo; |
Leela V Kiran Kumar Reddy Chirala | 6a45875 | 2013-02-16 15:41:27 -0800 | [diff] [blame] | 4685 | for (Index=0; Index < maxChannelIndex; Index++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4686 | { |
| 4687 | if ((fPopulate5GBand && (CSR_IS_CHANNEL_5GHZ(pMac->scan.defaultPowerTable[Index].chanId))) || |
| 4688 | (!fPopulate5GBand && (CSR_IS_CHANNEL_24GHZ(pMac->scan.defaultPowerTable[Index].chanId))) ) |
| 4689 | { |
Leela V Kiran Kumar Reddy Chirala | 6a45875 | 2013-02-16 15:41:27 -0800 | [diff] [blame] | 4690 | if(count >= WNI_CFG_VALID_CHANNEL_LIST_LEN) |
| 4691 | { |
| 4692 | smsLog( pMac, LOGW, FL(" csrSaveChannelPowerForBand, count exceeded, count = %d"), count); |
| 4693 | break; |
| 4694 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4695 | pChanInfo->firstChanNum = pMac->scan.defaultPowerTable[Index].chanId; |
| 4696 | pChanInfo->numChannels = 1; |
| 4697 | pChanInfo->maxTxPower = CSR_ROAM_MIN( pMac->scan.defaultPowerTable[Index].pwr, pMac->roam.configParam.nTxPowerCap ); |
| 4698 | pChanInfo++; |
| 4699 | count++; |
| 4700 | } |
| 4701 | } |
| 4702 | if(count) |
| 4703 | { |
| 4704 | csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart ); |
| 4705 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4706 | vos_mem_free(pChanInfoStart); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4707 | } |
| 4708 | } |
| 4709 | |
| 4710 | |
| 4711 | void csrSetOppositeBandChannelInfo( tpAniSirGlobal pMac ) |
| 4712 | { |
| 4713 | tANI_BOOLEAN fPopulate5GBand = FALSE; |
| 4714 | |
| 4715 | do |
| 4716 | { |
| 4717 | // if this is not a dual band product, then we don't need to set the opposite |
| 4718 | // band info. We only work in one band so no need to look in the other band. |
| 4719 | if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) ) break; |
| 4720 | // if we found channel info on the 5.0 band and... |
| 4721 | if ( CSR_IS_CHANNEL_5GHZ( pMac->scan.channelOf11dInfo ) ) |
| 4722 | { |
| 4723 | // and the 2.4 band is empty, then populate the 2.4 channel info |
Kiet Lam | 8d985a0 | 2013-10-11 03:39:41 +0530 | [diff] [blame] | 4724 | if ( !csrLLIsListEmpty( &pMac->scan.channelPowerInfoList24, LL_ACCESS_LOCK ) ) break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4725 | fPopulate5GBand = FALSE; |
| 4726 | } |
| 4727 | else |
| 4728 | { |
| 4729 | // else, we found channel info in the 2.4 GHz band. If the 5.0 band is empty |
| 4730 | // set the 5.0 band info from the 2.4 country code. |
Kiet Lam | 8d985a0 | 2013-10-11 03:39:41 +0530 | [diff] [blame] | 4731 | if ( !csrLLIsListEmpty( &pMac->scan.channelPowerInfoList5G, LL_ACCESS_LOCK ) ) break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4732 | fPopulate5GBand = TRUE; |
| 4733 | } |
| 4734 | csrSaveChannelPowerForBand( pMac, fPopulate5GBand ); |
| 4735 | |
| 4736 | } while( 0 ); |
| 4737 | } |
| 4738 | |
| 4739 | |
| 4740 | tANI_BOOLEAN csrIsSupportedChannel(tpAniSirGlobal pMac, tANI_U8 channelId) |
| 4741 | { |
| 4742 | tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE; |
| 4743 | tANI_U32 i; |
| 4744 | |
| 4745 | //Make sure it is a channel that is in our supported list. |
| 4746 | for ( i = 0; i < pMac->scan.baseChannels.numChannels; i++ ) |
| 4747 | { |
| 4748 | if ( channelId == pMac->scan.baseChannels.channelList[i] ) |
| 4749 | { |
| 4750 | fRet = eANI_BOOLEAN_TRUE; |
| 4751 | break; |
| 4752 | } |
| 4753 | } |
| 4754 | |
| 4755 | //If it is configured to limit a set of the channels |
| 4756 | if( fRet && pMac->roam.configParam.fEnforce11dChannels ) |
| 4757 | { |
| 4758 | fRet = eANI_BOOLEAN_FALSE; |
| 4759 | for ( i = 0; i < pMac->scan.base20MHzChannels.numChannels; i++ ) |
| 4760 | { |
| 4761 | if ( channelId == pMac->scan.base20MHzChannels.channelList[i] ) |
| 4762 | { |
| 4763 | fRet = eANI_BOOLEAN_TRUE; |
| 4764 | break; |
| 4765 | } |
| 4766 | } |
| 4767 | } |
| 4768 | |
| 4769 | return (fRet); |
| 4770 | } |
| 4771 | |
| 4772 | |
| 4773 | |
| 4774 | //bSize specify the buffer size of pChannelList |
| 4775 | tANI_U8 csrGetChannelListFromChannelSet( tpAniSirGlobal pMac, tANI_U8 *pChannelList, tANI_U8 bSize, tCsrChannelPowerInfo *pChannelSet ) |
| 4776 | { |
| 4777 | tANI_U8 i, j = 0, chnId; |
| 4778 | |
| 4779 | bSize = CSR_MIN(bSize, pChannelSet->numChannels); |
| 4780 | for( i = 0; i < bSize; i++ ) |
| 4781 | { |
| 4782 | chnId = (tANI_U8)(pChannelSet->firstChannel + ( i * pChannelSet->interChannelOffset )); |
| 4783 | if ( csrIsSupportedChannel( pMac, chnId ) ) |
| 4784 | { |
| 4785 | pChannelList[j++] = chnId; |
| 4786 | } |
| 4787 | } |
| 4788 | |
| 4789 | return (j); |
| 4790 | } |
| 4791 | |
| 4792 | |
| 4793 | |
| 4794 | //bSize -- specify the buffer size of pChannelList |
| 4795 | void csrConstructCurrentValidChannelList( tpAniSirGlobal pMac, tDblLinkList *pChannelSetList, |
| 4796 | tANI_U8 *pChannelList, tANI_U8 bSize, tANI_U8 *pNumChannels ) |
| 4797 | { |
| 4798 | tListElem *pEntry; |
| 4799 | tCsrChannelPowerInfo *pChannelSet; |
| 4800 | tANI_U8 numChannels; |
| 4801 | tANI_U8 *pChannels; |
| 4802 | |
| 4803 | if( pChannelSetList && pChannelList && pNumChannels ) |
| 4804 | { |
| 4805 | pChannels = pChannelList; |
| 4806 | *pNumChannels = 0; |
| 4807 | pEntry = csrLLPeekHead( pChannelSetList, LL_ACCESS_LOCK ); |
| 4808 | while( pEntry ) |
| 4809 | { |
| 4810 | pChannelSet = GET_BASE_ADDR( pEntry, tCsrChannelPowerInfo, link ); |
| 4811 | numChannels = csrGetChannelListFromChannelSet( pMac, pChannels, bSize, pChannelSet ); |
| 4812 | pChannels += numChannels; |
| 4813 | *pNumChannels += numChannels; |
| 4814 | pEntry = csrLLNext( pChannelSetList, pEntry, LL_ACCESS_LOCK ); |
| 4815 | } |
| 4816 | } |
| 4817 | } |
| 4818 | |
| 4819 | |
| 4820 | /* |
| 4821 | * 802.11D only: Gather 11d IE via beacon or Probe response and store them in pAdapter->channels11d |
| 4822 | */ |
Chandrasekaran, Manishekar | 90c4932 | 2014-06-24 13:26:14 +0530 | [diff] [blame] | 4823 | tANI_BOOLEAN csrLearnCountryInformation( tpAniSirGlobal pMac, tSirBssDescription *pSirBssDesc, |
| 4824 | tDot11fBeaconIEs *pIes, tANI_BOOLEAN fForce) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4825 | { |
Agarwal Ashish | 60a37ee | 2014-05-28 17:20:20 +0530 | [diff] [blame] | 4826 | eHalStatus status; |
Chandrasekaran, Manishekar | 90c4932 | 2014-06-24 13:26:14 +0530 | [diff] [blame] | 4827 | tANI_U8 *pCountryCodeSelected; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4828 | tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE; |
| 4829 | v_REGDOMAIN_t domainId; |
Chandrasekaran, Manishekar | 90c4932 | 2014-06-24 13:26:14 +0530 | [diff] [blame] | 4830 | tDot11fBeaconIEs *pIesLocal = pIes; |
| 4831 | tANI_BOOLEAN useVoting = eANI_BOOLEAN_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4832 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4833 | if (VOS_STA_SAP_MODE == vos_get_conparam ()) |
| 4834 | return eHAL_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4835 | |
Chandrasekaran, Manishekar | 90c4932 | 2014-06-24 13:26:14 +0530 | [diff] [blame] | 4836 | if ((NULL == pSirBssDesc) && (NULL == pIes)) |
| 4837 | useVoting = eANI_BOOLEAN_TRUE; |
| 4838 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4839 | do |
| 4840 | { |
| 4841 | // check if .11d support is enabled |
| 4842 | if( !csrIs11dSupported( pMac ) ) break; |
Agarwal Ashish | 60a37ee | 2014-05-28 17:20:20 +0530 | [diff] [blame] | 4843 | |
Chandrasekaran, Manishekar | 90c4932 | 2014-06-24 13:26:14 +0530 | [diff] [blame] | 4844 | if (eANI_BOOLEAN_FALSE == useVoting) |
| 4845 | { |
| 4846 | if( !pIesLocal && |
| 4847 | (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, |
| 4848 | pSirBssDesc, &pIesLocal)))) |
| 4849 | { |
| 4850 | break; |
| 4851 | } |
| 4852 | // check if country information element is present |
| 4853 | if(!pIesLocal->Country.present) |
| 4854 | { |
| 4855 | //No country info |
| 4856 | break; |
| 4857 | } |
| 4858 | |
| 4859 | if( HAL_STATUS_SUCCESS(csrGetRegulatoryDomainForCountry |
| 4860 | (pMac, pIesLocal->Country.country, &domainId, |
| 4861 | COUNTRY_QUERY)) && |
| 4862 | ( domainId == REGDOMAIN_WORLD)) |
| 4863 | { |
| 4864 | break; |
| 4865 | } |
| 4866 | } //useVoting == eANI_BOOLEAN_FALSE |
| 4867 | |
| 4868 | if (eANI_BOOLEAN_FALSE == useVoting) |
| 4869 | pCountryCodeSelected = pIesLocal->Country.country; |
| 4870 | else |
| 4871 | pCountryCodeSelected = pMac->scan.countryCodeElected; |
| 4872 | |
Kiet Lam | 8d985a0 | 2013-10-11 03:39:41 +0530 | [diff] [blame] | 4873 | status = csrGetRegulatoryDomainForCountry(pMac, |
Chandrasekaran, Manishekar | 90c4932 | 2014-06-24 13:26:14 +0530 | [diff] [blame] | 4874 | pCountryCodeSelected, &domainId, COUNTRY_IE); |
Kiet Lam | 8d985a0 | 2013-10-11 03:39:41 +0530 | [diff] [blame] | 4875 | if ( status != eHAL_STATUS_SUCCESS ) |
| 4876 | { |
| 4877 | smsLog( pMac, LOGE, FL(" fail to get regId %d"), domainId ); |
| 4878 | fRet = eANI_BOOLEAN_FALSE; |
| 4879 | break; |
| 4880 | } |
Agarwal Ashish | 7693f2d | 2014-07-18 18:03:58 +0530 | [diff] [blame] | 4881 | |
| 4882 | /* updating 11d Country Code with Country code selected. */ |
| 4883 | |
| 4884 | vos_mem_copy(pMac->scan.countryCode11d, |
| 4885 | pCountryCodeSelected, |
| 4886 | WNI_CFG_COUNTRY_CODE_LEN); |
| 4887 | |
Agarwal Ashish | 60a37ee | 2014-05-28 17:20:20 +0530 | [diff] [blame] | 4888 | #ifndef CONFIG_ENABLE_LINUX_REG |
Venkata Prathyusha Kuntupalli | 316247e | 2013-03-15 17:45:25 -0700 | [diff] [blame] | 4889 | // Checking for Domain Id change |
| 4890 | if ( domainId != pMac->scan.domainIdCurrent ) |
| 4891 | { |
Kiet Lam | 8d985a0 | 2013-10-11 03:39:41 +0530 | [diff] [blame] | 4892 | vos_mem_copy(pMac->scan.countryCode11d, |
Chandrasekaran, Manishekar | 90c4932 | 2014-06-24 13:26:14 +0530 | [diff] [blame] | 4893 | pCountryCodeSelected, |
Kiet Lam | 8d985a0 | 2013-10-11 03:39:41 +0530 | [diff] [blame] | 4894 | sizeof( pMac->scan.countryCode11d ) ); |
| 4895 | /* Set Current Country code and Current Regulatory domain */ |
| 4896 | status = csrSetRegulatoryDomain(pMac, domainId, NULL); |
| 4897 | if (eHAL_STATUS_SUCCESS != status) |
| 4898 | { |
| 4899 | smsLog(pMac, LOGE, "Set Reg Domain Fail %d", status); |
| 4900 | fRet = eANI_BOOLEAN_FALSE; |
| 4901 | return fRet; |
| 4902 | } |
| 4903 | //csrSetRegulatoryDomain will fail if the country doesn't fit our domain criteria. |
| 4904 | vos_mem_copy(pMac->scan.countryCodeCurrent, |
Chandrasekaran, Manishekar | 90c4932 | 2014-06-24 13:26:14 +0530 | [diff] [blame] | 4905 | pCountryCodeSelected, WNI_CFG_COUNTRY_CODE_LEN); |
Kiet Lam | 8d985a0 | 2013-10-11 03:39:41 +0530 | [diff] [blame] | 4906 | //Simply set it to cfg. |
Chandrasekaran, Manishekar | 90c4932 | 2014-06-24 13:26:14 +0530 | [diff] [blame] | 4907 | csrSetCfgCountryCode(pMac, pCountryCodeSelected); |
Kiet Lam | 8d985a0 | 2013-10-11 03:39:41 +0530 | [diff] [blame] | 4908 | |
| 4909 | /* overwrite the defualt country code */ |
| 4910 | vos_mem_copy(pMac->scan.countryCodeDefault, |
| 4911 | pMac->scan.countryCodeCurrent, |
| 4912 | WNI_CFG_COUNTRY_CODE_LEN); |
| 4913 | /* Set Current RegDomain */ |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 4914 | status = WDA_SetRegDomain(pMac, domainId, eSIR_TRUE); |
Kiet Lam | 8d985a0 | 2013-10-11 03:39:41 +0530 | [diff] [blame] | 4915 | if ( status != eHAL_STATUS_SUCCESS ) |
| 4916 | { |
| 4917 | smsLog( pMac, LOGE, FL(" fail to Set regId %d"), domainId ); |
| 4918 | fRet = eANI_BOOLEAN_FALSE; |
| 4919 | return fRet; |
| 4920 | } |
| 4921 | /* set to default domain ID */ |
Madan Mohan Koyyalamudi | 0e5922d | 2013-09-10 15:45:24 +0530 | [diff] [blame] | 4922 | pMac->scan.domainIdCurrent = domainId; |
Kiet Lam | 8d985a0 | 2013-10-11 03:39:41 +0530 | [diff] [blame] | 4923 | /* get the channels based on new cc */ |
| 4924 | status = csrInitGetChannels( pMac ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4925 | |
Kiet Lam | 8d985a0 | 2013-10-11 03:39:41 +0530 | [diff] [blame] | 4926 | if ( status != eHAL_STATUS_SUCCESS ) |
| 4927 | { |
| 4928 | smsLog( pMac, LOGE, FL(" fail to get Channels ")); |
| 4929 | fRet = eANI_BOOLEAN_FALSE; |
| 4930 | return fRet; |
| 4931 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4932 | |
Kiet Lam | 8d985a0 | 2013-10-11 03:39:41 +0530 | [diff] [blame] | 4933 | /* reset info based on new cc, and we are done */ |
| 4934 | csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE); |
Agarwal Ashish | faef669 | 2014-01-29 19:40:30 +0530 | [diff] [blame] | 4935 | /* Regulatory Domain Changed, Purge Only scan result |
| 4936 | * which does not have channel number belong to 11d |
| 4937 | * channel list |
| 4938 | */ |
Srinivas, Dasari | 42bf770 | 2014-02-07 11:29:53 +0530 | [diff] [blame] | 4939 | csrScanFilterResults(pMac); |
Kiet Lam | 8d985a0 | 2013-10-11 03:39:41 +0530 | [diff] [blame] | 4940 | } |
Kiet Lam | 6c58333 | 2013-10-14 05:37:09 +0530 | [diff] [blame] | 4941 | #endif |
| 4942 | fRet = eANI_BOOLEAN_TRUE; |
| 4943 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4944 | } while( 0 ); |
Chandrasekaran, Manishekar | 90c4932 | 2014-06-24 13:26:14 +0530 | [diff] [blame] | 4945 | |
| 4946 | if( !pIes && pIesLocal ) |
| 4947 | { |
| 4948 | //locally allocated |
| 4949 | vos_mem_free(pIesLocal); |
| 4950 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4951 | |
| 4952 | return( fRet ); |
| 4953 | } |
| 4954 | |
| 4955 | |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 4956 | static void csrSaveScanResults( tpAniSirGlobal pMac, tANI_U8 reason ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4957 | { |
| 4958 | // initialize this to FALSE. profMoveInterimScanResultsToMainList() routine |
| 4959 | // will set this to the channel where an .11d beacon is seen |
| 4960 | pMac->scan.channelOf11dInfo = 0; |
| 4961 | // if we get any ambiguous .11d information then this will be set to TRUE |
| 4962 | pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE; |
| 4963 | //Tush |
| 4964 | // if we get any ambiguous .11d information, then this will be set to TRUE |
| 4965 | // only if the applied 11d info could be found in one of the scan results |
| 4966 | pMac->scan.fCurrent11dInfoMatch = eANI_BOOLEAN_FALSE; |
| 4967 | // move the scan results from interim list to the main scan list |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 4968 | csrMoveTempScanResultsToMainList( pMac, reason ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4969 | } |
| 4970 | |
| 4971 | |
| 4972 | void csrReinitScanCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
| 4973 | { |
| 4974 | switch (pCommand->u.scanCmd.reason) |
| 4975 | { |
| 4976 | case eCsrScanSetBGScanParam: |
| 4977 | case eCsrScanAbortBgScan: |
| 4978 | if(pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList) |
| 4979 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4980 | vos_mem_free(pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4981 | pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList = NULL; |
| 4982 | } |
| 4983 | break; |
| 4984 | case eCsrScanBGScanAbort: |
| 4985 | case eCsrScanBGScanEnable: |
| 4986 | case eCsrScanGetScanChnInfo: |
| 4987 | break; |
| 4988 | case eCsrScanAbortNormalScan: |
| 4989 | default: |
| 4990 | csrScanFreeRequest(pMac, &pCommand->u.scanCmd.u.scanRequest); |
| 4991 | break; |
| 4992 | } |
| 4993 | if(pCommand->u.scanCmd.pToRoamProfile) |
| 4994 | { |
| 4995 | csrReleaseProfile(pMac, pCommand->u.scanCmd.pToRoamProfile); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4996 | vos_mem_free(pCommand->u.scanCmd.pToRoamProfile); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4997 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4998 | vos_mem_set(&pCommand->u.scanCmd, sizeof(tScanCmd), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4999 | } |
| 5000 | |
| 5001 | |
| 5002 | tANI_BOOLEAN csrGetRemainingChannelsFor11dScan( tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U8 *pcChannels ) |
| 5003 | { |
| 5004 | tANI_U32 index11dChannels, index; |
| 5005 | tANI_U32 indexCurrentChannels; |
| 5006 | tANI_BOOLEAN fChannelAlreadyScanned; |
| 5007 | tANI_U32 len = sizeof(pMac->roam.validChannelList); |
| 5008 | |
| 5009 | *pcChannels = 0; |
| 5010 | if ( CSR_IS_11D_INFO_FOUND(pMac) && csrRoamIsChannelValid(pMac, pMac->scan.channelOf11dInfo) ) |
| 5011 | { |
| 5012 | if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len))) |
| 5013 | { |
| 5014 | //Find the channel index where we found the 11d info |
| 5015 | for(index = 0; index < len; index++) |
| 5016 | { |
| 5017 | if(pMac->scan.channelOf11dInfo == pMac->roam.validChannelList[index]) |
| 5018 | break; |
| 5019 | } |
| 5020 | //check whether we found the channel index |
| 5021 | if(index < len) |
| 5022 | { |
| 5023 | // Now, look through the 11d channel list and create a list of all channels in the 11d list that are |
| 5024 | // NOT in the current channel list. This gives us a list of the new channels that have not been |
| 5025 | // scanned. We'll scan this new list so we have a complete set of scan results on all of the domain channels |
| 5026 | // initially. |
| 5027 | for ( index11dChannels = 0; index11dChannels < pMac->scan.channels11d.numChannels; index11dChannels++ ) |
| 5028 | { |
| 5029 | fChannelAlreadyScanned = eANI_BOOLEAN_FALSE; |
| 5030 | |
| 5031 | for( indexCurrentChannels = 0; indexCurrentChannels < index; indexCurrentChannels++ ) |
| 5032 | { |
| 5033 | if ( pMac->roam.validChannelList[ indexCurrentChannels ] == pMac->scan.channels11d.channelList[ index11dChannels ] ) |
| 5034 | { |
| 5035 | fChannelAlreadyScanned = eANI_BOOLEAN_TRUE; |
| 5036 | break; |
| 5037 | } |
| 5038 | } |
| 5039 | |
| 5040 | if ( !fChannelAlreadyScanned ) |
| 5041 | { |
| 5042 | pChannels[ *pcChannels ] = pMac->scan.channels11d.channelList[ index11dChannels ]; |
| 5043 | ( *pcChannels )++; |
| 5044 | } |
| 5045 | } |
| 5046 | } |
| 5047 | }//GetCFG |
| 5048 | } |
| 5049 | return( *pcChannels ); |
| 5050 | } |
| 5051 | |
| 5052 | |
| 5053 | eCsrScanCompleteNextCommand csrScanGetNextCommandState( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fSuccess ) |
| 5054 | { |
| 5055 | eCsrScanCompleteNextCommand NextCommand = eCsrNextScanNothing; |
| 5056 | |
| 5057 | switch( pCommand->u.scanCmd.reason ) |
| 5058 | { |
| 5059 | case eCsrScan11d1: |
| 5060 | NextCommand = (fSuccess) ? eCsrNext11dScan1Success : eCsrNext11dScan1Failure; |
| 5061 | break; |
| 5062 | case eCsrScan11d2: |
| 5063 | NextCommand = (fSuccess) ? eCsrNext11dScan2Success : eCsrNext11dScan2Failure; |
| 5064 | break; |
| 5065 | case eCsrScan11dDone: |
| 5066 | NextCommand = eCsrNext11dScanComplete; |
| 5067 | break; |
| 5068 | case eCsrScanLostLink1: |
| 5069 | NextCommand = (fSuccess) ? eCsrNextLostLinkScan1Success : eCsrNextLostLinkScan1Failed; |
| 5070 | break; |
| 5071 | case eCsrScanLostLink2: |
| 5072 | NextCommand = (fSuccess) ? eCsrNextLostLinkScan2Success : eCsrNextLostLinkScan2Failed; |
| 5073 | break; |
| 5074 | case eCsrScanLostLink3: |
| 5075 | NextCommand = (fSuccess) ? eCsrNextLostLinkScan3Success : eCsrNextLostLinkScan3Failed; |
| 5076 | break; |
| 5077 | case eCsrScanForSsid: |
| 5078 | NextCommand = (fSuccess) ? eCsrNexteScanForSsidSuccess : eCsrNexteScanForSsidFailure; |
| 5079 | break; |
| 5080 | case eCsrScanForCapsChange: |
| 5081 | NextCommand = eCsrNextCapChangeScanComplete; //don't care success or not |
| 5082 | break; |
| 5083 | case eCsrScanIdleScan: |
| 5084 | NextCommand = eCsrNextIdleScanComplete; |
| 5085 | break; |
| 5086 | default: |
| 5087 | NextCommand = eCsrNextScanNothing; |
| 5088 | break; |
| 5089 | } |
| 5090 | return( NextCommand ); |
| 5091 | } |
| 5092 | |
| 5093 | |
| 5094 | //Return whether the pCommand is finished. |
| 5095 | tANI_BOOLEAN csrHandleScan11d1Failure(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
| 5096 | { |
| 5097 | tANI_BOOLEAN fRet = eANI_BOOLEAN_TRUE; |
| 5098 | |
| 5099 | //Apply back the default setting and passively scan one more time. |
Gopichand Nakkala | b9185f2 | 2012-12-21 08:03:42 -0800 | [diff] [blame] | 5100 | csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_TRUE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5101 | pCommand->u.scanCmd.reason = eCsrScan11d2; |
| 5102 | if(HAL_STATUS_SUCCESS(csrScanChannels(pMac, pCommand))) |
| 5103 | { |
| 5104 | fRet = eANI_BOOLEAN_FALSE; |
| 5105 | } |
| 5106 | |
| 5107 | return (fRet); |
| 5108 | } |
| 5109 | |
| 5110 | |
| 5111 | tANI_BOOLEAN csrHandleScan11dSuccess(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
| 5112 | { |
| 5113 | tANI_BOOLEAN fRet = eANI_BOOLEAN_TRUE; |
| 5114 | tANI_U8 *pChannels; |
| 5115 | tANI_U8 cChannels; |
| 5116 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5117 | pChannels = vos_mem_malloc(WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 5118 | if ( NULL != pChannels ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5119 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5120 | vos_mem_set(pChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5121 | if ( csrGetRemainingChannelsFor11dScan( pMac, pChannels, &cChannels ) ) |
| 5122 | { |
| 5123 | pCommand->u.scanCmd.reason = eCsrScan11dDone; |
| 5124 | if(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList) |
| 5125 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5126 | vos_mem_free(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList); |
James Zmuda | 9ea1edd | 2013-04-18 18:20:54 -0700 | [diff] [blame] | 5127 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5128 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5129 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = vos_mem_malloc(cChannels); |
| 5130 | if ( NULL != pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5131 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5132 | vos_mem_copy(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList, |
| 5133 | pChannels, cChannels); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5134 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = cChannels; |
| 5135 | pCommand->u.scanCmd.u.scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN; |
| 5136 | pCommand->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 5137 | if(HAL_STATUS_SUCCESS(csrScanChannels(pMac, pCommand))) |
| 5138 | { |
| 5139 | //Reuse the same command buffer |
| 5140 | fRet = eANI_BOOLEAN_FALSE; |
| 5141 | } |
| 5142 | } |
| 5143 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5144 | vos_mem_free(pChannels); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5145 | } |
| 5146 | |
| 5147 | return (fRet); |
| 5148 | } |
| 5149 | |
| 5150 | //Return whether the command should be removed |
| 5151 | tANI_BOOLEAN csrScanComplete( tpAniSirGlobal pMac, tSirSmeScanRsp *pScanRsp ) |
| 5152 | { |
| 5153 | eCsrScanCompleteNextCommand NextCommand = eCsrNextScanNothing; |
| 5154 | tListElem *pEntry; |
| 5155 | tSmeCmd *pCommand; |
| 5156 | tANI_BOOLEAN fRemoveCommand = eANI_BOOLEAN_TRUE; |
| 5157 | tANI_BOOLEAN fSuccess; |
| 5158 | |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 5159 | if (pMac->fScanOffload) |
| 5160 | pEntry = csrLLPeekHead(&pMac->sme.smeScanCmdActiveList, LL_ACCESS_LOCK); |
| 5161 | else |
| 5162 | pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5163 | |
| 5164 | if ( pEntry ) |
| 5165 | { |
| 5166 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 5167 | |
| 5168 | // If the head of the queue is Active and it is a SCAN command, remove |
| 5169 | // and put this on the Free queue. |
| 5170 | if ( eSmeCommandScan == pCommand->command ) |
| 5171 | { |
| 5172 | tANI_U32 sessionId = pCommand->sessionId; |
| 5173 | |
| 5174 | if(eSIR_SME_SUCCESS != pScanRsp->statusCode) |
| 5175 | { |
| 5176 | fSuccess = eANI_BOOLEAN_FALSE; |
| 5177 | } |
| 5178 | else |
| 5179 | { |
| 5180 | //pMac->scan.tempScanResults is not empty meaning the scan found something |
| 5181 | //This check only valid here because csrSaveScanresults is not yet called |
| 5182 | fSuccess = (!csrLLIsListEmpty(&pMac->scan.tempScanResults, LL_ACCESS_LOCK)); |
| 5183 | } |
Ratheesh S P | ece1f83 | 2015-07-25 15:50:25 +0530 | [diff] [blame] | 5184 | if (pCommand->u.scanCmd.abortScanIndication & |
| 5185 | eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE) |
Srinivas, Dasari | 187ca4e | 2014-02-07 12:40:09 +0530 | [diff] [blame] | 5186 | { |
| 5187 | /* |
| 5188 | * Scan aborted due to band change |
| 5189 | * The scan results need to be flushed |
| 5190 | */ |
| 5191 | if (pCommand->u.scanCmd.callback |
| 5192 | != pMac->scan.callback11dScanDone) |
| 5193 | { |
| 5194 | smsLog(pMac, LOG1, FL("Filtering the scan results as the " |
| 5195 | "results may belong to wrong band")); |
| 5196 | csrScanFilterResults(pMac); |
| 5197 | } |
| 5198 | else |
| 5199 | { |
| 5200 | smsLog(pMac, LOG1, FL("11d_scan_done will flush the scan" |
| 5201 | " results")); |
| 5202 | } |
Srinivas, Dasari | 187ca4e | 2014-02-07 12:40:09 +0530 | [diff] [blame] | 5203 | } |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 5204 | csrSaveScanResults(pMac, pCommand->u.scanCmd.reason); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5205 | |
Agrawal Ashish | df75267 | 2015-12-09 17:51:53 +0530 | [diff] [blame] | 5206 | /* filter scan result based on valid channel list number */ |
| 5207 | if (pMac->scan.fcc_constraint) |
| 5208 | { |
| 5209 | smsLog(pMac, LOG1, FL("Clear BSS from invalid channels")); |
| 5210 | csrScanFilterResults(pMac); |
| 5211 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5212 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 5213 | { |
| 5214 | vos_log_scan_pkt_type *pScanLog = NULL; |
| 5215 | tScanResultHandle hScanResult; |
| 5216 | tCsrScanResultInfo *pScanResult; |
| 5217 | tDot11fBeaconIEs *pIes; |
| 5218 | int n = 0, c = 0; |
| 5219 | |
| 5220 | WLAN_VOS_DIAG_LOG_ALLOC(pScanLog, vos_log_scan_pkt_type, LOG_WLAN_SCAN_C); |
| 5221 | if(pScanLog) |
| 5222 | { |
| 5223 | if(eCsrScanBgScan == pCommand->u.scanCmd.reason || |
| 5224 | eCsrScanProbeBss == pCommand->u.scanCmd.reason || |
| 5225 | eCsrScanSetBGScanParam == pCommand->u.scanCmd.reason) |
| 5226 | { |
| 5227 | pScanLog->eventId = WLAN_SCAN_EVENT_HO_SCAN_RSP; |
| 5228 | } |
| 5229 | else |
| 5230 | { |
| 5231 | if( eSIR_PASSIVE_SCAN != pMac->scan.curScanType ) |
| 5232 | { |
| 5233 | pScanLog->eventId = WLAN_SCAN_EVENT_ACTIVE_SCAN_RSP; |
| 5234 | } |
| 5235 | else |
| 5236 | { |
| 5237 | pScanLog->eventId = WLAN_SCAN_EVENT_PASSIVE_SCAN_RSP; |
| 5238 | } |
| 5239 | } |
| 5240 | if(eSIR_SME_SUCCESS == pScanRsp->statusCode) |
| 5241 | { |
| 5242 | if(HAL_STATUS_SUCCESS(csrScanGetResult(pMac, NULL, &hScanResult))) |
| 5243 | { |
| 5244 | while(((pScanResult = csrScanResultGetNext(pMac, hScanResult)) != NULL)) |
| 5245 | { |
| 5246 | if( n < VOS_LOG_MAX_NUM_BSSID ) |
| 5247 | { |
| 5248 | if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->BssDescriptor, &pIes))) |
| 5249 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5250 | smsLog(pMac, LOGE, FL(" fail to parse IEs")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5251 | break; |
| 5252 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5253 | vos_mem_copy(pScanLog->bssid[n], |
| 5254 | pScanResult->BssDescriptor.bssId, 6); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5255 | if(pIes && pIes->SSID.present && VOS_LOG_MAX_SSID_SIZE >= pIes->SSID.num_ssid) |
| 5256 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5257 | vos_mem_copy(pScanLog->ssid[n], |
| 5258 | pIes->SSID.ssid, pIes->SSID.num_ssid); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5259 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5260 | vos_mem_free(pIes); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5261 | n++; |
| 5262 | } |
| 5263 | c++; |
| 5264 | } |
| 5265 | pScanLog->numSsid = (v_U8_t)n; |
| 5266 | pScanLog->totalSsid = (v_U8_t)c; |
| 5267 | csrScanResultPurge(pMac, hScanResult); |
| 5268 | } |
| 5269 | } |
| 5270 | else |
| 5271 | { |
| 5272 | pScanLog->status = WLAN_SCAN_STATUS_FAILURE; |
| 5273 | } |
| 5274 | WLAN_VOS_DIAG_LOG_REPORT(pScanLog); |
| 5275 | } |
| 5276 | } |
| 5277 | #endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 5278 | |
| 5279 | NextCommand = csrScanGetNextCommandState(pMac, pCommand, fSuccess); |
| 5280 | //We reuse the command here instead reissue a new command |
| 5281 | switch(NextCommand) |
| 5282 | { |
| 5283 | case eCsrNext11dScan1Success: |
| 5284 | case eCsrNext11dScan2Success: |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5285 | smsLog( pMac, LOG2, FL("11dScan1/3 produced results. Reissue Active scan...")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5286 | // if we found country information, no need to continue scanning further, bail out |
| 5287 | fRemoveCommand = eANI_BOOLEAN_TRUE; |
| 5288 | NextCommand = eCsrNext11dScanComplete; |
| 5289 | break; |
| 5290 | case eCsrNext11dScan1Failure: |
| 5291 | //We are not done yet. 11d scan fail once. We will try to reset anything and do it over again |
| 5292 | //The only meaningful thing for this retry is that we cannot find 11d information after a reset so |
| 5293 | //we clear the "old" 11d info and give it once more chance |
| 5294 | fRemoveCommand = csrHandleScan11d1Failure(pMac, pCommand); |
| 5295 | if(fRemoveCommand) |
| 5296 | { |
| 5297 | NextCommand = eCsrNext11dScanComplete; |
| 5298 | } |
| 5299 | break; |
| 5300 | case eCsrNextLostLinkScan1Success: |
| 5301 | if(!HAL_STATUS_SUCCESS(csrIssueRoamAfterLostlinkScan(pMac, sessionId, eCsrLostLink1))) |
| 5302 | { |
| 5303 | csrScanHandleFailedLostlink1(pMac, sessionId); |
| 5304 | } |
| 5305 | break; |
| 5306 | case eCsrNextLostLinkScan2Success: |
| 5307 | if(!HAL_STATUS_SUCCESS(csrIssueRoamAfterLostlinkScan(pMac, sessionId, eCsrLostLink2))) |
| 5308 | { |
| 5309 | csrScanHandleFailedLostlink2(pMac, sessionId); |
| 5310 | } |
| 5311 | break; |
| 5312 | case eCsrNextLostLinkScan3Success: |
| 5313 | if(!HAL_STATUS_SUCCESS(csrIssueRoamAfterLostlinkScan(pMac, sessionId, eCsrLostLink3))) |
| 5314 | { |
| 5315 | csrScanHandleFailedLostlink3(pMac, sessionId); |
| 5316 | } |
| 5317 | break; |
| 5318 | case eCsrNextLostLinkScan1Failed: |
| 5319 | csrScanHandleFailedLostlink1(pMac, sessionId); |
| 5320 | break; |
| 5321 | case eCsrNextLostLinkScan2Failed: |
| 5322 | csrScanHandleFailedLostlink2(pMac, sessionId); |
| 5323 | break; |
| 5324 | case eCsrNextLostLinkScan3Failed: |
| 5325 | csrScanHandleFailedLostlink3(pMac, sessionId); |
| 5326 | break; |
| 5327 | case eCsrNexteScanForSsidSuccess: |
| 5328 | csrScanHandleSearchForSSID(pMac, pCommand); |
| 5329 | break; |
| 5330 | case eCsrNexteScanForSsidFailure: |
| 5331 | csrScanHandleSearchForSSIDFailure(pMac, pCommand); |
| 5332 | break; |
| 5333 | case eCsrNextIdleScanComplete: |
| 5334 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 5335 | break; |
| 5336 | case eCsrNextCapChangeScanComplete: |
| 5337 | csrScanHandleCapChangeScanComplete(pMac, sessionId); |
| 5338 | break; |
| 5339 | default: |
| 5340 | |
| 5341 | break; |
| 5342 | } |
| 5343 | } |
| 5344 | else |
| 5345 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5346 | smsLog( pMac, LOGW, FL("Scan Completion called but SCAN command is not ACTIVE ...")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5347 | fRemoveCommand = eANI_BOOLEAN_FALSE; |
| 5348 | } |
| 5349 | } |
| 5350 | else |
| 5351 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5352 | smsLog( pMac, LOGW, FL("Scan Completion called but NO commands are ACTIVE ...")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5353 | fRemoveCommand = eANI_BOOLEAN_FALSE; |
| 5354 | } |
| 5355 | |
| 5356 | return( fRemoveCommand ); |
| 5357 | } |
| 5358 | |
| 5359 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5360 | static void csrScanRemoveDupBssDescriptionFromInterimList( tpAniSirGlobal pMac, |
| 5361 | tSirBssDescription *pSirBssDescr, |
| 5362 | tDot11fBeaconIEs *pIes) |
| 5363 | { |
| 5364 | tListElem *pEntry; |
| 5365 | tCsrScanResult *pCsrBssDescription; |
Abhishek Singh | 56c2981 | 2018-06-12 14:07:52 +0530 | [diff] [blame^] | 5366 | tDot11fBeaconIEs *temp_ie = pIes; |
| 5367 | |
| 5368 | if (!temp_ie) |
| 5369 | csrGetParsedBssDescriptionIEs(pMac, pSirBssDescr, &temp_ie); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5370 | |
| 5371 | // Walk through all the chained BssDescriptions. If we find a chained BssDescription that |
| 5372 | // matches the BssID of the BssDescription passed in, then these must be duplicate scan |
| 5373 | // results for this Bss. In that case, remove the 'old' Bss description from the linked list. |
| 5374 | pEntry = csrLLPeekHead( &pMac->scan.tempScanResults, LL_ACCESS_LOCK ); |
| 5375 | while( pEntry ) |
| 5376 | { |
| 5377 | pCsrBssDescription = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 5378 | |
| 5379 | // we have a duplicate scan results only when BSSID, SSID, Channel and NetworkType |
| 5380 | // matches |
| 5381 | |
Abhishek Singh | 56c2981 | 2018-06-12 14:07:52 +0530 | [diff] [blame^] | 5382 | if (csrIsDuplicateBssDescription(pMac, |
| 5383 | &pCsrBssDescription->Result.BssDescriptor, |
| 5384 | pSirBssDescr, temp_ie, FALSE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5385 | { |
Abhishek Singh | 56c2981 | 2018-06-12 14:07:52 +0530 | [diff] [blame^] | 5386 | /* |
| 5387 | * Due to Rx sensitivity issue, sometime beacons are seen on |
| 5388 | * adjacent channel so workaround in software is needed. If DS |
| 5389 | * params or HT info are present driver can get proper channel |
| 5390 | * info from these IEs and the older RSSI values are used in new |
| 5391 | * entry. |
| 5392 | * |
| 5393 | * For the cases where DS params and HT info is not present, |
| 5394 | * driver needs to check below conditions to update proper |
| 5395 | * channel so that the older RSSI and channel values are used in |
| 5396 | * new entry: |
| 5397 | * -- The old entry channel and new entry channel are not same |
| 5398 | * -- RSSI is below 15db or more from old value, this indicate |
| 5399 | * that the signal has leaked in adjacent channel |
| 5400 | */ |
| 5401 | if (!pSirBssDescr->fProbeRsp && |
| 5402 | (temp_ie && !temp_ie->DSParams.present && |
| 5403 | !temp_ie->HTInfo.present) && |
| 5404 | (pSirBssDescr->channelId != |
| 5405 | pCsrBssDescription->Result.BssDescriptor.channelId) && |
| 5406 | ((pCsrBssDescription->Result.BssDescriptor.rssi - |
| 5407 | pSirBssDescr->rssi) > |
| 5408 | SIR_ADJACENT_CHANNEL_RSSI_DIFF_THRESHOLD)) { |
| 5409 | pSirBssDescr->channelId = |
| 5410 | pCsrBssDescription->Result.BssDescriptor.channelId; |
| 5411 | pSirBssDescr->rssi = |
| 5412 | pCsrBssDescription->Result.BssDescriptor.rssi; |
| 5413 | } |
| 5414 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5415 | pSirBssDescr->rssi = (tANI_S8)( (((tANI_S32)pSirBssDescr->rssi * CSR_SCAN_RESULT_RSSI_WEIGHT ) + |
| 5416 | ((tANI_S32)pCsrBssDescription->Result.BssDescriptor.rssi * (100 - CSR_SCAN_RESULT_RSSI_WEIGHT) )) / 100 ); |
| 5417 | |
| 5418 | // Remove the 'old' entry from the list.... |
| 5419 | if( csrLLRemoveEntry( &pMac->scan.tempScanResults, pEntry, LL_ACCESS_LOCK ) ) |
| 5420 | { |
| 5421 | csrCheckNSaveWscIe(pMac, pSirBssDescr, &pCsrBssDescription->Result.BssDescriptor); |
| 5422 | // we need to free the memory associated with this node |
| 5423 | csrFreeScanResultEntry( pMac, pCsrBssDescription ); |
| 5424 | } |
| 5425 | |
| 5426 | // If we found a match, we can stop looking through the list. |
| 5427 | break; |
| 5428 | } |
| 5429 | |
| 5430 | pEntry = csrLLNext( &pMac->scan.tempScanResults, pEntry, LL_ACCESS_LOCK ); |
| 5431 | } |
Abhishek Singh | 56c2981 | 2018-06-12 14:07:52 +0530 | [diff] [blame^] | 5432 | |
| 5433 | if (!pIes && temp_ie) |
| 5434 | vos_mem_free(temp_ie); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5435 | } |
| 5436 | |
| 5437 | |
| 5438 | |
| 5439 | //Caller allocated memory pfNewBssForConn to return whether new candidate for |
| 5440 | //current connection is found. Cannot be NULL |
| 5441 | tCsrScanResult *csrScanSaveBssDescriptionToInterimList( tpAniSirGlobal pMac, |
| 5442 | tSirBssDescription *pBSSDescription, |
| 5443 | tDot11fBeaconIEs *pIes) |
| 5444 | { |
| 5445 | tCsrScanResult *pCsrBssDescription = NULL; |
| 5446 | tANI_U32 cbBSSDesc; |
| 5447 | tANI_U32 cbAllocated; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5448 | |
| 5449 | // figure out how big the BSS description is (the BSSDesc->length does NOT |
| 5450 | // include the size of the length field itself). |
| 5451 | cbBSSDesc = pBSSDescription->length + sizeof( pBSSDescription->length ); |
| 5452 | |
| 5453 | cbAllocated = sizeof( tCsrScanResult ) + cbBSSDesc; |
| 5454 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5455 | pCsrBssDescription = vos_mem_malloc(cbAllocated); |
| 5456 | if ( NULL != pCsrBssDescription ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5457 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5458 | vos_mem_set(pCsrBssDescription, cbAllocated, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5459 | pCsrBssDescription->AgingCount = (tANI_S32)pMac->roam.configParam.agingCount; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5460 | vos_mem_copy(&pCsrBssDescription->Result.BssDescriptor, pBSSDescription, cbBSSDesc ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5461 | //Save SSID separately for later use |
| 5462 | if( pIes->SSID.present && !csrIsNULLSSID(pIes->SSID.ssid, pIes->SSID.num_ssid) ) |
| 5463 | { |
| 5464 | //SSID not hidden |
Madan Mohan Koyyalamudi | 4e31b13 | 2012-11-02 13:13:52 -0700 | [diff] [blame] | 5465 | tANI_U32 len = pIes->SSID.num_ssid; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5466 | if (len > SIR_MAC_MAX_SSID_LENGTH) |
| 5467 | { |
| 5468 | // truncate to fit in our struct |
| 5469 | len = SIR_MAC_MAX_SSID_LENGTH; |
| 5470 | } |
| 5471 | pCsrBssDescription->Result.ssId.length = len; |
| 5472 | pCsrBssDescription->Result.timer = vos_timer_get_system_time(); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5473 | vos_mem_copy(pCsrBssDescription->Result.ssId.ssId, pIes->SSID.ssid, len); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5474 | } |
| 5475 | csrLLInsertTail( &pMac->scan.tempScanResults, &pCsrBssDescription->Link, LL_ACCESS_LOCK ); |
| 5476 | } |
| 5477 | |
| 5478 | return( pCsrBssDescription ); |
| 5479 | } |
| 5480 | |
| 5481 | |
| 5482 | |
| 5483 | |
| 5484 | tANI_BOOLEAN csrIsDuplicateBssDescription( tpAniSirGlobal pMac, tSirBssDescription *pSirBssDesc1, |
Tushnim Bhattacharyya | 5128d75 | 2013-06-26 23:23:18 -0700 | [diff] [blame] | 5485 | tSirBssDescription *pSirBssDesc2, tDot11fBeaconIEs *pIes2, tANI_BOOLEAN fForced ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5486 | { |
| 5487 | tANI_BOOLEAN fMatch = FALSE; |
| 5488 | tSirMacCapabilityInfo *pCap1, *pCap2; |
| 5489 | tDot11fBeaconIEs *pIes1 = NULL; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5490 | tDot11fBeaconIEs *pIesTemp = pIes2; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5491 | |
| 5492 | pCap1 = (tSirMacCapabilityInfo *)&pSirBssDesc1->capabilityInfo; |
| 5493 | pCap2 = (tSirMacCapabilityInfo *)&pSirBssDesc2->capabilityInfo; |
| 5494 | if(pCap1->ess == pCap2->ess) |
| 5495 | { |
| 5496 | if (pCap1->ess && |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5497 | csrIsMacAddressEqual( pMac, (tCsrBssid *)pSirBssDesc1->bssId, (tCsrBssid *)pSirBssDesc2->bssId)&& |
Abhishek Singh | e3fa11f | 2014-05-13 11:11:10 +0530 | [diff] [blame] | 5498 | (fForced || (vos_chan_to_band(pSirBssDesc1->channelId) == vos_chan_to_band((pSirBssDesc2->channelId))))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5499 | { |
| 5500 | fMatch = TRUE; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5501 | // Check for SSID match, if exists |
| 5502 | do |
| 5503 | { |
| 5504 | if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc1, &pIes1))) |
| 5505 | { |
| 5506 | break; |
| 5507 | } |
| 5508 | if( NULL == pIesTemp ) |
| 5509 | { |
| 5510 | if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc2, &pIesTemp))) |
| 5511 | { |
| 5512 | break; |
| 5513 | } |
| 5514 | } |
| 5515 | if(pIes1->SSID.present && pIesTemp->SSID.present) |
| 5516 | { |
| 5517 | fMatch = csrIsSsidMatch(pMac, pIes1->SSID.ssid, pIes1->SSID.num_ssid, |
| 5518 | pIesTemp->SSID.ssid, pIesTemp->SSID.num_ssid, eANI_BOOLEAN_TRUE); |
| 5519 | } |
| 5520 | }while(0); |
| 5521 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5522 | } |
| 5523 | else if (pCap1->ibss && (pSirBssDesc1->channelId == pSirBssDesc2->channelId)) |
| 5524 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5525 | |
| 5526 | do |
| 5527 | { |
| 5528 | if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc1, &pIes1))) |
| 5529 | { |
| 5530 | break; |
| 5531 | } |
| 5532 | if( NULL == pIesTemp ) |
| 5533 | { |
| 5534 | if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc2, &pIesTemp))) |
| 5535 | { |
| 5536 | break; |
| 5537 | } |
| 5538 | } |
| 5539 | //Same channel cannot have same SSID for different IBSS |
| 5540 | if(pIes1->SSID.present && pIesTemp->SSID.present) |
| 5541 | { |
| 5542 | fMatch = csrIsSsidMatch(pMac, pIes1->SSID.ssid, pIes1->SSID.num_ssid, |
| 5543 | pIesTemp->SSID.ssid, pIesTemp->SSID.num_ssid, eANI_BOOLEAN_TRUE); |
| 5544 | } |
| 5545 | }while(0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5546 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5547 | /* In case of P2P devices, ess and ibss will be set to zero */ |
| 5548 | else if (!pCap1->ess && |
| 5549 | csrIsMacAddressEqual( pMac, (tCsrBssid *)pSirBssDesc1->bssId, (tCsrBssid *)pSirBssDesc2->bssId)) |
| 5550 | { |
| 5551 | fMatch = TRUE; |
| 5552 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5553 | } |
| 5554 | |
| 5555 | if(pIes1) |
| 5556 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5557 | vos_mem_free(pIes1); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5558 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5559 | |
| 5560 | if( (NULL == pIes2) && pIesTemp ) |
| 5561 | { |
| 5562 | //locally allocated |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5563 | vos_mem_free(pIesTemp); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5564 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5565 | |
| 5566 | return( fMatch ); |
| 5567 | } |
| 5568 | |
| 5569 | |
| 5570 | tANI_BOOLEAN csrIsNetworkTypeEqual( tSirBssDescription *pSirBssDesc1, tSirBssDescription *pSirBssDesc2 ) |
| 5571 | { |
| 5572 | return( pSirBssDesc1->nwType == pSirBssDesc2->nwType ); |
| 5573 | } |
| 5574 | |
| 5575 | |
| 5576 | //to check whether the BSS matches the dot11Mode |
| 5577 | static tANI_BOOLEAN csrScanIsBssAllowed(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc, |
| 5578 | tDot11fBeaconIEs *pIes) |
| 5579 | { |
| 5580 | tANI_BOOLEAN fAllowed = eANI_BOOLEAN_FALSE; |
| 5581 | eCsrPhyMode phyMode; |
| 5582 | |
| 5583 | if(HAL_STATUS_SUCCESS(csrGetPhyModeFromBss(pMac, pBssDesc, &phyMode, pIes))) |
| 5584 | { |
| 5585 | switch(pMac->roam.configParam.phyMode) |
| 5586 | { |
| 5587 | case eCSR_DOT11_MODE_11b: |
| 5588 | fAllowed = (tANI_BOOLEAN)(eCSR_DOT11_MODE_11a != phyMode); |
| 5589 | break; |
| 5590 | case eCSR_DOT11_MODE_11g: |
| 5591 | fAllowed = (tANI_BOOLEAN)(eCSR_DOT11_MODE_11a != phyMode); |
| 5592 | break; |
| 5593 | case eCSR_DOT11_MODE_11g_ONLY: |
| 5594 | fAllowed = (tANI_BOOLEAN)(eCSR_DOT11_MODE_11g == phyMode); |
| 5595 | break; |
| 5596 | case eCSR_DOT11_MODE_11a: |
| 5597 | fAllowed = (tANI_BOOLEAN)((eCSR_DOT11_MODE_11b != phyMode) && (eCSR_DOT11_MODE_11g != phyMode)); |
| 5598 | break; |
| 5599 | case eCSR_DOT11_MODE_11n_ONLY: |
| 5600 | fAllowed = (tANI_BOOLEAN)((eCSR_DOT11_MODE_11n == phyMode) || (eCSR_DOT11_MODE_TAURUS == phyMode)); |
| 5601 | break; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5602 | |
| 5603 | #ifdef WLAN_FEATURE_11AC |
| 5604 | case eCSR_DOT11_MODE_11ac_ONLY: |
| 5605 | fAllowed = (tANI_BOOLEAN)((eCSR_DOT11_MODE_11ac == phyMode) || (eCSR_DOT11_MODE_TAURUS == phyMode)); |
| 5606 | break; |
| 5607 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5608 | case eCSR_DOT11_MODE_11b_ONLY: |
| 5609 | fAllowed = (tANI_BOOLEAN)(eCSR_DOT11_MODE_11b == phyMode); |
| 5610 | break; |
| 5611 | case eCSR_DOT11_MODE_11a_ONLY: |
| 5612 | fAllowed = (tANI_BOOLEAN)(eCSR_DOT11_MODE_11a == phyMode); |
| 5613 | break; |
| 5614 | case eCSR_DOT11_MODE_11n: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5615 | #ifdef WLAN_FEATURE_11AC |
| 5616 | case eCSR_DOT11_MODE_11ac: |
| 5617 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5618 | case eCSR_DOT11_MODE_TAURUS: |
| 5619 | default: |
| 5620 | fAllowed = eANI_BOOLEAN_TRUE; |
| 5621 | break; |
| 5622 | } |
| 5623 | } |
| 5624 | |
| 5625 | return (fAllowed); |
| 5626 | } |
| 5627 | |
| 5628 | |
| 5629 | |
| 5630 | //Return pIes to caller for future use when returning TRUE. |
| 5631 | static tANI_BOOLEAN csrScanValidateScanResult( tpAniSirGlobal pMac, tANI_U8 *pChannels, |
| 5632 | tANI_U8 numChn, tSirBssDescription *pBssDesc, |
| 5633 | tDot11fBeaconIEs **ppIes ) |
| 5634 | { |
| 5635 | tANI_BOOLEAN fValidChannel = FALSE; |
| 5636 | tDot11fBeaconIEs *pIes = NULL; |
| 5637 | tANI_U8 index; |
| 5638 | |
| 5639 | for( index = 0; index < numChn; index++ ) |
| 5640 | { |
| 5641 | // This check relies on the fact that a single BSS description is returned in each |
| 5642 | // ScanRsp call, which is the way LIM implemented the scan req/rsp funtions. We changed |
| 5643 | // to this model when we ran with a large number of APs. If this were to change, then |
| 5644 | // this check would have to mess with removing the bssDescription from somewhere in an |
| 5645 | // arbitrary index in the bssDescription array. |
| 5646 | if ( pChannels[ index ] == pBssDesc->channelId ) |
| 5647 | { |
| 5648 | fValidChannel = TRUE; |
| 5649 | break; |
| 5650 | } |
| 5651 | } |
| 5652 | *ppIes = NULL; |
| 5653 | if(fValidChannel) |
| 5654 | { |
| 5655 | if( HAL_STATUS_SUCCESS( csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes) ) ) |
| 5656 | { |
| 5657 | fValidChannel = csrScanIsBssAllowed(pMac, pBssDesc, pIes); |
| 5658 | if( fValidChannel ) |
| 5659 | { |
| 5660 | *ppIes = pIes; |
| 5661 | } |
| 5662 | else |
| 5663 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5664 | vos_mem_free(pIes); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5665 | } |
| 5666 | } |
| 5667 | else |
| 5668 | { |
| 5669 | fValidChannel = FALSE; |
| 5670 | } |
| 5671 | } |
| 5672 | |
| 5673 | return( fValidChannel ); |
| 5674 | } |
| 5675 | |
| 5676 | |
| 5677 | //Return whether last scan result is received |
| 5678 | static tANI_BOOLEAN csrScanProcessScanResults( tpAniSirGlobal pMac, tSmeCmd *pCommand, |
| 5679 | tSirSmeScanRsp *pScanRsp, tANI_BOOLEAN *pfRemoveCommand ) |
| 5680 | { |
| 5681 | tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE, fRemoveCommand = eANI_BOOLEAN_FALSE; |
| 5682 | tDot11fBeaconIEs *pIes = NULL; |
| 5683 | tANI_U32 cbParsed; |
| 5684 | tSirBssDescription *pSirBssDescription; |
| 5685 | tANI_U32 cbBssDesc; |
Agrawal Ashish | 4cc15bb | 2016-02-04 17:56:16 +0530 | [diff] [blame] | 5686 | eHalStatus status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5687 | tANI_U32 cbScanResult = GET_FIELD_OFFSET( tSirSmeScanRsp, bssDescription ) |
| 5688 | + sizeof(tSirBssDescription); //We need at least one CB |
| 5689 | |
| 5690 | // don't consider the scan rsp to be valid if the status code is Scan Failure. Scan Failure |
| 5691 | // is returned when the scan could not find anything. so if we get scan failure return that |
| 5692 | // the scan response is invalid. Also check the lenght in the scan result for valid scan |
| 5693 | // BssDescriptions.... |
| 5694 | do |
| 5695 | { |
| 5696 | if ( ( cbScanResult <= pScanRsp->length ) && |
| 5697 | (( eSIR_SME_SUCCESS == pScanRsp->statusCode ) || |
| 5698 | ( eSIR_SME_MORE_SCAN_RESULTS_FOLLOW == pScanRsp->statusCode ) ) ) |
| 5699 | { |
| 5700 | tANI_U8 *pChannelList = NULL; |
| 5701 | tANI_U8 cChannels = 0; |
| 5702 | |
| 5703 | //Different scan type can reach this point, we need to distinguish it |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 5704 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 5705 | if( eCsrScanGetLfrResult == pCommand->u.scanCmd.reason ) |
| 5706 | { |
| 5707 | pChannelList = NULL; |
| 5708 | cChannels = 0; |
| 5709 | } |
| 5710 | else |
| 5711 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5712 | if( eCsrScanSetBGScanParam == pCommand->u.scanCmd.reason ) |
| 5713 | { |
| 5714 | //eCsrScanSetBGScanParam uses different structure |
| 5715 | tCsrBGScanRequest *pBgScanReq = &pCommand->u.scanCmd.u.bgScanRequest; |
| 5716 | |
| 5717 | cChannels = pBgScanReq->ChannelInfo.numOfChannels; |
| 5718 | pChannelList = pBgScanReq->ChannelInfo.ChannelList; |
| 5719 | } |
| 5720 | else |
| 5721 | { |
| 5722 | //the rest use generic scan request |
| 5723 | cChannels = pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels; |
| 5724 | pChannelList = pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList; |
| 5725 | } |
| 5726 | |
| 5727 | // if the scan result is not on one of the channels in the Valid channel list, then it |
| 5728 | // must have come from an AP on an overlapping channel (in the 2.4GHz band). In this case, |
| 5729 | // let's drop the scan result. |
| 5730 | // |
| 5731 | // The other situation is where the scan request is for a scan on a particular channel set |
| 5732 | // and the scan result is from a |
| 5733 | |
| 5734 | // if the NumChannels is 0, then we are supposed to be scanning all channels. Use the full channel |
| 5735 | // list as the 'valid' channel list. Otherwise, use the specific channel list in the scan parms |
| 5736 | // as the valid channels. |
| 5737 | if ( 0 == cChannels ) |
| 5738 | { |
| 5739 | tANI_U32 len = sizeof(pMac->roam.validChannelList); |
| 5740 | |
| 5741 | if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len))) |
| 5742 | { |
| 5743 | pChannelList = pMac->roam.validChannelList; |
| 5744 | cChannels = (tANI_U8)len; |
| 5745 | } |
| 5746 | else |
| 5747 | { |
| 5748 | //Cannot continue |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5749 | smsLog( pMac, LOGE, "CSR: Processing internal SCAN results...csrGetCfgValidChannels failed" ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5750 | break; |
| 5751 | } |
| 5752 | } |
| 5753 | |
| 5754 | smsLog( pMac, LOG2, "CSR: Processing internal SCAN results..." ); |
| 5755 | cbParsed = GET_FIELD_OFFSET( tSirSmeScanRsp, bssDescription ); |
| 5756 | pSirBssDescription = pScanRsp->bssDescription; |
| 5757 | while( cbParsed < pScanRsp->length ) |
| 5758 | { |
| 5759 | if ( csrScanValidateScanResult( pMac, pChannelList, cChannels, pSirBssDescription, &pIes ) ) |
| 5760 | { |
| 5761 | csrScanRemoveDupBssDescriptionFromInterimList(pMac, pSirBssDescription, pIes); |
| 5762 | csrScanSaveBssDescriptionToInterimList( pMac, pSirBssDescription, pIes ); |
| 5763 | if( eSIR_PASSIVE_SCAN == pMac->scan.curScanType ) |
| 5764 | { |
| 5765 | if( csrIs11dSupported( pMac) ) |
| 5766 | { |
| 5767 | //Check whether the BSS is acceptable base on 11d info and our configs. |
| 5768 | if( csrMatchCountryCode( pMac, NULL, pIes ) ) |
| 5769 | { |
| 5770 | //Double check whether the channel is acceptable by us. |
| 5771 | if( csrIsSupportedChannel( pMac, pSirBssDescription->channelId ) ) |
| 5772 | { |
| 5773 | pMac->scan.curScanType = eSIR_ACTIVE_SCAN; |
| 5774 | } |
| 5775 | } |
| 5776 | } |
| 5777 | else |
| 5778 | { |
| 5779 | pMac->scan.curScanType = eSIR_ACTIVE_SCAN; |
| 5780 | } |
| 5781 | } |
| 5782 | //Free the resource |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5783 | vos_mem_free(pIes); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5784 | } |
| 5785 | // skip over the BSS description to the next one... |
| 5786 | cbBssDesc = pSirBssDescription->length + sizeof( pSirBssDescription->length ); |
| 5787 | |
| 5788 | cbParsed += cbBssDesc; |
| 5789 | pSirBssDescription = (tSirBssDescription *)((tANI_U8 *)pSirBssDescription + cbBssDesc ); |
| 5790 | |
| 5791 | } //while |
| 5792 | } |
| 5793 | else |
| 5794 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5795 | smsLog( pMac, LOGW, " Scanrsp fail (0x%08X), length = %d (expected %d)", |
Madan Mohan Koyyalamudi | dd3c966 | 2012-11-09 17:39:30 -0800 | [diff] [blame] | 5796 | pScanRsp->statusCode, pScanRsp->length, cbScanResult); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5797 | //HO bg scan/probe failed no need to try autonomously |
| 5798 | if(eCsrScanBgScan == pCommand->u.scanCmd.reason || |
| 5799 | eCsrScanProbeBss == pCommand->u.scanCmd.reason || |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 5800 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 5801 | eCsrScanGetLfrResult == pCommand->u.scanCmd.reason || |
| 5802 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5803 | eCsrScanSetBGScanParam == pCommand->u.scanCmd.reason) |
| 5804 | { |
| 5805 | fRemoveCommand = eANI_BOOLEAN_TRUE; |
| 5806 | } |
| 5807 | } |
| 5808 | }while(0); |
| 5809 | if ( eSIR_SME_MORE_SCAN_RESULTS_FOLLOW != pScanRsp->statusCode ) |
| 5810 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5811 | smsLog(pMac, LOG1, " Scan received %d unique BSS scan reason is %d", csrLLCount(&pMac->scan.tempScanResults), pCommand->u.scanCmd.reason); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5812 | fRemoveCommand = csrScanComplete( pMac, pScanRsp ); |
| 5813 | fRet = eANI_BOOLEAN_TRUE; |
| 5814 | }//if ( eSIR_SME_MORE_SCAN_RESULTS_FOLLOW != pScanRsp->statusCode ) |
| 5815 | if(pfRemoveCommand) |
| 5816 | { |
| 5817 | *pfRemoveCommand = fRemoveCommand; |
| 5818 | } |
| 5819 | |
Agrawal Ashish | 4cc15bb | 2016-02-04 17:56:16 +0530 | [diff] [blame] | 5820 | /* |
| 5821 | * Currently SET_FCC_CHANNEL issues updated channel list to fw. |
| 5822 | * At the time of driver load, if scan is issued followed with |
| 5823 | * SET_FCC_CHANNEL, driver will send update channel list to fw. |
| 5824 | * Fw will stop ongoing scan because of that GUI will have very less |
| 5825 | * scan list. |
| 5826 | * Update channel list should be sent to fw once scan is done |
| 5827 | */ |
| 5828 | if (pMac->scan.defer_update_channel_list) { |
| 5829 | status = csrUpdateChannelList(pMac); |
| 5830 | if (eHAL_STATUS_SUCCESS != status) |
| 5831 | smsLog(pMac, LOGE, |
| 5832 | FL( "failed to update the supported channel list")); |
| 5833 | pMac->scan.defer_update_channel_list = false; |
| 5834 | } |
| 5835 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5836 | #ifdef WLAN_AP_STA_CONCURRENCY |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 5837 | if (pMac->fScanOffload) |
| 5838 | return fRet; |
| 5839 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5840 | if (!csrLLIsListEmpty( &pMac->scan.scanCmdPendingList, LL_ACCESS_LOCK )) |
| 5841 | { |
Madan Mohan Koyyalamudi | 48081ef | 2012-12-04 16:49:55 -0800 | [diff] [blame] | 5842 | /* Pending scan commands in the list because the previous scan command |
| 5843 | * was split into a scan command on one channel + a scan command for all |
| 5844 | * remaining channels. |
| 5845 | * |
| 5846 | * Start timer to trigger processing of the next scan command. |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 5847 | * NOTE for LFR: |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 5848 | * Do not split scans if no concurrent infra connections are |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 5849 | * active and if the scan is a BG scan triggered by LFR (OR) |
| 5850 | * any scan if LFR is in the middle of a BG scan. Splitting |
| 5851 | * the scan is delaying the time it takes for LFR to find |
| 5852 | * candidates and resulting in disconnects. |
Madan Mohan Koyyalamudi | 48081ef | 2012-12-04 16:49:55 -0800 | [diff] [blame] | 5853 | */ |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 5854 | if ( (csrIsStaSessionConnected(pMac) && |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 5855 | #ifdef FEATURE_WLAN_LFR |
| 5856 | (csrIsConcurrentInfraConnected(pMac) || |
| 5857 | ((pCommand->u.scanCmd.reason != eCsrScanBgScan) && |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 5858 | (pMac->roam.neighborRoamInfo.neighborRoamState != |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 5859 | eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN))) && |
| 5860 | #endif |
| 5861 | (pCommand->u.scanCmd.u.scanRequest.p2pSearch != 1)) || |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 5862 | (csrIsP2pSessionConnected(pMac)) ) |
Madan Mohan Koyyalamudi | 48081ef | 2012-12-04 16:49:55 -0800 | [diff] [blame] | 5863 | { |
Madan Mohan Koyyalamudi | d671358 | 2012-11-09 16:56:56 -0800 | [diff] [blame] | 5864 | /* if active connected sessions present then continue to split scan |
| 5865 | * with specified interval between consecutive scans */ |
| 5866 | csrSetDefaultScanTiming(pMac, pCommand->u.scanCmd.u.scanRequest.scanType, &(pCommand->u.scanCmd.u.scanRequest)); |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 5867 | vos_timer_start(&pMac->scan.hTimerStaApConcTimer, |
| 5868 | pCommand->u.scanCmd.u.scanRequest.restTime); |
Madan Mohan Koyyalamudi | d671358 | 2012-11-09 16:56:56 -0800 | [diff] [blame] | 5869 | } else { |
| 5870 | /* if no connected sessions present then initiate next scan command immediately */ |
| 5871 | /* minimum timer granularity is 10ms */ |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 5872 | vos_timer_start(&pMac->scan.hTimerStaApConcTimer, 10); |
Madan Mohan Koyyalamudi | d671358 | 2012-11-09 16:56:56 -0800 | [diff] [blame] | 5873 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5874 | } |
| 5875 | #endif |
| 5876 | return (fRet); |
| 5877 | } |
| 5878 | |
| 5879 | |
| 5880 | tANI_BOOLEAN csrScanIsWildCardScan( tpAniSirGlobal pMac, tSmeCmd *pCommand ) |
| 5881 | { |
| 5882 | tANI_U8 bssid[WNI_CFG_BSSID_LEN] = {0, 0, 0, 0, 0, 0}; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5883 | tANI_BOOLEAN f = vos_mem_compare(pCommand->u.scanCmd.u.scanRequest.bssid, |
| 5884 | bssid, sizeof(tCsrBssid)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5885 | |
| 5886 | //It is not a wild card scan if the bssid is not broadcast and the number of SSID is 1. |
| 5887 | return ((tANI_BOOLEAN)( (f || (0xff == pCommand->u.scanCmd.u.scanRequest.bssid[0])) && |
| 5888 | (pCommand->u.scanCmd.u.scanRequest.SSIDs.numOfSSIDs != 1) )); |
| 5889 | } |
| 5890 | |
| 5891 | |
| 5892 | eHalStatus csrScanSmeScanResponse( tpAniSirGlobal pMac, void *pMsgBuf ) |
| 5893 | { |
| 5894 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 5895 | tListElem *pEntry; |
| 5896 | tSmeCmd *pCommand; |
| 5897 | eCsrScanStatus scanStatus; |
Sunkad, Anand Ningappa | 3ec8bf7 | 2016-02-05 15:13:30 +0530 | [diff] [blame] | 5898 | tSirSmeScanRsp *pScanRsp; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5899 | tSmeGetScanChnRsp *pScanChnInfo; |
| 5900 | tANI_BOOLEAN fRemoveCommand = eANI_BOOLEAN_TRUE; |
| 5901 | eCsrScanReason reason = eCsrScanOther; |
| 5902 | |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 5903 | if (pMac->fScanOffload) |
| 5904 | pEntry = csrLLPeekHead(&pMac->sme.smeScanCmdActiveList, |
| 5905 | LL_ACCESS_LOCK); |
| 5906 | else |
| 5907 | pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5908 | |
| 5909 | if ( pEntry ) |
| 5910 | { |
| 5911 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 5912 | if ( eSmeCommandScan == pCommand->command ) |
| 5913 | { |
Deepthi Gowri | fe5340b | 2016-04-11 12:15:46 +0530 | [diff] [blame] | 5914 | /* Purge the scan results based on Aging */ |
| 5915 | if (pEntry && pMac->scan.scanResultCfgAgingTime) |
| 5916 | csrPurgeScanResultByAge(pMac); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5917 | reason = pCommand->u.scanCmd.reason; |
| 5918 | switch(pCommand->u.scanCmd.reason) |
| 5919 | { |
| 5920 | case eCsrScanAbortBgScan: |
| 5921 | case eCsrScanAbortNormalScan: |
| 5922 | case eCsrScanBGScanAbort: |
| 5923 | case eCsrScanBGScanEnable: |
Sunkad, Anand Ningappa | 3ec8bf7 | 2016-02-05 15:13:30 +0530 | [diff] [blame] | 5924 | pScanRsp = (tSirSmeScanRsp *)pMsgBuf; |
| 5925 | scanStatus = (eSIR_SME_SUCCESS == pScanRsp->statusCode) ? |
| 5926 | eCSR_SCAN_SUCCESS : eCSR_SCAN_FAILURE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5927 | break; |
| 5928 | case eCsrScanGetScanChnInfo: |
Deepthi Gowri | fe5340b | 2016-04-11 12:15:46 +0530 | [diff] [blame] | 5929 | pScanChnInfo = (tSmeGetScanChnRsp *)pMsgBuf; |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5930 | /* |
| 5931 | * status code not available in tSmeGetScanChnRsp, so |
| 5932 | * by default considereing it to be success |
| 5933 | */ |
| 5934 | scanStatus = eSIR_SME_SUCCESS; |
Deepthi Gowri | fe5340b | 2016-04-11 12:15:46 +0530 | [diff] [blame] | 5935 | csrScanAgeResults(pMac, pScanChnInfo); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5936 | break; |
| 5937 | case eCsrScanForCapsChange: |
Sunkad, Anand Ningappa | 3ec8bf7 | 2016-02-05 15:13:30 +0530 | [diff] [blame] | 5938 | pScanRsp = (tSirSmeScanRsp *)pMsgBuf; |
| 5939 | scanStatus = (eSIR_SME_SUCCESS == pScanRsp->statusCode) ? |
| 5940 | eCSR_SCAN_SUCCESS : eCSR_SCAN_FAILURE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5941 | csrScanProcessScanResults( pMac, pCommand, pScanRsp, &fRemoveCommand ); |
| 5942 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5943 | case eCsrScanP2PFindPeer: |
Sunkad, Anand Ningappa | 3ec8bf7 | 2016-02-05 15:13:30 +0530 | [diff] [blame] | 5944 | pScanRsp = (tSirSmeScanRsp *)pMsgBuf; |
| 5945 | scanStatus = ((eSIR_SME_SUCCESS == pScanRsp->statusCode) && |
| 5946 | (pScanRsp->length > 50)) ? eCSR_SCAN_FOUND_PEER : eCSR_SCAN_FAILURE; |
| 5947 | csrScanProcessScanResults( pMac, pCommand, pScanRsp, NULL ); |
| 5948 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5949 | case eCsrScanSetBGScanParam: |
| 5950 | default: |
Sunkad, Anand Ningappa | 3ec8bf7 | 2016-02-05 15:13:30 +0530 | [diff] [blame] | 5951 | pScanRsp = (tSirSmeScanRsp *)pMsgBuf; |
| 5952 | scanStatus = (eSIR_SME_SUCCESS == pScanRsp->statusCode) ? |
| 5953 | eCSR_SCAN_SUCCESS : eCSR_SCAN_FAILURE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5954 | if(csrScanProcessScanResults( pMac, pCommand, pScanRsp, &fRemoveCommand )) |
| 5955 | { |
| 5956 | //Not to get channel info if the scan is not a wildcard scan because |
| 5957 | //it may cause scan results got aged out incorrectly. |
Ratheesh S P | ece1f83 | 2015-07-25 15:50:25 +0530 | [diff] [blame] | 5958 | if(csrScanIsWildCardScan( pMac, pCommand ) && |
| 5959 | (!pCommand->u.scanCmd.u.scanRequest.p2pSearch) |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 5960 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 5961 | && (pCommand->u.scanCmd.reason != eCsrScanGetLfrResult) |
| 5962 | #endif |
| 5963 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5964 | { |
Ratheesh S P | ece1f83 | 2015-07-25 15:50:25 +0530 | [diff] [blame] | 5965 | csrScanGetScanChnInfo(pMac, pCommand); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5966 | } |
| 5967 | } |
| 5968 | break; |
| 5969 | }//switch |
| 5970 | if(fRemoveCommand) |
| 5971 | { |
| 5972 | |
| 5973 | csrReleaseScanCommand(pMac, pCommand, scanStatus); |
| 5974 | |
Sunkad, Anand Ningappa | 3ec8bf7 | 2016-02-05 15:13:30 +0530 | [diff] [blame] | 5975 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5976 | smeProcessPendingQueue( pMac ); |
| 5977 | } |
| 5978 | else |
| 5979 | { |
| 5980 | smsLog( pMac, LOGW, "CSR: Scan Completion called but SCAN command is not ACTIVE ..." ); |
| 5981 | status = eHAL_STATUS_FAILURE; |
| 5982 | } |
| 5983 | } |
| 5984 | else |
| 5985 | { |
| 5986 | smsLog( pMac, LOGW, "CSR: Scan Completion called but NO commands are ACTIVE ..." ); |
| 5987 | status = eHAL_STATUS_FAILURE; |
| 5988 | } |
| 5989 | |
| 5990 | return (status); |
| 5991 | } |
| 5992 | |
| 5993 | |
| 5994 | |
| 5995 | |
| 5996 | tCsrScanResultInfo *csrScanResultGetFirst(tpAniSirGlobal pMac, tScanResultHandle hScanResult) |
| 5997 | { |
| 5998 | tListElem *pEntry; |
| 5999 | tCsrScanResult *pResult; |
| 6000 | tCsrScanResultInfo *pRet = NULL; |
| 6001 | tScanResultList *pResultList = (tScanResultList *)hScanResult; |
| 6002 | |
| 6003 | if(pResultList) |
| 6004 | { |
| 6005 | csrLLLock(&pResultList->List); |
| 6006 | pEntry = csrLLPeekHead(&pResultList->List, LL_ACCESS_NOLOCK); |
| 6007 | if(pEntry) |
| 6008 | { |
| 6009 | pResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link); |
| 6010 | pRet = &pResult->Result; |
| 6011 | } |
| 6012 | pResultList->pCurEntry = pEntry; |
| 6013 | csrLLUnlock(&pResultList->List); |
| 6014 | } |
| 6015 | |
| 6016 | return pRet; |
| 6017 | } |
| 6018 | |
| 6019 | |
| 6020 | tCsrScanResultInfo *csrScanResultGetNext(tpAniSirGlobal pMac, tScanResultHandle hScanResult) |
| 6021 | { |
| 6022 | tListElem *pEntry = NULL; |
| 6023 | tCsrScanResult *pResult = NULL; |
| 6024 | tCsrScanResultInfo *pRet = NULL; |
| 6025 | tScanResultList *pResultList = (tScanResultList *)hScanResult; |
| 6026 | |
| 6027 | if(pResultList) |
| 6028 | { |
| 6029 | csrLLLock(&pResultList->List); |
| 6030 | if(NULL == pResultList->pCurEntry) |
| 6031 | { |
| 6032 | pEntry = csrLLPeekHead(&pResultList->List, LL_ACCESS_NOLOCK); |
| 6033 | } |
| 6034 | else |
| 6035 | { |
| 6036 | pEntry = csrLLNext(&pResultList->List, pResultList->pCurEntry, LL_ACCESS_NOLOCK); |
| 6037 | } |
| 6038 | if(pEntry) |
| 6039 | { |
| 6040 | pResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link); |
| 6041 | pRet = &pResult->Result; |
| 6042 | } |
| 6043 | pResultList->pCurEntry = pEntry; |
| 6044 | csrLLUnlock(&pResultList->List); |
| 6045 | } |
| 6046 | |
| 6047 | return pRet; |
| 6048 | } |
| 6049 | |
| 6050 | |
| 6051 | //This function moves the first BSS that matches the bssid to the head of the result |
| 6052 | eHalStatus csrMoveBssToHeadFromBSSID(tpAniSirGlobal pMac, tCsrBssid *bssid, tScanResultHandle hScanResult) |
| 6053 | { |
| 6054 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 6055 | tScanResultList *pResultList = (tScanResultList *)hScanResult; |
| 6056 | tCsrScanResult *pResult = NULL; |
| 6057 | tListElem *pEntry = NULL; |
| 6058 | |
| 6059 | if(pResultList && bssid) |
| 6060 | { |
| 6061 | csrLLLock(&pResultList->List); |
| 6062 | pEntry = csrLLPeekHead(&pResultList->List, LL_ACCESS_NOLOCK); |
| 6063 | while(pEntry) |
| 6064 | { |
| 6065 | pResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6066 | if (vos_mem_compare(bssid, pResult->Result.BssDescriptor.bssId, sizeof(tCsrBssid))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6067 | { |
| 6068 | status = eHAL_STATUS_SUCCESS; |
| 6069 | csrLLRemoveEntry(&pResultList->List, pEntry, LL_ACCESS_NOLOCK); |
| 6070 | csrLLInsertHead(&pResultList->List, pEntry, LL_ACCESS_NOLOCK); |
| 6071 | break; |
| 6072 | } |
| 6073 | pEntry = csrLLNext(&pResultList->List, pResultList->pCurEntry, LL_ACCESS_NOLOCK); |
| 6074 | } |
| 6075 | csrLLUnlock(&pResultList->List); |
| 6076 | } |
| 6077 | |
| 6078 | return (status); |
| 6079 | } |
| 6080 | |
| 6081 | |
| 6082 | //Remove the BSS if possible. |
| 6083 | //Return -- TRUE == the BSS is remove. False == Fail to remove it |
| 6084 | //This function is called when list lock is held. Be caution what functions it can call. |
| 6085 | tANI_BOOLEAN csrScanAgeOutBss(tpAniSirGlobal pMac, tCsrScanResult *pResult) |
| 6086 | { |
| 6087 | tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE; |
| 6088 | tANI_U32 i; |
| 6089 | tCsrRoamSession *pSession; |
Padma, Santhosh Kumar | 748b978 | 2014-07-02 12:24:23 +0530 | [diff] [blame] | 6090 | tANI_BOOLEAN isConnBssfound = eANI_BOOLEAN_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6091 | |
| 6092 | for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ ) |
| 6093 | { |
| 6094 | if( CSR_IS_SESSION_VALID( pMac, i ) ) |
| 6095 | { |
| 6096 | pSession = CSR_GET_SESSION( pMac, i ); |
| 6097 | //Not to remove the BSS we are connected to. |
Padma, Santhosh Kumar | 748b978 | 2014-07-02 12:24:23 +0530 | [diff] [blame] | 6098 | if(csrIsConnStateConnectedInfra(pMac, i) && (NULL != pSession->pConnectBssDesc) && |
| 6099 | (csrIsDuplicateBssDescription(pMac, &pResult->Result.BssDescriptor, |
Tushnim Bhattacharyya | 5128d75 | 2013-06-26 23:23:18 -0700 | [diff] [blame] | 6100 | pSession->pConnectBssDesc, NULL, FALSE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6101 | ) |
Padma, Santhosh Kumar | 748b978 | 2014-07-02 12:24:23 +0530 | [diff] [blame] | 6102 | { |
| 6103 | isConnBssfound = eANI_BOOLEAN_TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6104 | break; |
Padma, Santhosh Kumar | 748b978 | 2014-07-02 12:24:23 +0530 | [diff] [blame] | 6105 | } |
| 6106 | } |
| 6107 | } |
| 6108 | |
| 6109 | if( isConnBssfound ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6110 | { |
Padma, Santhosh Kumar | 748b978 | 2014-07-02 12:24:23 +0530 | [diff] [blame] | 6111 | //Reset the counter so that aging out of connected BSS won't hapeen too soon |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6112 | pResult->AgingCount = (tANI_S32)pMac->roam.configParam.agingCount; |
Deepthi Gowri | 4480a3f | 2016-05-18 19:30:17 +0530 | [diff] [blame] | 6113 | pResult->Result.BssDescriptor.nReceivedTime = |
| 6114 | vos_timer_get_system_time(); |
Padma, Santhosh Kumar | 748b978 | 2014-07-02 12:24:23 +0530 | [diff] [blame] | 6115 | |
| 6116 | return (fRet); |
| 6117 | } |
| 6118 | else |
| 6119 | { |
| 6120 | smsLog(pMac, LOGW, "Aging out BSS "MAC_ADDRESS_STR" Channel %d", |
| 6121 | MAC_ADDR_ARRAY(pResult->Result.BssDescriptor.bssId), |
| 6122 | pResult->Result.BssDescriptor.channelId); |
| 6123 | //No need to hold the spin lock because caller should hold the lock for pMac->scan.scanResultList |
| 6124 | if( csrLLRemoveEntry(&pMac->scan.scanResultList, &pResult->Link, LL_ACCESS_NOLOCK) ) |
| 6125 | { |
| 6126 | if (csrIsMacAddressEqual(pMac, |
| 6127 | (tCsrBssid *) pResult->Result.BssDescriptor.bssId, |
| 6128 | (tCsrBssid *) pMac->scan.currentCountryBssid)) |
| 6129 | { |
| 6130 | smsLog(pMac, LOGW, "Aging out 11d BSS "MAC_ADDRESS_STR, |
| 6131 | MAC_ADDR_ARRAY(pResult->Result.BssDescriptor.bssId)); |
| 6132 | pMac->scan.currentCountryRSSI = -128; |
| 6133 | } |
| 6134 | csrFreeScanResultEntry(pMac, pResult); |
| 6135 | fRet = eANI_BOOLEAN_TRUE; |
| 6136 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6137 | } |
| 6138 | |
| 6139 | return (fRet); |
| 6140 | } |
| 6141 | |
| 6142 | |
| 6143 | eHalStatus csrScanAgeResults(tpAniSirGlobal pMac, tSmeGetScanChnRsp *pScanChnInfo) |
| 6144 | { |
| 6145 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 6146 | tListElem *pEntry, *tmpEntry; |
| 6147 | tCsrScanResult *pResult; |
| 6148 | tLimScanChn *pChnInfo; |
| 6149 | tANI_U8 i; |
| 6150 | |
| 6151 | csrLLLock(&pMac->scan.scanResultList); |
| 6152 | for(i = 0; i < pScanChnInfo->numChn; i++) |
| 6153 | { |
| 6154 | pChnInfo = &pScanChnInfo->scanChn[i]; |
| 6155 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK ); |
| 6156 | while( pEntry ) |
| 6157 | { |
| 6158 | tmpEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK); |
| 6159 | pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 6160 | if(pResult->Result.BssDescriptor.channelId == pChnInfo->channelId) |
| 6161 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6162 | if(pResult->AgingCount <= 0) |
| 6163 | { |
| 6164 | smsLog(pMac, LOGW, " age out due to ref count"); |
| 6165 | csrScanAgeOutBss(pMac, pResult); |
| 6166 | } |
Madan Mohan Koyyalamudi | b9d3dcc | 2012-09-28 16:47:50 -0700 | [diff] [blame] | 6167 | else |
| 6168 | { |
| 6169 | pResult->AgingCount--; |
| 6170 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6171 | } |
| 6172 | pEntry = tmpEntry; |
| 6173 | } |
| 6174 | } |
| 6175 | csrLLUnlock(&pMac->scan.scanResultList); |
| 6176 | |
| 6177 | return (status); |
| 6178 | } |
| 6179 | |
Abhishek Singh | c640dbb | 2015-06-08 10:54:17 +0530 | [diff] [blame] | 6180 | eHalStatus csrIbssAgeBss(tpAniSirGlobal pMac) |
| 6181 | { |
| 6182 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 6183 | tListElem *pEntry, *tmpEntry; |
| 6184 | tCsrScanResult *pResult; |
| 6185 | |
| 6186 | csrLLLock(&pMac->scan.scanResultList); |
| 6187 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK ); |
| 6188 | while( pEntry ) |
| 6189 | { |
| 6190 | tmpEntry = csrLLNext(&pMac->scan.scanResultList, |
| 6191 | pEntry, LL_ACCESS_NOLOCK); |
| 6192 | pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 6193 | |
| 6194 | smsLog(pMac, LOGW, FL(" age out due Forced IBSS leave")); |
| 6195 | csrScanAgeOutBss(pMac, pResult); |
| 6196 | pEntry = tmpEntry; |
| 6197 | } |
| 6198 | csrLLUnlock(&pMac->scan.scanResultList); |
| 6199 | |
| 6200 | return (status); |
| 6201 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6202 | |
Abhishek Singh | 72c2f4e | 2016-07-22 11:25:43 +0530 | [diff] [blame] | 6203 | /** |
| 6204 | * csr_remove_bssid_from_scan_list() - remove the bssid from |
| 6205 | * scan list |
| 6206 | * @pMac: mac context. |
| 6207 | * @bssid: bssid to be removed |
| 6208 | * |
| 6209 | * This function remove the given bssid from scan list. |
| 6210 | * |
| 6211 | * Return: void. |
| 6212 | */ |
| 6213 | void csr_remove_bssid_from_scan_list(tpAniSirGlobal pMac, |
| 6214 | tSirMacAddr bssid) |
| 6215 | { |
| 6216 | tListElem *entry,*free_elem; |
| 6217 | tCsrScanResult *bss_desc; |
| 6218 | tDblLinkList *list = &pMac->scan.scanResultList; |
| 6219 | |
| 6220 | csrLLLock(list); |
| 6221 | entry = csrLLPeekHead(list, LL_ACCESS_NOLOCK); |
| 6222 | while (entry != NULL) { |
| 6223 | bss_desc = GET_BASE_ADDR( entry, tCsrScanResult, Link); |
| 6224 | if (vos_mem_compare(bss_desc->Result.BssDescriptor.bssId, |
| 6225 | bssid, sizeof(tSirMacAddr))) { |
| 6226 | free_elem = entry; |
| 6227 | entry = csrLLNext(list, entry, LL_ACCESS_NOLOCK); |
| 6228 | csrLLRemoveEntry(list, free_elem, LL_ACCESS_NOLOCK); |
| 6229 | csrFreeScanResultEntry(pMac, bss_desc); |
| 6230 | smsLog(pMac, LOGW, FL("Removed BSS entry:%pM"), |
| 6231 | bssid); |
| 6232 | continue; |
| 6233 | } |
| 6234 | entry = csrLLNext(list, entry, LL_ACCESS_NOLOCK); |
| 6235 | } |
| 6236 | csrLLUnlock(list); |
| 6237 | } |
| 6238 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6239 | eHalStatus csrSendMBScanReq( tpAniSirGlobal pMac, tANI_U16 sessionId, |
| 6240 | tCsrScanRequest *pScanReq, tScanReqParam *pScanReqParam ) |
| 6241 | { |
| 6242 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 6243 | tSirSmeScanReq *pMsg; |
| 6244 | tANI_U16 msgLen; |
| 6245 | tANI_U8 bssid[WNI_CFG_BSSID_LEN] = {0, 0, 0, 0, 0, 0}; |
| 6246 | tSirScanType scanType = pScanReq->scanType; |
| 6247 | tANI_U32 minChnTime; //in units of milliseconds |
| 6248 | tANI_U32 maxChnTime; //in units of milliseconds |
| 6249 | tANI_U32 i; |
| 6250 | tANI_U8 selfMacAddr[WNI_CFG_BSSID_LEN]; |
| 6251 | tANI_U8 *pSelfMac = NULL; |
| 6252 | |
| 6253 | msgLen = (tANI_U16)(sizeof( tSirSmeScanReq ) - sizeof( pMsg->channelList.channelNumber ) + |
| 6254 | ( sizeof( pMsg->channelList.channelNumber ) * pScanReq->ChannelInfo.numOfChannels )) + |
| 6255 | ( pScanReq->uIEFieldLen ) ; |
| 6256 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6257 | pMsg = vos_mem_malloc(msgLen); |
| 6258 | if ( NULL == pMsg ) |
| 6259 | status = eHAL_STATUS_FAILURE; |
| 6260 | else |
| 6261 | status = eHAL_STATUS_SUCCESS; |
| 6262 | if (HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6263 | { |
| 6264 | do |
| 6265 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6266 | vos_mem_set(pMsg, msgLen, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6267 | pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SCAN_REQ); |
| 6268 | pMsg->length = pal_cpu_to_be16(msgLen); |
| 6269 | //ToDO: Fill in session info when we need to do scan base on session. |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 6270 | if ((pMac->fScanOffload) && (sessionId != CSR_SESSION_ID_INVALID)) |
| 6271 | { |
| 6272 | pMsg->sessionId = sessionId; |
| 6273 | } |
| 6274 | else |
| 6275 | { |
| 6276 | /* if sessionId == CSR_SESSION_ID_INVALID, then send the scan |
| 6277 | request on first available session */ |
| 6278 | pMsg->sessionId = 0; |
| 6279 | } |
| 6280 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6281 | pMsg->transactionId = 0; |
| 6282 | pMsg->dot11mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac, csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode )); |
| 6283 | pMsg->bssType = pal_cpu_to_be32(csrTranslateBsstypeToMacType(pScanReq->BSSType)); |
| 6284 | |
| 6285 | if ( CSR_IS_SESSION_VALID( pMac, sessionId ) ) |
| 6286 | { |
| 6287 | pSelfMac = (tANI_U8 *)&pMac->roam.roamSession[sessionId].selfMacAddr; |
| 6288 | } |
| 6289 | else |
| 6290 | { |
| 6291 | // Since we don't have session for the scanning, we find a valid session. In case we fail to |
| 6292 | // do so, get the WNI_CFG_STA_ID |
| 6293 | for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ ) |
| 6294 | { |
| 6295 | if( CSR_IS_SESSION_VALID( pMac, i ) ) |
| 6296 | { |
| 6297 | pSelfMac = (tANI_U8 *)&pMac->roam.roamSession[i].selfMacAddr; |
| 6298 | break; |
| 6299 | } |
| 6300 | } |
| 6301 | if( CSR_ROAM_SESSION_MAX == i ) |
| 6302 | { |
| 6303 | tANI_U32 len = WNI_CFG_BSSID_LEN; |
| 6304 | pSelfMac = selfMacAddr; |
| 6305 | status = ccmCfgGetStr( pMac, WNI_CFG_STA_ID, pSelfMac, &len ); |
| 6306 | if( !HAL_STATUS_SUCCESS( status ) || |
| 6307 | ( len < WNI_CFG_BSSID_LEN ) ) |
| 6308 | { |
| 6309 | smsLog( pMac, LOGE, FL(" Can not get self MAC address from CFG status = %d"), status ); |
| 6310 | //Force failed status |
| 6311 | status = eHAL_STATUS_FAILURE; |
| 6312 | break; |
| 6313 | } |
| 6314 | } |
| 6315 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6316 | vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, pSelfMac, sizeof(tSirMacAddr)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6317 | |
| 6318 | //sirCopyMacAddr |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6319 | vos_mem_copy((tANI_U8 *)pMsg->bssId, (tANI_U8 *)&pScanReq->bssid, sizeof(tSirMacAddr)); |
| 6320 | if ( vos_mem_compare(pScanReq->bssid, bssid, sizeof(tCsrBssid))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6321 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6322 | vos_mem_set(pMsg->bssId, sizeof(tSirMacAddr), 0xff); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6323 | } |
| 6324 | else |
| 6325 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6326 | vos_mem_copy(pMsg->bssId, pScanReq->bssid, WNI_CFG_BSSID_LEN); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6327 | } |
| 6328 | minChnTime = pScanReq->minChnTime; |
| 6329 | maxChnTime = pScanReq->maxChnTime; |
| 6330 | |
| 6331 | //Verify the scan type first, if the scan is active scan, we need to make sure we |
| 6332 | //are allowed to do so. |
| 6333 | /* if 11d is enabled & we don't see any beacon around, scan type falls |
| 6334 | back to passive. But in BT AMP STA mode we need to send out a |
| 6335 | directed probe*/ |
| 6336 | if( (eSIR_PASSIVE_SCAN != scanType) && (eCSR_SCAN_P2P_DISCOVERY != pScanReq->requestType) |
| 6337 | && (eCSR_BSS_TYPE_WDS_STA != pScanReq->BSSType) |
| 6338 | && (eANI_BOOLEAN_FALSE == pMac->scan.fEnableBypass11d)) |
| 6339 | { |
| 6340 | scanType = pMac->scan.curScanType; |
| 6341 | if(eSIR_PASSIVE_SCAN == pMac->scan.curScanType) |
| 6342 | { |
| 6343 | if(minChnTime < pMac->roam.configParam.nPassiveMinChnTime) |
| 6344 | { |
| 6345 | minChnTime = pMac->roam.configParam.nPassiveMinChnTime; |
| 6346 | } |
| 6347 | if(maxChnTime < pMac->roam.configParam.nPassiveMaxChnTime) |
| 6348 | { |
| 6349 | maxChnTime = pMac->roam.configParam.nPassiveMaxChnTime; |
| 6350 | } |
| 6351 | } |
| 6352 | } |
| 6353 | pMsg->scanType = pal_cpu_to_be32(scanType); |
| 6354 | |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 6355 | pMsg->numSsid = |
| 6356 | (pScanReq->SSIDs.numOfSSIDs < SIR_SCAN_MAX_NUM_SSID) ? |
| 6357 | pScanReq->SSIDs.numOfSSIDs : SIR_SCAN_MAX_NUM_SSID; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6358 | if((pScanReq->SSIDs.numOfSSIDs != 0) && ( eSIR_PASSIVE_SCAN != scanType )) |
| 6359 | { |
Jeff Johnson | 40b59aa | 2013-03-19 14:43:18 -0700 | [diff] [blame] | 6360 | for (i = 0; i < pMsg->numSsid; i++) |
| 6361 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6362 | vos_mem_copy(&pMsg->ssId[i], |
| 6363 | &pScanReq->SSIDs.SSIDList[i].SSID, sizeof(tSirMacSSid)); |
Jeff Johnson | 40b59aa | 2013-03-19 14:43:18 -0700 | [diff] [blame] | 6364 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6365 | } |
| 6366 | else |
| 6367 | { |
| 6368 | //Otherwise we scan all SSID and let the result filter later |
Jeff Johnson | 40b59aa | 2013-03-19 14:43:18 -0700 | [diff] [blame] | 6369 | for (i = 0; i < SIR_SCAN_MAX_NUM_SSID; i++) |
| 6370 | { |
| 6371 | pMsg->ssId[i].length = 0; |
| 6372 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6373 | } |
| 6374 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6375 | pMsg->minChannelTime = pal_cpu_to_be32(minChnTime); |
| 6376 | pMsg->maxChannelTime = pal_cpu_to_be32(maxChnTime); |
Abhishek Singh | add1358 | 2016-09-29 17:00:03 +0530 | [diff] [blame] | 6377 | pMsg->min_chntime_btc_esco = |
| 6378 | pMac->roam.configParam.min_chntime_btc_esco; |
| 6379 | pMsg->max_chntime_btc_esco = |
| 6380 | pMac->roam.configParam.max_chntime_btc_esco; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6381 | //hidden SSID option |
| 6382 | pMsg->hiddenSsid = pScanReqParam->hiddenSsid; |
| 6383 | //rest time |
| 6384 | //pMsg->restTime = pScanReq->restTime; |
| 6385 | pMsg->returnAfterFirstMatch = pScanReqParam->bReturnAfter1stMatch; |
| 6386 | // All the scan results caching will be done by Roaming |
| 6387 | // We do not want LIM to do any caching of scan results, |
| 6388 | // so delete the LIM cache on all scan requests |
| 6389 | pMsg->returnFreshResults = pScanReqParam->freshScan; |
| 6390 | //Always ask for unique result |
| 6391 | pMsg->returnUniqueResults = pScanReqParam->fUniqueResult; |
| 6392 | pMsg->channelList.numChannels = (tANI_U8)pScanReq->ChannelInfo.numOfChannels; |
| 6393 | if(pScanReq->ChannelInfo.numOfChannels) |
| 6394 | { |
| 6395 | //Assuming the channelNumber is tANI_U8 (1 byte) |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6396 | vos_mem_copy(pMsg->channelList.channelNumber, |
| 6397 | pScanReq->ChannelInfo.ChannelList, |
| 6398 | pScanReq->ChannelInfo.numOfChannels); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6399 | } |
| 6400 | |
| 6401 | pMsg->uIEFieldLen = (tANI_U16) pScanReq->uIEFieldLen; |
| 6402 | pMsg->uIEFieldOffset = (tANI_U16)(sizeof( tSirSmeScanReq ) - sizeof( pMsg->channelList.channelNumber ) + |
| 6403 | ( sizeof( pMsg->channelList.channelNumber ) * pScanReq->ChannelInfo.numOfChannels )) ; |
| 6404 | if(pScanReq->uIEFieldLen != 0) |
| 6405 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6406 | vos_mem_copy((tANI_U8 *)pMsg+pMsg->uIEFieldOffset, pScanReq->pIEField, |
| 6407 | pScanReq->uIEFieldLen); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6408 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6409 | pMsg->p2pSearch = pScanReq->p2pSearch; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6410 | |
Madan Mohan Koyyalamudi | 9b87678 | 2012-10-11 16:22:51 -0700 | [diff] [blame] | 6411 | if (pScanReq->requestType == eCSR_SCAN_HO_BG_SCAN) |
| 6412 | { |
| 6413 | pMsg->backgroundScanMode = eSIR_ROAMING_SCAN; |
| 6414 | } |
| 6415 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6416 | }while(0); |
Sushant Kaushik | e0d2cce | 2014-04-10 14:36:07 +0530 | [diff] [blame] | 6417 | smsLog(pMac, LOG1, FL("domainIdCurrent %s (%d) scanType %s (%d)" |
| 6418 | "bssType %s (%d), requestType %s(%d)" |
| 6419 | "numChannels %d"), |
| 6420 | voss_DomainIdtoString(pMac->scan.domainIdCurrent), |
| 6421 | pMac->scan.domainIdCurrent, |
| 6422 | lim_ScanTypetoString(pMsg->scanType), pMsg->scanType, |
| 6423 | lim_BssTypetoString(pMsg->bssType), pMsg->bssType, |
| 6424 | sme_requestTypetoString(pScanReq->requestType), |
| 6425 | pScanReq->requestType, |
| 6426 | pMsg->channelList.numChannels); |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 6427 | |
| 6428 | for(i = 0; i < pMsg->channelList.numChannels; i++) |
| 6429 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6430 | smsLog(pMac, LOG3, FL("channelNumber[%d]= %d"), i, pMsg->channelList.channelNumber[i]); |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 6431 | } |
| 6432 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6433 | if(HAL_STATUS_SUCCESS(status)) |
| 6434 | { |
| 6435 | status = palSendMBMessage(pMac->hHdd, pMsg); |
| 6436 | } |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 6437 | else |
| 6438 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6439 | smsLog( pMac, LOGE, FL(" failed to send down scan req with status = %d"), status ); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6440 | vos_mem_free(pMsg); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6441 | } |
| 6442 | }//Success allocated memory |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 6443 | else |
| 6444 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6445 | smsLog( pMac, LOGE, FL(" memory allocation failure")); |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 6446 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6447 | |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 6448 | if(!HAL_STATUS_SUCCESS(status)) |
| 6449 | { |
| 6450 | smsLog( pMac, LOG1, FL("Failed: SId: %d FirstMatch = %d" |
| 6451 | " UniqueResult = %d freshScan = %d hiddenSsid = %d"), |
| 6452 | sessionId, pScanReqParam->bReturnAfter1stMatch, |
| 6453 | pScanReqParam->fUniqueResult, pScanReqParam->freshScan, |
| 6454 | pScanReqParam->hiddenSsid ); |
Sushant Kaushik | e0d2cce | 2014-04-10 14:36:07 +0530 | [diff] [blame] | 6455 | smsLog( pMac, LOG1, FL("scanType = %s (%d) BSSType = %s (%d) " |
| 6456 | "numOfSSIDs = %d numOfChannels = %d requestType = %s (%d)" |
| 6457 | " p2pSearch = %d\n"), |
| 6458 | lim_ScanTypetoString(pScanReq->scanType), |
| 6459 | pScanReq->scanType, |
| 6460 | lim_BssTypetoString(pScanReq->BSSType), |
| 6461 | pScanReq->BSSType, |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 6462 | pScanReq->SSIDs.numOfSSIDs, |
Sushant Kaushik | e0d2cce | 2014-04-10 14:36:07 +0530 | [diff] [blame] | 6463 | pScanReq->ChannelInfo.numOfChannels, |
| 6464 | sme_requestTypetoString(pScanReq->requestType), |
| 6465 | pScanReq->requestType, |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 6466 | pScanReq->p2pSearch ); |
| 6467 | |
| 6468 | } |
| 6469 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6470 | return( status ); |
| 6471 | } |
| 6472 | |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 6473 | eHalStatus csrSendMBScanResultReq( tpAniSirGlobal pMac, tANI_U32 sessionId, tScanReqParam *pScanReqParam ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6474 | { |
| 6475 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 6476 | tSirSmeScanReq *pMsg; |
| 6477 | tANI_U16 msgLen; |
| 6478 | |
| 6479 | msgLen = (tANI_U16)(sizeof( tSirSmeScanReq )); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6480 | pMsg = vos_mem_malloc(msgLen); |
| 6481 | if ( NULL == pMsg ) |
| 6482 | status = eHAL_STATUS_FAILURE; |
| 6483 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6484 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6485 | vos_mem_set(pMsg, msgLen, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6486 | pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SCAN_REQ); |
| 6487 | pMsg->length = pal_cpu_to_be16(msgLen); |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 6488 | pMsg->sessionId = sessionId; |
| 6489 | pMsg->transactionId = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6490 | pMsg->returnFreshResults = pScanReqParam->freshScan; |
| 6491 | //Always ask for unique result |
| 6492 | pMsg->returnUniqueResults = pScanReqParam->fUniqueResult; |
| 6493 | pMsg->returnAfterFirstMatch = pScanReqParam->bReturnAfter1stMatch; |
| 6494 | status = palSendMBMessage(pMac->hHdd, pMsg); |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 6495 | if (!HAL_STATUS_SUCCESS(status)) |
| 6496 | { |
| 6497 | smsLog( pMac, LOGE, FL(" failed to send down scan req with status = %d\n"), status ); |
| 6498 | } |
| 6499 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6500 | } |
| 6501 | |
| 6502 | return( status ); |
| 6503 | } |
| 6504 | |
| 6505 | |
| 6506 | |
| 6507 | eHalStatus csrScanChannels( tpAniSirGlobal pMac, tSmeCmd *pCommand ) |
| 6508 | { |
| 6509 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 6510 | tScanReqParam scanReq; |
| 6511 | |
| 6512 | do |
| 6513 | { |
| 6514 | scanReq.freshScan = CSR_SME_SCAN_FLAGS_DELETE_CACHE | TRUE; |
| 6515 | scanReq.fUniqueResult = TRUE; |
| 6516 | scanReq.hiddenSsid = SIR_SCAN_NO_HIDDEN_SSID; |
| 6517 | if(eCsrScanForSsid == pCommand->u.scanCmd.reason) |
| 6518 | { |
| 6519 | scanReq.bReturnAfter1stMatch = CSR_SCAN_RETURN_AFTER_FIRST_MATCH; |
| 6520 | } |
| 6521 | else |
| 6522 | { |
| 6523 | // Basically do scan on all channels even for 11D 1st scan case. |
| 6524 | scanReq.bReturnAfter1stMatch = CSR_SCAN_RETURN_AFTER_ALL_CHANNELS; |
| 6525 | } |
| 6526 | if((eCsrScanBgScan == pCommand->u.scanCmd.reason)|| |
| 6527 | (eCsrScanProbeBss == pCommand->u.scanCmd.reason)) |
| 6528 | { |
| 6529 | scanReq.hiddenSsid = SIR_SCAN_HIDDEN_SSID_PE_DECISION; |
| 6530 | } |
| 6531 | |
| 6532 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 6533 | { |
| 6534 | vos_log_scan_pkt_type *pScanLog = NULL; |
| 6535 | |
| 6536 | WLAN_VOS_DIAG_LOG_ALLOC(pScanLog, vos_log_scan_pkt_type, LOG_WLAN_SCAN_C); |
| 6537 | if(pScanLog) |
| 6538 | { |
| 6539 | if(eCsrScanBgScan == pCommand->u.scanCmd.reason || |
| 6540 | eCsrScanProbeBss == pCommand->u.scanCmd.reason) |
| 6541 | { |
| 6542 | pScanLog->eventId = WLAN_SCAN_EVENT_HO_SCAN_REQ; |
| 6543 | } |
| 6544 | else |
| 6545 | { |
| 6546 | if( (eSIR_PASSIVE_SCAN != pCommand->u.scanCmd.u.scanRequest.scanType) && |
| 6547 | (eSIR_PASSIVE_SCAN != pMac->scan.curScanType) ) |
| 6548 | { |
| 6549 | pScanLog->eventId = WLAN_SCAN_EVENT_ACTIVE_SCAN_REQ; |
| 6550 | } |
| 6551 | else |
| 6552 | { |
| 6553 | pScanLog->eventId = WLAN_SCAN_EVENT_PASSIVE_SCAN_REQ; |
| 6554 | } |
| 6555 | } |
| 6556 | pScanLog->minChnTime = (v_U8_t)pCommand->u.scanCmd.u.scanRequest.minChnTime; |
| 6557 | pScanLog->maxChnTime = (v_U8_t)pCommand->u.scanCmd.u.scanRequest.maxChnTime; |
| 6558 | pScanLog->numChannel = (v_U8_t)pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels; |
| 6559 | if(pScanLog->numChannel && (pScanLog->numChannel < VOS_LOG_MAX_NUM_CHANNEL)) |
| 6560 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6561 | vos_mem_copy(pScanLog->channels, |
| 6562 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList, |
| 6563 | pScanLog->numChannel); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6564 | } |
| 6565 | WLAN_VOS_DIAG_LOG_REPORT(pScanLog); |
| 6566 | } |
| 6567 | } |
| 6568 | #endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 6569 | |
Agrawal Ashish | 0b6984f | 2014-04-05 18:35:45 +0530 | [diff] [blame] | 6570 | csrClearVotesForCountryInfo(pMac); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6571 | status = csrSendMBScanReq(pMac, pCommand->sessionId, |
| 6572 | &pCommand->u.scanCmd.u.scanRequest, &scanReq); |
| 6573 | }while(0); |
| 6574 | |
| 6575 | return( status ); |
| 6576 | } |
| 6577 | |
| 6578 | |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 6579 | eHalStatus csrScanRetrieveResult(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6580 | { |
| 6581 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 6582 | tScanReqParam scanReq; |
| 6583 | |
| 6584 | do |
| 6585 | { |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 6586 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 6587 | if (eCsrScanGetLfrResult == pCommand->u.scanCmd.reason) |
| 6588 | { |
| 6589 | //to get the LFR candidates from PE cache |
| 6590 | scanReq.freshScan = SIR_BG_SCAN_RETURN_LFR_CACHED_RESULTS|SIR_BG_SCAN_PURGE_LFR_RESULTS; |
| 6591 | scanReq.fUniqueResult = TRUE; |
| 6592 | scanReq.bReturnAfter1stMatch = CSR_SCAN_RETURN_AFTER_ALL_CHANNELS; |
| 6593 | } |
| 6594 | else |
| 6595 | #endif |
| 6596 | { |
| 6597 | //not a fresh scan |
| 6598 | scanReq.freshScan = CSR_SME_SCAN_FLAGS_DELETE_CACHE; |
| 6599 | scanReq.fUniqueResult = TRUE; |
| 6600 | scanReq.bReturnAfter1stMatch = CSR_SCAN_RETURN_AFTER_ALL_CHANNELS; |
| 6601 | } |
| 6602 | status = csrSendMBScanResultReq(pMac, pCommand->sessionId, &scanReq); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6603 | }while(0); |
| 6604 | |
| 6605 | return (status); |
| 6606 | } |
| 6607 | |
Siddharth Bhal | d8a95e8 | 2015-02-12 20:14:52 +0530 | [diff] [blame] | 6608 | eHalStatus csrProcessMacAddrSpoofCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand ) |
| 6609 | { |
| 6610 | tSirSpoofMacAddrReq *pMsg; |
| 6611 | tANI_U16 msgLen; |
| 6612 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 6613 | do { |
| 6614 | msgLen = sizeof(tSirSpoofMacAddrReq); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6615 | |
Siddharth Bhal | d8a95e8 | 2015-02-12 20:14:52 +0530 | [diff] [blame] | 6616 | pMsg = vos_mem_malloc(msgLen); |
| 6617 | if ( NULL == pMsg ) |
| 6618 | return eHAL_STATUS_FAILURE; |
| 6619 | pMsg->messageType= pal_cpu_to_be16((tANI_U16)eWNI_SME_MAC_SPOOF_ADDR_IND); |
| 6620 | pMsg->length= pal_cpu_to_be16(msgLen); |
| 6621 | // spoof mac address |
| 6622 | vos_mem_copy((tANI_U8 *)pMsg->macAddr, |
| 6623 | (tANI_U8 *)pCommand->u.macAddrSpoofCmd.macAddr, sizeof(tSirMacAddr)); |
| 6624 | status = palSendMBMessage(pMac->hHdd, pMsg); |
| 6625 | } while( 0 ); |
| 6626 | return( status ); |
| 6627 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6628 | |
| 6629 | eHalStatus csrProcessScanCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand ) |
| 6630 | { |
| 6631 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 6632 | tCsrChannelInfo newChannelInfo = {0, NULL}; |
| 6633 | int i, j; |
| 6634 | tANI_U8 *pChannel = NULL; |
| 6635 | tANI_U32 len = 0; |
| 6636 | |
| 6637 | // Transition to Scanning state... |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 6638 | if (!pMac->fScanOffload) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6639 | { |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 6640 | for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ ) |
| 6641 | { |
Abhishek Singh | f52182c | 2016-08-24 11:15:23 +0530 | [diff] [blame] | 6642 | pMac->roam.prev_state[i]= |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 6643 | csrRoamStateChange( pMac, eCSR_ROAMING_STATE_SCANNING, i); |
| 6644 | smsLog( pMac, LOG3, "starting SCAN command from %d state...." |
Abhishek Singh | f52182c | 2016-08-24 11:15:23 +0530 | [diff] [blame] | 6645 | " reason is %d", pMac->roam.prev_state[i], |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 6646 | pCommand->u.scanCmd.reason ); |
| 6647 | } |
| 6648 | } |
| 6649 | else |
| 6650 | { |
Abhishek Singh | f52182c | 2016-08-24 11:15:23 +0530 | [diff] [blame] | 6651 | pMac->roam.prev_state[pCommand->sessionId] = |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 6652 | csrRoamStateChange(pMac, eCSR_ROAMING_STATE_SCANNING, |
| 6653 | pCommand->sessionId); |
| 6654 | smsLog( pMac, LOG3, |
| 6655 | "starting SCAN command from %d state.... reason is %d", |
Abhishek Singh | f52182c | 2016-08-24 11:15:23 +0530 | [diff] [blame] | 6656 | pMac->roam.prev_state[pCommand->sessionId], |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 6657 | pCommand->u.scanCmd.reason ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6658 | } |
| 6659 | |
| 6660 | switch(pCommand->u.scanCmd.reason) |
| 6661 | { |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 6662 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 6663 | case eCsrScanGetLfrResult: |
| 6664 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6665 | case eCsrScanGetResult: |
| 6666 | case eCsrScanForCapsChange: //For cap change, LIM already save BSS description |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 6667 | status = csrScanRetrieveResult(pMac, pCommand); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6668 | break; |
| 6669 | case eCsrScanSetBGScanParam: |
| 6670 | status = csrProcessSetBGScanParam(pMac, pCommand); |
| 6671 | break; |
| 6672 | case eCsrScanBGScanAbort: |
| 6673 | status = csrSetCfgBackgroundScanPeriod(pMac, 0); |
| 6674 | break; |
| 6675 | case eCsrScanBGScanEnable: |
| 6676 | status = csrSetCfgBackgroundScanPeriod(pMac, pMac->roam.configParam.bgScanInterval); |
| 6677 | break; |
| 6678 | case eCsrScanGetScanChnInfo: |
Madan Mohan Koyyalamudi | de1b5bc | 2013-07-12 00:56:04 +0530 | [diff] [blame] | 6679 | status = csrScanGetScanChannelInfo(pMac, pCommand->sessionId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6680 | break; |
| 6681 | case eCsrScanUserRequest: |
| 6682 | if(pMac->roam.configParam.fScanTwice) |
| 6683 | { |
| 6684 | //We scan 2.4 channel twice |
| 6685 | if(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels && |
| 6686 | (NULL != pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList)) |
| 6687 | { |
| 6688 | len = pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels; |
| 6689 | //allocate twice the channel |
Mukul Sharma | a631e89 | 2014-08-28 15:38:51 +0530 | [diff] [blame] | 6690 | newChannelInfo.ChannelList = (tANI_U8 *)vos_mem_malloc(len * 2); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6691 | pChannel = pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList; |
| 6692 | } |
| 6693 | else |
| 6694 | { |
| 6695 | //get the valid channel list to scan all. |
| 6696 | len = sizeof(pMac->roam.validChannelList); |
| 6697 | |
| 6698 | if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len))) |
| 6699 | { |
| 6700 | //allocate twice the channel |
| 6701 | newChannelInfo.ChannelList = (tANI_U8 *)vos_mem_malloc(len * 2); |
| 6702 | pChannel = pMac->roam.validChannelList; |
| 6703 | } |
| 6704 | } |
| 6705 | if(NULL == newChannelInfo.ChannelList) |
| 6706 | { |
| 6707 | newChannelInfo.numOfChannels = 0; |
| 6708 | } |
| 6709 | else |
| 6710 | { |
| 6711 | j = 0; |
| 6712 | for(i = 0; i < len; i++) |
| 6713 | { |
| 6714 | newChannelInfo.ChannelList[j++] = pChannel[i]; |
| 6715 | if(CSR_MAX_24GHz_CHANNEL_NUMBER >= pChannel[i]) |
| 6716 | { |
| 6717 | newChannelInfo.ChannelList[j++] = pChannel[i]; |
| 6718 | } |
| 6719 | } |
| 6720 | if(NULL != pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList) |
| 6721 | { |
| 6722 | //pChannel points to the channellist from the command, free it. |
| 6723 | vos_mem_free(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList); |
James Zmuda | 9ea1edd | 2013-04-18 18:20:54 -0700 | [diff] [blame] | 6724 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6725 | } |
| 6726 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = j; |
| 6727 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = newChannelInfo.ChannelList; |
| 6728 | } |
| 6729 | } //if(pMac->roam.configParam.fScanTwice) |
| 6730 | |
| 6731 | status = csrScanChannels(pMac, pCommand); |
| 6732 | |
| 6733 | break; |
| 6734 | default: |
| 6735 | status = csrScanChannels(pMac, pCommand); |
| 6736 | break; |
| 6737 | } |
| 6738 | |
| 6739 | if(!HAL_STATUS_SUCCESS(status)) |
| 6740 | { |
| 6741 | csrReleaseScanCommand(pMac, pCommand, eCSR_SCAN_FAILURE); |
| 6742 | } |
| 6743 | |
| 6744 | return (status); |
| 6745 | } |
| 6746 | |
| 6747 | |
| 6748 | eHalStatus csrScanSetBGScanparams(tpAniSirGlobal pMac, tCsrBGScanRequest *pScanReq) |
| 6749 | { |
| 6750 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 6751 | tSmeCmd *pCommand = NULL; |
| 6752 | |
| 6753 | if(pScanReq) |
| 6754 | { |
| 6755 | do |
| 6756 | { |
| 6757 | pCommand = csrGetCommandBuffer(pMac); |
| 6758 | if(!pCommand) |
| 6759 | { |
| 6760 | status = eHAL_STATUS_RESOURCES; |
| 6761 | break; |
| 6762 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6763 | vos_mem_set(&pCommand->u.scanCmd, sizeof(tScanCmd), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6764 | pCommand->command = eSmeCommandScan; |
| 6765 | pCommand->u.scanCmd.reason = eCsrScanSetBGScanParam; |
| 6766 | pCommand->u.scanCmd.callback = NULL; |
| 6767 | pCommand->u.scanCmd.pContext = NULL; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6768 | vos_mem_copy(&pCommand->u.scanCmd.u.bgScanRequest, pScanReq, sizeof(tCsrBGScanRequest)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6769 | //we have to do the follow |
| 6770 | if(pScanReq->ChannelInfo.numOfChannels == 0) |
| 6771 | { |
| 6772 | pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList = NULL; |
| 6773 | } |
| 6774 | else |
| 6775 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6776 | pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList |
| 6777 | = vos_mem_malloc(pScanReq->ChannelInfo.numOfChannels); |
| 6778 | if ( NULL != pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6779 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6780 | vos_mem_copy(pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList, |
| 6781 | pScanReq->ChannelInfo.ChannelList, |
| 6782 | pScanReq->ChannelInfo.numOfChannels); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6783 | } |
| 6784 | else |
| 6785 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6786 | smsLog(pMac, LOGE, FL("ran out of memory")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6787 | csrReleaseCommandScan(pMac, pCommand); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6788 | return eHAL_STATUS_FAILURE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6789 | } |
| 6790 | } |
| 6791 | |
| 6792 | //scan req for SSID |
| 6793 | if(pScanReq->SSID.length) |
| 6794 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6795 | vos_mem_copy(pCommand->u.scanCmd.u.bgScanRequest.SSID.ssId, |
| 6796 | pScanReq->SSID.ssId, pScanReq->SSID.length); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6797 | pCommand->u.scanCmd.u.bgScanRequest.SSID.length = pScanReq->SSID.length; |
| 6798 | |
| 6799 | } |
| 6800 | pCommand->u.scanCmd.u.bgScanRequest.maxChnTime= pScanReq->maxChnTime; |
| 6801 | pCommand->u.scanCmd.u.bgScanRequest.minChnTime = pScanReq->minChnTime; |
| 6802 | pCommand->u.scanCmd.u.bgScanRequest.scanInterval = pScanReq->scanInterval; |
| 6803 | |
| 6804 | |
| 6805 | status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE); |
| 6806 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 6807 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6808 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6809 | csrReleaseCommandScan( pMac, pCommand ); |
| 6810 | break; |
| 6811 | } |
| 6812 | }while(0); |
| 6813 | } |
| 6814 | |
| 6815 | return (status); |
| 6816 | } |
| 6817 | |
| 6818 | eHalStatus csrScanBGScanAbort( tpAniSirGlobal pMac ) |
| 6819 | { |
| 6820 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 6821 | tSmeCmd *pCommand = NULL; |
| 6822 | |
| 6823 | do |
| 6824 | { |
| 6825 | pCommand = csrGetCommandBuffer(pMac); |
| 6826 | if(!pCommand) |
| 6827 | { |
| 6828 | status = eHAL_STATUS_RESOURCES; |
| 6829 | break; |
| 6830 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6831 | vos_mem_set(&pCommand->u.scanCmd, sizeof(tScanCmd), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6832 | pCommand->command = eSmeCommandScan; |
| 6833 | pCommand->u.scanCmd.reason = eCsrScanBGScanAbort; |
| 6834 | pCommand->u.scanCmd.callback = NULL; |
| 6835 | pCommand->u.scanCmd.pContext = NULL; |
| 6836 | status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE); |
| 6837 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 6838 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6839 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6840 | csrReleaseCommandScan( pMac, pCommand ); |
| 6841 | break; |
| 6842 | } |
| 6843 | }while(0); |
| 6844 | |
| 6845 | return (status); |
| 6846 | } |
| 6847 | |
| 6848 | |
| 6849 | //This will enable the background scan with the non-zero interval |
| 6850 | eHalStatus csrScanBGScanEnable(tpAniSirGlobal pMac) |
| 6851 | { |
| 6852 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 6853 | tSmeCmd *pCommand = NULL; |
| 6854 | |
| 6855 | if(pMac->roam.configParam.bgScanInterval) |
| 6856 | { |
| 6857 | do |
| 6858 | { |
| 6859 | pCommand = csrGetCommandBuffer(pMac); |
| 6860 | if(!pCommand) |
| 6861 | { |
| 6862 | status = eHAL_STATUS_RESOURCES; |
| 6863 | break; |
| 6864 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6865 | vos_mem_set(&pCommand->u.scanCmd, sizeof(tScanCmd), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6866 | pCommand->command = eSmeCommandScan; |
| 6867 | pCommand->u.scanCmd.reason = eCsrScanBGScanEnable; |
| 6868 | pCommand->u.scanCmd.callback = NULL; |
| 6869 | pCommand->u.scanCmd.pContext = NULL; |
| 6870 | status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE); |
| 6871 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 6872 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6873 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6874 | csrReleaseCommandScan( pMac, pCommand ); |
| 6875 | break; |
| 6876 | } |
| 6877 | }while(0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6878 | } |
| 6879 | else |
| 6880 | { |
Sushant Kaushik | b8dbb3f | 2015-04-29 17:03:37 +0530 | [diff] [blame] | 6881 | smsLog(pMac, LOGE, FL("cannot continue because the bgscan interval is 0")); |
| 6882 | status = eHAL_STATUS_INVALID_PARAMETER; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6883 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6884 | return (status); |
| 6885 | } |
| 6886 | |
| 6887 | |
| 6888 | eHalStatus csrScanCopyRequest(tpAniSirGlobal pMac, tCsrScanRequest *pDstReq, tCsrScanRequest *pSrcReq) |
| 6889 | { |
| 6890 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 6891 | tANI_U32 len = sizeof(pMac->roam.validChannelList); |
| 6892 | tANI_U32 index = 0; |
| 6893 | tANI_U32 new_index = 0; |
Manjunathappa Prakash | de7b2a5 | 2014-02-28 16:59:03 -0800 | [diff] [blame] | 6894 | eNVChannelEnabledType NVchannel_state; |
Arif Hussain | 6af3862 | 2014-03-12 12:39:57 -0700 | [diff] [blame] | 6895 | tANI_U8 ch144_support = 0; |
| 6896 | |
| 6897 | ch144_support = WDA_getFwWlanFeatCaps(WLAN_CH144); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6898 | |
| 6899 | do |
| 6900 | { |
| 6901 | status = csrScanFreeRequest(pMac, pDstReq); |
| 6902 | if(HAL_STATUS_SUCCESS(status)) |
| 6903 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6904 | vos_mem_copy(pDstReq, pSrcReq, sizeof(tCsrScanRequest)); |
Gopichand Nakkala | c7b1d3e | 2012-12-31 14:07:19 -0800 | [diff] [blame] | 6905 | /* Re-initialize the pointers to NULL since we did a copy */ |
| 6906 | pDstReq->pIEField = NULL; |
| 6907 | pDstReq->ChannelInfo.ChannelList = NULL; |
| 6908 | pDstReq->SSIDs.SSIDList = NULL; |
| 6909 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6910 | if(pSrcReq->uIEFieldLen == 0) |
| 6911 | { |
| 6912 | pDstReq->pIEField = NULL; |
| 6913 | } |
| 6914 | else |
| 6915 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6916 | pDstReq->pIEField = vos_mem_malloc(pSrcReq->uIEFieldLen); |
| 6917 | if ( NULL == pDstReq->pIEField ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6918 | { |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 6919 | status = eHAL_STATUS_FAILURE; |
| 6920 | smsLog(pMac, LOGE, FL("No memory for scanning IE fields")); |
| 6921 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6922 | } |
| 6923 | else |
| 6924 | { |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 6925 | status = eHAL_STATUS_SUCCESS; |
| 6926 | vos_mem_copy(pDstReq->pIEField, pSrcReq->pIEField, |
| 6927 | pSrcReq->uIEFieldLen); |
| 6928 | pDstReq->uIEFieldLen = pSrcReq->uIEFieldLen; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6929 | } |
| 6930 | }//Allocate memory for IE field |
| 6931 | { |
| 6932 | if(pSrcReq->ChannelInfo.numOfChannels == 0) |
| 6933 | { |
| 6934 | pDstReq->ChannelInfo.ChannelList = NULL; |
| 6935 | pDstReq->ChannelInfo.numOfChannels = 0; |
| 6936 | } |
| 6937 | else |
| 6938 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6939 | pDstReq->ChannelInfo.ChannelList = vos_mem_malloc( |
| 6940 | pSrcReq->ChannelInfo.numOfChannels |
| 6941 | * sizeof(*pDstReq->ChannelInfo.ChannelList)); |
| 6942 | if ( NULL == pDstReq->ChannelInfo.ChannelList ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6943 | { |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 6944 | status = eHAL_STATUS_FAILURE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6945 | pDstReq->ChannelInfo.numOfChannels = 0; |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 6946 | smsLog(pMac, LOGE, FL("No memory for scanning Channel" |
| 6947 | " List")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6948 | break; |
| 6949 | } |
| 6950 | |
| 6951 | if((pSrcReq->scanType == eSIR_PASSIVE_SCAN) && (pSrcReq->requestType == eCSR_SCAN_REQUEST_11D_SCAN)) |
| 6952 | { |
| 6953 | for ( index = 0; index < pSrcReq->ChannelInfo.numOfChannels ; index++ ) |
| 6954 | { |
Arif Hussain | 6af3862 | 2014-03-12 12:39:57 -0700 | [diff] [blame] | 6955 | /* Skip CH 144 if firmware support not present */ |
| 6956 | if (pSrcReq->ChannelInfo.ChannelList[index] == 144 && !ch144_support) |
| 6957 | continue; |
Agarwal Ashish | 8bd53ae | 2015-06-12 18:03:45 +0530 | [diff] [blame] | 6958 | /* Skip channel 12 and 13 when FCC constraint is true */ |
| 6959 | if ((pMac->scan.fcc_constraint) && |
| 6960 | ((pSrcReq->ChannelInfo.ChannelList[index] ==12) || |
| 6961 | (pSrcReq->ChannelInfo.ChannelList[index] ==13))) |
| 6962 | { |
| 6963 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, |
| 6964 | FL("Ignoring channel : %d "), |
| 6965 | pSrcReq->ChannelInfo.ChannelList[index]); |
| 6966 | continue; |
| 6967 | } |
Arif Hussain | 6af3862 | 2014-03-12 12:39:57 -0700 | [diff] [blame] | 6968 | |
Manjunathappa Prakash | de7b2a5 | 2014-02-28 16:59:03 -0800 | [diff] [blame] | 6969 | NVchannel_state = vos_nv_getChannelEnabledState( |
| 6970 | pSrcReq->ChannelInfo.ChannelList[index]); |
| 6971 | if ((NV_CHANNEL_ENABLE == NVchannel_state) || |
| 6972 | (NV_CHANNEL_DFS == NVchannel_state)) |
| 6973 | { |
| 6974 | pDstReq->ChannelInfo.ChannelList[new_index] = |
| 6975 | pSrcReq->ChannelInfo.ChannelList[index]; |
| 6976 | new_index++; |
| 6977 | } |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 6978 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6979 | pDstReq->ChannelInfo.numOfChannels = new_index; |
| 6980 | } |
| 6981 | else if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len))) |
| 6982 | { |
| 6983 | new_index = 0; |
| 6984 | pMac->roam.numValidChannels = len; |
c_hpothu | 0d5a735 | 2014-03-22 12:30:25 +0530 | [diff] [blame] | 6985 | |
Deepthi Gowri | ecc9335 | 2016-11-09 16:58:47 +0530 | [diff] [blame] | 6986 | /* Since in CsrScanRequest,value of pMac->scan. |
| 6987 | * nextScanID is incremented before calling |
| 6988 | * CsrScanCopyRequest, as a result pMac->scan. |
| 6989 | * nextScanID is equal to ONE for the first scan. |
| 6990 | * If number of channels is less than max chan |
| 6991 | * for dwell time no need to skip dfs in first |
| 6992 | * scan as anyway few channels will be scanned |
| 6993 | * and it will not take much time to display |
| 6994 | * results on GUI. |
| 6995 | */ |
| 6996 | if (((pSrcReq->ChannelInfo.numOfChannels >= |
| 6997 | pMac->roam.configParam. |
| 6998 | max_chan_for_dwell_time_cfg) && |
| 6999 | (pMac->roam.configParam. |
| 7000 | initialScanSkipDFSCh && |
| 7001 | 1 == pMac->scan.nextScanID)) || |
| 7002 | (pMac->miracast_mode)) |
c_hpothu | 0d5a735 | 2014-03-22 12:30:25 +0530 | [diff] [blame] | 7003 | { |
Deepthi Gowri | ecc9335 | 2016-11-09 16:58:47 +0530 | [diff] [blame] | 7004 | smsLog(pMac, LOG1, |
| 7005 | FL("Initial scan, scan only non-DFS channels")); |
c_hpothu | 0d5a735 | 2014-03-22 12:30:25 +0530 | [diff] [blame] | 7006 | |
Deepthi Gowri | ecc9335 | 2016-11-09 16:58:47 +0530 | [diff] [blame] | 7007 | for (index = 0; index < pSrcReq->ChannelInfo. |
| 7008 | numOfChannels ; index++ ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7009 | { |
Deepthi Gowri | ecc9335 | 2016-11-09 16:58:47 +0530 | [diff] [blame] | 7010 | if((csrRoamIsValidChannel(pMac, |
| 7011 | pSrcReq->ChannelInfo. |
| 7012 | ChannelList[index]))) |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 7013 | { |
Deepthi Gowri | ecc9335 | 2016-11-09 16:58:47 +0530 | [diff] [blame] | 7014 | /*Skiipping DFS Channels for 1st scan */ |
| 7015 | if(NV_CHANNEL_DFS == |
| 7016 | vos_nv_getChannelEnabledState( |
| 7017 | pSrcReq->ChannelInfo. |
| 7018 | ChannelList[index])) |
| 7019 | continue ; |
Madan Mohan Koyyalamudi | c5992c9 | 2012-11-15 16:40:57 -0800 | [diff] [blame] | 7020 | |
Deepthi Gowri | ecc9335 | 2016-11-09 16:58:47 +0530 | [diff] [blame] | 7021 | pDstReq->ChannelInfo. |
| 7022 | ChannelList[new_index] = |
| 7023 | pSrcReq->ChannelInfo.ChannelList[index]; |
| 7024 | new_index++; |
| 7025 | |
| 7026 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7027 | } |
Deepthi Gowri | ecc9335 | 2016-11-09 16:58:47 +0530 | [diff] [blame] | 7028 | pMac->roam.configParam.initialScanSkipDFSCh = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7029 | } |
Deepthi Gowri | ecc9335 | 2016-11-09 16:58:47 +0530 | [diff] [blame] | 7030 | else |
| 7031 | csrValidateScanChannels(pMac, pDstReq, pSrcReq, |
Nishank Aggarwal | 42f7650 | 2017-02-16 12:00:19 +0530 | [diff] [blame] | 7032 | &new_index, ch144_support); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7033 | pDstReq->ChannelInfo.numOfChannels = new_index; |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 7034 | #ifdef FEATURE_WLAN_LFR |
Deepthi Gowri | ecc9335 | 2016-11-09 16:58:47 +0530 | [diff] [blame] | 7035 | if ( ( ( eCSR_SCAN_HO_BG_SCAN == |
| 7036 | pSrcReq->requestType ) || |
| 7037 | ( eCSR_SCAN_P2P_DISCOVERY == |
| 7038 | pSrcReq->requestType ) ) && |
| 7039 | ( 0 == pDstReq->ChannelInfo.numOfChannels ) ) |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 7040 | { |
| 7041 | /* |
| 7042 | * No valid channels found in the request. |
| 7043 | * Only perform scan on the channels passed |
Abhishek Singh | 2ec36ab | 2014-08-07 16:14:25 +0530 | [diff] [blame] | 7044 | * pSrcReq if it is a eCSR_SCAN_HO_BG_SCAN or |
| 7045 | * eCSR_SCAN_P2P_DISCOVERY. |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 7046 | * Passing 0 to LIM will trigger a scan on |
| 7047 | * all valid channels which is not desirable. |
| 7048 | */ |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 7049 | smsLog(pMac, LOGE, FL(" no valid channels found" |
Deepthi Gowri | ecc9335 | 2016-11-09 16:58:47 +0530 | [diff] [blame] | 7050 | " (request=%d)"), pSrcReq->requestType); |
| 7051 | for ( index = 0; index < pSrcReq->ChannelInfo. |
| 7052 | numOfChannels ; index++ ) |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 7053 | { |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 7054 | smsLog(pMac, LOGE, FL("pSrcReq index=%d" |
Deepthi Gowri | ecc9335 | 2016-11-09 16:58:47 +0530 | [diff] [blame] | 7055 | " channel=%d"), index, |
| 7056 | pSrcReq->ChannelInfo.ChannelList[index]); |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 7057 | } |
| 7058 | status = eHAL_STATUS_FAILURE; |
| 7059 | break; |
Deepthi Gowri | ecc9335 | 2016-11-09 16:58:47 +0530 | [diff] [blame] | 7060 | } |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 7061 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7062 | } |
| 7063 | else |
| 7064 | { |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 7065 | smsLog(pMac, LOGE, FL("Couldn't get the valid Channel" |
| 7066 | " List, keeping requester's list")); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7067 | vos_mem_copy(pDstReq->ChannelInfo.ChannelList, |
| 7068 | pSrcReq->ChannelInfo.ChannelList, |
| 7069 | pSrcReq->ChannelInfo.numOfChannels |
Deepthi Gowri | ecc9335 | 2016-11-09 16:58:47 +0530 | [diff] [blame] | 7070 | * sizeof(*pDstReq->ChannelInfo.ChannelList)); |
| 7071 | pDstReq->ChannelInfo.numOfChannels = |
| 7072 | pSrcReq->ChannelInfo.numOfChannels; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7073 | } |
| 7074 | }//Allocate memory for Channel List |
| 7075 | } |
| 7076 | if(pSrcReq->SSIDs.numOfSSIDs == 0) |
| 7077 | { |
| 7078 | pDstReq->SSIDs.numOfSSIDs = 0; |
| 7079 | pDstReq->SSIDs.SSIDList = NULL; |
| 7080 | } |
| 7081 | else |
| 7082 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7083 | pDstReq->SSIDs.SSIDList = vos_mem_malloc( |
| 7084 | pSrcReq->SSIDs.numOfSSIDs * sizeof(*pDstReq->SSIDs.SSIDList)); |
| 7085 | if ( NULL == pDstReq->SSIDs.SSIDList ) |
| 7086 | status = eHAL_STATUS_FAILURE; |
| 7087 | else |
| 7088 | status = eHAL_STATUS_SUCCESS; |
| 7089 | if (HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7090 | { |
| 7091 | pDstReq->SSIDs.numOfSSIDs = pSrcReq->SSIDs.numOfSSIDs; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7092 | vos_mem_copy(pDstReq->SSIDs.SSIDList, |
| 7093 | pSrcReq->SSIDs.SSIDList, |
| 7094 | pSrcReq->SSIDs.numOfSSIDs * sizeof(*pDstReq->SSIDs.SSIDList)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7095 | } |
| 7096 | else |
| 7097 | { |
| 7098 | pDstReq->SSIDs.numOfSSIDs = 0; |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 7099 | smsLog(pMac, LOGE, FL("No memory for scanning SSID List")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7100 | break; |
| 7101 | } |
| 7102 | }//Allocate memory for SSID List |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7103 | pDstReq->p2pSearch = pSrcReq->p2pSearch; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7104 | pDstReq->skipDfsChnlInP2pSearch = pSrcReq->skipDfsChnlInP2pSearch; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7105 | |
| 7106 | } |
| 7107 | }while(0); |
| 7108 | |
| 7109 | if(!HAL_STATUS_SUCCESS(status)) |
| 7110 | { |
| 7111 | csrScanFreeRequest(pMac, pDstReq); |
| 7112 | } |
| 7113 | |
| 7114 | return (status); |
| 7115 | } |
| 7116 | |
| 7117 | |
| 7118 | eHalStatus csrScanFreeRequest(tpAniSirGlobal pMac, tCsrScanRequest *pReq) |
| 7119 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7120 | |
| 7121 | if(pReq->ChannelInfo.ChannelList) |
| 7122 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7123 | vos_mem_free(pReq->ChannelInfo.ChannelList); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7124 | pReq->ChannelInfo.ChannelList = NULL; |
| 7125 | } |
| 7126 | pReq->ChannelInfo.numOfChannels = 0; |
| 7127 | if(pReq->pIEField) |
| 7128 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7129 | vos_mem_free(pReq->pIEField); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7130 | pReq->pIEField = NULL; |
| 7131 | } |
| 7132 | pReq->uIEFieldLen = 0; |
| 7133 | if(pReq->SSIDs.SSIDList) |
| 7134 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7135 | vos_mem_free(pReq->SSIDs.SSIDList); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7136 | pReq->SSIDs.SSIDList = NULL; |
| 7137 | } |
| 7138 | pReq->SSIDs.numOfSSIDs = 0; |
| 7139 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7140 | return eHAL_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7141 | } |
| 7142 | |
| 7143 | |
| 7144 | void csrScanCallCallback(tpAniSirGlobal pMac, tSmeCmd *pCommand, eCsrScanStatus scanStatus) |
| 7145 | { |
| 7146 | if(pCommand->u.scanCmd.callback) |
| 7147 | { |
Ratheesh S P | ece1f83 | 2015-07-25 15:50:25 +0530 | [diff] [blame] | 7148 | if (pCommand->u.scanCmd.abortScanIndication){ |
Kapil Gupta | c46b754 | 2016-10-25 13:03:20 +0530 | [diff] [blame] | 7149 | if ((pCommand->u.scanCmd.reason != eCsrScanForSsid) || |
| 7150 | (scanStatus != eCSR_SCAN_SUCCESS)) { |
| 7151 | smsLog( pMac, LOG1, FL("scanDone due to abort")); |
| 7152 | scanStatus = eCSR_SCAN_ABORT; |
| 7153 | } |
Ratheesh S P | ece1f83 | 2015-07-25 15:50:25 +0530 | [diff] [blame] | 7154 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7155 | pCommand->u.scanCmd.callback(pMac, pCommand->u.scanCmd.pContext, pCommand->u.scanCmd.scanID, scanStatus); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7156 | } else { |
Kapil Gupta | c46b754 | 2016-10-25 13:03:20 +0530 | [diff] [blame] | 7157 | smsLog(pMac, LOG2, |
| 7158 | FL("Callback NULL cmd reason %d"), |
| 7159 | pCommand->u.scanCmd.reason); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7160 | } |
| 7161 | } |
| 7162 | |
| 7163 | |
| 7164 | void csrScanStopTimers(tpAniSirGlobal pMac) |
| 7165 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7166 | csrScanStopIdleScanTimer(pMac); |
| 7167 | csrScanStopGetResultTimer(pMac); |
| 7168 | } |
| 7169 | |
| 7170 | |
| 7171 | eHalStatus csrScanStartGetResultTimer(tpAniSirGlobal pMac) |
| 7172 | { |
| 7173 | eHalStatus status; |
| 7174 | |
| 7175 | if(pMac->scan.fScanEnable) |
| 7176 | { |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 7177 | status = vos_timer_start(&pMac->scan.hTimerGetResult, CSR_SCAN_GET_RESULT_INTERVAL/PAL_TIMER_TO_MS_UNIT); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7178 | } |
| 7179 | else |
| 7180 | { |
| 7181 | status = eHAL_STATUS_FAILURE; |
| 7182 | } |
| 7183 | |
| 7184 | return (status); |
| 7185 | } |
| 7186 | |
| 7187 | |
| 7188 | eHalStatus csrScanStopGetResultTimer(tpAniSirGlobal pMac) |
| 7189 | { |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 7190 | return (vos_timer_stop(&pMac->scan.hTimerGetResult)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7191 | } |
| 7192 | |
| 7193 | |
| 7194 | void csrScanGetResultTimerHandler(void *pv) |
| 7195 | { |
| 7196 | tpAniSirGlobal pMac = PMAC_STRUCT( pv ); |
| 7197 | |
| 7198 | csrScanRequestResult(pMac); |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 7199 | |
| 7200 | vos_timer_start(&pMac->scan.hTimerGetResult, CSR_SCAN_GET_RESULT_INTERVAL/PAL_TIMER_TO_MS_UNIT); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7201 | } |
| 7202 | |
Padma, Santhosh Kumar | 3618335 | 2016-11-08 17:48:34 +0530 | [diff] [blame] | 7203 | |
| 7204 | void csr_handle_disable_scan(void *pv) |
| 7205 | { |
| 7206 | tpAniSirGlobal mac = PMAC_STRUCT(pv); |
| 7207 | |
| 7208 | if (mac->scan.disable_scan_during_sco_timer_info.callback) |
| 7209 | mac->scan.disable_scan_during_sco_timer_info.callback( |
| 7210 | mac, |
| 7211 | mac->scan.disable_scan_during_sco_timer_info.dev, |
| 7212 | mac->scan.disable_scan_during_sco_timer_info.scan_id, |
| 7213 | eHAL_STATUS_SUCCESS); |
| 7214 | else |
| 7215 | smsLog(mac, LOGE, FL("Callback is NULL")); |
| 7216 | } |
| 7217 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7218 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 7219 | static void csrStaApConcTimerHandler(void *pv) |
| 7220 | { |
| 7221 | tpAniSirGlobal pMac = PMAC_STRUCT( pv ); |
| 7222 | tListElem *pEntry; |
| 7223 | tSmeCmd *pScanCmd; |
| 7224 | |
| 7225 | csrLLLock(&pMac->scan.scanCmdPendingList); |
| 7226 | |
| 7227 | if ( NULL != ( pEntry = csrLLPeekHead( &pMac->scan.scanCmdPendingList, LL_ACCESS_NOLOCK) ) ) |
| 7228 | { |
| 7229 | tCsrScanRequest scanReq; |
| 7230 | tSmeCmd *pSendScanCmd = NULL; |
| 7231 | tANI_U8 numChn = 0; |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 7232 | tANI_U8 nNumChanCombinedConc = 0; |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 7233 | tANI_U8 i, j; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7234 | tCsrChannelInfo *pChnInfo = &scanReq.ChannelInfo; |
| 7235 | tANI_U8 channelToScan[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 7236 | eHalStatus status; |
| 7237 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7238 | pScanCmd = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 7239 | numChn = pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels; |
Madan Mohan Koyyalamudi | d671358 | 2012-11-09 16:56:56 -0800 | [diff] [blame] | 7240 | |
| 7241 | /* if any session is connected and the number of channels to scan is |
| 7242 | * greater than 1 then split the scan into multiple scan operations |
| 7243 | * on each individual channel else continue to perform scan on all |
| 7244 | * specified channels */ |
Madan Mohan Koyyalamudi | 48081ef | 2012-12-04 16:49:55 -0800 | [diff] [blame] | 7245 | |
| 7246 | /* split scan if number of channels to scan is greater than 1 and |
| 7247 | * any one of the following: |
| 7248 | * - STA session is connected and the scan is not a P2P search |
| 7249 | * - any P2P session is connected |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 7250 | * Do not split scans if no concurrent infra connections are |
| 7251 | * active and if the scan is a BG scan triggered by LFR (OR) |
| 7252 | * any scan if LFR is in the middle of a BG scan. Splitting |
| 7253 | * the scan is delaying the time it takes for LFR to find |
| 7254 | * candidates and resulting in disconnects. |
Madan Mohan Koyyalamudi | 48081ef | 2012-12-04 16:49:55 -0800 | [diff] [blame] | 7255 | */ |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 7256 | |
| 7257 | if((csrIsStaSessionConnected(pMac) && |
| 7258 | !csrIsP2pSessionConnected(pMac))) |
| 7259 | { |
| 7260 | nNumChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc; |
| 7261 | } |
| 7262 | else if(csrIsP2pSessionConnected(pMac)) |
| 7263 | { |
| 7264 | nNumChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc; |
| 7265 | } |
| 7266 | |
| 7267 | if ( (numChn > nNumChanCombinedConc) && |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 7268 | ((csrIsStaSessionConnected(pMac) && |
| 7269 | #ifdef FEATURE_WLAN_LFR |
| 7270 | (csrIsConcurrentInfraConnected(pMac) || |
| 7271 | ((pScanCmd->u.scanCmd.reason != eCsrScanBgScan) && |
| 7272 | (pMac->roam.neighborRoamInfo.neighborRoamState != |
| 7273 | eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN))) && |
| 7274 | #endif |
| 7275 | (pScanCmd->u.scanCmd.u.scanRequest.p2pSearch != 1)) || |
Madan Mohan Koyyalamudi | 48081ef | 2012-12-04 16:49:55 -0800 | [diff] [blame] | 7276 | (csrIsP2pSessionConnected(pMac)))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7277 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7278 | vos_mem_set(&scanReq, sizeof(tCsrScanRequest), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7279 | |
| 7280 | pSendScanCmd = csrGetCommandBuffer(pMac); //optimize this to use 2 command buffer only |
| 7281 | if (!pSendScanCmd) |
| 7282 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7283 | smsLog( pMac, LOGE, FL(" Failed to get Queue command buffer") ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7284 | csrLLUnlock(&pMac->scan.scanCmdPendingList); |
| 7285 | return; |
| 7286 | } |
| 7287 | pSendScanCmd->command = pScanCmd->command; |
| 7288 | pSendScanCmd->sessionId = pScanCmd->sessionId; |
| 7289 | pSendScanCmd->u.scanCmd.callback = NULL; |
| 7290 | pSendScanCmd->u.scanCmd.pContext = pScanCmd->u.scanCmd.pContext; |
| 7291 | pSendScanCmd->u.scanCmd.reason = pScanCmd->u.scanCmd.reason; |
| 7292 | pSendScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around |
| 7293 | |
Madan Mohan Koyyalamudi | af2a8b9 | 2012-10-09 14:58:07 -0700 | [diff] [blame] | 7294 | /* First copy all the parameters to local variable of scan request */ |
| 7295 | csrScanCopyRequest(pMac, &scanReq, &pScanCmd->u.scanCmd.u.scanRequest); |
| 7296 | |
| 7297 | /* Now modify the elements of local var scan request required to be modified for split scan */ |
Madan Mohan Koyyalamudi | 0c626f3 | 2012-11-30 15:10:25 -0800 | [diff] [blame] | 7298 | if(scanReq.ChannelInfo.ChannelList != NULL) |
| 7299 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7300 | vos_mem_free(scanReq.ChannelInfo.ChannelList); |
Madan Mohan Koyyalamudi | 0c626f3 | 2012-11-30 15:10:25 -0800 | [diff] [blame] | 7301 | scanReq.ChannelInfo.ChannelList = NULL; |
| 7302 | } |
| 7303 | |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 7304 | pChnInfo->numOfChannels = nNumChanCombinedConc; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7305 | vos_mem_copy(&channelToScan[0], |
| 7306 | &pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[0], |
| 7307 | pChnInfo->numOfChannels * sizeof(tANI_U8));//just send one channel |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7308 | pChnInfo->ChannelList = &channelToScan[0]; |
| 7309 | |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 7310 | for (i = 0, j = nNumChanCombinedConc; i < (numChn-nNumChanCombinedConc); i++, j++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7311 | { |
| 7312 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[i] = |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 7313 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[j]; //Move all the channels one step |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7314 | } |
| 7315 | |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 7316 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = numChn - nNumChanCombinedConc; //reduce outstanding # of channels to be scanned |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7317 | |
| 7318 | scanReq.BSSType = eCSR_BSS_TYPE_ANY; |
c_hpothu | dbefd3e | 2014-04-28 15:59:47 +0530 | [diff] [blame] | 7319 | |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 7320 | //Use concurrency values for min/maxChnTime. |
| 7321 | //We know csrIsAnySessionConnected(pMac) returns TRUE here |
| 7322 | csrSetDefaultScanTiming(pMac, scanReq.scanType, &scanReq); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7323 | |
| 7324 | status = csrScanCopyRequest(pMac, &pSendScanCmd->u.scanCmd.u.scanRequest, &scanReq); |
| 7325 | if(!HAL_STATUS_SUCCESS(status)) |
| 7326 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7327 | smsLog( pMac, LOGE, FL(" Failed to get copy csrScanRequest = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7328 | csrLLUnlock(&pMac->scan.scanCmdPendingList); |
| 7329 | return; |
Madan Mohan Koyyalamudi | 0c626f3 | 2012-11-30 15:10:25 -0800 | [diff] [blame] | 7330 | } |
| 7331 | /* Clean the local scan variable */ |
| 7332 | scanReq.ChannelInfo.ChannelList = NULL; |
| 7333 | scanReq.ChannelInfo.numOfChannels = 0; |
| 7334 | csrScanFreeRequest(pMac, &scanReq); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7335 | } |
| 7336 | else |
Madan Mohan Koyyalamudi | d671358 | 2012-11-09 16:56:56 -0800 | [diff] [blame] | 7337 | { |
| 7338 | /* no active connected session present or numChn == 1 |
| 7339 | * scan all remaining channels */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7340 | pSendScanCmd = pScanCmd; |
| 7341 | //remove this command from pending list |
| 7342 | if (csrLLRemoveHead( &pMac->scan.scanCmdPendingList, LL_ACCESS_NOLOCK) == NULL) |
| 7343 | { //In case between PeekHead and here, the entry got removed by another thread. |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7344 | smsLog( pMac, LOGE, FL(" Failed to remove entry from scanCmdPendingList")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7345 | } |
| 7346 | |
| 7347 | } |
| 7348 | csrQueueSmeCommand(pMac, pSendScanCmd, eANI_BOOLEAN_FALSE); |
| 7349 | |
| 7350 | } |
| 7351 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7352 | csrLLUnlock(&pMac->scan.scanCmdPendingList); |
| 7353 | |
| 7354 | } |
| 7355 | #endif |
| 7356 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7357 | //This function returns the maximum time a BSS is allowed in the scan result. |
| 7358 | //The time varies base on connection and power saving factors. |
| 7359 | //Not connected, No PS |
| 7360 | //Not connected, with PS |
| 7361 | //Connected w/o traffic, No PS |
| 7362 | //Connected w/o traffic, with PS |
| 7363 | //Connected w/ traffic, no PS -- Not supported |
| 7364 | //Connected w/ traffic, with PS -- Not supported |
| 7365 | //the return unit is in seconds. |
| 7366 | tANI_U32 csrScanGetAgeOutTime(tpAniSirGlobal pMac) |
| 7367 | { |
| 7368 | tANI_U32 nRet; |
| 7369 | |
| 7370 | if(pMac->scan.nAgingCountDown) |
| 7371 | { |
| 7372 | //Calculate what should be the timeout value for this |
| 7373 | nRet = pMac->scan.nLastAgeTimeOut * pMac->scan.nAgingCountDown; |
| 7374 | pMac->scan.nAgingCountDown--; |
| 7375 | } |
| 7376 | else |
| 7377 | { |
| 7378 | if( csrIsAllSessionDisconnected( pMac ) ) |
| 7379 | { |
| 7380 | if(pmcIsPowerSaveEnabled(pMac, ePMC_IDLE_MODE_POWER_SAVE)) |
| 7381 | { |
| 7382 | nRet = pMac->roam.configParam.scanAgeTimeNCPS; |
| 7383 | } |
| 7384 | else |
| 7385 | { |
| 7386 | nRet = pMac->roam.configParam.scanAgeTimeNCNPS; |
| 7387 | } |
| 7388 | } |
| 7389 | else |
| 7390 | { |
| 7391 | if(pmcIsPowerSaveEnabled(pMac, ePMC_BEACON_MODE_POWER_SAVE)) |
| 7392 | { |
| 7393 | nRet = pMac->roam.configParam.scanAgeTimeCPS; |
| 7394 | } |
| 7395 | else |
| 7396 | { |
| 7397 | nRet = pMac->roam.configParam.scanAgeTimeCNPS; |
| 7398 | } |
| 7399 | } |
| 7400 | //If state-change causing aging time out change, we want to delay it somewhat to avoid |
| 7401 | //unnecessary removal of BSS. This is mostly due to transition from connect to disconnect. |
| 7402 | if(pMac->scan.nLastAgeTimeOut > nRet) |
| 7403 | { |
| 7404 | if(nRet) |
| 7405 | { |
| 7406 | pMac->scan.nAgingCountDown = (pMac->scan.nLastAgeTimeOut / nRet); |
| 7407 | } |
| 7408 | pMac->scan.nLastAgeTimeOut = nRet; |
| 7409 | nRet *= pMac->scan.nAgingCountDown; |
| 7410 | } |
| 7411 | else |
| 7412 | { |
| 7413 | pMac->scan.nLastAgeTimeOut = nRet; |
| 7414 | } |
| 7415 | } |
| 7416 | |
| 7417 | return (nRet); |
| 7418 | } |
| 7419 | |
Deepthi Gowri | 6a08e31 | 2016-03-31 19:10:14 +0530 | [diff] [blame] | 7420 | static void csrPurgeScanResultByAge(void *pv) |
Sandeep Puligilla | 2b6dc63 | 2012-12-17 14:44:16 -0800 | [diff] [blame] | 7421 | { |
| 7422 | tpAniSirGlobal pMac = PMAC_STRUCT( pv ); |
| 7423 | tListElem *pEntry, *tmpEntry; |
| 7424 | tCsrScanResult *pResult; |
Deepthi Gowri | 4480a3f | 2016-05-18 19:30:17 +0530 | [diff] [blame] | 7425 | v_TIME_t ageOutTime = |
| 7426 | (v_TIME_t)(pMac->scan.scanResultCfgAgingTime * SYSTEM_TIME_SEC_TO_MSEC); |
| 7427 | v_TIME_t curTime = vos_timer_get_system_time(); |
Sandeep Puligilla | 2b6dc63 | 2012-12-17 14:44:16 -0800 | [diff] [blame] | 7428 | |
| 7429 | csrLLLock(&pMac->scan.scanResultList); |
| 7430 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK ); |
Deepthi Gowri | 6a08e31 | 2016-03-31 19:10:14 +0530 | [diff] [blame] | 7431 | smsLog(pMac, LOG1, FL("Ageout time=%lu"),ageOutTime); |
Sandeep Puligilla | 2b6dc63 | 2012-12-17 14:44:16 -0800 | [diff] [blame] | 7432 | while( pEntry ) |
| 7433 | { |
| 7434 | tmpEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK); |
| 7435 | pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 7436 | if((curTime - pResult->Result.BssDescriptor.nReceivedTime) > ageOutTime) |
| 7437 | { |
Deepthi Gowri | 50e2fa5 | 2016-03-17 15:30:53 +0530 | [diff] [blame] | 7438 | smsLog(pMac, LOG1, FL("age out due to time out for BSSID" MAC_ADDRESS_STR), |
| 7439 | MAC_ADDR_ARRAY(pResult->Result.BssDescriptor.bssId)); |
Sandeep Puligilla | 2b6dc63 | 2012-12-17 14:44:16 -0800 | [diff] [blame] | 7440 | csrScanAgeOutBss(pMac, pResult); |
| 7441 | } |
| 7442 | pEntry = tmpEntry; |
| 7443 | } |
| 7444 | csrLLUnlock(&pMac->scan.scanResultList); |
| 7445 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7446 | |
| 7447 | eHalStatus csrScanStartIdleScanTimer(tpAniSirGlobal pMac, tANI_U32 interval) |
| 7448 | { |
| 7449 | eHalStatus status; |
| 7450 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7451 | smsLog(pMac, LOG1, " csrScanStartIdleScanTimer"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7452 | if((pMac->scan.fScanEnable) && (eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan) && interval) |
| 7453 | { |
| 7454 | pMac->scan.nIdleScanTimeGap += interval; |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 7455 | vos_timer_stop(&pMac->scan.hTimerIdleScan); |
| 7456 | status = vos_timer_start(&pMac->scan.hTimerIdleScan, interval/PAL_TIMER_TO_MS_UNIT); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7457 | if( !HAL_STATUS_SUCCESS(status) ) |
| 7458 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7459 | smsLog(pMac, LOGE, " Fail to start Idle scan timer. status = %d interval = %d", status, interval); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7460 | //This should not happen but set the flag to restart when ready |
| 7461 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 7462 | } |
| 7463 | } |
| 7464 | else |
| 7465 | { |
| 7466 | if( pMac->scan.fScanEnable && (eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan) ) |
| 7467 | { |
| 7468 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 7469 | } |
| 7470 | status = eHAL_STATUS_FAILURE; |
| 7471 | } |
| 7472 | |
| 7473 | return (status); |
| 7474 | } |
| 7475 | |
| 7476 | |
| 7477 | eHalStatus csrScanStopIdleScanTimer(tpAniSirGlobal pMac) |
| 7478 | { |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 7479 | return (vos_timer_stop(&pMac->scan.hTimerIdleScan)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7480 | } |
| 7481 | |
| 7482 | |
| 7483 | //Stop CSR from asking for IMPS, This function doesn't disable IMPS from CSR |
| 7484 | void csrScanSuspendIMPS( tpAniSirGlobal pMac ) |
| 7485 | { |
| 7486 | csrScanCancelIdleScan(pMac); |
| 7487 | } |
| 7488 | |
| 7489 | |
| 7490 | //Start CSR from asking for IMPS. This function doesn't trigger CSR to request entering IMPS |
| 7491 | //because IMPS maybe disabled. |
| 7492 | void csrScanResumeIMPS( tpAniSirGlobal pMac ) |
| 7493 | { |
| 7494 | csrScanStartIdleScan( pMac ); |
| 7495 | } |
| 7496 | |
| 7497 | |
| 7498 | void csrScanIMPSCallback(void *callbackContext, eHalStatus status) |
| 7499 | { |
| 7500 | tpAniSirGlobal pMac = PMAC_STRUCT( callbackContext ); |
| 7501 | |
| 7502 | if(eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan) |
| 7503 | { |
| 7504 | if(pMac->roam.configParam.IsIdleScanEnabled) |
| 7505 | { |
| 7506 | if(HAL_STATUS_SUCCESS(status)) |
| 7507 | { |
| 7508 | if(csrIsAllSessionDisconnected(pMac) && !csrIsRoamCommandWaiting(pMac)) |
| 7509 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7510 | smsLog(pMac, LOGW, FL("starts idle mode full scan")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7511 | csrScanAllChannels(pMac, eCSR_SCAN_IDLE_MODE_SCAN); |
| 7512 | } |
| 7513 | else |
| 7514 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7515 | smsLog(pMac, LOGW, FL("cannot start idle mode full scan")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7516 | //even though we are in timer handle, calling stop timer will make sure the timer |
| 7517 | //doesn't get to restart. |
| 7518 | csrScanStopIdleScanTimer(pMac); |
| 7519 | } |
| 7520 | } |
| 7521 | else |
| 7522 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7523 | smsLog(pMac, LOGE, FL("sees not success status (%d)"), status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7524 | } |
| 7525 | } |
| 7526 | else |
| 7527 | {//we might need another flag to check if CSR needs to request imps at all |
| 7528 | |
| 7529 | tANI_U32 nTime = 0; |
| 7530 | |
| 7531 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE; |
| 7532 | if(!HAL_STATUS_SUCCESS(csrScanTriggerIdleScan(pMac, &nTime))) |
| 7533 | { |
| 7534 | csrScanStartIdleScanTimer(pMac, nTime); |
| 7535 | } |
| 7536 | } |
| 7537 | } |
| 7538 | } |
| 7539 | |
| 7540 | |
Rashmi Ramanna | 68b309c | 2014-05-20 11:52:22 +0530 | [diff] [blame] | 7541 | //Param: pTimeInterval -- Caller allocated memory in return, if failed, to specify the nxt time interval for |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7542 | //idle scan timer interval |
| 7543 | //Return: Not success -- meaning it cannot start IMPS, caller needs to start a timer for idle scan |
| 7544 | eHalStatus csrScanTriggerIdleScan(tpAniSirGlobal pMac, tANI_U32 *pTimeInterval) |
| 7545 | { |
| 7546 | eHalStatus status = eHAL_STATUS_CSR_WRONG_STATE; |
| 7547 | |
| 7548 | //Do not trigger IMPS in case of concurrency |
Agarwal Ashish | 5974ed3 | 2014-06-16 16:59:54 +0530 | [diff] [blame] | 7549 | if (vos_concurrent_open_sessions_running() && |
| 7550 | csrIsAnySessionInConnectState(pMac)) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7551 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7552 | smsLog( pMac, LOG1, FL("Cannot request IMPS because Concurrent Sessions Running") ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7553 | return (status); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7554 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7555 | |
| 7556 | if(pTimeInterval) |
| 7557 | { |
| 7558 | *pTimeInterval = 0; |
| 7559 | } |
| 7560 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7561 | smsLog(pMac, LOG3, FL("called")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7562 | if( smeCommandPending( pMac ) ) |
| 7563 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7564 | smsLog( pMac, LOG1, FL(" Cannot request IMPS because command pending") ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7565 | //Not to enter IMPS because more work to do |
| 7566 | if(pTimeInterval) |
| 7567 | { |
| 7568 | *pTimeInterval = 0; |
| 7569 | } |
| 7570 | //restart when ready |
| 7571 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 7572 | |
| 7573 | return (status); |
| 7574 | } |
Kiran Kumar Lokere | f8c3992 | 2013-03-18 11:08:11 -0700 | [diff] [blame] | 7575 | if (IsPmcImpsReqFailed (pMac)) |
| 7576 | { |
| 7577 | if(pTimeInterval) |
| 7578 | { |
| 7579 | *pTimeInterval = 1000000; //usec |
| 7580 | } |
| 7581 | //restart when ready |
| 7582 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7583 | |
Kiran Kumar Lokere | f8c3992 | 2013-03-18 11:08:11 -0700 | [diff] [blame] | 7584 | return status; |
| 7585 | } |
Rashmi Ramanna | 68b309c | 2014-05-20 11:52:22 +0530 | [diff] [blame] | 7586 | |
| 7587 | if ( !pMac->deferImps && pMac->fDeferIMPSTime ) |
| 7588 | { |
| 7589 | smsLog( pMac, LOG1, FL("Defer IMPS for %dms as command processed"), |
| 7590 | pMac->fDeferIMPSTime); |
Girish Gowli | 4f3775a | 2014-05-30 17:17:08 +0530 | [diff] [blame] | 7591 | if(pTimeInterval) |
| 7592 | { |
| 7593 | *pTimeInterval = pMac->fDeferIMPSTime * 1000; //usec |
| 7594 | } |
Rashmi Ramanna | 68b309c | 2014-05-20 11:52:22 +0530 | [diff] [blame] | 7595 | pMac->deferImps = eANI_BOOLEAN_TRUE; |
| 7596 | return status; |
| 7597 | } |
| 7598 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7599 | if((pMac->scan.fScanEnable) && (eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan) |
| 7600 | /*&& pMac->roam.configParam.impsSleepTime*/) |
| 7601 | { |
| 7602 | //Stop get result timer because idle scan gets scan result out of PE |
| 7603 | csrScanStopGetResultTimer(pMac); |
| 7604 | if(pTimeInterval) |
| 7605 | { |
| 7606 | *pTimeInterval = pMac->roam.configParam.impsSleepTime; |
| 7607 | } |
| 7608 | //pmcRequestImps take a period in millisecond unit. |
| 7609 | status = pmcRequestImps(pMac, pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_MS_UNIT, csrScanIMPSCallback, pMac); |
| 7610 | if(!HAL_STATUS_SUCCESS(status)) |
| 7611 | { |
| 7612 | if(eHAL_STATUS_PMC_ALREADY_IN_IMPS != status) |
| 7613 | { |
| 7614 | //Do restart the timer if CSR thinks it cannot do IMPS |
| 7615 | if( !csrCheckPSReady( pMac ) ) |
| 7616 | { |
| 7617 | if(pTimeInterval) |
| 7618 | { |
| 7619 | *pTimeInterval = 0; |
| 7620 | } |
| 7621 | //Set the restart flag to true because that idle scan |
| 7622 | //can be restarted even though the timer will not be running |
| 7623 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 7624 | } |
| 7625 | else |
| 7626 | { |
| 7627 | //For not now, we do a quicker retry |
| 7628 | if(pTimeInterval) |
| 7629 | { |
| 7630 | *pTimeInterval = CSR_IDLE_SCAN_WAIT_TIME; |
| 7631 | } |
| 7632 | } |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7633 | smsLog(pMac, LOGW, FL("call pmcRequestImps and it returns status code (%d)"), status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7634 | } |
| 7635 | else |
| 7636 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7637 | smsLog(pMac, LOGW, FL("already in IMPS")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7638 | //Since CSR is the only module to request for IMPS. If it is already in IMPS, CSR assumes |
| 7639 | //the callback will be called in the future. Should not happen though. |
| 7640 | status = eHAL_STATUS_SUCCESS; |
| 7641 | pMac->scan.nIdleScanTimeGap = 0; |
| 7642 | } |
| 7643 | } |
| 7644 | else |
| 7645 | { |
| 7646 | //requested so let's reset the value |
| 7647 | pMac->scan.nIdleScanTimeGap = 0; |
| 7648 | } |
| 7649 | } |
| 7650 | |
| 7651 | return (status); |
| 7652 | } |
| 7653 | |
| 7654 | |
| 7655 | eHalStatus csrScanStartIdleScan(tpAniSirGlobal pMac) |
| 7656 | { |
| 7657 | eHalStatus status = eHAL_STATUS_CSR_WRONG_STATE; |
| 7658 | tANI_U32 nTime = 0; |
| 7659 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7660 | smsLog(pMac, LOGW, FL("called")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7661 | if(pMac->roam.configParam.IsIdleScanEnabled) |
| 7662 | { |
| 7663 | //stop bg scan first |
| 7664 | csrScanBGScanAbort(pMac); |
| 7665 | //Stop get result timer because idle scan gets scan result out of PE |
| 7666 | csrScanStopGetResultTimer(pMac); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7667 | } |
| 7668 | pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE; |
| 7669 | status = csrScanTriggerIdleScan(pMac, &nTime); |
| 7670 | if(!HAL_STATUS_SUCCESS(status)) |
| 7671 | { |
| 7672 | csrScanStartIdleScanTimer(pMac, nTime); |
| 7673 | } |
| 7674 | |
| 7675 | return (status); |
| 7676 | } |
| 7677 | |
| 7678 | |
| 7679 | void csrScanCancelIdleScan(tpAniSirGlobal pMac) |
| 7680 | { |
| 7681 | if(eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan) |
| 7682 | { |
Agarwal Ashish | 5974ed3 | 2014-06-16 16:59:54 +0530 | [diff] [blame] | 7683 | if (vos_concurrent_open_sessions_running()) { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7684 | return; |
| 7685 | } |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7686 | smsLog(pMac, LOG1, " csrScanCancelIdleScan"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7687 | pMac->scan.fCancelIdleScan = eANI_BOOLEAN_TRUE; |
| 7688 | //Set the restart flag in case later on it is uncancelled |
| 7689 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 7690 | csrScanStopIdleScanTimer(pMac); |
| 7691 | csrScanRemoveNotRoamingScanCommand(pMac); |
| 7692 | } |
| 7693 | } |
| 7694 | |
| 7695 | |
| 7696 | void csrScanIdleScanTimerHandler(void *pv) |
| 7697 | { |
| 7698 | tpAniSirGlobal pMac = PMAC_STRUCT( pv ); |
| 7699 | eHalStatus status; |
| 7700 | tANI_U32 nTime = 0; |
| 7701 | |
| 7702 | smsLog(pMac, LOGW, " csrScanIdleScanTimerHandler called "); |
Kiran Kumar Lokere | f8c3992 | 2013-03-18 11:08:11 -0700 | [diff] [blame] | 7703 | pmcResetImpsFailStatus (pMac); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7704 | status = csrScanTriggerIdleScan(pMac, &nTime); |
| 7705 | if(!HAL_STATUS_SUCCESS(status) && (eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan)) |
| 7706 | { |
| 7707 | //Check whether it is time to actually do an idle scan |
| 7708 | if(pMac->scan.nIdleScanTimeGap >= pMac->roam.configParam.impsSleepTime) |
| 7709 | { |
| 7710 | pMac->scan.nIdleScanTimeGap = 0; |
| 7711 | csrScanIMPSCallback(pMac, eHAL_STATUS_SUCCESS); |
| 7712 | } |
| 7713 | else |
| 7714 | { |
| 7715 | csrScanStartIdleScanTimer(pMac, nTime); |
| 7716 | } |
| 7717 | } |
Rashmi Ramanna | 68b309c | 2014-05-20 11:52:22 +0530 | [diff] [blame] | 7718 | if(pMac->deferImps) |
| 7719 | { |
| 7720 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 7721 | pMac->deferImps = eANI_BOOLEAN_FALSE; |
| 7722 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7723 | } |
| 7724 | |
| 7725 | |
| 7726 | |
| 7727 | |
| 7728 | tANI_BOOLEAN csrScanRemoveNotRoamingScanCommand(tpAniSirGlobal pMac) |
| 7729 | { |
| 7730 | tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE; |
| 7731 | tListElem *pEntry, *pEntryTmp; |
| 7732 | tSmeCmd *pCommand; |
| 7733 | tDblLinkList localList; |
Madan Mohan Koyyalamudi | 2125599 | 2013-08-01 18:00:25 +0530 | [diff] [blame] | 7734 | tDblLinkList *pCmdList; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7735 | |
| 7736 | vos_mem_zero(&localList, sizeof(tDblLinkList)); |
| 7737 | if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList))) |
| 7738 | { |
| 7739 | smsLog(pMac, LOGE, FL(" failed to open list")); |
| 7740 | return fRet; |
| 7741 | } |
Madan Mohan Koyyalamudi | 2125599 | 2013-08-01 18:00:25 +0530 | [diff] [blame] | 7742 | if (!pMac->fScanOffload) |
| 7743 | pCmdList = &pMac->sme.smeCmdPendingList; |
| 7744 | else |
| 7745 | pCmdList = &pMac->sme.smeScanCmdPendingList; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7746 | |
Madan Mohan Koyyalamudi | 2125599 | 2013-08-01 18:00:25 +0530 | [diff] [blame] | 7747 | csrLLLock(pCmdList); |
| 7748 | pEntry = csrLLPeekHead(pCmdList, LL_ACCESS_NOLOCK); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7749 | while(pEntry) |
| 7750 | { |
Madan Mohan Koyyalamudi | 2125599 | 2013-08-01 18:00:25 +0530 | [diff] [blame] | 7751 | pEntryTmp = csrLLNext(pCmdList, pEntry, LL_ACCESS_NOLOCK); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7752 | pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link); |
| 7753 | if( eSmeCommandScan == pCommand->command ) |
| 7754 | { |
| 7755 | switch( pCommand->u.scanCmd.reason ) |
| 7756 | { |
| 7757 | case eCsrScanIdleScan: |
Madan Mohan Koyyalamudi | 2125599 | 2013-08-01 18:00:25 +0530 | [diff] [blame] | 7758 | if( csrLLRemoveEntry(pCmdList, pEntry, LL_ACCESS_NOLOCK) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7759 | { |
| 7760 | csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK); |
| 7761 | } |
| 7762 | fRet = eANI_BOOLEAN_TRUE; |
| 7763 | break; |
| 7764 | |
| 7765 | default: |
| 7766 | break; |
| 7767 | } //switch |
| 7768 | } |
| 7769 | pEntry = pEntryTmp; |
| 7770 | } |
| 7771 | |
Madan Mohan Koyyalamudi | 2125599 | 2013-08-01 18:00:25 +0530 | [diff] [blame] | 7772 | csrLLUnlock(pCmdList); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7773 | |
| 7774 | while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) ) |
| 7775 | { |
| 7776 | pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link); |
| 7777 | csrReleaseCommandScan( pMac, pCommand ); |
| 7778 | } |
| 7779 | |
| 7780 | csrLLClose(&localList); |
| 7781 | |
| 7782 | return (fRet); |
| 7783 | } |
| 7784 | |
| 7785 | |
| 7786 | tANI_BOOLEAN csrScanRemoveFreshScanCommand(tpAniSirGlobal pMac, tANI_U8 sessionId) |
| 7787 | { |
| 7788 | tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE; |
| 7789 | tListElem *pEntry, *pEntryTmp; |
| 7790 | tSmeCmd *pCommand; |
| 7791 | tDblLinkList localList; |
Madan Mohan Koyyalamudi | 2125599 | 2013-08-01 18:00:25 +0530 | [diff] [blame] | 7792 | tDblLinkList *pCmdList; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7793 | |
| 7794 | vos_mem_zero(&localList, sizeof(tDblLinkList)); |
| 7795 | if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList))) |
| 7796 | { |
| 7797 | smsLog(pMac, LOGE, FL(" failed to open list")); |
| 7798 | return fRet; |
| 7799 | } |
| 7800 | |
Madan Mohan Koyyalamudi | 2125599 | 2013-08-01 18:00:25 +0530 | [diff] [blame] | 7801 | if (!pMac->fScanOffload) |
| 7802 | pCmdList = &pMac->sme.smeCmdPendingList; |
| 7803 | else |
| 7804 | pCmdList = &pMac->sme.smeScanCmdPendingList; |
| 7805 | |
| 7806 | csrLLLock(pCmdList); |
| 7807 | pEntry = csrLLPeekHead(pCmdList, LL_ACCESS_NOLOCK); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7808 | while(pEntry) |
| 7809 | { |
Madan Mohan Koyyalamudi | 2125599 | 2013-08-01 18:00:25 +0530 | [diff] [blame] | 7810 | pEntryTmp = csrLLNext(pCmdList, pEntry, LL_ACCESS_NOLOCK); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7811 | pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link); |
| 7812 | if( (eSmeCommandScan == pCommand->command) && (sessionId == pCommand->sessionId) ) |
| 7813 | { |
| 7814 | switch(pCommand->u.scanCmd.reason) |
| 7815 | { |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 7816 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 7817 | case eCsrScanGetLfrResult: |
| 7818 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7819 | case eCsrScanGetResult: |
| 7820 | case eCsrScanSetBGScanParam: |
| 7821 | case eCsrScanBGScanAbort: |
| 7822 | case eCsrScanBGScanEnable: |
| 7823 | case eCsrScanGetScanChnInfo: |
| 7824 | break; |
| 7825 | default: |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7826 | smsLog (pMac, LOGW, "%s: -------- abort scan command reason = %d", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7827 | __func__, pCommand->u.scanCmd.reason); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7828 | //The rest are fresh scan requests |
Madan Mohan Koyyalamudi | 2125599 | 2013-08-01 18:00:25 +0530 | [diff] [blame] | 7829 | if( csrLLRemoveEntry(pCmdList, pEntry, LL_ACCESS_NOLOCK) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7830 | { |
| 7831 | csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK); |
| 7832 | } |
| 7833 | fRet = eANI_BOOLEAN_TRUE; |
| 7834 | break; |
| 7835 | } |
| 7836 | } |
| 7837 | pEntry = pEntryTmp; |
| 7838 | } |
| 7839 | |
Madan Mohan Koyyalamudi | 2125599 | 2013-08-01 18:00:25 +0530 | [diff] [blame] | 7840 | csrLLUnlock(pCmdList); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7841 | |
| 7842 | while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) ) |
| 7843 | { |
| 7844 | pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link); |
| 7845 | if (pCommand->u.scanCmd.callback) |
| 7846 | { |
| 7847 | /* User scan request is pending, |
| 7848 | * send response with status eCSR_SCAN_ABORT*/ |
| 7849 | pCommand->u.scanCmd.callback(pMac, |
| 7850 | pCommand->u.scanCmd.pContext, |
| 7851 | pCommand->u.scanCmd.scanID, |
| 7852 | eCSR_SCAN_ABORT); |
| 7853 | } |
| 7854 | csrReleaseCommandScan( pMac, pCommand ); |
| 7855 | } |
| 7856 | csrLLClose(&localList); |
| 7857 | |
| 7858 | return (fRet); |
| 7859 | } |
| 7860 | |
| 7861 | |
| 7862 | void csrReleaseScanCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand, eCsrScanStatus scanStatus) |
| 7863 | { |
| 7864 | eCsrScanReason reason = pCommand->u.scanCmd.reason; |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 7865 | tANI_BOOLEAN status; |
| 7866 | |
| 7867 | if (!pMac->fScanOffload) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7868 | { |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 7869 | tANI_U32 i; |
| 7870 | for(i = 0; i < CSR_ROAM_SESSION_MAX; i++) |
Abhishek Singh | f52182c | 2016-08-24 11:15:23 +0530 | [diff] [blame] | 7871 | csrRoamStateChange(pMac, |
| 7872 | pMac->roam.prev_state[i], i); |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 7873 | } |
| 7874 | else |
| 7875 | { |
| 7876 | csrRoamStateChange(pMac, |
Abhishek Singh | f52182c | 2016-08-24 11:15:23 +0530 | [diff] [blame] | 7877 | pMac->roam.prev_state[pCommand->sessionId], |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 7878 | pCommand->sessionId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7879 | } |
| 7880 | |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 7881 | csrScanCallCallback(pMac, pCommand, scanStatus); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7882 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7883 | smsLog(pMac, LOG3, " Remove Scan command reason = %d", reason); |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 7884 | if (pMac->fScanOffload) |
| 7885 | { |
| 7886 | status = csrLLRemoveEntry(&pMac->sme.smeScanCmdActiveList, |
| 7887 | &pCommand->Link, LL_ACCESS_LOCK); |
| 7888 | } |
| 7889 | else |
| 7890 | { |
| 7891 | status = csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, |
| 7892 | &pCommand->Link, LL_ACCESS_LOCK); |
| 7893 | } |
| 7894 | |
| 7895 | if(status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7896 | { |
| 7897 | csrReleaseCommandScan( pMac, pCommand ); |
| 7898 | } |
| 7899 | else |
| 7900 | { |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 7901 | smsLog(pMac, LOGE, |
| 7902 | " ********csrReleaseScanCommand cannot release command reason %d", |
| 7903 | pCommand->u.scanCmd.reason ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7904 | } |
| 7905 | } |
| 7906 | |
| 7907 | |
| 7908 | eHalStatus csrScanGetPMKIDCandidateList(tpAniSirGlobal pMac, tANI_U32 sessionId, |
| 7909 | tPmkidCandidateInfo *pPmkidList, tANI_U32 *pNumItems ) |
| 7910 | { |
| 7911 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 7912 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 7913 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 7914 | if(!pSession) |
| 7915 | { |
| 7916 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 7917 | return eHAL_STATUS_FAILURE; |
| 7918 | } |
| 7919 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7920 | smsLog(pMac, LOGW, " pMac->scan.NumPmkidCandidate = %d", pSession->NumPmkidCandidate); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7921 | csrResetPMKIDCandidateList(pMac, sessionId); |
| 7922 | if(csrIsConnStateConnected(pMac, sessionId) && pSession->pCurRoamProfile) |
| 7923 | { |
| 7924 | tCsrScanResultFilter *pScanFilter; |
| 7925 | tCsrScanResultInfo *pScanResult; |
| 7926 | tScanResultHandle hBSSList; |
| 7927 | tANI_U32 nItems = *pNumItems; |
| 7928 | |
| 7929 | *pNumItems = 0; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7930 | pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter)); |
| 7931 | if ( NULL == pScanFilter ) |
| 7932 | status = eHAL_STATUS_FAILURE; |
| 7933 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7934 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7935 | vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7936 | //Here is the profile we need to connect to |
| 7937 | status = csrRoamPrepareFilterFromProfile(pMac, pSession->pCurRoamProfile, pScanFilter); |
| 7938 | if(HAL_STATUS_SUCCESS(status)) |
| 7939 | { |
| 7940 | status = csrScanGetResult(pMac, pScanFilter, &hBSSList); |
| 7941 | if(HAL_STATUS_SUCCESS(status)) |
| 7942 | { |
| 7943 | while(((pScanResult = csrScanResultGetNext(pMac, hBSSList)) != NULL) && ( pSession->NumPmkidCandidate < nItems)) |
| 7944 | { |
| 7945 | //NumPmkidCandidate adds up here |
| 7946 | csrProcessBSSDescForPMKIDList(pMac, &pScanResult->BssDescriptor, |
| 7947 | (tDot11fBeaconIEs *)( pScanResult->pvIes )); |
| 7948 | } |
| 7949 | if(pSession->NumPmkidCandidate) |
| 7950 | { |
| 7951 | *pNumItems = pSession->NumPmkidCandidate; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7952 | vos_mem_copy(pPmkidList, pSession->PmkidCandidateInfo, |
| 7953 | pSession->NumPmkidCandidate * sizeof(tPmkidCandidateInfo)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7954 | } |
| 7955 | csrScanResultPurge(pMac, hBSSList); |
| 7956 | }//Have scan result |
| 7957 | csrFreeScanFilter(pMac, pScanFilter); |
| 7958 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7959 | vos_mem_free(pScanFilter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7960 | } |
| 7961 | } |
| 7962 | |
| 7963 | return (status); |
| 7964 | } |
| 7965 | |
| 7966 | |
| 7967 | |
| 7968 | #ifdef FEATURE_WLAN_WAPI |
| 7969 | eHalStatus csrScanGetBKIDCandidateList(tpAniSirGlobal pMac, tANI_U32 sessionId, |
| 7970 | tBkidCandidateInfo *pBkidList, tANI_U32 *pNumItems ) |
| 7971 | { |
| 7972 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 7973 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 7974 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 7975 | if(!pSession) |
| 7976 | { |
| 7977 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 7978 | return eHAL_STATUS_FAILURE; |
| 7979 | } |
| 7980 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7981 | smsLog(pMac, LOGW, " pMac->scan.NumBkidCandidate = %d", pSession->NumBkidCandidate); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7982 | csrResetBKIDCandidateList(pMac, sessionId); |
| 7983 | if(csrIsConnStateConnected(pMac, sessionId) && pSession->pCurRoamProfile) |
| 7984 | { |
| 7985 | tCsrScanResultFilter *pScanFilter; |
| 7986 | tCsrScanResultInfo *pScanResult; |
| 7987 | tScanResultHandle hBSSList; |
| 7988 | tANI_U32 nItems = *pNumItems; |
| 7989 | *pNumItems = 0; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7990 | pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter)); |
| 7991 | if ( NULL == pScanFilter ) |
| 7992 | status = eHAL_STATUS_FAILURE; |
| 7993 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7994 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7995 | vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7996 | //Here is the profile we need to connect to |
| 7997 | status = csrRoamPrepareFilterFromProfile(pMac, pSession->pCurRoamProfile, pScanFilter); |
| 7998 | if(HAL_STATUS_SUCCESS(status)) |
| 7999 | { |
| 8000 | status = csrScanGetResult(pMac, pScanFilter, &hBSSList); |
| 8001 | if(HAL_STATUS_SUCCESS(status)) |
| 8002 | { |
| 8003 | while(((pScanResult = csrScanResultGetNext(pMac, hBSSList)) != NULL) && ( pSession->NumBkidCandidate < nItems)) |
| 8004 | { |
| 8005 | //pMac->scan.NumBkidCandidate adds up here |
| 8006 | csrProcessBSSDescForBKIDList(pMac, &pScanResult->BssDescriptor, |
| 8007 | (tDot11fBeaconIEs *)( pScanResult->pvIes )); |
| 8008 | |
| 8009 | } |
| 8010 | if(pSession->NumBkidCandidate) |
| 8011 | { |
| 8012 | *pNumItems = pSession->NumBkidCandidate; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8013 | vos_mem_copy(pBkidList, pSession->BkidCandidateInfo, pSession->NumBkidCandidate * sizeof(tBkidCandidateInfo)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8014 | } |
| 8015 | csrScanResultPurge(pMac, hBSSList); |
| 8016 | }//Have scan result |
| 8017 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8018 | vos_mem_free(pScanFilter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8019 | } |
| 8020 | } |
| 8021 | |
| 8022 | return (status); |
| 8023 | } |
| 8024 | #endif /* FEATURE_WLAN_WAPI */ |
| 8025 | |
Selvaraj, Sridhar | 32417ed | 2016-06-22 15:19:12 +0530 | [diff] [blame] | 8026 | /** |
| 8027 | * csr_scan_request_set_chan_time() - Populate max and min |
| 8028 | * channel time in Scan request |
| 8029 | * @pMac - pointer to mac context |
| 8030 | * @pScanCmd - pointer to the Scan command |
| 8031 | * |
| 8032 | * Return - None |
| 8033 | */ |
| 8034 | #ifndef QCA_WIFI_ISOC |
| 8035 | static void csr_scan_request_set_chan_time(tpAniSirGlobal pMac, |
| 8036 | tSmeCmd *pScanCmd) |
| 8037 | { |
| 8038 | if (pMac->roam.neighborRoamInfo.handoffReqInfo.src |
| 8039 | == FASTREASSOC) { |
| 8040 | pScanCmd->u.scanCmd.u.scanRequest.maxChnTime |
| 8041 | = MAX_ACTIVE_SCAN_FOR_ONE_CHANNEL_FASTREASSOC; |
| 8042 | pScanCmd->u.scanCmd.u.scanRequest.minChnTime |
| 8043 | = MIN_ACTIVE_SCAN_FOR_ONE_CHANNEL_FASTREASSOC; |
| 8044 | pMac->roam.neighborRoamInfo.handoffReqInfo.src = 0; |
| 8045 | } else { |
| 8046 | pScanCmd->u.scanCmd.u.scanRequest.maxChnTime |
| 8047 | = MAX_ACTIVE_SCAN_FOR_ONE_CHANNEL; |
| 8048 | pScanCmd->u.scanCmd.u.scanRequest.minChnTime |
| 8049 | = MIN_ACTIVE_SCAN_FOR_ONE_CHANNEL; |
| 8050 | } |
| 8051 | } |
| 8052 | #else |
| 8053 | static void csr_scan_request_set_chan_time(tpAniSirGlobal pMac, |
| 8054 | tSmeCmd *pScanCmd) |
| 8055 | { |
| 8056 | pScanCmd->u.scanCmd.u.scanRequest.maxChnTime |
| 8057 | = MAX_ACTIVE_SCAN_FOR_ONE_CHANNEL; |
| 8058 | pScanCmd->u.scanCmd.u.scanRequest.minChnTime |
| 8059 | = MIN_ACTIVE_SCAN_FOR_ONE_CHANNEL; |
| 8060 | } |
| 8061 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8062 | |
Kapil Gupta | c46b754 | 2016-10-25 13:03:20 +0530 | [diff] [blame] | 8063 | /** |
| 8064 | * csr_ssid_scan_done_callback() - Callback to indicate |
| 8065 | * scan is done for ssid scan |
| 8066 | * @halHandle: handle to hal |
| 8067 | * @context: SSID scan context |
| 8068 | * @scanId: Scan id for the scheduled scan |
| 8069 | * @status: scan done status |
| 8070 | * |
| 8071 | * Return - eHalStatus |
| 8072 | */ |
| 8073 | static eHalStatus csr_ssid_scan_done_callback(tHalHandle halHandle, |
| 8074 | void *context, |
| 8075 | tANI_U32 scanId, |
| 8076 | eCsrScanStatus status) |
| 8077 | { |
| 8078 | struct csr_scan_for_ssid_context *scan_context = |
| 8079 | (struct csr_scan_for_ssid_context *)context; |
| 8080 | |
Sreelakshmi Konamki | 5e32960 | 2016-11-21 12:02:44 +0530 | [diff] [blame] | 8081 | if (NULL == scan_context) { |
Kapil Gupta | c46b754 | 2016-10-25 13:03:20 +0530 | [diff] [blame] | 8082 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, |
| 8083 | FL("scan for ssid context not found")); |
Sreelakshmi Konamki | 5e32960 | 2016-11-21 12:02:44 +0530 | [diff] [blame] | 8084 | return eHAL_STATUS_FAILURE; |
| 8085 | } |
Kapil Gupta | c46b754 | 2016-10-25 13:03:20 +0530 | [diff] [blame] | 8086 | |
| 8087 | if (eCSR_SCAN_ABORT == status) |
| 8088 | csrRoamCallCallback(scan_context->pMac, scan_context->sessionId, |
| 8089 | NULL, scan_context->roamId, |
| 8090 | eCSR_ROAM_ASSOCIATION_FAILURE, |
| 8091 | eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE); |
| 8092 | vos_mem_free(scan_context); |
| 8093 | return eHAL_STATUS_SUCCESS; |
| 8094 | } |
| 8095 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8096 | //This function is usually used for BSSs that suppresses SSID so the profile |
| 8097 | //shall have one and only one SSID |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 8098 | eHalStatus csrScanForSSID(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tANI_U32 roamId, tANI_BOOLEAN notify) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8099 | { |
| 8100 | eHalStatus status = eHAL_STATUS_INVALID_PARAMETER; |
| 8101 | tSmeCmd *pScanCmd = NULL; |
| 8102 | tANI_U8 bAddr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; |
| 8103 | tANI_U8 index = 0; |
| 8104 | tANI_U32 numSsid = pProfile->SSIDs.numOfSSIDs; |
Kapil Gupta | c46b754 | 2016-10-25 13:03:20 +0530 | [diff] [blame] | 8105 | struct csr_scan_for_ssid_context *context; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8106 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 8107 | smsLog(pMac, LOG2, FL("called")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8108 | //For WDS, we use the index 0. There must be at least one in there |
| 8109 | if( CSR_IS_WDS_STA( pProfile ) && numSsid ) |
| 8110 | { |
| 8111 | numSsid = 1; |
| 8112 | } |
| 8113 | if(pMac->scan.fScanEnable && ( numSsid == 1 ) ) |
| 8114 | { |
| 8115 | do |
| 8116 | { |
| 8117 | pScanCmd = csrGetCommandBuffer(pMac); |
| 8118 | if(!pScanCmd) |
| 8119 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 8120 | smsLog(pMac, LOGE, FL("failed to allocate command buffer")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8121 | break; |
| 8122 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8123 | vos_mem_set(&pScanCmd->u.scanCmd, sizeof(tScanCmd), 0); |
| 8124 | pScanCmd->u.scanCmd.pToRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile)); |
| 8125 | if ( NULL == pScanCmd->u.scanCmd.pToRoamProfile ) |
krunal soni | 587bf01 | 2014-02-04 12:35:11 -0800 | [diff] [blame] | 8126 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8127 | status = eHAL_STATUS_FAILURE; |
krunal soni | 587bf01 | 2014-02-04 12:35:11 -0800 | [diff] [blame] | 8128 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8129 | else |
krunal soni | 587bf01 | 2014-02-04 12:35:11 -0800 | [diff] [blame] | 8130 | { |
| 8131 | status = csrRoamCopyProfile(pMac, pScanCmd->u.scanCmd.pToRoamProfile, pProfile); |
| 8132 | } |
Kapil Gupta | c46b754 | 2016-10-25 13:03:20 +0530 | [diff] [blame] | 8133 | context = vos_mem_malloc(sizeof(*context)); |
| 8134 | if (NULL == context) |
| 8135 | { |
| 8136 | smsLog(pMac, LOGE, |
| 8137 | "Failed to allocate memory for ssid scan context"); |
| 8138 | status = eHAL_STATUS_FAILED_ALLOC; |
| 8139 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8140 | if(!HAL_STATUS_SUCCESS(status)) |
| 8141 | break; |
Kapil Gupta | c46b754 | 2016-10-25 13:03:20 +0530 | [diff] [blame] | 8142 | context->pMac = pMac; |
| 8143 | context->sessionId = sessionId; |
| 8144 | context->roamId = roamId; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8145 | pScanCmd->u.scanCmd.roamId = roamId; |
| 8146 | pScanCmd->command = eSmeCommandScan; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8147 | pScanCmd->sessionId = (tANI_U8)sessionId; |
Kapil Gupta | c46b754 | 2016-10-25 13:03:20 +0530 | [diff] [blame] | 8148 | pScanCmd->u.scanCmd.callback = csr_ssid_scan_done_callback; |
| 8149 | pScanCmd->u.scanCmd.pContext = context; |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 8150 | pScanCmd->u.scanCmd.reason = eCsrScanForSsid;//Need to check: might need a new reason for SSID scan for LFR during multisession with p2p |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8151 | pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8152 | vos_mem_set(&pScanCmd->u.scanCmd.u.scanRequest, sizeof(tCsrScanRequest), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8153 | pScanCmd->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8154 | pScanCmd->u.scanCmd.u.scanRequest.BSSType = pProfile->BSSType; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8155 | // To avoid 11b rate in probe request Set p2pSearch flag as 1 for P2P Client Mode |
| 8156 | if(VOS_P2P_CLIENT_MODE == pProfile->csrPersona) |
| 8157 | { |
| 8158 | pScanCmd->u.scanCmd.u.scanRequest.p2pSearch = 1; |
| 8159 | } |
Agarwal Ashish | 4f61613 | 2013-12-30 23:32:50 +0530 | [diff] [blame] | 8160 | if(pProfile->nAddIEScanLength) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8161 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8162 | pScanCmd->u.scanCmd.u.scanRequest.pIEField = vos_mem_malloc( |
| 8163 | pProfile->nAddIEScanLength); |
| 8164 | if ( NULL == pScanCmd->u.scanCmd.u.scanRequest.pIEField ) |
| 8165 | status = eHAL_STATUS_FAILURE; |
| 8166 | else |
| 8167 | status = eHAL_STATUS_SUCCESS; |
| 8168 | vos_mem_set(pScanCmd->u.scanCmd.u.scanRequest.pIEField, |
| 8169 | pProfile->nAddIEScanLength, 0); |
| 8170 | if (HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8171 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8172 | vos_mem_copy(pScanCmd->u.scanCmd.u.scanRequest.pIEField, |
Agarwal Ashish | 4f61613 | 2013-12-30 23:32:50 +0530 | [diff] [blame] | 8173 | pProfile->addIEScan, pProfile->nAddIEScanLength); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8174 | pScanCmd->u.scanCmd.u.scanRequest.uIEFieldLen = pProfile->nAddIEScanLength; |
| 8175 | } |
| 8176 | else |
| 8177 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 8178 | smsLog(pMac, LOGE, "No memory for scanning IE fields"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8179 | } |
| 8180 | } //Allocate memory for IE field |
| 8181 | else |
| 8182 | { |
| 8183 | pScanCmd->u.scanCmd.u.scanRequest.uIEFieldLen = 0; |
| 8184 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 8185 | /* For one channel be good enpugh time to receive beacon atleast */ |
| 8186 | if( 1 == pProfile->ChannelInfo.numOfChannels ) |
| 8187 | { |
Selvaraj, Sridhar | 32417ed | 2016-06-22 15:19:12 +0530 | [diff] [blame] | 8188 | csr_scan_request_set_chan_time(pMac, pScanCmd); |
| 8189 | } else { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8190 | pScanCmd->u.scanCmd.u.scanRequest.maxChnTime = |
| 8191 | pMac->roam.configParam.nActiveMaxChnTime; |
| 8192 | pScanCmd->u.scanCmd.u.scanRequest.minChnTime = |
| 8193 | pMac->roam.configParam.nActiveMinChnTime; |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 8194 | } |
Abhishek Singh | add1358 | 2016-09-29 17:00:03 +0530 | [diff] [blame] | 8195 | pScanCmd->u.scanCmd.u.scanRequest.max_chntime_btc_esco = |
| 8196 | pMac->roam.configParam.max_chntime_btc_esco; |
| 8197 | pScanCmd->u.scanCmd.u.scanRequest.min_chntime_btc_esco = |
| 8198 | pMac->roam.configParam.min_chntime_btc_esco; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8199 | if(pProfile->BSSIDs.numOfBSSIDs == 1) |
| 8200 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8201 | vos_mem_copy(pScanCmd->u.scanCmd.u.scanRequest.bssid, |
| 8202 | pProfile->BSSIDs.bssid, sizeof(tCsrBssid)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8203 | } |
| 8204 | else |
| 8205 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8206 | vos_mem_copy(pScanCmd->u.scanCmd.u.scanRequest.bssid, bAddr, 6); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8207 | } |
| 8208 | if(pProfile->ChannelInfo.numOfChannels) |
| 8209 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8210 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = vos_mem_malloc( |
| 8211 | sizeof(*pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList) |
| 8212 | * pProfile->ChannelInfo.numOfChannels); |
| 8213 | if ( NULL == pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList ) |
| 8214 | status = eHAL_STATUS_FAILURE; |
| 8215 | else |
| 8216 | status = eHAL_STATUS_SUCCESS; |
| 8217 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = 0; |
| 8218 | if(HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8219 | { |
| 8220 | csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[0]); |
| 8221 | for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++) |
| 8222 | { |
| 8223 | if(csrRoamIsValidChannel(pMac, pProfile->ChannelInfo.ChannelList[index])) |
| 8224 | { |
| 8225 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels] |
| 8226 | = pProfile->ChannelInfo.ChannelList[index]; |
| 8227 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels++; |
| 8228 | } |
| 8229 | else |
| 8230 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 8231 | smsLog(pMac, LOGW, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8232 | } |
| 8233 | |
| 8234 | } |
| 8235 | } |
| 8236 | else |
| 8237 | { |
| 8238 | break; |
| 8239 | } |
| 8240 | |
| 8241 | } |
| 8242 | else |
| 8243 | { |
| 8244 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = 0; |
| 8245 | } |
| 8246 | if(pProfile->SSIDs.numOfSSIDs) |
| 8247 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8248 | pScanCmd->u.scanCmd.u.scanRequest.SSIDs.SSIDList = vos_mem_malloc( |
| 8249 | pProfile->SSIDs.numOfSSIDs * sizeof(tCsrSSIDInfo)); |
| 8250 | if ( NULL == pScanCmd->u.scanCmd.u.scanRequest.SSIDs.SSIDList ) |
| 8251 | status = eHAL_STATUS_FAILURE; |
| 8252 | else |
| 8253 | status = eHAL_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8254 | if(!HAL_STATUS_SUCCESS(status)) |
| 8255 | { |
| 8256 | break; |
| 8257 | } |
| 8258 | pScanCmd->u.scanCmd.u.scanRequest.SSIDs.numOfSSIDs = 1; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8259 | vos_mem_copy(pScanCmd->u.scanCmd.u.scanRequest.SSIDs.SSIDList, |
| 8260 | pProfile->SSIDs.SSIDList, sizeof(tCsrSSIDInfo)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8261 | } |
| 8262 | //Start process the command |
| 8263 | status = csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_FALSE); |
| 8264 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 8265 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 8266 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8267 | break; |
| 8268 | } |
| 8269 | }while(0); |
| 8270 | if(!HAL_STATUS_SUCCESS(status)) |
| 8271 | { |
| 8272 | if(pScanCmd) |
| 8273 | { |
| 8274 | csrReleaseCommandScan(pMac, pScanCmd); |
| 8275 | //TODO:free the memory that is allocated in this function |
| 8276 | } |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 8277 | if(notify) |
| 8278 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8279 | csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE); |
| 8280 | } |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 8281 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8282 | }//valid |
| 8283 | else |
| 8284 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 8285 | smsLog(pMac, LOGE, FL("cannot scan because scanEnable (%d) or numSSID (%d) is invalid"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8286 | pMac->scan.fScanEnable, pProfile->SSIDs.numOfSSIDs); |
| 8287 | } |
| 8288 | |
| 8289 | return (status); |
| 8290 | } |
| 8291 | |
| 8292 | |
| 8293 | //Issue a scan base on the new capability infomation |
| 8294 | //This should only happen when the associated AP changes its capability. |
| 8295 | //After this scan is done, CSR reroams base on the new scan results |
| 8296 | eHalStatus csrScanForCapabilityChange(tpAniSirGlobal pMac, tSirSmeApNewCaps *pNewCaps) |
| 8297 | { |
| 8298 | eHalStatus status = eHAL_STATUS_INVALID_PARAMETER; |
| 8299 | tSmeCmd *pScanCmd = NULL; |
| 8300 | |
| 8301 | if(pNewCaps) |
| 8302 | { |
| 8303 | do |
| 8304 | { |
| 8305 | pScanCmd = csrGetCommandBuffer(pMac); |
| 8306 | if(!pScanCmd) |
| 8307 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 8308 | smsLog(pMac, LOGE, FL("failed to allocate command buffer")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8309 | status = eHAL_STATUS_RESOURCES; |
| 8310 | break; |
| 8311 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8312 | vos_mem_set(&pScanCmd->u.scanCmd, sizeof(tScanCmd), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8313 | status = eHAL_STATUS_SUCCESS; |
| 8314 | pScanCmd->u.scanCmd.roamId = 0; |
| 8315 | pScanCmd->command = eSmeCommandScan; |
| 8316 | pScanCmd->u.scanCmd.callback = NULL; |
| 8317 | pScanCmd->u.scanCmd.pContext = NULL; |
| 8318 | pScanCmd->u.scanCmd.reason = eCsrScanForCapsChange; |
| 8319 | pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around |
| 8320 | status = csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_FALSE); |
| 8321 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 8322 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 8323 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8324 | break; |
| 8325 | } |
| 8326 | }while(0); |
| 8327 | if(!HAL_STATUS_SUCCESS(status)) |
| 8328 | { |
| 8329 | if(pScanCmd) |
| 8330 | { |
| 8331 | csrReleaseCommandScan(pMac, pScanCmd); |
| 8332 | } |
| 8333 | } |
| 8334 | } |
| 8335 | |
| 8336 | return (status); |
| 8337 | } |
| 8338 | |
| 8339 | |
| 8340 | |
| 8341 | void csrInitBGScanChannelList(tpAniSirGlobal pMac) |
| 8342 | { |
| 8343 | tANI_U32 len = CSR_MIN(sizeof(pMac->roam.validChannelList), sizeof(pMac->scan.bgScanChannelList)); |
| 8344 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8345 | vos_mem_set(pMac->scan.bgScanChannelList, len, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8346 | pMac->scan.numBGScanChannel = 0; |
| 8347 | |
| 8348 | if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len))) |
| 8349 | { |
| 8350 | pMac->roam.numValidChannels = len; |
| 8351 | pMac->scan.numBGScanChannel = (tANI_U8)CSR_MIN(len, WNI_CFG_BG_SCAN_CHANNEL_LIST_LEN); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8352 | vos_mem_copy(pMac->scan.bgScanChannelList, pMac->roam.validChannelList, |
| 8353 | pMac->scan.numBGScanChannel); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8354 | csrSetBGScanChannelList(pMac, pMac->scan.bgScanChannelList, pMac->scan.numBGScanChannel); |
| 8355 | } |
| 8356 | } |
| 8357 | |
| 8358 | |
| 8359 | //This function return TRUE if background scan channel list is adjusted. |
| 8360 | //this function will only shrink the background scan channel list |
| 8361 | tANI_BOOLEAN csrAdjustBGScanChannelList(tpAniSirGlobal pMac, tANI_U8 *pChannelList, tANI_U8 NumChannels, |
| 8362 | tANI_U8 *pAdjustChannels, tANI_U8 *pNumAdjustChannels) |
| 8363 | { |
| 8364 | tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE; |
| 8365 | tANI_U8 i, j, count = *pNumAdjustChannels; |
| 8366 | |
| 8367 | i = 0; |
| 8368 | while(i < count) |
| 8369 | { |
| 8370 | for(j = 0; j < NumChannels; j++) |
| 8371 | { |
| 8372 | if(pChannelList[j] == pAdjustChannels[i]) |
| 8373 | break; |
| 8374 | } |
| 8375 | if(j == NumChannels) |
| 8376 | { |
| 8377 | //This channel is not in the list, remove it |
| 8378 | fRet = eANI_BOOLEAN_TRUE; |
| 8379 | count--; |
| 8380 | if(count - i) |
| 8381 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8382 | vos_mem_copy(&pAdjustChannels[i], &pAdjustChannels[i+1], count - i); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8383 | } |
| 8384 | else |
| 8385 | { |
| 8386 | //already remove the last one. Done. |
| 8387 | break; |
| 8388 | } |
| 8389 | } |
| 8390 | else |
| 8391 | { |
| 8392 | i++; |
| 8393 | } |
| 8394 | }//while(i<count) |
| 8395 | *pNumAdjustChannels = count; |
| 8396 | |
| 8397 | return (fRet); |
| 8398 | } |
| 8399 | |
| 8400 | |
| 8401 | //Get the list of the base channels to scan for passively 11d info |
| 8402 | eHalStatus csrScanGetSupportedChannels( tpAniSirGlobal pMac ) |
| 8403 | { |
| 8404 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 8405 | int n = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 8406 | |
| 8407 | status = vos_nv_getSupportedChannels( pMac->scan.baseChannels.channelList, &n, NULL, NULL ); |
| 8408 | if( HAL_STATUS_SUCCESS(status) ) |
| 8409 | { |
| 8410 | pMac->scan.baseChannels.numChannels = (tANI_U8)n; |
| 8411 | } |
| 8412 | else |
| 8413 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 8414 | smsLog( pMac, LOGE, FL(" failed") ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8415 | pMac->scan.baseChannels.numChannels = 0; |
| 8416 | } |
| 8417 | |
| 8418 | return ( status ); |
| 8419 | } |
| 8420 | |
| 8421 | //This function use the input pChannelList to validate the current saved channel list |
| 8422 | eHalStatus csrSetBGScanChannelList( tpAniSirGlobal pMac, tANI_U8 *pAdjustChannels, tANI_U8 NumAdjustChannels) |
| 8423 | { |
| 8424 | tANI_U32 dataLen = sizeof( tANI_U8 ) * NumAdjustChannels; |
| 8425 | |
| 8426 | return (ccmCfgSetStr(pMac, WNI_CFG_BG_SCAN_CHANNEL_LIST, pAdjustChannels, dataLen, NULL, eANI_BOOLEAN_FALSE)); |
| 8427 | } |
| 8428 | |
| 8429 | |
| 8430 | void csrSetCfgValidChannelList( tpAniSirGlobal pMac, tANI_U8 *pChannelList, tANI_U8 NumChannels ) |
| 8431 | { |
| 8432 | tANI_U32 dataLen = sizeof( tANI_U8 ) * NumChannels; |
Gopichand Nakkala | f72a387 | 2013-06-11 17:51:13 +0530 | [diff] [blame] | 8433 | eHalStatus status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8434 | |
Mihir Shete | 31c435d | 2014-02-12 13:13:34 +0530 | [diff] [blame] | 8435 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, |
| 8436 | "%s: dump valid channel list(NumChannels(%d))", |
| 8437 | __func__,NumChannels); |
| 8438 | VOS_TRACE_HEX_DUMP(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, |
| 8439 | pChannelList, NumChannels); |
| 8440 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8441 | ccmCfgSetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST, pChannelList, dataLen, NULL, eANI_BOOLEAN_FALSE); |
Leela Venkata Kiran Kumar Reddy Chirala | c6663f7 | 2014-02-03 21:04:58 -0800 | [diff] [blame] | 8442 | #ifdef QCA_WIFI_2_0 |
Gopichand Nakkala | f72a387 | 2013-06-11 17:51:13 +0530 | [diff] [blame] | 8443 | if (pMac->fScanOffload) |
| 8444 | { |
| 8445 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, |
| 8446 | "Scan offload is enabled, update default chan list"); |
Leela Venkata Kiran Kumar Reddy Chirala | c6663f7 | 2014-02-03 21:04:58 -0800 | [diff] [blame] | 8447 | status = csrUpdateChannelList(pMac); |
| 8448 | } |
| 8449 | #else |
| 8450 | status = csrUpdateChannelList(pMac); |
| 8451 | #endif |
| 8452 | |
| 8453 | if (eHAL_STATUS_SUCCESS != status) |
| 8454 | { |
| 8455 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, |
| 8456 | "failed to update the supported channel list"); |
Gopichand Nakkala | f72a387 | 2013-06-11 17:51:13 +0530 | [diff] [blame] | 8457 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8458 | return; |
| 8459 | } |
| 8460 | |
| 8461 | |
| 8462 | |
| 8463 | /* |
| 8464 | * The Tx power limits are saved in the cfg for future usage. |
| 8465 | */ |
| 8466 | void csrSaveTxPowerToCfg( tpAniSirGlobal pMac, tDblLinkList *pList, tANI_U32 cfgId ) |
| 8467 | { |
| 8468 | tListElem *pEntry; |
| 8469 | tANI_U32 cbLen = 0, dataLen; |
| 8470 | tCsrChannelPowerInfo *pChannelSet; |
| 8471 | tANI_U32 idx; |
| 8472 | tSirMacChanInfo *pChannelPowerSet; |
| 8473 | tANI_U8 *pBuf = NULL; |
| 8474 | |
| 8475 | //allocate maximum space for all channels |
| 8476 | dataLen = WNI_CFG_VALID_CHANNEL_LIST_LEN * sizeof(tSirMacChanInfo); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8477 | if ( (pBuf = vos_mem_malloc(dataLen)) != NULL ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8478 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8479 | vos_mem_set(pBuf, dataLen, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8480 | pChannelPowerSet = (tSirMacChanInfo *)(pBuf); |
| 8481 | |
| 8482 | pEntry = csrLLPeekHead( pList, LL_ACCESS_LOCK ); |
| 8483 | // write the tuples (startChan, numChan, txPower) for each channel found in the channel power list. |
| 8484 | while( pEntry ) |
| 8485 | { |
| 8486 | pChannelSet = GET_BASE_ADDR( pEntry, tCsrChannelPowerInfo, link ); |
| 8487 | if ( 1 != pChannelSet->interChannelOffset ) |
| 8488 | { |
| 8489 | // we keep the 5G channel sets internally with an interchannel offset of 4. Expand these |
| 8490 | // to the right format... (inter channel offset of 1 is the only option for the triplets |
| 8491 | // that 11d advertises. |
| 8492 | if ((cbLen + (pChannelSet->numChannels * sizeof(tSirMacChanInfo))) >= dataLen) |
| 8493 | { |
| 8494 | // expanding this entry will overflow our allocation |
| 8495 | smsLog(pMac, LOGE, |
| 8496 | "%s: Buffer overflow, start %d, num %d, offset %d", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8497 | __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8498 | pChannelSet->firstChannel, |
| 8499 | pChannelSet->numChannels, |
| 8500 | pChannelSet->interChannelOffset); |
| 8501 | break; |
| 8502 | } |
| 8503 | |
| 8504 | for( idx = 0; idx < pChannelSet->numChannels; idx++ ) |
| 8505 | { |
| 8506 | pChannelPowerSet->firstChanNum = (tSirMacChanNum)(pChannelSet->firstChannel + ( idx * pChannelSet->interChannelOffset )); |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 8507 | smsLog(pMac, LOG3, " Setting Channel Number %d", pChannelPowerSet->firstChanNum); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8508 | pChannelPowerSet->numChannels = 1; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8509 | pChannelPowerSet->maxTxPower = CSR_ROAM_MIN( pChannelSet->txPower, pMac->roam.configParam.nTxPowerCap ); |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 8510 | smsLog(pMac, LOG3, " Setting Max Transmit Power %d", pChannelPowerSet->maxTxPower); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8511 | cbLen += sizeof( tSirMacChanInfo ); |
| 8512 | pChannelPowerSet++; |
| 8513 | } |
| 8514 | } |
| 8515 | else |
| 8516 | { |
| 8517 | if (cbLen >= dataLen) |
| 8518 | { |
| 8519 | // this entry will overflow our allocation |
| 8520 | smsLog(pMac, LOGE, |
| 8521 | "%s: Buffer overflow, start %d, num %d, offset %d", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8522 | __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8523 | pChannelSet->firstChannel, |
| 8524 | pChannelSet->numChannels, |
| 8525 | pChannelSet->interChannelOffset); |
| 8526 | break; |
| 8527 | } |
| 8528 | pChannelPowerSet->firstChanNum = pChannelSet->firstChannel; |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 8529 | smsLog(pMac, LOG3, " Setting Channel Number %d", pChannelPowerSet->firstChanNum); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8530 | pChannelPowerSet->numChannels = pChannelSet->numChannels; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8531 | pChannelPowerSet->maxTxPower = CSR_ROAM_MIN( pChannelSet->txPower, pMac->roam.configParam.nTxPowerCap ); |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 8532 | smsLog(pMac, LOG3, " Setting Max Transmit Power %d, nTxPower %d", pChannelPowerSet->maxTxPower,pMac->roam.configParam.nTxPowerCap ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8533 | |
| 8534 | |
| 8535 | cbLen += sizeof( tSirMacChanInfo ); |
| 8536 | pChannelPowerSet++; |
| 8537 | } |
| 8538 | |
| 8539 | pEntry = csrLLNext( pList, pEntry, LL_ACCESS_LOCK ); |
| 8540 | } |
| 8541 | |
| 8542 | if(cbLen) |
| 8543 | { |
| 8544 | ccmCfgSetStr(pMac, cfgId, (tANI_U8 *)pBuf, cbLen, NULL, eANI_BOOLEAN_FALSE); |
| 8545 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8546 | vos_mem_free(pBuf); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8547 | }//Allocate memory |
| 8548 | } |
| 8549 | |
| 8550 | |
| 8551 | void csrSetCfgCountryCode( tpAniSirGlobal pMac, tANI_U8 *countryCode ) |
| 8552 | { |
| 8553 | tANI_U8 cc[WNI_CFG_COUNTRY_CODE_LEN]; |
| 8554 | ///v_REGDOMAIN_t DomainId; |
| 8555 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 8556 | smsLog( pMac, LOG3, "Setting Country Code in Cfg from csrSetCfgCountryCode %s",countryCode ); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8557 | vos_mem_copy(cc, countryCode, WNI_CFG_COUNTRY_CODE_LEN); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8558 | |
| 8559 | // don't program the bogus country codes that we created for Korea in the MAC. if we see |
| 8560 | // the bogus country codes, program the MAC with the right country code. |
| 8561 | if ( ( 'K' == countryCode[ 0 ] && '1' == countryCode[ 1 ] ) || |
| 8562 | ( 'K' == countryCode[ 0 ] && '2' == countryCode[ 1 ] ) || |
| 8563 | ( 'K' == countryCode[ 0 ] && '3' == countryCode[ 1 ] ) || |
| 8564 | ( 'K' == countryCode[ 0 ] && '4' == countryCode[ 1 ] ) ) |
| 8565 | { |
| 8566 | // replace the alternate Korea country codes, 'K1', 'K2', .. with 'KR' for Korea |
| 8567 | cc[ 1 ] = 'R'; |
| 8568 | } |
| 8569 | ccmCfgSetStr(pMac, WNI_CFG_COUNTRY_CODE, cc, WNI_CFG_COUNTRY_CODE_LEN, NULL, eANI_BOOLEAN_FALSE); |
| 8570 | |
| 8571 | //Need to let HALPHY know about the current domain so it can apply some |
| 8572 | //domain-specific settings (TX filter...) |
| 8573 | /*if(HAL_STATUS_SUCCESS(csrGetRegulatoryDomainForCountry(pMac, cc, &DomainId))) |
| 8574 | { |
| 8575 | halPhySetRegDomain(pMac, DomainId); |
| 8576 | }*/ |
| 8577 | } |
| 8578 | |
| 8579 | |
| 8580 | |
| 8581 | eHalStatus csrGetCountryCode(tpAniSirGlobal pMac, tANI_U8 *pBuf, tANI_U8 *pbLen) |
| 8582 | { |
| 8583 | eHalStatus status = eHAL_STATUS_INVALID_PARAMETER; |
| 8584 | tANI_U32 len; |
| 8585 | |
| 8586 | if(pBuf && pbLen && (*pbLen >= WNI_CFG_COUNTRY_CODE_LEN)) |
| 8587 | { |
| 8588 | len = *pbLen; |
| 8589 | status = ccmCfgGetStr(pMac, WNI_CFG_COUNTRY_CODE, pBuf, &len); |
| 8590 | if(HAL_STATUS_SUCCESS(status)) |
| 8591 | { |
| 8592 | *pbLen = (tANI_U8)len; |
| 8593 | } |
| 8594 | } |
| 8595 | |
| 8596 | return (status); |
| 8597 | } |
| 8598 | |
| 8599 | |
| 8600 | void csrSetCfgScanControlList( tpAniSirGlobal pMac, tANI_U8 *countryCode, tCsrChannel *pChannelList ) |
| 8601 | { |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 8602 | tANI_U8 i, j, k; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8603 | tANI_BOOLEAN found=FALSE; |
| 8604 | tANI_U8 *pControlList = NULL; |
| 8605 | tANI_U32 len = WNI_CFG_SCAN_CONTROL_LIST_LEN; |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 8606 | tANI_U8 cfgActiveDFSChannels = 0; |
| 8607 | tANI_U8 *cfgActiveDFSChannelLIst = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8608 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8609 | if ( (pControlList = vos_mem_malloc(WNI_CFG_SCAN_CONTROL_LIST_LEN)) != NULL ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8610 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8611 | vos_mem_set((void *)pControlList, WNI_CFG_SCAN_CONTROL_LIST_LEN, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8612 | if(HAL_STATUS_SUCCESS(ccmCfgGetStr(pMac, WNI_CFG_SCAN_CONTROL_LIST, pControlList, &len))) |
| 8613 | { |
| 8614 | for (i = 0; i < pChannelList->numChannels; i++) |
| 8615 | { |
| 8616 | for (j = 0; j < len; j += 2) |
| 8617 | { |
| 8618 | if (pControlList[j] == pChannelList->channelList[i]) |
| 8619 | { |
| 8620 | found = TRUE; |
| 8621 | break; |
| 8622 | } |
| 8623 | } |
| 8624 | |
| 8625 | if (found) // insert a pair(channel#, flag) |
| 8626 | { |
Gopichand Nakkala | 392cbc1 | 2013-05-28 16:15:00 +0530 | [diff] [blame] | 8627 | pControlList[j+1] = csrGetScanType(pMac, pControlList[j]); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8628 | found = FALSE; // reset the flag |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8629 | |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 8630 | // When DFS mode is 2, mark static channels as active |
| 8631 | if (pMac->scan.fEnableDFSChnlScan == |
| 8632 | DFS_CHNL_SCAN_ENABLED_ACTIVE) |
| 8633 | { |
| 8634 | cfgActiveDFSChannels = |
| 8635 | pMac->roam.neighborRoamInfo.cfgParams. |
| 8636 | channelInfo.numOfChannels; |
| 8637 | cfgActiveDFSChannelLIst = |
| 8638 | pMac->roam.neighborRoamInfo.cfgParams. |
| 8639 | channelInfo.ChannelList; |
| 8640 | if (cfgActiveDFSChannelLIst) |
| 8641 | { |
| 8642 | for (k=0; k < cfgActiveDFSChannels; k++) |
| 8643 | { |
| 8644 | if(CSR_IS_CHANNEL_DFS(cfgActiveDFSChannelLIst[k]) |
| 8645 | && (pControlList[j] == |
| 8646 | cfgActiveDFSChannelLIst[k])) |
| 8647 | { |
| 8648 | pControlList[j+1] = eSIR_ACTIVE_SCAN; |
| 8649 | smsLog(pMac, LOG1, FL("Marked DFS ch %d" |
| 8650 | " as active"), |
| 8651 | cfgActiveDFSChannelLIst[k]); |
| 8652 | } |
| 8653 | } |
| 8654 | } |
| 8655 | } |
| 8656 | } |
| 8657 | } |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 8658 | smsLog(pMac, LOG1, FL("fEnableDFSChnlScan %d"), |
| 8659 | pMac->scan.fEnableDFSChnlScan); |
Mihir Shete | 31c435d | 2014-02-12 13:13:34 +0530 | [diff] [blame] | 8660 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, |
| 8661 | "%s: dump scan control list",__func__); |
| 8662 | VOS_TRACE_HEX_DUMP(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, |
| 8663 | pControlList, len); |
| 8664 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8665 | ccmCfgSetStr(pMac, WNI_CFG_SCAN_CONTROL_LIST, pControlList, len, NULL, eANI_BOOLEAN_FALSE); |
| 8666 | }//Successfully getting scan control list |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8667 | vos_mem_free(pControlList); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8668 | }//AllocateMemory |
Abhishek Singh | 6fcdf65 | 2016-11-23 10:59:12 +0530 | [diff] [blame] | 8669 | |
| 8670 | /* Send msg to Lim to clear DFS channel list */ |
| 8671 | smsLog(pMac, LOG1, FL("csrClearDfsChannelList")); |
| 8672 | csrClearDfsChannelList(pMac); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8673 | } |
| 8674 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8675 | //if bgPeriod is 0, background scan is disabled. It is in millisecond units |
| 8676 | eHalStatus csrSetCfgBackgroundScanPeriod(tpAniSirGlobal pMac, tANI_U32 bgPeriod) |
| 8677 | { |
| 8678 | return (ccmCfgSetInt(pMac, WNI_CFG_BACKGROUND_SCAN_PERIOD, bgPeriod, (tCcmCfgSetCallback) csrScanCcmCfgSetCallback, eANI_BOOLEAN_FALSE)); |
| 8679 | } |
| 8680 | |
| 8681 | |
| 8682 | void csrScanCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result) |
| 8683 | { |
| 8684 | tListElem *pEntry = NULL; |
| 8685 | tSmeCmd *pCommand = NULL; |
| 8686 | tpAniSirGlobal pMac = PMAC_STRUCT( hHal ); |
Madan Mohan Koyyalamudi | 2125599 | 2013-08-01 18:00:25 +0530 | [diff] [blame] | 8687 | tDblLinkList *pCmdList ; |
| 8688 | |
| 8689 | if (!pMac->fScanOffload) |
| 8690 | pCmdList = &pMac->sme.smeCmdActiveList; |
| 8691 | else |
| 8692 | pCmdList = &pMac->sme.smeScanCmdActiveList; |
| 8693 | |
| 8694 | pEntry = csrLLPeekHead( pCmdList, LL_ACCESS_LOCK ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8695 | if ( pEntry ) |
| 8696 | { |
| 8697 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 8698 | if ( eSmeCommandScan == pCommand->command ) |
| 8699 | { |
| 8700 | eCsrScanStatus scanStatus = (CCM_IS_RESULT_SUCCESS(result)) ? eCSR_SCAN_SUCCESS : eCSR_SCAN_FAILURE; |
| 8701 | csrReleaseScanCommand(pMac, pCommand, scanStatus); |
| 8702 | } |
| 8703 | else |
| 8704 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 8705 | smsLog( pMac, LOGW, "CSR: Scan Completion called but SCAN command is not ACTIVE ..." ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8706 | } |
| 8707 | } |
| 8708 | smeProcessPendingQueue( pMac ); |
| 8709 | } |
| 8710 | |
| 8711 | eHalStatus csrProcessSetBGScanParam(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
| 8712 | { |
| 8713 | eHalStatus status; |
| 8714 | tCsrBGScanRequest *pScanReq = &pCommand->u.scanCmd.u.bgScanRequest; |
| 8715 | tANI_U32 dataLen = sizeof( tANI_U8 ) * pScanReq->ChannelInfo.numOfChannels; |
| 8716 | |
| 8717 | //***setcfg for background scan channel list |
| 8718 | status = ccmCfgSetInt(pMac, WNI_CFG_ACTIVE_MINIMUM_CHANNEL_TIME, pScanReq->minChnTime, NULL, eANI_BOOLEAN_FALSE); |
| 8719 | status = ccmCfgSetInt(pMac, WNI_CFG_ACTIVE_MAXIMUM_CHANNEL_TIME, pScanReq->maxChnTime, NULL, eANI_BOOLEAN_FALSE); |
| 8720 | //Not set the background scan interval if not connected because bd scan should not be run if not connected |
| 8721 | if(!csrIsAllSessionDisconnected(pMac)) |
| 8722 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8723 | |
| 8724 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 8725 | { |
| 8726 | vos_log_scan_pkt_type *pScanLog = NULL; |
| 8727 | |
| 8728 | WLAN_VOS_DIAG_LOG_ALLOC(pScanLog, vos_log_scan_pkt_type, LOG_WLAN_SCAN_C); |
| 8729 | if(pScanLog) |
| 8730 | { |
| 8731 | pScanLog->eventId = WLAN_SCAN_EVENT_HO_SCAN_REQ; |
| 8732 | pScanLog->minChnTime = (v_U8_t)pScanReq->minChnTime; |
| 8733 | pScanLog->maxChnTime = (v_U8_t)pScanReq->maxChnTime; |
| 8734 | pScanLog->timeBetweenBgScan = (v_U8_t)pScanReq->scanInterval; |
| 8735 | pScanLog->numChannel = pScanReq->ChannelInfo.numOfChannels; |
| 8736 | if(pScanLog->numChannel && (pScanLog->numChannel < VOS_LOG_MAX_NUM_CHANNEL)) |
| 8737 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8738 | vos_mem_copy(pScanLog->channels, |
| 8739 | pScanReq->ChannelInfo.ChannelList, |
| 8740 | pScanLog->numChannel); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8741 | } |
| 8742 | WLAN_VOS_DIAG_LOG_REPORT(pScanLog); |
| 8743 | } |
| 8744 | } |
| 8745 | #endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 8746 | |
| 8747 | status = ccmCfgSetInt(pMac, WNI_CFG_BACKGROUND_SCAN_PERIOD, pScanReq->scanInterval, NULL, eANI_BOOLEAN_FALSE); |
| 8748 | } |
| 8749 | else |
| 8750 | { |
| 8751 | //No need to stop aging because IDLE scan is still running |
| 8752 | status = ccmCfgSetInt(pMac, WNI_CFG_BACKGROUND_SCAN_PERIOD, 0, NULL, eANI_BOOLEAN_FALSE); |
| 8753 | } |
| 8754 | |
| 8755 | if(pScanReq->SSID.length > WNI_CFG_SSID_LEN) |
| 8756 | { |
| 8757 | pScanReq->SSID.length = WNI_CFG_SSID_LEN; |
| 8758 | } |
| 8759 | |
| 8760 | status = ccmCfgSetStr(pMac, WNI_CFG_BG_SCAN_CHANNEL_LIST, pScanReq->ChannelInfo.ChannelList, dataLen, NULL, eANI_BOOLEAN_FALSE); |
| 8761 | status = ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pScanReq->SSID.ssId, pScanReq->SSID.length, NULL, eANI_BOOLEAN_FALSE); |
| 8762 | |
| 8763 | |
| 8764 | |
| 8765 | return (status); |
| 8766 | } |
| 8767 | |
| 8768 | |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 8769 | tSirAbortScanStatus csrScanAbortMacScan(tpAniSirGlobal pMac, |
| 8770 | tANI_U8 sessionId, |
| 8771 | eCsrAbortReason reason) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8772 | { |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 8773 | tSirAbortScanStatus abortScanStatus = eSIR_ABORT_ACTIVE_SCAN_LIST_EMPTY; |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 8774 | tSirSmeScanAbortReq *pMsg; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8775 | tANI_U16 msgLen; |
| 8776 | tListElem *pEntry; |
| 8777 | tSmeCmd *pCommand; |
| 8778 | |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 8779 | if (!pMac->fScanOffload) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8780 | { |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 8781 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 8782 | csrLLLock(&pMac->scan.scanCmdPendingList); |
| 8783 | while(NULL != |
| 8784 | (pEntry = csrLLRemoveHead(&pMac->scan.scanCmdPendingList, |
| 8785 | LL_ACCESS_NOLOCK))) |
| 8786 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8787 | |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 8788 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 8789 | csrAbortCommand( pMac, pCommand, eANI_BOOLEAN_FALSE); |
| 8790 | } |
| 8791 | csrLLUnlock(&pMac->scan.scanCmdPendingList); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8792 | #endif |
| 8793 | |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 8794 | pMac->scan.fDropScanCmd = eANI_BOOLEAN_TRUE; |
| 8795 | csrRemoveCmdFromPendingList( pMac, &pMac->roam.roamCmdPendingList, eSmeCommandScan); |
| 8796 | csrRemoveCmdFromPendingList( pMac, &pMac->sme.smeCmdPendingList, eSmeCommandScan); |
| 8797 | pMac->scan.fDropScanCmd = eANI_BOOLEAN_FALSE; |
| 8798 | |
| 8799 | pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK); |
| 8800 | } |
| 8801 | else |
| 8802 | { |
| 8803 | pMac->scan.fDropScanCmd = eANI_BOOLEAN_TRUE; |
| 8804 | csrRemoveCmdWithSessionIdFromPendingList(pMac, |
| 8805 | sessionId, |
| 8806 | &pMac->sme.smeScanCmdPendingList, |
| 8807 | eSmeCommandScan); |
| 8808 | pMac->scan.fDropScanCmd = eANI_BOOLEAN_FALSE; |
| 8809 | |
| 8810 | pEntry = csrLLPeekHead(&pMac->sme.smeScanCmdActiveList, LL_ACCESS_LOCK); |
| 8811 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8812 | |
| 8813 | //We need to abort scan only if we are scanning |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 8814 | if(NULL != pEntry) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8815 | { |
| 8816 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 8817 | if(eSmeCommandScan == pCommand->command && |
| 8818 | pCommand->sessionId == sessionId) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8819 | { |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 8820 | msgLen = (tANI_U16)(sizeof(tSirSmeScanAbortReq)); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8821 | pMsg = vos_mem_malloc(msgLen); |
| 8822 | if ( NULL == pMsg ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8823 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8824 | smsLog(pMac, LOGE, FL("Failed to allocate memory for SmeScanAbortReq")); |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 8825 | abortScanStatus = eSIR_ABORT_SCAN_FAILURE; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8826 | } |
| 8827 | else |
| 8828 | { |
Ratheesh S P | ece1f83 | 2015-07-25 15:50:25 +0530 | [diff] [blame] | 8829 | pCommand->u.scanCmd.abortScanIndication = eCSR_SCAN_ABORT_DEFAULT; |
Srinivas, Dasari | 187ca4e | 2014-02-07 12:40:09 +0530 | [diff] [blame] | 8830 | if(reason == eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE) |
| 8831 | { |
Ratheesh S P | ece1f83 | 2015-07-25 15:50:25 +0530 | [diff] [blame] | 8832 | pCommand->u.scanCmd.abortScanIndication |
| 8833 | = eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE; |
Srinivas, Dasari | 187ca4e | 2014-02-07 12:40:09 +0530 | [diff] [blame] | 8834 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8835 | vos_mem_set((void *)pMsg, msgLen, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8836 | pMsg->type = pal_cpu_to_be16((tANI_U16)eWNI_SME_SCAN_ABORT_IND); |
| 8837 | pMsg->msgLen = pal_cpu_to_be16(msgLen); |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 8838 | pMsg->sessionId = sessionId; |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 8839 | if (eHAL_STATUS_SUCCESS != palSendMBMessage(pMac->hHdd, pMsg)) |
| 8840 | { |
| 8841 | smsLog(pMac, LOGE, |
| 8842 | FL("Failed to post eWNI_SME_SCAN_ABORT_IND")); |
| 8843 | abortScanStatus = eSIR_ABORT_SCAN_FAILURE; |
Ratheesh S P | ece1f83 | 2015-07-25 15:50:25 +0530 | [diff] [blame] | 8844 | pCommand->u.scanCmd.abortScanIndication = 0; |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 8845 | } |
| 8846 | else |
| 8847 | { |
| 8848 | abortScanStatus = eSIR_ABORT_ACTIVE_SCAN_LIST_NOT_EMPTY; |
| 8849 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8850 | } |
| 8851 | } |
| 8852 | } |
| 8853 | |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 8854 | return(abortScanStatus); |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 8855 | } |
| 8856 | |
| 8857 | void csrRemoveCmdWithSessionIdFromPendingList(tpAniSirGlobal pMac, |
| 8858 | tANI_U8 sessionId, |
| 8859 | tDblLinkList *pList, |
| 8860 | eSmeCommandType commandType) |
| 8861 | { |
| 8862 | tDblLinkList localList; |
| 8863 | tListElem *pEntry; |
| 8864 | tSmeCmd *pCommand; |
| 8865 | tListElem *pEntryToRemove; |
| 8866 | |
| 8867 | vos_mem_zero(&localList, sizeof(tDblLinkList)); |
| 8868 | if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList))) |
| 8869 | { |
| 8870 | smsLog(pMac, LOGE, FL(" failed to open list")); |
| 8871 | return; |
| 8872 | } |
| 8873 | |
| 8874 | csrLLLock(pList); |
| 8875 | if ((pEntry = csrLLPeekHead( pList, LL_ACCESS_NOLOCK))) |
| 8876 | { |
| 8877 | |
| 8878 | /* Have to make sure we don't loop back to the head of the list, |
| 8879 | * which will happen if the entry is NOT on the list */ |
| 8880 | while (pEntry) |
| 8881 | { |
| 8882 | pEntryToRemove = pEntry; |
| 8883 | pEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK); |
| 8884 | pCommand = GET_BASE_ADDR( pEntryToRemove, tSmeCmd, Link ); |
| 8885 | if ((pCommand->command == commandType) && |
| 8886 | (pCommand->sessionId == sessionId)) |
| 8887 | { |
| 8888 | /* Remove that entry only */ |
| 8889 | if (csrLLRemoveEntry( pList, pEntryToRemove, LL_ACCESS_NOLOCK)) |
| 8890 | { |
| 8891 | csrLLInsertTail(&localList, pEntryToRemove, |
| 8892 | LL_ACCESS_NOLOCK); |
| 8893 | } |
| 8894 | } |
| 8895 | } |
| 8896 | } |
| 8897 | csrLLUnlock(pList); |
| 8898 | |
| 8899 | while ((pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK))) |
| 8900 | { |
| 8901 | pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link); |
| 8902 | csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_FALSE); |
| 8903 | } |
| 8904 | |
| 8905 | csrLLClose(&localList); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8906 | } |
| 8907 | |
| 8908 | void csrRemoveCmdFromPendingList(tpAniSirGlobal pMac, tDblLinkList *pList, |
| 8909 | eSmeCommandType commandType ) |
| 8910 | { |
| 8911 | tDblLinkList localList; |
| 8912 | tListElem *pEntry; |
| 8913 | tSmeCmd *pCommand; |
| 8914 | tListElem *pEntryToRemove; |
| 8915 | |
| 8916 | vos_mem_zero(&localList, sizeof(tDblLinkList)); |
| 8917 | if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList))) |
| 8918 | { |
| 8919 | smsLog(pMac, LOGE, FL(" failed to open list")); |
| 8920 | return; |
| 8921 | } |
| 8922 | |
| 8923 | csrLLLock(pList); |
| 8924 | if( !csrLLIsListEmpty( pList, LL_ACCESS_NOLOCK ) ) |
| 8925 | { |
| 8926 | pEntry = csrLLPeekHead( pList, LL_ACCESS_NOLOCK); |
| 8927 | |
| 8928 | // Have to make sure we don't loop back to the head of the list, which will |
| 8929 | // happen if the entry is NOT on the list... |
| 8930 | while( pEntry ) |
| 8931 | { |
| 8932 | pEntryToRemove = pEntry; |
| 8933 | pEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK); |
| 8934 | pCommand = GET_BASE_ADDR( pEntryToRemove, tSmeCmd, Link ); |
| 8935 | if ( pCommand->command == commandType ) |
| 8936 | { |
| 8937 | // Remove that entry only |
| 8938 | if(csrLLRemoveEntry( pList, pEntryToRemove, LL_ACCESS_NOLOCK)) |
| 8939 | { |
| 8940 | csrLLInsertTail(&localList, pEntryToRemove, LL_ACCESS_NOLOCK); |
| 8941 | } |
| 8942 | } |
| 8943 | } |
| 8944 | |
| 8945 | |
| 8946 | } |
| 8947 | csrLLUnlock(pList); |
| 8948 | |
| 8949 | while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) ) |
| 8950 | { |
| 8951 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 8952 | csrAbortCommand( pMac, pCommand, eANI_BOOLEAN_FALSE); |
| 8953 | } |
| 8954 | csrLLClose(&localList); |
| 8955 | |
| 8956 | } |
| 8957 | |
Abhishek Singh | dc2bfd4 | 2014-06-19 17:59:05 +0530 | [diff] [blame] | 8958 | eHalStatus csrScanAbortScanForSSID(tpAniSirGlobal pMac, tANI_U32 sessionId) |
| 8959 | { |
| 8960 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 8961 | tSirSmeScanAbortReq *pMsg; |
| 8962 | tANI_U16 msgLen; |
| 8963 | tListElem *pEntry; |
| 8964 | tSmeCmd *pCommand; |
| 8965 | |
| 8966 | if (!pMac->fScanOffload) |
| 8967 | { |
| 8968 | pMac->scan.fDropScanCmd = eANI_BOOLEAN_TRUE; |
| 8969 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 8970 | csrRemoveScanForSSIDFromPendingList( pMac, &pMac->scan.scanCmdPendingList, sessionId); |
| 8971 | #endif |
| 8972 | csrRemoveScanForSSIDFromPendingList( pMac, &pMac->roam.roamCmdPendingList, sessionId); |
| 8973 | csrRemoveScanForSSIDFromPendingList( pMac, &pMac->sme.smeCmdPendingList, sessionId); |
| 8974 | pMac->scan.fDropScanCmd = eANI_BOOLEAN_FALSE; |
| 8975 | pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK); |
| 8976 | } |
| 8977 | else |
| 8978 | { |
| 8979 | pMac->scan.fDropScanCmd = eANI_BOOLEAN_TRUE; |
| 8980 | csrRemoveScanForSSIDFromPendingList( pMac, &pMac->sme.smeScanCmdPendingList, sessionId); |
| 8981 | pMac->scan.fDropScanCmd = eANI_BOOLEAN_FALSE; |
| 8982 | pEntry = csrLLPeekHead(&pMac->sme.smeScanCmdActiveList, LL_ACCESS_LOCK); |
| 8983 | } |
| 8984 | |
| 8985 | if(NULL != pEntry) |
| 8986 | { |
| 8987 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 8988 | |
| 8989 | if ( (eSmeCommandScan == pCommand->command ) && |
| 8990 | (sessionId == pCommand->sessionId)) |
| 8991 | { |
| 8992 | if ( eCsrScanForSsid == pCommand->u.scanCmd.reason) |
| 8993 | { |
| 8994 | msgLen = (tANI_U16)(sizeof( tSirSmeScanAbortReq )); |
| 8995 | pMsg = vos_mem_malloc(msgLen); |
| 8996 | if ( NULL == pMsg ) |
| 8997 | { |
| 8998 | status = eHAL_STATUS_FAILURE; |
| 8999 | smsLog(pMac, LOGE, FL("Failed to allocate memory for SmeScanAbortReq")); |
| 9000 | } |
| 9001 | else |
| 9002 | { |
| 9003 | vos_mem_zero((void *)pMsg, msgLen); |
| 9004 | pMsg->type = pal_cpu_to_be16((tANI_U16)eWNI_SME_SCAN_ABORT_IND); |
| 9005 | pMsg->msgLen = pal_cpu_to_be16(msgLen); |
| 9006 | pMsg->sessionId = sessionId; |
| 9007 | status = palSendMBMessage(pMac->hHdd, pMsg); |
| 9008 | } |
| 9009 | } |
| 9010 | } |
| 9011 | } |
| 9012 | return( status ); |
| 9013 | } |
| 9014 | |
| 9015 | void csrRemoveScanForSSIDFromPendingList(tpAniSirGlobal pMac, tDblLinkList *pList, tANI_U32 sessionId) |
| 9016 | { |
| 9017 | tDblLinkList localList; |
| 9018 | tListElem *pEntry; |
| 9019 | tSmeCmd *pCommand; |
| 9020 | tListElem *pEntryToRemove; |
| 9021 | |
| 9022 | vos_mem_zero(&localList, sizeof(tDblLinkList)); |
| 9023 | if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList))) |
| 9024 | { |
| 9025 | smsLog(pMac, LOGE, FL(" failed to open list")); |
| 9026 | return; |
| 9027 | } |
| 9028 | |
| 9029 | csrLLLock(pList); |
| 9030 | if( !csrLLIsListEmpty( pList, LL_ACCESS_NOLOCK ) ) |
| 9031 | { |
| 9032 | pEntry = csrLLPeekHead( pList, LL_ACCESS_NOLOCK); |
| 9033 | |
| 9034 | // Have to make sure we don't loop back to the head of the list, which will |
| 9035 | // happen if the entry is NOT on the list... |
| 9036 | while( pEntry ) |
| 9037 | { |
| 9038 | pEntryToRemove = pEntry; |
| 9039 | pEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK); |
| 9040 | pCommand = GET_BASE_ADDR( pEntryToRemove, tSmeCmd, Link ); |
| 9041 | if ( (eSmeCommandScan == pCommand->command ) && |
| 9042 | (sessionId == pCommand->sessionId) ) |
| 9043 | { |
| 9044 | if ( eCsrScanForSsid == pCommand->u.scanCmd.reason) |
| 9045 | { |
| 9046 | // Remove that entry only |
| 9047 | if ( csrLLRemoveEntry( pList, pEntryToRemove, LL_ACCESS_NOLOCK)) |
| 9048 | { |
| 9049 | csrLLInsertTail(&localList, pEntryToRemove, LL_ACCESS_NOLOCK); |
| 9050 | } |
| 9051 | } |
| 9052 | } |
| 9053 | } |
| 9054 | } |
| 9055 | csrLLUnlock(pList); |
| 9056 | |
| 9057 | while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) ) |
| 9058 | { |
| 9059 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 9060 | csrAbortCommand( pMac, pCommand, eANI_BOOLEAN_FALSE); |
| 9061 | } |
| 9062 | csrLLClose(&localList); |
| 9063 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9064 | |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 9065 | eHalStatus csrScanAbortMacScanNotForConnect(tpAniSirGlobal pMac, |
| 9066 | tANI_U8 sessionId) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9067 | { |
| 9068 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 9069 | |
| 9070 | if( !csrIsScanForRoamCommandActive( pMac ) ) |
| 9071 | { |
| 9072 | //Only abort the scan if it is not used for other roam/connect purpose |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 9073 | if (eSIR_ABORT_SCAN_FAILURE == |
| 9074 | csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT)) |
| 9075 | { |
| 9076 | smsLog(pMac, LOGE, FL("fail to abort scan")); |
| 9077 | status = eHAL_STATUS_FAILURE; |
| 9078 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9079 | } |
| 9080 | |
| 9081 | return (status); |
| 9082 | } |
| 9083 | |
| 9084 | |
Madan Mohan Koyyalamudi | de1b5bc | 2013-07-12 00:56:04 +0530 | [diff] [blame] | 9085 | eHalStatus csrScanGetScanChannelInfo(tpAniSirGlobal pMac, tANI_U8 sessionId) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9086 | { |
| 9087 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 9088 | tSirMbMsg *pMsg; |
| 9089 | tANI_U16 msgLen; |
| 9090 | |
Madan Mohan Koyyalamudi | de1b5bc | 2013-07-12 00:56:04 +0530 | [diff] [blame] | 9091 | if (pMac->fScanOffload) |
| 9092 | msgLen = (tANI_U16)(sizeof(tSirSmeGetScanChanReq)); |
| 9093 | else |
| 9094 | msgLen = (tANI_U16)(sizeof(tSirMbMsg)); |
| 9095 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 9096 | pMsg = vos_mem_malloc(msgLen); |
| 9097 | if ( NULL == pMsg ) |
| 9098 | status = eHAL_STATUS_FAILURE; |
| 9099 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9100 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 9101 | vos_mem_set(pMsg, msgLen, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9102 | pMsg->type = eWNI_SME_GET_SCANNED_CHANNEL_REQ; |
| 9103 | pMsg->msgLen = msgLen; |
Madan Mohan Koyyalamudi | de1b5bc | 2013-07-12 00:56:04 +0530 | [diff] [blame] | 9104 | if (pMac->fScanOffload) |
| 9105 | ((tSirSmeGetScanChanReq *)pMsg)->sessionId = sessionId; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9106 | status = palSendMBMessage(pMac->hHdd, pMsg); |
| 9107 | } |
| 9108 | |
| 9109 | return( status ); |
| 9110 | } |
| 9111 | |
| 9112 | tANI_BOOLEAN csrRoamIsValidChannel( tpAniSirGlobal pMac, tANI_U8 channel ) |
| 9113 | { |
| 9114 | tANI_BOOLEAN fValid = FALSE; |
| 9115 | tANI_U32 idxValidChannels; |
| 9116 | tANI_U32 len = pMac->roam.numValidChannels; |
| 9117 | |
| 9118 | for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ ) |
| 9119 | { |
| 9120 | if ( channel == pMac->roam.validChannelList[ idxValidChannels ] ) |
| 9121 | { |
| 9122 | fValid = TRUE; |
| 9123 | break; |
| 9124 | } |
| 9125 | } |
| 9126 | |
| 9127 | return fValid; |
| 9128 | } |
| 9129 | |
Manjunathappa Prakash | 4f1d5a5 | 2013-11-11 16:22:19 -0800 | [diff] [blame] | 9130 | #ifdef FEATURE_WLAN_SCAN_PNO |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9131 | eHalStatus csrScanSavePreferredNetworkFound(tpAniSirGlobal pMac, |
| 9132 | tSirPrefNetworkFoundInd *pPrefNetworkFoundInd) |
| 9133 | { |
| 9134 | v_U32_t uLen = 0; |
| 9135 | tpSirProbeRespBeacon pParsedFrame; |
| 9136 | tCsrScanResult *pScanResult = NULL; |
| 9137 | tSirBssDescription *pBssDescr = NULL; |
| 9138 | tANI_BOOLEAN fDupBss; |
| 9139 | tDot11fBeaconIEs *pIesLocal = NULL; |
| 9140 | tAniSSID tmpSsid; |
| 9141 | v_TIME_t timer=0; |
| 9142 | tpSirMacMgmtHdr macHeader = (tpSirMacMgmtHdr)pPrefNetworkFoundInd->data; |
Abhishek Singh | d3d4e02 | 2014-11-11 13:02:40 +0530 | [diff] [blame] | 9143 | boolean bFoundonAppliedChannel = FALSE; |
| 9144 | v_U32_t indx; |
| 9145 | u8 channelsAllowed[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 9146 | v_U32_t numChannelsAllowed = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
Sushant Kaushik | 6274de6 | 2015-05-01 16:31:23 +0530 | [diff] [blame] | 9147 | tListElem *pEntry; |
Abhishek Singh | d3d4e02 | 2014-11-11 13:02:40 +0530 | [diff] [blame] | 9148 | |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9149 | |
| 9150 | pParsedFrame = |
Abhishek Singh | c75726d | 2015-04-13 14:44:14 +0530 | [diff] [blame] | 9151 | (tpSirProbeRespBeacon)vos_mem_vmalloc(sizeof(tSirProbeRespBeacon)); |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9152 | |
| 9153 | if (NULL == pParsedFrame) |
| 9154 | { |
| 9155 | smsLog(pMac, LOGE, FL(" fail to allocate memory for frame")); |
| 9156 | return eHAL_STATUS_RESOURCES; |
| 9157 | } |
| 9158 | |
| 9159 | if ( pPrefNetworkFoundInd->frameLength <= SIR_MAC_HDR_LEN_3A ) |
| 9160 | { |
| 9161 | smsLog(pMac, LOGE, |
| 9162 | FL("Not enough bytes in PNO indication probe resp frame! length=%d"), |
| 9163 | pPrefNetworkFoundInd->frameLength); |
Abhishek Singh | c75726d | 2015-04-13 14:44:14 +0530 | [diff] [blame] | 9164 | vos_mem_vfree(pParsedFrame); |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9165 | return eHAL_STATUS_FAILURE; |
| 9166 | } |
| 9167 | |
| 9168 | if (sirConvertProbeFrame2Struct(pMac, |
| 9169 | &pPrefNetworkFoundInd->data[SIR_MAC_HDR_LEN_3A], |
| 9170 | pPrefNetworkFoundInd->frameLength - SIR_MAC_HDR_LEN_3A, |
| 9171 | pParsedFrame) != eSIR_SUCCESS || |
| 9172 | !pParsedFrame->ssidPresent) |
| 9173 | { |
| 9174 | smsLog(pMac, LOGE, |
| 9175 | FL("Parse error ProbeResponse, length=%d"), |
| 9176 | pPrefNetworkFoundInd->frameLength); |
Abhishek Singh | c75726d | 2015-04-13 14:44:14 +0530 | [diff] [blame] | 9177 | vos_mem_vfree(pParsedFrame); |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9178 | return eHAL_STATUS_FAILURE; |
| 9179 | } |
| 9180 | //24 byte MAC header and 12 byte to ssid IE |
| 9181 | if (pPrefNetworkFoundInd->frameLength > |
| 9182 | (SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_SSID_OFFSET)) |
| 9183 | { |
| 9184 | uLen = pPrefNetworkFoundInd->frameLength - |
| 9185 | (SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_SSID_OFFSET); |
| 9186 | } |
| 9187 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 9188 | pScanResult = vos_mem_malloc(sizeof(tCsrScanResult) + uLen); |
| 9189 | if ( NULL == pScanResult ) |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9190 | { |
| 9191 | smsLog(pMac, LOGE, FL(" fail to allocate memory for frame")); |
| 9192 | vos_mem_free(pParsedFrame); |
| 9193 | return eHAL_STATUS_RESOURCES; |
| 9194 | } |
| 9195 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 9196 | vos_mem_set(pScanResult, sizeof(tCsrScanResult) + uLen, 0); |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9197 | pBssDescr = &pScanResult->Result.BssDescriptor; |
| 9198 | /** |
| 9199 | * Length of BSS desription is without length of |
| 9200 | * length itself and length of pointer |
| 9201 | * that holds the next BSS description |
| 9202 | */ |
| 9203 | pBssDescr->length = (tANI_U16)( |
Abhishek Singh | bad2b32 | 2016-10-21 11:22:33 +0530 | [diff] [blame] | 9204 | ((uintptr_t)OFFSET_OF(tSirBssDescription, ieFields)) |
| 9205 | - sizeof(pBssDescr->length) + uLen); |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9206 | if (pParsedFrame->dsParamsPresent) |
| 9207 | { |
| 9208 | pBssDescr->channelId = pParsedFrame->channelNumber; |
| 9209 | } |
| 9210 | else if (pParsedFrame->HTInfo.present) |
| 9211 | { |
| 9212 | pBssDescr->channelId = pParsedFrame->HTInfo.primaryChannel; |
| 9213 | } |
| 9214 | else |
| 9215 | { |
Mahesh A Saptasagar | add9979 | 2014-03-26 16:04:20 +0530 | [diff] [blame] | 9216 | /** |
| 9217 | * If Probe Responce received in PNO indication does not |
| 9218 | * contain DSParam IE or HT Info IE then add dummy channel |
| 9219 | * to the received BSS info so that Scan result received as |
| 9220 | * a part of PNO is updated to the supplicant. Specially |
| 9221 | * applicable in case of AP configured in 11A only mode. |
| 9222 | */ |
| 9223 | if ((pMac->roam.configParam.bandCapability == eCSR_BAND_ALL) || |
| 9224 | (pMac->roam.configParam.bandCapability == eCSR_BAND_24)) |
| 9225 | { |
| 9226 | pBssDescr->channelId = 1; |
| 9227 | } |
| 9228 | else if(pMac->roam.configParam.bandCapability == eCSR_BAND_5G) |
| 9229 | { |
| 9230 | pBssDescr->channelId = 36; |
| 9231 | } |
Abhishek Singh | d3d4e02 | 2014-11-11 13:02:40 +0530 | [diff] [blame] | 9232 | /* Restrict the logic to ignore the pno indication for invalid channel |
| 9233 | * only if valid channel info is present in beacon/probe resp. |
| 9234 | * If no channel info is present in beacon/probe resp, always process |
| 9235 | * the pno indication. |
| 9236 | */ |
| 9237 | bFoundonAppliedChannel = TRUE; |
| 9238 | } |
| 9239 | |
| 9240 | if (0 != sme_GetCfgValidChannels(pMac, channelsAllowed, &numChannelsAllowed)) |
| 9241 | { |
| 9242 | smsLog(pMac, LOGE, FL(" sme_GetCfgValidChannels failed ")); |
| 9243 | csrFreeScanResultEntry(pMac, pScanResult); |
Abhishek Singh | c75726d | 2015-04-13 14:44:14 +0530 | [diff] [blame] | 9244 | vos_mem_vfree(pParsedFrame); |
Abhishek Singh | d3d4e02 | 2014-11-11 13:02:40 +0530 | [diff] [blame] | 9245 | return eHAL_STATUS_FAILURE; |
| 9246 | } |
| 9247 | /* Checking chhanelId with allowed channel list */ |
| 9248 | for (indx = 0; indx < numChannelsAllowed; indx++) |
| 9249 | { |
| 9250 | if (pBssDescr->channelId == channelsAllowed[indx]) |
| 9251 | { |
| 9252 | bFoundonAppliedChannel = TRUE; |
| 9253 | smsLog(pMac, LOG1, FL(" pno ind found on applied channel =%d\n "), |
| 9254 | pBssDescr->channelId); |
| 9255 | break; |
| 9256 | } |
| 9257 | } |
| 9258 | /* Ignore PNO indication if AP is on Invalid channel. |
| 9259 | */ |
| 9260 | if(FALSE == bFoundonAppliedChannel) |
| 9261 | { |
| 9262 | smsLog(pMac, LOGW, FL(" prefered network found on invalid channel = %d"), |
| 9263 | pBssDescr->channelId); |
| 9264 | csrFreeScanResultEntry(pMac, pScanResult); |
Abhishek Singh | c75726d | 2015-04-13 14:44:14 +0530 | [diff] [blame] | 9265 | vos_mem_vfree(pParsedFrame); |
Abhishek Singh | d3d4e02 | 2014-11-11 13:02:40 +0530 | [diff] [blame] | 9266 | return eHAL_STATUS_FAILURE; |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9267 | } |
| 9268 | |
| 9269 | if ((pBssDescr->channelId > 0) && (pBssDescr->channelId < 15)) |
| 9270 | { |
| 9271 | int i; |
| 9272 | // 11b or 11g packet |
| 9273 | // 11g iff extended Rate IE is present or |
| 9274 | // if there is an A rate in suppRate IE |
| 9275 | for (i = 0; i < pParsedFrame->supportedRates.numRates; i++) |
| 9276 | { |
| 9277 | if (sirIsArate(pParsedFrame->supportedRates.rate[i] & 0x7f)) |
| 9278 | { |
| 9279 | pBssDescr->nwType = eSIR_11G_NW_TYPE; |
| 9280 | break; |
| 9281 | } |
| 9282 | } |
| 9283 | if (pParsedFrame->extendedRatesPresent) |
| 9284 | { |
| 9285 | pBssDescr->nwType = eSIR_11G_NW_TYPE; |
| 9286 | } |
| 9287 | } |
| 9288 | else |
| 9289 | { |
| 9290 | // 11a packet |
| 9291 | pBssDescr->nwType = eSIR_11A_NW_TYPE; |
| 9292 | } |
| 9293 | |
| 9294 | pBssDescr->sinr = 0; |
| 9295 | pBssDescr->rssi = -1 * pPrefNetworkFoundInd->rssi; |
| 9296 | pBssDescr->beaconInterval = pParsedFrame->beaconInterval; |
AnjaneeDevi Kapparapu | 4b04391 | 2014-02-18 13:22:35 +0530 | [diff] [blame] | 9297 | if (!pBssDescr->beaconInterval) |
| 9298 | { |
| 9299 | smsLog(pMac, LOGW, |
| 9300 | FL("Bcn Interval is Zero , default to 100" MAC_ADDRESS_STR), |
| 9301 | MAC_ADDR_ARRAY(pBssDescr->bssId) ); |
| 9302 | pBssDescr->beaconInterval = 100; |
| 9303 | } |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9304 | pBssDescr->timeStamp[0] = pParsedFrame->timeStamp[0]; |
| 9305 | pBssDescr->timeStamp[1] = pParsedFrame->timeStamp[1]; |
| 9306 | pBssDescr->capabilityInfo = *((tANI_U16 *)&pParsedFrame->capabilityInfo); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 9307 | vos_mem_copy((tANI_U8 *) &pBssDescr->bssId, (tANI_U8 *) macHeader->bssId, sizeof(tSirMacAddr)); |
Deepthi Gowri | 4480a3f | 2016-05-18 19:30:17 +0530 | [diff] [blame] | 9308 | pBssDescr->nReceivedTime = vos_timer_get_system_time(); |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9309 | |
Sreelakshmi Konamki | 9866a8c | 2017-02-10 12:45:27 +0530 | [diff] [blame] | 9310 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 9311 | // MobilityDomain |
| 9312 | pBssDescr->mdie[0] = 0; |
| 9313 | pBssDescr->mdie[1] = 0; |
| 9314 | pBssDescr->mdie[2] = 0; |
| 9315 | pBssDescr->mdiePresent = FALSE; |
| 9316 | // If mdie is present in the probe resp we fill it in the bss description |
| 9317 | if(pParsedFrame->mdiePresent) |
| 9318 | { |
| 9319 | pBssDescr->mdiePresent = TRUE; |
| 9320 | pBssDescr->mdie[0] = pParsedFrame->mdie[0]; |
| 9321 | pBssDescr->mdie[1] = pParsedFrame->mdie[1]; |
| 9322 | pBssDescr->mdie[2] = pParsedFrame->mdie[2]; |
| 9323 | } |
| 9324 | smsLog(pMac, LOG1, FL("mdie=%02x%02x%02x"), |
| 9325 | (unsigned int)pBssDescr->mdie[0], (unsigned int)pBssDescr->mdie[1], |
| 9326 | (unsigned int)pBssDescr->mdie[2]); |
| 9327 | #endif |
| 9328 | |
Abhishek Singh | 195c03e | 2014-05-14 17:21:30 +0530 | [diff] [blame] | 9329 | smsLog( pMac, LOG1, FL("Bssid= "MAC_ADDRESS_STR |
| 9330 | " chan= %d, rssi = %d "), |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 9331 | MAC_ADDR_ARRAY(pBssDescr->bssId), |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9332 | pBssDescr->channelId, |
Abhishek Singh | 195c03e | 2014-05-14 17:21:30 +0530 | [diff] [blame] | 9333 | pBssDescr->rssi); |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9334 | |
| 9335 | //IEs |
| 9336 | if (uLen) |
| 9337 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 9338 | vos_mem_copy(&pBssDescr->ieFields, |
| 9339 | pPrefNetworkFoundInd->data + (SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_SSID_OFFSET), |
| 9340 | uLen); |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9341 | } |
| 9342 | |
| 9343 | pIesLocal = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ); |
| 9344 | if ( !pIesLocal && |
| 9345 | (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, |
| 9346 | &pScanResult->Result.BssDescriptor, &pIesLocal))) ) |
| 9347 | { |
| 9348 | smsLog(pMac, LOGE, FL(" Cannot parse IEs")); |
| 9349 | csrFreeScanResultEntry(pMac, pScanResult); |
Abhishek Singh | c75726d | 2015-04-13 14:44:14 +0530 | [diff] [blame] | 9350 | vos_mem_vfree(pParsedFrame); |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9351 | return eHAL_STATUS_RESOURCES; |
| 9352 | } |
| 9353 | |
| 9354 | fDupBss = csrRemoveDupBssDescription( pMac, |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 9355 | &pScanResult->Result.BssDescriptor, pIesLocal, &tmpSsid, &timer, FALSE); |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9356 | //Check whether we have reach out limit |
| 9357 | if ( CSR_SCAN_IS_OVER_BSS_LIMIT(pMac) ) |
| 9358 | { |
| 9359 | //Limit reach |
| 9360 | smsLog(pMac, LOGE, FL(" BSS limit reached")); |
| 9361 | //Free the resources |
| 9362 | if( (pScanResult->Result.pvIes == NULL) && pIesLocal ) |
| 9363 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 9364 | vos_mem_free(pIesLocal); |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9365 | } |
| 9366 | csrFreeScanResultEntry(pMac, pScanResult); |
| 9367 | vos_mem_free(pParsedFrame); |
| 9368 | return eHAL_STATUS_RESOURCES; |
| 9369 | } |
Nalla Kartheek | 7194642 | 2015-09-15 14:41:22 +0530 | [diff] [blame] | 9370 | |
| 9371 | if ((macHeader->fc.type == SIR_MAC_MGMT_FRAME) && |
| 9372 | (macHeader->fc.subType == SIR_MAC_MGMT_PROBE_RSP)) |
| 9373 | { |
| 9374 | pScanResult->Result.BssDescriptor.fProbeRsp = 1; |
| 9375 | } |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9376 | //Add to scan cache |
| 9377 | csrScanAddResult(pMac, pScanResult, pIesLocal); |
Sushant Kaushik | 6274de6 | 2015-05-01 16:31:23 +0530 | [diff] [blame] | 9378 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_LOCK ); |
Kiet Lam | b537cfb | 2013-11-07 12:56:49 +0530 | [diff] [blame] | 9379 | if( (pScanResult->Result.pvIes == NULL) && pIesLocal ) |
| 9380 | { |
| 9381 | vos_mem_free(pIesLocal); |
| 9382 | } |
| 9383 | |
Abhishek Singh | c75726d | 2015-04-13 14:44:14 +0530 | [diff] [blame] | 9384 | vos_mem_vfree(pParsedFrame); |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9385 | |
| 9386 | return eHAL_STATUS_SUCCESS; |
| 9387 | } |
Manjunathappa Prakash | 4f1d5a5 | 2013-11-11 16:22:19 -0800 | [diff] [blame] | 9388 | #endif //FEATURE_WLAN_SCAN_PNO |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9389 | |
Madan Mohan Koyyalamudi | dd3c966 | 2012-11-09 17:39:30 -0800 | [diff] [blame] | 9390 | #ifdef FEATURE_WLAN_LFR |
| 9391 | void csrInitOccupiedChannelsList(tpAniSirGlobal pMac) |
| 9392 | { |
| 9393 | tListElem *pEntry = NULL; |
| 9394 | tCsrScanResult *pBssDesc = NULL; |
| 9395 | tDot11fBeaconIEs *pIes = NULL; |
Srinivas | 28b5b4e | 2012-12-12 13:07:53 -0800 | [diff] [blame] | 9396 | tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo; |
| 9397 | |
| 9398 | if (0 != pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels) |
| 9399 | { |
| 9400 | smsLog(pMac, LOG1, FL("%s: Ini file contains neighbor scan channel list," |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 9401 | " hence NO need to build occupied channel list (numChannels = %d)"), |
Srinivas | 28b5b4e | 2012-12-12 13:07:53 -0800 | [diff] [blame] | 9402 | __func__, pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels); |
| 9403 | return; |
| 9404 | } |
Madan Mohan Koyyalamudi | dd3c966 | 2012-11-09 17:39:30 -0800 | [diff] [blame] | 9405 | |
| 9406 | if (!csrNeighborRoamIsNewConnectedProfile(pMac)) |
| 9407 | { |
| 9408 | smsLog(pMac, LOG2, FL("%s: donot flush occupied list since current roam profile" |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 9409 | " matches previous (numChannels = %d)"), |
Madan Mohan Koyyalamudi | dd3c966 | 2012-11-09 17:39:30 -0800 | [diff] [blame] | 9410 | __func__, pMac->scan.occupiedChannels.numChannels); |
| 9411 | return; |
| 9412 | } |
| 9413 | |
| 9414 | /* Empty occupied channels here */ |
| 9415 | pMac->scan.occupiedChannels.numChannels = 0; |
| 9416 | |
| 9417 | csrLLLock(&pMac->scan.scanResultList); |
| 9418 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK ); |
| 9419 | while( pEntry ) |
| 9420 | { |
| 9421 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 9422 | pIes = (tDot11fBeaconIEs *)( pBssDesc->Result.pvIes ); |
| 9423 | |
| 9424 | //At this time, pBssDescription->Result.pvIes may be NULL |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 9425 | if( !pIes && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, |
Madan Mohan Koyyalamudi | dd3c966 | 2012-11-09 17:39:30 -0800 | [diff] [blame] | 9426 | &pBssDesc->Result.BssDescriptor, &pIes))) ) |
| 9427 | { |
| 9428 | continue; |
| 9429 | } |
| 9430 | |
| 9431 | csrScanAddToOccupiedChannels(pMac, pBssDesc, &pMac->scan.occupiedChannels, pIes); |
| 9432 | |
| 9433 | /* |
| 9434 | * Free the memory allocated for pIes in csrGetParsedBssDescriptionIEs |
| 9435 | */ |
| 9436 | if( (pBssDesc->Result.pvIes == NULL) && pIes ) |
| 9437 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 9438 | vos_mem_free(pIes); |
Madan Mohan Koyyalamudi | dd3c966 | 2012-11-09 17:39:30 -0800 | [diff] [blame] | 9439 | } |
| 9440 | |
| 9441 | pEntry = csrLLNext( &pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK ); |
| 9442 | }//while |
| 9443 | csrLLUnlock(&pMac->scan.scanResultList); |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 9444 | |
Madan Mohan Koyyalamudi | dd3c966 | 2012-11-09 17:39:30 -0800 | [diff] [blame] | 9445 | } |
| 9446 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9447 | |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 9448 | eHalStatus csrScanCreateEntryInScanCache(tpAniSirGlobal pMac, tANI_U32 sessionId, |
| 9449 | tCsrBssid bssid, tANI_U8 channel) |
| 9450 | { |
| 9451 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 9452 | tDot11fBeaconIEs *pNewIes = NULL; |
| 9453 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
Praveen Kumar Sirisilla | 8bdfac4 | 2013-10-10 17:20:48 -0700 | [diff] [blame] | 9454 | tSirBssDescription *pNewBssDescriptor = NULL; |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 9455 | tANI_U32 size = 0; |
| 9456 | |
| 9457 | if(NULL == pSession) |
| 9458 | { |
| 9459 | status = eHAL_STATUS_FAILURE; |
| 9460 | return status; |
| 9461 | } |
| 9462 | smsLog(pMac, LOG2, FL("csrScanCreateEntryInScanCache: Current bssid::" |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 9463 | MAC_ADDRESS_STR), |
| 9464 | MAC_ADDR_ARRAY(pSession->pConnectBssDesc->bssId)); |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 9465 | smsLog(pMac, LOG2, FL("csrScanCreateEntryInScanCache: My bssid::" |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 9466 | MAC_ADDRESS_STR" channel %d"), |
| 9467 | MAC_ADDR_ARRAY(bssid), channel); |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 9468 | |
| 9469 | do |
| 9470 | { |
| 9471 | if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, |
| 9472 | pSession->pConnectBssDesc, &pNewIes))) |
| 9473 | { |
| 9474 | smsLog(pMac, LOGE, FL("%s: Failed to parse IEs"), |
| 9475 | __func__); |
| 9476 | status = eHAL_STATUS_FAILURE; |
| 9477 | break; |
| 9478 | } |
| 9479 | |
| 9480 | size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 9481 | if (size) |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 9482 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 9483 | pNewBssDescriptor = vos_mem_malloc(size); |
| 9484 | if ( NULL == pNewBssDescriptor ) |
| 9485 | status = eHAL_STATUS_FAILURE; |
| 9486 | else |
| 9487 | status = eHAL_STATUS_SUCCESS; |
| 9488 | if (HAL_STATUS_SUCCESS(status)) |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 9489 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 9490 | vos_mem_copy(pNewBssDescriptor, pSession->pConnectBssDesc, size); |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 9491 | } |
| 9492 | else |
| 9493 | { |
| 9494 | smsLog(pMac, LOGE, FL("%s: memory allocation failed"), |
| 9495 | __func__); |
| 9496 | status = eHAL_STATUS_FAILURE; |
| 9497 | break; |
| 9498 | } |
| 9499 | |
| 9500 | //change the BSSID & channel as passed |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 9501 | vos_mem_copy(pNewBssDescriptor->bssId, bssid, sizeof(tSirMacAddr)); |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 9502 | pNewBssDescriptor->channelId = channel; |
Tushnim Bhattacharyya | 5128d75 | 2013-06-26 23:23:18 -0700 | [diff] [blame] | 9503 | if(NULL == csrScanAppendBssDescription( pMac, pNewBssDescriptor, pNewIes, TRUE )) |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 9504 | { |
Tushnim Bhattacharyya | 5128d75 | 2013-06-26 23:23:18 -0700 | [diff] [blame] | 9505 | smsLog(pMac, LOGE, FL("%s: csrScanAppendBssDescription failed"), |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 9506 | __func__); |
| 9507 | status = eHAL_STATUS_FAILURE; |
| 9508 | break; |
| 9509 | } |
| 9510 | } |
| 9511 | else |
| 9512 | { |
| 9513 | smsLog(pMac, LOGE, FL("%s: length of bss descriptor is 0"), |
| 9514 | __func__); |
| 9515 | status = eHAL_STATUS_FAILURE; |
| 9516 | break; |
| 9517 | } |
| 9518 | smsLog(pMac, LOGE, FL("%s: entry successfully added in scan cache"), |
| 9519 | __func__); |
| 9520 | }while(0); |
| 9521 | |
| 9522 | if(pNewIes) |
| 9523 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 9524 | vos_mem_free(pNewIes); |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 9525 | } |
| 9526 | if(pNewBssDescriptor) |
| 9527 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 9528 | vos_mem_free(pNewBssDescriptor); |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 9529 | } |
| 9530 | return status; |
| 9531 | } |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 9532 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 9533 | #ifdef FEATURE_WLAN_ESE |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 9534 | // Update the TSF with the difference in system time |
| 9535 | void UpdateCCKMTSF(tANI_U32 *timeStamp0, tANI_U32 *timeStamp1, tANI_U32 *incr) |
| 9536 | { |
| 9537 | tANI_U64 timeStamp64 = ((tANI_U64)*timeStamp1 << 32) | (*timeStamp0); |
| 9538 | |
| 9539 | timeStamp64 = (tANI_U64)(timeStamp64 + (tANI_U64)*incr); |
| 9540 | *timeStamp0 = (tANI_U32)(timeStamp64 & 0xffffffff); |
| 9541 | *timeStamp1 = (tANI_U32)((timeStamp64 >> 32) & 0xffffffff); |
| 9542 | } |
| 9543 | #endif |
Deepthi Gowri | ecc9335 | 2016-11-09 16:58:47 +0530 | [diff] [blame] | 9544 | |
| 9545 | void csrValidateScanChannels(tpAniSirGlobal pMac, tCsrScanRequest *pDstReq, |
Nishank Aggarwal | 42f7650 | 2017-02-16 12:00:19 +0530 | [diff] [blame] | 9546 | tCsrScanRequest *pSrcReq, tANI_U32 *new_index, tANI_U8 ch144_support) |
Deepthi Gowri | ecc9335 | 2016-11-09 16:58:47 +0530 | [diff] [blame] | 9547 | { |
| 9548 | |
| 9549 | int index; |
| 9550 | for ( index = 0; index < pSrcReq->ChannelInfo. |
| 9551 | numOfChannels ; index++ ) |
| 9552 | { |
| 9553 | /* Skip CH 144 if firmware support not present */ |
| 9554 | if (pSrcReq->ChannelInfo.ChannelList[index] == 144 && !ch144_support) |
| 9555 | continue; |
| 9556 | |
| 9557 | /* Allow scan on valid channels only. |
| 9558 | */ |
| 9559 | if ( ( csrRoamIsValidChannel(pMac, |
| 9560 | pSrcReq->ChannelInfo.ChannelList[index]) ) ) |
| 9561 | { |
| 9562 | if( ((pSrcReq->skipDfsChnlInP2pSearch || |
| 9563 | (pMac->scan.fEnableDFSChnlScan == |
| 9564 | DFS_CHNL_SCAN_DISABLED)) && |
| 9565 | (NV_CHANNEL_DFS == vos_nv_getChannelEnabledState( |
| 9566 | pSrcReq->ChannelInfo.ChannelList[index])) && |
| 9567 | (pSrcReq->ChannelInfo.numOfChannels > 1)) |
| 9568 | #ifdef FEATURE_WLAN_LFR |
| 9569 | /* |
| 9570 | * If LFR is requesting a contiguous scan |
| 9571 | * (i.e. numOfChannels > 1), then ignore |
| 9572 | * DFS channels. |
| 9573 | * TODO: vos_nv_getChannelEnabledState is returning |
| 9574 | * 120, 124 and 128 as non-DFS channels. Hence, the |
| 9575 | * use of direct check for channels below. |
| 9576 | */ |
| 9577 | || ((eCSR_SCAN_HO_BG_SCAN == pSrcReq->requestType) && |
| 9578 | (pSrcReq->ChannelInfo.numOfChannels > 1) && |
| 9579 | (CSR_IS_CHANNEL_DFS( |
| 9580 | pSrcReq->ChannelInfo.ChannelList[index])) && |
| 9581 | !pMac->roam.configParam.allowDFSChannelRoam) |
| 9582 | #endif |
| 9583 | ) |
| 9584 | { |
| 9585 | #ifdef FEATURE_WLAN_LFR |
| 9586 | smsLog(pMac, LOG1, |
| 9587 | FL(" reqType=%s (%d), numOfChannels=%d," |
| 9588 | " ignoring DFS channel:%d"), |
| 9589 | sme_requestTypetoString(pSrcReq->requestType), |
| 9590 | pSrcReq->requestType, |
| 9591 | pSrcReq->ChannelInfo.numOfChannels, |
| 9592 | pSrcReq->ChannelInfo.ChannelList[index]); |
| 9593 | #endif |
| 9594 | continue; |
| 9595 | } |
| 9596 | |
Nishank Aggarwal | 42f7650 | 2017-02-16 12:00:19 +0530 | [diff] [blame] | 9597 | pDstReq->ChannelInfo.ChannelList[*new_index] = |
Deepthi Gowri | ecc9335 | 2016-11-09 16:58:47 +0530 | [diff] [blame] | 9598 | pSrcReq->ChannelInfo.ChannelList[index]; |
Nishank Aggarwal | 42f7650 | 2017-02-16 12:00:19 +0530 | [diff] [blame] | 9599 | (*new_index)++; |
Deepthi Gowri | ecc9335 | 2016-11-09 16:58:47 +0530 | [diff] [blame] | 9600 | } |
| 9601 | } |
| 9602 | } |