Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Rajeev Kumar Sirasanagandla | 2bb30b8 | 2019-01-07 22:30:16 +0530 | [diff] [blame] | 2 | * Copyright (c) 2011-2019 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 |
Yeshwanth Sriram Guntuka | 7ea10b0 | 2018-09-05 17:35:44 +0530 | [diff] [blame] | 384 | * - STA+SAP. In STA+SAP concurrency, scan requests received on |
| 385 | * STA interface when not in connected state are not split. |
| 386 | * This can result in large time gap between successive beacons |
| 387 | * sent by SAP. |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 388 | * Do not split scans if no concurrent infra connections are |
| 389 | * active and if the scan is a BG scan triggered by LFR (OR) |
| 390 | * any scan if LFR is in the middle of a BG scan. Splitting |
| 391 | * the scan is delaying the time it takes for LFR to find |
| 392 | * candidates and resulting in disconnects. |
Madan Mohan Koyyalamudi | 48081ef | 2012-12-04 16:49:55 -0800 | [diff] [blame] | 393 | */ |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 394 | |
Bala Venkatesh | 5bfddc2 | 2019-02-13 14:42:05 +0530 | [diff] [blame] | 395 | if (csrIsInfraApStarted(pMac) && !csrIsP2pGoSessionConnected(pMac)) |
Yeshwanth Sriram Guntuka | 7ea10b0 | 2018-09-05 17:35:44 +0530 | [diff] [blame] | 396 | { |
| 397 | nNumChanCombinedConc = 1; |
| 398 | } |
| 399 | else if(csrIsStaSessionConnected(pMac) && |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 400 | !csrIsP2pSessionConnected(pMac)) |
| 401 | { |
| 402 | nNumChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc; |
| 403 | } |
| 404 | else if(csrIsP2pSessionConnected(pMac)) |
| 405 | { |
| 406 | nNumChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc; |
| 407 | } |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 408 | if ( (csrIsStaSessionConnected(pMac) && |
| 409 | #ifdef FEATURE_WLAN_LFR |
| 410 | (csrIsConcurrentInfraConnected(pMac) || |
| 411 | ((pScanCmd->u.scanCmd.reason != eCsrScanBgScan) && |
| 412 | (pMac->roam.neighborRoamInfo.neighborRoamState != |
| 413 | eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN))) && |
| 414 | #endif |
| 415 | (pScanCmd->u.scanCmd.u.scanRequest.p2pSearch != 1)) || |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 416 | (csrIsP2pSessionConnected(pMac)) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 417 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 418 | tCsrScanRequest scanReq; |
| 419 | tANI_U8 numChn = pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels; |
| 420 | tCsrChannelInfo *pChnInfo = &scanReq.ChannelInfo; |
| 421 | tANI_U8 channelToScan[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 422 | tANI_BOOLEAN bMemAlloc = eANI_BOOLEAN_FALSE; |
| 423 | |
| 424 | if (numChn == 0) |
| 425 | { |
| 426 | |
| 427 | numChn = pMac->scan.baseChannels.numChannels; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 428 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 429 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = vos_mem_malloc(numChn); |
| 430 | if ( NULL == pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 431 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 432 | smsLog( pMac, LOGE, FL(" Failed to get memory for channel list ") ); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 433 | return eHAL_STATUS_FAILURE; |
| 434 | } |
| 435 | bMemAlloc = eANI_BOOLEAN_TRUE; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 436 | vos_mem_copy(pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList, |
| 437 | pMac->scan.baseChannels.channelList, numChn); |
| 438 | status = eHAL_STATUS_SUCCESS; |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 439 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 440 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 441 | vos_mem_free(pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 442 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = NULL; |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 443 | smsLog( pMac, LOGE, FL(" Failed to copy memory to channel list ") ); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 444 | return eHAL_STATUS_FAILURE; |
| 445 | } |
| 446 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = numChn; |
| 447 | } |
Sushant Kaushik | 826de80 | 2014-05-08 18:04:11 +0530 | [diff] [blame] | 448 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, |
| 449 | "%s: Total Number of channels to scan : %d " |
| 450 | "Splitted in group of %d ", __func__, numChn, |
| 451 | nNumChanCombinedConc); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 452 | //Whenever we get a scan request with multiple channels we break it up into 2 requests |
| 453 | //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] | 454 | if ( numChn > nNumChanCombinedConc) |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 455 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 456 | vos_mem_set(&scanReq, sizeof(tCsrScanRequest), 0); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 457 | |
| 458 | pQueueScanCmd = csrGetCommandBuffer(pMac); //optimize this to use 2 command buffer only |
| 459 | if (!pQueueScanCmd) |
| 460 | { |
| 461 | if (bMemAlloc) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 462 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 463 | vos_mem_free(pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 464 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = NULL; |
| 465 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 466 | } |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 467 | smsLog( pMac, LOGE, FL(" Failed to get Queue command buffer") ); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 468 | return eHAL_STATUS_FAILURE; |
| 469 | } |
| 470 | pQueueScanCmd->command = pScanCmd->command; |
| 471 | pQueueScanCmd->sessionId = pScanCmd->sessionId; |
| 472 | pQueueScanCmd->u.scanCmd.callback = pScanCmd->u.scanCmd.callback; |
| 473 | pQueueScanCmd->u.scanCmd.pContext = pScanCmd->u.scanCmd.pContext; |
| 474 | pQueueScanCmd->u.scanCmd.reason = pScanCmd->u.scanCmd.reason; |
| 475 | pQueueScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 476 | |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 477 | /* First copy all the parameters to local variable of scan request */ |
| 478 | csrScanCopyRequest(pMac, &scanReq, &pScanCmd->u.scanCmd.u.scanRequest); |
Madan Mohan Koyyalamudi | af2a8b9 | 2012-10-09 14:58:07 -0700 | [diff] [blame] | 479 | |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 480 | /* Now modify the elements of local var scan request required to be modified for split scan */ |
| 481 | if(scanReq.ChannelInfo.ChannelList != NULL) |
| 482 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 483 | vos_mem_free(scanReq.ChannelInfo.ChannelList); |
Madan Mohan Koyyalamudi | 0c626f3 | 2012-11-30 15:10:25 -0800 | [diff] [blame] | 484 | scanReq.ChannelInfo.ChannelList = NULL; |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 485 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 486 | |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 487 | pChnInfo->numOfChannels = pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels - nNumChanCombinedConc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 488 | |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 489 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN, |
Jeff Johnson | 8947750 | 2017-09-19 08:35:23 -0700 | [diff] [blame] | 490 | 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] | 491 | &channelToScan[0], pScanCmd, |
| 492 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList, numChn); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 493 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 494 | vos_mem_copy(&channelToScan[0], |
| 495 | &pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[ |
| 496 | nNumChanCombinedConc], |
| 497 | pChnInfo->numOfChannels * sizeof(tANI_U8)); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 498 | |
| 499 | pChnInfo->ChannelList = &channelToScan[0]; |
| 500 | |
| 501 | scanReq.BSSType = eCSR_BSS_TYPE_ANY; |
c_hpothu | dbefd3e | 2014-04-28 15:59:47 +0530 | [diff] [blame] | 502 | |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 503 | //Use concurrency values for min/maxChnTime. |
| 504 | //We know csrIsAnySessionConnected(pMac) returns TRUE here |
| 505 | csrSetDefaultScanTiming(pMac, scanReq.scanType, &scanReq); |
| 506 | |
| 507 | status = csrScanCopyRequest(pMac, &pQueueScanCmd->u.scanCmd.u.scanRequest, &scanReq); |
| 508 | |
| 509 | if(!HAL_STATUS_SUCCESS(status)) |
| 510 | { |
| 511 | if (bMemAlloc) |
| 512 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 513 | vos_mem_free(pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 514 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = NULL; |
| 515 | |
| 516 | } |
| 517 | if( scanReq.pIEField != NULL) |
| 518 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 519 | vos_mem_free(scanReq.pIEField); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 520 | scanReq.pIEField = NULL; |
| 521 | } |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 522 | smsLog( pMac, LOGE, FL(" Failed to get copy csrScanRequest = %d"), status ); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 523 | return eHAL_STATUS_FAILURE; |
| 524 | } |
| 525 | /* Clean the local scan variable */ |
| 526 | scanReq.ChannelInfo.ChannelList = NULL; |
| 527 | scanReq.ChannelInfo.numOfChannels = 0; |
| 528 | csrScanFreeRequest(pMac, &scanReq); |
| 529 | |
| 530 | /* setup the command to scan 2 channels */ |
| 531 | pSendScanCmd = pScanCmd; |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 532 | pSendScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = nNumChanCombinedConc; |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 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 | pSendScanCmd->u.scanCmd.callback = NULL; |
| 539 | } else { |
| 540 | pSendScanCmd = pScanCmd; |
| 541 | pSendScanCmd->u.scanCmd.u.scanRequest.BSSType = eCSR_BSS_TYPE_ANY; |
c_hpothu | dbefd3e | 2014-04-28 15:59:47 +0530 | [diff] [blame] | 542 | |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 543 | //Use concurrency values for min/maxChnTime. |
| 544 | //We know csrIsAnySessionConnected(pMac) returns TRUE here |
| 545 | csrSetDefaultScanTiming(pMac, pSendScanCmd->u.scanCmd.u.scanRequest.scanType, &pSendScanCmd->u.scanCmd.u.scanRequest); |
| 546 | } |
| 547 | |
| 548 | fNoCmdPending = csrLLIsListEmpty( &pMac->scan.scanCmdPendingList, LL_ACCESS_LOCK ); |
| 549 | |
| 550 | //Logic Below is as follows |
| 551 | // If the scanCmdPendingList is empty then we directly send that command |
| 552 | // to smeCommandQueue else we buffer it in our scanCmdPendingList Queue |
| 553 | if( fNoCmdPending ) |
| 554 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 555 | if (pQueueScanCmd != NULL) |
| 556 | { |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 557 | csrLLInsertTail( &pMac->scan.scanCmdPendingList, &pQueueScanCmd->Link, LL_ACCESS_LOCK ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 558 | } |
| 559 | |
| 560 | if (pSendScanCmd != NULL) |
| 561 | { |
| 562 | return csrQueueSmeCommand(pMac, pSendScanCmd, eANI_BOOLEAN_FALSE); |
| 563 | } |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 564 | } |
| 565 | else |
| 566 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 567 | if (pSendScanCmd != NULL) |
| 568 | { |
| 569 | csrLLInsertTail( &pMac->scan.scanCmdPendingList, &pSendScanCmd->Link, LL_ACCESS_LOCK ); |
| 570 | } |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 571 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 572 | if (pQueueScanCmd != NULL) |
| 573 | { |
| 574 | csrLLInsertTail( &pMac->scan.scanCmdPendingList, &pQueueScanCmd->Link, LL_ACCESS_LOCK ); |
| 575 | } |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 576 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 577 | } |
| 578 | else |
| 579 | { //No concurrency case |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 580 | smsLog( pMac, LOG2, FL("Queuing scan command (reason=%d, roamState=%d" |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 581 | " numOfChannels=%d)"), |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 582 | pScanCmd->u.scanCmd.reason, |
| 583 | pMac->roam.neighborRoamInfo.neighborRoamState, |
| 584 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 585 | return csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_FALSE); |
| 586 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 587 | |
| 588 | return ( status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 589 | } |
| 590 | #endif |
| 591 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 592 | /* --------------------------------------------------------------------------- |
| 593 | \fn csrScan2GOnyRequest |
| 594 | \brief This function will update the scan request with only |
Jeff Johnson | b88db98 | 2012-12-10 13:34:59 -0800 | [diff] [blame] | 595 | 2.4GHz valid channel list. |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 596 | \param pMac |
| 597 | \param pScanCmd |
| 598 | \param pScanRequest |
| 599 | \return None |
| 600 | -------------------------------------------------------------------------------*/ |
| 601 | static void csrScan2GOnyRequest(tpAniSirGlobal pMac,tSmeCmd *pScanCmd, |
| 602 | tCsrScanRequest *pScanRequest) |
| 603 | { |
| 604 | tANI_U8 index, channelId, channelListSize = 0; |
| 605 | tANI_U8 channelList2G[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}; |
| 606 | static tANI_U8 validchannelList[CSR_MAX_2_4_GHZ_SUPPORTED_CHANNELS] = {0}; |
| 607 | |
| 608 | VOS_ASSERT(pScanCmd && pScanRequest); |
Madan Mohan Koyyalamudi | 33ef6a2 | 2012-10-30 17:44:43 -0700 | [diff] [blame] | 609 | /* To silence the KW tool null check is added */ |
| 610 | if((pScanCmd == NULL) || (pScanRequest == NULL)) |
| 611 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 612 | smsLog( pMac, LOGE, FL(" pScanCmd or pScanRequest is NULL ")); |
Madan Mohan Koyyalamudi | 33ef6a2 | 2012-10-30 17:44:43 -0700 | [diff] [blame] | 613 | return; |
| 614 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 615 | |
| 616 | if (pScanCmd->u.scanCmd.scanID || |
| 617 | (eCSR_SCAN_REQUEST_FULL_SCAN != pScanRequest->requestType)) |
| 618 | return; |
| 619 | |
| 620 | //Contsruct valid Supported 2.4 GHz Channel List |
| 621 | for( index = 0; index < ARRAY_SIZE(channelList2G); index++ ) |
| 622 | { |
| 623 | channelId = channelList2G[index]; |
| 624 | if ( csrIsSupportedChannel( pMac, channelId ) ) |
| 625 | { |
| 626 | validchannelList[channelListSize++] = channelId; |
| 627 | } |
| 628 | } |
| 629 | |
| 630 | pScanRequest->ChannelInfo.numOfChannels = channelListSize; |
| 631 | pScanRequest->ChannelInfo.ChannelList = validchannelList; |
| 632 | } |
| 633 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 634 | eHalStatus csrScanRequest(tpAniSirGlobal pMac, tANI_U16 sessionId, |
| 635 | tCsrScanRequest *pScanRequest, tANI_U32 *pScanRequestID, |
| 636 | csrScanCompleteCallback callback, void *pContext) |
| 637 | { |
| 638 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 639 | tSmeCmd *pScanCmd = NULL; |
Madan Mohan Koyyalamudi | cb90bb2 | 2012-10-30 18:24:43 -0700 | [diff] [blame] | 640 | eCsrConnectState ConnectState; |
Deepthi Gowri | e11da8c | 2016-02-04 18:18:39 +0530 | [diff] [blame] | 641 | |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 642 | if(pScanRequest == NULL) |
| 643 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 644 | smsLog( pMac, LOGE, FL(" pScanRequest is NULL")); |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 645 | VOS_ASSERT(0); |
Kaushik, Sushant | 488df38 | 2014-03-05 11:43:47 +0530 | [diff] [blame] | 646 | return eHAL_STATUS_FAILURE ; |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 647 | } |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 648 | |
Kiet Lam | d1f3dc8 | 2013-11-05 20:45:04 +0530 | [diff] [blame] | 649 | /* During group formation, the P2P client scans for GO with the specific SSID. |
| 650 | * There will be chances of GO switching to other channels because of scan or |
| 651 | * to STA channel in case of STA+GO MCC scenario. So to increase the possibility |
| 652 | * of client to find the GO, the dwell time of scan is increased to 100ms. |
| 653 | */ |
| 654 | if(pScanRequest->p2pSearch) |
| 655 | { |
Rashmi Ramanna | 6f7931c | 2013-12-20 09:04:12 +0530 | [diff] [blame] | 656 | if(pScanRequest->SSIDs.numOfSSIDs) |
Kiet Lam | d1f3dc8 | 2013-11-05 20:45:04 +0530 | [diff] [blame] | 657 | { |
Rashmi Ramanna | 6f7931c | 2013-12-20 09:04:12 +0530 | [diff] [blame] | 658 | //If the scan request is for specific SSId the length of SSID will be |
| 659 | //greater than 7 as SSID for p2p search contains "DIRECT-") |
| 660 | if(pScanRequest->SSIDs.SSIDList->SSID.length > DIRECT_SSID_LEN) |
| 661 | { |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 662 | smsLog( pMac, LOG1, FL("P2P: Increasing the min and max Dwell" |
| 663 | " time to %d for specific SSID scan %.*s"), |
| 664 | MAX_CHN_TIME_TO_FIND_GO, |
| 665 | pScanRequest->SSIDs.SSIDList->SSID.length, |
| 666 | pScanRequest->SSIDs.SSIDList->SSID.ssId); |
Rashmi Ramanna | 6f7931c | 2013-12-20 09:04:12 +0530 | [diff] [blame] | 667 | pScanRequest->maxChnTime = MAX_CHN_TIME_TO_FIND_GO; |
| 668 | pScanRequest->minChnTime = MIN_CHN_TIME_TO_FIND_GO; |
| 669 | } |
Kiet Lam | d1f3dc8 | 2013-11-05 20:45:04 +0530 | [diff] [blame] | 670 | } |
| 671 | } |
| 672 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 673 | do |
| 674 | { |
| 675 | if(pMac->scan.fScanEnable) |
| 676 | { |
| 677 | pScanCmd = csrGetCommandBuffer(pMac); |
| 678 | if(pScanCmd) |
| 679 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 680 | vos_mem_set(&pScanCmd->u.scanCmd, sizeof(tScanCmd), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 681 | pScanCmd->command = eSmeCommandScan; |
| 682 | pScanCmd->sessionId = sessionId; |
| 683 | pScanCmd->u.scanCmd.callback = callback; |
| 684 | pScanCmd->u.scanCmd.pContext = pContext; |
| 685 | if(eCSR_SCAN_REQUEST_11D_SCAN == pScanRequest->requestType) |
| 686 | { |
| 687 | pScanCmd->u.scanCmd.reason = eCsrScan11d1; |
| 688 | } |
| 689 | else if((eCSR_SCAN_REQUEST_FULL_SCAN == pScanRequest->requestType) || |
| 690 | (eCSR_SCAN_P2P_DISCOVERY == pScanRequest->requestType) |
| 691 | #ifdef SOFTAP_CHANNEL_RANGE |
| 692 | ||(eCSR_SCAN_SOFTAP_CHANNEL_RANGE == pScanRequest->requestType) |
| 693 | #endif |
| 694 | ) |
| 695 | { |
| 696 | pScanCmd->u.scanCmd.reason = eCsrScanUserRequest; |
| 697 | } |
| 698 | else if(eCSR_SCAN_HO_BG_SCAN == pScanRequest->requestType) |
| 699 | { |
| 700 | pScanCmd->u.scanCmd.reason = eCsrScanBgScan; |
| 701 | } |
| 702 | else if(eCSR_SCAN_HO_PROBE_SCAN == pScanRequest->requestType) |
| 703 | { |
| 704 | pScanCmd->u.scanCmd.reason = eCsrScanProbeBss; |
| 705 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 706 | else if(eCSR_SCAN_P2P_FIND_PEER == pScanRequest->requestType) |
| 707 | { |
| 708 | pScanCmd->u.scanCmd.reason = eCsrScanP2PFindPeer; |
| 709 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 710 | else |
| 711 | { |
| 712 | pScanCmd->u.scanCmd.reason = eCsrScanIdleScan; |
| 713 | } |
| 714 | if(pScanRequest->minChnTime == 0 && pScanRequest->maxChnTime == 0) |
| 715 | { |
| 716 | //The caller doesn't set the time correctly. Set it here |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 717 | csrSetDefaultScanTiming(pMac, pScanRequest->scanType, |
| 718 | pScanRequest); |
| 719 | smsLog(pMac, LOG1, FL("Setting default min %d and max %d" |
| 720 | " ChnTime"), pScanRequest->minChnTime, |
| 721 | pScanRequest->maxChnTime); |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 722 | } |
| 723 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 724 | if(pScanRequest->restTime == 0) |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 725 | { |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 726 | //Need to set restTime only if at least one session is connected |
| 727 | if(csrIsAnySessionConnected(pMac)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 728 | { |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 729 | pScanRequest->restTime = pMac->roam.configParam.nRestTimeConc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 730 | } |
| 731 | } |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 732 | #endif |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 733 | /*For Standalone wlan : channel time will remain the same. |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 734 | 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] | 735 | This has been done to provide a larger scan window for faster connection during btc.Else Scan is seen |
| 736 | to take a long time. |
| 737 | For BTC with A2DP up: Channel time will not be doubled, if station is already associated. |
| 738 | */ |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 739 | status = csrRoamGetConnectState(pMac,sessionId,&ConnectState); |
Srinivas Girigowda | c84c57c | 2013-02-19 17:41:56 -0800 | [diff] [blame] | 740 | if (HAL_STATUS_SUCCESS(status) && |
| 741 | pMac->btc.fA2DPUp && |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 742 | (eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED != ConnectState) && |
| 743 | (eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED != ConnectState)) |
| 744 | { |
| 745 | pScanRequest->maxChnTime = pScanRequest->maxChnTime << 1; |
| 746 | pScanRequest->minChnTime = pScanRequest->minChnTime << 1; |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 747 | smsLog( pMac, LOG1, FL("BTC A2DP up, doubling max and min" |
| 748 | " ChnTime (Max=%d Min=%d)"), |
| 749 | pScanRequest->maxChnTime, |
| 750 | pScanRequest->minChnTime); |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 751 | } |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 752 | |
Abhishek Singh | add1358 | 2016-09-29 17:00:03 +0530 | [diff] [blame] | 753 | pScanRequest->max_chntime_btc_esco = |
| 754 | pMac->roam.configParam.max_chntime_btc_esco; |
| 755 | pScanRequest->min_chntime_btc_esco = |
| 756 | pMac->roam.configParam.min_chntime_btc_esco; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 757 | //Need to make the following atomic |
| 758 | pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around |
| 759 | |
| 760 | if(pScanRequestID) |
| 761 | { |
| 762 | *pScanRequestID = pScanCmd->u.scanCmd.scanID; |
| 763 | } |
| 764 | |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 765 | // 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] | 766 | // If it is not, CSR will save the scan request in the pending cmd queue |
| 767 | // & issue an 11d scan request to PE. |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 768 | if (((0 == pScanCmd->u.scanCmd.scanID) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 769 | && (eCSR_SCAN_REQUEST_11D_SCAN != pScanRequest->requestType)) |
| 770 | #ifdef SOFTAP_CHANNEL_RANGE |
| 771 | && (eCSR_SCAN_SOFTAP_CHANNEL_RANGE != pScanRequest->requestType) |
| 772 | #endif |
| 773 | && (eANI_BOOLEAN_FALSE == pMac->scan.fEnableBypass11d) |
| 774 | ) |
| 775 | { |
| 776 | tSmeCmd *p11dScanCmd; |
| 777 | tCsrScanRequest scanReq; |
| 778 | tCsrChannelInfo *pChnInfo = &scanReq.ChannelInfo; |
| 779 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 780 | vos_mem_set(&scanReq, sizeof(tCsrScanRequest), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 781 | |
| 782 | p11dScanCmd = csrGetCommandBuffer(pMac); |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 783 | if (p11dScanCmd) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 784 | { |
| 785 | tANI_U32 numChn = pMac->scan.baseChannels.numChannels; |
| 786 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 787 | vos_mem_set(&p11dScanCmd->u.scanCmd, sizeof(tScanCmd), 0); |
| 788 | pChnInfo->ChannelList = vos_mem_malloc(numChn); |
| 789 | if ( NULL == pChnInfo->ChannelList ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 790 | { |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 791 | smsLog(pMac, LOGE, FL("Failed to allocate memory")); |
| 792 | status = eHAL_STATUS_FAILURE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 793 | break; |
| 794 | } |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 795 | vos_mem_copy(pChnInfo->ChannelList, |
| 796 | pMac->scan.baseChannels.channelList, |
| 797 | numChn); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 798 | pChnInfo->numOfChannels = (tANI_U8)numChn; |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 799 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 800 | p11dScanCmd->command = eSmeCommandScan; |
Mihir Shete | fc7ff5b | 2014-01-27 11:30:05 +0530 | [diff] [blame] | 801 | p11dScanCmd->u.scanCmd.callback = pMac->scan.callback11dScanDone; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 802 | p11dScanCmd->u.scanCmd.pContext = NULL; |
c_hpothu | 0d5a735 | 2014-03-22 12:30:25 +0530 | [diff] [blame] | 803 | p11dScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 804 | scanReq.BSSType = eCSR_BSS_TYPE_ANY; |
| 805 | |
| 806 | if ( csrIs11dSupported(pMac) ) |
| 807 | { |
c_hpothu | dbefd3e | 2014-04-28 15:59:47 +0530 | [diff] [blame] | 808 | scanReq.scanType = eSIR_PASSIVE_SCAN; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 809 | scanReq.requestType = eCSR_SCAN_REQUEST_11D_SCAN; |
| 810 | p11dScanCmd->u.scanCmd.reason = eCsrScan11d1; |
| 811 | scanReq.maxChnTime = pMac->roam.configParam.nPassiveMaxChnTime; |
| 812 | scanReq.minChnTime = pMac->roam.configParam.nPassiveMinChnTime; |
| 813 | } |
| 814 | else |
| 815 | { |
c_hpothu | dbefd3e | 2014-04-28 15:59:47 +0530 | [diff] [blame] | 816 | scanReq.scanType = pScanRequest->scanType; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 817 | scanReq.requestType = eCSR_SCAN_IDLE_MODE_SCAN; |
| 818 | p11dScanCmd->u.scanCmd.reason = eCsrScanIdleScan; |
| 819 | scanReq.maxChnTime = pMac->roam.configParam.nActiveMaxChnTime; |
| 820 | scanReq.minChnTime = pMac->roam.configParam.nActiveMinChnTime; |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 821 | |
Abhishek Singh | add1358 | 2016-09-29 17:00:03 +0530 | [diff] [blame] | 822 | scanReq.max_chntime_btc_esco = |
| 823 | pMac->roam.configParam.max_chntime_btc_esco; |
| 824 | scanReq.min_chntime_btc_esco = |
| 825 | pMac->roam.configParam.min_chntime_btc_esco; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 826 | } |
c_hpothu | 059edb0 | 2014-03-12 21:44:28 +0530 | [diff] [blame] | 827 | if (pMac->roam.configParam.nInitialDwellTime) |
| 828 | { |
| 829 | scanReq.maxChnTime = |
| 830 | pMac->roam.configParam.nInitialDwellTime; |
| 831 | smsLog(pMac, LOG1, FL("11d scan, updating" |
| 832 | "dwell time for first scan %u"), |
| 833 | scanReq.maxChnTime); |
| 834 | } |
Deepthi Gowri | e11da8c | 2016-02-04 18:18:39 +0530 | [diff] [blame] | 835 | if ((pScanCmd->u.scanCmd.reason == eCsrScanUserRequest) |
| 836 | && !(pScanRequest->p2pSearch) |
Gupta, Kapil | b79cda3 | 2015-12-30 20:36:33 +0530 | [diff] [blame] | 837 | &&(pScanRequest->ChannelInfo.numOfChannels |
| 838 | < pMac->roam.configParam. |
| 839 | max_chan_for_dwell_time_cfg)) |
| 840 | { |
| 841 | pScanRequest->maxChnTime = |
| 842 | pScanRequest->maxChnTime << 1; |
| 843 | pScanRequest->minChnTime = |
| 844 | pScanRequest->minChnTime << 1; |
| 845 | smsLog(pMac, LOG1, |
| 846 | FL("Double ChnTime (Max=%d Min=%d) numOfChannels=%d max_chan_for_dwell_time_cfg=%d"), |
| 847 | pScanRequest->maxChnTime, |
| 848 | pScanRequest->minChnTime, |
| 849 | pScanRequest->ChannelInfo.numOfChannels, |
| 850 | pMac->roam.configParam. |
| 851 | max_chan_for_dwell_time_cfg); |
| 852 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 853 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 854 | status = csrScanCopyRequest(pMac, &p11dScanCmd->u.scanCmd.u.scanRequest, &scanReq); |
| 855 | //Free the channel list |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 856 | vos_mem_free(pChnInfo->ChannelList); |
James Zmuda | 9ea1edd | 2013-04-18 18:20:54 -0700 | [diff] [blame] | 857 | pChnInfo->ChannelList = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 858 | |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 859 | if (HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 860 | { |
krunal soni | 5f112f0 | 2013-11-25 15:00:11 -0800 | [diff] [blame] | 861 | pMac->scan.scanProfile.numOfChannels = |
| 862 | p11dScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 863 | //Start process the command |
| 864 | #ifdef WLAN_AP_STA_CONCURRENCY |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 865 | if (!pMac->fScanOffload) |
| 866 | status = csrQueueScanRequest(pMac, p11dScanCmd); |
| 867 | else |
| 868 | status = csrQueueSmeCommand(pMac, p11dScanCmd, |
| 869 | eANI_BOOLEAN_FALSE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 870 | #else |
| 871 | status = csrQueueSmeCommand(pMac, p11dScanCmd, eANI_BOOLEAN_FALSE); |
| 872 | #endif |
| 873 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 874 | { |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 875 | smsLog(pMac, LOGE, FL("Failed to send message" |
| 876 | " status = %d"), status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 877 | break; |
| 878 | } |
| 879 | } |
| 880 | else |
| 881 | { |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 882 | smsLog(pMac, LOGE, FL("csrScanCopyRequest failed")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 883 | break; |
| 884 | } |
| 885 | } |
| 886 | else |
| 887 | { |
| 888 | //error |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 889 | smsLog( pMac, LOGE, FL("p11dScanCmd failed") ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 890 | break; |
| 891 | } |
| 892 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 893 | |
| 894 | //Scan only 2G Channels if set in ini file |
| 895 | //This is mainly to reduce the First Scan duration |
| 896 | //Once we turn on Wifi |
| 897 | if(pMac->scan.fFirstScanOnly2GChnl) |
| 898 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 899 | smsLog( pMac, LOG1, FL("Scanning only 2G Channels during first scan")); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 900 | csrScan2GOnyRequest(pMac, pScanCmd, pScanRequest); |
| 901 | } |
| 902 | |
c_hpothu | 059edb0 | 2014-03-12 21:44:28 +0530 | [diff] [blame] | 903 | if (pMac->roam.configParam.nInitialDwellTime) |
| 904 | { |
| 905 | pScanRequest->maxChnTime = |
| 906 | pMac->roam.configParam.nInitialDwellTime; |
| 907 | pMac->roam.configParam.nInitialDwellTime = 0; |
| 908 | smsLog(pMac, LOG1, |
| 909 | FL("updating dwell time for first scan %u"), |
| 910 | pScanRequest->maxChnTime); |
| 911 | } |
| 912 | |
Deepthi Gowri | e11da8c | 2016-02-04 18:18:39 +0530 | [diff] [blame] | 913 | if ((pScanCmd->u.scanCmd.reason == eCsrScanUserRequest) |
| 914 | && !(pScanRequest->p2pSearch) |
Gupta, Kapil | b79cda3 | 2015-12-30 20:36:33 +0530 | [diff] [blame] | 915 | && (pScanRequest->ChannelInfo.numOfChannels |
| 916 | < pMac->roam.configParam.max_chan_for_dwell_time_cfg)) |
| 917 | { |
| 918 | pScanRequest->maxChnTime = pScanRequest->maxChnTime << 1; |
| 919 | pScanRequest->minChnTime = pScanRequest->minChnTime << 1; |
| 920 | smsLog(pMac, LOG1, |
| 921 | FL("Double ChnTime (Max=%d Min=%d) numOfChannels=%d max_chan_for_dwell_time_cfg=%d"), |
| 922 | pScanRequest->maxChnTime, |
| 923 | pScanRequest->minChnTime, |
| 924 | pScanRequest->ChannelInfo.numOfChannels, |
| 925 | pMac->roam.configParam.max_chan_for_dwell_time_cfg); |
| 926 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 927 | status = csrScanCopyRequest(pMac, &pScanCmd->u.scanCmd.u.scanRequest, pScanRequest); |
| 928 | if(HAL_STATUS_SUCCESS(status)) |
| 929 | { |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 930 | tCsrScanRequest *pTempScanReq = |
| 931 | &pScanCmd->u.scanCmd.u.scanRequest; |
krunal soni | 5f112f0 | 2013-11-25 15:00:11 -0800 | [diff] [blame] | 932 | pMac->scan.scanProfile.numOfChannels = |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 933 | pTempScanReq->ChannelInfo.numOfChannels; |
krunal soni | 5f112f0 | 2013-11-25 15:00:11 -0800 | [diff] [blame] | 934 | |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 935 | smsLog( pMac, LOG1, FL(" SId=%d scanId=%d" |
| 936 | " Scan reason=%u numSSIDs=%d" |
| 937 | " numChan=%d P2P search=%d minCT=%d maxCT=%d" |
| 938 | " minCBtc=%d maxCBtx=%d"), |
| 939 | sessionId, pScanCmd->u.scanCmd.scanID, |
| 940 | pScanCmd->u.scanCmd.reason, |
| 941 | pTempScanReq->SSIDs.numOfSSIDs, |
| 942 | pTempScanReq->ChannelInfo.numOfChannels, |
| 943 | pTempScanReq->p2pSearch, |
| 944 | pTempScanReq->minChnTime, |
| 945 | pTempScanReq->maxChnTime, |
Abhishek Singh | add1358 | 2016-09-29 17:00:03 +0530 | [diff] [blame] | 946 | pTempScanReq->min_chntime_btc_esco, |
| 947 | pTempScanReq->max_chntime_btc_esco); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 948 | //Start process the command |
| 949 | #ifdef WLAN_AP_STA_CONCURRENCY |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 950 | if (!pMac->fScanOffload) |
| 951 | status = csrQueueScanRequest(pMac,pScanCmd); |
| 952 | else |
| 953 | status = csrQueueSmeCommand(pMac, pScanCmd, |
| 954 | eANI_BOOLEAN_FALSE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 955 | #else |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 956 | status = csrQueueSmeCommand(pMac, pScanCmd, |
| 957 | eANI_BOOLEAN_FALSE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 958 | #endif |
| 959 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 960 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 961 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 962 | break; |
| 963 | } |
| 964 | } |
| 965 | else |
| 966 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 967 | smsLog( pMac, LOGE, FL(" fail to copy request status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 968 | break; |
| 969 | } |
| 970 | } |
| 971 | else |
| 972 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 973 | smsLog( pMac, LOGE, FL(" pScanCmd is NULL")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 974 | break; |
| 975 | } |
| 976 | } |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 977 | else |
| 978 | { |
| 979 | smsLog( pMac, LOGE, FL("SId: %d Scanning not enabled" |
| 980 | " Scan type=%u, numOfSSIDs=%d P2P search=%d"), |
| 981 | sessionId, pScanRequest->requestType, |
| 982 | pScanRequest->SSIDs.numOfSSIDs, |
| 983 | pScanRequest->p2pSearch ); |
| 984 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 985 | } while(0); |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 986 | |
| 987 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 988 | if(!HAL_STATUS_SUCCESS(status) && pScanCmd) |
| 989 | { |
| 990 | if( eCsrScanIdleScan == pScanCmd->u.scanCmd.reason ) |
| 991 | { |
| 992 | //Set the flag back for restarting idle scan |
| 993 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 994 | } |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 995 | smsLog( pMac, LOGE, FL(" SId: %d Failed with status=%d" |
| 996 | " Scan reason=%u numOfSSIDs=%d" |
| 997 | " P2P search=%d scanId=%d"), |
| 998 | sessionId, status, pScanCmd->u.scanCmd.reason, |
| 999 | pScanRequest->SSIDs.numOfSSIDs, pScanRequest->p2pSearch, |
| 1000 | pScanCmd->u.scanCmd.scanID ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1001 | csrReleaseCommandScan(pMac, pScanCmd); |
| 1002 | } |
| 1003 | |
| 1004 | return (status); |
| 1005 | } |
| 1006 | |
| 1007 | |
| 1008 | eHalStatus csrScanRequestResult(tpAniSirGlobal pMac) |
| 1009 | { |
| 1010 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1011 | tSmeCmd *pScanCmd; |
| 1012 | |
| 1013 | if(pMac->scan.fScanEnable) |
| 1014 | { |
| 1015 | pScanCmd = csrGetCommandBuffer(pMac); |
| 1016 | if(pScanCmd) |
| 1017 | { |
| 1018 | pScanCmd->command = eSmeCommandScan; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1019 | vos_mem_set(&pScanCmd->u.scanCmd, sizeof(tScanCmd), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1020 | pScanCmd->u.scanCmd.callback = NULL; |
| 1021 | pScanCmd->u.scanCmd.pContext = NULL; |
| 1022 | pScanCmd->u.scanCmd.reason = eCsrScanGetResult; |
| 1023 | //Need to make the following atomic |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 1024 | pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID; //let it wrap around |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1025 | status = csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_FALSE); |
| 1026 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 1027 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1028 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1029 | csrReleaseCommandScan(pMac, pScanCmd); |
| 1030 | } |
| 1031 | } |
| 1032 | else |
| 1033 | { |
| 1034 | //log error |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1035 | smsLog(pMac, LOGE, FL("can not obtain a common buffer")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1036 | status = eHAL_STATUS_RESOURCES; |
| 1037 | } |
| 1038 | } |
| 1039 | |
| 1040 | return (status); |
| 1041 | } |
| 1042 | |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 1043 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 1044 | eHalStatus csrScanRequestLfrResult(tpAniSirGlobal pMac, tANI_U32 sessionId, |
| 1045 | csrScanCompleteCallback callback, void *pContext) |
| 1046 | { |
| 1047 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1048 | tSmeCmd *pScanCmd; |
| 1049 | |
| 1050 | if (pMac->scan.fScanEnable) |
| 1051 | { |
| 1052 | pScanCmd = csrGetCommandBuffer(pMac); |
| 1053 | if (pScanCmd) |
| 1054 | { |
| 1055 | pScanCmd->command = eSmeCommandScan; |
| 1056 | pScanCmd->sessionId = sessionId; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1057 | vos_mem_set(&pScanCmd->u.scanCmd, sizeof(tScanCmd), 0); |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 1058 | pScanCmd->u.scanCmd.callback = callback; |
| 1059 | pScanCmd->u.scanCmd.pContext = pContext; |
| 1060 | pScanCmd->u.scanCmd.reason = eCsrScanGetLfrResult; |
| 1061 | //Need to make the following atomic |
| 1062 | pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID; //let it wrap around |
| 1063 | status = csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_TRUE); |
| 1064 | if ( !HAL_STATUS_SUCCESS( status ) ) |
| 1065 | { |
| 1066 | smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status ); |
| 1067 | csrReleaseCommandScan(pMac, pScanCmd); |
| 1068 | } |
| 1069 | } |
| 1070 | else |
| 1071 | { |
| 1072 | //log error |
| 1073 | smsLog(pMac, LOGE, FL("can not obtain a common buffer\n")); |
| 1074 | status = eHAL_STATUS_RESOURCES; |
| 1075 | } |
| 1076 | } |
| 1077 | |
| 1078 | return (status); |
| 1079 | } |
| 1080 | #endif //WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1081 | |
| 1082 | eHalStatus csrScanAllChannels(tpAniSirGlobal pMac, eCsrRequestType reqType) |
| 1083 | { |
| 1084 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1085 | tANI_U32 scanId; |
| 1086 | tCsrScanRequest scanReq; |
| 1087 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1088 | vos_mem_set(&scanReq, sizeof(tCsrScanRequest), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1089 | scanReq.BSSType = eCSR_BSS_TYPE_ANY; |
| 1090 | scanReq.scanType = eSIR_ACTIVE_SCAN; |
| 1091 | scanReq.requestType = reqType; |
| 1092 | scanReq.maxChnTime = pMac->roam.configParam.nActiveMaxChnTime; |
| 1093 | scanReq.minChnTime = pMac->roam.configParam.nActiveMinChnTime; |
Abhishek Singh | add1358 | 2016-09-29 17:00:03 +0530 | [diff] [blame] | 1094 | scanReq.max_chntime_btc_esco = |
| 1095 | pMac->roam.configParam.max_chntime_btc_esco; |
| 1096 | scanReq.min_chntime_btc_esco = |
| 1097 | pMac->roam.configParam.min_chntime_btc_esco; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1098 | //Scan with invalid sessionId. |
| 1099 | //This results in SME using the first available session to scan. |
| 1100 | status = csrScanRequest(pMac, CSR_SESSION_ID_INVALID, &scanReq, |
| 1101 | &scanId, NULL, NULL); |
| 1102 | |
| 1103 | return (status); |
| 1104 | } |
| 1105 | |
| 1106 | |
| 1107 | |
| 1108 | |
| 1109 | eHalStatus csrIssueRoamAfterLostlinkScan(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamReason reason) |
| 1110 | { |
| 1111 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 1112 | tScanResultHandle hBSSList = NULL; |
| 1113 | tCsrScanResultFilter *pScanFilter = NULL; |
| 1114 | tANI_U32 roamId = 0; |
| 1115 | tCsrRoamProfile *pProfile = NULL; |
| 1116 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 1117 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1118 | if(!pSession) |
| 1119 | { |
| 1120 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 1121 | return eHAL_STATUS_FAILURE; |
| 1122 | } |
| 1123 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1124 | do |
| 1125 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1126 | smsLog(pMac, LOG1, " csrIssueRoamAfterLostlinkScan called"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1127 | if(pSession->fCancelRoaming) |
| 1128 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1129 | smsLog(pMac, LOGW, " lostlink roaming is cancelled"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1130 | csrScanStartIdleScan(pMac); |
| 1131 | status = eHAL_STATUS_SUCCESS; |
| 1132 | break; |
| 1133 | } |
| 1134 | //Here is the profile we need to connect to |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1135 | pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter)); |
| 1136 | if ( NULL == pScanFilter) |
| 1137 | status = eHAL_STATUS_FAILURE; |
| 1138 | else |
| 1139 | status = eHAL_STATUS_SUCCESS; |
| 1140 | if (!HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1141 | break; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1142 | vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1143 | if(NULL == pSession->pCurRoamProfile) |
| 1144 | { |
| 1145 | pScanFilter->EncryptionType.numEntries = 1; |
| 1146 | pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE; |
| 1147 | } |
| 1148 | else |
| 1149 | { |
| 1150 | //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] | 1151 | pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile)); |
| 1152 | if ( NULL == pProfile ) |
| 1153 | status = eHAL_STATUS_FAILURE; |
| 1154 | else |
| 1155 | status = eHAL_STATUS_SUCCESS; |
| 1156 | if (!HAL_STATUS_SUCCESS(status)) |
| 1157 | break; |
| 1158 | vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1159 | status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile); |
| 1160 | if(!HAL_STATUS_SUCCESS(status)) |
| 1161 | break; |
| 1162 | status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter); |
| 1163 | }//We have a profile |
| 1164 | roamId = GET_NEXT_ROAM_ID(&pMac->roam); |
| 1165 | if(HAL_STATUS_SUCCESS(status)) |
| 1166 | { |
| 1167 | status = csrScanGetResult(pMac, pScanFilter, &hBSSList); |
| 1168 | if(HAL_STATUS_SUCCESS(status)) |
| 1169 | { |
| 1170 | if(eCsrLostLink1 == reason) |
| 1171 | { |
| 1172 | //we want to put the last connected BSS to the very beginning, if possible |
| 1173 | csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList); |
| 1174 | } |
| 1175 | status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, reason, |
| 1176 | roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE); |
| 1177 | if(!HAL_STATUS_SUCCESS(status)) |
| 1178 | { |
| 1179 | csrScanResultPurge(pMac, hBSSList); |
| 1180 | } |
| 1181 | }//Have scan result |
| 1182 | } |
| 1183 | }while(0); |
| 1184 | if(pScanFilter) |
| 1185 | { |
| 1186 | //we need to free memory for filter if profile exists |
| 1187 | csrFreeScanFilter(pMac, pScanFilter); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1188 | vos_mem_free(pScanFilter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1189 | } |
| 1190 | if(NULL != pProfile) |
| 1191 | { |
| 1192 | csrReleaseProfile(pMac, pProfile); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1193 | vos_mem_free(pProfile); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1194 | } |
| 1195 | |
| 1196 | return (status); |
| 1197 | } |
| 1198 | |
| 1199 | |
Ratheesh S P | ece1f83 | 2015-07-25 15:50:25 +0530 | [diff] [blame] | 1200 | eHalStatus csrScanGetScanChnInfo(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1201 | { |
| 1202 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1203 | tSmeCmd *pScanCmd; |
| 1204 | |
| 1205 | if(pMac->scan.fScanEnable) |
| 1206 | { |
| 1207 | pScanCmd = csrGetCommandBuffer(pMac); |
| 1208 | if(pScanCmd) |
| 1209 | { |
| 1210 | pScanCmd->command = eSmeCommandScan; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1211 | vos_mem_set(&pScanCmd->u.scanCmd, sizeof(tScanCmd), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1212 | pScanCmd->u.scanCmd.reason = eCsrScanGetScanChnInfo; |
| 1213 | //Need to make the following atomic |
| 1214 | pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around |
Ratheesh S P | ece1f83 | 2015-07-25 15:50:25 +0530 | [diff] [blame] | 1215 | pScanCmd->sessionId = pCommand->sessionId; |
| 1216 | if( pCommand->u.scanCmd.reason == eCsrScanUserRequest) |
| 1217 | { |
| 1218 | pScanCmd->u.scanCmd.callback = NULL; |
| 1219 | pScanCmd->u.scanCmd.pContext = NULL; |
| 1220 | } else { |
| 1221 | pScanCmd->u.scanCmd.callback = pCommand->u.scanCmd.callback; |
| 1222 | pScanCmd->u.scanCmd.pContext = pCommand->u.scanCmd.pContext; |
| 1223 | pScanCmd->u.scanCmd.abortScanIndication = |
| 1224 | pCommand->u.scanCmd.abortScanIndication; |
| 1225 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1226 | status = csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_FALSE); |
| 1227 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 1228 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1229 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1230 | csrReleaseCommandScan(pMac, pScanCmd); |
| 1231 | } |
| 1232 | } |
| 1233 | else |
| 1234 | { |
| 1235 | //log error |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1236 | smsLog(pMac, LOGE, FL("can not obtain a common buffer")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1237 | status = eHAL_STATUS_RESOURCES; |
| 1238 | } |
| 1239 | } |
| 1240 | |
| 1241 | return (status); |
| 1242 | } |
| 1243 | |
| 1244 | |
| 1245 | eHalStatus csrScanHandleFailedLostlink1(tpAniSirGlobal pMac, tANI_U32 sessionId) |
| 1246 | { |
| 1247 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 1248 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 1249 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1250 | if(!pSession) |
| 1251 | { |
| 1252 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 1253 | return eHAL_STATUS_FAILURE; |
| 1254 | } |
| 1255 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1256 | smsLog(pMac, LOGW, " Lostlink scan 1 failed"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1257 | if(pSession->fCancelRoaming) |
| 1258 | { |
| 1259 | csrScanStartIdleScan(pMac); |
| 1260 | } |
| 1261 | else if(pSession->pCurRoamProfile) |
| 1262 | { |
| 1263 | //We fail lostlink1 but there may be other BSS in the cached result fit the profile. Give it a try first |
| 1264 | if(pSession->pCurRoamProfile->SSIDs.numOfSSIDs == 0 || |
| 1265 | pSession->pCurRoamProfile->SSIDs.numOfSSIDs > 1) |
| 1266 | { |
| 1267 | //try lostlink scan2 |
| 1268 | status = csrScanRequestLostLink2(pMac, sessionId); |
| 1269 | } |
| 1270 | else if(!pSession->pCurRoamProfile->ChannelInfo.ChannelList || |
| 1271 | pSession->pCurRoamProfile->ChannelInfo.ChannelList[0] == 0) |
| 1272 | { |
| 1273 | //go straight to lostlink scan3 |
| 1274 | status = csrScanRequestLostLink3(pMac, sessionId); |
| 1275 | } |
| 1276 | else |
| 1277 | { |
| 1278 | //we are done with lostlink |
| 1279 | if(csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_FALSE, eCSR_ROAM_RESULT_FAILURE)) |
| 1280 | { |
| 1281 | csrScanStartIdleScan(pMac); |
| 1282 | } |
| 1283 | status = eHAL_STATUS_SUCCESS; |
| 1284 | } |
| 1285 | } |
| 1286 | else |
| 1287 | { |
| 1288 | status = csrScanRequestLostLink3(pMac, sessionId); |
| 1289 | } |
| 1290 | |
| 1291 | return (status); |
| 1292 | } |
| 1293 | |
| 1294 | |
| 1295 | |
| 1296 | eHalStatus csrScanHandleFailedLostlink2(tpAniSirGlobal pMac, tANI_U32 sessionId) |
| 1297 | { |
| 1298 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 1299 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 1300 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1301 | if(!pSession) |
| 1302 | { |
| 1303 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 1304 | return eHAL_STATUS_FAILURE; |
| 1305 | } |
| 1306 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1307 | smsLog(pMac, LOGW, " Lostlink scan 2 failed"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1308 | if(pSession->fCancelRoaming) |
| 1309 | { |
| 1310 | csrScanStartIdleScan(pMac); |
| 1311 | } |
| 1312 | else if(!pSession->pCurRoamProfile || !pSession->pCurRoamProfile->ChannelInfo.ChannelList || |
| 1313 | pSession->pCurRoamProfile->ChannelInfo.ChannelList[0] == 0) |
| 1314 | { |
| 1315 | //try lostlink scan3 |
| 1316 | status = csrScanRequestLostLink3(pMac, sessionId); |
| 1317 | } |
| 1318 | else |
| 1319 | { |
| 1320 | //we are done with lostlink |
| 1321 | if(csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_FALSE, eCSR_ROAM_RESULT_FAILURE)) |
| 1322 | { |
| 1323 | csrScanStartIdleScan(pMac); |
| 1324 | } |
| 1325 | } |
| 1326 | |
| 1327 | return (status); |
| 1328 | } |
| 1329 | |
| 1330 | |
| 1331 | |
| 1332 | eHalStatus csrScanHandleFailedLostlink3(tpAniSirGlobal pMac, tANI_U32 sessionId) |
| 1333 | { |
| 1334 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1335 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1336 | smsLog(pMac, LOGW, " Lostlink scan 3 failed"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1337 | if(eANI_BOOLEAN_TRUE == csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_FALSE, eCSR_ROAM_RESULT_FAILURE)) |
| 1338 | { |
| 1339 | //we are done with lostlink |
| 1340 | csrScanStartIdleScan(pMac); |
| 1341 | } |
| 1342 | |
| 1343 | return (status); |
| 1344 | } |
| 1345 | |
| 1346 | |
| 1347 | |
| 1348 | |
| 1349 | //Lostlink1 scan is to actively scan the last connected profile's SSID on all matched BSS channels. |
| 1350 | //If no roam profile (it should not), it is like lostlinkscan3 |
| 1351 | eHalStatus csrScanRequestLostLink1( tpAniSirGlobal pMac, tANI_U32 sessionId ) |
| 1352 | { |
| 1353 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1354 | tSmeCmd *pCommand = NULL; |
| 1355 | tANI_U8 bAddr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; |
| 1356 | tCsrScanResultFilter *pScanFilter = NULL; |
| 1357 | tScanResultHandle hBSSList = NULL; |
| 1358 | tCsrScanResultInfo *pScanResult = NULL; |
| 1359 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 1360 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1361 | if(!pSession) |
| 1362 | { |
| 1363 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 1364 | return eHAL_STATUS_FAILURE; |
| 1365 | } |
| 1366 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1367 | smsLog(pMac, LOGW, FL(" called")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1368 | do |
| 1369 | { |
| 1370 | pCommand = csrGetCommandBuffer(pMac); |
| 1371 | if(!pCommand) |
| 1372 | { |
| 1373 | status = eHAL_STATUS_RESOURCES; |
| 1374 | break; |
| 1375 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1376 | vos_mem_set(&pCommand->u.scanCmd, sizeof(tScanCmd), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1377 | pCommand->command = eSmeCommandScan; |
| 1378 | pCommand->sessionId = (tANI_U8)sessionId; |
| 1379 | pCommand->u.scanCmd.reason = eCsrScanLostLink1; |
| 1380 | pCommand->u.scanCmd.callback = NULL; |
| 1381 | pCommand->u.scanCmd.pContext = NULL; |
| 1382 | pCommand->u.scanCmd.u.scanRequest.maxChnTime = pMac->roam.configParam.nActiveMaxChnTime; |
| 1383 | pCommand->u.scanCmd.u.scanRequest.minChnTime = pMac->roam.configParam.nActiveMinChnTime; |
Abhishek Singh | add1358 | 2016-09-29 17:00:03 +0530 | [diff] [blame] | 1384 | pCommand->u.scanCmd.u.scanRequest.max_chntime_btc_esco = |
| 1385 | pMac->roam.configParam.max_chntime_btc_esco; |
| 1386 | pCommand->u.scanCmd.u.scanRequest.min_chntime_btc_esco = |
| 1387 | pMac->roam.configParam.min_chntime_btc_esco; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1388 | pCommand->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 1389 | if(pSession->connectedProfile.SSID.length) |
| 1390 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1391 | pCommand->u.scanCmd.u.scanRequest.SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo)); |
| 1392 | if ( NULL == pCommand->u.scanCmd.u.scanRequest.SSIDs.SSIDList ) |
| 1393 | status = eHAL_STATUS_FAILURE; |
| 1394 | else |
| 1395 | status = eHAL_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1396 | if(!HAL_STATUS_SUCCESS(status)) |
| 1397 | { |
| 1398 | break; |
| 1399 | } |
| 1400 | pCommand->u.scanCmd.u.scanRequest.SSIDs.numOfSSIDs = 1; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1401 | vos_mem_copy(&pCommand->u.scanCmd.u.scanRequest.SSIDs.SSIDList[0].SSID, |
| 1402 | &pSession->connectedProfile.SSID, sizeof(tSirMacSSid)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1403 | } |
| 1404 | else |
| 1405 | { |
| 1406 | pCommand->u.scanCmd.u.scanRequest.SSIDs.numOfSSIDs = 0; |
| 1407 | } |
| 1408 | if(pSession->pCurRoamProfile) |
| 1409 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1410 | pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter)); |
| 1411 | if ( NULL == pScanFilter ) |
| 1412 | status = eHAL_STATUS_FAILURE; |
| 1413 | else |
| 1414 | status = eHAL_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1415 | if(!HAL_STATUS_SUCCESS(status)) |
| 1416 | { |
| 1417 | break; |
| 1418 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1419 | vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1420 | status = csrRoamPrepareFilterFromProfile(pMac, pSession->pCurRoamProfile, pScanFilter); |
| 1421 | if(!HAL_STATUS_SUCCESS(status)) |
| 1422 | { |
| 1423 | break; |
| 1424 | } |
| 1425 | //Don't change variable status here because whether we can get result or not, the command goes to PE. |
| 1426 | //The status is also used to indicate whether the command is queued. Not success meaning not queue |
| 1427 | if(HAL_STATUS_SUCCESS((csrScanGetResult(pMac, pScanFilter, &hBSSList))) && hBSSList) |
| 1428 | { |
| 1429 | tANI_U8 i, nChn = 0; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1430 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = |
| 1431 | vos_mem_malloc(WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 1432 | if ( NULL == pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList ) |
| 1433 | status = eHAL_STATUS_FAILURE; |
| 1434 | else |
| 1435 | status = eHAL_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1436 | if(!HAL_STATUS_SUCCESS(status)) |
| 1437 | { |
| 1438 | break; |
| 1439 | } |
| 1440 | while(((pScanResult = csrScanResultGetNext(pMac, hBSSList)) != NULL) && |
| 1441 | nChn < WNI_CFG_VALID_CHANNEL_LIST_LEN) |
| 1442 | { |
| 1443 | for(i = 0; i < nChn; i++) |
| 1444 | { |
| 1445 | if(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[i] == |
| 1446 | pScanResult->BssDescriptor.channelId) |
| 1447 | { |
| 1448 | break; |
| 1449 | } |
| 1450 | } |
| 1451 | if(i == nChn) |
| 1452 | { |
| 1453 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[nChn++] = pScanResult->BssDescriptor.channelId; |
| 1454 | } |
| 1455 | } |
| 1456 | //Include the last connected BSS' channel |
| 1457 | if(csrRoamIsChannelValid(pMac, pSession->connectedProfile.operationChannel)) |
| 1458 | { |
| 1459 | for(i = 0; i < nChn; i++) |
| 1460 | { |
| 1461 | if(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[i] == |
| 1462 | pSession->connectedProfile.operationChannel) |
| 1463 | { |
| 1464 | break; |
| 1465 | } |
| 1466 | } |
| 1467 | if(i == nChn) |
| 1468 | { |
| 1469 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[nChn++] = pSession->connectedProfile.operationChannel; |
| 1470 | } |
| 1471 | } |
| 1472 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = nChn; |
| 1473 | } |
| 1474 | else |
| 1475 | { |
| 1476 | if(csrRoamIsChannelValid(pMac, pSession->connectedProfile.operationChannel)) |
| 1477 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1478 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = vos_mem_malloc(1); |
| 1479 | if ( NULL == pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList ) |
| 1480 | status = eHAL_STATUS_FAILURE; |
| 1481 | else |
| 1482 | status = eHAL_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1483 | //just try the last connected channel |
| 1484 | if(HAL_STATUS_SUCCESS(status)) |
| 1485 | { |
| 1486 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[0] = pSession->connectedProfile.operationChannel; |
| 1487 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = 1; |
| 1488 | } |
| 1489 | else |
| 1490 | { |
| 1491 | break; |
| 1492 | } |
| 1493 | } |
| 1494 | } |
| 1495 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1496 | vos_mem_copy(&pCommand->u.scanCmd.u.scanRequest.bssid, bAddr, sizeof(tCsrBssid)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1497 | status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE); |
| 1498 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 1499 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1500 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1501 | break; |
| 1502 | } |
| 1503 | } while( 0 ); |
| 1504 | |
| 1505 | if(!HAL_STATUS_SUCCESS(status)) |
| 1506 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1507 | smsLog(pMac, LOGW, " csrScanRequestLostLink1 failed with status %d", status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1508 | if(pCommand) |
| 1509 | { |
| 1510 | csrReleaseCommandScan(pMac, pCommand); |
| 1511 | } |
| 1512 | status = csrScanHandleFailedLostlink1( pMac, sessionId ); |
| 1513 | } |
| 1514 | if(pScanFilter) |
| 1515 | { |
| 1516 | csrFreeScanFilter(pMac, pScanFilter); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1517 | vos_mem_free(pScanFilter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1518 | } |
| 1519 | if(hBSSList) |
| 1520 | { |
| 1521 | csrScanResultPurge(pMac, hBSSList); |
| 1522 | } |
| 1523 | |
| 1524 | return( status ); |
| 1525 | } |
| 1526 | |
| 1527 | |
| 1528 | //Lostlink2 scan is to actively scan the all SSIDs of the last roaming profile's on all matched BSS channels. |
| 1529 | //Since MAC doesn't support multiple SSID, we scan all SSIDs and filter them afterwards |
| 1530 | eHalStatus csrScanRequestLostLink2( tpAniSirGlobal pMac, tANI_U32 sessionId ) |
| 1531 | { |
| 1532 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1533 | tANI_U8 bAddr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; |
| 1534 | tCsrScanResultFilter *pScanFilter = NULL; |
| 1535 | tScanResultHandle hBSSList = NULL; |
| 1536 | tCsrScanResultInfo *pScanResult = NULL; |
| 1537 | tSmeCmd *pCommand = NULL; |
| 1538 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 1539 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1540 | if(!pSession) |
| 1541 | { |
| 1542 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 1543 | return eHAL_STATUS_FAILURE; |
| 1544 | } |
| 1545 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1546 | smsLog(pMac, LOGW, FL(" called")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1547 | do |
| 1548 | { |
| 1549 | pCommand = csrGetCommandBuffer(pMac); |
| 1550 | if(!pCommand) |
| 1551 | { |
| 1552 | status = eHAL_STATUS_RESOURCES; |
| 1553 | break; |
| 1554 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1555 | vos_mem_set(&pCommand->u.scanCmd, sizeof(tScanCmd), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1556 | pCommand->command = eSmeCommandScan; |
| 1557 | pCommand->sessionId = (tANI_U8)sessionId; |
| 1558 | pCommand->u.scanCmd.reason = eCsrScanLostLink2; |
| 1559 | pCommand->u.scanCmd.callback = NULL; |
| 1560 | pCommand->u.scanCmd.pContext = NULL; |
| 1561 | pCommand->u.scanCmd.u.scanRequest.maxChnTime = pMac->roam.configParam.nActiveMaxChnTime; |
| 1562 | pCommand->u.scanCmd.u.scanRequest.minChnTime = pMac->roam.configParam.nActiveMinChnTime; |
Abhishek Singh | add1358 | 2016-09-29 17:00:03 +0530 | [diff] [blame] | 1563 | pCommand->u.scanCmd.u.scanRequest.max_chntime_btc_esco = |
| 1564 | pMac->roam.configParam.max_chntime_btc_esco; |
| 1565 | pCommand->u.scanCmd.u.scanRequest.min_chntime_btc_esco = |
| 1566 | pMac->roam.configParam.min_chntime_btc_esco; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1567 | pCommand->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 1568 | if(pSession->pCurRoamProfile) |
| 1569 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1570 | pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter)); |
| 1571 | if ( NULL == pScanFilter ) |
| 1572 | status = eHAL_STATUS_FAILURE; |
| 1573 | else |
| 1574 | status = eHAL_STATUS_SUCCESS; |
| 1575 | if (!HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1576 | { |
| 1577 | break; |
| 1578 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1579 | vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1580 | status = csrRoamPrepareFilterFromProfile(pMac, pSession->pCurRoamProfile, pScanFilter); |
| 1581 | if(!HAL_STATUS_SUCCESS(status)) |
| 1582 | { |
| 1583 | break; |
| 1584 | } |
| 1585 | status = csrScanGetResult(pMac, pScanFilter, &hBSSList); |
| 1586 | if(!HAL_STATUS_SUCCESS(status)) |
| 1587 | { |
| 1588 | break; |
| 1589 | } |
| 1590 | if(hBSSList) |
| 1591 | { |
| 1592 | tANI_U8 i, nChn = 0; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1593 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = |
| 1594 | vos_mem_malloc(WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 1595 | if ( NULL == pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList ) |
| 1596 | status = eHAL_STATUS_FAILURE; |
| 1597 | else |
| 1598 | status = eHAL_STATUS_SUCCESS; |
| 1599 | if (!HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1600 | { |
| 1601 | break; |
| 1602 | } |
| 1603 | while(((pScanResult = csrScanResultGetNext(pMac, hBSSList)) != NULL) && |
| 1604 | nChn < WNI_CFG_VALID_CHANNEL_LIST_LEN) |
| 1605 | { |
| 1606 | for(i = 0; i < nChn; i++) |
| 1607 | { |
| 1608 | if(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[i] == |
| 1609 | pScanResult->BssDescriptor.channelId) |
| 1610 | { |
| 1611 | break; |
| 1612 | } |
| 1613 | } |
| 1614 | if(i == nChn) |
| 1615 | { |
| 1616 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[nChn++] = pScanResult->BssDescriptor.channelId; |
| 1617 | } |
| 1618 | } |
| 1619 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = nChn; |
| 1620 | } |
| 1621 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1622 | vos_mem_copy(&pCommand->u.scanCmd.u.scanRequest.bssid, bAddr, sizeof(tCsrBssid)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1623 | //Put to the head in pending queue |
| 1624 | status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE); |
| 1625 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 1626 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1627 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1628 | break; |
| 1629 | } |
| 1630 | } while( 0 ); |
| 1631 | |
| 1632 | if(!HAL_STATUS_SUCCESS(status)) |
| 1633 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1634 | smsLog(pMac, LOGW, " csrScanRequestLostLink2 failed with status %d", status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1635 | if(pCommand) |
| 1636 | { |
| 1637 | csrReleaseCommandScan(pMac, pCommand); |
| 1638 | } |
| 1639 | status = csrScanHandleFailedLostlink2( pMac, sessionId ); |
| 1640 | } |
| 1641 | if(pScanFilter) |
| 1642 | { |
| 1643 | csrFreeScanFilter(pMac, pScanFilter); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1644 | vos_mem_free(pScanFilter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1645 | } |
| 1646 | if(hBSSList) |
| 1647 | { |
| 1648 | csrScanResultPurge(pMac, hBSSList); |
| 1649 | } |
| 1650 | |
| 1651 | return( status ); |
| 1652 | } |
| 1653 | |
| 1654 | |
| 1655 | //To actively scan all valid channels |
| 1656 | eHalStatus csrScanRequestLostLink3( tpAniSirGlobal pMac, tANI_U32 sessionId ) |
| 1657 | { |
| 1658 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1659 | tSmeCmd *pCommand; |
| 1660 | tANI_U8 bAddr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; |
| 1661 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1662 | smsLog(pMac, LOGW, FL(" called")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1663 | do |
| 1664 | { |
| 1665 | pCommand = csrGetCommandBuffer(pMac); |
| 1666 | if(!pCommand) |
| 1667 | { |
| 1668 | status = eHAL_STATUS_RESOURCES; |
| 1669 | break; |
| 1670 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1671 | vos_mem_set(&pCommand->u.scanCmd, sizeof(tScanCmd), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1672 | pCommand->command = eSmeCommandScan; |
| 1673 | pCommand->sessionId = (tANI_U8)sessionId; |
| 1674 | pCommand->u.scanCmd.reason = eCsrScanLostLink3; |
| 1675 | pCommand->u.scanCmd.callback = NULL; |
| 1676 | pCommand->u.scanCmd.pContext = NULL; |
| 1677 | pCommand->u.scanCmd.u.scanRequest.maxChnTime = pMac->roam.configParam.nActiveMaxChnTime; |
| 1678 | pCommand->u.scanCmd.u.scanRequest.minChnTime = pMac->roam.configParam.nActiveMinChnTime; |
Abhishek Singh | add1358 | 2016-09-29 17:00:03 +0530 | [diff] [blame] | 1679 | pCommand->u.scanCmd.u.scanRequest.max_chntime_btc_esco = |
| 1680 | pMac->roam.configParam.max_chntime_btc_esco; |
| 1681 | pCommand->u.scanCmd.u.scanRequest.min_chntime_btc_esco = |
| 1682 | pMac->roam.configParam.min_chntime_btc_esco; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1683 | pCommand->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1684 | vos_mem_copy(&pCommand->u.scanCmd.u.scanRequest.bssid, bAddr, sizeof(tCsrBssid)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1685 | //Put to the head of pending queue |
| 1686 | status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE); |
| 1687 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 1688 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1689 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1690 | break; |
| 1691 | } |
| 1692 | } while( 0 ); |
| 1693 | if(!HAL_STATUS_SUCCESS(status)) |
| 1694 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1695 | smsLog(pMac, LOGW, " csrScanRequestLostLink3 failed with status %d", status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1696 | if(csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_FALSE, eCSR_ROAM_RESULT_FAILURE)) |
| 1697 | { |
| 1698 | csrScanStartIdleScan(pMac); |
| 1699 | } |
| 1700 | if(pCommand) |
| 1701 | { |
| 1702 | csrReleaseCommandScan(pMac, pCommand); |
| 1703 | } |
| 1704 | } |
| 1705 | |
| 1706 | return( status ); |
| 1707 | } |
| 1708 | |
| 1709 | |
| 1710 | eHalStatus csrScanHandleSearchForSSID(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
| 1711 | { |
| 1712 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 1713 | tScanResultHandle hBSSList = CSR_INVALID_SCANRESULT_HANDLE; |
| 1714 | tCsrScanResultFilter *pScanFilter = NULL; |
| 1715 | tCsrRoamProfile *pProfile = pCommand->u.scanCmd.pToRoamProfile; |
| 1716 | tANI_U32 sessionId = pCommand->sessionId; |
Abhishek Singh | d61b97a | 2015-12-17 15:23:52 +0530 | [diff] [blame] | 1717 | tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId); |
| 1718 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1719 | do |
| 1720 | { |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 1721 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 1722 | //if this scan is for LFR |
| 1723 | if(pMac->roam.neighborRoamInfo.uOsRequestedHandoff) |
| 1724 | { |
| 1725 | //notify LFR state m/c |
| 1726 | if(eHAL_STATUS_SUCCESS != csrNeighborRoamSssidScanDone(pMac, eHAL_STATUS_SUCCESS)) |
| 1727 | { |
Mukul Sharma | 20aa658 | 2014-08-07 21:36:12 +0530 | [diff] [blame] | 1728 | csrNeighborRoamStartLfrScan(pMac, REASON_OS_REQUESTED_ROAMING_NOW); |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 1729 | } |
| 1730 | status = eHAL_STATUS_SUCCESS; |
| 1731 | break; |
| 1732 | } |
| 1733 | #endif |
Abhishek Singh | d61b97a | 2015-12-17 15:23:52 +0530 | [diff] [blame] | 1734 | if (!pSession) |
| 1735 | { |
| 1736 | smsLog(pMac, LOGE, FL("session %d not found"), sessionId); |
| 1737 | break; |
| 1738 | } |
Abhishek Singh | 5de9efd | 2017-06-15 10:22:39 +0530 | [diff] [blame] | 1739 | /* If Disconnect is already issued from HDD no need to issue connect */ |
| 1740 | if (pSession->abortConnection) |
Abhishek Singh | d61b97a | 2015-12-17 15:23:52 +0530 | [diff] [blame] | 1741 | { |
| 1742 | smsLog(pMac, LOGE, |
| 1743 | FL("Disconnect in progress, no need to issue connect")); |
| 1744 | break; |
| 1745 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1746 | //If there is roam command waiting, ignore this roam because the newer roam command is the one to execute |
| 1747 | if(csrIsRoamCommandWaitingForSession(pMac, sessionId)) |
| 1748 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1749 | smsLog(pMac, LOGW, FL(" aborts because roam command waiting")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1750 | break; |
| 1751 | } |
| 1752 | if(pProfile == NULL) |
| 1753 | break; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1754 | pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter)); |
| 1755 | if ( NULL == pScanFilter ) |
| 1756 | status = eHAL_STATUS_FAILURE; |
| 1757 | else |
| 1758 | status = eHAL_STATUS_SUCCESS; |
| 1759 | if (!HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1760 | break; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1761 | vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1762 | status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter); |
| 1763 | if(!HAL_STATUS_SUCCESS(status)) |
| 1764 | break; |
| 1765 | status = csrScanGetResult(pMac, pScanFilter, &hBSSList); |
| 1766 | if(!HAL_STATUS_SUCCESS(status)) |
| 1767 | break; |
| 1768 | status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued, |
| 1769 | pCommand->u.scanCmd.roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE); |
| 1770 | if(!HAL_STATUS_SUCCESS(status)) |
| 1771 | { |
| 1772 | break; |
| 1773 | } |
| 1774 | }while(0); |
| 1775 | if(!HAL_STATUS_SUCCESS(status)) |
| 1776 | { |
| 1777 | if(CSR_INVALID_SCANRESULT_HANDLE != hBSSList) |
| 1778 | { |
| 1779 | csrScanResultPurge(pMac, hBSSList); |
| 1780 | } |
| 1781 | //We haven't done anything to this profile |
Abhishek Singh | 72c2f4e | 2016-07-22 11:25:43 +0530 | [diff] [blame] | 1782 | csrRoamCallCallback(pMac, sessionId, NULL, |
| 1783 | pCommand->u.scanCmd.roamId, |
| 1784 | eCSR_ROAM_ASSOCIATION_FAILURE, |
| 1785 | eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1786 | //In case we have nothing else to do, restart idle scan |
| 1787 | if(csrIsConnStateDisconnected(pMac, sessionId) && !csrIsRoamCommandWaiting(pMac)) |
| 1788 | { |
| 1789 | status = csrScanStartIdleScan(pMac); |
| 1790 | } |
| 1791 | #ifdef FEATURE_WLAN_BTAMP_UT_RF |
| 1792 | //In case of WDS station, let it retry. |
| 1793 | if( CSR_IS_WDS_STA(pProfile) ) |
| 1794 | { |
| 1795 | //Save the roma profile so we can retry |
| 1796 | csrFreeRoamProfile( pMac, sessionId ); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1797 | pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile)); |
| 1798 | if ( NULL != pSession->pCurRoamProfile ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1799 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1800 | vos_mem_set(pSession->pCurRoamProfilee, sizeof(tCsrRoamProfile), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1801 | csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile); |
| 1802 | } |
| 1803 | csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD); |
| 1804 | } |
| 1805 | #endif |
| 1806 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1807 | if (pScanFilter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1808 | { |
| 1809 | csrFreeScanFilter(pMac, pScanFilter); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1810 | vos_mem_free(pScanFilter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1811 | } |
| 1812 | |
| 1813 | return (status); |
| 1814 | } |
| 1815 | |
| 1816 | |
| 1817 | eHalStatus csrScanHandleSearchForSSIDFailure(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
| 1818 | { |
| 1819 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1820 | tANI_U32 sessionId = pCommand->sessionId; |
| 1821 | tCsrRoamProfile *pProfile = pCommand->u.scanCmd.pToRoamProfile; |
| 1822 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 1823 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 1824 | //if this scan is for LFR |
| 1825 | if(pMac->roam.neighborRoamInfo.uOsRequestedHandoff) |
| 1826 | { |
| 1827 | //notify LFR state m/c |
| 1828 | if(eHAL_STATUS_SUCCESS != csrNeighborRoamSssidScanDone(pMac, eHAL_STATUS_FAILURE)) |
| 1829 | { |
Mukul Sharma | 20aa658 | 2014-08-07 21:36:12 +0530 | [diff] [blame] | 1830 | csrNeighborRoamStartLfrScan(pMac, REASON_OS_REQUESTED_ROAMING_NOW); |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 1831 | } |
| 1832 | return eHAL_STATUS_SUCCESS; |
| 1833 | } |
| 1834 | #endif |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1835 | if(!pSession) |
| 1836 | { |
| 1837 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 1838 | return eHAL_STATUS_FAILURE; |
| 1839 | } |
| 1840 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1841 | #if defined(WLAN_DEBUG) |
| 1842 | if(pCommand->u.scanCmd.u.scanRequest.SSIDs.numOfSSIDs == 1) |
| 1843 | { |
| 1844 | char str[36]; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1845 | vos_mem_copy(str, |
| 1846 | pCommand->u.scanCmd.u.scanRequest.SSIDs.SSIDList[0].SSID.ssId, |
| 1847 | pCommand->u.scanCmd.u.scanRequest.SSIDs.SSIDList[0].SSID.length); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1848 | 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] | 1849 | smsLog(pMac, LOGW, FL(" SSID = %s"), str); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1850 | } |
| 1851 | #endif |
| 1852 | //Check whether it is for start ibss. No need to do anything if it is a JOIN request |
| 1853 | if(pProfile && CSR_IS_START_IBSS(pProfile)) |
| 1854 | { |
| 1855 | status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued, |
| 1856 | pCommand->u.scanCmd.roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE); |
| 1857 | if(!HAL_STATUS_SUCCESS(status)) |
| 1858 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1859 | 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] | 1860 | csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.scanCmd.roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE); |
| 1861 | } |
| 1862 | } |
| 1863 | else |
| 1864 | { |
| 1865 | eCsrRoamResult roamResult = eCSR_ROAM_RESULT_FAILURE; |
| 1866 | |
| 1867 | if(csrIsConnStateDisconnected(pMac, sessionId) && |
| 1868 | !csrIsRoamCommandWaitingForSession(pMac, sessionId)) |
| 1869 | { |
| 1870 | status = csrScanStartIdleScan(pMac); |
| 1871 | } |
| 1872 | if((NULL == pProfile) || !csrIsBssTypeIBSS(pProfile->BSSType)) |
| 1873 | { |
| 1874 | //Only indicate assoc_completion if we indicate assoc_start. |
| 1875 | if(pSession->bRefAssocStartCnt > 0) |
| 1876 | { |
| 1877 | tCsrRoamInfo *pRoamInfo = NULL, roamInfo; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1878 | vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1879 | pRoamInfo = &roamInfo; |
| 1880 | if(pCommand->u.roamCmd.pRoamBssEntry) |
| 1881 | { |
| 1882 | tCsrScanResult *pScanResult = |
| 1883 | GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, |
| 1884 | tCsrScanResult, Link); |
| 1885 | roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor; |
| 1886 | } |
| 1887 | roamInfo.statusCode = pSession->joinFailStatusCode.statusCode; |
| 1888 | roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode; |
| 1889 | pSession->bRefAssocStartCnt--; |
| 1890 | csrRoamCallCallback(pMac, sessionId, pRoamInfo, |
| 1891 | pCommand->u.scanCmd.roamId, |
| 1892 | eCSR_ROAM_ASSOCIATION_COMPLETION, |
Abhishek Singh | 72c2f4e | 2016-07-22 11:25:43 +0530 | [diff] [blame] | 1893 | eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1894 | } |
Madan Mohan Koyyalamudi | ee255f1 | 2012-09-28 15:41:19 -0700 | [diff] [blame] | 1895 | else |
| 1896 | { |
| 1897 | csrRoamCallCallback(pMac, sessionId, NULL, |
| 1898 | pCommand->u.scanCmd.roamId, |
| 1899 | eCSR_ROAM_ASSOCIATION_FAILURE, |
Abhishek Singh | 72c2f4e | 2016-07-22 11:25:43 +0530 | [diff] [blame] | 1900 | eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE); |
Madan Mohan Koyyalamudi | ee255f1 | 2012-09-28 15:41:19 -0700 | [diff] [blame] | 1901 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1902 | #ifdef FEATURE_WLAN_BTAMP_UT_RF |
| 1903 | //In case of WDS station, let it retry. |
| 1904 | if( CSR_IS_WDS_STA(pProfile) ) |
| 1905 | { |
| 1906 | //Save the roma profile so we can retry |
| 1907 | csrFreeRoamProfile( pMac, sessionId ); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1908 | pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile)); |
| 1909 | if ( NULL != pSession->pCurRoamProfile ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1910 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1911 | vos_mem_set(pSession->pCurRoamProfile, sizeof(tCsrRoamProfile), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1912 | csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile); |
| 1913 | } |
| 1914 | csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD); |
| 1915 | } |
| 1916 | #endif |
| 1917 | } |
| 1918 | else |
| 1919 | { |
| 1920 | roamResult = eCSR_ROAM_RESULT_IBSS_START_FAILED; |
| 1921 | } |
| 1922 | csrRoamCompletion(pMac, sessionId, NULL, pCommand, roamResult, eANI_BOOLEAN_FALSE); |
| 1923 | } |
| 1924 | |
| 1925 | return (status); |
| 1926 | } |
| 1927 | |
| 1928 | |
| 1929 | //After scan for cap changes, issue a roaming command to either reconnect to the AP or pick another one to connect |
| 1930 | eHalStatus csrScanHandleCapChangeScanComplete(tpAniSirGlobal pMac, tANI_U32 sessionId) |
| 1931 | { |
| 1932 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 1933 | tScanResultHandle hBSSList = NULL; |
| 1934 | tCsrScanResultFilter *pScanFilter = NULL; |
| 1935 | tANI_U32 roamId = 0; |
| 1936 | tCsrRoamProfile *pProfile = NULL; |
| 1937 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 1938 | |
| 1939 | do |
| 1940 | { |
| 1941 | //Here is the profile we need to connect to |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1942 | pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter)); |
| 1943 | if ( NULL == pScanFilter ) |
| 1944 | status = eHAL_STATUS_FAILURE; |
| 1945 | else |
| 1946 | status = eHAL_STATUS_SUCCESS; |
| 1947 | if (!HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1948 | break; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1949 | vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0); |
| 1950 | if (NULL == pSession) break; |
| 1951 | if (NULL == pSession->pCurRoamProfile) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1952 | { |
| 1953 | pScanFilter->EncryptionType.numEntries = 1; |
| 1954 | pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE; |
| 1955 | } |
| 1956 | else |
| 1957 | { |
| 1958 | //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] | 1959 | pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile)); |
| 1960 | if ( NULL == pProfile ) |
| 1961 | status = eHAL_STATUS_FAILURE; |
| 1962 | else |
| 1963 | status = eHAL_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1964 | if(!HAL_STATUS_SUCCESS(status)) |
| 1965 | break; |
| 1966 | status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile); |
| 1967 | if(!HAL_STATUS_SUCCESS(status)) |
| 1968 | break; |
| 1969 | status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter); |
| 1970 | }//We have a profile |
| 1971 | roamId = GET_NEXT_ROAM_ID(&pMac->roam); |
| 1972 | if(HAL_STATUS_SUCCESS(status)) |
| 1973 | { |
| 1974 | status = csrScanGetResult(pMac, pScanFilter, &hBSSList); |
| 1975 | if(HAL_STATUS_SUCCESS(status)) |
| 1976 | { |
| 1977 | //we want to put the last connected BSS to the very beginning, if possible |
| 1978 | csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList); |
| 1979 | status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, |
| 1980 | eCsrCapsChange, 0, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE); |
| 1981 | if(!HAL_STATUS_SUCCESS(status)) |
| 1982 | { |
| 1983 | csrScanResultPurge(pMac, hBSSList); |
| 1984 | } |
| 1985 | }//Have scan result |
| 1986 | else |
| 1987 | { |
Arif Hussain | a7c8e41 | 2013-11-20 11:06:42 -0800 | [diff] [blame] | 1988 | smsLog(pMac, LOGW, FL("cannot find matching BSS of " |
| 1989 | MAC_ADDRESS_STR), |
| 1990 | MAC_ADDR_ARRAY(pSession->connectedProfile.bssid)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1991 | //Disconnect |
| 1992 | csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED); |
| 1993 | } |
| 1994 | } |
| 1995 | }while(0); |
| 1996 | if(pScanFilter) |
| 1997 | { |
| 1998 | csrFreeScanFilter(pMac, pScanFilter); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1999 | vos_mem_free(pScanFilter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2000 | } |
| 2001 | if(NULL != pProfile) |
| 2002 | { |
| 2003 | csrReleaseProfile(pMac, pProfile); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2004 | vos_mem_free(pProfile); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2005 | } |
| 2006 | |
| 2007 | return (status); |
| 2008 | } |
| 2009 | |
| 2010 | |
| 2011 | |
| 2012 | eHalStatus csrScanResultPurge(tpAniSirGlobal pMac, tScanResultHandle hScanList) |
| 2013 | { |
| 2014 | eHalStatus status = eHAL_STATUS_INVALID_PARAMETER; |
| 2015 | tScanResultList *pScanList = (tScanResultList *)hScanList; |
| 2016 | |
| 2017 | if(pScanList) |
| 2018 | { |
| 2019 | status = csrLLScanPurgeResult(pMac, &pScanList->List); |
| 2020 | csrLLClose(&pScanList->List); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2021 | vos_mem_free(pScanList); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2022 | } |
| 2023 | return (status); |
| 2024 | } |
| 2025 | |
| 2026 | |
| 2027 | static tANI_U32 csrGetBssPreferValue(tpAniSirGlobal pMac, int rssi) |
| 2028 | { |
| 2029 | tANI_U32 ret = 0; |
| 2030 | int i = CSR_NUM_RSSI_CAT - 1; |
| 2031 | |
| 2032 | while(i >= 0) |
| 2033 | { |
| 2034 | if(rssi >= pMac->roam.configParam.RSSICat[i]) |
| 2035 | { |
| 2036 | ret = pMac->roam.configParam.BssPreferValue[i]; |
| 2037 | break; |
| 2038 | } |
| 2039 | i--; |
| 2040 | }; |
| 2041 | |
| 2042 | return (ret); |
| 2043 | } |
| 2044 | |
| 2045 | |
| 2046 | //Return a CapValue base on the capabilities of a BSS |
| 2047 | static tANI_U32 csrGetBssCapValue(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes) |
| 2048 | { |
| 2049 | tANI_U32 ret = CSR_BSS_CAP_VALUE_NONE; |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2050 | #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] | 2051 | if(CSR_IS_ROAM_PREFER_5GHZ(pMac)) |
| 2052 | { |
| 2053 | if((pBssDesc) && CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId)) |
| 2054 | { |
| 2055 | ret += CSR_BSS_CAP_VALUE_5GHZ; |
| 2056 | } |
| 2057 | } |
| 2058 | #endif |
Srinivas Girigowda | 41c7c5f | 2013-10-21 19:01:38 -0700 | [diff] [blame] | 2059 | /* if strict select 5GHz is non-zero then ignore the capability checking */ |
| 2060 | if (pIes && !CSR_IS_SELECT_5GHZ_MARGIN(pMac)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2061 | { |
| 2062 | //We only care about 11N capability |
| 2063 | if(pIes->HTCaps.present) |
| 2064 | { |
| 2065 | ret += CSR_BSS_CAP_VALUE_HT; |
| 2066 | } |
| 2067 | if(CSR_IS_QOS_BSS(pIes)) |
| 2068 | { |
| 2069 | ret += CSR_BSS_CAP_VALUE_WMM; |
| 2070 | //Give advantage to UAPSD |
| 2071 | if(CSR_IS_UAPSD_BSS(pIes)) |
| 2072 | { |
| 2073 | ret += CSR_BSS_CAP_VALUE_UAPSD; |
| 2074 | } |
| 2075 | } |
| 2076 | } |
| 2077 | |
| 2078 | return (ret); |
| 2079 | } |
| 2080 | |
Kapil Gupta | b3a981b | 2016-06-26 13:36:51 +0530 | [diff] [blame] | 2081 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 2082 | |
| 2083 | /* Calculate channel weight based on other APs RSSI and count for |
| 2084 | * PER based roaming */ |
| 2085 | static tANI_U32 GetPERRoamRssiCountWeight(tANI_S32 rssi, tANI_S32 count) |
| 2086 | { |
| 2087 | tANI_S32 rssiWeight=0; |
| 2088 | tANI_S32 countWeight=0; |
| 2089 | tANI_S32 rssicountWeight=0; |
| 2090 | |
| 2091 | rssiWeight = ROAMING_RSSI_WEIGHT * (rssi - MIN_RSSI) |
| 2092 | /(MAX_RSSI - MIN_RSSI); |
| 2093 | |
| 2094 | if(rssiWeight > ROAMING_RSSI_WEIGHT) |
| 2095 | rssiWeight = ROAMING_RSSI_WEIGHT; |
| 2096 | else if (rssiWeight < 0) |
| 2097 | rssiWeight = 0; |
| 2098 | |
| 2099 | countWeight = ROAM_AP_COUNT_WEIGHT * (count + ROAM_MIN_COUNT) |
| 2100 | /(ROAM_MAX_COUNT + ROAM_MIN_COUNT); |
| 2101 | |
| 2102 | if(countWeight > ROAM_AP_COUNT_WEIGHT) |
| 2103 | countWeight = ROAM_AP_COUNT_WEIGHT; |
| 2104 | |
| 2105 | rssicountWeight = ROAM_MAX_WEIGHT - (rssiWeight + countWeight); |
| 2106 | |
| 2107 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, |
| 2108 | FL("rssiWeight=%d, countWeight=%d, rssicountWeight=%d rssi=%d count=%d"), |
| 2109 | rssiWeight, countWeight, rssicountWeight, rssi, count); |
| 2110 | |
| 2111 | return rssicountWeight; |
| 2112 | } |
| 2113 | |
| 2114 | /* Calculate BSS score based on AP capabilty and channel condition |
| 2115 | * for PER based roaming */ |
| 2116 | static tANI_U32 calculateBssScore(tSirBssDescription *bssInfo, |
| 2117 | tANI_S32 best_rssi, tANI_S32 ap_cnt, tANI_S32 cca) |
| 2118 | { |
| 2119 | tANI_S32 score = 0; |
| 2120 | tANI_S32 ap_load = 0; |
| 2121 | tANI_S32 normalised_width = PER_ROAM_20MHZ; |
Sen, Devendra | 6940d0c | 2016-09-07 12:42:46 +0530 | [diff] [blame] | 2122 | tANI_S32 normalised_rssi = 0; |
Kapil Gupta | b3a981b | 2016-06-26 13:36:51 +0530 | [diff] [blame] | 2123 | tANI_S32 channel_weight; |
| 2124 | if (bssInfo->rssi) { |
| 2125 | /* Calculate % of rssi we are getting |
| 2126 | * max = 100 |
| 2127 | * min = 0 |
| 2128 | * less than -40 = 100% |
| 2129 | * -40 - -55 = 80% |
| 2130 | * -55 - -65 = 60% |
| 2131 | * below that = 100 - value |
| 2132 | * TODO: a linear decrement function after PER_ROAM_GOOD_RSSI_WEIGHT |
| 2133 | * since throughput decrements linearly after PER_ROAM_GOOD_RSSI_WEIGHT |
| 2134 | **/ |
| 2135 | if (bssInfo->rssi >= PER_EXCELENT_RSSI) |
| 2136 | normalised_rssi = PER_ROAM_EXCELLENT_RSSI_WEIGHT; |
| 2137 | else if (bssInfo->rssi >= PER_GOOD_RSSI) |
| 2138 | normalised_rssi = PER_ROAM_GOOD_RSSI_WEIGHT; |
| 2139 | else if (bssInfo->rssi >= PER_POOR_RSSI) |
| 2140 | normalised_rssi = PER_ROAM_BAD_RSSI_WEIGHT; |
| 2141 | else |
| 2142 | normalised_rssi = bssInfo->rssi - MIN_RSSI; |
| 2143 | |
| 2144 | /* Calculate score part for rssi */ |
| 2145 | score += (normalised_rssi * RSSI_WEIGHTAGE); |
| 2146 | } |
| 2147 | |
| 2148 | if (bssInfo->HTCapsPresent) { |
| 2149 | score += PER_ROAM_MAX_WEIGHT * HT_CAPABILITY_WEIGHTAGE; |
| 2150 | } |
| 2151 | /* VHT caps are available */ |
| 2152 | if (bssInfo->vhtCapsPresent) { |
| 2153 | score += PER_ROAM_MAX_WEIGHT * VHT_CAP_WEIGHTAGE; |
| 2154 | } |
| 2155 | |
| 2156 | if (bssInfo->beacomformingCapable) |
| 2157 | score += PER_ROAM_MAX_WEIGHT * BEAMFORMING_CAP_WEIGHTAGE; |
| 2158 | |
| 2159 | /* Channel width 20Mhz=30, 40Mhz=70, 80Mhz=100 */ |
| 2160 | if (bssInfo->chanWidth == eHT_CHANNEL_WIDTH_80MHZ) |
| 2161 | normalised_width = PER_ROAM_80MHZ; |
| 2162 | else if (bssInfo->chanWidth == eHT_CHANNEL_WIDTH_40MHZ) |
| 2163 | normalised_width = PER_ROAM_40MHZ; |
| 2164 | else |
| 2165 | normalised_width = PER_ROAM_20MHZ; |
| 2166 | score += normalised_width * CHAN_WIDTH_WEIGHTAGE; |
| 2167 | |
| 2168 | /* Channel Band, Channel Number */ |
| 2169 | if (GetRFBand(bssInfo->channelId) == SIR_BAND_5_GHZ) |
| 2170 | score += PER_ROAM_MAX_WEIGHT * CHAN_BAND_WEIGHTAGE; |
| 2171 | |
| 2172 | /* WMM emabled */ |
| 2173 | if (bssInfo->wmeInfoPresent) |
| 2174 | score += PER_ROAM_MAX_WEIGHT * WMM_WEIGHTAGE; |
| 2175 | |
| 2176 | #if defined(FEATURE_WLAN_ESE) || defined(WLAN_FEATURE_ROAM_SCAN_OFFLOAD) |
| 2177 | /* AP load Ie */ |
| 2178 | if (bssInfo->QBSSLoad_present) { |
| 2179 | /* calculate value in % */ |
| 2180 | ap_load = (bssInfo->QBSS_ChanLoad * PER_ROAM_MAX_WEIGHT) / MAX_AP_LOAD; |
| 2181 | } |
| 2182 | #endif |
Kapil Gupta | b3a981b | 2016-06-26 13:36:51 +0530 | [diff] [blame] | 2183 | /* if CCA consideration is off in configuration, FW will send 50% for |
| 2184 | every channel which should be considered as it is */ |
| 2185 | if (ap_load) |
| 2186 | score += (100 - ap_load) * CCA_WEIGHTAGE; |
| 2187 | else |
| 2188 | score += (100 - cca) * CCA_WEIGHTAGE; |
| 2189 | |
| 2190 | channel_weight = GetPERRoamRssiCountWeight(best_rssi, ap_cnt); |
| 2191 | |
| 2192 | score += channel_weight * OTHER_AP_WEIGHT; |
| 2193 | |
| 2194 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_LOW, |
| 2195 | FL("rssi=%d normalized_rssi=%d htcaps=%d vht=%d bw=%d channel=%d wmm=%d beamforming=%d ap_load=%d channel_weight=%d"), |
| 2196 | bssInfo->rssi, normalised_rssi, bssInfo->HTCapsPresent, |
| 2197 | bssInfo->vhtCapsPresent, bssInfo->chanWidth, |
| 2198 | bssInfo->channelId, bssInfo->wmeInfoPresent, |
| 2199 | bssInfo->beacomformingCapable, ap_load, channel_weight); |
| 2200 | return score; |
| 2201 | } |
| 2202 | |
| 2203 | /* Calculate candidate AP score for PER based roaming */ |
| 2204 | static tANI_S32 csrFindCongestionScore (tpAniSirGlobal pMac, tCsrScanResult *pBss) |
| 2205 | { |
| 2206 | tANI_S32 score = 0; |
| 2207 | tANI_S32 i; |
| 2208 | tANI_S32 candidateApCnt, best_rssi, other_ap_cnt; |
| 2209 | tANI_U32 current_timestamp; |
| 2210 | tpCsrNeighborRoamControlInfo pNeighborRoamInfo = |
| 2211 | &pMac->roam.neighborRoamInfo; |
| 2212 | |
| 2213 | tSirBssDescription *bssInfo = &(pBss->Result.BssDescriptor); |
| 2214 | pBss->congestionScore = 0; |
| 2215 | for (i = 0; i < pMac->PERroamCandidatesCnt; i++) |
| 2216 | if (pMac->candidateChannelInfo[i].channelNumber == |
| 2217 | pBss->Result.BssDescriptor.channelId) |
| 2218 | break; |
| 2219 | |
| 2220 | if (i == SIR_PER_ROAM_MAX_CANDIDATE_CNT) { |
| 2221 | smsLog(pMac, LOGE, |
| 2222 | FL("candidate chan info not found for channel %d bssid " |
| 2223 | MAC_ADDRESS_STR), pBss->Result.BssDescriptor.channelId, |
| 2224 | MAC_ADDR_ARRAY(pBss->Result.BssDescriptor.bssId)); |
| 2225 | return -1; |
| 2226 | } |
| 2227 | |
Kapil Gupta | 192d9d4 | 2016-11-25 16:24:13 +0530 | [diff] [blame] | 2228 | if (bssInfo->rssi < pMac->roam.configParam.PERMinRssiThresholdForRoam) { |
Kapil Gupta | a040e77 | 2016-09-15 19:03:45 +0530 | [diff] [blame] | 2229 | smsLog(pMac, LOG1, |
Kapil Gupta | e2b5c09 | 2017-02-06 15:04:47 +0530 | [diff] [blame] | 2230 | FL("discarding candidate due to low rssi=%d than %d, bssid " |
Kapil Gupta | a040e77 | 2016-09-15 19:03:45 +0530 | [diff] [blame] | 2231 | MAC_ADDRESS_STR), bssInfo->rssi, |
Kapil Gupta | e2b5c09 | 2017-02-06 15:04:47 +0530 | [diff] [blame] | 2232 | pMac->roam.configParam.PERMinRssiThresholdForRoam, |
Kapil Gupta | a040e77 | 2016-09-15 19:03:45 +0530 | [diff] [blame] | 2233 | MAC_ADDR_ARRAY(pBss->Result.BssDescriptor.bssId)); |
| 2234 | return 0; |
| 2235 | } |
Kapil Gupta | b3a981b | 2016-06-26 13:36:51 +0530 | [diff] [blame] | 2236 | /* find best RSSI of other AP in this channel */ |
| 2237 | best_rssi = MIN_RSSI; |
| 2238 | for (other_ap_cnt = 0; other_ap_cnt < |
| 2239 | pMac->candidateChannelInfo[i].otherApCount; other_ap_cnt++) { |
| 2240 | if (pMac->candidateChannelInfo[i].otherApRssi[other_ap_cnt] > best_rssi) |
| 2241 | best_rssi = pMac->candidateChannelInfo[i].otherApRssi[other_ap_cnt]; |
| 2242 | } |
| 2243 | |
| 2244 | score = calculateBssScore(bssInfo, best_rssi, |
| 2245 | pMac->candidateChannelInfo[i].otherApCount, |
| 2246 | pMac->candidateChannelInfo[i].channelCCA); |
| 2247 | current_timestamp = jiffies_to_msecs(jiffies); |
| 2248 | |
| 2249 | /* penalty logic */ |
| 2250 | |
| 2251 | /* In the previous list */ |
| 2252 | for (candidateApCnt = 0; candidateApCnt < |
| 2253 | SIR_PER_ROAM_MAX_CANDIDATE_CNT; candidateApCnt++) { |
| 2254 | if (sirCompareMacAddr(pMac->previousRoamApInfo[candidateApCnt].bssAddr, |
| 2255 | pBss->Result.BssDescriptor.bssId) && |
| 2256 | ((current_timestamp - pMac->previousRoamApInfo[candidateApCnt].timeStamp) < |
| 2257 | PENALTY_TIMEOUT)) { |
| 2258 | score = (score * PENALTY_REMAINING_SCORE)/PENALTY_TOTAL_SCORE; |
| 2259 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, |
| 2260 | FL("AP BSSID " MAC_ADDRESS_STR "adding penalty(in previous list)new score %d"), |
| 2261 | MAC_ADDR_ARRAY(pBss->Result.BssDescriptor.bssId), |
| 2262 | score); |
| 2263 | break; |
| 2264 | } |
| 2265 | } |
| 2266 | /* preauth failed last time */ |
| 2267 | for (candidateApCnt = 0; candidateApCnt < |
| 2268 | MAX_NUM_PREAUTH_FAIL_LIST_ADDRESS; candidateApCnt++) { |
| 2269 | if (sirCompareMacAddr(pNeighborRoamInfo->FTRoamInfo. |
| 2270 | preAuthFailList.macAddress[candidateApCnt], |
| 2271 | pBss->Result.BssDescriptor.bssId)) { |
| 2272 | score = (score * PENALTY_REMAINING_SCORE)/PENALTY_TOTAL_SCORE; |
| 2273 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, |
| 2274 | FL("AP BSSID " MAC_ADDRESS_STR "adding penalty(previously auth failed)new score %d"), |
| 2275 | MAC_ADDR_ARRAY(pBss->Result.BssDescriptor.bssId), |
| 2276 | score); |
| 2277 | break; |
| 2278 | } |
| 2279 | } |
| 2280 | pBss->congestionScore = score; |
| 2281 | |
| 2282 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, |
| 2283 | FL("AP BSSID " MAC_ADDRESS_STR " score %d channel %d"), |
| 2284 | MAC_ADDR_ARRAY(pBss->Result.BssDescriptor.bssId), |
| 2285 | score, pBss->Result.BssDescriptor.channelId); |
| 2286 | return 0; |
| 2287 | } |
| 2288 | |
| 2289 | /* Calculate current AP score for PER based roaming */ |
| 2290 | static tANI_S32 csrFindSelfCongestionScore(tpAniSirGlobal pMac, |
| 2291 | tSirBssDescription *bssInfo) |
| 2292 | { |
| 2293 | tANI_S32 i, best_rssi, other_ap_cnt; |
| 2294 | tANI_S32 score = 0; |
Kapil Gupta | c6ac477 | 2016-08-05 20:25:16 +0530 | [diff] [blame] | 2295 | tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, |
| 2296 | pMac->roam.roamSession->sessionId); |
| 2297 | |
| 2298 | if (pSession == NULL) |
| 2299 | return -1; |
Kapil Gupta | b3a981b | 2016-06-26 13:36:51 +0530 | [diff] [blame] | 2300 | |
Kapil Gupta | c3c4826 | 2017-03-09 18:05:51 +0530 | [diff] [blame] | 2301 | if (bssInfo->rssi < pMac->roam.configParam.PERMinRssiThresholdForRoam) { |
| 2302 | smsLog(pMac, LOG1, |
| 2303 | FL("Current AP has low rssi=%d than %d"), bssInfo->rssi, |
| 2304 | pMac->roam.configParam.PERMinRssiThresholdForRoam); |
| 2305 | /* |
| 2306 | * Make Current candidate score as zero which will cause roaming |
| 2307 | * in low RSSI scenarios |
| 2308 | */ |
| 2309 | pMac->currentBssScore = 0; |
| 2310 | return 0; |
| 2311 | } |
| 2312 | |
Kapil Gupta | b3a981b | 2016-06-26 13:36:51 +0530 | [diff] [blame] | 2313 | for (i = 0; i <= pMac->PERroamCandidatesCnt; i++) |
| 2314 | if (pMac->candidateChannelInfo[i].channelNumber == bssInfo->channelId) |
| 2315 | break; |
| 2316 | if (i > pMac->PERroamCandidatesCnt) { |
| 2317 | /* home channel info is not present, no need to roam */ |
| 2318 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, |
| 2319 | FL("home channel %d congestion info not present"), |
| 2320 | bssInfo->channelId); |
| 2321 | pMac->currentBssScore = PER_ROAM_MAX_BSS_SCORE; |
| 2322 | return -1; |
| 2323 | } |
| 2324 | |
| 2325 | /* find best RSSI of other AP in this channel */ |
| 2326 | best_rssi = MIN_RSSI; |
| 2327 | for (other_ap_cnt = 0; other_ap_cnt < |
| 2328 | pMac->candidateChannelInfo[i].otherApCount; other_ap_cnt++) { |
| 2329 | if (pMac->candidateChannelInfo[i].otherApRssi[other_ap_cnt] > best_rssi) |
| 2330 | best_rssi = pMac->candidateChannelInfo[i].otherApRssi[other_ap_cnt]; |
| 2331 | } |
| 2332 | |
Kapil Gupta | c6ac477 | 2016-08-05 20:25:16 +0530 | [diff] [blame] | 2333 | /* update latest RSSI for current AP */ |
| 2334 | WLANTL_GetRssi(vos_get_global_context(VOS_MODULE_ID_SME, NULL), |
| 2335 | pSession->connectedInfo.staId, |
| 2336 | &bssInfo->rssi); |
| 2337 | |
Kapil Gupta | b3a981b | 2016-06-26 13:36:51 +0530 | [diff] [blame] | 2338 | score = calculateBssScore(bssInfo, best_rssi, |
| 2339 | pMac->candidateChannelInfo[i].otherApCount, |
| 2340 | pMac->candidateChannelInfo[i].channelCCA); |
| 2341 | pMac->currentBssScore = score; |
| 2342 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, |
| 2343 | FL("PER Roam Current AP score %d channel %d"), |
| 2344 | score, bssInfo->channelId); |
| 2345 | return 0; |
| 2346 | } |
| 2347 | |
Kapil Gupta | b79e76f | 2016-09-12 20:04:37 +0530 | [diff] [blame] | 2348 | |
Kapil Gupta | b3a981b | 2016-06-26 13:36:51 +0530 | [diff] [blame] | 2349 | static tANI_BOOLEAN csrIsBetterBssInCongestion(tCsrScanResult *pBss1, |
| 2350 | tCsrScanResult *pBss2) |
| 2351 | { |
| 2352 | tANI_BOOLEAN ret; |
| 2353 | |
| 2354 | if(CSR_IS_BETTER_PREFER_VALUE(pBss1->congestionScore, |
| 2355 | pBss2->congestionScore)) |
| 2356 | ret = eANI_BOOLEAN_TRUE; |
| 2357 | else |
| 2358 | ret = eANI_BOOLEAN_FALSE; |
| 2359 | |
| 2360 | return (ret); |
| 2361 | } |
| 2362 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2363 | |
| 2364 | //To check whther pBss1 is better than pBss2 |
| 2365 | static tANI_BOOLEAN csrIsBetterBss(tCsrScanResult *pBss1, tCsrScanResult *pBss2) |
| 2366 | { |
| 2367 | tANI_BOOLEAN ret; |
| 2368 | |
| 2369 | if(CSR_IS_BETTER_PREFER_VALUE(pBss1->preferValue, pBss2->preferValue)) |
| 2370 | { |
| 2371 | ret = eANI_BOOLEAN_TRUE; |
| 2372 | } |
| 2373 | else if(CSR_IS_EQUAL_PREFER_VALUE(pBss1->preferValue, pBss2->preferValue)) |
| 2374 | { |
| 2375 | if(CSR_IS_BETTER_CAP_VALUE(pBss1->capValue, pBss2->capValue)) |
| 2376 | { |
| 2377 | ret = eANI_BOOLEAN_TRUE; |
| 2378 | } |
| 2379 | else |
| 2380 | { |
| 2381 | ret = eANI_BOOLEAN_FALSE; |
| 2382 | } |
| 2383 | } |
| 2384 | else |
| 2385 | { |
| 2386 | ret = eANI_BOOLEAN_FALSE; |
| 2387 | } |
| 2388 | |
| 2389 | return (ret); |
| 2390 | } |
| 2391 | |
| 2392 | |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 2393 | #ifdef FEATURE_WLAN_LFR |
Madan Mohan Koyyalamudi | 470d2cf | 2012-09-28 14:43:44 -0700 | [diff] [blame] | 2394 | //Add the channel to the occupiedChannels array |
| 2395 | static void csrScanAddToOccupiedChannels( |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 2396 | tpAniSirGlobal pMac, |
| 2397 | tCsrScanResult *pResult, |
| 2398 | tCsrChannel *pOccupiedChannels, |
Madan Mohan Koyyalamudi | 470d2cf | 2012-09-28 14:43:44 -0700 | [diff] [blame] | 2399 | tDot11fBeaconIEs *pIes) |
| 2400 | { |
| 2401 | eHalStatus status; |
| 2402 | tANI_U8 channel; |
| 2403 | tANI_U8 numOccupiedChannels = pOccupiedChannels->numChannels; |
| 2404 | tANI_U8 *pOccupiedChannelList = pOccupiedChannels->channelList; |
| 2405 | |
| 2406 | channel = pResult->Result.BssDescriptor.channelId; |
| 2407 | |
| 2408 | if (!csrIsChannelPresentInList(pOccupiedChannelList, numOccupiedChannels, channel) |
Madan Mohan Koyyalamudi | dd3c966 | 2012-11-09 17:39:30 -0800 | [diff] [blame] | 2409 | && csrNeighborRoamConnectedProfileMatch(pMac, pResult, pIes)) |
Madan Mohan Koyyalamudi | 470d2cf | 2012-09-28 14:43:44 -0700 | [diff] [blame] | 2410 | { |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 2411 | status = csrAddToChannelListFront(pOccupiedChannelList, numOccupiedChannels, channel); |
Madan Mohan Koyyalamudi | 470d2cf | 2012-09-28 14:43:44 -0700 | [diff] [blame] | 2412 | if(HAL_STATUS_SUCCESS(status)) |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 2413 | { |
Madan Mohan Koyyalamudi | 470d2cf | 2012-09-28 14:43:44 -0700 | [diff] [blame] | 2414 | pOccupiedChannels->numChannels++; |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 2415 | 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] | 2416 | __func__, channel, pOccupiedChannels->numChannels); |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 2417 | if (pOccupiedChannels->numChannels > CSR_BG_SCAN_OCCUPIED_CHANNEL_LIST_LEN) |
| 2418 | pOccupiedChannels->numChannels = CSR_BG_SCAN_OCCUPIED_CHANNEL_LIST_LEN; |
| 2419 | } |
Madan Mohan Koyyalamudi | 470d2cf | 2012-09-28 14:43:44 -0700 | [diff] [blame] | 2420 | } |
| 2421 | } |
Mukul Sharma | 9e4e0f9 | 2015-02-13 18:45:20 +0530 | [diff] [blame] | 2422 | |
| 2423 | void csrAddChannelToOccupiedChannelList(tpAniSirGlobal pMac, |
| 2424 | tANI_U8 channel) |
| 2425 | { |
| 2426 | eHalStatus status; |
| 2427 | tCsrChannel *pOccupiedChannels = &pMac->scan.occupiedChannels; |
| 2428 | tANI_U8 numOccupiedChannels = pOccupiedChannels->numChannels; |
| 2429 | tANI_U8 *pOccupiedChannelList = pOccupiedChannels->channelList; |
| 2430 | if (!csrIsChannelPresentInList(pOccupiedChannelList, |
| 2431 | numOccupiedChannels, channel)) |
| 2432 | { |
| 2433 | status = csrAddToChannelListFront(pOccupiedChannelList, |
| 2434 | numOccupiedChannels, channel); |
| 2435 | if(HAL_STATUS_SUCCESS(status)) |
| 2436 | { |
| 2437 | pOccupiedChannels->numChannels++; |
| 2438 | smsLog(pMac, LOG2, FL("added channel %d to the list (count=%d)"), |
| 2439 | channel, pOccupiedChannels->numChannels); |
| 2440 | if (pOccupiedChannels->numChannels > |
| 2441 | CSR_BG_SCAN_OCCUPIED_CHANNEL_LIST_LEN) |
| 2442 | { |
| 2443 | pOccupiedChannels->numChannels = |
| 2444 | CSR_BG_SCAN_OCCUPIED_CHANNEL_LIST_LEN; |
| 2445 | smsLog(pMac, LOG2, |
| 2446 | FL("trim no of Channels for Occ channel list")); |
| 2447 | } |
| 2448 | } |
| 2449 | } |
| 2450 | } |
Madan Mohan Koyyalamudi | 470d2cf | 2012-09-28 14:43:44 -0700 | [diff] [blame] | 2451 | #endif |
| 2452 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2453 | //Put the BSS into the scan result list |
| 2454 | //pIes can not be NULL |
| 2455 | static void csrScanAddResult(tpAniSirGlobal pMac, tCsrScanResult *pResult, tDot11fBeaconIEs *pIes) |
| 2456 | { |
Srinivas | 28b5b4e | 2012-12-12 13:07:53 -0800 | [diff] [blame] | 2457 | #ifdef FEATURE_WLAN_LFR |
| 2458 | tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo; |
| 2459 | #endif |
| 2460 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2461 | pResult->preferValue = csrGetBssPreferValue(pMac, (int)pResult->Result.BssDescriptor.rssi); |
| 2462 | pResult->capValue = csrGetBssCapValue(pMac, &pResult->Result.BssDescriptor, pIes); |
| 2463 | csrLLInsertTail( &pMac->scan.scanResultList, &pResult->Link, LL_ACCESS_LOCK ); |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 2464 | #ifdef FEATURE_WLAN_LFR |
Srinivas | 28b5b4e | 2012-12-12 13:07:53 -0800 | [diff] [blame] | 2465 | if(0 == pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels) |
| 2466 | { |
| 2467 | /* Build the occupied channel list, only if "gNeighborScanChannelList" is |
| 2468 | NOT set in the cfg.ini file */ |
| 2469 | csrScanAddToOccupiedChannels(pMac, pResult, &pMac->scan.occupiedChannels, pIes); |
| 2470 | } |
Madan Mohan Koyyalamudi | 470d2cf | 2012-09-28 14:43:44 -0700 | [diff] [blame] | 2471 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2472 | } |
| 2473 | |
| 2474 | |
| 2475 | eHalStatus csrScanGetResult(tpAniSirGlobal pMac, tCsrScanResultFilter *pFilter, tScanResultHandle *phResult) |
| 2476 | { |
| 2477 | eHalStatus status; |
| 2478 | tScanResultList *pRetList; |
| 2479 | tCsrScanResult *pResult, *pBssDesc; |
| 2480 | tANI_U32 count = 0; |
| 2481 | tListElem *pEntry; |
| 2482 | tANI_U32 bssLen, allocLen; |
| 2483 | eCsrEncryptionType uc = eCSR_ENCRYPT_TYPE_NONE, mc = eCSR_ENCRYPT_TYPE_NONE; |
| 2484 | eCsrAuthType auth = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 2485 | tDot11fBeaconIEs *pIes, *pNewIes; |
| 2486 | tANI_BOOLEAN fMatch; |
Srinivas Girigowda | 8e7e105 | 2013-11-13 18:53:14 -0800 | [diff] [blame] | 2487 | tANI_U16 i = 0; |
Kapil Gupta | b3a981b | 2016-06-26 13:36:51 +0530 | [diff] [blame] | 2488 | tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, |
| 2489 | pMac->roam.roamSession->sessionId); |
| 2490 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2491 | if(phResult) |
| 2492 | { |
| 2493 | *phResult = CSR_INVALID_SCANRESULT_HANDLE; |
| 2494 | } |
Srinivas Girigowda | 41c7c5f | 2013-10-21 19:01:38 -0700 | [diff] [blame] | 2495 | |
| 2496 | if (pMac->roam.configParam.nSelect5GHzMargin) |
| 2497 | { |
| 2498 | pMac->scan.inScanResultBestAPRssi = -128; |
| 2499 | csrLLLock(&pMac->scan.scanResultList); |
| 2500 | |
| 2501 | /* Find out the best AP Rssi going thru the scan results */ |
| 2502 | pEntry = csrLLPeekHead(&pMac->scan.scanResultList, LL_ACCESS_NOLOCK); |
| 2503 | while ( NULL != pEntry) |
| 2504 | { |
| 2505 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
Srinivas Girigowda | 8e7e105 | 2013-11-13 18:53:14 -0800 | [diff] [blame] | 2506 | fMatch = FALSE; |
| 2507 | |
| 2508 | if (pFilter) |
| 2509 | for(i = 0; i < pFilter->SSIDs.numOfSSIDs; i++) |
Srinivas Girigowda | 41c7c5f | 2013-10-21 19:01:38 -0700 | [diff] [blame] | 2510 | { |
Srinivas Girigowda | 8e7e105 | 2013-11-13 18:53:14 -0800 | [diff] [blame] | 2511 | fMatch = csrIsSsidMatch( pMac, pFilter->SSIDs.SSIDList[i].SSID.ssId, pFilter->SSIDs.SSIDList[i].SSID.length, |
| 2512 | pBssDesc->Result.ssId.ssId, |
| 2513 | pBssDesc->Result.ssId.length, eANI_BOOLEAN_TRUE ); |
| 2514 | if (fMatch) |
| 2515 | { |
| 2516 | pIes = (tDot11fBeaconIEs *)( pBssDesc->Result.pvIes ); |
| 2517 | |
| 2518 | //At this time, pBssDescription->Result.pvIes may be NULL |
| 2519 | if( !pIes && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, |
| 2520 | &pBssDesc->Result.BssDescriptor, &pIes))) ) |
| 2521 | { |
| 2522 | continue; |
| 2523 | } |
| 2524 | |
| 2525 | smsLog(pMac, LOG1, FL("SSID Matched")); |
Leela Venkata Kiran Kumar Reddy Chirala | e208a83 | 2014-04-27 22:34:25 -0700 | [diff] [blame] | 2526 | |
Leela Venkata Kiran Kumar Reddy Chirala | f257bef | 2014-04-11 18:48:12 -0700 | [diff] [blame] | 2527 | if ( pFilter->bOSENAssociation ) |
| 2528 | { |
| 2529 | fMatch = TRUE; |
| 2530 | } |
Leela Venkata Kiran Kumar Reddy Chirala | e208a83 | 2014-04-27 22:34:25 -0700 | [diff] [blame] | 2531 | else |
| 2532 | { |
Abhishek Singh | 658d4de | 2014-06-26 10:53:15 +0530 | [diff] [blame] | 2533 | #ifdef WLAN_FEATURE_11W |
Abhishek Singh | 3b56d3a | 2014-06-25 12:37:39 +0530 | [diff] [blame] | 2534 | fMatch = csrIsSecurityMatch(pMac, &pFilter->authType, |
| 2535 | &pFilter->EncryptionType, |
| 2536 | &pFilter->mcEncryptionType, |
| 2537 | &pFilter->MFPEnabled, |
| 2538 | &pFilter->MFPRequired, |
| 2539 | &pFilter->MFPCapable, |
| 2540 | &pBssDesc->Result.BssDescriptor, |
| 2541 | pIes, NULL, NULL, NULL ); |
Abhishek Singh | 658d4de | 2014-06-26 10:53:15 +0530 | [diff] [blame] | 2542 | #else |
| 2543 | fMatch = csrIsSecurityMatch(pMac, &pFilter->authType, |
| 2544 | &pFilter->EncryptionType, |
| 2545 | &pFilter->mcEncryptionType, |
| 2546 | NULL, NULL, NULL, |
| 2547 | &pBssDesc->Result.BssDescriptor, |
| 2548 | pIes, NULL, NULL, NULL ); |
| 2549 | #endif |
Leela Venkata Kiran Kumar Reddy Chirala | e208a83 | 2014-04-27 22:34:25 -0700 | [diff] [blame] | 2550 | } |
| 2551 | if ((pBssDesc->Result.pvIes == NULL) && pIes) |
| 2552 | vos_mem_free(pIes); |
Srinivas Girigowda | 8e7e105 | 2013-11-13 18:53:14 -0800 | [diff] [blame] | 2553 | |
| 2554 | if (fMatch) |
| 2555 | smsLog(pMac, LOG1, FL(" Security Matched")); |
| 2556 | } |
| 2557 | } |
| 2558 | |
| 2559 | if (fMatch && (pBssDesc->Result.BssDescriptor.rssi > pMac->scan.inScanResultBestAPRssi)) |
| 2560 | { |
| 2561 | smsLog(pMac, LOG1, FL("Best AP Rssi changed from %d to %d"), |
| 2562 | pMac->scan.inScanResultBestAPRssi, |
| 2563 | pBssDesc->Result.BssDescriptor.rssi); |
Srinivas Girigowda | 41c7c5f | 2013-10-21 19:01:38 -0700 | [diff] [blame] | 2564 | pMac->scan.inScanResultBestAPRssi = pBssDesc->Result.BssDescriptor.rssi; |
| 2565 | } |
| 2566 | pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK); |
| 2567 | } |
| 2568 | |
Srinivas Girigowda | 8e7e105 | 2013-11-13 18:53:14 -0800 | [diff] [blame] | 2569 | if ( -128 != pMac->scan.inScanResultBestAPRssi) |
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 | smsLog(pMac, LOG1, FL("Best AP Rssi is %d"), pMac->scan.inScanResultBestAPRssi); |
| 2572 | /* Modify Rssi category based on best AP Rssi */ |
| 2573 | csrAssignRssiForCategory(pMac, pMac->scan.inScanResultBestAPRssi, pMac->roam.configParam.bCatRssiOffset); |
| 2574 | pEntry = csrLLPeekHead(&pMac->scan.scanResultList, LL_ACCESS_NOLOCK); |
| 2575 | while ( NULL != pEntry) |
| 2576 | { |
| 2577 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
Srinivas Girigowda | 41c7c5f | 2013-10-21 19:01:38 -0700 | [diff] [blame] | 2578 | |
Srinivas Girigowda | 8e7e105 | 2013-11-13 18:53:14 -0800 | [diff] [blame] | 2579 | /* re-assign preference value based on modified rssi bucket */ |
| 2580 | pBssDesc->preferValue = csrGetBssPreferValue(pMac, (int)pBssDesc->Result.BssDescriptor.rssi); |
Srinivas Girigowda | 41c7c5f | 2013-10-21 19:01:38 -0700 | [diff] [blame] | 2581 | |
Arif Hussain | a7c8e41 | 2013-11-20 11:06:42 -0800 | [diff] [blame] | 2582 | smsLog(pMac, LOG2, FL("BSSID("MAC_ADDRESS_STR |
Jeff Johnson | 123ed00 | 2013-11-22 17:39:55 -0800 | [diff] [blame] | 2583 | ") Rssi(%d) Chnl(%d) PrefVal(%u) SSID=%.*s"), |
Arif Hussain | a7c8e41 | 2013-11-20 11:06:42 -0800 | [diff] [blame] | 2584 | MAC_ADDR_ARRAY(pBssDesc->Result.BssDescriptor.bssId), |
| 2585 | pBssDesc->Result.BssDescriptor.rssi, |
| 2586 | pBssDesc->Result.BssDescriptor.channelId, |
| 2587 | pBssDesc->preferValue, |
| 2588 | pBssDesc->Result.ssId.length, pBssDesc->Result.ssId.ssId); |
Srinivas Girigowda | 8e7e105 | 2013-11-13 18:53:14 -0800 | [diff] [blame] | 2589 | |
| 2590 | pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK); |
| 2591 | } |
Srinivas Girigowda | 41c7c5f | 2013-10-21 19:01:38 -0700 | [diff] [blame] | 2592 | } |
| 2593 | |
| 2594 | csrLLUnlock(&pMac->scan.scanResultList); |
| 2595 | } |
| 2596 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2597 | pRetList = vos_mem_malloc(sizeof(tScanResultList)); |
| 2598 | if ( NULL == pRetList ) |
| 2599 | status = eHAL_STATUS_FAILURE; |
| 2600 | else |
| 2601 | status = eHAL_STATUS_SUCCESS; |
Srinivas Girigowda | 41c7c5f | 2013-10-21 19:01:38 -0700 | [diff] [blame] | 2602 | if(HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2603 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2604 | vos_mem_set(pRetList, sizeof(tScanResultList), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2605 | csrLLOpen(pMac->hHdd, &pRetList->List); |
| 2606 | pRetList->pCurEntry = NULL; |
Kapil Gupta | b3a981b | 2016-06-26 13:36:51 +0530 | [diff] [blame] | 2607 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 2608 | if (pFilter && pFilter->isPERRoamScan) |
| 2609 | if (pSession && pSession->pConnectBssDesc) |
| 2610 | csrFindSelfCongestionScore(pMac, |
| 2611 | pSession->pConnectBssDesc); |
| 2612 | #endif |
| 2613 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2614 | csrLLLock(&pMac->scan.scanResultList); |
| 2615 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK ); |
| 2616 | while( pEntry ) |
| 2617 | { |
| 2618 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 2619 | pIes = (tDot11fBeaconIEs *)( pBssDesc->Result.pvIes ); |
| 2620 | //if pBssDesc->Result.pvIes is NULL, we need to free any memory allocated by csrMatchBSS |
| 2621 | //for any error condition, otherwiase, it will be freed later. |
| 2622 | //reset |
| 2623 | fMatch = eANI_BOOLEAN_FALSE; |
| 2624 | pNewIes = NULL; |
| 2625 | |
| 2626 | if(pFilter) |
| 2627 | { |
| 2628 | fMatch = csrMatchBSS(pMac, &pBssDesc->Result.BssDescriptor, pFilter, &auth, &uc, &mc, &pIes); |
| 2629 | if( NULL != pIes ) |
| 2630 | { |
| 2631 | //Only save it when matching |
| 2632 | if(fMatch) |
| 2633 | { |
| 2634 | if( !pBssDesc->Result.pvIes ) |
| 2635 | { |
| 2636 | //csrMatchBSS allocates the memory. Simply pass it and it is freed later |
| 2637 | pNewIes = pIes; |
| 2638 | } |
| 2639 | else |
| 2640 | { |
| 2641 | //The pIes is allocated by someone else. make a copy |
| 2642 | //Only to save parsed IEs if caller provides a filter. Most likely the caller |
| 2643 | //is using to for association, hence save the parsed IEs |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2644 | pNewIes = vos_mem_malloc(sizeof(tDot11fBeaconIEs)); |
| 2645 | if ( NULL == pNewIes ) |
| 2646 | status = eHAL_STATUS_FAILURE; |
| 2647 | else |
| 2648 | status = eHAL_STATUS_SUCCESS; |
| 2649 | if ( HAL_STATUS_SUCCESS( status ) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2650 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2651 | vos_mem_copy(pNewIes, pIes, sizeof( tDot11fBeaconIEs )); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2652 | } |
| 2653 | else |
| 2654 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 2655 | smsLog(pMac, LOGE, FL(" fail to allocate memory for IEs")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2656 | //Need to free memory allocated by csrMatchBSS |
| 2657 | 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 | break; |
| 2662 | } |
| 2663 | } |
| 2664 | }//fMatch |
| 2665 | else if( !pBssDesc->Result.pvIes ) |
| 2666 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2667 | vos_mem_free(pIes); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2668 | } |
| 2669 | } |
| 2670 | } |
| 2671 | if(NULL == pFilter || fMatch) |
| 2672 | { |
| 2673 | bssLen = pBssDesc->Result.BssDescriptor.length + sizeof(pBssDesc->Result.BssDescriptor.length); |
| 2674 | allocLen = sizeof( tCsrScanResult ) + bssLen; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2675 | pResult = vos_mem_malloc(allocLen); |
| 2676 | if ( NULL == pResult ) |
| 2677 | status = eHAL_STATUS_FAILURE; |
| 2678 | else |
| 2679 | status = eHAL_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2680 | if(!HAL_STATUS_SUCCESS(status)) |
| 2681 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 2682 | 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] | 2683 | if(pNewIes) |
| 2684 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2685 | vos_mem_free(pNewIes); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2686 | } |
| 2687 | break; |
| 2688 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2689 | vos_mem_set(pResult, allocLen, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2690 | pResult->capValue = pBssDesc->capValue; |
| 2691 | pResult->preferValue = pBssDesc->preferValue; |
| 2692 | pResult->ucEncryptionType = uc; |
| 2693 | pResult->mcEncryptionType = mc; |
| 2694 | pResult->authType = auth; |
| 2695 | pResult->Result.ssId = pBssDesc->Result.ssId; |
Padma, Santhosh Kumar | e12fd98 | 2016-03-21 13:07:52 +0530 | [diff] [blame] | 2696 | pResult->Result.timer = pBssDesc->Result.timer; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2697 | //save the pIes for later use |
| 2698 | pResult->Result.pvIes = pNewIes; |
| 2699 | //save bss description |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2700 | vos_mem_copy(&pResult->Result.BssDescriptor, |
| 2701 | &pBssDesc->Result.BssDescriptor, bssLen); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2702 | //No need to lock pRetList because it is locally allocated and no outside can access it at this time |
| 2703 | if(csrLLIsListEmpty(&pRetList->List, LL_ACCESS_NOLOCK)) |
| 2704 | { |
Kapil Gupta | b3a981b | 2016-06-26 13:36:51 +0530 | [diff] [blame] | 2705 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 2706 | if (pFilter && pFilter->isPERRoamScan) { |
| 2707 | csrFindCongestionScore(pMac, pResult); |
| 2708 | if (pResult->congestionScore > pMac->currentBssScore) { |
| 2709 | csrLLInsertTail(&pRetList->List, &pResult->Link, |
| 2710 | LL_ACCESS_NOLOCK); |
| 2711 | smsLog(pMac, LOGW, |
| 2712 | FL("added one entry in LL in PER Roam list")); |
| 2713 | } |
| 2714 | } |
| 2715 | else |
| 2716 | #endif |
| 2717 | { |
| 2718 | csrLLInsertTail(&pRetList->List, &pResult->Link, |
| 2719 | LL_ACCESS_NOLOCK); |
| 2720 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2721 | } |
Abhishek Singh | b3e376c | 2017-01-04 15:27:13 +0530 | [diff] [blame] | 2722 | /* bssid hint AP should be on head */ |
| 2723 | else if (pFilter && |
| 2724 | vos_mem_compare(pResult->Result.BssDescriptor.bssId, |
| 2725 | pFilter->bssid_hint, VOS_MAC_ADDR_SIZE)) |
| 2726 | { |
| 2727 | csrLLInsertHead(&pRetList->List, |
| 2728 | &pResult->Link, LL_ACCESS_NOLOCK); |
| 2729 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2730 | else |
| 2731 | { |
| 2732 | //To sort the list |
| 2733 | tListElem *pTmpEntry; |
| 2734 | tCsrScanResult *pTmpResult; |
| 2735 | |
| 2736 | pTmpEntry = csrLLPeekHead(&pRetList->List, LL_ACCESS_NOLOCK); |
| 2737 | while(pTmpEntry) |
| 2738 | { |
| 2739 | pTmpResult = GET_BASE_ADDR( pTmpEntry, tCsrScanResult, Link ); |
Abhishek Singh | b3e376c | 2017-01-04 15:27:13 +0530 | [diff] [blame] | 2740 | /* Skip the bssid hint AP, as it should be on head */ |
Abhishek Singh | 78f494b | 2017-01-24 10:07:08 +0530 | [diff] [blame] | 2741 | if (pFilter && vos_mem_compare( |
| 2742 | pTmpResult->Result.BssDescriptor.bssId, |
Abhishek Singh | b3e376c | 2017-01-04 15:27:13 +0530 | [diff] [blame] | 2743 | pFilter->bssid_hint, VOS_MAC_ADDR_SIZE)) { |
| 2744 | pTmpEntry = csrLLNext(&pRetList->List, |
| 2745 | pTmpEntry, LL_ACCESS_NOLOCK); |
| 2746 | continue; |
| 2747 | } |
Kapil Gupta | b3a981b | 2016-06-26 13:36:51 +0530 | [diff] [blame] | 2748 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 2749 | if (pFilter && pFilter->isPERRoamScan) { |
| 2750 | csrFindCongestionScore(pMac, pResult); |
| 2751 | if(csrIsBetterBssInCongestion(pResult, pTmpResult)&& |
| 2752 | (pResult->congestionScore > pMac->currentBssScore)) |
| 2753 | { |
| 2754 | csrLLInsertEntry(&pRetList->List, pTmpEntry, |
| 2755 | &pResult->Link, LL_ACCESS_NOLOCK); |
| 2756 | smsLog(pMac, LOGW, |
| 2757 | FL("added another entry in LL in PER Roam list")); |
| 2758 | pResult = NULL; |
| 2759 | break; |
| 2760 | } |
| 2761 | pTmpEntry = csrLLNext(&pRetList->List, |
| 2762 | pTmpEntry, LL_ACCESS_NOLOCK); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2763 | } |
Kapil Gupta | b3a981b | 2016-06-26 13:36:51 +0530 | [diff] [blame] | 2764 | else |
| 2765 | #endif |
| 2766 | { |
| 2767 | if(csrIsBetterBss(pResult, pTmpResult)) |
| 2768 | { |
| 2769 | csrLLInsertEntry(&pRetList->List, pTmpEntry, |
| 2770 | &pResult->Link, LL_ACCESS_NOLOCK); |
| 2771 | //To indicate we are done |
| 2772 | pResult = NULL; |
| 2773 | break; |
| 2774 | } |
| 2775 | pTmpEntry = csrLLNext(&pRetList->List, |
| 2776 | pTmpEntry, LL_ACCESS_NOLOCK); |
| 2777 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2778 | } |
| 2779 | if(pResult != NULL) |
Kapil Gupta | b3a981b | 2016-06-26 13:36:51 +0530 | [diff] [blame] | 2780 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 2781 | if ((pFilter && !pFilter->isPERRoamScan) || |
| 2782 | (pFilter == NULL) || |
| 2783 | (pResult->congestionScore > pMac->currentBssScore)) |
| 2784 | #endif |
| 2785 | { |
| 2786 | //This one is not better than any one |
| 2787 | csrLLInsertTail(&pRetList->List, |
| 2788 | &pResult->Link, LL_ACCESS_NOLOCK); |
| 2789 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2790 | } |
| 2791 | count++; |
| 2792 | } |
| 2793 | pEntry = csrLLNext( &pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK ); |
| 2794 | }//while |
| 2795 | csrLLUnlock(&pMac->scan.scanResultList); |
| 2796 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 2797 | smsLog(pMac, LOG2, FL("return %d BSS"), csrLLCount(&pRetList->List)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2798 | |
| 2799 | if( !HAL_STATUS_SUCCESS(status) || (phResult == NULL) ) |
| 2800 | { |
| 2801 | //Fail or No one wants the result. |
| 2802 | csrScanResultPurge(pMac, (tScanResultHandle)pRetList); |
| 2803 | } |
| 2804 | else |
| 2805 | { |
| 2806 | if(0 == count) |
| 2807 | { |
| 2808 | //We are here meaning the there is no match |
| 2809 | csrLLClose(&pRetList->List); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2810 | vos_mem_free(pRetList); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2811 | status = eHAL_STATUS_E_NULL_VALUE; |
Kapil Gupta | b3a981b | 2016-06-26 13:36:51 +0530 | [diff] [blame] | 2812 | smsLog(pMac, LOGW, |
| 2813 | FL("Nil scan results or no matching AP found")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2814 | } |
| 2815 | else if(phResult) |
| 2816 | { |
| 2817 | *phResult = pRetList; |
| 2818 | } |
| 2819 | } |
| 2820 | }//Allocated pRetList |
| 2821 | |
| 2822 | return (status); |
| 2823 | } |
| 2824 | |
Madan Mohan Koyyalamudi | ab41d0f | 2012-10-31 17:17:10 -0700 | [diff] [blame] | 2825 | /* |
| 2826 | * NOTE: This routine is being added to make |
| 2827 | * sure that scan results are not being flushed |
| 2828 | * while roaming. If the scan results are flushed, |
| 2829 | * we are unable to recover from |
| 2830 | * csrRoamRoamingStateDisassocRspProcessor. |
| 2831 | * If it is needed to remove this routine, |
| 2832 | * first ensure that we recover gracefully from |
| 2833 | * csrRoamRoamingStateDisassocRspProcessor if |
| 2834 | * csrScanGetResult returns with a failure because |
| 2835 | * of not being able to find the roaming BSS. |
| 2836 | */ |
| 2837 | tANI_U8 csrScanFlushDenied(tpAniSirGlobal pMac) |
| 2838 | { |
| 2839 | switch(pMac->roam.neighborRoamInfo.neighborRoamState) { |
| 2840 | case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN: |
| 2841 | case eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING: |
| 2842 | case eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE: |
| 2843 | case eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING: |
| 2844 | return (pMac->roam.neighborRoamInfo.neighborRoamState); |
| 2845 | default: |
| 2846 | return 0; |
| 2847 | } |
| 2848 | } |
| 2849 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2850 | eHalStatus csrScanFlushResult(tpAniSirGlobal pMac) |
| 2851 | { |
Madan Mohan Koyyalamudi | ab41d0f | 2012-10-31 17:17:10 -0700 | [diff] [blame] | 2852 | tANI_U8 isFlushDenied = csrScanFlushDenied(pMac); |
Srinivas, Dasari | 42bf770 | 2014-02-07 11:29:53 +0530 | [diff] [blame] | 2853 | eHalStatus status = eHAL_STATUS_SUCCESS; |
Madan Mohan Koyyalamudi | ab41d0f | 2012-10-31 17:17:10 -0700 | [diff] [blame] | 2854 | if (isFlushDenied) { |
| 2855 | smsLog(pMac, LOGW, "%s: scan flush denied in roam state %d", |
| 2856 | __func__, isFlushDenied); |
| 2857 | return eHAL_STATUS_FAILURE; |
| 2858 | } |
Srinivas, Dasari | 42bf770 | 2014-02-07 11:29:53 +0530 | [diff] [blame] | 2859 | csrLLScanPurgeResult( pMac, &pMac->scan.tempScanResults ); |
| 2860 | csrLLScanPurgeResult( pMac, &pMac->scan.scanResultList ); |
| 2861 | return( status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2862 | } |
| 2863 | |
Mukul Sharma | 20aa658 | 2014-08-07 21:36:12 +0530 | [diff] [blame] | 2864 | eHalStatus csrScanFlushSelectiveResultForBand(tpAniSirGlobal pMac, v_BOOL_t flushP2P, tSirRFBand band) |
| 2865 | { |
| 2866 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2867 | tListElem *pEntry,*pFreeElem; |
| 2868 | tCsrScanResult *pBssDesc; |
| 2869 | tDblLinkList *pList = &pMac->scan.scanResultList; |
| 2870 | |
| 2871 | csrLLLock(pList); |
| 2872 | |
| 2873 | pEntry = csrLLPeekHead( pList, LL_ACCESS_NOLOCK ); |
| 2874 | while( pEntry != NULL) |
| 2875 | { |
| 2876 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 2877 | if( (flushP2P == vos_mem_compare( pBssDesc->Result.ssId.ssId, |
| 2878 | "DIRECT-", 7)) && |
| 2879 | (GetRFBand(pBssDesc->Result.BssDescriptor.channelId) == band) |
| 2880 | ) |
| 2881 | { |
| 2882 | pFreeElem = pEntry; |
| 2883 | pEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK); |
| 2884 | csrLLRemoveEntry(pList, pFreeElem, LL_ACCESS_NOLOCK); |
| 2885 | csrFreeScanResultEntry( pMac, pBssDesc ); |
| 2886 | continue; |
| 2887 | } |
| 2888 | pEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK); |
| 2889 | } |
| 2890 | |
| 2891 | csrLLUnlock(pList); |
| 2892 | |
| 2893 | return (status); |
| 2894 | } |
| 2895 | |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2896 | eHalStatus csrScanFlushSelectiveResult(tpAniSirGlobal pMac, v_BOOL_t flushP2P) |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2897 | { |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2898 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2899 | tListElem *pEntry,*pFreeElem; |
| 2900 | tCsrScanResult *pBssDesc; |
| 2901 | tDblLinkList *pList = &pMac->scan.scanResultList; |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2902 | |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2903 | csrLLLock(pList); |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2904 | |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2905 | pEntry = csrLLPeekHead( pList, LL_ACCESS_NOLOCK ); |
| 2906 | while( pEntry != NULL) |
| 2907 | { |
| 2908 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 2909 | if( flushP2P == vos_mem_compare( pBssDesc->Result.ssId.ssId, |
| 2910 | "DIRECT-", 7) ) |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2911 | { |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2912 | pFreeElem = pEntry; |
| 2913 | pEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK); |
| 2914 | csrLLRemoveEntry(pList, pFreeElem, LL_ACCESS_NOLOCK); |
| 2915 | csrFreeScanResultEntry( pMac, pBssDesc ); |
| 2916 | continue; |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2917 | } |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2918 | pEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK); |
| 2919 | } |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2920 | |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2921 | csrLLUnlock(pList); |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2922 | |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2923 | return (status); |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2924 | } |
| 2925 | |
Padma, Santhosh Kumar | 0eeb775 | 2018-07-04 18:52:27 +0530 | [diff] [blame] | 2926 | eHalStatus csrScanFlushSelectiveSsid(tpAniSirGlobal pMac, tANI_U8 *ssId, |
| 2927 | tANI_U8 ssIdLen) |
| 2928 | { |
| 2929 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2930 | tListElem *pEntry,*pFreeElem; |
| 2931 | tCsrScanResult *pBssDesc; |
| 2932 | tDblLinkList *pList = &pMac->scan.scanResultList; |
| 2933 | |
| 2934 | csrLLLock(pList); |
| 2935 | |
| 2936 | pEntry = csrLLPeekHead( pList, LL_ACCESS_NOLOCK ); |
| 2937 | while( pEntry != NULL) |
| 2938 | { |
| 2939 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 2940 | if(vos_mem_compare(pBssDesc->Result.ssId.ssId, |
| 2941 | ssId, ssIdLen) ) |
| 2942 | { |
| 2943 | pFreeElem = pEntry; |
| 2944 | pEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK); |
| 2945 | csrLLRemoveEntry(pList, pFreeElem, LL_ACCESS_NOLOCK); |
| 2946 | csrFreeScanResultEntry( pMac, pBssDesc ); |
| 2947 | continue; |
| 2948 | } |
| 2949 | pEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK); |
| 2950 | } |
| 2951 | |
| 2952 | csrLLUnlock(pList); |
| 2953 | |
| 2954 | return (status); |
| 2955 | } |
| 2956 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2957 | /** |
| 2958 | * csrCheck11dChannel |
| 2959 | * |
| 2960 | *FUNCTION: |
Srinivas, Dasari | 42bf770 | 2014-02-07 11:29:53 +0530 | [diff] [blame] | 2961 | * This function is called from csrScanFilterResults function and |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2962 | * compare channel number with given channel list. |
| 2963 | * |
| 2964 | *LOGIC: |
| 2965 | * Check Scan result channel number with CFG channel list |
| 2966 | * |
| 2967 | *ASSUMPTIONS: |
| 2968 | * |
| 2969 | * |
| 2970 | *NOTE: |
| 2971 | * |
| 2972 | * @param channelId channel number |
| 2973 | * @param pChannelList Pointer to channel list |
| 2974 | * @param numChannels Number of channel in channel list |
| 2975 | * |
| 2976 | * @return Status |
| 2977 | */ |
| 2978 | |
| 2979 | eHalStatus csrCheck11dChannel(tANI_U8 channelId, tANI_U8 *pChannelList, tANI_U32 numChannels) |
| 2980 | { |
| 2981 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 2982 | tANI_U8 i = 0; |
| 2983 | |
| 2984 | for (i = 0; i < numChannels; i++) |
| 2985 | { |
| 2986 | if(pChannelList[ i ] == channelId) |
| 2987 | { |
| 2988 | status = eHAL_STATUS_SUCCESS; |
| 2989 | break; |
| 2990 | } |
| 2991 | } |
| 2992 | return status; |
| 2993 | } |
| 2994 | |
| 2995 | /** |
Srinivas, Dasari | 42bf770 | 2014-02-07 11:29:53 +0530 | [diff] [blame] | 2996 | * csrScanFilterResults |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2997 | * |
| 2998 | *FUNCTION: |
| 2999 | * This function is called from csrApplyCountryInformation function and |
| 3000 | * filter scan result based on valid channel list number. |
| 3001 | * |
| 3002 | *LOGIC: |
| 3003 | * Get scan result from scan list and Check Scan result channel number |
| 3004 | * with 11d channel list if channel number is found in 11d channel list |
| 3005 | * then do not remove scan result entry from scan list |
| 3006 | * |
| 3007 | *ASSUMPTIONS: |
| 3008 | * |
| 3009 | * |
| 3010 | *NOTE: |
| 3011 | * |
| 3012 | * @param pMac Pointer to Global MAC structure |
| 3013 | * |
| 3014 | * @return Status |
| 3015 | */ |
| 3016 | |
Srinivas, Dasari | 42bf770 | 2014-02-07 11:29:53 +0530 | [diff] [blame] | 3017 | eHalStatus csrScanFilterResults(tpAniSirGlobal pMac) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3018 | { |
| 3019 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 3020 | tListElem *pEntry,*pTempEntry; |
| 3021 | tCsrScanResult *pBssDesc; |
| 3022 | tANI_U32 len = sizeof(pMac->roam.validChannelList); |
| 3023 | |
| 3024 | /* Get valid channels list from CFG */ |
| 3025 | if (!HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, |
| 3026 | pMac->roam.validChannelList, &len))) |
| 3027 | { |
Agarwal Ashish | e3cca2a | 2013-07-21 03:01:48 +0530 | [diff] [blame] | 3028 | smsLog( pMac, LOGE, "Failed to get Channel list from CFG"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3029 | } |
| 3030 | |
| 3031 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_LOCK ); |
| 3032 | while( pEntry ) |
| 3033 | { |
| 3034 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
Srinivas, Dasari | 42bf770 | 2014-02-07 11:29:53 +0530 | [diff] [blame] | 3035 | pTempEntry = csrLLNext( &pMac->scan.scanResultList, pEntry, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3036 | LL_ACCESS_LOCK ); |
| 3037 | if(csrCheck11dChannel(pBssDesc->Result.BssDescriptor.channelId, |
Srinivas, Dasari | 42bf770 | 2014-02-07 11:29:53 +0530 | [diff] [blame] | 3038 | pMac->roam.validChannelList, len)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3039 | { |
| 3040 | /* Remove Scan result which does not have 11d channel */ |
| 3041 | if( csrLLRemoveEntry( &pMac->scan.scanResultList, pEntry, |
| 3042 | LL_ACCESS_LOCK )) |
| 3043 | { |
| 3044 | csrFreeScanResultEntry( pMac, pBssDesc ); |
| 3045 | } |
| 3046 | } |
Srinivas, Dasari | 42bf770 | 2014-02-07 11:29:53 +0530 | [diff] [blame] | 3047 | pEntry = pTempEntry; |
| 3048 | } |
| 3049 | |
| 3050 | pEntry = csrLLPeekHead( &pMac->scan.tempScanResults, LL_ACCESS_LOCK ); |
| 3051 | while( pEntry ) |
| 3052 | { |
| 3053 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 3054 | pTempEntry = csrLLNext( &pMac->scan.tempScanResults, pEntry, |
| 3055 | LL_ACCESS_LOCK ); |
| 3056 | if(csrCheck11dChannel(pBssDesc->Result.BssDescriptor.channelId, |
| 3057 | pMac->roam.validChannelList, len)) |
| 3058 | { |
| 3059 | /* Remove Scan result which does not have 11d channel */ |
| 3060 | if( csrLLRemoveEntry( &pMac->scan.tempScanResults, pEntry, |
| 3061 | LL_ACCESS_LOCK )) |
| 3062 | { |
| 3063 | csrFreeScanResultEntry( pMac, pBssDesc ); |
| 3064 | } |
| 3065 | } |
| 3066 | else |
| 3067 | { |
| 3068 | smsLog( pMac, LOG1, FL("%d is a Valid channel"), |
| 3069 | pBssDesc->Result.BssDescriptor.channelId); |
| 3070 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3071 | pEntry = pTempEntry; |
| 3072 | } |
| 3073 | return status; |
| 3074 | } |
| 3075 | |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 3076 | /** |
| 3077 | * csrScanFilterDFSResults |
| 3078 | * |
| 3079 | *FUNCTION: |
| 3080 | * This function filter BSSIDs on DFS channels from the scan results. |
| 3081 | * |
| 3082 | *LOGIC: |
| 3083 | * Get scan result from scan list and Check Scan result channel number |
| 3084 | * with 11d channel list if channel number is found in 11d channel list |
| 3085 | * and if fEnableDFSChnlScan is zero and if channel is DFS, then |
| 3086 | * remove scan result entry from scan list |
| 3087 | * |
| 3088 | *ASSUMPTIONS: |
| 3089 | * |
| 3090 | *NOTE: |
| 3091 | * |
| 3092 | * @param pMac Pointer to Global MAC structure |
| 3093 | * |
| 3094 | * @return Status |
| 3095 | */ |
| 3096 | |
| 3097 | eHalStatus csrScanFilterDFSResults(tpAniSirGlobal pMac) |
| 3098 | { |
| 3099 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 3100 | tListElem *pEntry,*pTempEntry; |
| 3101 | tCsrScanResult *pBssDesc; |
| 3102 | |
| 3103 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_LOCK ); |
| 3104 | while( pEntry ) |
| 3105 | { |
| 3106 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 3107 | pTempEntry = csrLLNext( &pMac->scan.scanResultList, pEntry, |
| 3108 | LL_ACCESS_LOCK ); |
| 3109 | if((pMac->scan.fEnableDFSChnlScan == DFS_CHNL_SCAN_DISABLED) && |
| 3110 | CSR_IS_CHANNEL_DFS(pBssDesc->Result.BssDescriptor.channelId)) |
| 3111 | { |
| 3112 | smsLog( pMac, LOG1, FL("%d is a DFS ch filtered from scan list"), |
| 3113 | pBssDesc->Result.BssDescriptor.channelId); |
| 3114 | /* Remove Scan result which does not have 11d channel */ |
| 3115 | if( csrLLRemoveEntry( &pMac->scan.scanResultList, pEntry, |
| 3116 | LL_ACCESS_LOCK )) |
| 3117 | { |
| 3118 | csrFreeScanResultEntry( pMac, pBssDesc ); |
| 3119 | } |
| 3120 | } |
| 3121 | else |
| 3122 | { |
| 3123 | smsLog( pMac, LOG1, FL("%d is a Valid channel"), |
| 3124 | pBssDesc->Result.BssDescriptor.channelId); |
| 3125 | } |
| 3126 | pEntry = pTempEntry; |
| 3127 | } |
| 3128 | |
| 3129 | pEntry = csrLLPeekHead( &pMac->scan.tempScanResults, LL_ACCESS_LOCK ); |
| 3130 | while( pEntry ) |
| 3131 | { |
| 3132 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 3133 | pTempEntry = csrLLNext( &pMac->scan.tempScanResults, pEntry, |
| 3134 | LL_ACCESS_LOCK ); |
| 3135 | |
| 3136 | if((pMac->scan.fEnableDFSChnlScan == DFS_CHNL_SCAN_DISABLED) && |
| 3137 | CSR_IS_CHANNEL_DFS(pBssDesc->Result.BssDescriptor.channelId)) |
| 3138 | { |
| 3139 | smsLog( pMac, LOG1, FL("%d is a DFS ch filtered from scan list"), |
| 3140 | pBssDesc->Result.BssDescriptor.channelId); |
| 3141 | /* Remove Scan result which does not have 11d channel */ |
| 3142 | if( csrLLRemoveEntry( &pMac->scan.tempScanResults, pEntry, |
| 3143 | LL_ACCESS_LOCK )) |
| 3144 | { |
| 3145 | csrFreeScanResultEntry( pMac, pBssDesc ); |
| 3146 | } |
| 3147 | } |
| 3148 | else |
| 3149 | { |
| 3150 | smsLog( pMac, LOG1, FL("%d is a Valid channel"), |
| 3151 | pBssDesc->Result.BssDescriptor.channelId); |
| 3152 | } |
| 3153 | pEntry = pTempEntry; |
| 3154 | } |
| 3155 | return status; |
| 3156 | } |
| 3157 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3158 | |
| 3159 | eHalStatus csrScanCopyResultList(tpAniSirGlobal pMac, tScanResultHandle hIn, tScanResultHandle *phResult) |
| 3160 | { |
| 3161 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 3162 | tScanResultList *pRetList, *pInList = (tScanResultList *)hIn; |
| 3163 | tCsrScanResult *pResult, *pScanResult; |
| 3164 | tANI_U32 count = 0; |
| 3165 | tListElem *pEntry; |
| 3166 | tANI_U32 bssLen, allocLen; |
| 3167 | |
| 3168 | if(phResult) |
| 3169 | { |
| 3170 | *phResult = CSR_INVALID_SCANRESULT_HANDLE; |
| 3171 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3172 | pRetList = vos_mem_malloc(sizeof(tScanResultList)); |
| 3173 | if ( NULL == pRetList ) |
| 3174 | status = eHAL_STATUS_FAILURE; |
| 3175 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3176 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3177 | vos_mem_set(pRetList, sizeof(tScanResultList), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3178 | csrLLOpen(pMac->hHdd, &pRetList->List); |
| 3179 | pRetList->pCurEntry = NULL; |
| 3180 | csrLLLock(&pMac->scan.scanResultList); |
| 3181 | csrLLLock(&pInList->List); |
| 3182 | |
| 3183 | pEntry = csrLLPeekHead( &pInList->List, LL_ACCESS_NOLOCK ); |
| 3184 | while( pEntry ) |
| 3185 | { |
| 3186 | pScanResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 3187 | bssLen = pScanResult->Result.BssDescriptor.length + sizeof(pScanResult->Result.BssDescriptor.length); |
| 3188 | allocLen = sizeof( tCsrScanResult ) + bssLen; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3189 | pResult = vos_mem_malloc(allocLen); |
| 3190 | if ( NULL == pResult ) |
| 3191 | status = eHAL_STATUS_FAILURE; |
| 3192 | else |
| 3193 | status = eHAL_STATUS_SUCCESS; |
| 3194 | if (!HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3195 | { |
| 3196 | csrScanResultPurge(pMac, (tScanResultHandle *)pRetList); |
| 3197 | count = 0; |
| 3198 | break; |
| 3199 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3200 | vos_mem_set(pResult, allocLen , 0); |
| 3201 | vos_mem_copy(&pResult->Result.BssDescriptor, &pScanResult->Result.BssDescriptor, bssLen); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3202 | if( pScanResult->Result.pvIes ) |
| 3203 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3204 | pResult->Result.pvIes = vos_mem_malloc(sizeof( tDot11fBeaconIEs )); |
| 3205 | if ( NULL == pResult->Result.pvIes ) |
| 3206 | status = eHAL_STATUS_FAILURE; |
| 3207 | else |
| 3208 | status = eHAL_STATUS_SUCCESS; |
| 3209 | if (!HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3210 | { |
| 3211 | //Free the memory we allocate above first |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3212 | vos_mem_free(pResult); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3213 | csrScanResultPurge(pMac, (tScanResultHandle *)pRetList); |
| 3214 | count = 0; |
| 3215 | break; |
| 3216 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3217 | vos_mem_copy(pResult->Result.pvIes, pScanResult->Result.pvIes, |
| 3218 | sizeof( tDot11fBeaconIEs )); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3219 | } |
| 3220 | csrLLInsertTail(&pRetList->List, &pResult->Link, LL_ACCESS_LOCK); |
| 3221 | count++; |
| 3222 | pEntry = csrLLNext( &pInList->List, pEntry, LL_ACCESS_NOLOCK ); |
| 3223 | }//while |
| 3224 | csrLLUnlock(&pInList->List); |
| 3225 | csrLLUnlock(&pMac->scan.scanResultList); |
| 3226 | |
| 3227 | if(HAL_STATUS_SUCCESS(status)) |
| 3228 | { |
| 3229 | if(0 == count) |
| 3230 | { |
| 3231 | csrLLClose(&pRetList->List); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3232 | vos_mem_free(pRetList); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3233 | status = eHAL_STATUS_E_NULL_VALUE; |
| 3234 | } |
| 3235 | else if(phResult) |
| 3236 | { |
| 3237 | *phResult = pRetList; |
| 3238 | } |
| 3239 | } |
| 3240 | }//Allocated pRetList |
| 3241 | |
| 3242 | return (status); |
| 3243 | } |
| 3244 | |
| 3245 | |
| 3246 | |
| 3247 | eHalStatus csrScanningStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf ) |
| 3248 | { |
| 3249 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 3250 | tSirMbMsg *pMsg = (tSirMbMsg *)pMsgBuf; |
Hanumantha Reddy Pothula | dc095f3 | 2015-11-30 20:50:23 +0530 | [diff] [blame] | 3251 | tSirSmeDisConDoneInd *pDisConDoneInd; |
Abhishek Singh | f52182c | 2016-08-24 11:15:23 +0530 | [diff] [blame] | 3252 | tCsrRoamSession *pSession; |
Hanumantha Reddy Pothula | dc095f3 | 2015-11-30 20:50:23 +0530 | [diff] [blame] | 3253 | tCsrRoamInfo roamInfo = {0}; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3254 | |
Hanumantha Reddy Pothula | dc095f3 | 2015-11-30 20:50:23 +0530 | [diff] [blame] | 3255 | if((eWNI_SME_SCAN_RSP == pMsg->type) || |
| 3256 | (eWNI_SME_GET_SCANNED_CHANNEL_RSP == pMsg->type)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3257 | { |
| 3258 | status = csrScanSmeScanResponse( pMac, pMsgBuf ); |
| 3259 | } |
| 3260 | else |
| 3261 | { |
Hanumantha Reddy Pothula | dc095f3 | 2015-11-30 20:50:23 +0530 | [diff] [blame] | 3262 | switch (pMsg->type) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3263 | { |
Hanumantha Reddy Pothula | dc095f3 | 2015-11-30 20:50:23 +0530 | [diff] [blame] | 3264 | case eWNI_SME_UPPER_LAYER_ASSOC_CNF: |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 3265 | { |
Hanumantha Reddy Pothula | dc095f3 | 2015-11-30 20:50:23 +0530 | [diff] [blame] | 3266 | tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf; |
| 3267 | tCsrRoamInfo *pRoamInfo = NULL; |
| 3268 | tANI_U32 sessionId; |
| 3269 | eHalStatus status; |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 3270 | |
Hanumantha Reddy Pothula | dc095f3 | 2015-11-30 20:50:23 +0530 | [diff] [blame] | 3271 | smsLog( pMac, LOG1, |
| 3272 | FL("Scanning : ASSOCIATION confirmation can be given to upper layer ")); |
| 3273 | pRoamInfo = &roamInfo; |
| 3274 | pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf; |
| 3275 | status = csrRoamGetSessionIdFromBSSID( pMac, |
| 3276 | (tCsrBssid *)pUpperLayerAssocCnf->bssId, |
| 3277 | &sessionId ); |
| 3278 | pSession = CSR_GET_SESSION(pMac, sessionId); |
| 3279 | |
| 3280 | if(!pSession) |
| 3281 | { |
| 3282 | smsLog(pMac, LOGE, FL("session %d not found "), sessionId); |
| 3283 | return eHAL_STATUS_FAILURE; |
| 3284 | } |
| 3285 | |
| 3286 | //send the status code as Success |
| 3287 | pRoamInfo->statusCode = eSIR_SME_SUCCESS; |
| 3288 | pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile; |
| 3289 | pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid; |
| 3290 | pRoamInfo->rsnIELen = |
| 3291 | (tANI_U8)pUpperLayerAssocCnf->rsnIE.length; |
| 3292 | pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata; |
| 3293 | pRoamInfo->addIELen = |
| 3294 | (tANI_U8)pUpperLayerAssocCnf->addIE.length; |
| 3295 | pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata; |
| 3296 | vos_mem_copy(pRoamInfo->peerMac, |
| 3297 | pUpperLayerAssocCnf->peerMacAddr, |
| 3298 | sizeof(tSirMacAddr)); |
| 3299 | vos_mem_copy(&pRoamInfo->bssid, |
| 3300 | pUpperLayerAssocCnf->bssId, |
| 3301 | sizeof(tCsrBssid)); |
| 3302 | pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta; |
Hardik Kantilal Patel | 1ba630f | 2014-11-21 04:32:05 +0530 | [diff] [blame] | 3303 | #ifdef WLAN_FEATURE_AP_HT40_24G |
Hanumantha Reddy Pothula | dc095f3 | 2015-11-30 20:50:23 +0530 | [diff] [blame] | 3304 | pRoamInfo->HT40MHzIntoEnabledSta = |
| 3305 | pUpperLayerAssocCnf->HT40MHzIntoEnabledSta; |
Hardik Kantilal Patel | 1ba630f | 2014-11-21 04:32:05 +0530 | [diff] [blame] | 3306 | #endif |
Hanumantha Reddy Pothula | dc095f3 | 2015-11-30 20:50:23 +0530 | [diff] [blame] | 3307 | if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) ) |
| 3308 | { |
| 3309 | pMac->roam.roamSession[sessionId].connectState = |
| 3310 | eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED; |
| 3311 | pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq; |
| 3312 | status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, |
| 3313 | 0, eCSR_ROAM_INFRA_IND, |
| 3314 | eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF); |
| 3315 | } |
| 3316 | if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile)) |
| 3317 | { |
| 3318 | vos_sleep( 100 ); |
| 3319 | pMac->roam.roamSession[sessionId].connectState = |
| 3320 | eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta |
| 3321 | status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, |
| 3322 | eCSR_ROAM_WDS_IND, |
| 3323 | eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta |
| 3324 | } |
| 3325 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3326 | } |
Hanumantha Reddy Pothula | dc095f3 | 2015-11-30 20:50:23 +0530 | [diff] [blame] | 3327 | case eWNI_SME_DISCONNECT_DONE_IND: |
| 3328 | pDisConDoneInd = (tSirSmeDisConDoneInd *)(pMsg); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 3329 | |
Hanumantha Reddy Pothula | dc095f3 | 2015-11-30 20:50:23 +0530 | [diff] [blame] | 3330 | smsLog( pMac, LOG1, |
| 3331 | FL("eWNI_SME_DISCONNECT_DONE_IND RC:%d"), |
| 3332 | pDisConDoneInd->reasonCode); |
Sreelakshmi Konamki | 033cf60 | 2016-10-12 15:30:14 +0530 | [diff] [blame] | 3333 | pSession = CSR_GET_SESSION(pMac,pDisConDoneInd->sessionId); |
| 3334 | if (pSession) |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 3335 | { |
Sreelakshmi Konamki | 033cf60 | 2016-10-12 15:30:14 +0530 | [diff] [blame] | 3336 | if( CSR_IS_SESSION_VALID(pMac, pDisConDoneInd->sessionId)) |
| 3337 | { |
| 3338 | roamInfo.reasonCode = pDisConDoneInd->reasonCode; |
| 3339 | roamInfo.statusCode = eSIR_SME_STA_DISASSOCIATED; |
| 3340 | vos_mem_copy(roamInfo.peerMac, pDisConDoneInd->peerMacAddr, |
| 3341 | sizeof(tSirMacAddr)); |
| 3342 | status = csrRoamCallCallback(pMac, |
| 3343 | pDisConDoneInd->sessionId, |
| 3344 | &roamInfo, 0, |
| 3345 | eCSR_ROAM_LOSTLINK, |
| 3346 | eCSR_ROAM_RESULT_DISASSOC_IND); |
| 3347 | /* |
| 3348 | * Update the previous state if |
| 3349 | * previous state was eCSR_ROAMING_STATE_JOINED |
| 3350 | * as we are disconnected and |
| 3351 | * currunt state is scanning |
| 3352 | */ |
| 3353 | if (!CSR_IS_INFRA_AP(&pSession->connectedProfile) |
| 3354 | && (eCSR_ROAMING_STATE_IDLE != |
| 3355 | pMac->roam.prev_state[pDisConDoneInd->sessionId])) |
| 3356 | pMac->roam.prev_state[pDisConDoneInd->sessionId] = |
| 3357 | eCSR_ROAMING_STATE_IDLE; |
| 3358 | } |
| 3359 | else |
| 3360 | { |
| 3361 | smsLog(pMac, LOGE, FL("Inactive session %d"), |
Abhishek Singh | f52182c | 2016-08-24 11:15:23 +0530 | [diff] [blame] | 3362 | pDisConDoneInd->sessionId); |
Sreelakshmi Konamki | 033cf60 | 2016-10-12 15:30:14 +0530 | [diff] [blame] | 3363 | status = eHAL_STATUS_FAILURE; |
| 3364 | } |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 3365 | } |
| 3366 | else |
| 3367 | { |
Sreelakshmi Konamki | 033cf60 | 2016-10-12 15:30:14 +0530 | [diff] [blame] | 3368 | smsLog(pMac, LOGE, FL("Invalid session")); |
Hanumantha Reddy Pothula | dc095f3 | 2015-11-30 20:50:23 +0530 | [diff] [blame] | 3369 | status = eHAL_STATUS_FAILURE; |
| 3370 | } |
| 3371 | break; |
| 3372 | |
| 3373 | default : |
| 3374 | if( csrIsAnySessionInConnectState( pMac ) ) |
| 3375 | { |
| 3376 | /*In case of we are connected, we need to check whether connect |
| 3377 | * status changes because scan may also run while connected. |
| 3378 | */ |
| 3379 | csrRoamCheckForLinkStatusChange( pMac, (tSirSmeRsp *)pMsgBuf ); |
| 3380 | } |
| 3381 | else |
| 3382 | { |
| 3383 | smsLog( pMac, LOGW, |
| 3384 | "Message [0x%04x] received in state, when expecting Scan Response", |
| 3385 | pMsg->type ); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 3386 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3387 | } |
| 3388 | } |
| 3389 | |
| 3390 | return (status); |
| 3391 | } |
| 3392 | |
Abhishek Singh | 02b08ed | 2018-09-26 15:04:58 +0530 | [diff] [blame] | 3393 | void csrCheckNSaveWscIe(tpAniSirGlobal pMac, tSirBssDescription *pNewBssDescr,tSirBssDescription *pOldBssDescr) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3394 | { |
Abhishek Singh | 02b08ed | 2018-09-26 15:04:58 +0530 | [diff] [blame] | 3395 | int elem_id, len, elem_len; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3396 | tANI_U8 *pbIe; |
| 3397 | |
| 3398 | //If failed to remove, assuming someone else got it. |
| 3399 | if((pNewBssDescr->fProbeRsp != pOldBssDescr->fProbeRsp) && |
| 3400 | (0 == pNewBssDescr->WscIeLen)) |
| 3401 | { |
Abhishek Singh | 02b08ed | 2018-09-26 15:04:58 +0530 | [diff] [blame] | 3402 | len = GET_IE_LEN_IN_BSS(pOldBssDescr->length); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3403 | pbIe = (tANI_U8 *)pOldBssDescr->ieFields; |
| 3404 | //Save WPS IE if it exists |
| 3405 | pNewBssDescr->WscIeLen = 0; |
Abhishek Singh | 02b08ed | 2018-09-26 15:04:58 +0530 | [diff] [blame] | 3406 | while (len >= 2) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3407 | { |
Abhishek Singh | 02b08ed | 2018-09-26 15:04:58 +0530 | [diff] [blame] | 3408 | elem_id = pbIe[0]; |
| 3409 | elem_len = pbIe[1]; |
| 3410 | len -= 2; |
| 3411 | if (elem_len > len) { |
| 3412 | smsLog(pMac, LOGW, FL("Invalid eid: %d elem_len: %d left: %d"), |
| 3413 | elem_id, elem_len, len); |
| 3414 | return; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3415 | } |
Abhishek Singh | 02b08ed | 2018-09-26 15:04:58 +0530 | [diff] [blame] | 3416 | if ((elem_id == DOT11F_EID_WSCPROBERES) && |
| 3417 | (elem_len >= DOT11F_IE_WSCPROBERES_MIN_LEN) && |
| 3418 | ((pbIe[2] == 0x00) && (pbIe[3] == 0x50) && (pbIe[4] == 0xf2) && |
| 3419 | (pbIe[5] == 0x04))) |
| 3420 | { |
| 3421 | if((elem_len + 2) <= WSCIE_PROBE_RSP_LEN) |
| 3422 | { |
| 3423 | vos_mem_copy(pNewBssDescr->WscIeProbeRsp, |
| 3424 | pbIe, elem_len + 2); |
| 3425 | pNewBssDescr->WscIeLen = elem_len + 2; |
| 3426 | } |
| 3427 | return; |
| 3428 | } |
| 3429 | len -= elem_len; |
| 3430 | pbIe += (elem_len + 2); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3431 | } |
| 3432 | } |
| 3433 | } |
| 3434 | |
| 3435 | |
| 3436 | |
| 3437 | //pIes may be NULL |
| 3438 | tANI_BOOLEAN csrRemoveDupBssDescription( tpAniSirGlobal pMac, tSirBssDescription *pSirBssDescr, |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 3439 | tDot11fBeaconIEs *pIes, tAniSSID *pSsid, v_TIME_t *timer, tANI_BOOLEAN fForced ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3440 | { |
| 3441 | tListElem *pEntry; |
| 3442 | |
| 3443 | tCsrScanResult *pBssDesc; |
| 3444 | tANI_BOOLEAN fRC = FALSE; |
Abhishek Singh | 56c2981 | 2018-06-12 14:07:52 +0530 | [diff] [blame] | 3445 | tDot11fBeaconIEs *temp_ie = pIes; |
| 3446 | |
| 3447 | if (!temp_ie) |
| 3448 | csrGetParsedBssDescriptionIEs(pMac, pSirBssDescr, &temp_ie); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3449 | |
| 3450 | // Walk through all the chained BssDescriptions. If we find a chained BssDescription that |
| 3451 | // matches the BssID of the BssDescription passed in, then these must be duplicate scan |
| 3452 | // results for this Bss. In that case, remove the 'old' Bss description from the linked list. |
| 3453 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_LOCK ); |
| 3454 | |
| 3455 | while( pEntry ) |
| 3456 | { |
| 3457 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 3458 | |
| 3459 | // we have a duplicate scan results only when BSSID, SSID, Channel and NetworkType |
| 3460 | // matches |
Abhishek Singh | 56c2981 | 2018-06-12 14:07:52 +0530 | [diff] [blame] | 3461 | if (csrIsDuplicateBssDescription(pMac, &pBssDesc->Result.BssDescriptor, |
| 3462 | pSirBssDescr, temp_ie, fForced)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3463 | { |
Abhishek Singh | 56c2981 | 2018-06-12 14:07:52 +0530 | [diff] [blame] | 3464 | /* |
| 3465 | * Due to Rx sensitivity issue, sometime beacons are seen on |
| 3466 | * adjacent channel so workaround in software is needed. If DS |
| 3467 | * params or HT info are present driver can get proper channel |
| 3468 | * info from these IEs and the older RSSI values are used in new |
| 3469 | * entry. |
| 3470 | * |
| 3471 | * For the cases where DS params and HT info is not present, |
| 3472 | * driver needs to check below conditions to update proper |
| 3473 | * channel so that the older RSSI and channel values are used in |
| 3474 | * new entry: |
| 3475 | * -- The old entry channel and new entry channel are not same |
| 3476 | * -- RSSI is below 15db or more from old value, this indicate |
| 3477 | * that the signal has leaked in adjacent channel |
| 3478 | */ |
| 3479 | if (!pSirBssDescr->fProbeRsp && |
| 3480 | (temp_ie && !temp_ie->DSParams.present && |
| 3481 | !temp_ie->HTInfo.present) && |
| 3482 | (pSirBssDescr->channelId != |
| 3483 | pBssDesc->Result.BssDescriptor.channelId) && |
| 3484 | ((pBssDesc->Result.BssDescriptor.rssi - pSirBssDescr->rssi) > |
| 3485 | SIR_ADJACENT_CHANNEL_RSSI_DIFF_THRESHOLD)) { |
| 3486 | pSirBssDescr->channelId = |
| 3487 | pBssDesc->Result.BssDescriptor.channelId; |
| 3488 | pSirBssDescr->rssi = |
| 3489 | pBssDesc->Result.BssDescriptor.rssi; |
| 3490 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3491 | pSirBssDescr->rssi = (tANI_S8)( (((tANI_S32)pSirBssDescr->rssi * CSR_SCAN_RESULT_RSSI_WEIGHT ) + |
| 3492 | ((tANI_S32)pBssDesc->Result.BssDescriptor.rssi * (100 - CSR_SCAN_RESULT_RSSI_WEIGHT) )) / 100 ); |
| 3493 | // Remove the 'old' entry from the list.... |
| 3494 | if( csrLLRemoveEntry( &pMac->scan.scanResultList, pEntry, LL_ACCESS_LOCK ) ) |
| 3495 | { |
| 3496 | // !we need to free the memory associated with this node |
| 3497 | //If failed to remove, assuming someone else got it. |
| 3498 | *pSsid = pBssDesc->Result.ssId; |
| 3499 | *timer = pBssDesc->Result.timer; |
| 3500 | csrCheckNSaveWscIe(pMac, pSirBssDescr, &pBssDesc->Result.BssDescriptor); |
| 3501 | |
| 3502 | csrFreeScanResultEntry( pMac, pBssDesc ); |
| 3503 | } |
| 3504 | else |
| 3505 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 3506 | smsLog( pMac, LOGW, FL( " fail to remove entry" ) ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3507 | } |
| 3508 | fRC = TRUE; |
| 3509 | |
| 3510 | // If we found a match, we can stop looking through the list. |
| 3511 | break; |
| 3512 | } |
| 3513 | |
| 3514 | pEntry = csrLLNext( &pMac->scan.scanResultList, pEntry, LL_ACCESS_LOCK ); |
| 3515 | } |
| 3516 | |
Abhishek Singh | 56c2981 | 2018-06-12 14:07:52 +0530 | [diff] [blame] | 3517 | if (!pIes && temp_ie) |
| 3518 | vos_mem_free(temp_ie); |
| 3519 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3520 | return fRC; |
| 3521 | } |
| 3522 | |
| 3523 | |
| 3524 | eHalStatus csrAddPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId, |
| 3525 | tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes ) |
| 3526 | { |
| 3527 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 3528 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 3529 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 3530 | if(!pSession) |
| 3531 | { |
| 3532 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 3533 | return eHAL_STATUS_FAILURE; |
| 3534 | } |
| 3535 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 3536 | smsLog(pMac, LOGW, "csrAddPMKIDCandidateList called pMac->scan.NumPmkidCandidate = %d", pSession->NumPmkidCandidate); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3537 | if( pIes ) |
| 3538 | { |
| 3539 | // check if this is a RSN BSS |
| 3540 | if( pIes->RSN.present ) |
| 3541 | { |
| 3542 | // Check if the BSS is capable of doing pre-authentication |
| 3543 | if( pSession->NumPmkidCandidate < CSR_MAX_PMKID_ALLOWED ) |
| 3544 | { |
| 3545 | |
| 3546 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 3547 | { |
| 3548 | WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3549 | vos_mem_set(&secEvent, sizeof(vos_event_wlan_security_payload_type), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3550 | secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_CANDIDATE_FOUND; |
| 3551 | secEvent.encryptionModeMulticast = |
| 3552 | (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType); |
| 3553 | secEvent.encryptionModeUnicast = |
| 3554 | (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3555 | vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3556 | secEvent.authMode = |
| 3557 | (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType); |
| 3558 | WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY); |
| 3559 | } |
| 3560 | #endif//#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 3561 | |
| 3562 | // if yes, then add to PMKIDCandidateList |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3563 | vos_mem_copy(pSession->PmkidCandidateInfo[pSession->NumPmkidCandidate].BSSID, |
| 3564 | pBssDesc->bssId, WNI_CFG_BSSID_LEN); |
| 3565 | // Bit 0 offirst byte - PreAuthentication Capability |
| 3566 | if ( (pIes->RSN.RSN_Cap[0] >> 0) & 0x1 ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3567 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3568 | pSession->PmkidCandidateInfo[pSession->NumPmkidCandidate].preAuthSupported |
| 3569 | = eANI_BOOLEAN_TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3570 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3571 | else |
| 3572 | { |
| 3573 | pSession->PmkidCandidateInfo[pSession->NumPmkidCandidate].preAuthSupported |
| 3574 | = eANI_BOOLEAN_FALSE; |
| 3575 | } |
| 3576 | pSession->NumPmkidCandidate++; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3577 | } |
| 3578 | else |
| 3579 | { |
| 3580 | status = eHAL_STATUS_FAILURE; |
| 3581 | } |
| 3582 | } |
| 3583 | } |
| 3584 | |
| 3585 | return (status); |
| 3586 | } |
| 3587 | |
| 3588 | //This function checks whether new AP is found for the current connected profile |
| 3589 | //If it is found, it return the sessionId, else it return invalid sessionID |
| 3590 | tANI_U32 csrProcessBSSDescForPMKIDList(tpAniSirGlobal pMac, |
| 3591 | tSirBssDescription *pBssDesc, |
| 3592 | tDot11fBeaconIEs *pIes) |
| 3593 | { |
| 3594 | tANI_U32 i, bRet = CSR_SESSION_ID_INVALID; |
| 3595 | tCsrRoamSession *pSession; |
| 3596 | tDot11fBeaconIEs *pIesLocal = pIes; |
| 3597 | |
| 3598 | if( pIesLocal || HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal)) ) |
| 3599 | { |
| 3600 | for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ ) |
| 3601 | { |
| 3602 | if( CSR_IS_SESSION_VALID( pMac, i ) ) |
| 3603 | { |
| 3604 | pSession = CSR_GET_SESSION( pMac, i ); |
| 3605 | if( csrIsConnStateConnectedInfra( pMac, i ) && |
| 3606 | ( eCSR_AUTH_TYPE_RSN == pSession->connectedProfile.AuthType ) ) |
| 3607 | { |
| 3608 | if(csrMatchBSSToConnectProfile(pMac, &pSession->connectedProfile, pBssDesc, pIesLocal)) |
| 3609 | { |
| 3610 | //this new BSS fits the current profile connected |
| 3611 | if(HAL_STATUS_SUCCESS(csrAddPMKIDCandidateList(pMac, i, pBssDesc, pIesLocal))) |
| 3612 | { |
| 3613 | bRet = i; |
| 3614 | } |
| 3615 | break; |
| 3616 | } |
| 3617 | } |
| 3618 | } |
| 3619 | } |
| 3620 | if( !pIes ) |
| 3621 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3622 | vos_mem_free(pIesLocal); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3623 | } |
| 3624 | } |
| 3625 | |
| 3626 | return (tANI_U8)bRet; |
| 3627 | } |
| 3628 | |
| 3629 | #ifdef FEATURE_WLAN_WAPI |
| 3630 | eHalStatus csrAddBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId, |
| 3631 | tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes ) |
| 3632 | { |
| 3633 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 3634 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 3635 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 3636 | if(!pSession) |
| 3637 | { |
| 3638 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 3639 | return eHAL_STATUS_FAILURE; |
| 3640 | } |
| 3641 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3642 | smsLog(pMac, LOGW, "csrAddBKIDCandidateList called pMac->scan.NumBkidCandidate = %d", |
| 3643 | pSession->NumBkidCandidate); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3644 | if( pIes ) |
| 3645 | { |
| 3646 | // check if this is a WAPI BSS |
| 3647 | if( pIes->WAPI.present ) |
| 3648 | { |
| 3649 | // Check if the BSS is capable of doing pre-authentication |
| 3650 | if( pSession->NumBkidCandidate < CSR_MAX_BKID_ALLOWED ) |
| 3651 | { |
| 3652 | |
| 3653 | // if yes, then add to BKIDCandidateList |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3654 | vos_mem_copy(pSession->BkidCandidateInfo[pSession->NumBkidCandidate].BSSID, |
| 3655 | pBssDesc->bssId, WNI_CFG_BSSID_LEN); |
| 3656 | if ( pIes->WAPI.preauth ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3657 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3658 | pSession->BkidCandidateInfo[pSession->NumBkidCandidate].preAuthSupported |
| 3659 | = eANI_BOOLEAN_TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3660 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3661 | else |
| 3662 | { |
| 3663 | pSession->BkidCandidateInfo[pSession->NumBkidCandidate].preAuthSupported |
| 3664 | = eANI_BOOLEAN_FALSE; |
| 3665 | } |
| 3666 | pSession->NumBkidCandidate++; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3667 | } |
| 3668 | else |
| 3669 | { |
| 3670 | status = eHAL_STATUS_FAILURE; |
| 3671 | } |
| 3672 | } |
| 3673 | } |
| 3674 | |
| 3675 | return (status); |
| 3676 | } |
| 3677 | |
| 3678 | //This function checks whether new AP is found for the current connected profile |
| 3679 | //if so add to BKIDCandidateList |
| 3680 | tANI_BOOLEAN csrProcessBSSDescForBKIDList(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc, |
| 3681 | tDot11fBeaconIEs *pIes) |
| 3682 | { |
| 3683 | tANI_BOOLEAN fRC = FALSE; |
| 3684 | tDot11fBeaconIEs *pIesLocal = pIes; |
| 3685 | tANI_U32 sessionId; |
| 3686 | tCsrRoamSession *pSession; |
| 3687 | |
| 3688 | if( pIesLocal || HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal)) ) |
| 3689 | { |
| 3690 | for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ ) |
| 3691 | { |
| 3692 | if( CSR_IS_SESSION_VALID( pMac, sessionId) ) |
| 3693 | { |
| 3694 | pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 3695 | if( csrIsConnStateConnectedInfra( pMac, sessionId ) && |
| 3696 | eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == pSession->connectedProfile.AuthType) |
| 3697 | { |
| 3698 | if(csrMatchBSSToConnectProfile(pMac, &pSession->connectedProfile,pBssDesc, pIesLocal)) |
| 3699 | { |
| 3700 | //this new BSS fits the current profile connected |
| 3701 | if(HAL_STATUS_SUCCESS(csrAddBKIDCandidateList(pMac, sessionId, pBssDesc, pIesLocal))) |
| 3702 | { |
| 3703 | fRC = TRUE; |
| 3704 | } |
| 3705 | } |
| 3706 | } |
| 3707 | } |
| 3708 | } |
| 3709 | if(!pIes) |
| 3710 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3711 | vos_mem_free(pIesLocal); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3712 | } |
| 3713 | |
| 3714 | } |
| 3715 | return fRC; |
| 3716 | } |
| 3717 | |
| 3718 | #endif |
| 3719 | |
| 3720 | |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 3721 | static void csrMoveTempScanResultsToMainList( tpAniSirGlobal pMac, tANI_U8 reason ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3722 | { |
| 3723 | tListElem *pEntry; |
| 3724 | tCsrScanResult *pBssDescription; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3725 | tANI_BOOLEAN fDupBss; |
| 3726 | #ifdef FEATURE_WLAN_WAPI |
| 3727 | tANI_BOOLEAN fNewWapiBSSForCurConnection = eANI_BOOLEAN_FALSE; |
| 3728 | #endif /* FEATURE_WLAN_WAPI */ |
| 3729 | tDot11fBeaconIEs *pIesLocal = NULL; |
| 3730 | tANI_U32 sessionId = CSR_SESSION_ID_INVALID; |
| 3731 | tAniSSID tmpSsid; |
| 3732 | v_TIME_t timer=0; |
Kapil Gupta | 2f2fae4 | 2016-09-15 15:29:47 +0530 | [diff] [blame] | 3733 | tANI_U8 occupied_chan_count = pMac->scan.occupiedChannels.numChannels; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3734 | |
| 3735 | tmpSsid.length = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3736 | |
| 3737 | // remove the BSS descriptions from temporary list |
| 3738 | while( ( pEntry = csrLLRemoveTail( &pMac->scan.tempScanResults, LL_ACCESS_LOCK ) ) != NULL) |
| 3739 | { |
| 3740 | pBssDescription = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 3741 | |
Vinay Krishna Eranna | 566365f | 2015-03-09 12:34:13 +0530 | [diff] [blame] | 3742 | smsLog( pMac, LOG2, "...Bssid= "MAC_ADDRESS_STR" chan= %d, rssi = -%d", |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 3743 | MAC_ADDR_ARRAY(pBssDescription->Result.BssDescriptor.bssId), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3744 | pBssDescription->Result.BssDescriptor.channelId, |
| 3745 | pBssDescription->Result.BssDescriptor.rssi * (-1) ); |
| 3746 | |
| 3747 | //At this time, pBssDescription->Result.pvIes may be NULL |
| 3748 | pIesLocal = (tDot11fBeaconIEs *)( pBssDescription->Result.pvIes ); |
| 3749 | if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pBssDescription->Result.BssDescriptor, &pIesLocal))) ) |
| 3750 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 3751 | smsLog(pMac, LOGE, FL(" Cannot pared IEs")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3752 | csrFreeScanResultEntry(pMac, pBssDescription); |
| 3753 | continue; |
| 3754 | } |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 3755 | fDupBss = csrRemoveDupBssDescription( pMac, &pBssDescription->Result.BssDescriptor, pIesLocal, &tmpSsid, &timer, FALSE ); |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 3756 | //Check whether we have reach out limit, but don't lose the LFR candidates came from FW |
| 3757 | if( CSR_SCAN_IS_OVER_BSS_LIMIT(pMac) |
| 3758 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 3759 | && !( eCsrScanGetLfrResult == reason ) |
| 3760 | #endif |
| 3761 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3762 | { |
Deepthi Gowri | 50e2fa5 | 2016-03-17 15:30:53 +0530 | [diff] [blame] | 3763 | smsLog(pMac, LOG1, FL("########## BSS Limit reached ###########")); |
Abhishek Singh | 5deecd1 | 2017-06-12 11:08:40 +0530 | [diff] [blame] | 3764 | csrPurgeScanResults(pMac); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3765 | } |
| 3766 | // check for duplicate scan results |
| 3767 | if ( !fDupBss ) |
| 3768 | { |
| 3769 | //Found a new BSS |
| 3770 | sessionId = csrProcessBSSDescForPMKIDList(pMac, |
| 3771 | &pBssDescription->Result.BssDescriptor, pIesLocal); |
| 3772 | if( CSR_SESSION_ID_INVALID != sessionId) |
| 3773 | { |
| 3774 | csrRoamCallCallback(pMac, sessionId, NULL, 0, |
| 3775 | eCSR_ROAM_SCAN_FOUND_NEW_BSS, eCSR_ROAM_RESULT_NONE); |
| 3776 | } |
| 3777 | } |
| 3778 | else |
| 3779 | { |
| 3780 | //Check if the new one has SSID it it, if not, use the older SSID if it exists. |
| 3781 | if( (0 == pBssDescription->Result.ssId.length) && tmpSsid.length ) |
| 3782 | { |
| 3783 | //New BSS has a hidden SSID and old one has the SSID. Keep the SSID only |
| 3784 | //if diff of saved SSID time and current time is less than 1 min to avoid |
| 3785 | //side effect of saving SSID with old one is that if AP changes its SSID while remain |
| 3786 | //hidden, we may never see it and also to address the requirement of |
| 3787 | //When we remove hidden ssid from the profile i.e., forget the SSID via |
| 3788 | // GUI that SSID shouldn't see in the profile |
| 3789 | if( (vos_timer_get_system_time() - timer) <= HIDDEN_TIMER) |
| 3790 | { |
| 3791 | pBssDescription->Result.timer = timer; |
| 3792 | pBssDescription->Result.ssId = tmpSsid; |
| 3793 | } |
| 3794 | } |
| 3795 | } |
| 3796 | |
Agarwal Ashish | d9d7260 | 2013-09-13 00:06:17 +0530 | [diff] [blame] | 3797 | //Find a good AP for 11d info |
| 3798 | if ( csrIs11dSupported( pMac ) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3799 | { |
Agrawal Ashish | 0b6984f | 2014-04-05 18:35:45 +0530 | [diff] [blame] | 3800 | // check if country information element is present |
| 3801 | if (pIesLocal->Country.present) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3802 | { |
Agrawal Ashish | 0b6984f | 2014-04-05 18:35:45 +0530 | [diff] [blame] | 3803 | csrAddVoteForCountryInfo(pMac, pIesLocal->Country.country); |
| 3804 | smsLog(pMac, LOGW, FL("11d AP Bssid " MAC_ADDRESS_STR |
| 3805 | " chan= %d, rssi = -%d, countryCode %c%c"), |
| 3806 | MAC_ADDR_ARRAY( pBssDescription->Result.BssDescriptor.bssId), |
| 3807 | pBssDescription->Result.BssDescriptor.channelId, |
| 3808 | pBssDescription->Result.BssDescriptor.rssi * (-1), |
| 3809 | pIesLocal->Country.country[0],pIesLocal->Country.country[1] ); |
| 3810 | } |
Agarwal Ashish | d9d7260 | 2013-09-13 00:06:17 +0530 | [diff] [blame] | 3811 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3812 | } |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 3813 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3814 | // append to main list |
| 3815 | csrScanAddResult(pMac, pBssDescription, pIesLocal); |
Agarwal Ashish | d9d7260 | 2013-09-13 00:06:17 +0530 | [diff] [blame] | 3816 | if ( (pBssDescription->Result.pvIes == NULL) && pIesLocal ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3817 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3818 | vos_mem_free(pIesLocal); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3819 | } |
| 3820 | } |
| 3821 | |
Kapil Gupta | 2f2fae4 | 2016-09-15 15:29:47 +0530 | [diff] [blame] | 3822 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 3823 | if (sme_IsFeatureSupportedByFW(PER_BASED_ROAMING) && |
| 3824 | (csrGetInfraSessionId(pMac) != -1) && |
| 3825 | (pMac->scan.occupiedChannels.numChannels != occupied_chan_count)) |
| 3826 | { |
| 3827 | /* Update FW with new list */ |
| 3828 | smsLog(pMac, LOGW, |
| 3829 | FL("Updating occupied channel list, new chanNum %d"), |
| 3830 | pMac->scan.occupiedChannels.numChannels); |
| 3831 | csrRoamOffloadScan(pMac, ROAM_SCAN_OFFLOAD_UPDATE_CFG, |
| 3832 | REASON_CHANNEL_LIST_CHANGED); |
| 3833 | } |
| 3834 | #endif |
Sushant Kaushik | 6274de6 | 2015-05-01 16:31:23 +0530 | [diff] [blame] | 3835 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_LOCK ); |
Tushnim Bhattacharyya | ae31777 | 2013-10-23 18:55:38 -0700 | [diff] [blame] | 3836 | //we don't need to update CC while connected to an AP which is advertising CC already |
| 3837 | if (csrIs11dSupported(pMac)) |
| 3838 | { |
| 3839 | tANI_U32 i; |
| 3840 | tCsrRoamSession *pSession; |
| 3841 | |
| 3842 | for (i = 0; i < CSR_ROAM_SESSION_MAX; i++ ) |
| 3843 | { |
| 3844 | if (CSR_IS_SESSION_VALID( pMac, i ) ) |
| 3845 | { |
| 3846 | pSession = CSR_GET_SESSION( pMac, i ); |
| 3847 | if (csrIsConnStateConnected(pMac, i)) |
| 3848 | { |
Agrawal Ashish | 0b6984f | 2014-04-05 18:35:45 +0530 | [diff] [blame] | 3849 | smsLog(pMac, LOGW, FL("No need for updating CC in" |
| 3850 | "connected state")); |
| 3851 | goto end; |
Tushnim Bhattacharyya | ae31777 | 2013-10-23 18:55:38 -0700 | [diff] [blame] | 3852 | } |
| 3853 | } |
| 3854 | } |
Agrawal Ashish | bd3a593 | 2016-04-12 16:22:39 +0530 | [diff] [blame] | 3855 | if (csrElectedCountryInfo(pMac)) |
| 3856 | csrLearnCountryInformation(pMac, NULL, NULL, |
| 3857 | eANI_BOOLEAN_TRUE); |
Agarwal Ashish | d9d7260 | 2013-09-13 00:06:17 +0530 | [diff] [blame] | 3858 | } |
| 3859 | |
Tushnim Bhattacharyya | ae31777 | 2013-10-23 18:55:38 -0700 | [diff] [blame] | 3860 | end: |
| 3861 | //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] | 3862 | // a good enough AP with the 11d info from the scan results then no need to |
| 3863 | // get into ambiguous state |
| 3864 | if(pMac->scan.fAmbiguous11dInfoFound) |
| 3865 | { |
Agrawal Ashish | 0b6984f | 2014-04-05 18:35:45 +0530 | [diff] [blame] | 3866 | if((pMac->scan.fCurrent11dInfoMatch)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3867 | { |
| 3868 | pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE; |
| 3869 | } |
| 3870 | } |
| 3871 | |
| 3872 | #ifdef FEATURE_WLAN_WAPI |
| 3873 | if(fNewWapiBSSForCurConnection) |
| 3874 | { |
| 3875 | //remember it first |
| 3876 | csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_SCAN_FOUND_NEW_BSS, eCSR_ROAM_RESULT_NEW_WAPI_BSS); |
| 3877 | } |
| 3878 | #endif /* FEATURE_WLAN_WAPI */ |
| 3879 | |
| 3880 | return; |
| 3881 | } |
| 3882 | |
Abhishek Singh | 5deecd1 | 2017-06-12 11:08:40 +0530 | [diff] [blame] | 3883 | /** |
| 3884 | * csrPurgeScanResults() - This function removes scan entry based |
| 3885 | * on RSSI or AGE |
| 3886 | * @pMac: pointer to Global MAC structure |
| 3887 | * |
| 3888 | * This function removes scan entry based on RSSI or AGE. |
| 3889 | * If an scan entry with RSSI less than CSR_PURGE_RSSI_THRESHOLD, |
| 3890 | * the scan entry is removed else oldest entry is removed. |
| 3891 | * |
| 3892 | * Return: None |
| 3893 | */ |
| 3894 | void csrPurgeScanResults(tpAniSirGlobal pMac) |
Deepthi Gowri | 50e2fa5 | 2016-03-17 15:30:53 +0530 | [diff] [blame] | 3895 | { |
| 3896 | tListElem *pEntry, *tmpEntry; |
Abhishek Singh | 5deecd1 | 2017-06-12 11:08:40 +0530 | [diff] [blame] | 3897 | tCsrScanResult *pResult, *oldest_bss = NULL, *weakest_bss = NULL; |
Deepthi Gowri | 4480a3f | 2016-05-18 19:30:17 +0530 | [diff] [blame] | 3898 | v_TIME_t oldest_entry = 0; |
| 3899 | v_TIME_t curTime = vos_timer_get_system_time(); |
Abhishek Singh | 5deecd1 | 2017-06-12 11:08:40 +0530 | [diff] [blame] | 3900 | tANI_S8 weakest_rssi = 0; |
Deepthi Gowri | 50e2fa5 | 2016-03-17 15:30:53 +0530 | [diff] [blame] | 3901 | |
| 3902 | csrLLLock(&pMac->scan.scanResultList); |
| 3903 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK ); |
Abhishek Singh | 5deecd1 | 2017-06-12 11:08:40 +0530 | [diff] [blame] | 3904 | while(pEntry) |
Deepthi Gowri | 50e2fa5 | 2016-03-17 15:30:53 +0530 | [diff] [blame] | 3905 | { |
| 3906 | tmpEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, |
| 3907 | LL_ACCESS_NOLOCK); |
| 3908 | pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 3909 | if((curTime - |
| 3910 | pResult->Result.BssDescriptor.nReceivedTime) > oldest_entry) |
| 3911 | { |
| 3912 | oldest_entry = curTime - |
| 3913 | pResult->Result.BssDescriptor.nReceivedTime; |
| 3914 | oldest_bss = pResult; |
| 3915 | } |
Abhishek Singh | 5deecd1 | 2017-06-12 11:08:40 +0530 | [diff] [blame] | 3916 | if (pResult->Result.BssDescriptor.rssi < weakest_rssi) |
| 3917 | { |
| 3918 | weakest_rssi = pResult->Result.BssDescriptor.rssi; |
| 3919 | weakest_bss = pResult; |
| 3920 | } |
Deepthi Gowri | 50e2fa5 | 2016-03-17 15:30:53 +0530 | [diff] [blame] | 3921 | pEntry = tmpEntry; |
| 3922 | } |
| 3923 | if (oldest_bss) |
| 3924 | { |
Abhishek Singh | 5deecd1 | 2017-06-12 11:08:40 +0530 | [diff] [blame] | 3925 | tCsrScanResult *bss_to_remove; |
| 3926 | |
| 3927 | if (weakest_rssi < CSR_PURGE_RSSI_THRESHOLD) |
| 3928 | bss_to_remove = weakest_bss; |
| 3929 | else |
| 3930 | bss_to_remove = oldest_bss; |
| 3931 | |
Deepthi Gowri | 50e2fa5 | 2016-03-17 15:30:53 +0530 | [diff] [blame] | 3932 | //Free the old BSS Entries |
Abhishek Singh | 5deecd1 | 2017-06-12 11:08:40 +0530 | [diff] [blame] | 3933 | if(csrLLRemoveEntry(&pMac->scan.scanResultList, |
| 3934 | &bss_to_remove->Link, LL_ACCESS_NOLOCK)) |
Deepthi Gowri | 50e2fa5 | 2016-03-17 15:30:53 +0530 | [diff] [blame] | 3935 | { |
Abhishek Singh | 5deecd1 | 2017-06-12 11:08:40 +0530 | [diff] [blame] | 3936 | smsLog(pMac, LOG1, |
| 3937 | FL("BSSID: "MAC_ADDRESS_STR" Removed, time delta (%lu) RSSI %d"), |
| 3938 | MAC_ADDR_ARRAY( |
| 3939 | bss_to_remove->Result.BssDescriptor.bssId), |
| 3940 | (curTime - |
| 3941 | bss_to_remove->Result.BssDescriptor.nReceivedTime), |
| 3942 | bss_to_remove->Result.BssDescriptor.rssi); |
| 3943 | csrFreeScanResultEntry(pMac, bss_to_remove); |
Deepthi Gowri | 50e2fa5 | 2016-03-17 15:30:53 +0530 | [diff] [blame] | 3944 | } |
| 3945 | } |
| 3946 | csrLLUnlock(&pMac->scan.scanResultList); |
| 3947 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3948 | |
| 3949 | static tCsrScanResult *csrScanSaveBssDescription( tpAniSirGlobal pMac, tSirBssDescription *pBSSDescription, |
| 3950 | tDot11fBeaconIEs *pIes) |
| 3951 | { |
| 3952 | tCsrScanResult *pCsrBssDescription = NULL; |
| 3953 | tANI_U32 cbBSSDesc; |
| 3954 | tANI_U32 cbAllocated; |
Sushant Kaushik | 6274de6 | 2015-05-01 16:31:23 +0530 | [diff] [blame] | 3955 | tListElem *pEntry; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3956 | |
| 3957 | // figure out how big the BSS description is (the BSSDesc->length does NOT |
| 3958 | // include the size of the length field itself). |
| 3959 | cbBSSDesc = pBSSDescription->length + sizeof( pBSSDescription->length ); |
| 3960 | |
| 3961 | cbAllocated = sizeof( tCsrScanResult ) + cbBSSDesc; |
| 3962 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3963 | pCsrBssDescription = vos_mem_malloc(cbAllocated); |
| 3964 | if ( NULL != pCsrBssDescription ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3965 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3966 | vos_mem_set(pCsrBssDescription, cbAllocated, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3967 | pCsrBssDescription->AgingCount = (tANI_S32)pMac->roam.configParam.agingCount; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3968 | vos_mem_copy(&pCsrBssDescription->Result.BssDescriptor, pBSSDescription, cbBSSDesc); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3969 | #if defined(VOSS_ENSBALED) |
| 3970 | VOS_ASSERT( pCsrBssDescription->Result.pvIes == NULL ); |
| 3971 | #endif |
| 3972 | csrScanAddResult(pMac, pCsrBssDescription, pIes); |
Sushant Kaushik | 6274de6 | 2015-05-01 16:31:23 +0530 | [diff] [blame] | 3973 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_LOCK ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3974 | } |
| 3975 | |
| 3976 | return( pCsrBssDescription ); |
| 3977 | } |
| 3978 | |
| 3979 | // Append a Bss Description... |
| 3980 | tCsrScanResult *csrScanAppendBssDescription( tpAniSirGlobal pMac, |
| 3981 | tSirBssDescription *pSirBssDescription, |
Tushnim Bhattacharyya | 5128d75 | 2013-06-26 23:23:18 -0700 | [diff] [blame] | 3982 | tDot11fBeaconIEs *pIes, tANI_BOOLEAN fForced ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3983 | { |
| 3984 | tCsrScanResult *pCsrBssDescription = NULL; |
| 3985 | tAniSSID tmpSsid; |
| 3986 | v_TIME_t timer = 0; |
| 3987 | int result; |
| 3988 | |
| 3989 | tmpSsid.length = 0; |
Tushnim Bhattacharyya | 5128d75 | 2013-06-26 23:23:18 -0700 | [diff] [blame] | 3990 | result = csrRemoveDupBssDescription( pMac, pSirBssDescription, pIes, &tmpSsid, &timer, fForced ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3991 | pCsrBssDescription = csrScanSaveBssDescription( pMac, pSirBssDescription, pIes ); |
| 3992 | if (result && (pCsrBssDescription != NULL)) |
| 3993 | { |
| 3994 | //Check if the new one has SSID it it, if not, use the older SSID if it exists. |
| 3995 | if( (0 == pCsrBssDescription->Result.ssId.length) && tmpSsid.length ) |
| 3996 | { |
| 3997 | //New BSS has a hidden SSID and old one has the SSID. Keep the SSID only |
| 3998 | //if diff of saved SSID time and current time is less than 1 min to avoid |
| 3999 | //side effect of saving SSID with old one is that if AP changes its SSID while remain |
| 4000 | //hidden, we may never see it and also to address the requirement of |
| 4001 | //When we remove hidden ssid from the profile i.e., forget the SSID via |
| 4002 | // GUI that SSID shouldn't see in the profile |
| 4003 | if((vos_timer_get_system_time()-timer) <= HIDDEN_TIMER) |
| 4004 | { |
| 4005 | pCsrBssDescription->Result.ssId = tmpSsid; |
| 4006 | pCsrBssDescription->Result.timer = timer; |
| 4007 | } |
| 4008 | } |
| 4009 | } |
| 4010 | |
| 4011 | |
| 4012 | return( pCsrBssDescription ); |
| 4013 | } |
| 4014 | |
| 4015 | |
| 4016 | |
| 4017 | void csrPurgeChannelPower( tpAniSirGlobal pMac, tDblLinkList *pChannelList ) |
| 4018 | { |
| 4019 | tCsrChannelPowerInfo *pChannelSet; |
| 4020 | tListElem *pEntry; |
| 4021 | |
| 4022 | csrLLLock(pChannelList); |
| 4023 | // Remove the channel sets from the learned list and put them in the free list |
| 4024 | while( ( pEntry = csrLLRemoveHead( pChannelList, LL_ACCESS_NOLOCK ) ) != NULL) |
| 4025 | { |
| 4026 | pChannelSet = GET_BASE_ADDR( pEntry, tCsrChannelPowerInfo, link ); |
| 4027 | if( pChannelSet ) |
| 4028 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4029 | vos_mem_free(pChannelSet); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4030 | } |
| 4031 | } |
| 4032 | csrLLUnlock(pChannelList); |
| 4033 | return; |
| 4034 | } |
| 4035 | |
| 4036 | |
| 4037 | /* |
| 4038 | * Save the channelList into the ultimate storage as the final stage of channel |
| 4039 | * Input: pCountryInfo -- the country code (e.g. "USI"), channel list, and power limit are all stored inside this data structure |
| 4040 | */ |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4041 | eHalStatus csrSaveToChannelPower2G_5G( tpAniSirGlobal pMac, tANI_U32 tableSize, tSirMacChanInfo *channelTable ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4042 | { |
| 4043 | tANI_U32 i = tableSize / sizeof( tSirMacChanInfo ); |
| 4044 | tSirMacChanInfo *pChannelInfo; |
| 4045 | tCsrChannelPowerInfo *pChannelSet; |
| 4046 | tANI_BOOLEAN f2GHzInfoFound = FALSE; |
| 4047 | tANI_BOOLEAN f2GListPurged = FALSE, f5GListPurged = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4048 | |
| 4049 | pChannelInfo = channelTable; |
| 4050 | // atleast 3 bytes have to be remaining -- from "countryString" |
| 4051 | while ( i-- ) |
| 4052 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4053 | pChannelSet = vos_mem_malloc(sizeof(tCsrChannelPowerInfo)); |
| 4054 | if ( NULL != pChannelSet ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4055 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4056 | vos_mem_set(pChannelSet, sizeof(tCsrChannelPowerInfo), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4057 | pChannelSet->firstChannel = pChannelInfo->firstChanNum; |
| 4058 | pChannelSet->numChannels = pChannelInfo->numChannels; |
| 4059 | |
| 4060 | // 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] | 4061 | if( (CSR_IS_CHANNEL_24GHZ(pChannelSet->firstChannel)) && |
Madan Mohan Koyyalamudi | 5904d7c | 2012-09-24 13:49:03 -0700 | [diff] [blame] | 4062 | ((pChannelSet->firstChannel + (pChannelSet->numChannels - 1)) <= CSR_MAX_24GHz_CHANNEL_NUMBER) ) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4063 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4064 | { |
| 4065 | pChannelSet->interChannelOffset = 1; |
| 4066 | f2GHzInfoFound = TRUE; |
| 4067 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4068 | else if ( (CSR_IS_CHANNEL_5GHZ(pChannelSet->firstChannel)) && |
Madan Mohan Koyyalamudi | 5904d7c | 2012-09-24 13:49:03 -0700 | [diff] [blame] | 4069 | ((pChannelSet->firstChannel + ((pChannelSet->numChannels - 1) * 4)) <= CSR_MAX_5GHz_CHANNEL_NUMBER) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4070 | { |
| 4071 | pChannelSet->interChannelOffset = 4; |
| 4072 | f2GHzInfoFound = FALSE; |
| 4073 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4074 | else |
| 4075 | { |
Madan Mohan Koyyalamudi | 5904d7c | 2012-09-24 13:49:03 -0700 | [diff] [blame] | 4076 | smsLog( pMac, LOGW, FL("Invalid Channel %d Present in Country IE"), |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4077 | pChannelSet->firstChannel); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4078 | vos_mem_free(pChannelSet); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4079 | return eHAL_STATUS_FAILURE; |
| 4080 | } |
| 4081 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4082 | pChannelSet->txPower = CSR_ROAM_MIN( pChannelInfo->maxTxPower, pMac->roam.configParam.nTxPowerCap ); |
| 4083 | |
| 4084 | if( f2GHzInfoFound ) |
| 4085 | { |
| 4086 | if( !f2GListPurged ) |
| 4087 | { |
| 4088 | // purge previous results if found new |
| 4089 | csrPurgeChannelPower( pMac, &pMac->scan.channelPowerInfoList24 ); |
| 4090 | f2GListPurged = TRUE; |
| 4091 | } |
| 4092 | |
| 4093 | if(CSR_IS_OPERATING_BG_BAND(pMac)) |
| 4094 | { |
| 4095 | // add to the list of 2.4 GHz channel sets |
| 4096 | csrLLInsertTail( &pMac->scan.channelPowerInfoList24, &pChannelSet->link, LL_ACCESS_LOCK ); |
| 4097 | } |
| 4098 | else { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 4099 | 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] | 4100 | pChannelSet->firstChannel); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4101 | vos_mem_free(pChannelSet); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4102 | } |
| 4103 | } |
| 4104 | else |
| 4105 | { |
| 4106 | // 5GHz info found |
| 4107 | if( !f5GListPurged ) |
| 4108 | { |
| 4109 | // purge previous results if found new |
| 4110 | csrPurgeChannelPower( pMac, &pMac->scan.channelPowerInfoList5G ); |
| 4111 | f5GListPurged = TRUE; |
| 4112 | } |
| 4113 | |
| 4114 | if(CSR_IS_OPERATING_A_BAND(pMac)) |
| 4115 | { |
| 4116 | // add to the list of 5GHz channel sets |
| 4117 | csrLLInsertTail( &pMac->scan.channelPowerInfoList5G, &pChannelSet->link, LL_ACCESS_LOCK ); |
| 4118 | } |
| 4119 | else { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 4120 | 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] | 4121 | pChannelSet->firstChannel); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4122 | vos_mem_free(pChannelSet); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4123 | } |
| 4124 | } |
| 4125 | } |
| 4126 | |
| 4127 | pChannelInfo++; // move to next entry |
| 4128 | } |
| 4129 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4130 | return eHAL_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4131 | } |
| 4132 | |
Gopichand Nakkala | c178ac8 | 2013-05-30 19:53:39 +0530 | [diff] [blame] | 4133 | static void csrClearDfsChannelList( tpAniSirGlobal pMac ) |
| 4134 | { |
| 4135 | tSirMbMsg *pMsg; |
| 4136 | tANI_U16 msgLen; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4137 | |
Gopichand Nakkala | c178ac8 | 2013-05-30 19:53:39 +0530 | [diff] [blame] | 4138 | msgLen = (tANI_U16)(sizeof( tSirMbMsg )); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4139 | pMsg = vos_mem_malloc(msgLen); |
| 4140 | if ( NULL != pMsg ) |
Gopichand Nakkala | c178ac8 | 2013-05-30 19:53:39 +0530 | [diff] [blame] | 4141 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4142 | vos_mem_set((void *)pMsg, msgLen, 0); |
Gopichand Nakkala | c178ac8 | 2013-05-30 19:53:39 +0530 | [diff] [blame] | 4143 | pMsg->type = pal_cpu_to_be16((tANI_U16)eWNI_SME_CLEAR_DFS_CHANNEL_LIST); |
| 4144 | pMsg->msgLen = pal_cpu_to_be16(msgLen); |
| 4145 | palSendMBMessage(pMac->hHdd, pMsg); |
| 4146 | } |
| 4147 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4148 | |
| 4149 | void csrApplyPower2Current( tpAniSirGlobal pMac ) |
| 4150 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 4151 | smsLog( pMac, LOG3, FL(" Updating Cfg with power settings")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4152 | csrSaveTxPowerToCfg( pMac, &pMac->scan.channelPowerInfoList24, WNI_CFG_MAX_TX_POWER_2_4 ); |
| 4153 | csrSaveTxPowerToCfg( pMac, &pMac->scan.channelPowerInfoList5G, WNI_CFG_MAX_TX_POWER_5 ); |
| 4154 | } |
| 4155 | |
| 4156 | |
Gopichand Nakkala | b9185f2 | 2012-12-21 08:03:42 -0800 | [diff] [blame] | 4157 | void csrApplyChannelPowerCountryInfo( tpAniSirGlobal pMac, tCsrChannel *pChannelList, tANI_U8 *countryCode, tANI_BOOLEAN updateRiva) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4158 | { |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 4159 | int i, j, count, countryIndex = -1; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4160 | tANI_U8 numChannels = 0; |
| 4161 | tANI_U8 tempNumChannels = 0; |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 4162 | tANI_U8 channelIgnore = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4163 | tCsrChannel ChannelList; |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 4164 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4165 | if( pChannelList->numChannels ) |
| 4166 | { |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 4167 | for(count=0; count < MAX_COUNTRY_IGNORE; count++) |
| 4168 | { |
| 4169 | if(vos_mem_compare(countryCode, countryIgnoreList[count].countryCode, |
| 4170 | VOS_COUNTRY_CODE_LEN)) |
| 4171 | { |
| 4172 | countryIndex = count; |
| 4173 | break; |
| 4174 | } |
| 4175 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4176 | tempNumChannels = CSR_MIN(pChannelList->numChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN); |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 4177 | |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 4178 | for(i=0; i < tempNumChannels; i++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4179 | { |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 4180 | channelIgnore = FALSE; |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 4181 | if( countryIndex != -1 ) |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 4182 | { |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 4183 | for(j=0; j < countryIgnoreList[countryIndex].channelCount; j++) |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 4184 | { |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 4185 | if( pChannelList->channelList[i] == |
| 4186 | countryIgnoreList[countryIndex].channelList[j] ) |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 4187 | { |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 4188 | channelIgnore = TRUE; |
| 4189 | break; |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 4190 | } |
| 4191 | } |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 4192 | } |
| 4193 | if( FALSE == channelIgnore ) |
| 4194 | { |
| 4195 | ChannelList.channelList[numChannels] = pChannelList->channelList[i]; |
| 4196 | numChannels++; |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 4197 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4198 | } |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 4199 | ChannelList.numChannels = numChannels; |
Mahesh A Saptasagar | 1ed5958 | 2014-06-04 18:45:07 +0530 | [diff] [blame] | 4200 | csrApplyPower2Current( pMac ); // Store the channel+power info in the global place: Cfg |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4201 | csrSetCfgValidChannelList(pMac, ChannelList.channelList, ChannelList.numChannels); |
| 4202 | // extend scan capability |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 4203 | // build a scan list based on the channel list : channel# + active/passive scan |
| 4204 | csrSetCfgScanControlList(pMac, countryCode, &ChannelList); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4205 | #ifdef FEATURE_WLAN_SCAN_PNO |
Gopichand Nakkala | b9185f2 | 2012-12-21 08:03:42 -0800 | [diff] [blame] | 4206 | if (updateRiva) |
| 4207 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 4208 | 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] | 4209 | // Send HAL UpdateScanParams message |
| 4210 | pmcUpdateScanParams(pMac, &(pMac->roam.configParam), &ChannelList, TRUE); |
| 4211 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4212 | #endif // FEATURE_WLAN_SCAN_PNO |
| 4213 | } |
| 4214 | else |
| 4215 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 4216 | smsLog( pMac, LOGE, FL(" 11D channel list is empty")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4217 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4218 | csrSetCfgCountryCode(pMac, countryCode); |
| 4219 | } |
| 4220 | |
Sourav Mohapatra | 3dd5dba | 2018-03-26 15:12:47 +0530 | [diff] [blame] | 4221 | void csrUpdateFCCChannelList(tpAniSirGlobal pMac) |
| 4222 | { |
| 4223 | tCsrChannel ChannelList; |
| 4224 | tANI_U8 chnlIndx = 0; |
| 4225 | int i; |
| 4226 | |
| 4227 | for ( i = 0; i < pMac->scan.base20MHzChannels.numChannels; i++ ) |
| 4228 | { |
| 4229 | if (pMac->scan.fcc_constraint && |
| 4230 | ((pMac->scan.base20MHzChannels.channelList[i] == 12) || |
| 4231 | (pMac->scan.base20MHzChannels.channelList[i] == 13))) |
| 4232 | { |
| 4233 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, |
| 4234 | FL("removing channel %d"), |
| 4235 | pMac->scan.base20MHzChannels.channelList[i]); |
| 4236 | continue; |
| 4237 | } |
| 4238 | ChannelList.channelList[chnlIndx] = |
| 4239 | pMac->scan.base20MHzChannels.channelList[i]; |
| 4240 | chnlIndx++; |
| 4241 | } |
| 4242 | csrSetCfgValidChannelList(pMac, ChannelList.channelList, chnlIndx); |
| 4243 | csrScanFilterResults(pMac); |
| 4244 | } |
| 4245 | |
Gopichand Nakkala | b9185f2 | 2012-12-21 08:03:42 -0800 | [diff] [blame] | 4246 | void csrResetCountryInformation( tpAniSirGlobal pMac, tANI_BOOLEAN fForce, tANI_BOOLEAN updateRiva ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4247 | { |
| 4248 | if( fForce || (csrIs11dSupported( pMac ) && (!pMac->scan.f11dInfoReset))) |
| 4249 | { |
| 4250 | |
| 4251 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 4252 | { |
| 4253 | vos_log_802_11d_pkt_type *p11dLog; |
| 4254 | int Index; |
| 4255 | |
| 4256 | WLAN_VOS_DIAG_LOG_ALLOC(p11dLog, vos_log_802_11d_pkt_type, LOG_WLAN_80211D_C); |
| 4257 | if(p11dLog) |
| 4258 | { |
| 4259 | p11dLog->eventId = WLAN_80211D_EVENT_RESET; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4260 | vos_mem_copy(p11dLog->countryCode, pMac->scan.countryCodeCurrent, 3); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4261 | p11dLog->numChannel = pMac->scan.base20MHzChannels.numChannels; |
| 4262 | if(p11dLog->numChannel <= VOS_LOG_MAX_NUM_CHANNEL) |
| 4263 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4264 | vos_mem_copy(p11dLog->Channels, |
| 4265 | pMac->scan.base20MHzChannels.channelList, |
| 4266 | p11dLog->numChannel); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4267 | for (Index=0; Index < pMac->scan.base20MHzChannels.numChannels; Index++) |
| 4268 | { |
| 4269 | p11dLog->TxPwr[Index] = CSR_ROAM_MIN( pMac->scan.defaultPowerTable[Index].pwr, pMac->roam.configParam.nTxPowerCap ); |
| 4270 | } |
| 4271 | } |
| 4272 | if(!pMac->roam.configParam.Is11dSupportEnabled) |
| 4273 | { |
| 4274 | p11dLog->supportMultipleDomain = WLAN_80211D_DISABLED; |
| 4275 | } |
| 4276 | else if(pMac->roam.configParam.fEnforceDefaultDomain) |
| 4277 | { |
| 4278 | p11dLog->supportMultipleDomain = WLAN_80211D_NOT_SUPPORT_MULTI_DOMAIN; |
| 4279 | } |
| 4280 | else |
| 4281 | { |
| 4282 | p11dLog->supportMultipleDomain = WLAN_80211D_SUPPORT_MULTI_DOMAIN; |
| 4283 | } |
| 4284 | WLAN_VOS_DIAG_LOG_REPORT(p11dLog); |
| 4285 | } |
| 4286 | } |
| 4287 | #endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 4288 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4289 | csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels); |
| 4290 | csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels); |
| 4291 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4292 | csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE); |
| 4293 | csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE); |
| 4294 | // ... and apply the channel list, power settings, and the country code. |
Gopichand Nakkala | b9185f2 | 2012-12-21 08:03:42 -0800 | [diff] [blame] | 4295 | csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, updateRiva ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4296 | // clear the 11d channel list |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4297 | vos_mem_set(&pMac->scan.channels11d, sizeof(pMac->scan.channels11d), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4298 | pMac->scan.f11dInfoReset = eANI_BOOLEAN_TRUE; |
| 4299 | pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE; |
| 4300 | } |
| 4301 | |
| 4302 | return; |
| 4303 | } |
| 4304 | |
| 4305 | |
| 4306 | eHalStatus csrResetCountryCodeInformation(tpAniSirGlobal pMac, tANI_BOOLEAN *pfRestartNeeded) |
| 4307 | { |
| 4308 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 4309 | tANI_BOOLEAN fRestart = eANI_BOOLEAN_FALSE; |
| 4310 | |
| 4311 | //Use the Country code and domain from EEPROM |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4312 | vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault, |
| 4313 | WNI_CFG_COUNTRY_CODE_LEN); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4314 | csrSetRegulatoryDomain(pMac, pMac->scan.domainIdCurrent, &fRestart); |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 4315 | if( ((eANI_BOOLEAN_FALSE == fRestart) || (pfRestartNeeded == NULL) ) |
| 4316 | && !csrIsInfraConnected(pMac)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4317 | { |
| 4318 | //Only reset the country info if we don't need to restart |
Gopichand Nakkala | b9185f2 | 2012-12-21 08:03:42 -0800 | [diff] [blame] | 4319 | csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4320 | } |
| 4321 | if(pfRestartNeeded) |
| 4322 | { |
| 4323 | *pfRestartNeeded = fRestart; |
| 4324 | } |
| 4325 | |
| 4326 | return (status); |
| 4327 | } |
| 4328 | |
Agrawal Ashish | 0b6984f | 2014-04-05 18:35:45 +0530 | [diff] [blame] | 4329 | void csrClearVotesForCountryInfo(tpAniSirGlobal pMac) |
| 4330 | { |
| 4331 | pMac->scan.countryCodeCount = 0; |
| 4332 | vos_mem_set(pMac->scan.votes11d, |
| 4333 | sizeof(tCsrVotes11d) * CSR_MAX_NUM_COUNTRY_CODE, 0); |
| 4334 | } |
| 4335 | |
| 4336 | void csrAddVoteForCountryInfo(tpAniSirGlobal pMac, tANI_U8 *pCountryCode) |
| 4337 | { |
| 4338 | tANI_BOOLEAN match = FALSE; |
| 4339 | tANI_U8 i; |
| 4340 | |
| 4341 | /* convert to UPPER here so we are assured |
| 4342 | * the strings are always in upper case. |
| 4343 | */ |
| 4344 | for( i = 0; i < 3; i++ ) |
| 4345 | { |
| 4346 | pCountryCode[ i ] = (tANI_U8)csrToUpper( pCountryCode[ i ] ); |
| 4347 | } |
| 4348 | |
| 4349 | /* Some of the 'old' Cisco 350 series AP's advertise NA as the |
| 4350 | * country code (for North America ??). NA is not a valid country code |
| 4351 | * or domain so let's allow this by changing it to the proper |
| 4352 | * country code (which is US). We've also seen some NETGEAR AP's |
| 4353 | * that have "XX " as the country code with valid 2.4 GHz US channel |
| 4354 | * information. If we cannot find the country code advertised in the |
| 4355 | * 11d information element, let's default to US. |
| 4356 | */ |
| 4357 | |
| 4358 | if ( !HAL_STATUS_SUCCESS(csrGetRegulatoryDomainForCountry( pMac, |
| 4359 | pCountryCode, NULL,COUNTRY_QUERY ) ) ) |
| 4360 | { |
| 4361 | pCountryCode[ 0 ] = '0'; |
| 4362 | pCountryCode[ 1 ] = '0'; |
| 4363 | } |
| 4364 | |
| 4365 | /* We've seen some of the AP's improperly put a 0 for the |
| 4366 | * third character of the country code. spec says valid charcters are |
| 4367 | * 'O' (for outdoor), 'I' for Indoor, or ' ' (space; for either). |
| 4368 | * if we see a 0 in this third character, let's change it to a ' '. |
| 4369 | */ |
| 4370 | if ( 0 == pCountryCode[ 2 ] ) |
| 4371 | { |
| 4372 | pCountryCode[ 2 ] = ' '; |
| 4373 | } |
| 4374 | |
| 4375 | for (i = 0; i < pMac->scan.countryCodeCount; i++) |
| 4376 | { |
| 4377 | match = (vos_mem_compare(pMac->scan.votes11d[i].countryCode, |
| 4378 | pCountryCode, 2)); |
| 4379 | if(match) |
| 4380 | { |
| 4381 | break; |
| 4382 | } |
| 4383 | } |
| 4384 | |
| 4385 | if (match) |
| 4386 | { |
| 4387 | pMac->scan.votes11d[i].votes++; |
| 4388 | } |
| 4389 | else |
| 4390 | { |
| 4391 | vos_mem_copy( pMac->scan.votes11d[pMac->scan.countryCodeCount].countryCode, |
| 4392 | pCountryCode, 3 ); |
| 4393 | pMac->scan.votes11d[pMac->scan.countryCodeCount].votes = 1; |
| 4394 | pMac->scan.countryCodeCount++; |
| 4395 | } |
| 4396 | |
| 4397 | return; |
| 4398 | } |
| 4399 | |
| 4400 | tANI_BOOLEAN csrElectedCountryInfo(tpAniSirGlobal pMac) |
| 4401 | { |
| 4402 | tANI_BOOLEAN fRet = FALSE; |
| 4403 | tANI_U8 maxVotes = 0; |
| 4404 | tANI_U8 i, j=0; |
| 4405 | |
| 4406 | if (!pMac->scan.countryCodeCount) |
| 4407 | { |
Agrawal Ashish | bd3a593 | 2016-04-12 16:22:39 +0530 | [diff] [blame] | 4408 | VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN, |
| 4409 | "No AP with 11d Country code is present in scan list"); |
Agrawal Ashish | 0b6984f | 2014-04-05 18:35:45 +0530 | [diff] [blame] | 4410 | return fRet; |
| 4411 | } |
| 4412 | maxVotes = pMac->scan.votes11d[0].votes; |
| 4413 | fRet = TRUE; |
| 4414 | |
| 4415 | for(i = 1; i < pMac->scan.countryCodeCount; i++) |
| 4416 | { |
| 4417 | /* If we have a tie for max votes for 2 different country codes, |
| 4418 | * pick random.we can put some more intelligence - TBD |
| 4419 | */ |
| 4420 | if (maxVotes < pMac->scan.votes11d[i].votes) |
| 4421 | { |
| 4422 | VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, |
| 4423 | " Votes for Country %c%c : %d\n", |
| 4424 | pMac->scan.votes11d[i].countryCode[0], |
| 4425 | pMac->scan.votes11d[i].countryCode[1], |
| 4426 | pMac->scan.votes11d[i].votes); |
| 4427 | |
| 4428 | maxVotes = pMac->scan.votes11d[i].votes; |
| 4429 | j = i; |
| 4430 | fRet = TRUE; |
| 4431 | } |
| 4432 | |
| 4433 | } |
| 4434 | if (fRet) |
| 4435 | { |
Rajesh Babu Prathipati | 20cdffa | 2014-07-01 22:24:59 +0530 | [diff] [blame] | 4436 | vos_mem_copy(pMac->scan.countryCodeElected, |
Agrawal Ashish | 0b6984f | 2014-04-05 18:35:45 +0530 | [diff] [blame] | 4437 | pMac->scan.votes11d[j].countryCode, WNI_CFG_COUNTRY_CODE_LEN); |
Rajesh Babu Prathipati | 20cdffa | 2014-07-01 22:24:59 +0530 | [diff] [blame] | 4438 | vos_mem_copy(pMac->scan.countryCode11d, |
Agarwal Ashish | 852b2c3 | 2014-05-23 17:13:25 +0530 | [diff] [blame] | 4439 | pMac->scan.votes11d[j].countryCode, WNI_CFG_COUNTRY_CODE_LEN); |
Agrawal Ashish | 0b6984f | 2014-04-05 18:35:45 +0530 | [diff] [blame] | 4440 | VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, |
| 4441 | "Selected Country is %c%c With count %d\n", |
| 4442 | pMac->scan.votes11d[j].countryCode[0], |
| 4443 | pMac->scan.votes11d[j].countryCode[1], |
| 4444 | pMac->scan.votes11d[j].votes); |
| 4445 | } |
| 4446 | return fRet; |
| 4447 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4448 | |
| 4449 | eHalStatus csrSetCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry, tANI_BOOLEAN *pfRestartNeeded) |
| 4450 | { |
| 4451 | eHalStatus status = eHAL_STATUS_INVALID_PARAMETER; |
| 4452 | v_REGDOMAIN_t domainId; |
| 4453 | |
| 4454 | if(pCountry) |
| 4455 | { |
Kiet Lam | 6c58333 | 2013-10-14 05:37:09 +0530 | [diff] [blame] | 4456 | status = csrGetRegulatoryDomainForCountry(pMac, pCountry, &domainId, COUNTRY_USER); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4457 | if(HAL_STATUS_SUCCESS(status)) |
| 4458 | { |
| 4459 | status = csrSetRegulatoryDomain(pMac, domainId, pfRestartNeeded); |
| 4460 | if(HAL_STATUS_SUCCESS(status)) |
| 4461 | { |
| 4462 | //We don't need to check the pMac->roam.configParam.fEnforceDefaultDomain flag here, |
| 4463 | //csrSetRegulatoryDomain will fail if the country doesn't fit our domain criteria. |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4464 | vos_mem_copy(pMac->scan.countryCodeCurrent, pCountry, WNI_CFG_COUNTRY_CODE_LEN); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4465 | if((pfRestartNeeded == NULL) || !(*pfRestartNeeded)) |
| 4466 | { |
| 4467 | //Simply set it to cfg. If we need to restart, restart will apply it to the CFG |
| 4468 | csrSetCfgCountryCode(pMac, pCountry); |
| 4469 | } |
| 4470 | } |
| 4471 | } |
| 4472 | } |
| 4473 | |
| 4474 | return (status); |
| 4475 | } |
| 4476 | |
| 4477 | |
| 4478 | |
| 4479 | //caller allocated memory for pNumChn and pChnPowerInfo |
| 4480 | //As input, *pNumChn has the size of the array of pChnPowerInfo |
| 4481 | //Upon return, *pNumChn has the number of channels assigned. |
| 4482 | void csrGetChannelPowerInfo( tpAniSirGlobal pMac, tDblLinkList *pList, |
| 4483 | tANI_U32 *pNumChn, tChannelListWithPower *pChnPowerInfo) |
| 4484 | { |
| 4485 | tListElem *pEntry; |
| 4486 | tANI_U32 chnIdx = 0, idx; |
| 4487 | tCsrChannelPowerInfo *pChannelSet; |
| 4488 | |
| 4489 | //Get 2.4Ghz first |
| 4490 | pEntry = csrLLPeekHead( pList, LL_ACCESS_LOCK ); |
| 4491 | while( pEntry && (chnIdx < *pNumChn) ) |
| 4492 | { |
| 4493 | pChannelSet = GET_BASE_ADDR( pEntry, tCsrChannelPowerInfo, link ); |
| 4494 | if ( 1 != pChannelSet->interChannelOffset ) |
| 4495 | { |
| 4496 | for( idx = 0; (idx < pChannelSet->numChannels) && (chnIdx < *pNumChn); idx++ ) |
| 4497 | { |
| 4498 | pChnPowerInfo[chnIdx].chanId = (tANI_U8)(pChannelSet->firstChannel + ( idx * pChannelSet->interChannelOffset )); |
| 4499 | pChnPowerInfo[chnIdx++].pwr = pChannelSet->txPower; |
| 4500 | } |
| 4501 | } |
| 4502 | else |
| 4503 | { |
| 4504 | for( idx = 0; (idx < pChannelSet->numChannels) && (chnIdx < *pNumChn); idx++ ) |
| 4505 | { |
| 4506 | pChnPowerInfo[chnIdx].chanId = (tANI_U8)(pChannelSet->firstChannel + idx); |
| 4507 | pChnPowerInfo[chnIdx++].pwr = pChannelSet->txPower; |
| 4508 | } |
| 4509 | } |
| 4510 | |
| 4511 | pEntry = csrLLNext( pList, pEntry, LL_ACCESS_LOCK ); |
| 4512 | } |
| 4513 | *pNumChn = chnIdx; |
| 4514 | |
| 4515 | return ; |
| 4516 | } |
| 4517 | |
| 4518 | |
| 4519 | |
| 4520 | void csrApplyCountryInformation( tpAniSirGlobal pMac, tANI_BOOLEAN fForce ) |
| 4521 | { |
| 4522 | v_REGDOMAIN_t domainId; |
| 4523 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 4524 | |
| 4525 | do |
| 4526 | { |
| 4527 | if( !csrIs11dSupported( pMac ) || 0 == pMac->scan.channelOf11dInfo) break; |
| 4528 | if( pMac->scan.fAmbiguous11dInfoFound ) |
| 4529 | { |
| 4530 | // ambiguous info found |
| 4531 | //Restore te default domain as well |
Kiet Lam | 6c58333 | 2013-10-14 05:37:09 +0530 | [diff] [blame] | 4532 | if(HAL_STATUS_SUCCESS(csrGetRegulatoryDomainForCountry( |
| 4533 | pMac, pMac->scan.countryCodeCurrent, |
| 4534 | &domainId, COUNTRY_QUERY))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4535 | { |
| 4536 | pMac->scan.domainIdCurrent = domainId; |
| 4537 | } |
| 4538 | else |
| 4539 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 4540 | smsLog(pMac, LOGE, FL(" failed to get domain from currentCountryCode %02X%02X"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4541 | pMac->scan.countryCodeCurrent[0], pMac->scan.countryCodeCurrent[1]); |
| 4542 | } |
Gopichand Nakkala | b9185f2 | 2012-12-21 08:03:42 -0800 | [diff] [blame] | 4543 | csrResetCountryInformation( pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_TRUE ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4544 | break; |
| 4545 | } |
| 4546 | if ( pMac->scan.f11dInfoApplied && !fForce ) break; |
Kiet Lam | 6c58333 | 2013-10-14 05:37:09 +0530 | [diff] [blame] | 4547 | if(HAL_STATUS_SUCCESS(csrGetRegulatoryDomainForCountry( |
| 4548 | pMac, pMac->scan.countryCode11d, |
| 4549 | &domainId, COUNTRY_QUERY))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4550 | { |
| 4551 | //Check whether we need to enforce default domain |
| 4552 | if( ( !pMac->roam.configParam.fEnforceDefaultDomain ) || |
| 4553 | (pMac->scan.domainIdCurrent == domainId) ) |
| 4554 | { |
| 4555 | |
| 4556 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 4557 | { |
| 4558 | vos_log_802_11d_pkt_type *p11dLog; |
| 4559 | tChannelListWithPower chnPwrInfo[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 4560 | tANI_U32 nChnInfo = WNI_CFG_VALID_CHANNEL_LIST_LEN, nTmp; |
| 4561 | |
| 4562 | WLAN_VOS_DIAG_LOG_ALLOC(p11dLog, vos_log_802_11d_pkt_type, LOG_WLAN_80211D_C); |
| 4563 | if(p11dLog) |
| 4564 | { |
| 4565 | p11dLog->eventId = WLAN_80211D_EVENT_COUNTRY_SET; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4566 | vos_mem_copy(p11dLog->countryCode, pMac->scan.countryCode11d, 3); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4567 | p11dLog->numChannel = pMac->scan.channels11d.numChannels; |
| 4568 | if(p11dLog->numChannel <= VOS_LOG_MAX_NUM_CHANNEL) |
| 4569 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4570 | vos_mem_copy(p11dLog->Channels, |
| 4571 | pMac->scan.channels11d.channelList, |
| 4572 | p11dLog->numChannel); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4573 | csrGetChannelPowerInfo(pMac, &pMac->scan.channelPowerInfoList24, |
| 4574 | &nChnInfo, chnPwrInfo); |
| 4575 | nTmp = nChnInfo; |
| 4576 | nChnInfo = WNI_CFG_VALID_CHANNEL_LIST_LEN - nTmp; |
| 4577 | csrGetChannelPowerInfo(pMac, &pMac->scan.channelPowerInfoList5G, |
| 4578 | &nChnInfo, &chnPwrInfo[nTmp]); |
| 4579 | for(nTmp = 0; nTmp < p11dLog->numChannel; nTmp++) |
| 4580 | { |
| 4581 | for(nChnInfo = 0; nChnInfo < WNI_CFG_VALID_CHANNEL_LIST_LEN; nChnInfo++) |
| 4582 | { |
| 4583 | if(p11dLog->Channels[nTmp] == chnPwrInfo[nChnInfo].chanId) |
| 4584 | { |
| 4585 | p11dLog->TxPwr[nTmp] = chnPwrInfo[nChnInfo].pwr; |
| 4586 | break; |
| 4587 | } |
| 4588 | } |
| 4589 | } |
| 4590 | } |
| 4591 | if(!pMac->roam.configParam.Is11dSupportEnabled) |
| 4592 | { |
| 4593 | p11dLog->supportMultipleDomain = WLAN_80211D_DISABLED; |
| 4594 | } |
| 4595 | else if(pMac->roam.configParam.fEnforceDefaultDomain) |
| 4596 | { |
| 4597 | p11dLog->supportMultipleDomain = WLAN_80211D_NOT_SUPPORT_MULTI_DOMAIN; |
| 4598 | } |
| 4599 | else |
| 4600 | { |
| 4601 | p11dLog->supportMultipleDomain = WLAN_80211D_SUPPORT_MULTI_DOMAIN; |
| 4602 | } |
| 4603 | WLAN_VOS_DIAG_LOG_REPORT(p11dLog); |
| 4604 | } |
| 4605 | } |
| 4606 | #endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 4607 | if(pMac->scan.domainIdCurrent != domainId) |
| 4608 | { |
Sushant Kaushik | e0d2cce | 2014-04-10 14:36:07 +0530 | [diff] [blame] | 4609 | smsLog(pMac, LOGW, FL("Domain Changed Old %s (%d), new %s"), |
| 4610 | voss_DomainIdtoString(pMac->scan.domainIdCurrent), |
| 4611 | pMac->scan.domainIdCurrent, |
| 4612 | voss_DomainIdtoString(domainId)); |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 4613 | status = WDA_SetRegDomain(pMac, domainId, eSIR_TRUE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4614 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4615 | if (status != eHAL_STATUS_SUCCESS) |
| 4616 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 4617 | smsLog( pMac, LOGE, FL(" fail to set regId %d"), domainId ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4618 | } |
| 4619 | pMac->scan.domainIdCurrent = domainId; |
Kiet Lam | 6c58333 | 2013-10-14 05:37:09 +0530 | [diff] [blame] | 4620 | #ifndef CONFIG_ENABLE_LINUX_REG |
Kiet Lam | bb14e95 | 2013-11-19 14:58:29 +0530 | [diff] [blame] | 4621 | csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, |
| 4622 | pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE ); |
Kiet Lam | 6c58333 | 2013-10-14 05:37:09 +0530 | [diff] [blame] | 4623 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4624 | // switch to active scans using this new channel list |
| 4625 | pMac->scan.curScanType = eSIR_ACTIVE_SCAN; |
| 4626 | pMac->scan.f11dInfoApplied = eANI_BOOLEAN_TRUE; |
| 4627 | pMac->scan.f11dInfoReset = eANI_BOOLEAN_FALSE; |
| 4628 | } |
| 4629 | } |
| 4630 | |
| 4631 | } while( 0 ); |
| 4632 | |
| 4633 | return; |
| 4634 | } |
| 4635 | |
| 4636 | |
| 4637 | |
| 4638 | tANI_BOOLEAN csrSave11dCountryString( tpAniSirGlobal pMac, tANI_U8 *pCountryCode, |
| 4639 | tANI_BOOLEAN fForce) |
| 4640 | { |
| 4641 | tANI_BOOLEAN fCountryStringChanged = FALSE, fUnknownCountryCode = FALSE; |
| 4642 | tANI_U32 i; |
Kiet Lam | 6c58333 | 2013-10-14 05:37:09 +0530 | [diff] [blame] | 4643 | v_REGDOMAIN_t regd; |
Tushnim Bhattacharyya | 582ac1d | 2013-11-07 23:44:09 -0800 | [diff] [blame] | 4644 | tANI_BOOLEAN fCountryNotPresentInDriver = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4645 | |
| 4646 | // convert to UPPER here so we are assured the strings are always in upper case. |
| 4647 | for( i = 0; i < 3; i++ ) |
| 4648 | { |
| 4649 | pCountryCode[ i ] = (tANI_U8)csrToUpper( pCountryCode[ i ] ); |
| 4650 | } |
| 4651 | |
| 4652 | // Some of the 'old' Cisco 350 series AP's advertise NA as the country code (for North America ??). |
| 4653 | // NA is not a valid country code or domain so let's allow this by changing it to the proper |
| 4654 | // country code (which is US). We've also seen some NETGEAR AP's that have "XX " as the country code |
| 4655 | // with valid 2.4 GHz US channel information. If we cannot find the country code advertised in the |
| 4656 | // 11d information element, let's default to US. |
Kiet Lam | 6c58333 | 2013-10-14 05:37:09 +0530 | [diff] [blame] | 4657 | if ( !HAL_STATUS_SUCCESS(csrGetRegulatoryDomainForCountry(pMac, |
| 4658 | pCountryCode, |
| 4659 | ®d, |
| 4660 | COUNTRY_QUERY) ) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4661 | { |
| 4662 | // Check the enforcement first |
| 4663 | if( pMac->roam.configParam.fEnforceDefaultDomain || pMac->roam.configParam.fEnforceCountryCodeMatch ) |
| 4664 | { |
| 4665 | fUnknownCountryCode = TRUE; |
| 4666 | } |
| 4667 | else |
| 4668 | { |
Tushnim Bhattacharyya | 582ac1d | 2013-11-07 23:44:09 -0800 | [diff] [blame] | 4669 | fCountryNotPresentInDriver = TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4670 | } |
| 4671 | } |
Tushnim Bhattacharyya | c3c1e8e | 2013-10-29 17:27:43 -0700 | [diff] [blame] | 4672 | //right now, even if we don't find the CC in driver we set to world. Making |
| 4673 | //sure countryCode11d doesn't get updated with the invalid CC, instead |
| 4674 | //reflect the world CC |
| 4675 | else if (REGDOMAIN_WORLD == regd) |
| 4676 | { |
Tushnim Bhattacharyya | 582ac1d | 2013-11-07 23:44:09 -0800 | [diff] [blame] | 4677 | fCountryNotPresentInDriver = TRUE; |
Tushnim Bhattacharyya | c3c1e8e | 2013-10-29 17:27:43 -0700 | [diff] [blame] | 4678 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4679 | |
| 4680 | // We've seen some of the AP's improperly put a 0 for the third character of the country code. |
| 4681 | // spec says valid charcters are 'O' (for outdoor), 'I' for Indoor, or ' ' (space; for either). |
| 4682 | // if we see a 0 in this third character, let's change it to a ' '. |
| 4683 | if ( 0 == pCountryCode[ 2 ] ) |
| 4684 | { |
| 4685 | pCountryCode[ 2 ] = ' '; |
| 4686 | } |
| 4687 | |
| 4688 | if( !fUnknownCountryCode ) |
| 4689 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4690 | fCountryStringChanged = (!vos_mem_compare(pMac->scan.countryCode11d, pCountryCode, 2)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4691 | |
| 4692 | |
| 4693 | if(( 0 == pMac->scan.countryCode11d[ 0 ] && 0 == pMac->scan.countryCode11d[ 1 ] ) |
| 4694 | || (fForce)) |
| 4695 | { |
Tushnim Bhattacharyya | 582ac1d | 2013-11-07 23:44:09 -0800 | [diff] [blame] | 4696 | if (!fCountryNotPresentInDriver) |
| 4697 | { |
| 4698 | // this is the first .11d information |
| 4699 | vos_mem_copy(pMac->scan.countryCode11d, pCountryCode, |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4700 | sizeof( pMac->scan.countryCode11d )); |
Tushnim Bhattacharyya | 582ac1d | 2013-11-07 23:44:09 -0800 | [diff] [blame] | 4701 | |
| 4702 | } |
| 4703 | else |
| 4704 | { |
| 4705 | pMac->scan.countryCode11d[0] = '0'; |
| 4706 | pMac->scan.countryCode11d[1] = '0'; |
| 4707 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4708 | } |
| 4709 | } |
| 4710 | |
| 4711 | return( fCountryStringChanged ); |
| 4712 | } |
| 4713 | |
| 4714 | |
| 4715 | void csrSaveChannelPowerForBand( tpAniSirGlobal pMac, tANI_BOOLEAN fPopulate5GBand ) |
| 4716 | { |
| 4717 | tANI_U32 Index, count=0; |
| 4718 | tSirMacChanInfo *pChanInfo; |
| 4719 | tSirMacChanInfo *pChanInfoStart; |
Leela V Kiran Kumar Reddy Chirala | 6a45875 | 2013-02-16 15:41:27 -0800 | [diff] [blame] | 4720 | tANI_S32 maxChannelIndex; |
| 4721 | |
| 4722 | maxChannelIndex = ( pMac->scan.base20MHzChannels.numChannels < WNI_CFG_VALID_CHANNEL_LIST_LEN ) ? |
| 4723 | pMac->scan.base20MHzChannels.numChannels : WNI_CFG_VALID_CHANNEL_LIST_LEN ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4724 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4725 | pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 4726 | if ( NULL != pChanInfo ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4727 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4728 | 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] | 4729 | pChanInfoStart = pChanInfo; |
Leela V Kiran Kumar Reddy Chirala | 6a45875 | 2013-02-16 15:41:27 -0800 | [diff] [blame] | 4730 | for (Index=0; Index < maxChannelIndex; Index++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4731 | { |
| 4732 | if ((fPopulate5GBand && (CSR_IS_CHANNEL_5GHZ(pMac->scan.defaultPowerTable[Index].chanId))) || |
| 4733 | (!fPopulate5GBand && (CSR_IS_CHANNEL_24GHZ(pMac->scan.defaultPowerTable[Index].chanId))) ) |
| 4734 | { |
Leela V Kiran Kumar Reddy Chirala | 6a45875 | 2013-02-16 15:41:27 -0800 | [diff] [blame] | 4735 | if(count >= WNI_CFG_VALID_CHANNEL_LIST_LEN) |
| 4736 | { |
| 4737 | smsLog( pMac, LOGW, FL(" csrSaveChannelPowerForBand, count exceeded, count = %d"), count); |
| 4738 | break; |
| 4739 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4740 | pChanInfo->firstChanNum = pMac->scan.defaultPowerTable[Index].chanId; |
| 4741 | pChanInfo->numChannels = 1; |
| 4742 | pChanInfo->maxTxPower = CSR_ROAM_MIN( pMac->scan.defaultPowerTable[Index].pwr, pMac->roam.configParam.nTxPowerCap ); |
| 4743 | pChanInfo++; |
| 4744 | count++; |
| 4745 | } |
| 4746 | } |
| 4747 | if(count) |
| 4748 | { |
| 4749 | csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart ); |
| 4750 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4751 | vos_mem_free(pChanInfoStart); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4752 | } |
| 4753 | } |
| 4754 | |
| 4755 | |
| 4756 | void csrSetOppositeBandChannelInfo( tpAniSirGlobal pMac ) |
| 4757 | { |
| 4758 | tANI_BOOLEAN fPopulate5GBand = FALSE; |
| 4759 | |
| 4760 | do |
| 4761 | { |
| 4762 | // if this is not a dual band product, then we don't need to set the opposite |
| 4763 | // band info. We only work in one band so no need to look in the other band. |
| 4764 | if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) ) break; |
| 4765 | // if we found channel info on the 5.0 band and... |
| 4766 | if ( CSR_IS_CHANNEL_5GHZ( pMac->scan.channelOf11dInfo ) ) |
| 4767 | { |
| 4768 | // 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] | 4769 | if ( !csrLLIsListEmpty( &pMac->scan.channelPowerInfoList24, LL_ACCESS_LOCK ) ) break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4770 | fPopulate5GBand = FALSE; |
| 4771 | } |
| 4772 | else |
| 4773 | { |
| 4774 | // else, we found channel info in the 2.4 GHz band. If the 5.0 band is empty |
| 4775 | // set the 5.0 band info from the 2.4 country code. |
Kiet Lam | 8d985a0 | 2013-10-11 03:39:41 +0530 | [diff] [blame] | 4776 | if ( !csrLLIsListEmpty( &pMac->scan.channelPowerInfoList5G, LL_ACCESS_LOCK ) ) break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4777 | fPopulate5GBand = TRUE; |
| 4778 | } |
| 4779 | csrSaveChannelPowerForBand( pMac, fPopulate5GBand ); |
| 4780 | |
| 4781 | } while( 0 ); |
| 4782 | } |
| 4783 | |
| 4784 | |
| 4785 | tANI_BOOLEAN csrIsSupportedChannel(tpAniSirGlobal pMac, tANI_U8 channelId) |
| 4786 | { |
| 4787 | tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE; |
| 4788 | tANI_U32 i; |
| 4789 | |
| 4790 | //Make sure it is a channel that is in our supported list. |
| 4791 | for ( i = 0; i < pMac->scan.baseChannels.numChannels; i++ ) |
| 4792 | { |
| 4793 | if ( channelId == pMac->scan.baseChannels.channelList[i] ) |
| 4794 | { |
| 4795 | fRet = eANI_BOOLEAN_TRUE; |
| 4796 | break; |
| 4797 | } |
| 4798 | } |
| 4799 | |
| 4800 | //If it is configured to limit a set of the channels |
| 4801 | if( fRet && pMac->roam.configParam.fEnforce11dChannels ) |
| 4802 | { |
| 4803 | fRet = eANI_BOOLEAN_FALSE; |
| 4804 | for ( i = 0; i < pMac->scan.base20MHzChannels.numChannels; i++ ) |
| 4805 | { |
| 4806 | if ( channelId == pMac->scan.base20MHzChannels.channelList[i] ) |
| 4807 | { |
| 4808 | fRet = eANI_BOOLEAN_TRUE; |
| 4809 | break; |
| 4810 | } |
| 4811 | } |
| 4812 | } |
| 4813 | |
| 4814 | return (fRet); |
| 4815 | } |
| 4816 | |
| 4817 | |
| 4818 | |
| 4819 | //bSize specify the buffer size of pChannelList |
| 4820 | tANI_U8 csrGetChannelListFromChannelSet( tpAniSirGlobal pMac, tANI_U8 *pChannelList, tANI_U8 bSize, tCsrChannelPowerInfo *pChannelSet ) |
| 4821 | { |
| 4822 | tANI_U8 i, j = 0, chnId; |
| 4823 | |
| 4824 | bSize = CSR_MIN(bSize, pChannelSet->numChannels); |
| 4825 | for( i = 0; i < bSize; i++ ) |
| 4826 | { |
| 4827 | chnId = (tANI_U8)(pChannelSet->firstChannel + ( i * pChannelSet->interChannelOffset )); |
| 4828 | if ( csrIsSupportedChannel( pMac, chnId ) ) |
| 4829 | { |
| 4830 | pChannelList[j++] = chnId; |
| 4831 | } |
| 4832 | } |
| 4833 | |
| 4834 | return (j); |
| 4835 | } |
| 4836 | |
| 4837 | |
| 4838 | |
| 4839 | //bSize -- specify the buffer size of pChannelList |
| 4840 | void csrConstructCurrentValidChannelList( tpAniSirGlobal pMac, tDblLinkList *pChannelSetList, |
| 4841 | tANI_U8 *pChannelList, tANI_U8 bSize, tANI_U8 *pNumChannels ) |
| 4842 | { |
| 4843 | tListElem *pEntry; |
| 4844 | tCsrChannelPowerInfo *pChannelSet; |
| 4845 | tANI_U8 numChannels; |
| 4846 | tANI_U8 *pChannels; |
| 4847 | |
| 4848 | if( pChannelSetList && pChannelList && pNumChannels ) |
| 4849 | { |
| 4850 | pChannels = pChannelList; |
| 4851 | *pNumChannels = 0; |
| 4852 | pEntry = csrLLPeekHead( pChannelSetList, LL_ACCESS_LOCK ); |
| 4853 | while( pEntry ) |
| 4854 | { |
| 4855 | pChannelSet = GET_BASE_ADDR( pEntry, tCsrChannelPowerInfo, link ); |
| 4856 | numChannels = csrGetChannelListFromChannelSet( pMac, pChannels, bSize, pChannelSet ); |
| 4857 | pChannels += numChannels; |
| 4858 | *pNumChannels += numChannels; |
| 4859 | pEntry = csrLLNext( pChannelSetList, pEntry, LL_ACCESS_LOCK ); |
| 4860 | } |
| 4861 | } |
| 4862 | } |
| 4863 | |
| 4864 | |
| 4865 | /* |
| 4866 | * 802.11D only: Gather 11d IE via beacon or Probe response and store them in pAdapter->channels11d |
| 4867 | */ |
Chandrasekaran, Manishekar | 90c4932 | 2014-06-24 13:26:14 +0530 | [diff] [blame] | 4868 | tANI_BOOLEAN csrLearnCountryInformation( tpAniSirGlobal pMac, tSirBssDescription *pSirBssDesc, |
| 4869 | tDot11fBeaconIEs *pIes, tANI_BOOLEAN fForce) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4870 | { |
Agarwal Ashish | 60a37ee | 2014-05-28 17:20:20 +0530 | [diff] [blame] | 4871 | eHalStatus status; |
Chandrasekaran, Manishekar | 90c4932 | 2014-06-24 13:26:14 +0530 | [diff] [blame] | 4872 | tANI_U8 *pCountryCodeSelected; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4873 | tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE; |
| 4874 | v_REGDOMAIN_t domainId; |
Chandrasekaran, Manishekar | 90c4932 | 2014-06-24 13:26:14 +0530 | [diff] [blame] | 4875 | tDot11fBeaconIEs *pIesLocal = pIes; |
| 4876 | tANI_BOOLEAN useVoting = eANI_BOOLEAN_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4877 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4878 | if (VOS_STA_SAP_MODE == vos_get_conparam ()) |
| 4879 | return eHAL_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4880 | |
Chandrasekaran, Manishekar | 90c4932 | 2014-06-24 13:26:14 +0530 | [diff] [blame] | 4881 | if ((NULL == pSirBssDesc) && (NULL == pIes)) |
| 4882 | useVoting = eANI_BOOLEAN_TRUE; |
| 4883 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4884 | do |
| 4885 | { |
| 4886 | // check if .11d support is enabled |
| 4887 | if( !csrIs11dSupported( pMac ) ) break; |
Agarwal Ashish | 60a37ee | 2014-05-28 17:20:20 +0530 | [diff] [blame] | 4888 | |
Chandrasekaran, Manishekar | 90c4932 | 2014-06-24 13:26:14 +0530 | [diff] [blame] | 4889 | if (eANI_BOOLEAN_FALSE == useVoting) |
| 4890 | { |
| 4891 | if( !pIesLocal && |
| 4892 | (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, |
| 4893 | pSirBssDesc, &pIesLocal)))) |
| 4894 | { |
| 4895 | break; |
| 4896 | } |
| 4897 | // check if country information element is present |
| 4898 | if(!pIesLocal->Country.present) |
| 4899 | { |
| 4900 | //No country info |
| 4901 | break; |
| 4902 | } |
| 4903 | |
| 4904 | if( HAL_STATUS_SUCCESS(csrGetRegulatoryDomainForCountry |
| 4905 | (pMac, pIesLocal->Country.country, &domainId, |
| 4906 | COUNTRY_QUERY)) && |
| 4907 | ( domainId == REGDOMAIN_WORLD)) |
| 4908 | { |
| 4909 | break; |
| 4910 | } |
| 4911 | } //useVoting == eANI_BOOLEAN_FALSE |
| 4912 | |
| 4913 | if (eANI_BOOLEAN_FALSE == useVoting) |
| 4914 | pCountryCodeSelected = pIesLocal->Country.country; |
| 4915 | else |
| 4916 | pCountryCodeSelected = pMac->scan.countryCodeElected; |
| 4917 | |
Kiet Lam | 8d985a0 | 2013-10-11 03:39:41 +0530 | [diff] [blame] | 4918 | status = csrGetRegulatoryDomainForCountry(pMac, |
Chandrasekaran, Manishekar | 90c4932 | 2014-06-24 13:26:14 +0530 | [diff] [blame] | 4919 | pCountryCodeSelected, &domainId, COUNTRY_IE); |
Kiet Lam | 8d985a0 | 2013-10-11 03:39:41 +0530 | [diff] [blame] | 4920 | if ( status != eHAL_STATUS_SUCCESS ) |
| 4921 | { |
| 4922 | smsLog( pMac, LOGE, FL(" fail to get regId %d"), domainId ); |
| 4923 | fRet = eANI_BOOLEAN_FALSE; |
| 4924 | break; |
| 4925 | } |
Agarwal Ashish | 7693f2d | 2014-07-18 18:03:58 +0530 | [diff] [blame] | 4926 | |
| 4927 | /* updating 11d Country Code with Country code selected. */ |
| 4928 | |
| 4929 | vos_mem_copy(pMac->scan.countryCode11d, |
| 4930 | pCountryCodeSelected, |
| 4931 | WNI_CFG_COUNTRY_CODE_LEN); |
| 4932 | |
Agarwal Ashish | 60a37ee | 2014-05-28 17:20:20 +0530 | [diff] [blame] | 4933 | #ifndef CONFIG_ENABLE_LINUX_REG |
Venkata Prathyusha Kuntupalli | 316247e | 2013-03-15 17:45:25 -0700 | [diff] [blame] | 4934 | // Checking for Domain Id change |
| 4935 | if ( domainId != pMac->scan.domainIdCurrent ) |
| 4936 | { |
Kiet Lam | 8d985a0 | 2013-10-11 03:39:41 +0530 | [diff] [blame] | 4937 | vos_mem_copy(pMac->scan.countryCode11d, |
Chandrasekaran, Manishekar | 90c4932 | 2014-06-24 13:26:14 +0530 | [diff] [blame] | 4938 | pCountryCodeSelected, |
Kiet Lam | 8d985a0 | 2013-10-11 03:39:41 +0530 | [diff] [blame] | 4939 | sizeof( pMac->scan.countryCode11d ) ); |
| 4940 | /* Set Current Country code and Current Regulatory domain */ |
| 4941 | status = csrSetRegulatoryDomain(pMac, domainId, NULL); |
| 4942 | if (eHAL_STATUS_SUCCESS != status) |
| 4943 | { |
| 4944 | smsLog(pMac, LOGE, "Set Reg Domain Fail %d", status); |
| 4945 | fRet = eANI_BOOLEAN_FALSE; |
| 4946 | return fRet; |
| 4947 | } |
| 4948 | //csrSetRegulatoryDomain will fail if the country doesn't fit our domain criteria. |
| 4949 | vos_mem_copy(pMac->scan.countryCodeCurrent, |
Chandrasekaran, Manishekar | 90c4932 | 2014-06-24 13:26:14 +0530 | [diff] [blame] | 4950 | pCountryCodeSelected, WNI_CFG_COUNTRY_CODE_LEN); |
Kiet Lam | 8d985a0 | 2013-10-11 03:39:41 +0530 | [diff] [blame] | 4951 | //Simply set it to cfg. |
Chandrasekaran, Manishekar | 90c4932 | 2014-06-24 13:26:14 +0530 | [diff] [blame] | 4952 | csrSetCfgCountryCode(pMac, pCountryCodeSelected); |
Kiet Lam | 8d985a0 | 2013-10-11 03:39:41 +0530 | [diff] [blame] | 4953 | |
| 4954 | /* overwrite the defualt country code */ |
| 4955 | vos_mem_copy(pMac->scan.countryCodeDefault, |
| 4956 | pMac->scan.countryCodeCurrent, |
| 4957 | WNI_CFG_COUNTRY_CODE_LEN); |
| 4958 | /* Set Current RegDomain */ |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 4959 | status = WDA_SetRegDomain(pMac, domainId, eSIR_TRUE); |
Kiet Lam | 8d985a0 | 2013-10-11 03:39:41 +0530 | [diff] [blame] | 4960 | if ( status != eHAL_STATUS_SUCCESS ) |
| 4961 | { |
| 4962 | smsLog( pMac, LOGE, FL(" fail to Set regId %d"), domainId ); |
| 4963 | fRet = eANI_BOOLEAN_FALSE; |
| 4964 | return fRet; |
| 4965 | } |
| 4966 | /* set to default domain ID */ |
Madan Mohan Koyyalamudi | 0e5922d | 2013-09-10 15:45:24 +0530 | [diff] [blame] | 4967 | pMac->scan.domainIdCurrent = domainId; |
Kiet Lam | 8d985a0 | 2013-10-11 03:39:41 +0530 | [diff] [blame] | 4968 | /* get the channels based on new cc */ |
| 4969 | status = csrInitGetChannels( pMac ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4970 | |
Kiet Lam | 8d985a0 | 2013-10-11 03:39:41 +0530 | [diff] [blame] | 4971 | if ( status != eHAL_STATUS_SUCCESS ) |
| 4972 | { |
| 4973 | smsLog( pMac, LOGE, FL(" fail to get Channels ")); |
| 4974 | fRet = eANI_BOOLEAN_FALSE; |
| 4975 | return fRet; |
| 4976 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4977 | |
Kiet Lam | 8d985a0 | 2013-10-11 03:39:41 +0530 | [diff] [blame] | 4978 | /* reset info based on new cc, and we are done */ |
| 4979 | csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE); |
Agarwal Ashish | faef669 | 2014-01-29 19:40:30 +0530 | [diff] [blame] | 4980 | /* Regulatory Domain Changed, Purge Only scan result |
| 4981 | * which does not have channel number belong to 11d |
| 4982 | * channel list |
| 4983 | */ |
Srinivas, Dasari | 42bf770 | 2014-02-07 11:29:53 +0530 | [diff] [blame] | 4984 | csrScanFilterResults(pMac); |
Kiet Lam | 8d985a0 | 2013-10-11 03:39:41 +0530 | [diff] [blame] | 4985 | } |
Kiet Lam | 6c58333 | 2013-10-14 05:37:09 +0530 | [diff] [blame] | 4986 | #endif |
| 4987 | fRet = eANI_BOOLEAN_TRUE; |
| 4988 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4989 | } while( 0 ); |
Chandrasekaran, Manishekar | 90c4932 | 2014-06-24 13:26:14 +0530 | [diff] [blame] | 4990 | |
| 4991 | if( !pIes && pIesLocal ) |
| 4992 | { |
| 4993 | //locally allocated |
| 4994 | vos_mem_free(pIesLocal); |
| 4995 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4996 | |
| 4997 | return( fRet ); |
| 4998 | } |
| 4999 | |
| 5000 | |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 5001 | static void csrSaveScanResults( tpAniSirGlobal pMac, tANI_U8 reason ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5002 | { |
| 5003 | // initialize this to FALSE. profMoveInterimScanResultsToMainList() routine |
| 5004 | // will set this to the channel where an .11d beacon is seen |
| 5005 | pMac->scan.channelOf11dInfo = 0; |
| 5006 | // if we get any ambiguous .11d information then this will be set to TRUE |
| 5007 | pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE; |
| 5008 | //Tush |
| 5009 | // if we get any ambiguous .11d information, then this will be set to TRUE |
| 5010 | // only if the applied 11d info could be found in one of the scan results |
| 5011 | pMac->scan.fCurrent11dInfoMatch = eANI_BOOLEAN_FALSE; |
| 5012 | // 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] | 5013 | csrMoveTempScanResultsToMainList( pMac, reason ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5014 | } |
| 5015 | |
| 5016 | |
| 5017 | void csrReinitScanCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
| 5018 | { |
| 5019 | switch (pCommand->u.scanCmd.reason) |
| 5020 | { |
| 5021 | case eCsrScanSetBGScanParam: |
| 5022 | case eCsrScanAbortBgScan: |
| 5023 | if(pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList) |
| 5024 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5025 | vos_mem_free(pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5026 | pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList = NULL; |
| 5027 | } |
| 5028 | break; |
| 5029 | case eCsrScanBGScanAbort: |
| 5030 | case eCsrScanBGScanEnable: |
| 5031 | case eCsrScanGetScanChnInfo: |
| 5032 | break; |
| 5033 | case eCsrScanAbortNormalScan: |
| 5034 | default: |
| 5035 | csrScanFreeRequest(pMac, &pCommand->u.scanCmd.u.scanRequest); |
| 5036 | break; |
| 5037 | } |
| 5038 | if(pCommand->u.scanCmd.pToRoamProfile) |
| 5039 | { |
| 5040 | csrReleaseProfile(pMac, pCommand->u.scanCmd.pToRoamProfile); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5041 | vos_mem_free(pCommand->u.scanCmd.pToRoamProfile); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5042 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5043 | vos_mem_set(&pCommand->u.scanCmd, sizeof(tScanCmd), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5044 | } |
| 5045 | |
| 5046 | |
| 5047 | tANI_BOOLEAN csrGetRemainingChannelsFor11dScan( tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U8 *pcChannels ) |
| 5048 | { |
| 5049 | tANI_U32 index11dChannels, index; |
| 5050 | tANI_U32 indexCurrentChannels; |
| 5051 | tANI_BOOLEAN fChannelAlreadyScanned; |
| 5052 | tANI_U32 len = sizeof(pMac->roam.validChannelList); |
| 5053 | |
| 5054 | *pcChannels = 0; |
| 5055 | if ( CSR_IS_11D_INFO_FOUND(pMac) && csrRoamIsChannelValid(pMac, pMac->scan.channelOf11dInfo) ) |
| 5056 | { |
| 5057 | if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len))) |
| 5058 | { |
| 5059 | //Find the channel index where we found the 11d info |
| 5060 | for(index = 0; index < len; index++) |
| 5061 | { |
| 5062 | if(pMac->scan.channelOf11dInfo == pMac->roam.validChannelList[index]) |
| 5063 | break; |
| 5064 | } |
| 5065 | //check whether we found the channel index |
| 5066 | if(index < len) |
| 5067 | { |
| 5068 | // Now, look through the 11d channel list and create a list of all channels in the 11d list that are |
| 5069 | // NOT in the current channel list. This gives us a list of the new channels that have not been |
| 5070 | // scanned. We'll scan this new list so we have a complete set of scan results on all of the domain channels |
| 5071 | // initially. |
| 5072 | for ( index11dChannels = 0; index11dChannels < pMac->scan.channels11d.numChannels; index11dChannels++ ) |
| 5073 | { |
| 5074 | fChannelAlreadyScanned = eANI_BOOLEAN_FALSE; |
| 5075 | |
| 5076 | for( indexCurrentChannels = 0; indexCurrentChannels < index; indexCurrentChannels++ ) |
| 5077 | { |
| 5078 | if ( pMac->roam.validChannelList[ indexCurrentChannels ] == pMac->scan.channels11d.channelList[ index11dChannels ] ) |
| 5079 | { |
| 5080 | fChannelAlreadyScanned = eANI_BOOLEAN_TRUE; |
| 5081 | break; |
| 5082 | } |
| 5083 | } |
| 5084 | |
| 5085 | if ( !fChannelAlreadyScanned ) |
| 5086 | { |
| 5087 | pChannels[ *pcChannels ] = pMac->scan.channels11d.channelList[ index11dChannels ]; |
| 5088 | ( *pcChannels )++; |
| 5089 | } |
| 5090 | } |
| 5091 | } |
| 5092 | }//GetCFG |
| 5093 | } |
| 5094 | return( *pcChannels ); |
| 5095 | } |
| 5096 | |
| 5097 | |
| 5098 | eCsrScanCompleteNextCommand csrScanGetNextCommandState( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fSuccess ) |
| 5099 | { |
| 5100 | eCsrScanCompleteNextCommand NextCommand = eCsrNextScanNothing; |
| 5101 | |
| 5102 | switch( pCommand->u.scanCmd.reason ) |
| 5103 | { |
| 5104 | case eCsrScan11d1: |
| 5105 | NextCommand = (fSuccess) ? eCsrNext11dScan1Success : eCsrNext11dScan1Failure; |
| 5106 | break; |
| 5107 | case eCsrScan11d2: |
| 5108 | NextCommand = (fSuccess) ? eCsrNext11dScan2Success : eCsrNext11dScan2Failure; |
| 5109 | break; |
| 5110 | case eCsrScan11dDone: |
| 5111 | NextCommand = eCsrNext11dScanComplete; |
| 5112 | break; |
| 5113 | case eCsrScanLostLink1: |
| 5114 | NextCommand = (fSuccess) ? eCsrNextLostLinkScan1Success : eCsrNextLostLinkScan1Failed; |
| 5115 | break; |
| 5116 | case eCsrScanLostLink2: |
| 5117 | NextCommand = (fSuccess) ? eCsrNextLostLinkScan2Success : eCsrNextLostLinkScan2Failed; |
| 5118 | break; |
| 5119 | case eCsrScanLostLink3: |
| 5120 | NextCommand = (fSuccess) ? eCsrNextLostLinkScan3Success : eCsrNextLostLinkScan3Failed; |
| 5121 | break; |
| 5122 | case eCsrScanForSsid: |
| 5123 | NextCommand = (fSuccess) ? eCsrNexteScanForSsidSuccess : eCsrNexteScanForSsidFailure; |
| 5124 | break; |
| 5125 | case eCsrScanForCapsChange: |
| 5126 | NextCommand = eCsrNextCapChangeScanComplete; //don't care success or not |
| 5127 | break; |
| 5128 | case eCsrScanIdleScan: |
| 5129 | NextCommand = eCsrNextIdleScanComplete; |
| 5130 | break; |
| 5131 | default: |
| 5132 | NextCommand = eCsrNextScanNothing; |
| 5133 | break; |
| 5134 | } |
| 5135 | return( NextCommand ); |
| 5136 | } |
| 5137 | |
| 5138 | |
| 5139 | //Return whether the pCommand is finished. |
| 5140 | tANI_BOOLEAN csrHandleScan11d1Failure(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
| 5141 | { |
| 5142 | tANI_BOOLEAN fRet = eANI_BOOLEAN_TRUE; |
| 5143 | |
| 5144 | //Apply back the default setting and passively scan one more time. |
Gopichand Nakkala | b9185f2 | 2012-12-21 08:03:42 -0800 | [diff] [blame] | 5145 | csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_TRUE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5146 | pCommand->u.scanCmd.reason = eCsrScan11d2; |
| 5147 | if(HAL_STATUS_SUCCESS(csrScanChannels(pMac, pCommand))) |
| 5148 | { |
| 5149 | fRet = eANI_BOOLEAN_FALSE; |
| 5150 | } |
| 5151 | |
| 5152 | return (fRet); |
| 5153 | } |
| 5154 | |
| 5155 | |
| 5156 | tANI_BOOLEAN csrHandleScan11dSuccess(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
| 5157 | { |
| 5158 | tANI_BOOLEAN fRet = eANI_BOOLEAN_TRUE; |
| 5159 | tANI_U8 *pChannels; |
| 5160 | tANI_U8 cChannels; |
| 5161 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5162 | pChannels = vos_mem_malloc(WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 5163 | if ( NULL != pChannels ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5164 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5165 | vos_mem_set(pChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5166 | if ( csrGetRemainingChannelsFor11dScan( pMac, pChannels, &cChannels ) ) |
| 5167 | { |
| 5168 | pCommand->u.scanCmd.reason = eCsrScan11dDone; |
| 5169 | if(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList) |
| 5170 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5171 | vos_mem_free(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList); |
James Zmuda | 9ea1edd | 2013-04-18 18:20:54 -0700 | [diff] [blame] | 5172 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5173 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5174 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = vos_mem_malloc(cChannels); |
| 5175 | if ( NULL != pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5176 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5177 | vos_mem_copy(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList, |
| 5178 | pChannels, cChannels); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5179 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = cChannels; |
| 5180 | pCommand->u.scanCmd.u.scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN; |
| 5181 | pCommand->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 5182 | if(HAL_STATUS_SUCCESS(csrScanChannels(pMac, pCommand))) |
| 5183 | { |
| 5184 | //Reuse the same command buffer |
| 5185 | fRet = eANI_BOOLEAN_FALSE; |
| 5186 | } |
| 5187 | } |
| 5188 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5189 | vos_mem_free(pChannels); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5190 | } |
| 5191 | |
| 5192 | return (fRet); |
| 5193 | } |
| 5194 | |
| 5195 | //Return whether the command should be removed |
| 5196 | tANI_BOOLEAN csrScanComplete( tpAniSirGlobal pMac, tSirSmeScanRsp *pScanRsp ) |
| 5197 | { |
| 5198 | eCsrScanCompleteNextCommand NextCommand = eCsrNextScanNothing; |
| 5199 | tListElem *pEntry; |
| 5200 | tSmeCmd *pCommand; |
| 5201 | tANI_BOOLEAN fRemoveCommand = eANI_BOOLEAN_TRUE; |
| 5202 | tANI_BOOLEAN fSuccess; |
| 5203 | |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 5204 | if (pMac->fScanOffload) |
| 5205 | pEntry = csrLLPeekHead(&pMac->sme.smeScanCmdActiveList, LL_ACCESS_LOCK); |
| 5206 | else |
| 5207 | pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5208 | |
| 5209 | if ( pEntry ) |
| 5210 | { |
| 5211 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 5212 | |
| 5213 | // If the head of the queue is Active and it is a SCAN command, remove |
| 5214 | // and put this on the Free queue. |
| 5215 | if ( eSmeCommandScan == pCommand->command ) |
| 5216 | { |
| 5217 | tANI_U32 sessionId = pCommand->sessionId; |
| 5218 | |
| 5219 | if(eSIR_SME_SUCCESS != pScanRsp->statusCode) |
| 5220 | { |
| 5221 | fSuccess = eANI_BOOLEAN_FALSE; |
| 5222 | } |
| 5223 | else |
| 5224 | { |
| 5225 | //pMac->scan.tempScanResults is not empty meaning the scan found something |
| 5226 | //This check only valid here because csrSaveScanresults is not yet called |
| 5227 | fSuccess = (!csrLLIsListEmpty(&pMac->scan.tempScanResults, LL_ACCESS_LOCK)); |
| 5228 | } |
Ratheesh S P | ece1f83 | 2015-07-25 15:50:25 +0530 | [diff] [blame] | 5229 | if (pCommand->u.scanCmd.abortScanIndication & |
| 5230 | eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE) |
Srinivas, Dasari | 187ca4e | 2014-02-07 12:40:09 +0530 | [diff] [blame] | 5231 | { |
| 5232 | /* |
| 5233 | * Scan aborted due to band change |
| 5234 | * The scan results need to be flushed |
| 5235 | */ |
| 5236 | if (pCommand->u.scanCmd.callback |
| 5237 | != pMac->scan.callback11dScanDone) |
| 5238 | { |
| 5239 | smsLog(pMac, LOG1, FL("Filtering the scan results as the " |
| 5240 | "results may belong to wrong band")); |
| 5241 | csrScanFilterResults(pMac); |
| 5242 | } |
| 5243 | else |
| 5244 | { |
| 5245 | smsLog(pMac, LOG1, FL("11d_scan_done will flush the scan" |
| 5246 | " results")); |
| 5247 | } |
Srinivas, Dasari | 187ca4e | 2014-02-07 12:40:09 +0530 | [diff] [blame] | 5248 | } |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 5249 | csrSaveScanResults(pMac, pCommand->u.scanCmd.reason); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5250 | |
Agrawal Ashish | df75267 | 2015-12-09 17:51:53 +0530 | [diff] [blame] | 5251 | /* filter scan result based on valid channel list number */ |
| 5252 | if (pMac->scan.fcc_constraint) |
| 5253 | { |
| 5254 | smsLog(pMac, LOG1, FL("Clear BSS from invalid channels")); |
| 5255 | csrScanFilterResults(pMac); |
| 5256 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5257 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 5258 | { |
| 5259 | vos_log_scan_pkt_type *pScanLog = NULL; |
| 5260 | tScanResultHandle hScanResult; |
| 5261 | tCsrScanResultInfo *pScanResult; |
| 5262 | tDot11fBeaconIEs *pIes; |
| 5263 | int n = 0, c = 0; |
| 5264 | |
| 5265 | WLAN_VOS_DIAG_LOG_ALLOC(pScanLog, vos_log_scan_pkt_type, LOG_WLAN_SCAN_C); |
| 5266 | if(pScanLog) |
| 5267 | { |
| 5268 | if(eCsrScanBgScan == pCommand->u.scanCmd.reason || |
| 5269 | eCsrScanProbeBss == pCommand->u.scanCmd.reason || |
| 5270 | eCsrScanSetBGScanParam == pCommand->u.scanCmd.reason) |
| 5271 | { |
| 5272 | pScanLog->eventId = WLAN_SCAN_EVENT_HO_SCAN_RSP; |
| 5273 | } |
| 5274 | else |
| 5275 | { |
| 5276 | if( eSIR_PASSIVE_SCAN != pMac->scan.curScanType ) |
| 5277 | { |
| 5278 | pScanLog->eventId = WLAN_SCAN_EVENT_ACTIVE_SCAN_RSP; |
| 5279 | } |
| 5280 | else |
| 5281 | { |
| 5282 | pScanLog->eventId = WLAN_SCAN_EVENT_PASSIVE_SCAN_RSP; |
| 5283 | } |
| 5284 | } |
| 5285 | if(eSIR_SME_SUCCESS == pScanRsp->statusCode) |
| 5286 | { |
| 5287 | if(HAL_STATUS_SUCCESS(csrScanGetResult(pMac, NULL, &hScanResult))) |
| 5288 | { |
| 5289 | while(((pScanResult = csrScanResultGetNext(pMac, hScanResult)) != NULL)) |
| 5290 | { |
| 5291 | if( n < VOS_LOG_MAX_NUM_BSSID ) |
| 5292 | { |
| 5293 | if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->BssDescriptor, &pIes))) |
| 5294 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5295 | smsLog(pMac, LOGE, FL(" fail to parse IEs")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5296 | break; |
| 5297 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5298 | vos_mem_copy(pScanLog->bssid[n], |
| 5299 | pScanResult->BssDescriptor.bssId, 6); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5300 | if(pIes && pIes->SSID.present && VOS_LOG_MAX_SSID_SIZE >= pIes->SSID.num_ssid) |
| 5301 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5302 | vos_mem_copy(pScanLog->ssid[n], |
| 5303 | pIes->SSID.ssid, pIes->SSID.num_ssid); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5304 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5305 | vos_mem_free(pIes); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5306 | n++; |
| 5307 | } |
| 5308 | c++; |
| 5309 | } |
| 5310 | pScanLog->numSsid = (v_U8_t)n; |
| 5311 | pScanLog->totalSsid = (v_U8_t)c; |
| 5312 | csrScanResultPurge(pMac, hScanResult); |
| 5313 | } |
| 5314 | } |
| 5315 | else |
| 5316 | { |
| 5317 | pScanLog->status = WLAN_SCAN_STATUS_FAILURE; |
| 5318 | } |
| 5319 | WLAN_VOS_DIAG_LOG_REPORT(pScanLog); |
| 5320 | } |
| 5321 | } |
| 5322 | #endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 5323 | |
| 5324 | NextCommand = csrScanGetNextCommandState(pMac, pCommand, fSuccess); |
| 5325 | //We reuse the command here instead reissue a new command |
| 5326 | switch(NextCommand) |
| 5327 | { |
| 5328 | case eCsrNext11dScan1Success: |
| 5329 | case eCsrNext11dScan2Success: |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5330 | smsLog( pMac, LOG2, FL("11dScan1/3 produced results. Reissue Active scan...")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5331 | // if we found country information, no need to continue scanning further, bail out |
| 5332 | fRemoveCommand = eANI_BOOLEAN_TRUE; |
| 5333 | NextCommand = eCsrNext11dScanComplete; |
| 5334 | break; |
| 5335 | case eCsrNext11dScan1Failure: |
| 5336 | //We are not done yet. 11d scan fail once. We will try to reset anything and do it over again |
| 5337 | //The only meaningful thing for this retry is that we cannot find 11d information after a reset so |
| 5338 | //we clear the "old" 11d info and give it once more chance |
| 5339 | fRemoveCommand = csrHandleScan11d1Failure(pMac, pCommand); |
| 5340 | if(fRemoveCommand) |
| 5341 | { |
| 5342 | NextCommand = eCsrNext11dScanComplete; |
| 5343 | } |
| 5344 | break; |
| 5345 | case eCsrNextLostLinkScan1Success: |
| 5346 | if(!HAL_STATUS_SUCCESS(csrIssueRoamAfterLostlinkScan(pMac, sessionId, eCsrLostLink1))) |
| 5347 | { |
| 5348 | csrScanHandleFailedLostlink1(pMac, sessionId); |
| 5349 | } |
| 5350 | break; |
| 5351 | case eCsrNextLostLinkScan2Success: |
| 5352 | if(!HAL_STATUS_SUCCESS(csrIssueRoamAfterLostlinkScan(pMac, sessionId, eCsrLostLink2))) |
| 5353 | { |
| 5354 | csrScanHandleFailedLostlink2(pMac, sessionId); |
| 5355 | } |
| 5356 | break; |
| 5357 | case eCsrNextLostLinkScan3Success: |
| 5358 | if(!HAL_STATUS_SUCCESS(csrIssueRoamAfterLostlinkScan(pMac, sessionId, eCsrLostLink3))) |
| 5359 | { |
| 5360 | csrScanHandleFailedLostlink3(pMac, sessionId); |
| 5361 | } |
| 5362 | break; |
| 5363 | case eCsrNextLostLinkScan1Failed: |
| 5364 | csrScanHandleFailedLostlink1(pMac, sessionId); |
| 5365 | break; |
| 5366 | case eCsrNextLostLinkScan2Failed: |
| 5367 | csrScanHandleFailedLostlink2(pMac, sessionId); |
| 5368 | break; |
| 5369 | case eCsrNextLostLinkScan3Failed: |
| 5370 | csrScanHandleFailedLostlink3(pMac, sessionId); |
| 5371 | break; |
| 5372 | case eCsrNexteScanForSsidSuccess: |
| 5373 | csrScanHandleSearchForSSID(pMac, pCommand); |
| 5374 | break; |
| 5375 | case eCsrNexteScanForSsidFailure: |
| 5376 | csrScanHandleSearchForSSIDFailure(pMac, pCommand); |
| 5377 | break; |
| 5378 | case eCsrNextIdleScanComplete: |
| 5379 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 5380 | break; |
| 5381 | case eCsrNextCapChangeScanComplete: |
| 5382 | csrScanHandleCapChangeScanComplete(pMac, sessionId); |
| 5383 | break; |
| 5384 | default: |
| 5385 | |
| 5386 | break; |
| 5387 | } |
| 5388 | } |
| 5389 | else |
| 5390 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5391 | 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] | 5392 | fRemoveCommand = eANI_BOOLEAN_FALSE; |
| 5393 | } |
| 5394 | } |
| 5395 | else |
| 5396 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5397 | smsLog( pMac, LOGW, FL("Scan Completion called but NO commands are ACTIVE ...")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5398 | fRemoveCommand = eANI_BOOLEAN_FALSE; |
| 5399 | } |
| 5400 | |
| 5401 | return( fRemoveCommand ); |
| 5402 | } |
| 5403 | |
| 5404 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5405 | static void csrScanRemoveDupBssDescriptionFromInterimList( tpAniSirGlobal pMac, |
| 5406 | tSirBssDescription *pSirBssDescr, |
| 5407 | tDot11fBeaconIEs *pIes) |
| 5408 | { |
| 5409 | tListElem *pEntry; |
| 5410 | tCsrScanResult *pCsrBssDescription; |
Abhishek Singh | 56c2981 | 2018-06-12 14:07:52 +0530 | [diff] [blame] | 5411 | tDot11fBeaconIEs *temp_ie = pIes; |
| 5412 | |
| 5413 | if (!temp_ie) |
| 5414 | csrGetParsedBssDescriptionIEs(pMac, pSirBssDescr, &temp_ie); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5415 | |
| 5416 | // Walk through all the chained BssDescriptions. If we find a chained BssDescription that |
| 5417 | // matches the BssID of the BssDescription passed in, then these must be duplicate scan |
| 5418 | // results for this Bss. In that case, remove the 'old' Bss description from the linked list. |
| 5419 | pEntry = csrLLPeekHead( &pMac->scan.tempScanResults, LL_ACCESS_LOCK ); |
| 5420 | while( pEntry ) |
| 5421 | { |
| 5422 | pCsrBssDescription = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 5423 | |
| 5424 | // we have a duplicate scan results only when BSSID, SSID, Channel and NetworkType |
| 5425 | // matches |
| 5426 | |
Abhishek Singh | 56c2981 | 2018-06-12 14:07:52 +0530 | [diff] [blame] | 5427 | if (csrIsDuplicateBssDescription(pMac, |
| 5428 | &pCsrBssDescription->Result.BssDescriptor, |
| 5429 | pSirBssDescr, temp_ie, FALSE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5430 | { |
Abhishek Singh | 56c2981 | 2018-06-12 14:07:52 +0530 | [diff] [blame] | 5431 | /* |
| 5432 | * Due to Rx sensitivity issue, sometime beacons are seen on |
| 5433 | * adjacent channel so workaround in software is needed. If DS |
| 5434 | * params or HT info are present driver can get proper channel |
| 5435 | * info from these IEs and the older RSSI values are used in new |
| 5436 | * entry. |
| 5437 | * |
| 5438 | * For the cases where DS params and HT info is not present, |
| 5439 | * driver needs to check below conditions to update proper |
| 5440 | * channel so that the older RSSI and channel values are used in |
| 5441 | * new entry: |
| 5442 | * -- The old entry channel and new entry channel are not same |
| 5443 | * -- RSSI is below 15db or more from old value, this indicate |
| 5444 | * that the signal has leaked in adjacent channel |
| 5445 | */ |
| 5446 | if (!pSirBssDescr->fProbeRsp && |
| 5447 | (temp_ie && !temp_ie->DSParams.present && |
| 5448 | !temp_ie->HTInfo.present) && |
| 5449 | (pSirBssDescr->channelId != |
| 5450 | pCsrBssDescription->Result.BssDescriptor.channelId) && |
| 5451 | ((pCsrBssDescription->Result.BssDescriptor.rssi - |
| 5452 | pSirBssDescr->rssi) > |
| 5453 | SIR_ADJACENT_CHANNEL_RSSI_DIFF_THRESHOLD)) { |
| 5454 | pSirBssDescr->channelId = |
| 5455 | pCsrBssDescription->Result.BssDescriptor.channelId; |
| 5456 | pSirBssDescr->rssi = |
| 5457 | pCsrBssDescription->Result.BssDescriptor.rssi; |
| 5458 | } |
| 5459 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5460 | pSirBssDescr->rssi = (tANI_S8)( (((tANI_S32)pSirBssDescr->rssi * CSR_SCAN_RESULT_RSSI_WEIGHT ) + |
| 5461 | ((tANI_S32)pCsrBssDescription->Result.BssDescriptor.rssi * (100 - CSR_SCAN_RESULT_RSSI_WEIGHT) )) / 100 ); |
| 5462 | |
| 5463 | // Remove the 'old' entry from the list.... |
| 5464 | if( csrLLRemoveEntry( &pMac->scan.tempScanResults, pEntry, LL_ACCESS_LOCK ) ) |
| 5465 | { |
| 5466 | csrCheckNSaveWscIe(pMac, pSirBssDescr, &pCsrBssDescription->Result.BssDescriptor); |
| 5467 | // we need to free the memory associated with this node |
| 5468 | csrFreeScanResultEntry( pMac, pCsrBssDescription ); |
| 5469 | } |
| 5470 | |
| 5471 | // If we found a match, we can stop looking through the list. |
| 5472 | break; |
| 5473 | } |
| 5474 | |
| 5475 | pEntry = csrLLNext( &pMac->scan.tempScanResults, pEntry, LL_ACCESS_LOCK ); |
| 5476 | } |
Abhishek Singh | 56c2981 | 2018-06-12 14:07:52 +0530 | [diff] [blame] | 5477 | |
| 5478 | if (!pIes && temp_ie) |
| 5479 | vos_mem_free(temp_ie); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5480 | } |
| 5481 | |
| 5482 | |
| 5483 | |
| 5484 | //Caller allocated memory pfNewBssForConn to return whether new candidate for |
| 5485 | //current connection is found. Cannot be NULL |
| 5486 | tCsrScanResult *csrScanSaveBssDescriptionToInterimList( tpAniSirGlobal pMac, |
| 5487 | tSirBssDescription *pBSSDescription, |
| 5488 | tDot11fBeaconIEs *pIes) |
| 5489 | { |
| 5490 | tCsrScanResult *pCsrBssDescription = NULL; |
| 5491 | tANI_U32 cbBSSDesc; |
| 5492 | tANI_U32 cbAllocated; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5493 | |
| 5494 | // figure out how big the BSS description is (the BSSDesc->length does NOT |
| 5495 | // include the size of the length field itself). |
| 5496 | cbBSSDesc = pBSSDescription->length + sizeof( pBSSDescription->length ); |
| 5497 | |
| 5498 | cbAllocated = sizeof( tCsrScanResult ) + cbBSSDesc; |
| 5499 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5500 | pCsrBssDescription = vos_mem_malloc(cbAllocated); |
| 5501 | if ( NULL != pCsrBssDescription ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5502 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5503 | vos_mem_set(pCsrBssDescription, cbAllocated, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5504 | pCsrBssDescription->AgingCount = (tANI_S32)pMac->roam.configParam.agingCount; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5505 | vos_mem_copy(&pCsrBssDescription->Result.BssDescriptor, pBSSDescription, cbBSSDesc ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5506 | //Save SSID separately for later use |
| 5507 | if( pIes->SSID.present && !csrIsNULLSSID(pIes->SSID.ssid, pIes->SSID.num_ssid) ) |
| 5508 | { |
| 5509 | //SSID not hidden |
Madan Mohan Koyyalamudi | 4e31b13 | 2012-11-02 13:13:52 -0700 | [diff] [blame] | 5510 | tANI_U32 len = pIes->SSID.num_ssid; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5511 | if (len > SIR_MAC_MAX_SSID_LENGTH) |
| 5512 | { |
| 5513 | // truncate to fit in our struct |
| 5514 | len = SIR_MAC_MAX_SSID_LENGTH; |
| 5515 | } |
| 5516 | pCsrBssDescription->Result.ssId.length = len; |
| 5517 | pCsrBssDescription->Result.timer = vos_timer_get_system_time(); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5518 | vos_mem_copy(pCsrBssDescription->Result.ssId.ssId, pIes->SSID.ssid, len); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5519 | } |
| 5520 | csrLLInsertTail( &pMac->scan.tempScanResults, &pCsrBssDescription->Link, LL_ACCESS_LOCK ); |
| 5521 | } |
| 5522 | |
| 5523 | return( pCsrBssDescription ); |
| 5524 | } |
| 5525 | |
| 5526 | |
| 5527 | |
| 5528 | |
| 5529 | tANI_BOOLEAN csrIsDuplicateBssDescription( tpAniSirGlobal pMac, tSirBssDescription *pSirBssDesc1, |
Tushnim Bhattacharyya | 5128d75 | 2013-06-26 23:23:18 -0700 | [diff] [blame] | 5530 | tSirBssDescription *pSirBssDesc2, tDot11fBeaconIEs *pIes2, tANI_BOOLEAN fForced ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5531 | { |
| 5532 | tANI_BOOLEAN fMatch = FALSE; |
| 5533 | tSirMacCapabilityInfo *pCap1, *pCap2; |
| 5534 | tDot11fBeaconIEs *pIes1 = NULL; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5535 | tDot11fBeaconIEs *pIesTemp = pIes2; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5536 | |
| 5537 | pCap1 = (tSirMacCapabilityInfo *)&pSirBssDesc1->capabilityInfo; |
| 5538 | pCap2 = (tSirMacCapabilityInfo *)&pSirBssDesc2->capabilityInfo; |
| 5539 | if(pCap1->ess == pCap2->ess) |
| 5540 | { |
| 5541 | if (pCap1->ess && |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5542 | csrIsMacAddressEqual( pMac, (tCsrBssid *)pSirBssDesc1->bssId, (tCsrBssid *)pSirBssDesc2->bssId)&& |
Abhishek Singh | e3fa11f | 2014-05-13 11:11:10 +0530 | [diff] [blame] | 5543 | (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] | 5544 | { |
| 5545 | fMatch = TRUE; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5546 | // Check for SSID match, if exists |
| 5547 | do |
| 5548 | { |
| 5549 | if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc1, &pIes1))) |
| 5550 | { |
| 5551 | break; |
| 5552 | } |
| 5553 | if( NULL == pIesTemp ) |
| 5554 | { |
| 5555 | if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc2, &pIesTemp))) |
| 5556 | { |
| 5557 | break; |
| 5558 | } |
| 5559 | } |
| 5560 | if(pIes1->SSID.present && pIesTemp->SSID.present) |
| 5561 | { |
| 5562 | fMatch = csrIsSsidMatch(pMac, pIes1->SSID.ssid, pIes1->SSID.num_ssid, |
| 5563 | pIesTemp->SSID.ssid, pIesTemp->SSID.num_ssid, eANI_BOOLEAN_TRUE); |
| 5564 | } |
| 5565 | }while(0); |
| 5566 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5567 | } |
| 5568 | else if (pCap1->ibss && (pSirBssDesc1->channelId == pSirBssDesc2->channelId)) |
| 5569 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5570 | |
| 5571 | do |
| 5572 | { |
| 5573 | if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc1, &pIes1))) |
| 5574 | { |
| 5575 | break; |
| 5576 | } |
| 5577 | if( NULL == pIesTemp ) |
| 5578 | { |
| 5579 | if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc2, &pIesTemp))) |
| 5580 | { |
| 5581 | break; |
| 5582 | } |
| 5583 | } |
| 5584 | //Same channel cannot have same SSID for different IBSS |
| 5585 | if(pIes1->SSID.present && pIesTemp->SSID.present) |
| 5586 | { |
| 5587 | fMatch = csrIsSsidMatch(pMac, pIes1->SSID.ssid, pIes1->SSID.num_ssid, |
| 5588 | pIesTemp->SSID.ssid, pIesTemp->SSID.num_ssid, eANI_BOOLEAN_TRUE); |
| 5589 | } |
| 5590 | }while(0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5591 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5592 | /* In case of P2P devices, ess and ibss will be set to zero */ |
| 5593 | else if (!pCap1->ess && |
| 5594 | csrIsMacAddressEqual( pMac, (tCsrBssid *)pSirBssDesc1->bssId, (tCsrBssid *)pSirBssDesc2->bssId)) |
| 5595 | { |
| 5596 | fMatch = TRUE; |
| 5597 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5598 | } |
| 5599 | |
| 5600 | if(pIes1) |
| 5601 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5602 | vos_mem_free(pIes1); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5603 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5604 | |
| 5605 | if( (NULL == pIes2) && pIesTemp ) |
| 5606 | { |
| 5607 | //locally allocated |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5608 | vos_mem_free(pIesTemp); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5609 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5610 | |
| 5611 | return( fMatch ); |
| 5612 | } |
| 5613 | |
| 5614 | |
| 5615 | tANI_BOOLEAN csrIsNetworkTypeEqual( tSirBssDescription *pSirBssDesc1, tSirBssDescription *pSirBssDesc2 ) |
| 5616 | { |
| 5617 | return( pSirBssDesc1->nwType == pSirBssDesc2->nwType ); |
| 5618 | } |
| 5619 | |
| 5620 | |
| 5621 | //to check whether the BSS matches the dot11Mode |
| 5622 | static tANI_BOOLEAN csrScanIsBssAllowed(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc, |
| 5623 | tDot11fBeaconIEs *pIes) |
| 5624 | { |
| 5625 | tANI_BOOLEAN fAllowed = eANI_BOOLEAN_FALSE; |
| 5626 | eCsrPhyMode phyMode; |
| 5627 | |
| 5628 | if(HAL_STATUS_SUCCESS(csrGetPhyModeFromBss(pMac, pBssDesc, &phyMode, pIes))) |
| 5629 | { |
| 5630 | switch(pMac->roam.configParam.phyMode) |
| 5631 | { |
| 5632 | case eCSR_DOT11_MODE_11b: |
| 5633 | fAllowed = (tANI_BOOLEAN)(eCSR_DOT11_MODE_11a != phyMode); |
| 5634 | break; |
| 5635 | case eCSR_DOT11_MODE_11g: |
| 5636 | fAllowed = (tANI_BOOLEAN)(eCSR_DOT11_MODE_11a != phyMode); |
| 5637 | break; |
| 5638 | case eCSR_DOT11_MODE_11g_ONLY: |
| 5639 | fAllowed = (tANI_BOOLEAN)(eCSR_DOT11_MODE_11g == phyMode); |
| 5640 | break; |
| 5641 | case eCSR_DOT11_MODE_11a: |
| 5642 | fAllowed = (tANI_BOOLEAN)((eCSR_DOT11_MODE_11b != phyMode) && (eCSR_DOT11_MODE_11g != phyMode)); |
| 5643 | break; |
| 5644 | case eCSR_DOT11_MODE_11n_ONLY: |
| 5645 | fAllowed = (tANI_BOOLEAN)((eCSR_DOT11_MODE_11n == phyMode) || (eCSR_DOT11_MODE_TAURUS == phyMode)); |
| 5646 | break; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5647 | |
| 5648 | #ifdef WLAN_FEATURE_11AC |
| 5649 | case eCSR_DOT11_MODE_11ac_ONLY: |
| 5650 | fAllowed = (tANI_BOOLEAN)((eCSR_DOT11_MODE_11ac == phyMode) || (eCSR_DOT11_MODE_TAURUS == phyMode)); |
| 5651 | break; |
| 5652 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5653 | case eCSR_DOT11_MODE_11b_ONLY: |
| 5654 | fAllowed = (tANI_BOOLEAN)(eCSR_DOT11_MODE_11b == phyMode); |
| 5655 | break; |
| 5656 | case eCSR_DOT11_MODE_11a_ONLY: |
| 5657 | fAllowed = (tANI_BOOLEAN)(eCSR_DOT11_MODE_11a == phyMode); |
| 5658 | break; |
| 5659 | case eCSR_DOT11_MODE_11n: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5660 | #ifdef WLAN_FEATURE_11AC |
| 5661 | case eCSR_DOT11_MODE_11ac: |
| 5662 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5663 | case eCSR_DOT11_MODE_TAURUS: |
| 5664 | default: |
| 5665 | fAllowed = eANI_BOOLEAN_TRUE; |
| 5666 | break; |
| 5667 | } |
| 5668 | } |
| 5669 | |
| 5670 | return (fAllowed); |
| 5671 | } |
| 5672 | |
| 5673 | |
| 5674 | |
| 5675 | //Return pIes to caller for future use when returning TRUE. |
| 5676 | static tANI_BOOLEAN csrScanValidateScanResult( tpAniSirGlobal pMac, tANI_U8 *pChannels, |
| 5677 | tANI_U8 numChn, tSirBssDescription *pBssDesc, |
| 5678 | tDot11fBeaconIEs **ppIes ) |
| 5679 | { |
| 5680 | tANI_BOOLEAN fValidChannel = FALSE; |
| 5681 | tDot11fBeaconIEs *pIes = NULL; |
| 5682 | tANI_U8 index; |
| 5683 | |
| 5684 | for( index = 0; index < numChn; index++ ) |
| 5685 | { |
| 5686 | // This check relies on the fact that a single BSS description is returned in each |
| 5687 | // ScanRsp call, which is the way LIM implemented the scan req/rsp funtions. We changed |
| 5688 | // to this model when we ran with a large number of APs. If this were to change, then |
| 5689 | // this check would have to mess with removing the bssDescription from somewhere in an |
| 5690 | // arbitrary index in the bssDescription array. |
| 5691 | if ( pChannels[ index ] == pBssDesc->channelId ) |
| 5692 | { |
| 5693 | fValidChannel = TRUE; |
| 5694 | break; |
| 5695 | } |
| 5696 | } |
| 5697 | *ppIes = NULL; |
| 5698 | if(fValidChannel) |
| 5699 | { |
| 5700 | if( HAL_STATUS_SUCCESS( csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes) ) ) |
| 5701 | { |
| 5702 | fValidChannel = csrScanIsBssAllowed(pMac, pBssDesc, pIes); |
| 5703 | if( fValidChannel ) |
| 5704 | { |
| 5705 | *ppIes = pIes; |
| 5706 | } |
| 5707 | else |
| 5708 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5709 | vos_mem_free(pIes); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5710 | } |
| 5711 | } |
| 5712 | else |
| 5713 | { |
| 5714 | fValidChannel = FALSE; |
| 5715 | } |
| 5716 | } |
| 5717 | |
| 5718 | return( fValidChannel ); |
| 5719 | } |
| 5720 | |
| 5721 | |
| 5722 | //Return whether last scan result is received |
| 5723 | static tANI_BOOLEAN csrScanProcessScanResults( tpAniSirGlobal pMac, tSmeCmd *pCommand, |
| 5724 | tSirSmeScanRsp *pScanRsp, tANI_BOOLEAN *pfRemoveCommand ) |
| 5725 | { |
| 5726 | tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE, fRemoveCommand = eANI_BOOLEAN_FALSE; |
| 5727 | tDot11fBeaconIEs *pIes = NULL; |
| 5728 | tANI_U32 cbParsed; |
| 5729 | tSirBssDescription *pSirBssDescription; |
| 5730 | tANI_U32 cbBssDesc; |
Agrawal Ashish | 4cc15bb | 2016-02-04 17:56:16 +0530 | [diff] [blame] | 5731 | eHalStatus status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5732 | tANI_U32 cbScanResult = GET_FIELD_OFFSET( tSirSmeScanRsp, bssDescription ) |
| 5733 | + sizeof(tSirBssDescription); //We need at least one CB |
| 5734 | |
| 5735 | // don't consider the scan rsp to be valid if the status code is Scan Failure. Scan Failure |
| 5736 | // is returned when the scan could not find anything. so if we get scan failure return that |
| 5737 | // the scan response is invalid. Also check the lenght in the scan result for valid scan |
| 5738 | // BssDescriptions.... |
| 5739 | do |
| 5740 | { |
| 5741 | if ( ( cbScanResult <= pScanRsp->length ) && |
| 5742 | (( eSIR_SME_SUCCESS == pScanRsp->statusCode ) || |
| 5743 | ( eSIR_SME_MORE_SCAN_RESULTS_FOLLOW == pScanRsp->statusCode ) ) ) |
| 5744 | { |
| 5745 | tANI_U8 *pChannelList = NULL; |
| 5746 | tANI_U8 cChannels = 0; |
| 5747 | |
| 5748 | //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] | 5749 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 5750 | if( eCsrScanGetLfrResult == pCommand->u.scanCmd.reason ) |
| 5751 | { |
| 5752 | pChannelList = NULL; |
| 5753 | cChannels = 0; |
| 5754 | } |
| 5755 | else |
| 5756 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5757 | if( eCsrScanSetBGScanParam == pCommand->u.scanCmd.reason ) |
| 5758 | { |
| 5759 | //eCsrScanSetBGScanParam uses different structure |
| 5760 | tCsrBGScanRequest *pBgScanReq = &pCommand->u.scanCmd.u.bgScanRequest; |
| 5761 | |
| 5762 | cChannels = pBgScanReq->ChannelInfo.numOfChannels; |
| 5763 | pChannelList = pBgScanReq->ChannelInfo.ChannelList; |
| 5764 | } |
| 5765 | else |
| 5766 | { |
| 5767 | //the rest use generic scan request |
| 5768 | cChannels = pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels; |
| 5769 | pChannelList = pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList; |
| 5770 | } |
| 5771 | |
| 5772 | // if the scan result is not on one of the channels in the Valid channel list, then it |
| 5773 | // must have come from an AP on an overlapping channel (in the 2.4GHz band). In this case, |
| 5774 | // let's drop the scan result. |
| 5775 | // |
| 5776 | // The other situation is where the scan request is for a scan on a particular channel set |
| 5777 | // and the scan result is from a |
| 5778 | |
| 5779 | // if the NumChannels is 0, then we are supposed to be scanning all channels. Use the full channel |
| 5780 | // list as the 'valid' channel list. Otherwise, use the specific channel list in the scan parms |
| 5781 | // as the valid channels. |
| 5782 | if ( 0 == cChannels ) |
| 5783 | { |
| 5784 | tANI_U32 len = sizeof(pMac->roam.validChannelList); |
| 5785 | |
| 5786 | if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len))) |
| 5787 | { |
| 5788 | pChannelList = pMac->roam.validChannelList; |
| 5789 | cChannels = (tANI_U8)len; |
| 5790 | } |
| 5791 | else |
| 5792 | { |
| 5793 | //Cannot continue |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5794 | smsLog( pMac, LOGE, "CSR: Processing internal SCAN results...csrGetCfgValidChannels failed" ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5795 | break; |
| 5796 | } |
| 5797 | } |
| 5798 | |
| 5799 | smsLog( pMac, LOG2, "CSR: Processing internal SCAN results..." ); |
| 5800 | cbParsed = GET_FIELD_OFFSET( tSirSmeScanRsp, bssDescription ); |
| 5801 | pSirBssDescription = pScanRsp->bssDescription; |
| 5802 | while( cbParsed < pScanRsp->length ) |
| 5803 | { |
| 5804 | if ( csrScanValidateScanResult( pMac, pChannelList, cChannels, pSirBssDescription, &pIes ) ) |
| 5805 | { |
| 5806 | csrScanRemoveDupBssDescriptionFromInterimList(pMac, pSirBssDescription, pIes); |
| 5807 | csrScanSaveBssDescriptionToInterimList( pMac, pSirBssDescription, pIes ); |
| 5808 | if( eSIR_PASSIVE_SCAN == pMac->scan.curScanType ) |
| 5809 | { |
| 5810 | if( csrIs11dSupported( pMac) ) |
| 5811 | { |
| 5812 | //Check whether the BSS is acceptable base on 11d info and our configs. |
| 5813 | if( csrMatchCountryCode( pMac, NULL, pIes ) ) |
| 5814 | { |
| 5815 | //Double check whether the channel is acceptable by us. |
| 5816 | if( csrIsSupportedChannel( pMac, pSirBssDescription->channelId ) ) |
| 5817 | { |
| 5818 | pMac->scan.curScanType = eSIR_ACTIVE_SCAN; |
| 5819 | } |
| 5820 | } |
| 5821 | } |
| 5822 | else |
| 5823 | { |
| 5824 | pMac->scan.curScanType = eSIR_ACTIVE_SCAN; |
| 5825 | } |
| 5826 | } |
| 5827 | //Free the resource |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5828 | vos_mem_free(pIes); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5829 | } |
| 5830 | // skip over the BSS description to the next one... |
| 5831 | cbBssDesc = pSirBssDescription->length + sizeof( pSirBssDescription->length ); |
| 5832 | |
| 5833 | cbParsed += cbBssDesc; |
| 5834 | pSirBssDescription = (tSirBssDescription *)((tANI_U8 *)pSirBssDescription + cbBssDesc ); |
| 5835 | |
| 5836 | } //while |
| 5837 | } |
| 5838 | else |
| 5839 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5840 | smsLog( pMac, LOGW, " Scanrsp fail (0x%08X), length = %d (expected %d)", |
Madan Mohan Koyyalamudi | dd3c966 | 2012-11-09 17:39:30 -0800 | [diff] [blame] | 5841 | pScanRsp->statusCode, pScanRsp->length, cbScanResult); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5842 | //HO bg scan/probe failed no need to try autonomously |
| 5843 | if(eCsrScanBgScan == pCommand->u.scanCmd.reason || |
| 5844 | eCsrScanProbeBss == pCommand->u.scanCmd.reason || |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 5845 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 5846 | eCsrScanGetLfrResult == pCommand->u.scanCmd.reason || |
| 5847 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5848 | eCsrScanSetBGScanParam == pCommand->u.scanCmd.reason) |
| 5849 | { |
| 5850 | fRemoveCommand = eANI_BOOLEAN_TRUE; |
| 5851 | } |
| 5852 | } |
| 5853 | }while(0); |
| 5854 | if ( eSIR_SME_MORE_SCAN_RESULTS_FOLLOW != pScanRsp->statusCode ) |
| 5855 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5856 | 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] | 5857 | fRemoveCommand = csrScanComplete( pMac, pScanRsp ); |
| 5858 | fRet = eANI_BOOLEAN_TRUE; |
| 5859 | }//if ( eSIR_SME_MORE_SCAN_RESULTS_FOLLOW != pScanRsp->statusCode ) |
| 5860 | if(pfRemoveCommand) |
| 5861 | { |
| 5862 | *pfRemoveCommand = fRemoveCommand; |
| 5863 | } |
| 5864 | |
Agrawal Ashish | 4cc15bb | 2016-02-04 17:56:16 +0530 | [diff] [blame] | 5865 | /* |
| 5866 | * Currently SET_FCC_CHANNEL issues updated channel list to fw. |
| 5867 | * At the time of driver load, if scan is issued followed with |
| 5868 | * SET_FCC_CHANNEL, driver will send update channel list to fw. |
| 5869 | * Fw will stop ongoing scan because of that GUI will have very less |
| 5870 | * scan list. |
| 5871 | * Update channel list should be sent to fw once scan is done |
| 5872 | */ |
| 5873 | if (pMac->scan.defer_update_channel_list) { |
| 5874 | status = csrUpdateChannelList(pMac); |
| 5875 | if (eHAL_STATUS_SUCCESS != status) |
| 5876 | smsLog(pMac, LOGE, |
| 5877 | FL( "failed to update the supported channel list")); |
| 5878 | pMac->scan.defer_update_channel_list = false; |
| 5879 | } |
| 5880 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5881 | #ifdef WLAN_AP_STA_CONCURRENCY |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 5882 | if (pMac->fScanOffload) |
| 5883 | return fRet; |
| 5884 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5885 | if (!csrLLIsListEmpty( &pMac->scan.scanCmdPendingList, LL_ACCESS_LOCK )) |
| 5886 | { |
Madan Mohan Koyyalamudi | 48081ef | 2012-12-04 16:49:55 -0800 | [diff] [blame] | 5887 | /* Pending scan commands in the list because the previous scan command |
| 5888 | * was split into a scan command on one channel + a scan command for all |
| 5889 | * remaining channels. |
| 5890 | * |
| 5891 | * Start timer to trigger processing of the next scan command. |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 5892 | * NOTE for LFR: |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 5893 | * Do not split scans if no concurrent infra connections are |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 5894 | * active and if the scan is a BG scan triggered by LFR (OR) |
| 5895 | * any scan if LFR is in the middle of a BG scan. Splitting |
| 5896 | * the scan is delaying the time it takes for LFR to find |
| 5897 | * candidates and resulting in disconnects. |
Madan Mohan Koyyalamudi | 48081ef | 2012-12-04 16:49:55 -0800 | [diff] [blame] | 5898 | */ |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 5899 | if ( (csrIsStaSessionConnected(pMac) && |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 5900 | #ifdef FEATURE_WLAN_LFR |
| 5901 | (csrIsConcurrentInfraConnected(pMac) || |
| 5902 | ((pCommand->u.scanCmd.reason != eCsrScanBgScan) && |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 5903 | (pMac->roam.neighborRoamInfo.neighborRoamState != |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 5904 | eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN))) && |
| 5905 | #endif |
| 5906 | (pCommand->u.scanCmd.u.scanRequest.p2pSearch != 1)) || |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 5907 | (csrIsP2pSessionConnected(pMac)) ) |
Madan Mohan Koyyalamudi | 48081ef | 2012-12-04 16:49:55 -0800 | [diff] [blame] | 5908 | { |
Madan Mohan Koyyalamudi | d671358 | 2012-11-09 16:56:56 -0800 | [diff] [blame] | 5909 | /* if active connected sessions present then continue to split scan |
| 5910 | * with specified interval between consecutive scans */ |
| 5911 | 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] | 5912 | vos_timer_start(&pMac->scan.hTimerStaApConcTimer, |
| 5913 | pCommand->u.scanCmd.u.scanRequest.restTime); |
Madan Mohan Koyyalamudi | d671358 | 2012-11-09 16:56:56 -0800 | [diff] [blame] | 5914 | } else { |
| 5915 | /* if no connected sessions present then initiate next scan command immediately */ |
| 5916 | /* minimum timer granularity is 10ms */ |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 5917 | vos_timer_start(&pMac->scan.hTimerStaApConcTimer, 10); |
Madan Mohan Koyyalamudi | d671358 | 2012-11-09 16:56:56 -0800 | [diff] [blame] | 5918 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5919 | } |
| 5920 | #endif |
| 5921 | return (fRet); |
| 5922 | } |
| 5923 | |
| 5924 | |
| 5925 | tANI_BOOLEAN csrScanIsWildCardScan( tpAniSirGlobal pMac, tSmeCmd *pCommand ) |
| 5926 | { |
| 5927 | 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] | 5928 | tANI_BOOLEAN f = vos_mem_compare(pCommand->u.scanCmd.u.scanRequest.bssid, |
| 5929 | bssid, sizeof(tCsrBssid)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5930 | |
| 5931 | //It is not a wild card scan if the bssid is not broadcast and the number of SSID is 1. |
| 5932 | return ((tANI_BOOLEAN)( (f || (0xff == pCommand->u.scanCmd.u.scanRequest.bssid[0])) && |
| 5933 | (pCommand->u.scanCmd.u.scanRequest.SSIDs.numOfSSIDs != 1) )); |
| 5934 | } |
| 5935 | |
| 5936 | |
| 5937 | eHalStatus csrScanSmeScanResponse( tpAniSirGlobal pMac, void *pMsgBuf ) |
| 5938 | { |
| 5939 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 5940 | tListElem *pEntry; |
| 5941 | tSmeCmd *pCommand; |
| 5942 | eCsrScanStatus scanStatus; |
Sunkad, Anand Ningappa | 3ec8bf7 | 2016-02-05 15:13:30 +0530 | [diff] [blame] | 5943 | tSirSmeScanRsp *pScanRsp; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5944 | tSmeGetScanChnRsp *pScanChnInfo; |
| 5945 | tANI_BOOLEAN fRemoveCommand = eANI_BOOLEAN_TRUE; |
| 5946 | eCsrScanReason reason = eCsrScanOther; |
| 5947 | |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 5948 | if (pMac->fScanOffload) |
| 5949 | pEntry = csrLLPeekHead(&pMac->sme.smeScanCmdActiveList, |
| 5950 | LL_ACCESS_LOCK); |
| 5951 | else |
| 5952 | pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5953 | |
| 5954 | if ( pEntry ) |
| 5955 | { |
| 5956 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 5957 | if ( eSmeCommandScan == pCommand->command ) |
| 5958 | { |
Deepthi Gowri | fe5340b | 2016-04-11 12:15:46 +0530 | [diff] [blame] | 5959 | /* Purge the scan results based on Aging */ |
| 5960 | if (pEntry && pMac->scan.scanResultCfgAgingTime) |
| 5961 | csrPurgeScanResultByAge(pMac); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5962 | reason = pCommand->u.scanCmd.reason; |
| 5963 | switch(pCommand->u.scanCmd.reason) |
| 5964 | { |
| 5965 | case eCsrScanAbortBgScan: |
| 5966 | case eCsrScanAbortNormalScan: |
| 5967 | case eCsrScanBGScanAbort: |
| 5968 | case eCsrScanBGScanEnable: |
Sunkad, Anand Ningappa | 3ec8bf7 | 2016-02-05 15:13:30 +0530 | [diff] [blame] | 5969 | pScanRsp = (tSirSmeScanRsp *)pMsgBuf; |
| 5970 | scanStatus = (eSIR_SME_SUCCESS == pScanRsp->statusCode) ? |
| 5971 | eCSR_SCAN_SUCCESS : eCSR_SCAN_FAILURE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5972 | break; |
| 5973 | case eCsrScanGetScanChnInfo: |
Deepthi Gowri | fe5340b | 2016-04-11 12:15:46 +0530 | [diff] [blame] | 5974 | pScanChnInfo = (tSmeGetScanChnRsp *)pMsgBuf; |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5975 | /* |
| 5976 | * status code not available in tSmeGetScanChnRsp, so |
| 5977 | * by default considereing it to be success |
| 5978 | */ |
| 5979 | scanStatus = eSIR_SME_SUCCESS; |
Deepthi Gowri | fe5340b | 2016-04-11 12:15:46 +0530 | [diff] [blame] | 5980 | csrScanAgeResults(pMac, pScanChnInfo); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5981 | break; |
| 5982 | case eCsrScanForCapsChange: |
Sunkad, Anand Ningappa | 3ec8bf7 | 2016-02-05 15:13:30 +0530 | [diff] [blame] | 5983 | pScanRsp = (tSirSmeScanRsp *)pMsgBuf; |
| 5984 | scanStatus = (eSIR_SME_SUCCESS == pScanRsp->statusCode) ? |
| 5985 | eCSR_SCAN_SUCCESS : eCSR_SCAN_FAILURE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5986 | csrScanProcessScanResults( pMac, pCommand, pScanRsp, &fRemoveCommand ); |
| 5987 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5988 | case eCsrScanP2PFindPeer: |
Sunkad, Anand Ningappa | 3ec8bf7 | 2016-02-05 15:13:30 +0530 | [diff] [blame] | 5989 | pScanRsp = (tSirSmeScanRsp *)pMsgBuf; |
| 5990 | scanStatus = ((eSIR_SME_SUCCESS == pScanRsp->statusCode) && |
| 5991 | (pScanRsp->length > 50)) ? eCSR_SCAN_FOUND_PEER : eCSR_SCAN_FAILURE; |
| 5992 | csrScanProcessScanResults( pMac, pCommand, pScanRsp, NULL ); |
| 5993 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5994 | case eCsrScanSetBGScanParam: |
| 5995 | default: |
Sunkad, Anand Ningappa | 3ec8bf7 | 2016-02-05 15:13:30 +0530 | [diff] [blame] | 5996 | pScanRsp = (tSirSmeScanRsp *)pMsgBuf; |
| 5997 | scanStatus = (eSIR_SME_SUCCESS == pScanRsp->statusCode) ? |
| 5998 | eCSR_SCAN_SUCCESS : eCSR_SCAN_FAILURE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5999 | if(csrScanProcessScanResults( pMac, pCommand, pScanRsp, &fRemoveCommand )) |
| 6000 | { |
| 6001 | //Not to get channel info if the scan is not a wildcard scan because |
| 6002 | //it may cause scan results got aged out incorrectly. |
Ratheesh S P | ece1f83 | 2015-07-25 15:50:25 +0530 | [diff] [blame] | 6003 | if(csrScanIsWildCardScan( pMac, pCommand ) && |
| 6004 | (!pCommand->u.scanCmd.u.scanRequest.p2pSearch) |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 6005 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 6006 | && (pCommand->u.scanCmd.reason != eCsrScanGetLfrResult) |
| 6007 | #endif |
| 6008 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6009 | { |
Ratheesh S P | ece1f83 | 2015-07-25 15:50:25 +0530 | [diff] [blame] | 6010 | csrScanGetScanChnInfo(pMac, pCommand); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6011 | } |
| 6012 | } |
| 6013 | break; |
| 6014 | }//switch |
| 6015 | if(fRemoveCommand) |
| 6016 | { |
| 6017 | |
| 6018 | csrReleaseScanCommand(pMac, pCommand, scanStatus); |
| 6019 | |
Sunkad, Anand Ningappa | 3ec8bf7 | 2016-02-05 15:13:30 +0530 | [diff] [blame] | 6020 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6021 | smeProcessPendingQueue( pMac ); |
| 6022 | } |
| 6023 | else |
| 6024 | { |
| 6025 | smsLog( pMac, LOGW, "CSR: Scan Completion called but SCAN command is not ACTIVE ..." ); |
| 6026 | status = eHAL_STATUS_FAILURE; |
| 6027 | } |
| 6028 | } |
| 6029 | else |
| 6030 | { |
| 6031 | smsLog( pMac, LOGW, "CSR: Scan Completion called but NO commands are ACTIVE ..." ); |
| 6032 | status = eHAL_STATUS_FAILURE; |
| 6033 | } |
| 6034 | |
| 6035 | return (status); |
| 6036 | } |
| 6037 | |
| 6038 | |
| 6039 | |
| 6040 | |
| 6041 | tCsrScanResultInfo *csrScanResultGetFirst(tpAniSirGlobal pMac, tScanResultHandle hScanResult) |
| 6042 | { |
| 6043 | tListElem *pEntry; |
| 6044 | tCsrScanResult *pResult; |
| 6045 | tCsrScanResultInfo *pRet = NULL; |
| 6046 | tScanResultList *pResultList = (tScanResultList *)hScanResult; |
| 6047 | |
| 6048 | if(pResultList) |
| 6049 | { |
| 6050 | csrLLLock(&pResultList->List); |
| 6051 | pEntry = csrLLPeekHead(&pResultList->List, LL_ACCESS_NOLOCK); |
| 6052 | if(pEntry) |
| 6053 | { |
| 6054 | pResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link); |
| 6055 | pRet = &pResult->Result; |
| 6056 | } |
| 6057 | pResultList->pCurEntry = pEntry; |
| 6058 | csrLLUnlock(&pResultList->List); |
| 6059 | } |
| 6060 | |
| 6061 | return pRet; |
| 6062 | } |
| 6063 | |
| 6064 | |
| 6065 | tCsrScanResultInfo *csrScanResultGetNext(tpAniSirGlobal pMac, tScanResultHandle hScanResult) |
| 6066 | { |
| 6067 | tListElem *pEntry = NULL; |
| 6068 | tCsrScanResult *pResult = NULL; |
| 6069 | tCsrScanResultInfo *pRet = NULL; |
| 6070 | tScanResultList *pResultList = (tScanResultList *)hScanResult; |
| 6071 | |
| 6072 | if(pResultList) |
| 6073 | { |
| 6074 | csrLLLock(&pResultList->List); |
| 6075 | if(NULL == pResultList->pCurEntry) |
| 6076 | { |
| 6077 | pEntry = csrLLPeekHead(&pResultList->List, LL_ACCESS_NOLOCK); |
| 6078 | } |
| 6079 | else |
| 6080 | { |
| 6081 | pEntry = csrLLNext(&pResultList->List, pResultList->pCurEntry, LL_ACCESS_NOLOCK); |
| 6082 | } |
| 6083 | if(pEntry) |
| 6084 | { |
| 6085 | pResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link); |
| 6086 | pRet = &pResult->Result; |
| 6087 | } |
| 6088 | pResultList->pCurEntry = pEntry; |
| 6089 | csrLLUnlock(&pResultList->List); |
| 6090 | } |
| 6091 | |
| 6092 | return pRet; |
| 6093 | } |
| 6094 | |
| 6095 | |
| 6096 | //This function moves the first BSS that matches the bssid to the head of the result |
| 6097 | eHalStatus csrMoveBssToHeadFromBSSID(tpAniSirGlobal pMac, tCsrBssid *bssid, tScanResultHandle hScanResult) |
| 6098 | { |
| 6099 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 6100 | tScanResultList *pResultList = (tScanResultList *)hScanResult; |
| 6101 | tCsrScanResult *pResult = NULL; |
| 6102 | tListElem *pEntry = NULL; |
| 6103 | |
| 6104 | if(pResultList && bssid) |
| 6105 | { |
| 6106 | csrLLLock(&pResultList->List); |
| 6107 | pEntry = csrLLPeekHead(&pResultList->List, LL_ACCESS_NOLOCK); |
| 6108 | while(pEntry) |
| 6109 | { |
| 6110 | pResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6111 | if (vos_mem_compare(bssid, pResult->Result.BssDescriptor.bssId, sizeof(tCsrBssid))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6112 | { |
| 6113 | status = eHAL_STATUS_SUCCESS; |
| 6114 | csrLLRemoveEntry(&pResultList->List, pEntry, LL_ACCESS_NOLOCK); |
| 6115 | csrLLInsertHead(&pResultList->List, pEntry, LL_ACCESS_NOLOCK); |
| 6116 | break; |
| 6117 | } |
| 6118 | pEntry = csrLLNext(&pResultList->List, pResultList->pCurEntry, LL_ACCESS_NOLOCK); |
| 6119 | } |
| 6120 | csrLLUnlock(&pResultList->List); |
| 6121 | } |
| 6122 | |
| 6123 | return (status); |
| 6124 | } |
| 6125 | |
| 6126 | |
| 6127 | //Remove the BSS if possible. |
| 6128 | //Return -- TRUE == the BSS is remove. False == Fail to remove it |
| 6129 | //This function is called when list lock is held. Be caution what functions it can call. |
| 6130 | tANI_BOOLEAN csrScanAgeOutBss(tpAniSirGlobal pMac, tCsrScanResult *pResult) |
| 6131 | { |
| 6132 | tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE; |
| 6133 | tANI_U32 i; |
| 6134 | tCsrRoamSession *pSession; |
Padma, Santhosh Kumar | 748b978 | 2014-07-02 12:24:23 +0530 | [diff] [blame] | 6135 | tANI_BOOLEAN isConnBssfound = eANI_BOOLEAN_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6136 | |
| 6137 | for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ ) |
| 6138 | { |
| 6139 | if( CSR_IS_SESSION_VALID( pMac, i ) ) |
| 6140 | { |
| 6141 | pSession = CSR_GET_SESSION( pMac, i ); |
| 6142 | //Not to remove the BSS we are connected to. |
Padma, Santhosh Kumar | 748b978 | 2014-07-02 12:24:23 +0530 | [diff] [blame] | 6143 | if(csrIsConnStateConnectedInfra(pMac, i) && (NULL != pSession->pConnectBssDesc) && |
| 6144 | (csrIsDuplicateBssDescription(pMac, &pResult->Result.BssDescriptor, |
Tushnim Bhattacharyya | 5128d75 | 2013-06-26 23:23:18 -0700 | [diff] [blame] | 6145 | pSession->pConnectBssDesc, NULL, FALSE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6146 | ) |
Padma, Santhosh Kumar | 748b978 | 2014-07-02 12:24:23 +0530 | [diff] [blame] | 6147 | { |
| 6148 | isConnBssfound = eANI_BOOLEAN_TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6149 | break; |
Padma, Santhosh Kumar | 748b978 | 2014-07-02 12:24:23 +0530 | [diff] [blame] | 6150 | } |
| 6151 | } |
| 6152 | } |
| 6153 | |
| 6154 | if( isConnBssfound ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6155 | { |
Padma, Santhosh Kumar | 748b978 | 2014-07-02 12:24:23 +0530 | [diff] [blame] | 6156 | //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] | 6157 | pResult->AgingCount = (tANI_S32)pMac->roam.configParam.agingCount; |
Deepthi Gowri | 4480a3f | 2016-05-18 19:30:17 +0530 | [diff] [blame] | 6158 | pResult->Result.BssDescriptor.nReceivedTime = |
| 6159 | vos_timer_get_system_time(); |
Padma, Santhosh Kumar | 748b978 | 2014-07-02 12:24:23 +0530 | [diff] [blame] | 6160 | |
| 6161 | return (fRet); |
| 6162 | } |
| 6163 | else |
| 6164 | { |
| 6165 | smsLog(pMac, LOGW, "Aging out BSS "MAC_ADDRESS_STR" Channel %d", |
| 6166 | MAC_ADDR_ARRAY(pResult->Result.BssDescriptor.bssId), |
| 6167 | pResult->Result.BssDescriptor.channelId); |
| 6168 | //No need to hold the spin lock because caller should hold the lock for pMac->scan.scanResultList |
| 6169 | if( csrLLRemoveEntry(&pMac->scan.scanResultList, &pResult->Link, LL_ACCESS_NOLOCK) ) |
| 6170 | { |
| 6171 | if (csrIsMacAddressEqual(pMac, |
| 6172 | (tCsrBssid *) pResult->Result.BssDescriptor.bssId, |
| 6173 | (tCsrBssid *) pMac->scan.currentCountryBssid)) |
| 6174 | { |
| 6175 | smsLog(pMac, LOGW, "Aging out 11d BSS "MAC_ADDRESS_STR, |
| 6176 | MAC_ADDR_ARRAY(pResult->Result.BssDescriptor.bssId)); |
| 6177 | pMac->scan.currentCountryRSSI = -128; |
| 6178 | } |
| 6179 | csrFreeScanResultEntry(pMac, pResult); |
| 6180 | fRet = eANI_BOOLEAN_TRUE; |
| 6181 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6182 | } |
| 6183 | |
| 6184 | return (fRet); |
| 6185 | } |
| 6186 | |
| 6187 | |
| 6188 | eHalStatus csrScanAgeResults(tpAniSirGlobal pMac, tSmeGetScanChnRsp *pScanChnInfo) |
| 6189 | { |
| 6190 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 6191 | tListElem *pEntry, *tmpEntry; |
| 6192 | tCsrScanResult *pResult; |
| 6193 | tLimScanChn *pChnInfo; |
| 6194 | tANI_U8 i; |
| 6195 | |
| 6196 | csrLLLock(&pMac->scan.scanResultList); |
| 6197 | for(i = 0; i < pScanChnInfo->numChn; i++) |
| 6198 | { |
| 6199 | pChnInfo = &pScanChnInfo->scanChn[i]; |
| 6200 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK ); |
| 6201 | while( pEntry ) |
| 6202 | { |
| 6203 | tmpEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK); |
| 6204 | pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 6205 | if(pResult->Result.BssDescriptor.channelId == pChnInfo->channelId) |
| 6206 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6207 | if(pResult->AgingCount <= 0) |
| 6208 | { |
| 6209 | smsLog(pMac, LOGW, " age out due to ref count"); |
| 6210 | csrScanAgeOutBss(pMac, pResult); |
| 6211 | } |
Madan Mohan Koyyalamudi | b9d3dcc | 2012-09-28 16:47:50 -0700 | [diff] [blame] | 6212 | else |
| 6213 | { |
| 6214 | pResult->AgingCount--; |
| 6215 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6216 | } |
| 6217 | pEntry = tmpEntry; |
| 6218 | } |
| 6219 | } |
| 6220 | csrLLUnlock(&pMac->scan.scanResultList); |
| 6221 | |
| 6222 | return (status); |
| 6223 | } |
| 6224 | |
Abhishek Singh | c640dbb | 2015-06-08 10:54:17 +0530 | [diff] [blame] | 6225 | eHalStatus csrIbssAgeBss(tpAniSirGlobal pMac) |
| 6226 | { |
| 6227 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 6228 | tListElem *pEntry, *tmpEntry; |
| 6229 | tCsrScanResult *pResult; |
| 6230 | |
| 6231 | csrLLLock(&pMac->scan.scanResultList); |
| 6232 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK ); |
| 6233 | while( pEntry ) |
| 6234 | { |
| 6235 | tmpEntry = csrLLNext(&pMac->scan.scanResultList, |
| 6236 | pEntry, LL_ACCESS_NOLOCK); |
| 6237 | pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 6238 | |
| 6239 | smsLog(pMac, LOGW, FL(" age out due Forced IBSS leave")); |
| 6240 | csrScanAgeOutBss(pMac, pResult); |
| 6241 | pEntry = tmpEntry; |
| 6242 | } |
| 6243 | csrLLUnlock(&pMac->scan.scanResultList); |
| 6244 | |
| 6245 | return (status); |
| 6246 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6247 | |
Abhishek Singh | 72c2f4e | 2016-07-22 11:25:43 +0530 | [diff] [blame] | 6248 | /** |
| 6249 | * csr_remove_bssid_from_scan_list() - remove the bssid from |
| 6250 | * scan list |
| 6251 | * @pMac: mac context. |
| 6252 | * @bssid: bssid to be removed |
| 6253 | * |
| 6254 | * This function remove the given bssid from scan list. |
| 6255 | * |
| 6256 | * Return: void. |
| 6257 | */ |
| 6258 | void csr_remove_bssid_from_scan_list(tpAniSirGlobal pMac, |
| 6259 | tSirMacAddr bssid) |
| 6260 | { |
| 6261 | tListElem *entry,*free_elem; |
| 6262 | tCsrScanResult *bss_desc; |
| 6263 | tDblLinkList *list = &pMac->scan.scanResultList; |
| 6264 | |
| 6265 | csrLLLock(list); |
| 6266 | entry = csrLLPeekHead(list, LL_ACCESS_NOLOCK); |
| 6267 | while (entry != NULL) { |
| 6268 | bss_desc = GET_BASE_ADDR( entry, tCsrScanResult, Link); |
| 6269 | if (vos_mem_compare(bss_desc->Result.BssDescriptor.bssId, |
| 6270 | bssid, sizeof(tSirMacAddr))) { |
| 6271 | free_elem = entry; |
| 6272 | entry = csrLLNext(list, entry, LL_ACCESS_NOLOCK); |
| 6273 | csrLLRemoveEntry(list, free_elem, LL_ACCESS_NOLOCK); |
| 6274 | csrFreeScanResultEntry(pMac, bss_desc); |
| 6275 | smsLog(pMac, LOGW, FL("Removed BSS entry:%pM"), |
| 6276 | bssid); |
| 6277 | continue; |
| 6278 | } |
| 6279 | entry = csrLLNext(list, entry, LL_ACCESS_NOLOCK); |
| 6280 | } |
| 6281 | csrLLUnlock(list); |
| 6282 | } |
| 6283 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6284 | eHalStatus csrSendMBScanReq( tpAniSirGlobal pMac, tANI_U16 sessionId, |
| 6285 | tCsrScanRequest *pScanReq, tScanReqParam *pScanReqParam ) |
| 6286 | { |
| 6287 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 6288 | tSirSmeScanReq *pMsg; |
| 6289 | tANI_U16 msgLen; |
| 6290 | tANI_U8 bssid[WNI_CFG_BSSID_LEN] = {0, 0, 0, 0, 0, 0}; |
| 6291 | tSirScanType scanType = pScanReq->scanType; |
| 6292 | tANI_U32 minChnTime; //in units of milliseconds |
| 6293 | tANI_U32 maxChnTime; //in units of milliseconds |
| 6294 | tANI_U32 i; |
| 6295 | tANI_U8 selfMacAddr[WNI_CFG_BSSID_LEN]; |
| 6296 | tANI_U8 *pSelfMac = NULL; |
| 6297 | |
| 6298 | msgLen = (tANI_U16)(sizeof( tSirSmeScanReq ) - sizeof( pMsg->channelList.channelNumber ) + |
| 6299 | ( sizeof( pMsg->channelList.channelNumber ) * pScanReq->ChannelInfo.numOfChannels )) + |
| 6300 | ( pScanReq->uIEFieldLen ) ; |
| 6301 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6302 | pMsg = vos_mem_malloc(msgLen); |
| 6303 | if ( NULL == pMsg ) |
| 6304 | status = eHAL_STATUS_FAILURE; |
| 6305 | else |
| 6306 | status = eHAL_STATUS_SUCCESS; |
| 6307 | if (HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6308 | { |
| 6309 | do |
| 6310 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6311 | vos_mem_set(pMsg, msgLen, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6312 | pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SCAN_REQ); |
| 6313 | pMsg->length = pal_cpu_to_be16(msgLen); |
| 6314 | //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] | 6315 | if ((pMac->fScanOffload) && (sessionId != CSR_SESSION_ID_INVALID)) |
| 6316 | { |
| 6317 | pMsg->sessionId = sessionId; |
| 6318 | } |
| 6319 | else |
| 6320 | { |
| 6321 | /* if sessionId == CSR_SESSION_ID_INVALID, then send the scan |
| 6322 | request on first available session */ |
| 6323 | pMsg->sessionId = 0; |
| 6324 | } |
| 6325 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6326 | pMsg->transactionId = 0; |
| 6327 | pMsg->dot11mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac, csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode )); |
| 6328 | pMsg->bssType = pal_cpu_to_be32(csrTranslateBsstypeToMacType(pScanReq->BSSType)); |
| 6329 | |
| 6330 | if ( CSR_IS_SESSION_VALID( pMac, sessionId ) ) |
| 6331 | { |
| 6332 | pSelfMac = (tANI_U8 *)&pMac->roam.roamSession[sessionId].selfMacAddr; |
| 6333 | } |
| 6334 | else |
| 6335 | { |
| 6336 | // Since we don't have session for the scanning, we find a valid session. In case we fail to |
| 6337 | // do so, get the WNI_CFG_STA_ID |
| 6338 | for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ ) |
| 6339 | { |
| 6340 | if( CSR_IS_SESSION_VALID( pMac, i ) ) |
| 6341 | { |
| 6342 | pSelfMac = (tANI_U8 *)&pMac->roam.roamSession[i].selfMacAddr; |
| 6343 | break; |
| 6344 | } |
| 6345 | } |
| 6346 | if( CSR_ROAM_SESSION_MAX == i ) |
| 6347 | { |
| 6348 | tANI_U32 len = WNI_CFG_BSSID_LEN; |
| 6349 | pSelfMac = selfMacAddr; |
| 6350 | status = ccmCfgGetStr( pMac, WNI_CFG_STA_ID, pSelfMac, &len ); |
| 6351 | if( !HAL_STATUS_SUCCESS( status ) || |
| 6352 | ( len < WNI_CFG_BSSID_LEN ) ) |
| 6353 | { |
| 6354 | smsLog( pMac, LOGE, FL(" Can not get self MAC address from CFG status = %d"), status ); |
| 6355 | //Force failed status |
| 6356 | status = eHAL_STATUS_FAILURE; |
| 6357 | break; |
| 6358 | } |
| 6359 | } |
| 6360 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6361 | vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, pSelfMac, sizeof(tSirMacAddr)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6362 | |
| 6363 | //sirCopyMacAddr |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6364 | vos_mem_copy((tANI_U8 *)pMsg->bssId, (tANI_U8 *)&pScanReq->bssid, sizeof(tSirMacAddr)); |
| 6365 | if ( vos_mem_compare(pScanReq->bssid, bssid, sizeof(tCsrBssid))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6366 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6367 | vos_mem_set(pMsg->bssId, sizeof(tSirMacAddr), 0xff); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6368 | } |
| 6369 | else |
| 6370 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6371 | vos_mem_copy(pMsg->bssId, pScanReq->bssid, WNI_CFG_BSSID_LEN); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6372 | } |
| 6373 | minChnTime = pScanReq->minChnTime; |
| 6374 | maxChnTime = pScanReq->maxChnTime; |
| 6375 | |
| 6376 | //Verify the scan type first, if the scan is active scan, we need to make sure we |
| 6377 | //are allowed to do so. |
| 6378 | /* if 11d is enabled & we don't see any beacon around, scan type falls |
| 6379 | back to passive. But in BT AMP STA mode we need to send out a |
| 6380 | directed probe*/ |
| 6381 | if( (eSIR_PASSIVE_SCAN != scanType) && (eCSR_SCAN_P2P_DISCOVERY != pScanReq->requestType) |
| 6382 | && (eCSR_BSS_TYPE_WDS_STA != pScanReq->BSSType) |
| 6383 | && (eANI_BOOLEAN_FALSE == pMac->scan.fEnableBypass11d)) |
| 6384 | { |
| 6385 | scanType = pMac->scan.curScanType; |
| 6386 | if(eSIR_PASSIVE_SCAN == pMac->scan.curScanType) |
| 6387 | { |
| 6388 | if(minChnTime < pMac->roam.configParam.nPassiveMinChnTime) |
| 6389 | { |
| 6390 | minChnTime = pMac->roam.configParam.nPassiveMinChnTime; |
| 6391 | } |
| 6392 | if(maxChnTime < pMac->roam.configParam.nPassiveMaxChnTime) |
| 6393 | { |
| 6394 | maxChnTime = pMac->roam.configParam.nPassiveMaxChnTime; |
| 6395 | } |
| 6396 | } |
| 6397 | } |
| 6398 | pMsg->scanType = pal_cpu_to_be32(scanType); |
| 6399 | |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 6400 | pMsg->numSsid = |
| 6401 | (pScanReq->SSIDs.numOfSSIDs < SIR_SCAN_MAX_NUM_SSID) ? |
| 6402 | pScanReq->SSIDs.numOfSSIDs : SIR_SCAN_MAX_NUM_SSID; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6403 | if((pScanReq->SSIDs.numOfSSIDs != 0) && ( eSIR_PASSIVE_SCAN != scanType )) |
| 6404 | { |
Jeff Johnson | 40b59aa | 2013-03-19 14:43:18 -0700 | [diff] [blame] | 6405 | for (i = 0; i < pMsg->numSsid; i++) |
| 6406 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6407 | vos_mem_copy(&pMsg->ssId[i], |
| 6408 | &pScanReq->SSIDs.SSIDList[i].SSID, sizeof(tSirMacSSid)); |
Jeff Johnson | 40b59aa | 2013-03-19 14:43:18 -0700 | [diff] [blame] | 6409 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6410 | } |
| 6411 | else |
| 6412 | { |
| 6413 | //Otherwise we scan all SSID and let the result filter later |
Jeff Johnson | 40b59aa | 2013-03-19 14:43:18 -0700 | [diff] [blame] | 6414 | for (i = 0; i < SIR_SCAN_MAX_NUM_SSID; i++) |
| 6415 | { |
| 6416 | pMsg->ssId[i].length = 0; |
| 6417 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6418 | } |
| 6419 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6420 | pMsg->minChannelTime = pal_cpu_to_be32(minChnTime); |
| 6421 | pMsg->maxChannelTime = pal_cpu_to_be32(maxChnTime); |
Abhishek Singh | add1358 | 2016-09-29 17:00:03 +0530 | [diff] [blame] | 6422 | pMsg->min_chntime_btc_esco = |
| 6423 | pMac->roam.configParam.min_chntime_btc_esco; |
| 6424 | pMsg->max_chntime_btc_esco = |
| 6425 | pMac->roam.configParam.max_chntime_btc_esco; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6426 | //hidden SSID option |
| 6427 | pMsg->hiddenSsid = pScanReqParam->hiddenSsid; |
| 6428 | //rest time |
| 6429 | //pMsg->restTime = pScanReq->restTime; |
| 6430 | pMsg->returnAfterFirstMatch = pScanReqParam->bReturnAfter1stMatch; |
| 6431 | // All the scan results caching will be done by Roaming |
| 6432 | // We do not want LIM to do any caching of scan results, |
| 6433 | // so delete the LIM cache on all scan requests |
| 6434 | pMsg->returnFreshResults = pScanReqParam->freshScan; |
| 6435 | //Always ask for unique result |
| 6436 | pMsg->returnUniqueResults = pScanReqParam->fUniqueResult; |
| 6437 | pMsg->channelList.numChannels = (tANI_U8)pScanReq->ChannelInfo.numOfChannels; |
| 6438 | if(pScanReq->ChannelInfo.numOfChannels) |
| 6439 | { |
| 6440 | //Assuming the channelNumber is tANI_U8 (1 byte) |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6441 | vos_mem_copy(pMsg->channelList.channelNumber, |
| 6442 | pScanReq->ChannelInfo.ChannelList, |
| 6443 | pScanReq->ChannelInfo.numOfChannels); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6444 | } |
| 6445 | |
| 6446 | pMsg->uIEFieldLen = (tANI_U16) pScanReq->uIEFieldLen; |
| 6447 | pMsg->uIEFieldOffset = (tANI_U16)(sizeof( tSirSmeScanReq ) - sizeof( pMsg->channelList.channelNumber ) + |
| 6448 | ( sizeof( pMsg->channelList.channelNumber ) * pScanReq->ChannelInfo.numOfChannels )) ; |
| 6449 | if(pScanReq->uIEFieldLen != 0) |
| 6450 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6451 | vos_mem_copy((tANI_U8 *)pMsg+pMsg->uIEFieldOffset, pScanReq->pIEField, |
| 6452 | pScanReq->uIEFieldLen); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6453 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6454 | pMsg->p2pSearch = pScanReq->p2pSearch; |
Rajeev Kumar Sirasanagandla | 2bb30b8 | 2019-01-07 22:30:16 +0530 | [diff] [blame] | 6455 | pMsg->scan_randomize= pScanReq->scan_randomize; |
| 6456 | pMsg->nl_scan = pScanReq->nl_scan; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6457 | |
Madan Mohan Koyyalamudi | 9b87678 | 2012-10-11 16:22:51 -0700 | [diff] [blame] | 6458 | if (pScanReq->requestType == eCSR_SCAN_HO_BG_SCAN) |
| 6459 | { |
| 6460 | pMsg->backgroundScanMode = eSIR_ROAMING_SCAN; |
| 6461 | } |
| 6462 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6463 | }while(0); |
Sushant Kaushik | e0d2cce | 2014-04-10 14:36:07 +0530 | [diff] [blame] | 6464 | smsLog(pMac, LOG1, FL("domainIdCurrent %s (%d) scanType %s (%d)" |
| 6465 | "bssType %s (%d), requestType %s(%d)" |
| 6466 | "numChannels %d"), |
| 6467 | voss_DomainIdtoString(pMac->scan.domainIdCurrent), |
| 6468 | pMac->scan.domainIdCurrent, |
| 6469 | lim_ScanTypetoString(pMsg->scanType), pMsg->scanType, |
| 6470 | lim_BssTypetoString(pMsg->bssType), pMsg->bssType, |
| 6471 | sme_requestTypetoString(pScanReq->requestType), |
| 6472 | pScanReq->requestType, |
| 6473 | pMsg->channelList.numChannels); |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 6474 | |
| 6475 | for(i = 0; i < pMsg->channelList.numChannels; i++) |
| 6476 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6477 | smsLog(pMac, LOG3, FL("channelNumber[%d]= %d"), i, pMsg->channelList.channelNumber[i]); |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 6478 | } |
| 6479 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6480 | if(HAL_STATUS_SUCCESS(status)) |
| 6481 | { |
| 6482 | status = palSendMBMessage(pMac->hHdd, pMsg); |
| 6483 | } |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 6484 | else |
| 6485 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6486 | 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] | 6487 | vos_mem_free(pMsg); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6488 | } |
| 6489 | }//Success allocated memory |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 6490 | else |
| 6491 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6492 | smsLog( pMac, LOGE, FL(" memory allocation failure")); |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 6493 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6494 | |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 6495 | if(!HAL_STATUS_SUCCESS(status)) |
| 6496 | { |
| 6497 | smsLog( pMac, LOG1, FL("Failed: SId: %d FirstMatch = %d" |
| 6498 | " UniqueResult = %d freshScan = %d hiddenSsid = %d"), |
| 6499 | sessionId, pScanReqParam->bReturnAfter1stMatch, |
| 6500 | pScanReqParam->fUniqueResult, pScanReqParam->freshScan, |
| 6501 | pScanReqParam->hiddenSsid ); |
Sushant Kaushik | e0d2cce | 2014-04-10 14:36:07 +0530 | [diff] [blame] | 6502 | smsLog( pMac, LOG1, FL("scanType = %s (%d) BSSType = %s (%d) " |
| 6503 | "numOfSSIDs = %d numOfChannels = %d requestType = %s (%d)" |
| 6504 | " p2pSearch = %d\n"), |
| 6505 | lim_ScanTypetoString(pScanReq->scanType), |
| 6506 | pScanReq->scanType, |
| 6507 | lim_BssTypetoString(pScanReq->BSSType), |
| 6508 | pScanReq->BSSType, |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 6509 | pScanReq->SSIDs.numOfSSIDs, |
Sushant Kaushik | e0d2cce | 2014-04-10 14:36:07 +0530 | [diff] [blame] | 6510 | pScanReq->ChannelInfo.numOfChannels, |
| 6511 | sme_requestTypetoString(pScanReq->requestType), |
| 6512 | pScanReq->requestType, |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 6513 | pScanReq->p2pSearch ); |
| 6514 | |
| 6515 | } |
| 6516 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6517 | return( status ); |
| 6518 | } |
| 6519 | |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 6520 | eHalStatus csrSendMBScanResultReq( tpAniSirGlobal pMac, tANI_U32 sessionId, tScanReqParam *pScanReqParam ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6521 | { |
| 6522 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 6523 | tSirSmeScanReq *pMsg; |
| 6524 | tANI_U16 msgLen; |
| 6525 | |
| 6526 | msgLen = (tANI_U16)(sizeof( tSirSmeScanReq )); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6527 | pMsg = vos_mem_malloc(msgLen); |
| 6528 | if ( NULL == pMsg ) |
| 6529 | status = eHAL_STATUS_FAILURE; |
| 6530 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6531 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6532 | vos_mem_set(pMsg, msgLen, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6533 | pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SCAN_REQ); |
| 6534 | pMsg->length = pal_cpu_to_be16(msgLen); |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 6535 | pMsg->sessionId = sessionId; |
| 6536 | pMsg->transactionId = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6537 | pMsg->returnFreshResults = pScanReqParam->freshScan; |
| 6538 | //Always ask for unique result |
| 6539 | pMsg->returnUniqueResults = pScanReqParam->fUniqueResult; |
| 6540 | pMsg->returnAfterFirstMatch = pScanReqParam->bReturnAfter1stMatch; |
| 6541 | status = palSendMBMessage(pMac->hHdd, pMsg); |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 6542 | if (!HAL_STATUS_SUCCESS(status)) |
| 6543 | { |
| 6544 | smsLog( pMac, LOGE, FL(" failed to send down scan req with status = %d\n"), status ); |
| 6545 | } |
| 6546 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6547 | } |
| 6548 | |
| 6549 | return( status ); |
| 6550 | } |
| 6551 | |
| 6552 | |
| 6553 | |
| 6554 | eHalStatus csrScanChannels( tpAniSirGlobal pMac, tSmeCmd *pCommand ) |
| 6555 | { |
| 6556 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 6557 | tScanReqParam scanReq; |
| 6558 | |
| 6559 | do |
| 6560 | { |
| 6561 | scanReq.freshScan = CSR_SME_SCAN_FLAGS_DELETE_CACHE | TRUE; |
| 6562 | scanReq.fUniqueResult = TRUE; |
| 6563 | scanReq.hiddenSsid = SIR_SCAN_NO_HIDDEN_SSID; |
| 6564 | if(eCsrScanForSsid == pCommand->u.scanCmd.reason) |
| 6565 | { |
| 6566 | scanReq.bReturnAfter1stMatch = CSR_SCAN_RETURN_AFTER_FIRST_MATCH; |
| 6567 | } |
| 6568 | else |
| 6569 | { |
| 6570 | // Basically do scan on all channels even for 11D 1st scan case. |
| 6571 | scanReq.bReturnAfter1stMatch = CSR_SCAN_RETURN_AFTER_ALL_CHANNELS; |
| 6572 | } |
| 6573 | if((eCsrScanBgScan == pCommand->u.scanCmd.reason)|| |
| 6574 | (eCsrScanProbeBss == pCommand->u.scanCmd.reason)) |
| 6575 | { |
| 6576 | scanReq.hiddenSsid = SIR_SCAN_HIDDEN_SSID_PE_DECISION; |
| 6577 | } |
| 6578 | |
| 6579 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 6580 | { |
| 6581 | vos_log_scan_pkt_type *pScanLog = NULL; |
| 6582 | |
| 6583 | WLAN_VOS_DIAG_LOG_ALLOC(pScanLog, vos_log_scan_pkt_type, LOG_WLAN_SCAN_C); |
| 6584 | if(pScanLog) |
| 6585 | { |
| 6586 | if(eCsrScanBgScan == pCommand->u.scanCmd.reason || |
| 6587 | eCsrScanProbeBss == pCommand->u.scanCmd.reason) |
| 6588 | { |
| 6589 | pScanLog->eventId = WLAN_SCAN_EVENT_HO_SCAN_REQ; |
| 6590 | } |
| 6591 | else |
| 6592 | { |
| 6593 | if( (eSIR_PASSIVE_SCAN != pCommand->u.scanCmd.u.scanRequest.scanType) && |
| 6594 | (eSIR_PASSIVE_SCAN != pMac->scan.curScanType) ) |
| 6595 | { |
| 6596 | pScanLog->eventId = WLAN_SCAN_EVENT_ACTIVE_SCAN_REQ; |
| 6597 | } |
| 6598 | else |
| 6599 | { |
| 6600 | pScanLog->eventId = WLAN_SCAN_EVENT_PASSIVE_SCAN_REQ; |
| 6601 | } |
| 6602 | } |
| 6603 | pScanLog->minChnTime = (v_U8_t)pCommand->u.scanCmd.u.scanRequest.minChnTime; |
| 6604 | pScanLog->maxChnTime = (v_U8_t)pCommand->u.scanCmd.u.scanRequest.maxChnTime; |
| 6605 | pScanLog->numChannel = (v_U8_t)pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels; |
| 6606 | if(pScanLog->numChannel && (pScanLog->numChannel < VOS_LOG_MAX_NUM_CHANNEL)) |
| 6607 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6608 | vos_mem_copy(pScanLog->channels, |
| 6609 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList, |
| 6610 | pScanLog->numChannel); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6611 | } |
| 6612 | WLAN_VOS_DIAG_LOG_REPORT(pScanLog); |
| 6613 | } |
| 6614 | } |
| 6615 | #endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 6616 | |
Agrawal Ashish | 0b6984f | 2014-04-05 18:35:45 +0530 | [diff] [blame] | 6617 | csrClearVotesForCountryInfo(pMac); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6618 | status = csrSendMBScanReq(pMac, pCommand->sessionId, |
| 6619 | &pCommand->u.scanCmd.u.scanRequest, &scanReq); |
| 6620 | }while(0); |
| 6621 | |
| 6622 | return( status ); |
| 6623 | } |
| 6624 | |
| 6625 | |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 6626 | eHalStatus csrScanRetrieveResult(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6627 | { |
| 6628 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 6629 | tScanReqParam scanReq; |
| 6630 | |
| 6631 | do |
| 6632 | { |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 6633 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 6634 | if (eCsrScanGetLfrResult == pCommand->u.scanCmd.reason) |
| 6635 | { |
| 6636 | //to get the LFR candidates from PE cache |
| 6637 | scanReq.freshScan = SIR_BG_SCAN_RETURN_LFR_CACHED_RESULTS|SIR_BG_SCAN_PURGE_LFR_RESULTS; |
| 6638 | scanReq.fUniqueResult = TRUE; |
| 6639 | scanReq.bReturnAfter1stMatch = CSR_SCAN_RETURN_AFTER_ALL_CHANNELS; |
| 6640 | } |
| 6641 | else |
| 6642 | #endif |
| 6643 | { |
| 6644 | //not a fresh scan |
| 6645 | scanReq.freshScan = CSR_SME_SCAN_FLAGS_DELETE_CACHE; |
| 6646 | scanReq.fUniqueResult = TRUE; |
| 6647 | scanReq.bReturnAfter1stMatch = CSR_SCAN_RETURN_AFTER_ALL_CHANNELS; |
| 6648 | } |
| 6649 | status = csrSendMBScanResultReq(pMac, pCommand->sessionId, &scanReq); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6650 | }while(0); |
| 6651 | |
| 6652 | return (status); |
| 6653 | } |
| 6654 | |
Siddharth Bhal | d8a95e8 | 2015-02-12 20:14:52 +0530 | [diff] [blame] | 6655 | eHalStatus csrProcessMacAddrSpoofCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand ) |
| 6656 | { |
| 6657 | tSirSpoofMacAddrReq *pMsg; |
| 6658 | tANI_U16 msgLen; |
| 6659 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 6660 | do { |
| 6661 | msgLen = sizeof(tSirSpoofMacAddrReq); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6662 | |
Siddharth Bhal | d8a95e8 | 2015-02-12 20:14:52 +0530 | [diff] [blame] | 6663 | pMsg = vos_mem_malloc(msgLen); |
| 6664 | if ( NULL == pMsg ) |
| 6665 | return eHAL_STATUS_FAILURE; |
| 6666 | pMsg->messageType= pal_cpu_to_be16((tANI_U16)eWNI_SME_MAC_SPOOF_ADDR_IND); |
| 6667 | pMsg->length= pal_cpu_to_be16(msgLen); |
| 6668 | // spoof mac address |
| 6669 | vos_mem_copy((tANI_U8 *)pMsg->macAddr, |
| 6670 | (tANI_U8 *)pCommand->u.macAddrSpoofCmd.macAddr, sizeof(tSirMacAddr)); |
Rajeev Kumar Sirasanagandla | 2bb30b8 | 2019-01-07 22:30:16 +0530 | [diff] [blame] | 6671 | pMsg->spoof_mac_oui = |
| 6672 | pal_cpu_to_be16(pCommand->u.macAddrSpoofCmd.spoof_mac_oui); |
| 6673 | |
Siddharth Bhal | d8a95e8 | 2015-02-12 20:14:52 +0530 | [diff] [blame] | 6674 | status = palSendMBMessage(pMac->hHdd, pMsg); |
| 6675 | } while( 0 ); |
| 6676 | return( status ); |
| 6677 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6678 | |
| 6679 | eHalStatus csrProcessScanCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand ) |
| 6680 | { |
| 6681 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 6682 | tCsrChannelInfo newChannelInfo = {0, NULL}; |
| 6683 | int i, j; |
| 6684 | tANI_U8 *pChannel = NULL; |
| 6685 | tANI_U32 len = 0; |
| 6686 | |
| 6687 | // Transition to Scanning state... |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 6688 | if (!pMac->fScanOffload) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6689 | { |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 6690 | for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ ) |
| 6691 | { |
Abhishek Singh | f52182c | 2016-08-24 11:15:23 +0530 | [diff] [blame] | 6692 | pMac->roam.prev_state[i]= |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 6693 | csrRoamStateChange( pMac, eCSR_ROAMING_STATE_SCANNING, i); |
| 6694 | smsLog( pMac, LOG3, "starting SCAN command from %d state...." |
Abhishek Singh | f52182c | 2016-08-24 11:15:23 +0530 | [diff] [blame] | 6695 | " reason is %d", pMac->roam.prev_state[i], |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 6696 | pCommand->u.scanCmd.reason ); |
| 6697 | } |
| 6698 | } |
| 6699 | else |
| 6700 | { |
Abhishek Singh | f52182c | 2016-08-24 11:15:23 +0530 | [diff] [blame] | 6701 | pMac->roam.prev_state[pCommand->sessionId] = |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 6702 | csrRoamStateChange(pMac, eCSR_ROAMING_STATE_SCANNING, |
| 6703 | pCommand->sessionId); |
| 6704 | smsLog( pMac, LOG3, |
| 6705 | "starting SCAN command from %d state.... reason is %d", |
Abhishek Singh | f52182c | 2016-08-24 11:15:23 +0530 | [diff] [blame] | 6706 | pMac->roam.prev_state[pCommand->sessionId], |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 6707 | pCommand->u.scanCmd.reason ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6708 | } |
| 6709 | |
| 6710 | switch(pCommand->u.scanCmd.reason) |
| 6711 | { |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 6712 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 6713 | case eCsrScanGetLfrResult: |
| 6714 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6715 | case eCsrScanGetResult: |
| 6716 | case eCsrScanForCapsChange: //For cap change, LIM already save BSS description |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 6717 | status = csrScanRetrieveResult(pMac, pCommand); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6718 | break; |
| 6719 | case eCsrScanSetBGScanParam: |
| 6720 | status = csrProcessSetBGScanParam(pMac, pCommand); |
| 6721 | break; |
| 6722 | case eCsrScanBGScanAbort: |
| 6723 | status = csrSetCfgBackgroundScanPeriod(pMac, 0); |
| 6724 | break; |
| 6725 | case eCsrScanBGScanEnable: |
| 6726 | status = csrSetCfgBackgroundScanPeriod(pMac, pMac->roam.configParam.bgScanInterval); |
| 6727 | break; |
| 6728 | case eCsrScanGetScanChnInfo: |
Madan Mohan Koyyalamudi | de1b5bc | 2013-07-12 00:56:04 +0530 | [diff] [blame] | 6729 | status = csrScanGetScanChannelInfo(pMac, pCommand->sessionId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6730 | break; |
| 6731 | case eCsrScanUserRequest: |
| 6732 | if(pMac->roam.configParam.fScanTwice) |
| 6733 | { |
| 6734 | //We scan 2.4 channel twice |
| 6735 | if(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels && |
| 6736 | (NULL != pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList)) |
| 6737 | { |
| 6738 | len = pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels; |
| 6739 | //allocate twice the channel |
Mukul Sharma | a631e89 | 2014-08-28 15:38:51 +0530 | [diff] [blame] | 6740 | newChannelInfo.ChannelList = (tANI_U8 *)vos_mem_malloc(len * 2); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6741 | pChannel = pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList; |
| 6742 | } |
| 6743 | else |
| 6744 | { |
| 6745 | //get the valid channel list to scan all. |
| 6746 | len = sizeof(pMac->roam.validChannelList); |
| 6747 | |
| 6748 | if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len))) |
| 6749 | { |
| 6750 | //allocate twice the channel |
| 6751 | newChannelInfo.ChannelList = (tANI_U8 *)vos_mem_malloc(len * 2); |
| 6752 | pChannel = pMac->roam.validChannelList; |
| 6753 | } |
| 6754 | } |
| 6755 | if(NULL == newChannelInfo.ChannelList) |
| 6756 | { |
| 6757 | newChannelInfo.numOfChannels = 0; |
| 6758 | } |
| 6759 | else |
| 6760 | { |
| 6761 | j = 0; |
| 6762 | for(i = 0; i < len; i++) |
| 6763 | { |
| 6764 | newChannelInfo.ChannelList[j++] = pChannel[i]; |
| 6765 | if(CSR_MAX_24GHz_CHANNEL_NUMBER >= pChannel[i]) |
| 6766 | { |
| 6767 | newChannelInfo.ChannelList[j++] = pChannel[i]; |
| 6768 | } |
| 6769 | } |
| 6770 | if(NULL != pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList) |
| 6771 | { |
| 6772 | //pChannel points to the channellist from the command, free it. |
| 6773 | vos_mem_free(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList); |
James Zmuda | 9ea1edd | 2013-04-18 18:20:54 -0700 | [diff] [blame] | 6774 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6775 | } |
| 6776 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = j; |
| 6777 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = newChannelInfo.ChannelList; |
| 6778 | } |
| 6779 | } //if(pMac->roam.configParam.fScanTwice) |
| 6780 | |
| 6781 | status = csrScanChannels(pMac, pCommand); |
| 6782 | |
| 6783 | break; |
| 6784 | default: |
| 6785 | status = csrScanChannels(pMac, pCommand); |
| 6786 | break; |
| 6787 | } |
| 6788 | |
| 6789 | if(!HAL_STATUS_SUCCESS(status)) |
| 6790 | { |
| 6791 | csrReleaseScanCommand(pMac, pCommand, eCSR_SCAN_FAILURE); |
| 6792 | } |
| 6793 | |
| 6794 | return (status); |
| 6795 | } |
| 6796 | |
| 6797 | |
| 6798 | eHalStatus csrScanSetBGScanparams(tpAniSirGlobal pMac, tCsrBGScanRequest *pScanReq) |
| 6799 | { |
| 6800 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 6801 | tSmeCmd *pCommand = NULL; |
| 6802 | |
| 6803 | if(pScanReq) |
| 6804 | { |
| 6805 | do |
| 6806 | { |
| 6807 | pCommand = csrGetCommandBuffer(pMac); |
| 6808 | if(!pCommand) |
| 6809 | { |
| 6810 | status = eHAL_STATUS_RESOURCES; |
| 6811 | break; |
| 6812 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6813 | vos_mem_set(&pCommand->u.scanCmd, sizeof(tScanCmd), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6814 | pCommand->command = eSmeCommandScan; |
| 6815 | pCommand->u.scanCmd.reason = eCsrScanSetBGScanParam; |
| 6816 | pCommand->u.scanCmd.callback = NULL; |
| 6817 | pCommand->u.scanCmd.pContext = NULL; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6818 | vos_mem_copy(&pCommand->u.scanCmd.u.bgScanRequest, pScanReq, sizeof(tCsrBGScanRequest)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6819 | //we have to do the follow |
| 6820 | if(pScanReq->ChannelInfo.numOfChannels == 0) |
| 6821 | { |
| 6822 | pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList = NULL; |
| 6823 | } |
| 6824 | else |
| 6825 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6826 | pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList |
| 6827 | = vos_mem_malloc(pScanReq->ChannelInfo.numOfChannels); |
| 6828 | if ( NULL != pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6829 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6830 | vos_mem_copy(pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList, |
| 6831 | pScanReq->ChannelInfo.ChannelList, |
| 6832 | pScanReq->ChannelInfo.numOfChannels); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6833 | } |
| 6834 | else |
| 6835 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6836 | smsLog(pMac, LOGE, FL("ran out of memory")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6837 | csrReleaseCommandScan(pMac, pCommand); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6838 | return eHAL_STATUS_FAILURE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6839 | } |
| 6840 | } |
| 6841 | |
| 6842 | //scan req for SSID |
| 6843 | if(pScanReq->SSID.length) |
| 6844 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6845 | vos_mem_copy(pCommand->u.scanCmd.u.bgScanRequest.SSID.ssId, |
| 6846 | pScanReq->SSID.ssId, pScanReq->SSID.length); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6847 | pCommand->u.scanCmd.u.bgScanRequest.SSID.length = pScanReq->SSID.length; |
| 6848 | |
| 6849 | } |
| 6850 | pCommand->u.scanCmd.u.bgScanRequest.maxChnTime= pScanReq->maxChnTime; |
| 6851 | pCommand->u.scanCmd.u.bgScanRequest.minChnTime = pScanReq->minChnTime; |
| 6852 | pCommand->u.scanCmd.u.bgScanRequest.scanInterval = pScanReq->scanInterval; |
| 6853 | |
| 6854 | |
| 6855 | status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE); |
| 6856 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 6857 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6858 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6859 | csrReleaseCommandScan( pMac, pCommand ); |
| 6860 | break; |
| 6861 | } |
| 6862 | }while(0); |
| 6863 | } |
| 6864 | |
| 6865 | return (status); |
| 6866 | } |
| 6867 | |
| 6868 | eHalStatus csrScanBGScanAbort( tpAniSirGlobal pMac ) |
| 6869 | { |
| 6870 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 6871 | tSmeCmd *pCommand = NULL; |
| 6872 | |
| 6873 | do |
| 6874 | { |
| 6875 | pCommand = csrGetCommandBuffer(pMac); |
| 6876 | if(!pCommand) |
| 6877 | { |
| 6878 | status = eHAL_STATUS_RESOURCES; |
| 6879 | break; |
| 6880 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6881 | vos_mem_set(&pCommand->u.scanCmd, sizeof(tScanCmd), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6882 | pCommand->command = eSmeCommandScan; |
| 6883 | pCommand->u.scanCmd.reason = eCsrScanBGScanAbort; |
| 6884 | pCommand->u.scanCmd.callback = NULL; |
| 6885 | pCommand->u.scanCmd.pContext = NULL; |
| 6886 | status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE); |
| 6887 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 6888 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6889 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6890 | csrReleaseCommandScan( pMac, pCommand ); |
| 6891 | break; |
| 6892 | } |
| 6893 | }while(0); |
| 6894 | |
| 6895 | return (status); |
| 6896 | } |
| 6897 | |
| 6898 | |
| 6899 | //This will enable the background scan with the non-zero interval |
| 6900 | eHalStatus csrScanBGScanEnable(tpAniSirGlobal pMac) |
| 6901 | { |
| 6902 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 6903 | tSmeCmd *pCommand = NULL; |
| 6904 | |
| 6905 | if(pMac->roam.configParam.bgScanInterval) |
| 6906 | { |
| 6907 | do |
| 6908 | { |
| 6909 | pCommand = csrGetCommandBuffer(pMac); |
| 6910 | if(!pCommand) |
| 6911 | { |
| 6912 | status = eHAL_STATUS_RESOURCES; |
| 6913 | break; |
| 6914 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6915 | vos_mem_set(&pCommand->u.scanCmd, sizeof(tScanCmd), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6916 | pCommand->command = eSmeCommandScan; |
| 6917 | pCommand->u.scanCmd.reason = eCsrScanBGScanEnable; |
| 6918 | pCommand->u.scanCmd.callback = NULL; |
| 6919 | pCommand->u.scanCmd.pContext = NULL; |
| 6920 | status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE); |
| 6921 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 6922 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6923 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6924 | csrReleaseCommandScan( pMac, pCommand ); |
| 6925 | break; |
| 6926 | } |
| 6927 | }while(0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6928 | } |
| 6929 | else |
| 6930 | { |
Sushant Kaushik | b8dbb3f | 2015-04-29 17:03:37 +0530 | [diff] [blame] | 6931 | smsLog(pMac, LOGE, FL("cannot continue because the bgscan interval is 0")); |
| 6932 | status = eHAL_STATUS_INVALID_PARAMETER; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6933 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6934 | return (status); |
| 6935 | } |
| 6936 | |
| 6937 | |
| 6938 | eHalStatus csrScanCopyRequest(tpAniSirGlobal pMac, tCsrScanRequest *pDstReq, tCsrScanRequest *pSrcReq) |
| 6939 | { |
| 6940 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 6941 | tANI_U32 len = sizeof(pMac->roam.validChannelList); |
| 6942 | tANI_U32 index = 0; |
| 6943 | tANI_U32 new_index = 0; |
Manjunathappa Prakash | de7b2a5 | 2014-02-28 16:59:03 -0800 | [diff] [blame] | 6944 | eNVChannelEnabledType NVchannel_state; |
Arif Hussain | 6af3862 | 2014-03-12 12:39:57 -0700 | [diff] [blame] | 6945 | tANI_U8 ch144_support = 0; |
| 6946 | |
| 6947 | ch144_support = WDA_getFwWlanFeatCaps(WLAN_CH144); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6948 | |
| 6949 | do |
| 6950 | { |
| 6951 | status = csrScanFreeRequest(pMac, pDstReq); |
| 6952 | if(HAL_STATUS_SUCCESS(status)) |
| 6953 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6954 | vos_mem_copy(pDstReq, pSrcReq, sizeof(tCsrScanRequest)); |
Gopichand Nakkala | c7b1d3e | 2012-12-31 14:07:19 -0800 | [diff] [blame] | 6955 | /* Re-initialize the pointers to NULL since we did a copy */ |
| 6956 | pDstReq->pIEField = NULL; |
| 6957 | pDstReq->ChannelInfo.ChannelList = NULL; |
| 6958 | pDstReq->SSIDs.SSIDList = NULL; |
| 6959 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6960 | if(pSrcReq->uIEFieldLen == 0) |
| 6961 | { |
| 6962 | pDstReq->pIEField = NULL; |
| 6963 | } |
| 6964 | else |
| 6965 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6966 | pDstReq->pIEField = vos_mem_malloc(pSrcReq->uIEFieldLen); |
| 6967 | if ( NULL == pDstReq->pIEField ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6968 | { |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 6969 | status = eHAL_STATUS_FAILURE; |
| 6970 | smsLog(pMac, LOGE, FL("No memory for scanning IE fields")); |
| 6971 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6972 | } |
| 6973 | else |
| 6974 | { |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 6975 | status = eHAL_STATUS_SUCCESS; |
| 6976 | vos_mem_copy(pDstReq->pIEField, pSrcReq->pIEField, |
| 6977 | pSrcReq->uIEFieldLen); |
| 6978 | pDstReq->uIEFieldLen = pSrcReq->uIEFieldLen; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6979 | } |
| 6980 | }//Allocate memory for IE field |
| 6981 | { |
| 6982 | if(pSrcReq->ChannelInfo.numOfChannels == 0) |
| 6983 | { |
| 6984 | pDstReq->ChannelInfo.ChannelList = NULL; |
| 6985 | pDstReq->ChannelInfo.numOfChannels = 0; |
| 6986 | } |
| 6987 | else |
| 6988 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6989 | pDstReq->ChannelInfo.ChannelList = vos_mem_malloc( |
| 6990 | pSrcReq->ChannelInfo.numOfChannels |
| 6991 | * sizeof(*pDstReq->ChannelInfo.ChannelList)); |
| 6992 | if ( NULL == pDstReq->ChannelInfo.ChannelList ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6993 | { |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 6994 | status = eHAL_STATUS_FAILURE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6995 | pDstReq->ChannelInfo.numOfChannels = 0; |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 6996 | smsLog(pMac, LOGE, FL("No memory for scanning Channel" |
| 6997 | " List")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6998 | break; |
| 6999 | } |
| 7000 | |
| 7001 | if((pSrcReq->scanType == eSIR_PASSIVE_SCAN) && (pSrcReq->requestType == eCSR_SCAN_REQUEST_11D_SCAN)) |
| 7002 | { |
| 7003 | for ( index = 0; index < pSrcReq->ChannelInfo.numOfChannels ; index++ ) |
| 7004 | { |
Arif Hussain | 6af3862 | 2014-03-12 12:39:57 -0700 | [diff] [blame] | 7005 | /* Skip CH 144 if firmware support not present */ |
| 7006 | if (pSrcReq->ChannelInfo.ChannelList[index] == 144 && !ch144_support) |
| 7007 | continue; |
Agarwal Ashish | 8bd53ae | 2015-06-12 18:03:45 +0530 | [diff] [blame] | 7008 | /* Skip channel 12 and 13 when FCC constraint is true */ |
| 7009 | if ((pMac->scan.fcc_constraint) && |
| 7010 | ((pSrcReq->ChannelInfo.ChannelList[index] ==12) || |
| 7011 | (pSrcReq->ChannelInfo.ChannelList[index] ==13))) |
| 7012 | { |
| 7013 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, |
| 7014 | FL("Ignoring channel : %d "), |
| 7015 | pSrcReq->ChannelInfo.ChannelList[index]); |
| 7016 | continue; |
| 7017 | } |
Arif Hussain | 6af3862 | 2014-03-12 12:39:57 -0700 | [diff] [blame] | 7018 | |
Manjunathappa Prakash | de7b2a5 | 2014-02-28 16:59:03 -0800 | [diff] [blame] | 7019 | NVchannel_state = vos_nv_getChannelEnabledState( |
| 7020 | pSrcReq->ChannelInfo.ChannelList[index]); |
| 7021 | if ((NV_CHANNEL_ENABLE == NVchannel_state) || |
| 7022 | (NV_CHANNEL_DFS == NVchannel_state)) |
| 7023 | { |
| 7024 | pDstReq->ChannelInfo.ChannelList[new_index] = |
| 7025 | pSrcReq->ChannelInfo.ChannelList[index]; |
| 7026 | new_index++; |
| 7027 | } |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 7028 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7029 | pDstReq->ChannelInfo.numOfChannels = new_index; |
| 7030 | } |
| 7031 | else if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len))) |
| 7032 | { |
| 7033 | new_index = 0; |
| 7034 | pMac->roam.numValidChannels = len; |
c_hpothu | 0d5a735 | 2014-03-22 12:30:25 +0530 | [diff] [blame] | 7035 | |
Deepthi Gowri | ecc9335 | 2016-11-09 16:58:47 +0530 | [diff] [blame] | 7036 | /* Since in CsrScanRequest,value of pMac->scan. |
| 7037 | * nextScanID is incremented before calling |
| 7038 | * CsrScanCopyRequest, as a result pMac->scan. |
| 7039 | * nextScanID is equal to ONE for the first scan. |
| 7040 | * If number of channels is less than max chan |
| 7041 | * for dwell time no need to skip dfs in first |
| 7042 | * scan as anyway few channels will be scanned |
| 7043 | * and it will not take much time to display |
| 7044 | * results on GUI. |
| 7045 | */ |
| 7046 | if (((pSrcReq->ChannelInfo.numOfChannels >= |
| 7047 | pMac->roam.configParam. |
| 7048 | max_chan_for_dwell_time_cfg) && |
| 7049 | (pMac->roam.configParam. |
| 7050 | initialScanSkipDFSCh && |
| 7051 | 1 == pMac->scan.nextScanID)) || |
| 7052 | (pMac->miracast_mode)) |
c_hpothu | 0d5a735 | 2014-03-22 12:30:25 +0530 | [diff] [blame] | 7053 | { |
Deepthi Gowri | ecc9335 | 2016-11-09 16:58:47 +0530 | [diff] [blame] | 7054 | smsLog(pMac, LOG1, |
| 7055 | FL("Initial scan, scan only non-DFS channels")); |
c_hpothu | 0d5a735 | 2014-03-22 12:30:25 +0530 | [diff] [blame] | 7056 | |
Deepthi Gowri | ecc9335 | 2016-11-09 16:58:47 +0530 | [diff] [blame] | 7057 | for (index = 0; index < pSrcReq->ChannelInfo. |
| 7058 | numOfChannels ; index++ ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7059 | { |
Deepthi Gowri | ecc9335 | 2016-11-09 16:58:47 +0530 | [diff] [blame] | 7060 | if((csrRoamIsValidChannel(pMac, |
| 7061 | pSrcReq->ChannelInfo. |
| 7062 | ChannelList[index]))) |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 7063 | { |
Deepthi Gowri | ecc9335 | 2016-11-09 16:58:47 +0530 | [diff] [blame] | 7064 | /*Skiipping DFS Channels for 1st scan */ |
| 7065 | if(NV_CHANNEL_DFS == |
| 7066 | vos_nv_getChannelEnabledState( |
| 7067 | pSrcReq->ChannelInfo. |
| 7068 | ChannelList[index])) |
| 7069 | continue ; |
Madan Mohan Koyyalamudi | c5992c9 | 2012-11-15 16:40:57 -0800 | [diff] [blame] | 7070 | |
Deepthi Gowri | ecc9335 | 2016-11-09 16:58:47 +0530 | [diff] [blame] | 7071 | pDstReq->ChannelInfo. |
| 7072 | ChannelList[new_index] = |
| 7073 | pSrcReq->ChannelInfo.ChannelList[index]; |
| 7074 | new_index++; |
| 7075 | |
| 7076 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7077 | } |
Deepthi Gowri | ecc9335 | 2016-11-09 16:58:47 +0530 | [diff] [blame] | 7078 | pMac->roam.configParam.initialScanSkipDFSCh = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7079 | } |
Deepthi Gowri | ecc9335 | 2016-11-09 16:58:47 +0530 | [diff] [blame] | 7080 | else |
| 7081 | csrValidateScanChannels(pMac, pDstReq, pSrcReq, |
Nishank Aggarwal | 42f7650 | 2017-02-16 12:00:19 +0530 | [diff] [blame] | 7082 | &new_index, ch144_support); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7083 | pDstReq->ChannelInfo.numOfChannels = new_index; |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 7084 | #ifdef FEATURE_WLAN_LFR |
Deepthi Gowri | ecc9335 | 2016-11-09 16:58:47 +0530 | [diff] [blame] | 7085 | if ( ( ( eCSR_SCAN_HO_BG_SCAN == |
| 7086 | pSrcReq->requestType ) || |
| 7087 | ( eCSR_SCAN_P2P_DISCOVERY == |
| 7088 | pSrcReq->requestType ) ) && |
| 7089 | ( 0 == pDstReq->ChannelInfo.numOfChannels ) ) |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 7090 | { |
| 7091 | /* |
| 7092 | * No valid channels found in the request. |
| 7093 | * Only perform scan on the channels passed |
Abhishek Singh | 2ec36ab | 2014-08-07 16:14:25 +0530 | [diff] [blame] | 7094 | * pSrcReq if it is a eCSR_SCAN_HO_BG_SCAN or |
| 7095 | * eCSR_SCAN_P2P_DISCOVERY. |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 7096 | * Passing 0 to LIM will trigger a scan on |
| 7097 | * all valid channels which is not desirable. |
| 7098 | */ |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 7099 | smsLog(pMac, LOGE, FL(" no valid channels found" |
Deepthi Gowri | ecc9335 | 2016-11-09 16:58:47 +0530 | [diff] [blame] | 7100 | " (request=%d)"), pSrcReq->requestType); |
| 7101 | for ( index = 0; index < pSrcReq->ChannelInfo. |
| 7102 | numOfChannels ; index++ ) |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 7103 | { |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 7104 | smsLog(pMac, LOGE, FL("pSrcReq index=%d" |
Deepthi Gowri | ecc9335 | 2016-11-09 16:58:47 +0530 | [diff] [blame] | 7105 | " channel=%d"), index, |
| 7106 | pSrcReq->ChannelInfo.ChannelList[index]); |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 7107 | } |
| 7108 | status = eHAL_STATUS_FAILURE; |
| 7109 | break; |
Deepthi Gowri | ecc9335 | 2016-11-09 16:58:47 +0530 | [diff] [blame] | 7110 | } |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 7111 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7112 | } |
| 7113 | else |
| 7114 | { |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 7115 | smsLog(pMac, LOGE, FL("Couldn't get the valid Channel" |
| 7116 | " List, keeping requester's list")); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7117 | vos_mem_copy(pDstReq->ChannelInfo.ChannelList, |
| 7118 | pSrcReq->ChannelInfo.ChannelList, |
| 7119 | pSrcReq->ChannelInfo.numOfChannels |
Deepthi Gowri | ecc9335 | 2016-11-09 16:58:47 +0530 | [diff] [blame] | 7120 | * sizeof(*pDstReq->ChannelInfo.ChannelList)); |
| 7121 | pDstReq->ChannelInfo.numOfChannels = |
| 7122 | pSrcReq->ChannelInfo.numOfChannels; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7123 | } |
| 7124 | }//Allocate memory for Channel List |
| 7125 | } |
| 7126 | if(pSrcReq->SSIDs.numOfSSIDs == 0) |
| 7127 | { |
| 7128 | pDstReq->SSIDs.numOfSSIDs = 0; |
| 7129 | pDstReq->SSIDs.SSIDList = NULL; |
| 7130 | } |
| 7131 | else |
| 7132 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7133 | pDstReq->SSIDs.SSIDList = vos_mem_malloc( |
| 7134 | pSrcReq->SSIDs.numOfSSIDs * sizeof(*pDstReq->SSIDs.SSIDList)); |
| 7135 | if ( NULL == pDstReq->SSIDs.SSIDList ) |
| 7136 | status = eHAL_STATUS_FAILURE; |
| 7137 | else |
| 7138 | status = eHAL_STATUS_SUCCESS; |
| 7139 | if (HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7140 | { |
| 7141 | pDstReq->SSIDs.numOfSSIDs = pSrcReq->SSIDs.numOfSSIDs; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7142 | vos_mem_copy(pDstReq->SSIDs.SSIDList, |
| 7143 | pSrcReq->SSIDs.SSIDList, |
| 7144 | pSrcReq->SSIDs.numOfSSIDs * sizeof(*pDstReq->SSIDs.SSIDList)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7145 | } |
| 7146 | else |
| 7147 | { |
| 7148 | pDstReq->SSIDs.numOfSSIDs = 0; |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 7149 | smsLog(pMac, LOGE, FL("No memory for scanning SSID List")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7150 | break; |
| 7151 | } |
| 7152 | }//Allocate memory for SSID List |
Rajeev Kumar Sirasanagandla | 2bb30b8 | 2019-01-07 22:30:16 +0530 | [diff] [blame] | 7153 | pDstReq->scan_randomize = pSrcReq->scan_randomize; |
| 7154 | pDstReq->nl_scan = pSrcReq->nl_scan; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7155 | pDstReq->p2pSearch = pSrcReq->p2pSearch; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7156 | pDstReq->skipDfsChnlInP2pSearch = pSrcReq->skipDfsChnlInP2pSearch; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7157 | |
| 7158 | } |
| 7159 | }while(0); |
| 7160 | |
| 7161 | if(!HAL_STATUS_SUCCESS(status)) |
| 7162 | { |
| 7163 | csrScanFreeRequest(pMac, pDstReq); |
| 7164 | } |
| 7165 | |
| 7166 | return (status); |
| 7167 | } |
| 7168 | |
| 7169 | |
| 7170 | eHalStatus csrScanFreeRequest(tpAniSirGlobal pMac, tCsrScanRequest *pReq) |
| 7171 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7172 | |
| 7173 | if(pReq->ChannelInfo.ChannelList) |
| 7174 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7175 | vos_mem_free(pReq->ChannelInfo.ChannelList); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7176 | pReq->ChannelInfo.ChannelList = NULL; |
| 7177 | } |
| 7178 | pReq->ChannelInfo.numOfChannels = 0; |
| 7179 | if(pReq->pIEField) |
| 7180 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7181 | vos_mem_free(pReq->pIEField); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7182 | pReq->pIEField = NULL; |
| 7183 | } |
| 7184 | pReq->uIEFieldLen = 0; |
| 7185 | if(pReq->SSIDs.SSIDList) |
| 7186 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7187 | vos_mem_free(pReq->SSIDs.SSIDList); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7188 | pReq->SSIDs.SSIDList = NULL; |
| 7189 | } |
| 7190 | pReq->SSIDs.numOfSSIDs = 0; |
| 7191 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7192 | return eHAL_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7193 | } |
| 7194 | |
| 7195 | |
| 7196 | void csrScanCallCallback(tpAniSirGlobal pMac, tSmeCmd *pCommand, eCsrScanStatus scanStatus) |
| 7197 | { |
| 7198 | if(pCommand->u.scanCmd.callback) |
| 7199 | { |
Ratheesh S P | ece1f83 | 2015-07-25 15:50:25 +0530 | [diff] [blame] | 7200 | if (pCommand->u.scanCmd.abortScanIndication){ |
Kapil Gupta | c46b754 | 2016-10-25 13:03:20 +0530 | [diff] [blame] | 7201 | if ((pCommand->u.scanCmd.reason != eCsrScanForSsid) || |
| 7202 | (scanStatus != eCSR_SCAN_SUCCESS)) { |
| 7203 | smsLog( pMac, LOG1, FL("scanDone due to abort")); |
| 7204 | scanStatus = eCSR_SCAN_ABORT; |
| 7205 | } |
Ratheesh S P | ece1f83 | 2015-07-25 15:50:25 +0530 | [diff] [blame] | 7206 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7207 | 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] | 7208 | } else { |
Kapil Gupta | c46b754 | 2016-10-25 13:03:20 +0530 | [diff] [blame] | 7209 | smsLog(pMac, LOG2, |
| 7210 | FL("Callback NULL cmd reason %d"), |
| 7211 | pCommand->u.scanCmd.reason); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7212 | } |
| 7213 | } |
| 7214 | |
| 7215 | |
| 7216 | void csrScanStopTimers(tpAniSirGlobal pMac) |
| 7217 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7218 | csrScanStopIdleScanTimer(pMac); |
| 7219 | csrScanStopGetResultTimer(pMac); |
| 7220 | } |
| 7221 | |
| 7222 | |
| 7223 | eHalStatus csrScanStartGetResultTimer(tpAniSirGlobal pMac) |
| 7224 | { |
| 7225 | eHalStatus status; |
| 7226 | |
| 7227 | if(pMac->scan.fScanEnable) |
| 7228 | { |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 7229 | 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] | 7230 | } |
| 7231 | else |
| 7232 | { |
| 7233 | status = eHAL_STATUS_FAILURE; |
| 7234 | } |
| 7235 | |
| 7236 | return (status); |
| 7237 | } |
| 7238 | |
| 7239 | |
| 7240 | eHalStatus csrScanStopGetResultTimer(tpAniSirGlobal pMac) |
| 7241 | { |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 7242 | return (vos_timer_stop(&pMac->scan.hTimerGetResult)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7243 | } |
| 7244 | |
| 7245 | |
| 7246 | void csrScanGetResultTimerHandler(void *pv) |
| 7247 | { |
| 7248 | tpAniSirGlobal pMac = PMAC_STRUCT( pv ); |
| 7249 | |
| 7250 | csrScanRequestResult(pMac); |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 7251 | |
| 7252 | 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] | 7253 | } |
| 7254 | |
Padma, Santhosh Kumar | 3618335 | 2016-11-08 17:48:34 +0530 | [diff] [blame] | 7255 | |
| 7256 | void csr_handle_disable_scan(void *pv) |
| 7257 | { |
| 7258 | tpAniSirGlobal mac = PMAC_STRUCT(pv); |
| 7259 | |
| 7260 | if (mac->scan.disable_scan_during_sco_timer_info.callback) |
| 7261 | mac->scan.disable_scan_during_sco_timer_info.callback( |
| 7262 | mac, |
| 7263 | mac->scan.disable_scan_during_sco_timer_info.dev, |
| 7264 | mac->scan.disable_scan_during_sco_timer_info.scan_id, |
| 7265 | eHAL_STATUS_SUCCESS); |
| 7266 | else |
| 7267 | smsLog(mac, LOGE, FL("Callback is NULL")); |
| 7268 | } |
| 7269 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7270 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 7271 | static void csrStaApConcTimerHandler(void *pv) |
| 7272 | { |
| 7273 | tpAniSirGlobal pMac = PMAC_STRUCT( pv ); |
| 7274 | tListElem *pEntry; |
| 7275 | tSmeCmd *pScanCmd; |
| 7276 | |
| 7277 | csrLLLock(&pMac->scan.scanCmdPendingList); |
| 7278 | |
| 7279 | if ( NULL != ( pEntry = csrLLPeekHead( &pMac->scan.scanCmdPendingList, LL_ACCESS_NOLOCK) ) ) |
| 7280 | { |
| 7281 | tCsrScanRequest scanReq; |
| 7282 | tSmeCmd *pSendScanCmd = NULL; |
| 7283 | tANI_U8 numChn = 0; |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 7284 | tANI_U8 nNumChanCombinedConc = 0; |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 7285 | tANI_U8 i, j; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7286 | tCsrChannelInfo *pChnInfo = &scanReq.ChannelInfo; |
| 7287 | tANI_U8 channelToScan[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 7288 | eHalStatus status; |
| 7289 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7290 | pScanCmd = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 7291 | numChn = pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels; |
Madan Mohan Koyyalamudi | d671358 | 2012-11-09 16:56:56 -0800 | [diff] [blame] | 7292 | |
| 7293 | /* if any session is connected and the number of channels to scan is |
| 7294 | * greater than 1 then split the scan into multiple scan operations |
| 7295 | * on each individual channel else continue to perform scan on all |
| 7296 | * specified channels */ |
Madan Mohan Koyyalamudi | 48081ef | 2012-12-04 16:49:55 -0800 | [diff] [blame] | 7297 | |
| 7298 | /* split scan if number of channels to scan is greater than 1 and |
| 7299 | * any one of the following: |
| 7300 | * - STA session is connected and the scan is not a P2P search |
| 7301 | * - any P2P session is connected |
Yeshwanth Sriram Guntuka | 7ea10b0 | 2018-09-05 17:35:44 +0530 | [diff] [blame] | 7302 | * - STA+SAP. In STA+SAP concurrency, scan requests received on |
| 7303 | * STA interface when not in connected state are not split. |
| 7304 | * This can result in large time gap between successive beacons |
| 7305 | * sent by SAP. |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 7306 | * Do not split scans if no concurrent infra connections are |
| 7307 | * active and if the scan is a BG scan triggered by LFR (OR) |
| 7308 | * any scan if LFR is in the middle of a BG scan. Splitting |
| 7309 | * the scan is delaying the time it takes for LFR to find |
| 7310 | * candidates and resulting in disconnects. |
Madan Mohan Koyyalamudi | 48081ef | 2012-12-04 16:49:55 -0800 | [diff] [blame] | 7311 | */ |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 7312 | |
Bala Venkatesh | 5bfddc2 | 2019-02-13 14:42:05 +0530 | [diff] [blame] | 7313 | if (csrIsInfraApStarted(pMac) && !csrIsP2pGoSessionConnected(pMac)) |
Yeshwanth Sriram Guntuka | 7ea10b0 | 2018-09-05 17:35:44 +0530 | [diff] [blame] | 7314 | { |
| 7315 | nNumChanCombinedConc = 1; |
| 7316 | } |
| 7317 | else if((csrIsStaSessionConnected(pMac) && |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 7318 | !csrIsP2pSessionConnected(pMac))) |
| 7319 | { |
| 7320 | nNumChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc; |
| 7321 | } |
| 7322 | else if(csrIsP2pSessionConnected(pMac)) |
| 7323 | { |
| 7324 | nNumChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc; |
| 7325 | } |
| 7326 | |
| 7327 | if ( (numChn > nNumChanCombinedConc) && |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 7328 | ((csrIsStaSessionConnected(pMac) && |
| 7329 | #ifdef FEATURE_WLAN_LFR |
| 7330 | (csrIsConcurrentInfraConnected(pMac) || |
| 7331 | ((pScanCmd->u.scanCmd.reason != eCsrScanBgScan) && |
| 7332 | (pMac->roam.neighborRoamInfo.neighborRoamState != |
| 7333 | eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN))) && |
| 7334 | #endif |
| 7335 | (pScanCmd->u.scanCmd.u.scanRequest.p2pSearch != 1)) || |
Madan Mohan Koyyalamudi | 48081ef | 2012-12-04 16:49:55 -0800 | [diff] [blame] | 7336 | (csrIsP2pSessionConnected(pMac)))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7337 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7338 | vos_mem_set(&scanReq, sizeof(tCsrScanRequest), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7339 | |
| 7340 | pSendScanCmd = csrGetCommandBuffer(pMac); //optimize this to use 2 command buffer only |
| 7341 | if (!pSendScanCmd) |
| 7342 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7343 | smsLog( pMac, LOGE, FL(" Failed to get Queue command buffer") ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7344 | csrLLUnlock(&pMac->scan.scanCmdPendingList); |
| 7345 | return; |
| 7346 | } |
| 7347 | pSendScanCmd->command = pScanCmd->command; |
| 7348 | pSendScanCmd->sessionId = pScanCmd->sessionId; |
| 7349 | pSendScanCmd->u.scanCmd.callback = NULL; |
| 7350 | pSendScanCmd->u.scanCmd.pContext = pScanCmd->u.scanCmd.pContext; |
| 7351 | pSendScanCmd->u.scanCmd.reason = pScanCmd->u.scanCmd.reason; |
| 7352 | pSendScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around |
| 7353 | |
Madan Mohan Koyyalamudi | af2a8b9 | 2012-10-09 14:58:07 -0700 | [diff] [blame] | 7354 | /* First copy all the parameters to local variable of scan request */ |
| 7355 | csrScanCopyRequest(pMac, &scanReq, &pScanCmd->u.scanCmd.u.scanRequest); |
| 7356 | |
| 7357 | /* 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] | 7358 | if(scanReq.ChannelInfo.ChannelList != NULL) |
| 7359 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7360 | vos_mem_free(scanReq.ChannelInfo.ChannelList); |
Madan Mohan Koyyalamudi | 0c626f3 | 2012-11-30 15:10:25 -0800 | [diff] [blame] | 7361 | scanReq.ChannelInfo.ChannelList = NULL; |
| 7362 | } |
| 7363 | |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 7364 | pChnInfo->numOfChannels = nNumChanCombinedConc; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7365 | vos_mem_copy(&channelToScan[0], |
| 7366 | &pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[0], |
| 7367 | pChnInfo->numOfChannels * sizeof(tANI_U8));//just send one channel |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7368 | pChnInfo->ChannelList = &channelToScan[0]; |
| 7369 | |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 7370 | for (i = 0, j = nNumChanCombinedConc; i < (numChn-nNumChanCombinedConc); i++, j++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7371 | { |
| 7372 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[i] = |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 7373 | 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] | 7374 | } |
| 7375 | |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 7376 | 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] | 7377 | |
| 7378 | scanReq.BSSType = eCSR_BSS_TYPE_ANY; |
c_hpothu | dbefd3e | 2014-04-28 15:59:47 +0530 | [diff] [blame] | 7379 | |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 7380 | //Use concurrency values for min/maxChnTime. |
| 7381 | //We know csrIsAnySessionConnected(pMac) returns TRUE here |
| 7382 | csrSetDefaultScanTiming(pMac, scanReq.scanType, &scanReq); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7383 | |
| 7384 | status = csrScanCopyRequest(pMac, &pSendScanCmd->u.scanCmd.u.scanRequest, &scanReq); |
| 7385 | if(!HAL_STATUS_SUCCESS(status)) |
| 7386 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7387 | smsLog( pMac, LOGE, FL(" Failed to get copy csrScanRequest = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7388 | csrLLUnlock(&pMac->scan.scanCmdPendingList); |
| 7389 | return; |
Madan Mohan Koyyalamudi | 0c626f3 | 2012-11-30 15:10:25 -0800 | [diff] [blame] | 7390 | } |
| 7391 | /* Clean the local scan variable */ |
| 7392 | scanReq.ChannelInfo.ChannelList = NULL; |
| 7393 | scanReq.ChannelInfo.numOfChannels = 0; |
| 7394 | csrScanFreeRequest(pMac, &scanReq); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7395 | } |
| 7396 | else |
Madan Mohan Koyyalamudi | d671358 | 2012-11-09 16:56:56 -0800 | [diff] [blame] | 7397 | { |
| 7398 | /* no active connected session present or numChn == 1 |
| 7399 | * scan all remaining channels */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7400 | pSendScanCmd = pScanCmd; |
| 7401 | //remove this command from pending list |
| 7402 | if (csrLLRemoveHead( &pMac->scan.scanCmdPendingList, LL_ACCESS_NOLOCK) == NULL) |
| 7403 | { //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] | 7404 | smsLog( pMac, LOGE, FL(" Failed to remove entry from scanCmdPendingList")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7405 | } |
| 7406 | |
| 7407 | } |
| 7408 | csrQueueSmeCommand(pMac, pSendScanCmd, eANI_BOOLEAN_FALSE); |
| 7409 | |
| 7410 | } |
| 7411 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7412 | csrLLUnlock(&pMac->scan.scanCmdPendingList); |
| 7413 | |
| 7414 | } |
| 7415 | #endif |
| 7416 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7417 | //This function returns the maximum time a BSS is allowed in the scan result. |
| 7418 | //The time varies base on connection and power saving factors. |
| 7419 | //Not connected, No PS |
| 7420 | //Not connected, with PS |
| 7421 | //Connected w/o traffic, No PS |
| 7422 | //Connected w/o traffic, with PS |
| 7423 | //Connected w/ traffic, no PS -- Not supported |
| 7424 | //Connected w/ traffic, with PS -- Not supported |
| 7425 | //the return unit is in seconds. |
| 7426 | tANI_U32 csrScanGetAgeOutTime(tpAniSirGlobal pMac) |
| 7427 | { |
| 7428 | tANI_U32 nRet; |
| 7429 | |
| 7430 | if(pMac->scan.nAgingCountDown) |
| 7431 | { |
| 7432 | //Calculate what should be the timeout value for this |
| 7433 | nRet = pMac->scan.nLastAgeTimeOut * pMac->scan.nAgingCountDown; |
| 7434 | pMac->scan.nAgingCountDown--; |
| 7435 | } |
| 7436 | else |
| 7437 | { |
| 7438 | if( csrIsAllSessionDisconnected( pMac ) ) |
| 7439 | { |
| 7440 | if(pmcIsPowerSaveEnabled(pMac, ePMC_IDLE_MODE_POWER_SAVE)) |
| 7441 | { |
| 7442 | nRet = pMac->roam.configParam.scanAgeTimeNCPS; |
| 7443 | } |
| 7444 | else |
| 7445 | { |
| 7446 | nRet = pMac->roam.configParam.scanAgeTimeNCNPS; |
| 7447 | } |
| 7448 | } |
| 7449 | else |
| 7450 | { |
| 7451 | if(pmcIsPowerSaveEnabled(pMac, ePMC_BEACON_MODE_POWER_SAVE)) |
| 7452 | { |
| 7453 | nRet = pMac->roam.configParam.scanAgeTimeCPS; |
| 7454 | } |
| 7455 | else |
| 7456 | { |
| 7457 | nRet = pMac->roam.configParam.scanAgeTimeCNPS; |
| 7458 | } |
| 7459 | } |
| 7460 | //If state-change causing aging time out change, we want to delay it somewhat to avoid |
| 7461 | //unnecessary removal of BSS. This is mostly due to transition from connect to disconnect. |
| 7462 | if(pMac->scan.nLastAgeTimeOut > nRet) |
| 7463 | { |
| 7464 | if(nRet) |
| 7465 | { |
| 7466 | pMac->scan.nAgingCountDown = (pMac->scan.nLastAgeTimeOut / nRet); |
| 7467 | } |
| 7468 | pMac->scan.nLastAgeTimeOut = nRet; |
| 7469 | nRet *= pMac->scan.nAgingCountDown; |
| 7470 | } |
| 7471 | else |
| 7472 | { |
| 7473 | pMac->scan.nLastAgeTimeOut = nRet; |
| 7474 | } |
| 7475 | } |
| 7476 | |
| 7477 | return (nRet); |
| 7478 | } |
| 7479 | |
Deepthi Gowri | 6a08e31 | 2016-03-31 19:10:14 +0530 | [diff] [blame] | 7480 | static void csrPurgeScanResultByAge(void *pv) |
Sandeep Puligilla | 2b6dc63 | 2012-12-17 14:44:16 -0800 | [diff] [blame] | 7481 | { |
| 7482 | tpAniSirGlobal pMac = PMAC_STRUCT( pv ); |
| 7483 | tListElem *pEntry, *tmpEntry; |
| 7484 | tCsrScanResult *pResult; |
Deepthi Gowri | 4480a3f | 2016-05-18 19:30:17 +0530 | [diff] [blame] | 7485 | v_TIME_t ageOutTime = |
| 7486 | (v_TIME_t)(pMac->scan.scanResultCfgAgingTime * SYSTEM_TIME_SEC_TO_MSEC); |
| 7487 | v_TIME_t curTime = vos_timer_get_system_time(); |
Sandeep Puligilla | 2b6dc63 | 2012-12-17 14:44:16 -0800 | [diff] [blame] | 7488 | |
| 7489 | csrLLLock(&pMac->scan.scanResultList); |
| 7490 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK ); |
Deepthi Gowri | 6a08e31 | 2016-03-31 19:10:14 +0530 | [diff] [blame] | 7491 | smsLog(pMac, LOG1, FL("Ageout time=%lu"),ageOutTime); |
Sandeep Puligilla | 2b6dc63 | 2012-12-17 14:44:16 -0800 | [diff] [blame] | 7492 | while( pEntry ) |
| 7493 | { |
| 7494 | tmpEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK); |
| 7495 | pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 7496 | if((curTime - pResult->Result.BssDescriptor.nReceivedTime) > ageOutTime) |
| 7497 | { |
Deepthi Gowri | 50e2fa5 | 2016-03-17 15:30:53 +0530 | [diff] [blame] | 7498 | smsLog(pMac, LOG1, FL("age out due to time out for BSSID" MAC_ADDRESS_STR), |
| 7499 | MAC_ADDR_ARRAY(pResult->Result.BssDescriptor.bssId)); |
Sandeep Puligilla | 2b6dc63 | 2012-12-17 14:44:16 -0800 | [diff] [blame] | 7500 | csrScanAgeOutBss(pMac, pResult); |
| 7501 | } |
| 7502 | pEntry = tmpEntry; |
| 7503 | } |
| 7504 | csrLLUnlock(&pMac->scan.scanResultList); |
| 7505 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7506 | |
| 7507 | eHalStatus csrScanStartIdleScanTimer(tpAniSirGlobal pMac, tANI_U32 interval) |
| 7508 | { |
| 7509 | eHalStatus status; |
| 7510 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7511 | smsLog(pMac, LOG1, " csrScanStartIdleScanTimer"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7512 | if((pMac->scan.fScanEnable) && (eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan) && interval) |
| 7513 | { |
| 7514 | pMac->scan.nIdleScanTimeGap += interval; |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 7515 | vos_timer_stop(&pMac->scan.hTimerIdleScan); |
| 7516 | 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] | 7517 | if( !HAL_STATUS_SUCCESS(status) ) |
| 7518 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7519 | 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] | 7520 | //This should not happen but set the flag to restart when ready |
| 7521 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 7522 | } |
| 7523 | } |
| 7524 | else |
| 7525 | { |
| 7526 | if( pMac->scan.fScanEnable && (eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan) ) |
| 7527 | { |
| 7528 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 7529 | } |
| 7530 | status = eHAL_STATUS_FAILURE; |
| 7531 | } |
| 7532 | |
| 7533 | return (status); |
| 7534 | } |
| 7535 | |
| 7536 | |
| 7537 | eHalStatus csrScanStopIdleScanTimer(tpAniSirGlobal pMac) |
| 7538 | { |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 7539 | return (vos_timer_stop(&pMac->scan.hTimerIdleScan)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7540 | } |
| 7541 | |
| 7542 | |
| 7543 | //Stop CSR from asking for IMPS, This function doesn't disable IMPS from CSR |
| 7544 | void csrScanSuspendIMPS( tpAniSirGlobal pMac ) |
| 7545 | { |
| 7546 | csrScanCancelIdleScan(pMac); |
| 7547 | } |
| 7548 | |
| 7549 | |
| 7550 | //Start CSR from asking for IMPS. This function doesn't trigger CSR to request entering IMPS |
| 7551 | //because IMPS maybe disabled. |
| 7552 | void csrScanResumeIMPS( tpAniSirGlobal pMac ) |
| 7553 | { |
| 7554 | csrScanStartIdleScan( pMac ); |
| 7555 | } |
| 7556 | |
| 7557 | |
| 7558 | void csrScanIMPSCallback(void *callbackContext, eHalStatus status) |
| 7559 | { |
| 7560 | tpAniSirGlobal pMac = PMAC_STRUCT( callbackContext ); |
| 7561 | |
| 7562 | if(eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan) |
| 7563 | { |
| 7564 | if(pMac->roam.configParam.IsIdleScanEnabled) |
| 7565 | { |
| 7566 | if(HAL_STATUS_SUCCESS(status)) |
| 7567 | { |
| 7568 | if(csrIsAllSessionDisconnected(pMac) && !csrIsRoamCommandWaiting(pMac)) |
| 7569 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7570 | smsLog(pMac, LOGW, FL("starts idle mode full scan")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7571 | csrScanAllChannels(pMac, eCSR_SCAN_IDLE_MODE_SCAN); |
| 7572 | } |
| 7573 | else |
| 7574 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7575 | smsLog(pMac, LOGW, FL("cannot start idle mode full scan")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7576 | //even though we are in timer handle, calling stop timer will make sure the timer |
| 7577 | //doesn't get to restart. |
| 7578 | csrScanStopIdleScanTimer(pMac); |
| 7579 | } |
| 7580 | } |
| 7581 | else |
| 7582 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7583 | smsLog(pMac, LOGE, FL("sees not success status (%d)"), status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7584 | } |
| 7585 | } |
| 7586 | else |
| 7587 | {//we might need another flag to check if CSR needs to request imps at all |
| 7588 | |
| 7589 | tANI_U32 nTime = 0; |
| 7590 | |
| 7591 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE; |
| 7592 | if(!HAL_STATUS_SUCCESS(csrScanTriggerIdleScan(pMac, &nTime))) |
| 7593 | { |
| 7594 | csrScanStartIdleScanTimer(pMac, nTime); |
| 7595 | } |
| 7596 | } |
| 7597 | } |
| 7598 | } |
| 7599 | |
| 7600 | |
Rashmi Ramanna | 68b309c | 2014-05-20 11:52:22 +0530 | [diff] [blame] | 7601 | //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] | 7602 | //idle scan timer interval |
| 7603 | //Return: Not success -- meaning it cannot start IMPS, caller needs to start a timer for idle scan |
| 7604 | eHalStatus csrScanTriggerIdleScan(tpAniSirGlobal pMac, tANI_U32 *pTimeInterval) |
| 7605 | { |
| 7606 | eHalStatus status = eHAL_STATUS_CSR_WRONG_STATE; |
| 7607 | |
| 7608 | //Do not trigger IMPS in case of concurrency |
Agarwal Ashish | 5974ed3 | 2014-06-16 16:59:54 +0530 | [diff] [blame] | 7609 | if (vos_concurrent_open_sessions_running() && |
| 7610 | csrIsAnySessionInConnectState(pMac)) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7611 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7612 | smsLog( pMac, LOG1, FL("Cannot request IMPS because Concurrent Sessions Running") ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7613 | return (status); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7614 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7615 | |
| 7616 | if(pTimeInterval) |
| 7617 | { |
| 7618 | *pTimeInterval = 0; |
| 7619 | } |
| 7620 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7621 | smsLog(pMac, LOG3, FL("called")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7622 | if( smeCommandPending( pMac ) ) |
| 7623 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7624 | smsLog( pMac, LOG1, FL(" Cannot request IMPS because command pending") ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7625 | //Not to enter IMPS because more work to do |
| 7626 | if(pTimeInterval) |
| 7627 | { |
| 7628 | *pTimeInterval = 0; |
| 7629 | } |
| 7630 | //restart when ready |
| 7631 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 7632 | |
| 7633 | return (status); |
| 7634 | } |
Kiran Kumar Lokere | f8c3992 | 2013-03-18 11:08:11 -0700 | [diff] [blame] | 7635 | if (IsPmcImpsReqFailed (pMac)) |
| 7636 | { |
| 7637 | if(pTimeInterval) |
| 7638 | { |
| 7639 | *pTimeInterval = 1000000; //usec |
| 7640 | } |
| 7641 | //restart when ready |
| 7642 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7643 | |
Kiran Kumar Lokere | f8c3992 | 2013-03-18 11:08:11 -0700 | [diff] [blame] | 7644 | return status; |
| 7645 | } |
Rashmi Ramanna | 68b309c | 2014-05-20 11:52:22 +0530 | [diff] [blame] | 7646 | |
| 7647 | if ( !pMac->deferImps && pMac->fDeferIMPSTime ) |
| 7648 | { |
| 7649 | smsLog( pMac, LOG1, FL("Defer IMPS for %dms as command processed"), |
| 7650 | pMac->fDeferIMPSTime); |
Girish Gowli | 4f3775a | 2014-05-30 17:17:08 +0530 | [diff] [blame] | 7651 | if(pTimeInterval) |
| 7652 | { |
| 7653 | *pTimeInterval = pMac->fDeferIMPSTime * 1000; //usec |
| 7654 | } |
Rashmi Ramanna | 68b309c | 2014-05-20 11:52:22 +0530 | [diff] [blame] | 7655 | pMac->deferImps = eANI_BOOLEAN_TRUE; |
| 7656 | return status; |
| 7657 | } |
| 7658 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7659 | if((pMac->scan.fScanEnable) && (eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan) |
| 7660 | /*&& pMac->roam.configParam.impsSleepTime*/) |
| 7661 | { |
| 7662 | //Stop get result timer because idle scan gets scan result out of PE |
| 7663 | csrScanStopGetResultTimer(pMac); |
| 7664 | if(pTimeInterval) |
| 7665 | { |
| 7666 | *pTimeInterval = pMac->roam.configParam.impsSleepTime; |
| 7667 | } |
| 7668 | //pmcRequestImps take a period in millisecond unit. |
| 7669 | status = pmcRequestImps(pMac, pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_MS_UNIT, csrScanIMPSCallback, pMac); |
| 7670 | if(!HAL_STATUS_SUCCESS(status)) |
| 7671 | { |
| 7672 | if(eHAL_STATUS_PMC_ALREADY_IN_IMPS != status) |
| 7673 | { |
| 7674 | //Do restart the timer if CSR thinks it cannot do IMPS |
| 7675 | if( !csrCheckPSReady( pMac ) ) |
| 7676 | { |
| 7677 | if(pTimeInterval) |
| 7678 | { |
| 7679 | *pTimeInterval = 0; |
| 7680 | } |
| 7681 | //Set the restart flag to true because that idle scan |
| 7682 | //can be restarted even though the timer will not be running |
| 7683 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 7684 | } |
| 7685 | else |
| 7686 | { |
| 7687 | //For not now, we do a quicker retry |
| 7688 | if(pTimeInterval) |
| 7689 | { |
| 7690 | *pTimeInterval = CSR_IDLE_SCAN_WAIT_TIME; |
| 7691 | } |
| 7692 | } |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7693 | 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] | 7694 | } |
| 7695 | else |
| 7696 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7697 | smsLog(pMac, LOGW, FL("already in IMPS")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7698 | //Since CSR is the only module to request for IMPS. If it is already in IMPS, CSR assumes |
| 7699 | //the callback will be called in the future. Should not happen though. |
| 7700 | status = eHAL_STATUS_SUCCESS; |
| 7701 | pMac->scan.nIdleScanTimeGap = 0; |
| 7702 | } |
| 7703 | } |
| 7704 | else |
| 7705 | { |
| 7706 | //requested so let's reset the value |
| 7707 | pMac->scan.nIdleScanTimeGap = 0; |
| 7708 | } |
| 7709 | } |
| 7710 | |
| 7711 | return (status); |
| 7712 | } |
| 7713 | |
| 7714 | |
| 7715 | eHalStatus csrScanStartIdleScan(tpAniSirGlobal pMac) |
| 7716 | { |
| 7717 | eHalStatus status = eHAL_STATUS_CSR_WRONG_STATE; |
| 7718 | tANI_U32 nTime = 0; |
| 7719 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7720 | smsLog(pMac, LOGW, FL("called")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7721 | if(pMac->roam.configParam.IsIdleScanEnabled) |
| 7722 | { |
| 7723 | //stop bg scan first |
| 7724 | csrScanBGScanAbort(pMac); |
| 7725 | //Stop get result timer because idle scan gets scan result out of PE |
| 7726 | csrScanStopGetResultTimer(pMac); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7727 | } |
| 7728 | pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE; |
| 7729 | status = csrScanTriggerIdleScan(pMac, &nTime); |
| 7730 | if(!HAL_STATUS_SUCCESS(status)) |
| 7731 | { |
| 7732 | csrScanStartIdleScanTimer(pMac, nTime); |
| 7733 | } |
| 7734 | |
| 7735 | return (status); |
| 7736 | } |
| 7737 | |
| 7738 | |
| 7739 | void csrScanCancelIdleScan(tpAniSirGlobal pMac) |
| 7740 | { |
| 7741 | if(eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan) |
| 7742 | { |
Agarwal Ashish | 5974ed3 | 2014-06-16 16:59:54 +0530 | [diff] [blame] | 7743 | if (vos_concurrent_open_sessions_running()) { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7744 | return; |
| 7745 | } |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7746 | smsLog(pMac, LOG1, " csrScanCancelIdleScan"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7747 | pMac->scan.fCancelIdleScan = eANI_BOOLEAN_TRUE; |
| 7748 | //Set the restart flag in case later on it is uncancelled |
| 7749 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 7750 | csrScanStopIdleScanTimer(pMac); |
| 7751 | csrScanRemoveNotRoamingScanCommand(pMac); |
| 7752 | } |
| 7753 | } |
| 7754 | |
| 7755 | |
| 7756 | void csrScanIdleScanTimerHandler(void *pv) |
| 7757 | { |
| 7758 | tpAniSirGlobal pMac = PMAC_STRUCT( pv ); |
| 7759 | eHalStatus status; |
| 7760 | tANI_U32 nTime = 0; |
| 7761 | |
| 7762 | smsLog(pMac, LOGW, " csrScanIdleScanTimerHandler called "); |
Kiran Kumar Lokere | f8c3992 | 2013-03-18 11:08:11 -0700 | [diff] [blame] | 7763 | pmcResetImpsFailStatus (pMac); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7764 | status = csrScanTriggerIdleScan(pMac, &nTime); |
| 7765 | if(!HAL_STATUS_SUCCESS(status) && (eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan)) |
| 7766 | { |
| 7767 | //Check whether it is time to actually do an idle scan |
| 7768 | if(pMac->scan.nIdleScanTimeGap >= pMac->roam.configParam.impsSleepTime) |
| 7769 | { |
| 7770 | pMac->scan.nIdleScanTimeGap = 0; |
| 7771 | csrScanIMPSCallback(pMac, eHAL_STATUS_SUCCESS); |
| 7772 | } |
| 7773 | else |
| 7774 | { |
| 7775 | csrScanStartIdleScanTimer(pMac, nTime); |
| 7776 | } |
| 7777 | } |
Rashmi Ramanna | 68b309c | 2014-05-20 11:52:22 +0530 | [diff] [blame] | 7778 | if(pMac->deferImps) |
| 7779 | { |
| 7780 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 7781 | pMac->deferImps = eANI_BOOLEAN_FALSE; |
| 7782 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7783 | } |
| 7784 | |
| 7785 | |
| 7786 | |
| 7787 | |
| 7788 | tANI_BOOLEAN csrScanRemoveNotRoamingScanCommand(tpAniSirGlobal pMac) |
| 7789 | { |
| 7790 | tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE; |
| 7791 | tListElem *pEntry, *pEntryTmp; |
| 7792 | tSmeCmd *pCommand; |
| 7793 | tDblLinkList localList; |
Madan Mohan Koyyalamudi | 2125599 | 2013-08-01 18:00:25 +0530 | [diff] [blame] | 7794 | tDblLinkList *pCmdList; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7795 | |
| 7796 | vos_mem_zero(&localList, sizeof(tDblLinkList)); |
| 7797 | if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList))) |
| 7798 | { |
| 7799 | smsLog(pMac, LOGE, FL(" failed to open list")); |
| 7800 | return fRet; |
| 7801 | } |
Madan Mohan Koyyalamudi | 2125599 | 2013-08-01 18:00:25 +0530 | [diff] [blame] | 7802 | if (!pMac->fScanOffload) |
| 7803 | pCmdList = &pMac->sme.smeCmdPendingList; |
| 7804 | else |
| 7805 | pCmdList = &pMac->sme.smeScanCmdPendingList; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7806 | |
Madan Mohan Koyyalamudi | 2125599 | 2013-08-01 18:00:25 +0530 | [diff] [blame] | 7807 | csrLLLock(pCmdList); |
| 7808 | pEntry = csrLLPeekHead(pCmdList, LL_ACCESS_NOLOCK); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7809 | while(pEntry) |
| 7810 | { |
Madan Mohan Koyyalamudi | 2125599 | 2013-08-01 18:00:25 +0530 | [diff] [blame] | 7811 | pEntryTmp = csrLLNext(pCmdList, pEntry, LL_ACCESS_NOLOCK); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7812 | pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link); |
| 7813 | if( eSmeCommandScan == pCommand->command ) |
| 7814 | { |
| 7815 | switch( pCommand->u.scanCmd.reason ) |
| 7816 | { |
| 7817 | case eCsrScanIdleScan: |
Madan Mohan Koyyalamudi | 2125599 | 2013-08-01 18:00:25 +0530 | [diff] [blame] | 7818 | if( csrLLRemoveEntry(pCmdList, pEntry, LL_ACCESS_NOLOCK) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7819 | { |
| 7820 | csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK); |
| 7821 | } |
| 7822 | fRet = eANI_BOOLEAN_TRUE; |
| 7823 | break; |
| 7824 | |
| 7825 | default: |
| 7826 | break; |
| 7827 | } //switch |
| 7828 | } |
| 7829 | pEntry = pEntryTmp; |
| 7830 | } |
| 7831 | |
Madan Mohan Koyyalamudi | 2125599 | 2013-08-01 18:00:25 +0530 | [diff] [blame] | 7832 | csrLLUnlock(pCmdList); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7833 | |
| 7834 | while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) ) |
| 7835 | { |
| 7836 | pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link); |
| 7837 | csrReleaseCommandScan( pMac, pCommand ); |
| 7838 | } |
| 7839 | |
| 7840 | csrLLClose(&localList); |
| 7841 | |
| 7842 | return (fRet); |
| 7843 | } |
| 7844 | |
| 7845 | |
| 7846 | tANI_BOOLEAN csrScanRemoveFreshScanCommand(tpAniSirGlobal pMac, tANI_U8 sessionId) |
| 7847 | { |
| 7848 | tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE; |
| 7849 | tListElem *pEntry, *pEntryTmp; |
| 7850 | tSmeCmd *pCommand; |
| 7851 | tDblLinkList localList; |
Madan Mohan Koyyalamudi | 2125599 | 2013-08-01 18:00:25 +0530 | [diff] [blame] | 7852 | tDblLinkList *pCmdList; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7853 | |
| 7854 | vos_mem_zero(&localList, sizeof(tDblLinkList)); |
| 7855 | if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList))) |
| 7856 | { |
| 7857 | smsLog(pMac, LOGE, FL(" failed to open list")); |
| 7858 | return fRet; |
| 7859 | } |
| 7860 | |
Madan Mohan Koyyalamudi | 2125599 | 2013-08-01 18:00:25 +0530 | [diff] [blame] | 7861 | if (!pMac->fScanOffload) |
| 7862 | pCmdList = &pMac->sme.smeCmdPendingList; |
| 7863 | else |
| 7864 | pCmdList = &pMac->sme.smeScanCmdPendingList; |
| 7865 | |
| 7866 | csrLLLock(pCmdList); |
| 7867 | pEntry = csrLLPeekHead(pCmdList, LL_ACCESS_NOLOCK); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7868 | while(pEntry) |
| 7869 | { |
Madan Mohan Koyyalamudi | 2125599 | 2013-08-01 18:00:25 +0530 | [diff] [blame] | 7870 | pEntryTmp = csrLLNext(pCmdList, pEntry, LL_ACCESS_NOLOCK); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7871 | pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link); |
| 7872 | if( (eSmeCommandScan == pCommand->command) && (sessionId == pCommand->sessionId) ) |
| 7873 | { |
| 7874 | switch(pCommand->u.scanCmd.reason) |
| 7875 | { |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 7876 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 7877 | case eCsrScanGetLfrResult: |
| 7878 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7879 | case eCsrScanGetResult: |
| 7880 | case eCsrScanSetBGScanParam: |
| 7881 | case eCsrScanBGScanAbort: |
| 7882 | case eCsrScanBGScanEnable: |
| 7883 | case eCsrScanGetScanChnInfo: |
| 7884 | break; |
| 7885 | default: |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7886 | smsLog (pMac, LOGW, "%s: -------- abort scan command reason = %d", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7887 | __func__, pCommand->u.scanCmd.reason); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7888 | //The rest are fresh scan requests |
Madan Mohan Koyyalamudi | 2125599 | 2013-08-01 18:00:25 +0530 | [diff] [blame] | 7889 | if( csrLLRemoveEntry(pCmdList, pEntry, LL_ACCESS_NOLOCK) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7890 | { |
| 7891 | csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK); |
| 7892 | } |
| 7893 | fRet = eANI_BOOLEAN_TRUE; |
| 7894 | break; |
| 7895 | } |
| 7896 | } |
| 7897 | pEntry = pEntryTmp; |
| 7898 | } |
| 7899 | |
Madan Mohan Koyyalamudi | 2125599 | 2013-08-01 18:00:25 +0530 | [diff] [blame] | 7900 | csrLLUnlock(pCmdList); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7901 | |
| 7902 | while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) ) |
| 7903 | { |
| 7904 | pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link); |
| 7905 | if (pCommand->u.scanCmd.callback) |
| 7906 | { |
| 7907 | /* User scan request is pending, |
| 7908 | * send response with status eCSR_SCAN_ABORT*/ |
| 7909 | pCommand->u.scanCmd.callback(pMac, |
| 7910 | pCommand->u.scanCmd.pContext, |
| 7911 | pCommand->u.scanCmd.scanID, |
| 7912 | eCSR_SCAN_ABORT); |
| 7913 | } |
| 7914 | csrReleaseCommandScan( pMac, pCommand ); |
| 7915 | } |
| 7916 | csrLLClose(&localList); |
| 7917 | |
| 7918 | return (fRet); |
| 7919 | } |
| 7920 | |
| 7921 | |
| 7922 | void csrReleaseScanCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand, eCsrScanStatus scanStatus) |
| 7923 | { |
| 7924 | eCsrScanReason reason = pCommand->u.scanCmd.reason; |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 7925 | tANI_BOOLEAN status; |
| 7926 | |
| 7927 | if (!pMac->fScanOffload) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7928 | { |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 7929 | tANI_U32 i; |
| 7930 | for(i = 0; i < CSR_ROAM_SESSION_MAX; i++) |
Abhishek Singh | f52182c | 2016-08-24 11:15:23 +0530 | [diff] [blame] | 7931 | csrRoamStateChange(pMac, |
| 7932 | pMac->roam.prev_state[i], i); |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 7933 | } |
| 7934 | else |
| 7935 | { |
| 7936 | csrRoamStateChange(pMac, |
Abhishek Singh | f52182c | 2016-08-24 11:15:23 +0530 | [diff] [blame] | 7937 | pMac->roam.prev_state[pCommand->sessionId], |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 7938 | pCommand->sessionId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7939 | } |
| 7940 | |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 7941 | csrScanCallCallback(pMac, pCommand, scanStatus); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7942 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7943 | smsLog(pMac, LOG3, " Remove Scan command reason = %d", reason); |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 7944 | if (pMac->fScanOffload) |
| 7945 | { |
| 7946 | status = csrLLRemoveEntry(&pMac->sme.smeScanCmdActiveList, |
| 7947 | &pCommand->Link, LL_ACCESS_LOCK); |
| 7948 | } |
| 7949 | else |
| 7950 | { |
| 7951 | status = csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, |
| 7952 | &pCommand->Link, LL_ACCESS_LOCK); |
| 7953 | } |
| 7954 | |
| 7955 | if(status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7956 | { |
| 7957 | csrReleaseCommandScan( pMac, pCommand ); |
| 7958 | } |
| 7959 | else |
| 7960 | { |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 7961 | smsLog(pMac, LOGE, |
| 7962 | " ********csrReleaseScanCommand cannot release command reason %d", |
| 7963 | pCommand->u.scanCmd.reason ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7964 | } |
| 7965 | } |
| 7966 | |
| 7967 | |
| 7968 | eHalStatus csrScanGetPMKIDCandidateList(tpAniSirGlobal pMac, tANI_U32 sessionId, |
| 7969 | tPmkidCandidateInfo *pPmkidList, tANI_U32 *pNumItems ) |
| 7970 | { |
| 7971 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 7972 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 7973 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 7974 | if(!pSession) |
| 7975 | { |
| 7976 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 7977 | return eHAL_STATUS_FAILURE; |
| 7978 | } |
| 7979 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7980 | smsLog(pMac, LOGW, " pMac->scan.NumPmkidCandidate = %d", pSession->NumPmkidCandidate); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7981 | csrResetPMKIDCandidateList(pMac, sessionId); |
| 7982 | if(csrIsConnStateConnected(pMac, sessionId) && pSession->pCurRoamProfile) |
| 7983 | { |
| 7984 | tCsrScanResultFilter *pScanFilter; |
| 7985 | tCsrScanResultInfo *pScanResult; |
| 7986 | tScanResultHandle hBSSList; |
| 7987 | tANI_U32 nItems = *pNumItems; |
| 7988 | |
| 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->NumPmkidCandidate < nItems)) |
| 8004 | { |
| 8005 | //NumPmkidCandidate adds up here |
| 8006 | csrProcessBSSDescForPMKIDList(pMac, &pScanResult->BssDescriptor, |
| 8007 | (tDot11fBeaconIEs *)( pScanResult->pvIes )); |
| 8008 | } |
| 8009 | if(pSession->NumPmkidCandidate) |
| 8010 | { |
| 8011 | *pNumItems = pSession->NumPmkidCandidate; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8012 | vos_mem_copy(pPmkidList, pSession->PmkidCandidateInfo, |
| 8013 | pSession->NumPmkidCandidate * sizeof(tPmkidCandidateInfo)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8014 | } |
| 8015 | csrScanResultPurge(pMac, hBSSList); |
| 8016 | }//Have scan result |
| 8017 | csrFreeScanFilter(pMac, pScanFilter); |
| 8018 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8019 | vos_mem_free(pScanFilter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8020 | } |
| 8021 | } |
| 8022 | |
| 8023 | return (status); |
| 8024 | } |
| 8025 | |
| 8026 | |
| 8027 | |
| 8028 | #ifdef FEATURE_WLAN_WAPI |
| 8029 | eHalStatus csrScanGetBKIDCandidateList(tpAniSirGlobal pMac, tANI_U32 sessionId, |
| 8030 | tBkidCandidateInfo *pBkidList, tANI_U32 *pNumItems ) |
| 8031 | { |
| 8032 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 8033 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 8034 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 8035 | if(!pSession) |
| 8036 | { |
| 8037 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 8038 | return eHAL_STATUS_FAILURE; |
| 8039 | } |
| 8040 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 8041 | smsLog(pMac, LOGW, " pMac->scan.NumBkidCandidate = %d", pSession->NumBkidCandidate); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8042 | csrResetBKIDCandidateList(pMac, sessionId); |
| 8043 | if(csrIsConnStateConnected(pMac, sessionId) && pSession->pCurRoamProfile) |
| 8044 | { |
| 8045 | tCsrScanResultFilter *pScanFilter; |
| 8046 | tCsrScanResultInfo *pScanResult; |
| 8047 | tScanResultHandle hBSSList; |
| 8048 | tANI_U32 nItems = *pNumItems; |
| 8049 | *pNumItems = 0; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8050 | pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter)); |
| 8051 | if ( NULL == pScanFilter ) |
| 8052 | status = eHAL_STATUS_FAILURE; |
| 8053 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8054 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8055 | vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8056 | //Here is the profile we need to connect to |
| 8057 | status = csrRoamPrepareFilterFromProfile(pMac, pSession->pCurRoamProfile, pScanFilter); |
| 8058 | if(HAL_STATUS_SUCCESS(status)) |
| 8059 | { |
| 8060 | status = csrScanGetResult(pMac, pScanFilter, &hBSSList); |
| 8061 | if(HAL_STATUS_SUCCESS(status)) |
| 8062 | { |
| 8063 | while(((pScanResult = csrScanResultGetNext(pMac, hBSSList)) != NULL) && ( pSession->NumBkidCandidate < nItems)) |
| 8064 | { |
| 8065 | //pMac->scan.NumBkidCandidate adds up here |
| 8066 | csrProcessBSSDescForBKIDList(pMac, &pScanResult->BssDescriptor, |
| 8067 | (tDot11fBeaconIEs *)( pScanResult->pvIes )); |
| 8068 | |
| 8069 | } |
| 8070 | if(pSession->NumBkidCandidate) |
| 8071 | { |
| 8072 | *pNumItems = pSession->NumBkidCandidate; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8073 | vos_mem_copy(pBkidList, pSession->BkidCandidateInfo, pSession->NumBkidCandidate * sizeof(tBkidCandidateInfo)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8074 | } |
| 8075 | csrScanResultPurge(pMac, hBSSList); |
| 8076 | }//Have scan result |
| 8077 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8078 | vos_mem_free(pScanFilter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8079 | } |
| 8080 | } |
| 8081 | |
| 8082 | return (status); |
| 8083 | } |
| 8084 | #endif /* FEATURE_WLAN_WAPI */ |
| 8085 | |
Selvaraj, Sridhar | 32417ed | 2016-06-22 15:19:12 +0530 | [diff] [blame] | 8086 | /** |
| 8087 | * csr_scan_request_set_chan_time() - Populate max and min |
| 8088 | * channel time in Scan request |
| 8089 | * @pMac - pointer to mac context |
| 8090 | * @pScanCmd - pointer to the Scan command |
| 8091 | * |
| 8092 | * Return - None |
| 8093 | */ |
| 8094 | #ifndef QCA_WIFI_ISOC |
| 8095 | static void csr_scan_request_set_chan_time(tpAniSirGlobal pMac, |
| 8096 | tSmeCmd *pScanCmd) |
| 8097 | { |
| 8098 | if (pMac->roam.neighborRoamInfo.handoffReqInfo.src |
| 8099 | == FASTREASSOC) { |
| 8100 | pScanCmd->u.scanCmd.u.scanRequest.maxChnTime |
| 8101 | = MAX_ACTIVE_SCAN_FOR_ONE_CHANNEL_FASTREASSOC; |
| 8102 | pScanCmd->u.scanCmd.u.scanRequest.minChnTime |
| 8103 | = MIN_ACTIVE_SCAN_FOR_ONE_CHANNEL_FASTREASSOC; |
| 8104 | pMac->roam.neighborRoamInfo.handoffReqInfo.src = 0; |
| 8105 | } else { |
| 8106 | pScanCmd->u.scanCmd.u.scanRequest.maxChnTime |
| 8107 | = MAX_ACTIVE_SCAN_FOR_ONE_CHANNEL; |
| 8108 | pScanCmd->u.scanCmd.u.scanRequest.minChnTime |
| 8109 | = MIN_ACTIVE_SCAN_FOR_ONE_CHANNEL; |
| 8110 | } |
| 8111 | } |
| 8112 | #else |
| 8113 | static void csr_scan_request_set_chan_time(tpAniSirGlobal pMac, |
| 8114 | tSmeCmd *pScanCmd) |
| 8115 | { |
| 8116 | pScanCmd->u.scanCmd.u.scanRequest.maxChnTime |
| 8117 | = MAX_ACTIVE_SCAN_FOR_ONE_CHANNEL; |
| 8118 | pScanCmd->u.scanCmd.u.scanRequest.minChnTime |
| 8119 | = MIN_ACTIVE_SCAN_FOR_ONE_CHANNEL; |
| 8120 | } |
| 8121 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8122 | |
Kapil Gupta | c46b754 | 2016-10-25 13:03:20 +0530 | [diff] [blame] | 8123 | /** |
| 8124 | * csr_ssid_scan_done_callback() - Callback to indicate |
| 8125 | * scan is done for ssid scan |
| 8126 | * @halHandle: handle to hal |
| 8127 | * @context: SSID scan context |
| 8128 | * @scanId: Scan id for the scheduled scan |
| 8129 | * @status: scan done status |
| 8130 | * |
| 8131 | * Return - eHalStatus |
| 8132 | */ |
| 8133 | static eHalStatus csr_ssid_scan_done_callback(tHalHandle halHandle, |
| 8134 | void *context, |
| 8135 | tANI_U32 scanId, |
| 8136 | eCsrScanStatus status) |
| 8137 | { |
| 8138 | struct csr_scan_for_ssid_context *scan_context = |
| 8139 | (struct csr_scan_for_ssid_context *)context; |
| 8140 | |
Sreelakshmi Konamki | 5e32960 | 2016-11-21 12:02:44 +0530 | [diff] [blame] | 8141 | if (NULL == scan_context) { |
Kapil Gupta | c46b754 | 2016-10-25 13:03:20 +0530 | [diff] [blame] | 8142 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, |
| 8143 | FL("scan for ssid context not found")); |
Sreelakshmi Konamki | 5e32960 | 2016-11-21 12:02:44 +0530 | [diff] [blame] | 8144 | return eHAL_STATUS_FAILURE; |
| 8145 | } |
Kapil Gupta | c46b754 | 2016-10-25 13:03:20 +0530 | [diff] [blame] | 8146 | |
| 8147 | if (eCSR_SCAN_ABORT == status) |
| 8148 | csrRoamCallCallback(scan_context->pMac, scan_context->sessionId, |
| 8149 | NULL, scan_context->roamId, |
| 8150 | eCSR_ROAM_ASSOCIATION_FAILURE, |
| 8151 | eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE); |
| 8152 | vos_mem_free(scan_context); |
| 8153 | return eHAL_STATUS_SUCCESS; |
| 8154 | } |
| 8155 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8156 | //This function is usually used for BSSs that suppresses SSID so the profile |
| 8157 | //shall have one and only one SSID |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 8158 | 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] | 8159 | { |
| 8160 | eHalStatus status = eHAL_STATUS_INVALID_PARAMETER; |
| 8161 | tSmeCmd *pScanCmd = NULL; |
| 8162 | tANI_U8 bAddr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; |
| 8163 | tANI_U8 index = 0; |
| 8164 | tANI_U32 numSsid = pProfile->SSIDs.numOfSSIDs; |
Kapil Gupta | c46b754 | 2016-10-25 13:03:20 +0530 | [diff] [blame] | 8165 | struct csr_scan_for_ssid_context *context; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8166 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 8167 | smsLog(pMac, LOG2, FL("called")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8168 | //For WDS, we use the index 0. There must be at least one in there |
| 8169 | if( CSR_IS_WDS_STA( pProfile ) && numSsid ) |
| 8170 | { |
| 8171 | numSsid = 1; |
| 8172 | } |
| 8173 | if(pMac->scan.fScanEnable && ( numSsid == 1 ) ) |
| 8174 | { |
| 8175 | do |
| 8176 | { |
| 8177 | pScanCmd = csrGetCommandBuffer(pMac); |
| 8178 | if(!pScanCmd) |
| 8179 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 8180 | smsLog(pMac, LOGE, FL("failed to allocate command buffer")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8181 | break; |
| 8182 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8183 | vos_mem_set(&pScanCmd->u.scanCmd, sizeof(tScanCmd), 0); |
| 8184 | pScanCmd->u.scanCmd.pToRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile)); |
| 8185 | if ( NULL == pScanCmd->u.scanCmd.pToRoamProfile ) |
krunal soni | 587bf01 | 2014-02-04 12:35:11 -0800 | [diff] [blame] | 8186 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8187 | status = eHAL_STATUS_FAILURE; |
krunal soni | 587bf01 | 2014-02-04 12:35:11 -0800 | [diff] [blame] | 8188 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8189 | else |
krunal soni | 587bf01 | 2014-02-04 12:35:11 -0800 | [diff] [blame] | 8190 | { |
| 8191 | status = csrRoamCopyProfile(pMac, pScanCmd->u.scanCmd.pToRoamProfile, pProfile); |
| 8192 | } |
Kapil Gupta | c46b754 | 2016-10-25 13:03:20 +0530 | [diff] [blame] | 8193 | context = vos_mem_malloc(sizeof(*context)); |
| 8194 | if (NULL == context) |
| 8195 | { |
| 8196 | smsLog(pMac, LOGE, |
| 8197 | "Failed to allocate memory for ssid scan context"); |
| 8198 | status = eHAL_STATUS_FAILED_ALLOC; |
| 8199 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8200 | if(!HAL_STATUS_SUCCESS(status)) |
| 8201 | break; |
Kapil Gupta | c46b754 | 2016-10-25 13:03:20 +0530 | [diff] [blame] | 8202 | context->pMac = pMac; |
| 8203 | context->sessionId = sessionId; |
| 8204 | context->roamId = roamId; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8205 | pScanCmd->u.scanCmd.roamId = roamId; |
| 8206 | pScanCmd->command = eSmeCommandScan; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8207 | pScanCmd->sessionId = (tANI_U8)sessionId; |
Kapil Gupta | c46b754 | 2016-10-25 13:03:20 +0530 | [diff] [blame] | 8208 | pScanCmd->u.scanCmd.callback = csr_ssid_scan_done_callback; |
| 8209 | pScanCmd->u.scanCmd.pContext = context; |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 8210 | 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] | 8211 | pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8212 | vos_mem_set(&pScanCmd->u.scanCmd.u.scanRequest, sizeof(tCsrScanRequest), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8213 | pScanCmd->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8214 | pScanCmd->u.scanCmd.u.scanRequest.BSSType = pProfile->BSSType; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8215 | // To avoid 11b rate in probe request Set p2pSearch flag as 1 for P2P Client Mode |
| 8216 | if(VOS_P2P_CLIENT_MODE == pProfile->csrPersona) |
| 8217 | { |
| 8218 | pScanCmd->u.scanCmd.u.scanRequest.p2pSearch = 1; |
| 8219 | } |
Agarwal Ashish | 4f61613 | 2013-12-30 23:32:50 +0530 | [diff] [blame] | 8220 | if(pProfile->nAddIEScanLength) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8221 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8222 | pScanCmd->u.scanCmd.u.scanRequest.pIEField = vos_mem_malloc( |
| 8223 | pProfile->nAddIEScanLength); |
| 8224 | if ( NULL == pScanCmd->u.scanCmd.u.scanRequest.pIEField ) |
| 8225 | status = eHAL_STATUS_FAILURE; |
| 8226 | else |
| 8227 | status = eHAL_STATUS_SUCCESS; |
| 8228 | vos_mem_set(pScanCmd->u.scanCmd.u.scanRequest.pIEField, |
| 8229 | pProfile->nAddIEScanLength, 0); |
| 8230 | if (HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8231 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8232 | vos_mem_copy(pScanCmd->u.scanCmd.u.scanRequest.pIEField, |
Agarwal Ashish | 4f61613 | 2013-12-30 23:32:50 +0530 | [diff] [blame] | 8233 | pProfile->addIEScan, pProfile->nAddIEScanLength); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8234 | pScanCmd->u.scanCmd.u.scanRequest.uIEFieldLen = pProfile->nAddIEScanLength; |
| 8235 | } |
| 8236 | else |
| 8237 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 8238 | smsLog(pMac, LOGE, "No memory for scanning IE fields"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 8239 | } |
| 8240 | } //Allocate memory for IE field |
| 8241 | else |
| 8242 | { |
| 8243 | pScanCmd->u.scanCmd.u.scanRequest.uIEFieldLen = 0; |
| 8244 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 8245 | /* For one channel be good enpugh time to receive beacon atleast */ |
| 8246 | if( 1 == pProfile->ChannelInfo.numOfChannels ) |
| 8247 | { |
Selvaraj, Sridhar | 32417ed | 2016-06-22 15:19:12 +0530 | [diff] [blame] | 8248 | csr_scan_request_set_chan_time(pMac, pScanCmd); |
| 8249 | } else { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8250 | pScanCmd->u.scanCmd.u.scanRequest.maxChnTime = |
| 8251 | pMac->roam.configParam.nActiveMaxChnTime; |
| 8252 | pScanCmd->u.scanCmd.u.scanRequest.minChnTime = |
| 8253 | pMac->roam.configParam.nActiveMinChnTime; |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 8254 | } |
Abhishek Singh | add1358 | 2016-09-29 17:00:03 +0530 | [diff] [blame] | 8255 | pScanCmd->u.scanCmd.u.scanRequest.max_chntime_btc_esco = |
| 8256 | pMac->roam.configParam.max_chntime_btc_esco; |
| 8257 | pScanCmd->u.scanCmd.u.scanRequest.min_chntime_btc_esco = |
| 8258 | pMac->roam.configParam.min_chntime_btc_esco; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8259 | if(pProfile->BSSIDs.numOfBSSIDs == 1) |
| 8260 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8261 | vos_mem_copy(pScanCmd->u.scanCmd.u.scanRequest.bssid, |
| 8262 | pProfile->BSSIDs.bssid, sizeof(tCsrBssid)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8263 | } |
| 8264 | else |
| 8265 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8266 | vos_mem_copy(pScanCmd->u.scanCmd.u.scanRequest.bssid, bAddr, 6); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8267 | } |
| 8268 | if(pProfile->ChannelInfo.numOfChannels) |
| 8269 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8270 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = vos_mem_malloc( |
| 8271 | sizeof(*pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList) |
| 8272 | * pProfile->ChannelInfo.numOfChannels); |
| 8273 | if ( NULL == pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList ) |
| 8274 | status = eHAL_STATUS_FAILURE; |
| 8275 | else |
| 8276 | status = eHAL_STATUS_SUCCESS; |
| 8277 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = 0; |
| 8278 | if(HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8279 | { |
| 8280 | csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[0]); |
| 8281 | for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++) |
| 8282 | { |
| 8283 | if(csrRoamIsValidChannel(pMac, pProfile->ChannelInfo.ChannelList[index])) |
| 8284 | { |
| 8285 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels] |
| 8286 | = pProfile->ChannelInfo.ChannelList[index]; |
| 8287 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels++; |
| 8288 | } |
| 8289 | else |
| 8290 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 8291 | 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] | 8292 | } |
| 8293 | |
| 8294 | } |
| 8295 | } |
| 8296 | else |
| 8297 | { |
| 8298 | break; |
| 8299 | } |
| 8300 | |
| 8301 | } |
| 8302 | else |
| 8303 | { |
| 8304 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = 0; |
| 8305 | } |
| 8306 | if(pProfile->SSIDs.numOfSSIDs) |
| 8307 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8308 | pScanCmd->u.scanCmd.u.scanRequest.SSIDs.SSIDList = vos_mem_malloc( |
| 8309 | pProfile->SSIDs.numOfSSIDs * sizeof(tCsrSSIDInfo)); |
| 8310 | if ( NULL == pScanCmd->u.scanCmd.u.scanRequest.SSIDs.SSIDList ) |
| 8311 | status = eHAL_STATUS_FAILURE; |
| 8312 | else |
| 8313 | status = eHAL_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8314 | if(!HAL_STATUS_SUCCESS(status)) |
| 8315 | { |
| 8316 | break; |
| 8317 | } |
| 8318 | pScanCmd->u.scanCmd.u.scanRequest.SSIDs.numOfSSIDs = 1; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8319 | vos_mem_copy(pScanCmd->u.scanCmd.u.scanRequest.SSIDs.SSIDList, |
| 8320 | pProfile->SSIDs.SSIDList, sizeof(tCsrSSIDInfo)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8321 | } |
| 8322 | //Start process the command |
| 8323 | status = csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_FALSE); |
| 8324 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 8325 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 8326 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8327 | break; |
| 8328 | } |
| 8329 | }while(0); |
| 8330 | if(!HAL_STATUS_SUCCESS(status)) |
| 8331 | { |
| 8332 | if(pScanCmd) |
| 8333 | { |
| 8334 | csrReleaseCommandScan(pMac, pScanCmd); |
| 8335 | //TODO:free the memory that is allocated in this function |
| 8336 | } |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 8337 | if(notify) |
| 8338 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8339 | csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE); |
| 8340 | } |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 8341 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8342 | }//valid |
| 8343 | else |
| 8344 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 8345 | 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] | 8346 | pMac->scan.fScanEnable, pProfile->SSIDs.numOfSSIDs); |
| 8347 | } |
| 8348 | |
| 8349 | return (status); |
| 8350 | } |
| 8351 | |
| 8352 | |
| 8353 | //Issue a scan base on the new capability infomation |
| 8354 | //This should only happen when the associated AP changes its capability. |
| 8355 | //After this scan is done, CSR reroams base on the new scan results |
| 8356 | eHalStatus csrScanForCapabilityChange(tpAniSirGlobal pMac, tSirSmeApNewCaps *pNewCaps) |
| 8357 | { |
| 8358 | eHalStatus status = eHAL_STATUS_INVALID_PARAMETER; |
| 8359 | tSmeCmd *pScanCmd = NULL; |
| 8360 | |
| 8361 | if(pNewCaps) |
| 8362 | { |
| 8363 | do |
| 8364 | { |
| 8365 | pScanCmd = csrGetCommandBuffer(pMac); |
| 8366 | if(!pScanCmd) |
| 8367 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 8368 | smsLog(pMac, LOGE, FL("failed to allocate command buffer")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8369 | status = eHAL_STATUS_RESOURCES; |
| 8370 | break; |
| 8371 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8372 | vos_mem_set(&pScanCmd->u.scanCmd, sizeof(tScanCmd), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8373 | status = eHAL_STATUS_SUCCESS; |
| 8374 | pScanCmd->u.scanCmd.roamId = 0; |
| 8375 | pScanCmd->command = eSmeCommandScan; |
| 8376 | pScanCmd->u.scanCmd.callback = NULL; |
| 8377 | pScanCmd->u.scanCmd.pContext = NULL; |
| 8378 | pScanCmd->u.scanCmd.reason = eCsrScanForCapsChange; |
| 8379 | pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around |
| 8380 | status = csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_FALSE); |
| 8381 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 8382 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 8383 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8384 | break; |
| 8385 | } |
| 8386 | }while(0); |
| 8387 | if(!HAL_STATUS_SUCCESS(status)) |
| 8388 | { |
| 8389 | if(pScanCmd) |
| 8390 | { |
| 8391 | csrReleaseCommandScan(pMac, pScanCmd); |
| 8392 | } |
| 8393 | } |
| 8394 | } |
| 8395 | |
| 8396 | return (status); |
| 8397 | } |
| 8398 | |
| 8399 | |
| 8400 | |
| 8401 | void csrInitBGScanChannelList(tpAniSirGlobal pMac) |
| 8402 | { |
| 8403 | tANI_U32 len = CSR_MIN(sizeof(pMac->roam.validChannelList), sizeof(pMac->scan.bgScanChannelList)); |
| 8404 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8405 | vos_mem_set(pMac->scan.bgScanChannelList, len, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8406 | pMac->scan.numBGScanChannel = 0; |
| 8407 | |
| 8408 | if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len))) |
| 8409 | { |
| 8410 | pMac->roam.numValidChannels = len; |
| 8411 | 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] | 8412 | vos_mem_copy(pMac->scan.bgScanChannelList, pMac->roam.validChannelList, |
| 8413 | pMac->scan.numBGScanChannel); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8414 | csrSetBGScanChannelList(pMac, pMac->scan.bgScanChannelList, pMac->scan.numBGScanChannel); |
| 8415 | } |
| 8416 | } |
| 8417 | |
| 8418 | |
| 8419 | //This function return TRUE if background scan channel list is adjusted. |
| 8420 | //this function will only shrink the background scan channel list |
| 8421 | tANI_BOOLEAN csrAdjustBGScanChannelList(tpAniSirGlobal pMac, tANI_U8 *pChannelList, tANI_U8 NumChannels, |
| 8422 | tANI_U8 *pAdjustChannels, tANI_U8 *pNumAdjustChannels) |
| 8423 | { |
| 8424 | tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE; |
| 8425 | tANI_U8 i, j, count = *pNumAdjustChannels; |
| 8426 | |
| 8427 | i = 0; |
| 8428 | while(i < count) |
| 8429 | { |
| 8430 | for(j = 0; j < NumChannels; j++) |
| 8431 | { |
| 8432 | if(pChannelList[j] == pAdjustChannels[i]) |
| 8433 | break; |
| 8434 | } |
| 8435 | if(j == NumChannels) |
| 8436 | { |
| 8437 | //This channel is not in the list, remove it |
| 8438 | fRet = eANI_BOOLEAN_TRUE; |
| 8439 | count--; |
| 8440 | if(count - i) |
| 8441 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8442 | vos_mem_copy(&pAdjustChannels[i], &pAdjustChannels[i+1], count - i); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8443 | } |
| 8444 | else |
| 8445 | { |
| 8446 | //already remove the last one. Done. |
| 8447 | break; |
| 8448 | } |
| 8449 | } |
| 8450 | else |
| 8451 | { |
| 8452 | i++; |
| 8453 | } |
| 8454 | }//while(i<count) |
| 8455 | *pNumAdjustChannels = count; |
| 8456 | |
| 8457 | return (fRet); |
| 8458 | } |
| 8459 | |
| 8460 | |
| 8461 | //Get the list of the base channels to scan for passively 11d info |
| 8462 | eHalStatus csrScanGetSupportedChannels( tpAniSirGlobal pMac ) |
| 8463 | { |
| 8464 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 8465 | int n = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 8466 | |
| 8467 | status = vos_nv_getSupportedChannels( pMac->scan.baseChannels.channelList, &n, NULL, NULL ); |
| 8468 | if( HAL_STATUS_SUCCESS(status) ) |
| 8469 | { |
| 8470 | pMac->scan.baseChannels.numChannels = (tANI_U8)n; |
| 8471 | } |
| 8472 | else |
| 8473 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 8474 | smsLog( pMac, LOGE, FL(" failed") ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8475 | pMac->scan.baseChannels.numChannels = 0; |
| 8476 | } |
| 8477 | |
| 8478 | return ( status ); |
| 8479 | } |
| 8480 | |
| 8481 | //This function use the input pChannelList to validate the current saved channel list |
| 8482 | eHalStatus csrSetBGScanChannelList( tpAniSirGlobal pMac, tANI_U8 *pAdjustChannels, tANI_U8 NumAdjustChannels) |
| 8483 | { |
| 8484 | tANI_U32 dataLen = sizeof( tANI_U8 ) * NumAdjustChannels; |
| 8485 | |
| 8486 | return (ccmCfgSetStr(pMac, WNI_CFG_BG_SCAN_CHANNEL_LIST, pAdjustChannels, dataLen, NULL, eANI_BOOLEAN_FALSE)); |
| 8487 | } |
| 8488 | |
| 8489 | |
| 8490 | void csrSetCfgValidChannelList( tpAniSirGlobal pMac, tANI_U8 *pChannelList, tANI_U8 NumChannels ) |
| 8491 | { |
| 8492 | tANI_U32 dataLen = sizeof( tANI_U8 ) * NumChannels; |
Gopichand Nakkala | f72a387 | 2013-06-11 17:51:13 +0530 | [diff] [blame] | 8493 | eHalStatus status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8494 | |
Mihir Shete | 31c435d | 2014-02-12 13:13:34 +0530 | [diff] [blame] | 8495 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, |
| 8496 | "%s: dump valid channel list(NumChannels(%d))", |
| 8497 | __func__,NumChannels); |
| 8498 | VOS_TRACE_HEX_DUMP(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, |
| 8499 | pChannelList, NumChannels); |
| 8500 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8501 | 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] | 8502 | #ifdef QCA_WIFI_2_0 |
Gopichand Nakkala | f72a387 | 2013-06-11 17:51:13 +0530 | [diff] [blame] | 8503 | if (pMac->fScanOffload) |
| 8504 | { |
| 8505 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, |
| 8506 | "Scan offload is enabled, update default chan list"); |
Leela Venkata Kiran Kumar Reddy Chirala | c6663f7 | 2014-02-03 21:04:58 -0800 | [diff] [blame] | 8507 | status = csrUpdateChannelList(pMac); |
| 8508 | } |
| 8509 | #else |
| 8510 | status = csrUpdateChannelList(pMac); |
| 8511 | #endif |
| 8512 | |
| 8513 | if (eHAL_STATUS_SUCCESS != status) |
| 8514 | { |
| 8515 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, |
| 8516 | "failed to update the supported channel list"); |
Gopichand Nakkala | f72a387 | 2013-06-11 17:51:13 +0530 | [diff] [blame] | 8517 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8518 | return; |
| 8519 | } |
| 8520 | |
| 8521 | |
| 8522 | |
| 8523 | /* |
| 8524 | * The Tx power limits are saved in the cfg for future usage. |
| 8525 | */ |
| 8526 | void csrSaveTxPowerToCfg( tpAniSirGlobal pMac, tDblLinkList *pList, tANI_U32 cfgId ) |
| 8527 | { |
| 8528 | tListElem *pEntry; |
| 8529 | tANI_U32 cbLen = 0, dataLen; |
| 8530 | tCsrChannelPowerInfo *pChannelSet; |
| 8531 | tANI_U32 idx; |
| 8532 | tSirMacChanInfo *pChannelPowerSet; |
| 8533 | tANI_U8 *pBuf = NULL; |
| 8534 | |
| 8535 | //allocate maximum space for all channels |
| 8536 | dataLen = WNI_CFG_VALID_CHANNEL_LIST_LEN * sizeof(tSirMacChanInfo); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8537 | if ( (pBuf = vos_mem_malloc(dataLen)) != NULL ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8538 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8539 | vos_mem_set(pBuf, dataLen, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8540 | pChannelPowerSet = (tSirMacChanInfo *)(pBuf); |
| 8541 | |
| 8542 | pEntry = csrLLPeekHead( pList, LL_ACCESS_LOCK ); |
| 8543 | // write the tuples (startChan, numChan, txPower) for each channel found in the channel power list. |
| 8544 | while( pEntry ) |
| 8545 | { |
| 8546 | pChannelSet = GET_BASE_ADDR( pEntry, tCsrChannelPowerInfo, link ); |
| 8547 | if ( 1 != pChannelSet->interChannelOffset ) |
| 8548 | { |
| 8549 | // we keep the 5G channel sets internally with an interchannel offset of 4. Expand these |
| 8550 | // to the right format... (inter channel offset of 1 is the only option for the triplets |
| 8551 | // that 11d advertises. |
| 8552 | if ((cbLen + (pChannelSet->numChannels * sizeof(tSirMacChanInfo))) >= dataLen) |
| 8553 | { |
| 8554 | // expanding this entry will overflow our allocation |
| 8555 | smsLog(pMac, LOGE, |
| 8556 | "%s: Buffer overflow, start %d, num %d, offset %d", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8557 | __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8558 | pChannelSet->firstChannel, |
| 8559 | pChannelSet->numChannels, |
| 8560 | pChannelSet->interChannelOffset); |
| 8561 | break; |
| 8562 | } |
| 8563 | |
| 8564 | for( idx = 0; idx < pChannelSet->numChannels; idx++ ) |
| 8565 | { |
| 8566 | pChannelPowerSet->firstChanNum = (tSirMacChanNum)(pChannelSet->firstChannel + ( idx * pChannelSet->interChannelOffset )); |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 8567 | smsLog(pMac, LOG3, " Setting Channel Number %d", pChannelPowerSet->firstChanNum); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8568 | pChannelPowerSet->numChannels = 1; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8569 | pChannelPowerSet->maxTxPower = CSR_ROAM_MIN( pChannelSet->txPower, pMac->roam.configParam.nTxPowerCap ); |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 8570 | smsLog(pMac, LOG3, " Setting Max Transmit Power %d", pChannelPowerSet->maxTxPower); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8571 | cbLen += sizeof( tSirMacChanInfo ); |
| 8572 | pChannelPowerSet++; |
| 8573 | } |
| 8574 | } |
| 8575 | else |
| 8576 | { |
| 8577 | if (cbLen >= dataLen) |
| 8578 | { |
| 8579 | // this entry will overflow our allocation |
| 8580 | smsLog(pMac, LOGE, |
| 8581 | "%s: Buffer overflow, start %d, num %d, offset %d", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 8582 | __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8583 | pChannelSet->firstChannel, |
| 8584 | pChannelSet->numChannels, |
| 8585 | pChannelSet->interChannelOffset); |
| 8586 | break; |
| 8587 | } |
| 8588 | pChannelPowerSet->firstChanNum = pChannelSet->firstChannel; |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 8589 | smsLog(pMac, LOG3, " Setting Channel Number %d", pChannelPowerSet->firstChanNum); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8590 | pChannelPowerSet->numChannels = pChannelSet->numChannels; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8591 | pChannelPowerSet->maxTxPower = CSR_ROAM_MIN( pChannelSet->txPower, pMac->roam.configParam.nTxPowerCap ); |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 8592 | 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] | 8593 | |
| 8594 | |
| 8595 | cbLen += sizeof( tSirMacChanInfo ); |
| 8596 | pChannelPowerSet++; |
| 8597 | } |
| 8598 | |
| 8599 | pEntry = csrLLNext( pList, pEntry, LL_ACCESS_LOCK ); |
| 8600 | } |
| 8601 | |
| 8602 | if(cbLen) |
| 8603 | { |
| 8604 | ccmCfgSetStr(pMac, cfgId, (tANI_U8 *)pBuf, cbLen, NULL, eANI_BOOLEAN_FALSE); |
| 8605 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8606 | vos_mem_free(pBuf); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8607 | }//Allocate memory |
| 8608 | } |
| 8609 | |
| 8610 | |
| 8611 | void csrSetCfgCountryCode( tpAniSirGlobal pMac, tANI_U8 *countryCode ) |
| 8612 | { |
| 8613 | tANI_U8 cc[WNI_CFG_COUNTRY_CODE_LEN]; |
| 8614 | ///v_REGDOMAIN_t DomainId; |
| 8615 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 8616 | smsLog( pMac, LOG3, "Setting Country Code in Cfg from csrSetCfgCountryCode %s",countryCode ); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8617 | vos_mem_copy(cc, countryCode, WNI_CFG_COUNTRY_CODE_LEN); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8618 | |
| 8619 | // don't program the bogus country codes that we created for Korea in the MAC. if we see |
| 8620 | // the bogus country codes, program the MAC with the right country code. |
| 8621 | if ( ( 'K' == countryCode[ 0 ] && '1' == countryCode[ 1 ] ) || |
| 8622 | ( 'K' == countryCode[ 0 ] && '2' == countryCode[ 1 ] ) || |
| 8623 | ( 'K' == countryCode[ 0 ] && '3' == countryCode[ 1 ] ) || |
| 8624 | ( 'K' == countryCode[ 0 ] && '4' == countryCode[ 1 ] ) ) |
| 8625 | { |
| 8626 | // replace the alternate Korea country codes, 'K1', 'K2', .. with 'KR' for Korea |
| 8627 | cc[ 1 ] = 'R'; |
| 8628 | } |
| 8629 | ccmCfgSetStr(pMac, WNI_CFG_COUNTRY_CODE, cc, WNI_CFG_COUNTRY_CODE_LEN, NULL, eANI_BOOLEAN_FALSE); |
| 8630 | |
| 8631 | //Need to let HALPHY know about the current domain so it can apply some |
| 8632 | //domain-specific settings (TX filter...) |
| 8633 | /*if(HAL_STATUS_SUCCESS(csrGetRegulatoryDomainForCountry(pMac, cc, &DomainId))) |
| 8634 | { |
| 8635 | halPhySetRegDomain(pMac, DomainId); |
| 8636 | }*/ |
| 8637 | } |
| 8638 | |
| 8639 | |
| 8640 | |
| 8641 | eHalStatus csrGetCountryCode(tpAniSirGlobal pMac, tANI_U8 *pBuf, tANI_U8 *pbLen) |
| 8642 | { |
| 8643 | eHalStatus status = eHAL_STATUS_INVALID_PARAMETER; |
| 8644 | tANI_U32 len; |
| 8645 | |
| 8646 | if(pBuf && pbLen && (*pbLen >= WNI_CFG_COUNTRY_CODE_LEN)) |
| 8647 | { |
| 8648 | len = *pbLen; |
| 8649 | status = ccmCfgGetStr(pMac, WNI_CFG_COUNTRY_CODE, pBuf, &len); |
| 8650 | if(HAL_STATUS_SUCCESS(status)) |
| 8651 | { |
| 8652 | *pbLen = (tANI_U8)len; |
| 8653 | } |
| 8654 | } |
| 8655 | |
| 8656 | return (status); |
| 8657 | } |
| 8658 | |
| 8659 | |
| 8660 | void csrSetCfgScanControlList( tpAniSirGlobal pMac, tANI_U8 *countryCode, tCsrChannel *pChannelList ) |
| 8661 | { |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 8662 | tANI_U8 i, j, k; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8663 | tANI_BOOLEAN found=FALSE; |
| 8664 | tANI_U8 *pControlList = NULL; |
| 8665 | tANI_U32 len = WNI_CFG_SCAN_CONTROL_LIST_LEN; |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 8666 | tANI_U8 cfgActiveDFSChannels = 0; |
| 8667 | tANI_U8 *cfgActiveDFSChannelLIst = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8668 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8669 | if ( (pControlList = vos_mem_malloc(WNI_CFG_SCAN_CONTROL_LIST_LEN)) != NULL ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8670 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8671 | vos_mem_set((void *)pControlList, WNI_CFG_SCAN_CONTROL_LIST_LEN, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8672 | if(HAL_STATUS_SUCCESS(ccmCfgGetStr(pMac, WNI_CFG_SCAN_CONTROL_LIST, pControlList, &len))) |
| 8673 | { |
| 8674 | for (i = 0; i < pChannelList->numChannels; i++) |
| 8675 | { |
| 8676 | for (j = 0; j < len; j += 2) |
| 8677 | { |
| 8678 | if (pControlList[j] == pChannelList->channelList[i]) |
| 8679 | { |
| 8680 | found = TRUE; |
| 8681 | break; |
| 8682 | } |
| 8683 | } |
| 8684 | |
| 8685 | if (found) // insert a pair(channel#, flag) |
| 8686 | { |
Gopichand Nakkala | 392cbc1 | 2013-05-28 16:15:00 +0530 | [diff] [blame] | 8687 | pControlList[j+1] = csrGetScanType(pMac, pControlList[j]); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8688 | found = FALSE; // reset the flag |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8689 | |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 8690 | // When DFS mode is 2, mark static channels as active |
| 8691 | if (pMac->scan.fEnableDFSChnlScan == |
| 8692 | DFS_CHNL_SCAN_ENABLED_ACTIVE) |
| 8693 | { |
| 8694 | cfgActiveDFSChannels = |
| 8695 | pMac->roam.neighborRoamInfo.cfgParams. |
| 8696 | channelInfo.numOfChannels; |
| 8697 | cfgActiveDFSChannelLIst = |
| 8698 | pMac->roam.neighborRoamInfo.cfgParams. |
| 8699 | channelInfo.ChannelList; |
| 8700 | if (cfgActiveDFSChannelLIst) |
| 8701 | { |
| 8702 | for (k=0; k < cfgActiveDFSChannels; k++) |
| 8703 | { |
| 8704 | if(CSR_IS_CHANNEL_DFS(cfgActiveDFSChannelLIst[k]) |
| 8705 | && (pControlList[j] == |
| 8706 | cfgActiveDFSChannelLIst[k])) |
| 8707 | { |
| 8708 | pControlList[j+1] = eSIR_ACTIVE_SCAN; |
| 8709 | smsLog(pMac, LOG1, FL("Marked DFS ch %d" |
| 8710 | " as active"), |
| 8711 | cfgActiveDFSChannelLIst[k]); |
| 8712 | } |
| 8713 | } |
| 8714 | } |
| 8715 | } |
| 8716 | } |
| 8717 | } |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 8718 | smsLog(pMac, LOG1, FL("fEnableDFSChnlScan %d"), |
| 8719 | pMac->scan.fEnableDFSChnlScan); |
Mihir Shete | 31c435d | 2014-02-12 13:13:34 +0530 | [diff] [blame] | 8720 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, |
| 8721 | "%s: dump scan control list",__func__); |
| 8722 | VOS_TRACE_HEX_DUMP(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, |
| 8723 | pControlList, len); |
| 8724 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8725 | ccmCfgSetStr(pMac, WNI_CFG_SCAN_CONTROL_LIST, pControlList, len, NULL, eANI_BOOLEAN_FALSE); |
| 8726 | }//Successfully getting scan control list |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8727 | vos_mem_free(pControlList); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8728 | }//AllocateMemory |
Abhishek Singh | 6fcdf65 | 2016-11-23 10:59:12 +0530 | [diff] [blame] | 8729 | |
| 8730 | /* Send msg to Lim to clear DFS channel list */ |
| 8731 | smsLog(pMac, LOG1, FL("csrClearDfsChannelList")); |
| 8732 | csrClearDfsChannelList(pMac); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8733 | } |
| 8734 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8735 | //if bgPeriod is 0, background scan is disabled. It is in millisecond units |
| 8736 | eHalStatus csrSetCfgBackgroundScanPeriod(tpAniSirGlobal pMac, tANI_U32 bgPeriod) |
| 8737 | { |
| 8738 | return (ccmCfgSetInt(pMac, WNI_CFG_BACKGROUND_SCAN_PERIOD, bgPeriod, (tCcmCfgSetCallback) csrScanCcmCfgSetCallback, eANI_BOOLEAN_FALSE)); |
| 8739 | } |
| 8740 | |
| 8741 | |
| 8742 | void csrScanCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result) |
| 8743 | { |
| 8744 | tListElem *pEntry = NULL; |
| 8745 | tSmeCmd *pCommand = NULL; |
| 8746 | tpAniSirGlobal pMac = PMAC_STRUCT( hHal ); |
Madan Mohan Koyyalamudi | 2125599 | 2013-08-01 18:00:25 +0530 | [diff] [blame] | 8747 | tDblLinkList *pCmdList ; |
| 8748 | |
| 8749 | if (!pMac->fScanOffload) |
| 8750 | pCmdList = &pMac->sme.smeCmdActiveList; |
| 8751 | else |
| 8752 | pCmdList = &pMac->sme.smeScanCmdActiveList; |
| 8753 | |
| 8754 | pEntry = csrLLPeekHead( pCmdList, LL_ACCESS_LOCK ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8755 | if ( pEntry ) |
| 8756 | { |
| 8757 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 8758 | if ( eSmeCommandScan == pCommand->command ) |
| 8759 | { |
| 8760 | eCsrScanStatus scanStatus = (CCM_IS_RESULT_SUCCESS(result)) ? eCSR_SCAN_SUCCESS : eCSR_SCAN_FAILURE; |
| 8761 | csrReleaseScanCommand(pMac, pCommand, scanStatus); |
| 8762 | } |
| 8763 | else |
| 8764 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 8765 | 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] | 8766 | } |
| 8767 | } |
| 8768 | smeProcessPendingQueue( pMac ); |
| 8769 | } |
| 8770 | |
| 8771 | eHalStatus csrProcessSetBGScanParam(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
| 8772 | { |
| 8773 | eHalStatus status; |
| 8774 | tCsrBGScanRequest *pScanReq = &pCommand->u.scanCmd.u.bgScanRequest; |
| 8775 | tANI_U32 dataLen = sizeof( tANI_U8 ) * pScanReq->ChannelInfo.numOfChannels; |
| 8776 | |
| 8777 | //***setcfg for background scan channel list |
| 8778 | status = ccmCfgSetInt(pMac, WNI_CFG_ACTIVE_MINIMUM_CHANNEL_TIME, pScanReq->minChnTime, NULL, eANI_BOOLEAN_FALSE); |
| 8779 | status = ccmCfgSetInt(pMac, WNI_CFG_ACTIVE_MAXIMUM_CHANNEL_TIME, pScanReq->maxChnTime, NULL, eANI_BOOLEAN_FALSE); |
| 8780 | //Not set the background scan interval if not connected because bd scan should not be run if not connected |
| 8781 | if(!csrIsAllSessionDisconnected(pMac)) |
| 8782 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8783 | |
| 8784 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 8785 | { |
| 8786 | vos_log_scan_pkt_type *pScanLog = NULL; |
| 8787 | |
| 8788 | WLAN_VOS_DIAG_LOG_ALLOC(pScanLog, vos_log_scan_pkt_type, LOG_WLAN_SCAN_C); |
| 8789 | if(pScanLog) |
| 8790 | { |
| 8791 | pScanLog->eventId = WLAN_SCAN_EVENT_HO_SCAN_REQ; |
| 8792 | pScanLog->minChnTime = (v_U8_t)pScanReq->minChnTime; |
| 8793 | pScanLog->maxChnTime = (v_U8_t)pScanReq->maxChnTime; |
| 8794 | pScanLog->timeBetweenBgScan = (v_U8_t)pScanReq->scanInterval; |
| 8795 | pScanLog->numChannel = pScanReq->ChannelInfo.numOfChannels; |
| 8796 | if(pScanLog->numChannel && (pScanLog->numChannel < VOS_LOG_MAX_NUM_CHANNEL)) |
| 8797 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8798 | vos_mem_copy(pScanLog->channels, |
| 8799 | pScanReq->ChannelInfo.ChannelList, |
| 8800 | pScanLog->numChannel); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8801 | } |
| 8802 | WLAN_VOS_DIAG_LOG_REPORT(pScanLog); |
| 8803 | } |
| 8804 | } |
| 8805 | #endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 8806 | |
| 8807 | status = ccmCfgSetInt(pMac, WNI_CFG_BACKGROUND_SCAN_PERIOD, pScanReq->scanInterval, NULL, eANI_BOOLEAN_FALSE); |
| 8808 | } |
| 8809 | else |
| 8810 | { |
| 8811 | //No need to stop aging because IDLE scan is still running |
| 8812 | status = ccmCfgSetInt(pMac, WNI_CFG_BACKGROUND_SCAN_PERIOD, 0, NULL, eANI_BOOLEAN_FALSE); |
| 8813 | } |
| 8814 | |
| 8815 | if(pScanReq->SSID.length > WNI_CFG_SSID_LEN) |
| 8816 | { |
| 8817 | pScanReq->SSID.length = WNI_CFG_SSID_LEN; |
| 8818 | } |
| 8819 | |
| 8820 | status = ccmCfgSetStr(pMac, WNI_CFG_BG_SCAN_CHANNEL_LIST, pScanReq->ChannelInfo.ChannelList, dataLen, NULL, eANI_BOOLEAN_FALSE); |
| 8821 | status = ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pScanReq->SSID.ssId, pScanReq->SSID.length, NULL, eANI_BOOLEAN_FALSE); |
| 8822 | |
| 8823 | |
| 8824 | |
| 8825 | return (status); |
| 8826 | } |
| 8827 | |
| 8828 | |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 8829 | tSirAbortScanStatus csrScanAbortMacScan(tpAniSirGlobal pMac, |
| 8830 | tANI_U8 sessionId, |
| 8831 | eCsrAbortReason reason) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8832 | { |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 8833 | tSirAbortScanStatus abortScanStatus = eSIR_ABORT_ACTIVE_SCAN_LIST_EMPTY; |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 8834 | tSirSmeScanAbortReq *pMsg; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8835 | tANI_U16 msgLen; |
| 8836 | tListElem *pEntry; |
| 8837 | tSmeCmd *pCommand; |
| 8838 | |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 8839 | if (!pMac->fScanOffload) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8840 | { |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 8841 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 8842 | csrLLLock(&pMac->scan.scanCmdPendingList); |
| 8843 | while(NULL != |
| 8844 | (pEntry = csrLLRemoveHead(&pMac->scan.scanCmdPendingList, |
| 8845 | LL_ACCESS_NOLOCK))) |
| 8846 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8847 | |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 8848 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 8849 | csrAbortCommand( pMac, pCommand, eANI_BOOLEAN_FALSE); |
| 8850 | } |
| 8851 | csrLLUnlock(&pMac->scan.scanCmdPendingList); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8852 | #endif |
| 8853 | |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 8854 | pMac->scan.fDropScanCmd = eANI_BOOLEAN_TRUE; |
| 8855 | csrRemoveCmdFromPendingList( pMac, &pMac->roam.roamCmdPendingList, eSmeCommandScan); |
| 8856 | csrRemoveCmdFromPendingList( pMac, &pMac->sme.smeCmdPendingList, eSmeCommandScan); |
| 8857 | pMac->scan.fDropScanCmd = eANI_BOOLEAN_FALSE; |
| 8858 | |
| 8859 | pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK); |
| 8860 | } |
| 8861 | else |
| 8862 | { |
| 8863 | pMac->scan.fDropScanCmd = eANI_BOOLEAN_TRUE; |
| 8864 | csrRemoveCmdWithSessionIdFromPendingList(pMac, |
| 8865 | sessionId, |
| 8866 | &pMac->sme.smeScanCmdPendingList, |
| 8867 | eSmeCommandScan); |
| 8868 | pMac->scan.fDropScanCmd = eANI_BOOLEAN_FALSE; |
| 8869 | |
| 8870 | pEntry = csrLLPeekHead(&pMac->sme.smeScanCmdActiveList, LL_ACCESS_LOCK); |
| 8871 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8872 | |
| 8873 | //We need to abort scan only if we are scanning |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 8874 | if(NULL != pEntry) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8875 | { |
| 8876 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 8877 | if(eSmeCommandScan == pCommand->command && |
| 8878 | pCommand->sessionId == sessionId) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8879 | { |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 8880 | msgLen = (tANI_U16)(sizeof(tSirSmeScanAbortReq)); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8881 | pMsg = vos_mem_malloc(msgLen); |
| 8882 | if ( NULL == pMsg ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8883 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8884 | smsLog(pMac, LOGE, FL("Failed to allocate memory for SmeScanAbortReq")); |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 8885 | abortScanStatus = eSIR_ABORT_SCAN_FAILURE; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8886 | } |
| 8887 | else |
| 8888 | { |
Ratheesh S P | ece1f83 | 2015-07-25 15:50:25 +0530 | [diff] [blame] | 8889 | pCommand->u.scanCmd.abortScanIndication = eCSR_SCAN_ABORT_DEFAULT; |
Srinivas, Dasari | 187ca4e | 2014-02-07 12:40:09 +0530 | [diff] [blame] | 8890 | if(reason == eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE) |
| 8891 | { |
Ratheesh S P | ece1f83 | 2015-07-25 15:50:25 +0530 | [diff] [blame] | 8892 | pCommand->u.scanCmd.abortScanIndication |
| 8893 | = eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE; |
Srinivas, Dasari | 187ca4e | 2014-02-07 12:40:09 +0530 | [diff] [blame] | 8894 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8895 | vos_mem_set((void *)pMsg, msgLen, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8896 | pMsg->type = pal_cpu_to_be16((tANI_U16)eWNI_SME_SCAN_ABORT_IND); |
| 8897 | pMsg->msgLen = pal_cpu_to_be16(msgLen); |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 8898 | pMsg->sessionId = sessionId; |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 8899 | if (eHAL_STATUS_SUCCESS != palSendMBMessage(pMac->hHdd, pMsg)) |
| 8900 | { |
| 8901 | smsLog(pMac, LOGE, |
| 8902 | FL("Failed to post eWNI_SME_SCAN_ABORT_IND")); |
| 8903 | abortScanStatus = eSIR_ABORT_SCAN_FAILURE; |
Ratheesh S P | ece1f83 | 2015-07-25 15:50:25 +0530 | [diff] [blame] | 8904 | pCommand->u.scanCmd.abortScanIndication = 0; |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 8905 | } |
| 8906 | else |
| 8907 | { |
| 8908 | abortScanStatus = eSIR_ABORT_ACTIVE_SCAN_LIST_NOT_EMPTY; |
| 8909 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8910 | } |
| 8911 | } |
| 8912 | } |
| 8913 | |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 8914 | return(abortScanStatus); |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 8915 | } |
| 8916 | |
| 8917 | void csrRemoveCmdWithSessionIdFromPendingList(tpAniSirGlobal pMac, |
| 8918 | tANI_U8 sessionId, |
| 8919 | tDblLinkList *pList, |
| 8920 | eSmeCommandType commandType) |
| 8921 | { |
| 8922 | tDblLinkList localList; |
| 8923 | tListElem *pEntry; |
| 8924 | tSmeCmd *pCommand; |
| 8925 | tListElem *pEntryToRemove; |
| 8926 | |
| 8927 | vos_mem_zero(&localList, sizeof(tDblLinkList)); |
| 8928 | if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList))) |
| 8929 | { |
| 8930 | smsLog(pMac, LOGE, FL(" failed to open list")); |
| 8931 | return; |
| 8932 | } |
| 8933 | |
| 8934 | csrLLLock(pList); |
| 8935 | if ((pEntry = csrLLPeekHead( pList, LL_ACCESS_NOLOCK))) |
| 8936 | { |
| 8937 | |
| 8938 | /* Have to make sure we don't loop back to the head of the list, |
| 8939 | * which will happen if the entry is NOT on the list */ |
| 8940 | while (pEntry) |
| 8941 | { |
| 8942 | pEntryToRemove = pEntry; |
| 8943 | pEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK); |
| 8944 | pCommand = GET_BASE_ADDR( pEntryToRemove, tSmeCmd, Link ); |
| 8945 | if ((pCommand->command == commandType) && |
| 8946 | (pCommand->sessionId == sessionId)) |
| 8947 | { |
| 8948 | /* Remove that entry only */ |
| 8949 | if (csrLLRemoveEntry( pList, pEntryToRemove, LL_ACCESS_NOLOCK)) |
| 8950 | { |
| 8951 | csrLLInsertTail(&localList, pEntryToRemove, |
| 8952 | LL_ACCESS_NOLOCK); |
| 8953 | } |
| 8954 | } |
| 8955 | } |
| 8956 | } |
| 8957 | csrLLUnlock(pList); |
| 8958 | |
| 8959 | while ((pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK))) |
| 8960 | { |
| 8961 | pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link); |
| 8962 | csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_FALSE); |
| 8963 | } |
| 8964 | |
| 8965 | csrLLClose(&localList); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8966 | } |
| 8967 | |
| 8968 | void csrRemoveCmdFromPendingList(tpAniSirGlobal pMac, tDblLinkList *pList, |
| 8969 | eSmeCommandType commandType ) |
| 8970 | { |
| 8971 | tDblLinkList localList; |
| 8972 | tListElem *pEntry; |
| 8973 | tSmeCmd *pCommand; |
| 8974 | tListElem *pEntryToRemove; |
| 8975 | |
| 8976 | vos_mem_zero(&localList, sizeof(tDblLinkList)); |
| 8977 | if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList))) |
| 8978 | { |
| 8979 | smsLog(pMac, LOGE, FL(" failed to open list")); |
| 8980 | return; |
| 8981 | } |
| 8982 | |
| 8983 | csrLLLock(pList); |
| 8984 | if( !csrLLIsListEmpty( pList, LL_ACCESS_NOLOCK ) ) |
| 8985 | { |
| 8986 | pEntry = csrLLPeekHead( pList, LL_ACCESS_NOLOCK); |
| 8987 | |
| 8988 | // Have to make sure we don't loop back to the head of the list, which will |
| 8989 | // happen if the entry is NOT on the list... |
| 8990 | while( pEntry ) |
| 8991 | { |
| 8992 | pEntryToRemove = pEntry; |
| 8993 | pEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK); |
| 8994 | pCommand = GET_BASE_ADDR( pEntryToRemove, tSmeCmd, Link ); |
| 8995 | if ( pCommand->command == commandType ) |
| 8996 | { |
| 8997 | // Remove that entry only |
| 8998 | if(csrLLRemoveEntry( pList, pEntryToRemove, LL_ACCESS_NOLOCK)) |
| 8999 | { |
| 9000 | csrLLInsertTail(&localList, pEntryToRemove, LL_ACCESS_NOLOCK); |
| 9001 | } |
| 9002 | } |
| 9003 | } |
| 9004 | |
| 9005 | |
| 9006 | } |
| 9007 | csrLLUnlock(pList); |
| 9008 | |
| 9009 | while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) ) |
| 9010 | { |
| 9011 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 9012 | csrAbortCommand( pMac, pCommand, eANI_BOOLEAN_FALSE); |
| 9013 | } |
| 9014 | csrLLClose(&localList); |
| 9015 | |
| 9016 | } |
| 9017 | |
Abhishek Singh | dc2bfd4 | 2014-06-19 17:59:05 +0530 | [diff] [blame] | 9018 | eHalStatus csrScanAbortScanForSSID(tpAniSirGlobal pMac, tANI_U32 sessionId) |
| 9019 | { |
| 9020 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 9021 | tSirSmeScanAbortReq *pMsg; |
| 9022 | tANI_U16 msgLen; |
| 9023 | tListElem *pEntry; |
| 9024 | tSmeCmd *pCommand; |
| 9025 | |
| 9026 | if (!pMac->fScanOffload) |
| 9027 | { |
| 9028 | pMac->scan.fDropScanCmd = eANI_BOOLEAN_TRUE; |
| 9029 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 9030 | csrRemoveScanForSSIDFromPendingList( pMac, &pMac->scan.scanCmdPendingList, sessionId); |
| 9031 | #endif |
| 9032 | csrRemoveScanForSSIDFromPendingList( pMac, &pMac->roam.roamCmdPendingList, sessionId); |
| 9033 | csrRemoveScanForSSIDFromPendingList( pMac, &pMac->sme.smeCmdPendingList, sessionId); |
| 9034 | pMac->scan.fDropScanCmd = eANI_BOOLEAN_FALSE; |
| 9035 | pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK); |
| 9036 | } |
| 9037 | else |
| 9038 | { |
| 9039 | pMac->scan.fDropScanCmd = eANI_BOOLEAN_TRUE; |
| 9040 | csrRemoveScanForSSIDFromPendingList( pMac, &pMac->sme.smeScanCmdPendingList, sessionId); |
| 9041 | pMac->scan.fDropScanCmd = eANI_BOOLEAN_FALSE; |
| 9042 | pEntry = csrLLPeekHead(&pMac->sme.smeScanCmdActiveList, LL_ACCESS_LOCK); |
| 9043 | } |
| 9044 | |
| 9045 | if(NULL != pEntry) |
| 9046 | { |
| 9047 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 9048 | |
| 9049 | if ( (eSmeCommandScan == pCommand->command ) && |
| 9050 | (sessionId == pCommand->sessionId)) |
| 9051 | { |
| 9052 | if ( eCsrScanForSsid == pCommand->u.scanCmd.reason) |
| 9053 | { |
| 9054 | msgLen = (tANI_U16)(sizeof( tSirSmeScanAbortReq )); |
| 9055 | pMsg = vos_mem_malloc(msgLen); |
| 9056 | if ( NULL == pMsg ) |
| 9057 | { |
| 9058 | status = eHAL_STATUS_FAILURE; |
| 9059 | smsLog(pMac, LOGE, FL("Failed to allocate memory for SmeScanAbortReq")); |
| 9060 | } |
| 9061 | else |
| 9062 | { |
| 9063 | vos_mem_zero((void *)pMsg, msgLen); |
| 9064 | pMsg->type = pal_cpu_to_be16((tANI_U16)eWNI_SME_SCAN_ABORT_IND); |
| 9065 | pMsg->msgLen = pal_cpu_to_be16(msgLen); |
| 9066 | pMsg->sessionId = sessionId; |
| 9067 | status = palSendMBMessage(pMac->hHdd, pMsg); |
| 9068 | } |
| 9069 | } |
| 9070 | } |
| 9071 | } |
| 9072 | return( status ); |
| 9073 | } |
| 9074 | |
| 9075 | void csrRemoveScanForSSIDFromPendingList(tpAniSirGlobal pMac, tDblLinkList *pList, tANI_U32 sessionId) |
| 9076 | { |
| 9077 | tDblLinkList localList; |
| 9078 | tListElem *pEntry; |
| 9079 | tSmeCmd *pCommand; |
| 9080 | tListElem *pEntryToRemove; |
| 9081 | |
| 9082 | vos_mem_zero(&localList, sizeof(tDblLinkList)); |
| 9083 | if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList))) |
| 9084 | { |
| 9085 | smsLog(pMac, LOGE, FL(" failed to open list")); |
| 9086 | return; |
| 9087 | } |
| 9088 | |
| 9089 | csrLLLock(pList); |
| 9090 | if( !csrLLIsListEmpty( pList, LL_ACCESS_NOLOCK ) ) |
| 9091 | { |
| 9092 | pEntry = csrLLPeekHead( pList, LL_ACCESS_NOLOCK); |
| 9093 | |
| 9094 | // Have to make sure we don't loop back to the head of the list, which will |
| 9095 | // happen if the entry is NOT on the list... |
| 9096 | while( pEntry ) |
| 9097 | { |
| 9098 | pEntryToRemove = pEntry; |
| 9099 | pEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK); |
| 9100 | pCommand = GET_BASE_ADDR( pEntryToRemove, tSmeCmd, Link ); |
| 9101 | if ( (eSmeCommandScan == pCommand->command ) && |
| 9102 | (sessionId == pCommand->sessionId) ) |
| 9103 | { |
| 9104 | if ( eCsrScanForSsid == pCommand->u.scanCmd.reason) |
| 9105 | { |
| 9106 | // Remove that entry only |
| 9107 | if ( csrLLRemoveEntry( pList, pEntryToRemove, LL_ACCESS_NOLOCK)) |
| 9108 | { |
| 9109 | csrLLInsertTail(&localList, pEntryToRemove, LL_ACCESS_NOLOCK); |
| 9110 | } |
| 9111 | } |
| 9112 | } |
| 9113 | } |
| 9114 | } |
| 9115 | csrLLUnlock(pList); |
| 9116 | |
| 9117 | while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) ) |
| 9118 | { |
| 9119 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 9120 | csrAbortCommand( pMac, pCommand, eANI_BOOLEAN_FALSE); |
| 9121 | } |
| 9122 | csrLLClose(&localList); |
| 9123 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9124 | |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 9125 | eHalStatus csrScanAbortMacScanNotForConnect(tpAniSirGlobal pMac, |
| 9126 | tANI_U8 sessionId) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9127 | { |
| 9128 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 9129 | |
| 9130 | if( !csrIsScanForRoamCommandActive( pMac ) ) |
| 9131 | { |
| 9132 | //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] | 9133 | if (eSIR_ABORT_SCAN_FAILURE == |
| 9134 | csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT)) |
| 9135 | { |
| 9136 | smsLog(pMac, LOGE, FL("fail to abort scan")); |
| 9137 | status = eHAL_STATUS_FAILURE; |
| 9138 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9139 | } |
| 9140 | |
| 9141 | return (status); |
| 9142 | } |
| 9143 | |
| 9144 | |
Madan Mohan Koyyalamudi | de1b5bc | 2013-07-12 00:56:04 +0530 | [diff] [blame] | 9145 | eHalStatus csrScanGetScanChannelInfo(tpAniSirGlobal pMac, tANI_U8 sessionId) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9146 | { |
| 9147 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 9148 | tSirMbMsg *pMsg; |
| 9149 | tANI_U16 msgLen; |
| 9150 | |
Madan Mohan Koyyalamudi | de1b5bc | 2013-07-12 00:56:04 +0530 | [diff] [blame] | 9151 | if (pMac->fScanOffload) |
| 9152 | msgLen = (tANI_U16)(sizeof(tSirSmeGetScanChanReq)); |
| 9153 | else |
| 9154 | msgLen = (tANI_U16)(sizeof(tSirMbMsg)); |
| 9155 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 9156 | pMsg = vos_mem_malloc(msgLen); |
| 9157 | if ( NULL == pMsg ) |
| 9158 | status = eHAL_STATUS_FAILURE; |
| 9159 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9160 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 9161 | vos_mem_set(pMsg, msgLen, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9162 | pMsg->type = eWNI_SME_GET_SCANNED_CHANNEL_REQ; |
| 9163 | pMsg->msgLen = msgLen; |
Madan Mohan Koyyalamudi | de1b5bc | 2013-07-12 00:56:04 +0530 | [diff] [blame] | 9164 | if (pMac->fScanOffload) |
| 9165 | ((tSirSmeGetScanChanReq *)pMsg)->sessionId = sessionId; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9166 | status = palSendMBMessage(pMac->hHdd, pMsg); |
| 9167 | } |
| 9168 | |
| 9169 | return( status ); |
| 9170 | } |
| 9171 | |
| 9172 | tANI_BOOLEAN csrRoamIsValidChannel( tpAniSirGlobal pMac, tANI_U8 channel ) |
| 9173 | { |
| 9174 | tANI_BOOLEAN fValid = FALSE; |
| 9175 | tANI_U32 idxValidChannels; |
| 9176 | tANI_U32 len = pMac->roam.numValidChannels; |
| 9177 | |
| 9178 | for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ ) |
| 9179 | { |
| 9180 | if ( channel == pMac->roam.validChannelList[ idxValidChannels ] ) |
| 9181 | { |
| 9182 | fValid = TRUE; |
| 9183 | break; |
| 9184 | } |
| 9185 | } |
| 9186 | |
| 9187 | return fValid; |
| 9188 | } |
| 9189 | |
Manjunathappa Prakash | 4f1d5a5 | 2013-11-11 16:22:19 -0800 | [diff] [blame] | 9190 | #ifdef FEATURE_WLAN_SCAN_PNO |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9191 | eHalStatus csrScanSavePreferredNetworkFound(tpAniSirGlobal pMac, |
| 9192 | tSirPrefNetworkFoundInd *pPrefNetworkFoundInd) |
| 9193 | { |
| 9194 | v_U32_t uLen = 0; |
| 9195 | tpSirProbeRespBeacon pParsedFrame; |
| 9196 | tCsrScanResult *pScanResult = NULL; |
| 9197 | tSirBssDescription *pBssDescr = NULL; |
| 9198 | tANI_BOOLEAN fDupBss; |
| 9199 | tDot11fBeaconIEs *pIesLocal = NULL; |
| 9200 | tAniSSID tmpSsid; |
| 9201 | v_TIME_t timer=0; |
| 9202 | tpSirMacMgmtHdr macHeader = (tpSirMacMgmtHdr)pPrefNetworkFoundInd->data; |
Abhishek Singh | d3d4e02 | 2014-11-11 13:02:40 +0530 | [diff] [blame] | 9203 | boolean bFoundonAppliedChannel = FALSE; |
| 9204 | v_U32_t indx; |
| 9205 | u8 channelsAllowed[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 9206 | v_U32_t numChannelsAllowed = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
Sushant Kaushik | 6274de6 | 2015-05-01 16:31:23 +0530 | [diff] [blame] | 9207 | tListElem *pEntry; |
Abhishek Singh | d3d4e02 | 2014-11-11 13:02:40 +0530 | [diff] [blame] | 9208 | |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9209 | |
| 9210 | pParsedFrame = |
Abhishek Singh | c75726d | 2015-04-13 14:44:14 +0530 | [diff] [blame] | 9211 | (tpSirProbeRespBeacon)vos_mem_vmalloc(sizeof(tSirProbeRespBeacon)); |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9212 | |
| 9213 | if (NULL == pParsedFrame) |
| 9214 | { |
| 9215 | smsLog(pMac, LOGE, FL(" fail to allocate memory for frame")); |
| 9216 | return eHAL_STATUS_RESOURCES; |
| 9217 | } |
| 9218 | |
| 9219 | if ( pPrefNetworkFoundInd->frameLength <= SIR_MAC_HDR_LEN_3A ) |
| 9220 | { |
| 9221 | smsLog(pMac, LOGE, |
| 9222 | FL("Not enough bytes in PNO indication probe resp frame! length=%d"), |
| 9223 | pPrefNetworkFoundInd->frameLength); |
Abhishek Singh | c75726d | 2015-04-13 14:44:14 +0530 | [diff] [blame] | 9224 | vos_mem_vfree(pParsedFrame); |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9225 | return eHAL_STATUS_FAILURE; |
| 9226 | } |
| 9227 | |
| 9228 | if (sirConvertProbeFrame2Struct(pMac, |
| 9229 | &pPrefNetworkFoundInd->data[SIR_MAC_HDR_LEN_3A], |
| 9230 | pPrefNetworkFoundInd->frameLength - SIR_MAC_HDR_LEN_3A, |
| 9231 | pParsedFrame) != eSIR_SUCCESS || |
| 9232 | !pParsedFrame->ssidPresent) |
| 9233 | { |
| 9234 | smsLog(pMac, LOGE, |
| 9235 | FL("Parse error ProbeResponse, length=%d"), |
| 9236 | pPrefNetworkFoundInd->frameLength); |
Abhishek Singh | c75726d | 2015-04-13 14:44:14 +0530 | [diff] [blame] | 9237 | vos_mem_vfree(pParsedFrame); |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9238 | return eHAL_STATUS_FAILURE; |
| 9239 | } |
| 9240 | //24 byte MAC header and 12 byte to ssid IE |
| 9241 | if (pPrefNetworkFoundInd->frameLength > |
| 9242 | (SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_SSID_OFFSET)) |
| 9243 | { |
| 9244 | uLen = pPrefNetworkFoundInd->frameLength - |
| 9245 | (SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_SSID_OFFSET); |
| 9246 | } |
| 9247 | |
Yeshwanth Sriram Guntuka | 1a10255 | 2018-08-10 15:33:26 +0530 | [diff] [blame] | 9248 | if (uLen > (UINT_MAX - sizeof(tCsrScanResult))) { |
| 9249 | smsLog(pMac, LOGE, FL("Incorrect len: %d, may leads to int overflow, uLen %d"), |
| 9250 | pPrefNetworkFoundInd->frameLength, uLen); |
| 9251 | vos_mem_vfree(pParsedFrame); |
| 9252 | return eHAL_STATUS_FAILURE; |
| 9253 | } |
| 9254 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 9255 | pScanResult = vos_mem_malloc(sizeof(tCsrScanResult) + uLen); |
| 9256 | if ( NULL == pScanResult ) |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9257 | { |
| 9258 | smsLog(pMac, LOGE, FL(" fail to allocate memory for frame")); |
| 9259 | vos_mem_free(pParsedFrame); |
| 9260 | return eHAL_STATUS_RESOURCES; |
| 9261 | } |
| 9262 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 9263 | vos_mem_set(pScanResult, sizeof(tCsrScanResult) + uLen, 0); |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9264 | pBssDescr = &pScanResult->Result.BssDescriptor; |
| 9265 | /** |
| 9266 | * Length of BSS desription is without length of |
| 9267 | * length itself and length of pointer |
| 9268 | * that holds the next BSS description |
| 9269 | */ |
| 9270 | pBssDescr->length = (tANI_U16)( |
Abhishek Singh | bad2b32 | 2016-10-21 11:22:33 +0530 | [diff] [blame] | 9271 | ((uintptr_t)OFFSET_OF(tSirBssDescription, ieFields)) |
| 9272 | - sizeof(pBssDescr->length) + uLen); |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9273 | if (pParsedFrame->dsParamsPresent) |
| 9274 | { |
| 9275 | pBssDescr->channelId = pParsedFrame->channelNumber; |
| 9276 | } |
| 9277 | else if (pParsedFrame->HTInfo.present) |
| 9278 | { |
| 9279 | pBssDescr->channelId = pParsedFrame->HTInfo.primaryChannel; |
| 9280 | } |
| 9281 | else |
| 9282 | { |
Mahesh A Saptasagar | add9979 | 2014-03-26 16:04:20 +0530 | [diff] [blame] | 9283 | /** |
| 9284 | * If Probe Responce received in PNO indication does not |
| 9285 | * contain DSParam IE or HT Info IE then add dummy channel |
| 9286 | * to the received BSS info so that Scan result received as |
| 9287 | * a part of PNO is updated to the supplicant. Specially |
| 9288 | * applicable in case of AP configured in 11A only mode. |
| 9289 | */ |
| 9290 | if ((pMac->roam.configParam.bandCapability == eCSR_BAND_ALL) || |
| 9291 | (pMac->roam.configParam.bandCapability == eCSR_BAND_24)) |
| 9292 | { |
| 9293 | pBssDescr->channelId = 1; |
| 9294 | } |
| 9295 | else if(pMac->roam.configParam.bandCapability == eCSR_BAND_5G) |
| 9296 | { |
| 9297 | pBssDescr->channelId = 36; |
| 9298 | } |
Abhishek Singh | d3d4e02 | 2014-11-11 13:02:40 +0530 | [diff] [blame] | 9299 | /* Restrict the logic to ignore the pno indication for invalid channel |
| 9300 | * only if valid channel info is present in beacon/probe resp. |
| 9301 | * If no channel info is present in beacon/probe resp, always process |
| 9302 | * the pno indication. |
| 9303 | */ |
| 9304 | bFoundonAppliedChannel = TRUE; |
| 9305 | } |
| 9306 | |
| 9307 | if (0 != sme_GetCfgValidChannels(pMac, channelsAllowed, &numChannelsAllowed)) |
| 9308 | { |
| 9309 | smsLog(pMac, LOGE, FL(" sme_GetCfgValidChannels failed ")); |
| 9310 | csrFreeScanResultEntry(pMac, pScanResult); |
Abhishek Singh | c75726d | 2015-04-13 14:44:14 +0530 | [diff] [blame] | 9311 | vos_mem_vfree(pParsedFrame); |
Abhishek Singh | d3d4e02 | 2014-11-11 13:02:40 +0530 | [diff] [blame] | 9312 | return eHAL_STATUS_FAILURE; |
| 9313 | } |
| 9314 | /* Checking chhanelId with allowed channel list */ |
| 9315 | for (indx = 0; indx < numChannelsAllowed; indx++) |
| 9316 | { |
| 9317 | if (pBssDescr->channelId == channelsAllowed[indx]) |
| 9318 | { |
| 9319 | bFoundonAppliedChannel = TRUE; |
| 9320 | smsLog(pMac, LOG1, FL(" pno ind found on applied channel =%d\n "), |
| 9321 | pBssDescr->channelId); |
| 9322 | break; |
| 9323 | } |
| 9324 | } |
| 9325 | /* Ignore PNO indication if AP is on Invalid channel. |
| 9326 | */ |
| 9327 | if(FALSE == bFoundonAppliedChannel) |
| 9328 | { |
| 9329 | smsLog(pMac, LOGW, FL(" prefered network found on invalid channel = %d"), |
| 9330 | pBssDescr->channelId); |
| 9331 | csrFreeScanResultEntry(pMac, pScanResult); |
Abhishek Singh | c75726d | 2015-04-13 14:44:14 +0530 | [diff] [blame] | 9332 | vos_mem_vfree(pParsedFrame); |
Abhishek Singh | d3d4e02 | 2014-11-11 13:02:40 +0530 | [diff] [blame] | 9333 | return eHAL_STATUS_FAILURE; |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9334 | } |
| 9335 | |
| 9336 | if ((pBssDescr->channelId > 0) && (pBssDescr->channelId < 15)) |
| 9337 | { |
| 9338 | int i; |
| 9339 | // 11b or 11g packet |
| 9340 | // 11g iff extended Rate IE is present or |
| 9341 | // if there is an A rate in suppRate IE |
| 9342 | for (i = 0; i < pParsedFrame->supportedRates.numRates; i++) |
| 9343 | { |
| 9344 | if (sirIsArate(pParsedFrame->supportedRates.rate[i] & 0x7f)) |
| 9345 | { |
| 9346 | pBssDescr->nwType = eSIR_11G_NW_TYPE; |
| 9347 | break; |
| 9348 | } |
| 9349 | } |
| 9350 | if (pParsedFrame->extendedRatesPresent) |
| 9351 | { |
| 9352 | pBssDescr->nwType = eSIR_11G_NW_TYPE; |
| 9353 | } |
| 9354 | } |
| 9355 | else |
| 9356 | { |
| 9357 | // 11a packet |
| 9358 | pBssDescr->nwType = eSIR_11A_NW_TYPE; |
| 9359 | } |
| 9360 | |
| 9361 | pBssDescr->sinr = 0; |
| 9362 | pBssDescr->rssi = -1 * pPrefNetworkFoundInd->rssi; |
| 9363 | pBssDescr->beaconInterval = pParsedFrame->beaconInterval; |
AnjaneeDevi Kapparapu | 4b04391 | 2014-02-18 13:22:35 +0530 | [diff] [blame] | 9364 | if (!pBssDescr->beaconInterval) |
| 9365 | { |
| 9366 | smsLog(pMac, LOGW, |
| 9367 | FL("Bcn Interval is Zero , default to 100" MAC_ADDRESS_STR), |
| 9368 | MAC_ADDR_ARRAY(pBssDescr->bssId) ); |
| 9369 | pBssDescr->beaconInterval = 100; |
| 9370 | } |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9371 | pBssDescr->timeStamp[0] = pParsedFrame->timeStamp[0]; |
| 9372 | pBssDescr->timeStamp[1] = pParsedFrame->timeStamp[1]; |
| 9373 | pBssDescr->capabilityInfo = *((tANI_U16 *)&pParsedFrame->capabilityInfo); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 9374 | 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] | 9375 | pBssDescr->nReceivedTime = vos_timer_get_system_time(); |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9376 | |
Sreelakshmi Konamki | 9866a8c | 2017-02-10 12:45:27 +0530 | [diff] [blame] | 9377 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 9378 | // MobilityDomain |
| 9379 | pBssDescr->mdie[0] = 0; |
| 9380 | pBssDescr->mdie[1] = 0; |
| 9381 | pBssDescr->mdie[2] = 0; |
| 9382 | pBssDescr->mdiePresent = FALSE; |
| 9383 | // If mdie is present in the probe resp we fill it in the bss description |
| 9384 | if(pParsedFrame->mdiePresent) |
| 9385 | { |
| 9386 | pBssDescr->mdiePresent = TRUE; |
| 9387 | pBssDescr->mdie[0] = pParsedFrame->mdie[0]; |
| 9388 | pBssDescr->mdie[1] = pParsedFrame->mdie[1]; |
| 9389 | pBssDescr->mdie[2] = pParsedFrame->mdie[2]; |
| 9390 | } |
| 9391 | smsLog(pMac, LOG1, FL("mdie=%02x%02x%02x"), |
| 9392 | (unsigned int)pBssDescr->mdie[0], (unsigned int)pBssDescr->mdie[1], |
| 9393 | (unsigned int)pBssDescr->mdie[2]); |
| 9394 | #endif |
| 9395 | |
Abhishek Singh | 195c03e | 2014-05-14 17:21:30 +0530 | [diff] [blame] | 9396 | smsLog( pMac, LOG1, FL("Bssid= "MAC_ADDRESS_STR |
| 9397 | " chan= %d, rssi = %d "), |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 9398 | MAC_ADDR_ARRAY(pBssDescr->bssId), |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9399 | pBssDescr->channelId, |
Abhishek Singh | 195c03e | 2014-05-14 17:21:30 +0530 | [diff] [blame] | 9400 | pBssDescr->rssi); |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9401 | |
| 9402 | //IEs |
| 9403 | if (uLen) |
| 9404 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 9405 | vos_mem_copy(&pBssDescr->ieFields, |
| 9406 | pPrefNetworkFoundInd->data + (SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_SSID_OFFSET), |
| 9407 | uLen); |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9408 | } |
| 9409 | |
| 9410 | pIesLocal = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ); |
| 9411 | if ( !pIesLocal && |
| 9412 | (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, |
| 9413 | &pScanResult->Result.BssDescriptor, &pIesLocal))) ) |
| 9414 | { |
| 9415 | smsLog(pMac, LOGE, FL(" Cannot parse IEs")); |
| 9416 | csrFreeScanResultEntry(pMac, pScanResult); |
Abhishek Singh | c75726d | 2015-04-13 14:44:14 +0530 | [diff] [blame] | 9417 | vos_mem_vfree(pParsedFrame); |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9418 | return eHAL_STATUS_RESOURCES; |
| 9419 | } |
| 9420 | |
| 9421 | fDupBss = csrRemoveDupBssDescription( pMac, |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 9422 | &pScanResult->Result.BssDescriptor, pIesLocal, &tmpSsid, &timer, FALSE); |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9423 | //Check whether we have reach out limit |
| 9424 | if ( CSR_SCAN_IS_OVER_BSS_LIMIT(pMac) ) |
| 9425 | { |
| 9426 | //Limit reach |
| 9427 | smsLog(pMac, LOGE, FL(" BSS limit reached")); |
| 9428 | //Free the resources |
| 9429 | if( (pScanResult->Result.pvIes == NULL) && pIesLocal ) |
| 9430 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 9431 | vos_mem_free(pIesLocal); |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9432 | } |
| 9433 | csrFreeScanResultEntry(pMac, pScanResult); |
| 9434 | vos_mem_free(pParsedFrame); |
| 9435 | return eHAL_STATUS_RESOURCES; |
| 9436 | } |
Nalla Kartheek | 7194642 | 2015-09-15 14:41:22 +0530 | [diff] [blame] | 9437 | |
| 9438 | if ((macHeader->fc.type == SIR_MAC_MGMT_FRAME) && |
| 9439 | (macHeader->fc.subType == SIR_MAC_MGMT_PROBE_RSP)) |
| 9440 | { |
| 9441 | pScanResult->Result.BssDescriptor.fProbeRsp = 1; |
| 9442 | } |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9443 | //Add to scan cache |
| 9444 | csrScanAddResult(pMac, pScanResult, pIesLocal); |
Sushant Kaushik | 6274de6 | 2015-05-01 16:31:23 +0530 | [diff] [blame] | 9445 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_LOCK ); |
Kiet Lam | b537cfb | 2013-11-07 12:56:49 +0530 | [diff] [blame] | 9446 | if( (pScanResult->Result.pvIes == NULL) && pIesLocal ) |
| 9447 | { |
| 9448 | vos_mem_free(pIesLocal); |
| 9449 | } |
| 9450 | |
Abhishek Singh | c75726d | 2015-04-13 14:44:14 +0530 | [diff] [blame] | 9451 | vos_mem_vfree(pParsedFrame); |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9452 | |
| 9453 | return eHAL_STATUS_SUCCESS; |
| 9454 | } |
Manjunathappa Prakash | 4f1d5a5 | 2013-11-11 16:22:19 -0800 | [diff] [blame] | 9455 | #endif //FEATURE_WLAN_SCAN_PNO |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 9456 | |
Madan Mohan Koyyalamudi | dd3c966 | 2012-11-09 17:39:30 -0800 | [diff] [blame] | 9457 | #ifdef FEATURE_WLAN_LFR |
| 9458 | void csrInitOccupiedChannelsList(tpAniSirGlobal pMac) |
| 9459 | { |
| 9460 | tListElem *pEntry = NULL; |
| 9461 | tCsrScanResult *pBssDesc = NULL; |
| 9462 | tDot11fBeaconIEs *pIes = NULL; |
Srinivas | 28b5b4e | 2012-12-12 13:07:53 -0800 | [diff] [blame] | 9463 | tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo; |
| 9464 | |
| 9465 | if (0 != pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels) |
| 9466 | { |
| 9467 | 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] | 9468 | " hence NO need to build occupied channel list (numChannels = %d)"), |
Srinivas | 28b5b4e | 2012-12-12 13:07:53 -0800 | [diff] [blame] | 9469 | __func__, pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels); |
| 9470 | return; |
| 9471 | } |
Madan Mohan Koyyalamudi | dd3c966 | 2012-11-09 17:39:30 -0800 | [diff] [blame] | 9472 | |
| 9473 | if (!csrNeighborRoamIsNewConnectedProfile(pMac)) |
| 9474 | { |
| 9475 | 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] | 9476 | " matches previous (numChannels = %d)"), |
Madan Mohan Koyyalamudi | dd3c966 | 2012-11-09 17:39:30 -0800 | [diff] [blame] | 9477 | __func__, pMac->scan.occupiedChannels.numChannels); |
| 9478 | return; |
| 9479 | } |
| 9480 | |
| 9481 | /* Empty occupied channels here */ |
| 9482 | pMac->scan.occupiedChannels.numChannels = 0; |
| 9483 | |
| 9484 | csrLLLock(&pMac->scan.scanResultList); |
| 9485 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK ); |
| 9486 | while( pEntry ) |
| 9487 | { |
| 9488 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 9489 | pIes = (tDot11fBeaconIEs *)( pBssDesc->Result.pvIes ); |
| 9490 | |
| 9491 | //At this time, pBssDescription->Result.pvIes may be NULL |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 9492 | if( !pIes && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, |
Madan Mohan Koyyalamudi | dd3c966 | 2012-11-09 17:39:30 -0800 | [diff] [blame] | 9493 | &pBssDesc->Result.BssDescriptor, &pIes))) ) |
| 9494 | { |
| 9495 | continue; |
| 9496 | } |
| 9497 | |
| 9498 | csrScanAddToOccupiedChannels(pMac, pBssDesc, &pMac->scan.occupiedChannels, pIes); |
| 9499 | |
| 9500 | /* |
| 9501 | * Free the memory allocated for pIes in csrGetParsedBssDescriptionIEs |
| 9502 | */ |
| 9503 | if( (pBssDesc->Result.pvIes == NULL) && pIes ) |
| 9504 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 9505 | vos_mem_free(pIes); |
Madan Mohan Koyyalamudi | dd3c966 | 2012-11-09 17:39:30 -0800 | [diff] [blame] | 9506 | } |
| 9507 | |
| 9508 | pEntry = csrLLNext( &pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK ); |
| 9509 | }//while |
| 9510 | csrLLUnlock(&pMac->scan.scanResultList); |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 9511 | |
Madan Mohan Koyyalamudi | dd3c966 | 2012-11-09 17:39:30 -0800 | [diff] [blame] | 9512 | } |
| 9513 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9514 | |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 9515 | eHalStatus csrScanCreateEntryInScanCache(tpAniSirGlobal pMac, tANI_U32 sessionId, |
| 9516 | tCsrBssid bssid, tANI_U8 channel) |
| 9517 | { |
| 9518 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 9519 | tDot11fBeaconIEs *pNewIes = NULL; |
| 9520 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
Praveen Kumar Sirisilla | 8bdfac4 | 2013-10-10 17:20:48 -0700 | [diff] [blame] | 9521 | tSirBssDescription *pNewBssDescriptor = NULL; |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 9522 | tANI_U32 size = 0; |
| 9523 | |
| 9524 | if(NULL == pSession) |
| 9525 | { |
| 9526 | status = eHAL_STATUS_FAILURE; |
| 9527 | return status; |
| 9528 | } |
| 9529 | smsLog(pMac, LOG2, FL("csrScanCreateEntryInScanCache: Current bssid::" |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 9530 | MAC_ADDRESS_STR), |
| 9531 | MAC_ADDR_ARRAY(pSession->pConnectBssDesc->bssId)); |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 9532 | smsLog(pMac, LOG2, FL("csrScanCreateEntryInScanCache: My bssid::" |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 9533 | MAC_ADDRESS_STR" channel %d"), |
| 9534 | MAC_ADDR_ARRAY(bssid), channel); |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 9535 | |
| 9536 | do |
| 9537 | { |
| 9538 | if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, |
| 9539 | pSession->pConnectBssDesc, &pNewIes))) |
| 9540 | { |
| 9541 | smsLog(pMac, LOGE, FL("%s: Failed to parse IEs"), |
| 9542 | __func__); |
| 9543 | status = eHAL_STATUS_FAILURE; |
| 9544 | break; |
| 9545 | } |
| 9546 | |
| 9547 | size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 9548 | if (size) |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 9549 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 9550 | pNewBssDescriptor = vos_mem_malloc(size); |
| 9551 | if ( NULL == pNewBssDescriptor ) |
| 9552 | status = eHAL_STATUS_FAILURE; |
| 9553 | else |
| 9554 | status = eHAL_STATUS_SUCCESS; |
| 9555 | if (HAL_STATUS_SUCCESS(status)) |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 9556 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 9557 | vos_mem_copy(pNewBssDescriptor, pSession->pConnectBssDesc, size); |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 9558 | } |
| 9559 | else |
| 9560 | { |
| 9561 | smsLog(pMac, LOGE, FL("%s: memory allocation failed"), |
| 9562 | __func__); |
| 9563 | status = eHAL_STATUS_FAILURE; |
| 9564 | break; |
| 9565 | } |
| 9566 | |
| 9567 | //change the BSSID & channel as passed |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 9568 | vos_mem_copy(pNewBssDescriptor->bssId, bssid, sizeof(tSirMacAddr)); |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 9569 | pNewBssDescriptor->channelId = channel; |
Tushnim Bhattacharyya | 5128d75 | 2013-06-26 23:23:18 -0700 | [diff] [blame] | 9570 | if(NULL == csrScanAppendBssDescription( pMac, pNewBssDescriptor, pNewIes, TRUE )) |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 9571 | { |
Tushnim Bhattacharyya | 5128d75 | 2013-06-26 23:23:18 -0700 | [diff] [blame] | 9572 | smsLog(pMac, LOGE, FL("%s: csrScanAppendBssDescription failed"), |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 9573 | __func__); |
| 9574 | status = eHAL_STATUS_FAILURE; |
| 9575 | break; |
| 9576 | } |
| 9577 | } |
| 9578 | else |
| 9579 | { |
| 9580 | smsLog(pMac, LOGE, FL("%s: length of bss descriptor is 0"), |
| 9581 | __func__); |
| 9582 | status = eHAL_STATUS_FAILURE; |
| 9583 | break; |
| 9584 | } |
| 9585 | smsLog(pMac, LOGE, FL("%s: entry successfully added in scan cache"), |
| 9586 | __func__); |
| 9587 | }while(0); |
| 9588 | |
| 9589 | if(pNewIes) |
| 9590 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 9591 | vos_mem_free(pNewIes); |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 9592 | } |
| 9593 | if(pNewBssDescriptor) |
| 9594 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 9595 | vos_mem_free(pNewBssDescriptor); |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 9596 | } |
| 9597 | return status; |
| 9598 | } |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 9599 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 9600 | #ifdef FEATURE_WLAN_ESE |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 9601 | // Update the TSF with the difference in system time |
| 9602 | void UpdateCCKMTSF(tANI_U32 *timeStamp0, tANI_U32 *timeStamp1, tANI_U32 *incr) |
| 9603 | { |
| 9604 | tANI_U64 timeStamp64 = ((tANI_U64)*timeStamp1 << 32) | (*timeStamp0); |
| 9605 | |
| 9606 | timeStamp64 = (tANI_U64)(timeStamp64 + (tANI_U64)*incr); |
| 9607 | *timeStamp0 = (tANI_U32)(timeStamp64 & 0xffffffff); |
| 9608 | *timeStamp1 = (tANI_U32)((timeStamp64 >> 32) & 0xffffffff); |
| 9609 | } |
| 9610 | #endif |
Deepthi Gowri | ecc9335 | 2016-11-09 16:58:47 +0530 | [diff] [blame] | 9611 | |
| 9612 | void csrValidateScanChannels(tpAniSirGlobal pMac, tCsrScanRequest *pDstReq, |
Nishank Aggarwal | 42f7650 | 2017-02-16 12:00:19 +0530 | [diff] [blame] | 9613 | tCsrScanRequest *pSrcReq, tANI_U32 *new_index, tANI_U8 ch144_support) |
Deepthi Gowri | ecc9335 | 2016-11-09 16:58:47 +0530 | [diff] [blame] | 9614 | { |
| 9615 | |
| 9616 | int index; |
| 9617 | for ( index = 0; index < pSrcReq->ChannelInfo. |
| 9618 | numOfChannels ; index++ ) |
| 9619 | { |
| 9620 | /* Skip CH 144 if firmware support not present */ |
| 9621 | if (pSrcReq->ChannelInfo.ChannelList[index] == 144 && !ch144_support) |
| 9622 | continue; |
| 9623 | |
| 9624 | /* Allow scan on valid channels only. |
| 9625 | */ |
| 9626 | if ( ( csrRoamIsValidChannel(pMac, |
| 9627 | pSrcReq->ChannelInfo.ChannelList[index]) ) ) |
| 9628 | { |
| 9629 | if( ((pSrcReq->skipDfsChnlInP2pSearch || |
| 9630 | (pMac->scan.fEnableDFSChnlScan == |
| 9631 | DFS_CHNL_SCAN_DISABLED)) && |
| 9632 | (NV_CHANNEL_DFS == vos_nv_getChannelEnabledState( |
| 9633 | pSrcReq->ChannelInfo.ChannelList[index])) && |
| 9634 | (pSrcReq->ChannelInfo.numOfChannels > 1)) |
| 9635 | #ifdef FEATURE_WLAN_LFR |
| 9636 | /* |
| 9637 | * If LFR is requesting a contiguous scan |
| 9638 | * (i.e. numOfChannels > 1), then ignore |
| 9639 | * DFS channels. |
| 9640 | * TODO: vos_nv_getChannelEnabledState is returning |
| 9641 | * 120, 124 and 128 as non-DFS channels. Hence, the |
| 9642 | * use of direct check for channels below. |
| 9643 | */ |
| 9644 | || ((eCSR_SCAN_HO_BG_SCAN == pSrcReq->requestType) && |
| 9645 | (pSrcReq->ChannelInfo.numOfChannels > 1) && |
| 9646 | (CSR_IS_CHANNEL_DFS( |
| 9647 | pSrcReq->ChannelInfo.ChannelList[index])) && |
| 9648 | !pMac->roam.configParam.allowDFSChannelRoam) |
| 9649 | #endif |
| 9650 | ) |
| 9651 | { |
| 9652 | #ifdef FEATURE_WLAN_LFR |
| 9653 | smsLog(pMac, LOG1, |
| 9654 | FL(" reqType=%s (%d), numOfChannels=%d," |
| 9655 | " ignoring DFS channel:%d"), |
| 9656 | sme_requestTypetoString(pSrcReq->requestType), |
| 9657 | pSrcReq->requestType, |
| 9658 | pSrcReq->ChannelInfo.numOfChannels, |
| 9659 | pSrcReq->ChannelInfo.ChannelList[index]); |
| 9660 | #endif |
| 9661 | continue; |
| 9662 | } |
| 9663 | |
Nishank Aggarwal | 42f7650 | 2017-02-16 12:00:19 +0530 | [diff] [blame] | 9664 | pDstReq->ChannelInfo.ChannelList[*new_index] = |
Deepthi Gowri | ecc9335 | 2016-11-09 16:58:47 +0530 | [diff] [blame] | 9665 | pSrcReq->ChannelInfo.ChannelList[index]; |
Nishank Aggarwal | 42f7650 | 2017-02-16 12:00:19 +0530 | [diff] [blame] | 9666 | (*new_index)++; |
Deepthi Gowri | ecc9335 | 2016-11-09 16:58:47 +0530 | [diff] [blame] | 9667 | } |
| 9668 | } |
| 9669 | } |