Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Gopichand Nakkala | 92f07d8 | 2013-01-08 21:16:34 -0800 | [diff] [blame] | 2 | * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. |
| 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | /* |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 22 | * Copyright (c) 2012, The Linux Foundation. All rights reserved. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 23 | * |
| 24 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 25 | * |
| 26 | * |
| 27 | * Permission to use, copy, modify, and/or distribute this software for |
| 28 | * any purpose with or without fee is hereby granted, provided that the |
| 29 | * above copyright notice and this permission notice appear in all |
| 30 | * copies. |
| 31 | * |
| 32 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 33 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 35 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 36 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 37 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 38 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 39 | * PERFORMANCE OF THIS SOFTWARE. |
| 40 | */ |
| 41 | |
| 42 | /** ------------------------------------------------------------------------- * |
| 43 | ------------------------------------------------------------------------- * |
| 44 | |
| 45 | |
| 46 | \file csrApiScan.c |
| 47 | |
| 48 | Implementation for the Common Scan interfaces. |
| 49 | |
| 50 | Copyright (C) 2006 Airgo Networks, Incorporated |
| 51 | ========================================================================== */ |
| 52 | |
| 53 | #include "aniGlobal.h" |
| 54 | |
| 55 | #include "palApi.h" |
| 56 | #include "csrInsideApi.h" |
| 57 | #include "smeInside.h" |
| 58 | #include "smsDebug.h" |
| 59 | |
| 60 | #include "csrSupport.h" |
| 61 | #include "wlan_qct_tl.h" |
| 62 | |
| 63 | #include "vos_diag_core_log.h" |
| 64 | #include "vos_diag_core_event.h" |
| 65 | |
| 66 | #include "vos_nvitem.h" |
| 67 | #include "wlan_qct_wda.h" |
| 68 | |
| 69 | #define CSR_VALIDATE_LIST //This portion of code need to be removed once the issue is resolved. |
| 70 | |
| 71 | #ifdef CSR_VALIDATE_LIST |
| 72 | tDblLinkList *g_pchannelPowerInfoList24 = NULL, * g_pchannelPowerInfoList5 = NULL; |
Madan Mohan Koyyalamudi | dfd6aa8 | 2012-10-18 20:18:43 -0700 | [diff] [blame] | 73 | tpAniSirGlobal g_pMac; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 74 | #endif |
| 75 | |
| 76 | /* Purpose of HIDDEN_TIMER |
| 77 | ** When we remove hidden ssid from the profile i.e., forget the SSID via GUI that SSID shouldn't see in the profile |
| 78 | ** For above requirement we used timer limit, logic is explained below |
| 79 | ** Timer value is initialsed to current time when it receives corresponding probe response of hidden SSID (The probe request is |
| 80 | ** received regularly till SSID in the profile. Once it is removed from profile probe request is not sent.) when we receive probe response |
| 81 | ** 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 |
| 82 | ** then we are not updating with old one |
| 83 | */ |
| 84 | |
| 85 | #define HIDDEN_TIMER (1*60*1000) |
| 86 | #define CSR_SCAN_RESULT_RSSI_WEIGHT 80 // must be less than 100, represent the persentage of new RSSI |
| 87 | |
| 88 | /*--------------------------------------------------------------------------- |
| 89 | PER filter constant fraction: it is a % |
| 90 | ---------------------------------------------------------------------------*/ |
| 91 | #define CSR_SCAN_PER_FILTER_FRAC 100 |
| 92 | |
| 93 | /*--------------------------------------------------------------------------- |
| 94 | RSSI filter constant fraction: it is a % |
| 95 | ---------------------------------------------------------------------------*/ |
| 96 | #define CSR_SCAN_RSSI_FILTER_FRAC 100 |
| 97 | |
| 98 | /*--------------------------------------------------------------------------- |
| 99 | Convert RSSI into overall score: Since RSSI is in -dBm values, and the |
| 100 | overall needs to be weighted inversely (where greater value means better |
| 101 | system), we convert. |
| 102 | RSSI *cannot* be more than 0xFF or less than 0 for meaningful WLAN operation |
| 103 | ---------------------------------------------------------------------------*/ |
| 104 | #define CSR_SCAN_MAX_SCORE_VAL 0xFF |
| 105 | #define CSR_SCAN_MIN_SCORE_VAL 0x0 |
| 106 | #define CSR_SCAN_HANDOFF_DELTA 10 |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 107 | #define MAX_ACTIVE_SCAN_FOR_ONE_CHANNEL 140 |
| 108 | #define MIN_ACTIVE_SCAN_FOR_ONE_CHANNEL 120 |
Madan Mohan Koyyalamudi | a53c4dc | 2012-11-13 10:35:42 -0800 | [diff] [blame] | 109 | #define CSR_SCAN_OVERALL_SCORE( rssi ) \ |
| 110 | (( rssi < CSR_SCAN_MAX_SCORE_VAL ) \ |
| 111 | ? (CSR_SCAN_MAX_SCORE_VAL-rssi) : CSR_SCAN_MIN_SCORE_VAL) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 112 | |
| 113 | |
| 114 | #define CSR_SCAN_IS_OVER_BSS_LIMIT(pMac) \ |
| 115 | ( (pMac)->scan.nBssLimit <= (csrLLCount(&(pMac)->scan.scanResultList)) ) |
| 116 | |
| 117 | //*** This is temporary work around. It need to call CCM api to get to CFG later |
| 118 | /// Get string parameter value |
| 119 | extern tSirRetStatus wlan_cfgGetStr(tpAniSirGlobal, tANI_U16, tANI_U8*, tANI_U32*); |
| 120 | |
| 121 | void csrScanGetResultTimerHandler(void *); |
| 122 | void csrScanResultAgingTimerHandler(void *pv); |
Sandeep Puligilla | 2b6dc63 | 2012-12-17 14:44:16 -0800 | [diff] [blame] | 123 | static void csrScanResultCfgAgingTimerHandler(void *pv); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 124 | void csrScanIdleScanTimerHandler(void *); |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 125 | static void csrSetDefaultScanTiming( tpAniSirGlobal pMac, tSirScanType scanType, tCsrScanRequest *pScanRequest); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 126 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 127 | static void csrStaApConcTimerHandler(void *); |
| 128 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 129 | tANI_BOOLEAN csrIsSupportedChannel(tpAniSirGlobal pMac, tANI_U8 channelId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 130 | eHalStatus csrScanChannels( tpAniSirGlobal pMac, tSmeCmd *pCommand ); |
| 131 | void csrSetCfgValidChannelList( tpAniSirGlobal pMac, tANI_U8 *pChannelList, tANI_U8 NumChannels ); |
| 132 | void csrSaveTxPowerToCfg( tpAniSirGlobal pMac, tDblLinkList *pList, tANI_U32 cfgId ); |
| 133 | void csrSetCfgCountryCode( tpAniSirGlobal pMac, tANI_U8 *countryCode ); |
| 134 | void csrPurgeChannelPower( tpAniSirGlobal pMac, tDblLinkList *pChannelList ); |
| 135 | //if bgPeriod is 0, background scan is disabled. It is in millisecond units |
| 136 | eHalStatus csrSetCfgBackgroundScanPeriod(tpAniSirGlobal pMac, tANI_U32 bgPeriod); |
| 137 | eHalStatus csrProcessSetBGScanParam(tpAniSirGlobal pMac, tSmeCmd *pCommand); |
| 138 | void csrReleaseScanCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand, eCsrScanStatus scanStatus); |
| 139 | static tANI_BOOLEAN csrScanValidateScanResult( tpAniSirGlobal pMac, tANI_U8 *pChannels, |
| 140 | tANI_U8 numChn, tSirBssDescription *pBssDesc, |
| 141 | tDot11fBeaconIEs **ppIes ); |
| 142 | eHalStatus csrSetBGScanChannelList( tpAniSirGlobal pMac, tANI_U8 *pAdjustChannels, tANI_U8 NumAdjustChannels); |
| 143 | void csrReleaseCmdSingle(tpAniSirGlobal pMac, tSmeCmd *pCommand); |
| 144 | tANI_BOOLEAN csrRoamIsValidChannel( tpAniSirGlobal pMac, tANI_U8 channel ); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 145 | void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 146 | |
Madan Mohan Koyyalamudi | 783b236 | 2012-10-21 11:54:41 -0700 | [diff] [blame] | 147 | #define CSR_IS_SOCIAL_CHANNEL(channel) (((channel) == 1) || ((channel) == 6) || ((channel) == 11) ) |
| 148 | |
Madan Mohan Koyyalamudi | 783b236 | 2012-10-21 11:54:41 -0700 | [diff] [blame] | 149 | |
Madan Mohan Koyyalamudi | 783b236 | 2012-10-21 11:54:41 -0700 | [diff] [blame] | 150 | |
Madan Mohan Koyyalamudi | 923c1e1 | 2012-11-30 17:53:27 -0800 | [diff] [blame] | 151 | static void csrReleaseScanCmdPendingList(tpAniSirGlobal pMac) |
| 152 | { |
| 153 | tListElem *pEntry; |
| 154 | tSmeCmd *pCommand; |
| 155 | |
| 156 | while((pEntry = csrLLRemoveHead( &pMac->scan.scanCmdPendingList, LL_ACCESS_LOCK)) != NULL) |
| 157 | { |
| 158 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 159 | if ( eSmeCsrCommandMask & pCommand->command ) |
| 160 | { |
| 161 | csrAbortCommand( pMac, pCommand, eANI_BOOLEAN_TRUE ); |
| 162 | } |
| 163 | else |
| 164 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 165 | smsLog(pMac, LOGE, FL("Error: Received command : %d"),pCommand->command); |
Madan Mohan Koyyalamudi | 923c1e1 | 2012-11-30 17:53:27 -0800 | [diff] [blame] | 166 | } |
| 167 | } |
| 168 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 169 | //pResult is invalid calling this function. |
| 170 | void csrFreeScanResultEntry( tpAniSirGlobal pMac, tCsrScanResult *pResult ) |
| 171 | { |
| 172 | if( NULL != pResult->Result.pvIes ) |
| 173 | { |
| 174 | palFreeMemory( pMac->hHdd, pResult->Result.pvIes ); |
| 175 | } |
| 176 | palFreeMemory(pMac->hHdd, pResult); |
| 177 | } |
| 178 | |
| 179 | |
| 180 | static eHalStatus csrLLScanPurgeResult(tpAniSirGlobal pMac, tDblLinkList *pList) |
| 181 | { |
| 182 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 183 | tListElem *pEntry; |
| 184 | tCsrScanResult *pBssDesc; |
| 185 | |
| 186 | csrLLLock(pList); |
| 187 | |
| 188 | while((pEntry = csrLLRemoveHead(pList, LL_ACCESS_NOLOCK)) != NULL) |
| 189 | { |
| 190 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 191 | csrFreeScanResultEntry( pMac, pBssDesc ); |
| 192 | } |
| 193 | |
| 194 | csrLLUnlock(pList); |
| 195 | |
| 196 | return (status); |
| 197 | } |
| 198 | |
| 199 | |
| 200 | int csrCheckValidateLists(void * dest, const void *src, v_SIZE_t num, int idx) |
| 201 | { |
| 202 | #ifdef CSR_VALIDATE_LIST |
| 203 | |
| 204 | int ii = 1; |
| 205 | |
| 206 | if( (NULL == g_pMac) || (!g_pMac->scan.fValidateList ) ) |
| 207 | { |
| 208 | return ii; |
| 209 | } |
| 210 | if(g_pchannelPowerInfoList24) |
| 211 | { |
| 212 | //check 2.4 list |
| 213 | tListElem *pElem, *pHead; |
| 214 | int count; |
| 215 | |
| 216 | count = (int)(g_pchannelPowerInfoList24->Count); |
| 217 | pHead = &g_pchannelPowerInfoList24->ListHead; |
| 218 | pElem = pHead->next; |
| 219 | if((tANI_U32)(pHead->next) > 0x00010000) //Assuming kernel address is not that low. |
| 220 | { |
| 221 | //this loop crashes if the pointer is not right |
| 222 | while(pElem->next != pHead) |
| 223 | { |
| 224 | if((tANI_U32)(pElem->next) > 0x00010000) |
| 225 | { |
| 226 | pElem = pElem->next; |
| 227 | VOS_ASSERT(count > 0); |
| 228 | count--; |
| 229 | } |
| 230 | else |
| 231 | { |
| 232 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL, |
| 233 | " %d Detect 1 list(0x%X) error Head(0x%X) next(0x%X) Count %d, dest(0x%X) src(0x%X) numBytes(%d)", |
| 234 | idx, (unsigned int)g_pchannelPowerInfoList24, (unsigned int)pHead, |
| 235 | (unsigned int)(pHead->next), (int)g_pchannelPowerInfoList24->Count, |
| 236 | (unsigned int)dest, (unsigned int)src, (int)num); |
| 237 | VOS_ASSERT(0); |
| 238 | ii = 0; |
| 239 | break; |
| 240 | } |
| 241 | } |
| 242 | } |
| 243 | else |
| 244 | { |
| 245 | //Bad list |
| 246 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL, " %d Detect list(0x%X) error Head(0x%X) next(0x%X) Count %d, dest(0x%X) src(0x%X) numBytes(%d)", |
| 247 | idx, (unsigned int)g_pchannelPowerInfoList24, (unsigned int)pHead, |
| 248 | (unsigned int)(pHead->next), (int)g_pchannelPowerInfoList24->Count, |
| 249 | (unsigned int)dest, (unsigned int)src, (int)num); |
| 250 | VOS_ASSERT(0); |
| 251 | ii = 0; |
| 252 | } |
| 253 | } |
| 254 | else |
| 255 | { |
| 256 | //list ok |
| 257 | ii = 1; |
| 258 | } |
| 259 | |
| 260 | |
| 261 | return ii; |
| 262 | |
| 263 | #else |
| 264 | return 1; |
| 265 | #endif //#ifdef CSR_VALIDATE_LIST |
| 266 | } |
| 267 | |
| 268 | |
| 269 | eHalStatus csrScanOpen( tpAniSirGlobal pMac ) |
| 270 | { |
| 271 | eHalStatus status; |
| 272 | |
| 273 | do |
| 274 | { |
| 275 | csrLLOpen(pMac->hHdd, &pMac->scan.scanResultList); |
| 276 | csrLLOpen(pMac->hHdd, &pMac->scan.tempScanResults); |
| 277 | csrLLOpen(pMac->hHdd, &pMac->scan.channelPowerInfoList24); |
| 278 | csrLLOpen(pMac->hHdd, &pMac->scan.channelPowerInfoList5G); |
| 279 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 280 | csrLLOpen(pMac->hHdd, &pMac->scan.scanCmdPendingList); |
| 281 | #endif |
| 282 | #ifdef CSR_VALIDATE_LIST |
| 283 | g_pchannelPowerInfoList5 = &pMac->scan.channelPowerInfoList5G; |
| 284 | g_pMac = pMac; |
| 285 | g_pchannelPowerInfoList24 = &pMac->scan.channelPowerInfoList24; |
| 286 | #endif |
| 287 | pMac->scan.fFullScanIssued = eANI_BOOLEAN_FALSE; |
| 288 | pMac->scan.nBssLimit = CSR_MAX_BSS_SUPPORT; |
| 289 | status = palTimerAlloc(pMac->hHdd, &pMac->scan.hTimerGetResult, csrScanGetResultTimerHandler, pMac); |
| 290 | if(!HAL_STATUS_SUCCESS(status)) |
| 291 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 292 | smsLog(pMac, LOGE, FL("cannot allocate memory for getResult timer")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 293 | break; |
| 294 | } |
| 295 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 296 | status = palTimerAlloc(pMac->hHdd, &pMac->scan.hTimerStaApConcTimer, csrStaApConcTimerHandler, pMac); |
| 297 | if(!HAL_STATUS_SUCCESS(status)) |
| 298 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 299 | smsLog(pMac, LOGE, FL("cannot allocate memory for hTimerStaApConcTimer timer")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 300 | break; |
| 301 | } |
| 302 | #endif |
| 303 | status = palTimerAlloc(pMac->hHdd, &pMac->scan.hTimerIdleScan, csrScanIdleScanTimerHandler, pMac); |
| 304 | if(!HAL_STATUS_SUCCESS(status)) |
| 305 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 306 | smsLog(pMac, LOGE, FL("cannot allocate memory for idleScan timer")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 307 | break; |
| 308 | } |
| 309 | status = palTimerAlloc(pMac->hHdd, &pMac->scan.hTimerResultAging, csrScanResultAgingTimerHandler, pMac); |
| 310 | if(!HAL_STATUS_SUCCESS(status)) |
| 311 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 312 | smsLog(pMac, LOGE, FL("cannot allocate memory for ResultAging timer")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 313 | break; |
| 314 | } |
Sandeep Puligilla | 2b6dc63 | 2012-12-17 14:44:16 -0800 | [diff] [blame] | 315 | status = palTimerAlloc(pMac->hHdd, &pMac->scan.hTimerResultCfgAging, |
| 316 | csrScanResultCfgAgingTimerHandler, pMac); |
| 317 | if(!HAL_STATUS_SUCCESS(status)) |
| 318 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 319 | smsLog(pMac, LOGE, FL("cannot allocate memory for CFG ResultAging timer")); |
Sandeep Puligilla | 2b6dc63 | 2012-12-17 14:44:16 -0800 | [diff] [blame] | 320 | break; |
| 321 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 322 | }while(0); |
| 323 | |
| 324 | return (status); |
| 325 | } |
| 326 | |
| 327 | |
| 328 | eHalStatus csrScanClose( tpAniSirGlobal pMac ) |
| 329 | { |
| 330 | #ifdef CSR_VALIDATE_LIST |
| 331 | g_pchannelPowerInfoList24 = NULL; |
| 332 | g_pchannelPowerInfoList5 = NULL; |
| 333 | g_pMac = NULL; |
| 334 | #endif |
| 335 | csrLLScanPurgeResult(pMac, &pMac->scan.tempScanResults); |
| 336 | csrLLScanPurgeResult(pMac, &pMac->scan.scanResultList); |
| 337 | #ifdef WLAN_AP_STA_CONCURRENCY |
Madan Mohan Koyyalamudi | 923c1e1 | 2012-11-30 17:53:27 -0800 | [diff] [blame] | 338 | csrReleaseScanCmdPendingList(pMac); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 339 | #endif |
| 340 | csrLLClose(&pMac->scan.scanResultList); |
| 341 | csrLLClose(&pMac->scan.tempScanResults); |
| 342 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 343 | csrLLClose(&pMac->scan.scanCmdPendingList); |
| 344 | #endif |
| 345 | csrPurgeChannelPower(pMac, &pMac->scan.channelPowerInfoList24); |
| 346 | csrPurgeChannelPower(pMac, &pMac->scan.channelPowerInfoList5G); |
| 347 | csrLLClose(&pMac->scan.channelPowerInfoList24); |
| 348 | csrLLClose(&pMac->scan.channelPowerInfoList5G); |
| 349 | csrScanDisable(pMac); |
| 350 | palTimerFree(pMac->hHdd, pMac->scan.hTimerResultAging); |
Sandeep Puligilla | 2b6dc63 | 2012-12-17 14:44:16 -0800 | [diff] [blame] | 351 | palTimerFree(pMac->hHdd, pMac->scan.hTimerResultCfgAging); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 352 | palTimerFree(pMac->hHdd, pMac->scan.hTimerGetResult); |
| 353 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 354 | palTimerFree(pMac->hHdd, pMac->scan.hTimerStaApConcTimer); |
| 355 | #endif |
| 356 | palTimerFree(pMac->hHdd, pMac->scan.hTimerIdleScan); |
| 357 | return eHAL_STATUS_SUCCESS; |
| 358 | } |
| 359 | |
| 360 | |
| 361 | eHalStatus csrScanEnable( tpAniSirGlobal pMac ) |
| 362 | { |
| 363 | |
| 364 | pMac->scan.fScanEnable = eANI_BOOLEAN_TRUE; |
| 365 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 366 | |
| 367 | return eHAL_STATUS_SUCCESS; |
| 368 | } |
| 369 | |
| 370 | |
| 371 | eHalStatus csrScanDisable( tpAniSirGlobal pMac ) |
| 372 | { |
| 373 | |
| 374 | csrScanStopTimers(pMac); |
| 375 | pMac->scan.fScanEnable = eANI_BOOLEAN_FALSE; |
| 376 | |
| 377 | return eHAL_STATUS_SUCCESS; |
| 378 | } |
| 379 | |
| 380 | |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 381 | //Set scan timing parameters according to state of other driver sessions |
| 382 | //No validation of the parameters is performed. |
| 383 | static void csrSetDefaultScanTiming( tpAniSirGlobal pMac, tSirScanType scanType, tCsrScanRequest *pScanRequest) |
| 384 | { |
| 385 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 386 | if(csrIsAnySessionConnected(pMac)) |
| 387 | { |
| 388 | //If multi-session, use the appropriate default scan times |
| 389 | if(scanType == eSIR_ACTIVE_SCAN) |
| 390 | { |
| 391 | pScanRequest->maxChnTime = pMac->roam.configParam.nActiveMaxChnTimeConc; |
| 392 | pScanRequest->minChnTime = pMac->roam.configParam.nActiveMinChnTimeConc; |
| 393 | } |
| 394 | else |
| 395 | { |
| 396 | pScanRequest->maxChnTime = pMac->roam.configParam.nPassiveMaxChnTimeConc; |
| 397 | pScanRequest->minChnTime = pMac->roam.configParam.nPassiveMinChnTimeConc; |
| 398 | } |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 399 | pScanRequest->maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc; |
| 400 | pScanRequest->minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc; |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 401 | |
| 402 | pScanRequest->restTime = pMac->roam.configParam.nRestTimeConc; |
| 403 | |
| 404 | //Return so that fields set above will not be overwritten. |
| 405 | return; |
| 406 | } |
| 407 | #endif |
| 408 | |
| 409 | //This portion of the code executed if multi-session not supported |
| 410 | //(WLAN_AP_STA_CONCURRENCY not defined) or no multi-session. |
| 411 | //Use the "regular" (non-concurrency) default scan timing. |
| 412 | if(pScanRequest->scanType == eSIR_ACTIVE_SCAN) |
| 413 | { |
| 414 | pScanRequest->maxChnTime = pMac->roam.configParam.nActiveMaxChnTime; |
| 415 | pScanRequest->minChnTime = pMac->roam.configParam.nActiveMinChnTime; |
| 416 | } |
| 417 | else |
| 418 | { |
| 419 | pScanRequest->maxChnTime = pMac->roam.configParam.nPassiveMaxChnTime; |
| 420 | pScanRequest->minChnTime = pMac->roam.configParam.nPassiveMinChnTime; |
| 421 | } |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 422 | pScanRequest->maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc; |
| 423 | pScanRequest->minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc; |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 424 | |
| 425 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 426 | //No rest time if no sessions are connected. |
| 427 | pScanRequest->restTime = 0; |
| 428 | #endif |
| 429 | } |
| 430 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 431 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 432 | //Return SUCCESS is the command is queued, else returns eHAL_STATUS_FAILURE |
| 433 | eHalStatus csrQueueScanRequest( tpAniSirGlobal pMac, tSmeCmd *pScanCmd ) |
| 434 | { |
| 435 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 436 | |
| 437 | tANI_BOOLEAN fNoCmdPending; |
| 438 | tSmeCmd *pQueueScanCmd=NULL; |
| 439 | tSmeCmd *pSendScanCmd=NULL; |
| 440 | |
Madan Mohan Koyyalamudi | 48081ef | 2012-12-04 16:49:55 -0800 | [diff] [blame] | 441 | /* split scan if any one of the following: |
| 442 | * - STA session is connected and the scan is not a P2P search |
| 443 | * - any P2P session is connected |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 444 | * Do not split scans if no concurrent infra connections are |
| 445 | * active and if the scan is a BG scan triggered by LFR (OR) |
| 446 | * any scan if LFR is in the middle of a BG scan. Splitting |
| 447 | * the scan is delaying the time it takes for LFR to find |
| 448 | * candidates and resulting in disconnects. |
Madan Mohan Koyyalamudi | 48081ef | 2012-12-04 16:49:55 -0800 | [diff] [blame] | 449 | */ |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 450 | if ( (csrIsStaSessionConnected(pMac) && |
| 451 | #ifdef FEATURE_WLAN_LFR |
| 452 | (csrIsConcurrentInfraConnected(pMac) || |
| 453 | ((pScanCmd->u.scanCmd.reason != eCsrScanBgScan) && |
| 454 | (pMac->roam.neighborRoamInfo.neighborRoamState != |
| 455 | eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN))) && |
| 456 | #endif |
| 457 | (pScanCmd->u.scanCmd.u.scanRequest.p2pSearch != 1)) || |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 458 | (csrIsP2pSessionConnected(pMac)) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 459 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 460 | tCsrScanRequest scanReq; |
| 461 | tANI_U8 numChn = pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels; |
| 462 | tCsrChannelInfo *pChnInfo = &scanReq.ChannelInfo; |
| 463 | tANI_U8 channelToScan[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 464 | tANI_BOOLEAN bMemAlloc = eANI_BOOLEAN_FALSE; |
| 465 | |
| 466 | if (numChn == 0) |
| 467 | { |
| 468 | |
| 469 | numChn = pMac->scan.baseChannels.numChannels; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 470 | |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 471 | status = palAllocateMemory( pMac->hHdd, (void **)&pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList, numChn ); |
| 472 | if( !HAL_STATUS_SUCCESS( status ) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 473 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 474 | smsLog( pMac, LOGE, FL(" Failed to get memory for channel list ") ); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 475 | return eHAL_STATUS_FAILURE; |
| 476 | } |
| 477 | bMemAlloc = eANI_BOOLEAN_TRUE; |
| 478 | status = palCopyMemory( pMac->hHdd, pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList, |
| 479 | pMac->scan.baseChannels.channelList, numChn ); |
| 480 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 481 | { |
| 482 | palFreeMemory( pMac->hHdd, pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList ); |
| 483 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = NULL; |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 484 | smsLog( pMac, LOGE, FL(" Failed to copy memory to channel list ") ); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 485 | return eHAL_STATUS_FAILURE; |
| 486 | } |
| 487 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = numChn; |
| 488 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 489 | |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 490 | //Whenever we get a scan request with multiple channels we break it up into 2 requests |
| 491 | //First request for first channel to scan and second request to scan remaining channels |
| 492 | if (numChn > pMac->roam.configParam.nNumChanCombinedConc) |
| 493 | { |
| 494 | palZeroMemory(pMac->hHdd, &scanReq, sizeof(tCsrScanRequest)); |
| 495 | |
| 496 | pQueueScanCmd = csrGetCommandBuffer(pMac); //optimize this to use 2 command buffer only |
| 497 | if (!pQueueScanCmd) |
| 498 | { |
| 499 | if (bMemAlloc) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 500 | { |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 501 | palFreeMemory( pMac->hHdd, pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList ); |
| 502 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = NULL; |
| 503 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 504 | } |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 505 | smsLog( pMac, LOGE, FL(" Failed to get Queue command buffer") ); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 506 | return eHAL_STATUS_FAILURE; |
| 507 | } |
| 508 | pQueueScanCmd->command = pScanCmd->command; |
| 509 | pQueueScanCmd->sessionId = pScanCmd->sessionId; |
| 510 | pQueueScanCmd->u.scanCmd.callback = pScanCmd->u.scanCmd.callback; |
| 511 | pQueueScanCmd->u.scanCmd.pContext = pScanCmd->u.scanCmd.pContext; |
| 512 | pQueueScanCmd->u.scanCmd.reason = pScanCmd->u.scanCmd.reason; |
| 513 | pQueueScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 514 | |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 515 | /* First copy all the parameters to local variable of scan request */ |
| 516 | csrScanCopyRequest(pMac, &scanReq, &pScanCmd->u.scanCmd.u.scanRequest); |
Madan Mohan Koyyalamudi | af2a8b9 | 2012-10-09 14:58:07 -0700 | [diff] [blame] | 517 | |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 518 | /* Now modify the elements of local var scan request required to be modified for split scan */ |
| 519 | if(scanReq.ChannelInfo.ChannelList != NULL) |
| 520 | { |
| 521 | palFreeMemory(pMac->hHdd, scanReq.ChannelInfo.ChannelList); |
Madan Mohan Koyyalamudi | 0c626f3 | 2012-11-30 15:10:25 -0800 | [diff] [blame] | 522 | scanReq.ChannelInfo.ChannelList = NULL; |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 523 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 524 | |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 525 | pChnInfo->numOfChannels = pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels - pMac->roam.configParam.nNumChanCombinedConc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 526 | |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 527 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN, |
| 528 | FL(" &channelToScan %0x pScanCmd(0x%X) pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList(0x%X)numChn(%d)"), |
| 529 | &channelToScan[0], (unsigned int)pScanCmd, |
| 530 | (unsigned int)pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList, numChn); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 531 | |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 532 | palCopyMemory(pMac->hHdd, &channelToScan[0], &pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[pMac->roam.configParam.nNumChanCombinedConc], |
| 533 | pChnInfo->numOfChannels * sizeof(tANI_U8)); |
| 534 | |
| 535 | pChnInfo->ChannelList = &channelToScan[0]; |
| 536 | |
| 537 | scanReq.BSSType = eCSR_BSS_TYPE_ANY; |
| 538 | //Modify callers parameters in case of concurrency |
| 539 | scanReq.scanType = eSIR_ACTIVE_SCAN; |
| 540 | //Use concurrency values for min/maxChnTime. |
| 541 | //We know csrIsAnySessionConnected(pMac) returns TRUE here |
| 542 | csrSetDefaultScanTiming(pMac, scanReq.scanType, &scanReq); |
| 543 | |
| 544 | status = csrScanCopyRequest(pMac, &pQueueScanCmd->u.scanCmd.u.scanRequest, &scanReq); |
| 545 | |
| 546 | if(!HAL_STATUS_SUCCESS(status)) |
| 547 | { |
| 548 | if (bMemAlloc) |
| 549 | { |
| 550 | palFreeMemory( pMac->hHdd, pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList ); |
| 551 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = NULL; |
| 552 | |
| 553 | } |
| 554 | if( scanReq.pIEField != NULL) |
| 555 | { |
| 556 | palFreeMemory(pMac->hHdd, scanReq.pIEField); |
| 557 | scanReq.pIEField = NULL; |
| 558 | } |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 559 | smsLog( pMac, LOGE, FL(" Failed to get copy csrScanRequest = %d"), status ); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 560 | return eHAL_STATUS_FAILURE; |
| 561 | } |
| 562 | /* Clean the local scan variable */ |
| 563 | scanReq.ChannelInfo.ChannelList = NULL; |
| 564 | scanReq.ChannelInfo.numOfChannels = 0; |
| 565 | csrScanFreeRequest(pMac, &scanReq); |
| 566 | |
| 567 | /* setup the command to scan 2 channels */ |
| 568 | pSendScanCmd = pScanCmd; |
| 569 | pSendScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = pMac->roam.configParam.nNumChanCombinedConc; |
| 570 | pSendScanCmd->u.scanCmd.u.scanRequest.BSSType = eCSR_BSS_TYPE_ANY; |
| 571 | pSendScanCmd->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 572 | //Use concurrency values for min/maxChnTime. |
| 573 | //We know csrIsAnySessionConnected(pMac) returns TRUE here |
| 574 | csrSetDefaultScanTiming(pMac, pSendScanCmd->u.scanCmd.u.scanRequest.scanType, &pSendScanCmd->u.scanCmd.u.scanRequest); |
| 575 | pSendScanCmd->u.scanCmd.callback = NULL; |
| 576 | } else { |
| 577 | pSendScanCmd = pScanCmd; |
| 578 | pSendScanCmd->u.scanCmd.u.scanRequest.BSSType = eCSR_BSS_TYPE_ANY; |
| 579 | pSendScanCmd->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 580 | //Use concurrency values for min/maxChnTime. |
| 581 | //We know csrIsAnySessionConnected(pMac) returns TRUE here |
| 582 | csrSetDefaultScanTiming(pMac, pSendScanCmd->u.scanCmd.u.scanRequest.scanType, &pSendScanCmd->u.scanCmd.u.scanRequest); |
| 583 | } |
| 584 | |
| 585 | fNoCmdPending = csrLLIsListEmpty( &pMac->scan.scanCmdPendingList, LL_ACCESS_LOCK ); |
| 586 | |
| 587 | //Logic Below is as follows |
| 588 | // If the scanCmdPendingList is empty then we directly send that command |
| 589 | // to smeCommandQueue else we buffer it in our scanCmdPendingList Queue |
| 590 | if( fNoCmdPending ) |
| 591 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 592 | if (pQueueScanCmd != NULL) |
| 593 | { |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 594 | csrLLInsertTail( &pMac->scan.scanCmdPendingList, &pQueueScanCmd->Link, LL_ACCESS_LOCK ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 595 | } |
| 596 | |
| 597 | if (pSendScanCmd != NULL) |
| 598 | { |
| 599 | return csrQueueSmeCommand(pMac, pSendScanCmd, eANI_BOOLEAN_FALSE); |
| 600 | } |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 601 | } |
| 602 | else |
| 603 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 604 | if (pSendScanCmd != NULL) |
| 605 | { |
| 606 | csrLLInsertTail( &pMac->scan.scanCmdPendingList, &pSendScanCmd->Link, LL_ACCESS_LOCK ); |
| 607 | } |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 608 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 609 | if (pQueueScanCmd != NULL) |
| 610 | { |
| 611 | csrLLInsertTail( &pMac->scan.scanCmdPendingList, &pQueueScanCmd->Link, LL_ACCESS_LOCK ); |
| 612 | } |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 613 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 614 | } |
| 615 | else |
| 616 | { //No concurrency case |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 617 | smsLog( pMac, LOG2, FL("Queuing scan command (reason=%d, roamState=%d" |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 618 | " numOfChannels=%d)"), |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 619 | pScanCmd->u.scanCmd.reason, |
| 620 | pMac->roam.neighborRoamInfo.neighborRoamState, |
| 621 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 622 | return csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_FALSE); |
| 623 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 624 | |
| 625 | return ( status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 626 | } |
| 627 | #endif |
| 628 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 629 | /* --------------------------------------------------------------------------- |
| 630 | \fn csrScan2GOnyRequest |
| 631 | \brief This function will update the scan request with only |
Jeff Johnson | b88db98 | 2012-12-10 13:34:59 -0800 | [diff] [blame] | 632 | 2.4GHz valid channel list. |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 633 | \param pMac |
| 634 | \param pScanCmd |
| 635 | \param pScanRequest |
| 636 | \return None |
| 637 | -------------------------------------------------------------------------------*/ |
| 638 | static void csrScan2GOnyRequest(tpAniSirGlobal pMac,tSmeCmd *pScanCmd, |
| 639 | tCsrScanRequest *pScanRequest) |
| 640 | { |
| 641 | tANI_U8 index, channelId, channelListSize = 0; |
| 642 | tANI_U8 channelList2G[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}; |
| 643 | static tANI_U8 validchannelList[CSR_MAX_2_4_GHZ_SUPPORTED_CHANNELS] = {0}; |
| 644 | |
| 645 | VOS_ASSERT(pScanCmd && pScanRequest); |
Madan Mohan Koyyalamudi | 33ef6a2 | 2012-10-30 17:44:43 -0700 | [diff] [blame] | 646 | /* To silence the KW tool null check is added */ |
| 647 | if((pScanCmd == NULL) || (pScanRequest == NULL)) |
| 648 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 649 | smsLog( pMac, LOGE, FL(" pScanCmd or pScanRequest is NULL ")); |
Madan Mohan Koyyalamudi | 33ef6a2 | 2012-10-30 17:44:43 -0700 | [diff] [blame] | 650 | return; |
| 651 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 652 | |
| 653 | if (pScanCmd->u.scanCmd.scanID || |
| 654 | (eCSR_SCAN_REQUEST_FULL_SCAN != pScanRequest->requestType)) |
| 655 | return; |
| 656 | |
| 657 | //Contsruct valid Supported 2.4 GHz Channel List |
| 658 | for( index = 0; index < ARRAY_SIZE(channelList2G); index++ ) |
| 659 | { |
| 660 | channelId = channelList2G[index]; |
| 661 | if ( csrIsSupportedChannel( pMac, channelId ) ) |
| 662 | { |
| 663 | validchannelList[channelListSize++] = channelId; |
| 664 | } |
| 665 | } |
| 666 | |
| 667 | pScanRequest->ChannelInfo.numOfChannels = channelListSize; |
| 668 | pScanRequest->ChannelInfo.ChannelList = validchannelList; |
| 669 | } |
| 670 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 671 | eHalStatus csrScanRequest(tpAniSirGlobal pMac, tANI_U16 sessionId, |
| 672 | tCsrScanRequest *pScanRequest, tANI_U32 *pScanRequestID, |
| 673 | csrScanCompleteCallback callback, void *pContext) |
| 674 | { |
| 675 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 676 | tSmeCmd *pScanCmd = NULL; |
Madan Mohan Koyyalamudi | cb90bb2 | 2012-10-30 18:24:43 -0700 | [diff] [blame] | 677 | eCsrConnectState ConnectState; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 678 | |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 679 | if(pScanRequest == NULL) |
| 680 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 681 | smsLog( pMac, LOGE, FL(" pScanRequest is NULL")); |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 682 | VOS_ASSERT(0); |
| 683 | } |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 684 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 685 | do |
| 686 | { |
| 687 | if(pMac->scan.fScanEnable) |
| 688 | { |
| 689 | pScanCmd = csrGetCommandBuffer(pMac); |
| 690 | if(pScanCmd) |
| 691 | { |
| 692 | palZeroMemory(pMac->hHdd, &pScanCmd->u.scanCmd, sizeof(tScanCmd)); |
| 693 | pScanCmd->command = eSmeCommandScan; |
| 694 | pScanCmd->sessionId = sessionId; |
| 695 | pScanCmd->u.scanCmd.callback = callback; |
| 696 | pScanCmd->u.scanCmd.pContext = pContext; |
| 697 | if(eCSR_SCAN_REQUEST_11D_SCAN == pScanRequest->requestType) |
| 698 | { |
| 699 | pScanCmd->u.scanCmd.reason = eCsrScan11d1; |
| 700 | } |
| 701 | else if((eCSR_SCAN_REQUEST_FULL_SCAN == pScanRequest->requestType) || |
| 702 | (eCSR_SCAN_P2P_DISCOVERY == pScanRequest->requestType) |
| 703 | #ifdef SOFTAP_CHANNEL_RANGE |
| 704 | ||(eCSR_SCAN_SOFTAP_CHANNEL_RANGE == pScanRequest->requestType) |
| 705 | #endif |
| 706 | ) |
| 707 | { |
| 708 | pScanCmd->u.scanCmd.reason = eCsrScanUserRequest; |
| 709 | } |
| 710 | else if(eCSR_SCAN_HO_BG_SCAN == pScanRequest->requestType) |
| 711 | { |
| 712 | pScanCmd->u.scanCmd.reason = eCsrScanBgScan; |
| 713 | } |
| 714 | else if(eCSR_SCAN_HO_PROBE_SCAN == pScanRequest->requestType) |
| 715 | { |
| 716 | pScanCmd->u.scanCmd.reason = eCsrScanProbeBss; |
| 717 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 718 | else if(eCSR_SCAN_P2P_FIND_PEER == pScanRequest->requestType) |
| 719 | { |
| 720 | pScanCmd->u.scanCmd.reason = eCsrScanP2PFindPeer; |
| 721 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 722 | else |
| 723 | { |
| 724 | pScanCmd->u.scanCmd.reason = eCsrScanIdleScan; |
| 725 | } |
| 726 | if(pScanRequest->minChnTime == 0 && pScanRequest->maxChnTime == 0) |
| 727 | { |
| 728 | //The caller doesn't set the time correctly. Set it here |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 729 | csrSetDefaultScanTiming(pMac, pScanRequest->scanType, pScanRequest); |
| 730 | } |
| 731 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 732 | if(pScanRequest->restTime == 0) |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 733 | { |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 734 | //Need to set restTime only if at least one session is connected |
| 735 | if(csrIsAnySessionConnected(pMac)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 736 | { |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 737 | pScanRequest->restTime = pMac->roam.configParam.nRestTimeConc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 738 | } |
| 739 | } |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 740 | #endif |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 741 | /*For Standalone wlan : channel time will remain the same. |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 742 | For BTC with A2DP up: Channel time = Channel time * 2 , if station is not already associated. |
| 743 | This has been done to provide a larger scan window for faster connection during btc.Else Scan is seen |
| 744 | to take a long time. |
| 745 | For BTC with A2DP up: Channel time will not be doubled, if station is already associated. |
| 746 | */ |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 747 | status = csrRoamGetConnectState(pMac,sessionId,&ConnectState); |
Srinivas Girigowda | c84c57c | 2013-02-19 17:41:56 -0800 | [diff] [blame] | 748 | if (HAL_STATUS_SUCCESS(status) && |
| 749 | pMac->btc.fA2DPUp && |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 750 | (eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED != ConnectState) && |
| 751 | (eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED != ConnectState)) |
| 752 | { |
| 753 | pScanRequest->maxChnTime = pScanRequest->maxChnTime << 1; |
| 754 | pScanRequest->minChnTime = pScanRequest->minChnTime << 1; |
| 755 | } |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 756 | |
| 757 | pScanRequest->maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc; |
| 758 | pScanRequest->minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 759 | //Need to make the following atomic |
| 760 | pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around |
| 761 | |
| 762 | if(pScanRequestID) |
| 763 | { |
| 764 | *pScanRequestID = pScanCmd->u.scanCmd.scanID; |
| 765 | } |
| 766 | |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 767 | // 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] | 768 | // If it is not, CSR will save the scan request in the pending cmd queue |
| 769 | // & issue an 11d scan request to PE. |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 770 | if (((0 == pScanCmd->u.scanCmd.scanID) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 771 | && (eCSR_SCAN_REQUEST_11D_SCAN != pScanRequest->requestType)) |
| 772 | #ifdef SOFTAP_CHANNEL_RANGE |
| 773 | && (eCSR_SCAN_SOFTAP_CHANNEL_RANGE != pScanRequest->requestType) |
| 774 | #endif |
| 775 | && (eANI_BOOLEAN_FALSE == pMac->scan.fEnableBypass11d) |
| 776 | ) |
| 777 | { |
| 778 | tSmeCmd *p11dScanCmd; |
| 779 | tCsrScanRequest scanReq; |
| 780 | tCsrChannelInfo *pChnInfo = &scanReq.ChannelInfo; |
| 781 | |
| 782 | palZeroMemory(pMac->hHdd, &scanReq, sizeof(tCsrScanRequest)); |
| 783 | |
| 784 | p11dScanCmd = csrGetCommandBuffer(pMac); |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 785 | if (p11dScanCmd) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 786 | { |
| 787 | tANI_U32 numChn = pMac->scan.baseChannels.numChannels; |
| 788 | |
| 789 | palZeroMemory(pMac->hHdd, &p11dScanCmd->u.scanCmd, sizeof(tScanCmd)); |
| 790 | status = palAllocateMemory( pMac->hHdd, (void **)&pChnInfo->ChannelList, numChn ); |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 791 | if ( !HAL_STATUS_SUCCESS( status ) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 792 | { |
| 793 | break; |
| 794 | } |
| 795 | status = palCopyMemory( pMac->hHdd, pChnInfo->ChannelList, |
| 796 | pMac->scan.baseChannels.channelList, numChn ); |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 797 | if ( !HAL_STATUS_SUCCESS( status ) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 798 | { |
| 799 | palFreeMemory( pMac->hHdd, pChnInfo->ChannelList ); |
| 800 | pChnInfo->ChannelList = NULL; |
| 801 | break; |
| 802 | } |
| 803 | pChnInfo->numOfChannels = (tANI_U8)numChn; |
| 804 | p11dScanCmd->command = eSmeCommandScan; |
| 805 | p11dScanCmd->u.scanCmd.callback = NULL; |
| 806 | p11dScanCmd->u.scanCmd.pContext = NULL; |
| 807 | p11dScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; |
| 808 | scanReq.BSSType = eCSR_BSS_TYPE_ANY; |
| 809 | |
| 810 | if ( csrIs11dSupported(pMac) ) |
| 811 | { |
| 812 | scanReq.scanType = eSIR_PASSIVE_SCAN; |
| 813 | scanReq.requestType = eCSR_SCAN_REQUEST_11D_SCAN; |
| 814 | p11dScanCmd->u.scanCmd.reason = eCsrScan11d1; |
| 815 | scanReq.maxChnTime = pMac->roam.configParam.nPassiveMaxChnTime; |
| 816 | scanReq.minChnTime = pMac->roam.configParam.nPassiveMinChnTime; |
| 817 | } |
| 818 | else |
| 819 | { |
| 820 | scanReq.scanType = eSIR_ACTIVE_SCAN; |
| 821 | scanReq.requestType = eCSR_SCAN_IDLE_MODE_SCAN; |
| 822 | p11dScanCmd->u.scanCmd.reason = eCsrScanIdleScan; |
| 823 | scanReq.maxChnTime = pMac->roam.configParam.nActiveMaxChnTime; |
| 824 | scanReq.minChnTime = pMac->roam.configParam.nActiveMinChnTime; |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 825 | |
| 826 | scanReq.maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc; |
| 827 | scanReq.minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 828 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 829 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 830 | status = csrScanCopyRequest(pMac, &p11dScanCmd->u.scanCmd.u.scanRequest, &scanReq); |
| 831 | //Free the channel list |
| 832 | palFreeMemory( pMac->hHdd, pChnInfo->ChannelList ); |
| 833 | |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 834 | if (HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 835 | { |
| 836 | //Start process the command |
| 837 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 838 | status = csrQueueScanRequest(pMac, p11dScanCmd); |
| 839 | #else |
| 840 | status = csrQueueSmeCommand(pMac, p11dScanCmd, eANI_BOOLEAN_FALSE); |
| 841 | #endif |
| 842 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 843 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 844 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 845 | break; |
| 846 | } |
| 847 | } |
| 848 | else |
| 849 | { |
| 850 | break; |
| 851 | } |
| 852 | } |
| 853 | else |
| 854 | { |
| 855 | //error |
| 856 | break; |
| 857 | } |
| 858 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 859 | |
| 860 | //Scan only 2G Channels if set in ini file |
| 861 | //This is mainly to reduce the First Scan duration |
| 862 | //Once we turn on Wifi |
| 863 | if(pMac->scan.fFirstScanOnly2GChnl) |
| 864 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 865 | smsLog( pMac, LOG1, FL("Scanning only 2G Channels during first scan")); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 866 | csrScan2GOnyRequest(pMac, pScanCmd, pScanRequest); |
| 867 | } |
| 868 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 869 | status = csrScanCopyRequest(pMac, &pScanCmd->u.scanCmd.u.scanRequest, pScanRequest); |
| 870 | if(HAL_STATUS_SUCCESS(status)) |
| 871 | { |
| 872 | //Start process the command |
| 873 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 874 | status = csrQueueScanRequest(pMac,pScanCmd); |
| 875 | #else |
| 876 | status = csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_FALSE); |
| 877 | #endif |
| 878 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 879 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 880 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 881 | break; |
| 882 | } |
| 883 | } |
| 884 | else |
| 885 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 886 | smsLog( pMac, LOGE, FL(" fail to copy request status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 887 | break; |
| 888 | } |
| 889 | } |
| 890 | else |
| 891 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 892 | smsLog( pMac, LOGE, FL(" pScanCmd is NULL")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 893 | break; |
| 894 | } |
| 895 | } |
| 896 | } while(0); |
| 897 | if(!HAL_STATUS_SUCCESS(status) && pScanCmd) |
| 898 | { |
| 899 | if( eCsrScanIdleScan == pScanCmd->u.scanCmd.reason ) |
| 900 | { |
| 901 | //Set the flag back for restarting idle scan |
| 902 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 903 | } |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 904 | smsLog( pMac, LOGE, FL(" failed with status = %d, releasing scan cmd"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 905 | csrReleaseCommandScan(pMac, pScanCmd); |
| 906 | } |
| 907 | |
| 908 | return (status); |
| 909 | } |
| 910 | |
| 911 | |
| 912 | eHalStatus csrScanRequestResult(tpAniSirGlobal pMac) |
| 913 | { |
| 914 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 915 | tSmeCmd *pScanCmd; |
| 916 | |
| 917 | if(pMac->scan.fScanEnable) |
| 918 | { |
| 919 | pScanCmd = csrGetCommandBuffer(pMac); |
| 920 | if(pScanCmd) |
| 921 | { |
| 922 | pScanCmd->command = eSmeCommandScan; |
| 923 | palZeroMemory(pMac->hHdd, &pScanCmd->u.scanCmd, sizeof(tScanCmd)); |
| 924 | pScanCmd->u.scanCmd.callback = NULL; |
| 925 | pScanCmd->u.scanCmd.pContext = NULL; |
| 926 | pScanCmd->u.scanCmd.reason = eCsrScanGetResult; |
| 927 | //Need to make the following atomic |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 928 | pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID; //let it wrap around |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 929 | status = csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_FALSE); |
| 930 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 931 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 932 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 933 | csrReleaseCommandScan(pMac, pScanCmd); |
| 934 | } |
| 935 | } |
| 936 | else |
| 937 | { |
| 938 | //log error |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 939 | smsLog(pMac, LOGE, FL("can not obtain a common buffer")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 940 | status = eHAL_STATUS_RESOURCES; |
| 941 | } |
| 942 | } |
| 943 | |
| 944 | return (status); |
| 945 | } |
| 946 | |
| 947 | |
| 948 | eHalStatus csrScanAllChannels(tpAniSirGlobal pMac, eCsrRequestType reqType) |
| 949 | { |
| 950 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 951 | tANI_U32 scanId; |
| 952 | tCsrScanRequest scanReq; |
| 953 | |
| 954 | palZeroMemory(pMac->hHdd, &scanReq, sizeof(tCsrScanRequest)); |
| 955 | scanReq.BSSType = eCSR_BSS_TYPE_ANY; |
| 956 | scanReq.scanType = eSIR_ACTIVE_SCAN; |
| 957 | scanReq.requestType = reqType; |
| 958 | scanReq.maxChnTime = pMac->roam.configParam.nActiveMaxChnTime; |
| 959 | scanReq.minChnTime = pMac->roam.configParam.nActiveMinChnTime; |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 960 | scanReq.maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc; |
| 961 | scanReq.minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 962 | //Scan with invalid sessionId. |
| 963 | //This results in SME using the first available session to scan. |
| 964 | status = csrScanRequest(pMac, CSR_SESSION_ID_INVALID, &scanReq, |
| 965 | &scanId, NULL, NULL); |
| 966 | |
| 967 | return (status); |
| 968 | } |
| 969 | |
| 970 | |
| 971 | |
| 972 | |
| 973 | eHalStatus csrIssueRoamAfterLostlinkScan(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamReason reason) |
| 974 | { |
| 975 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 976 | tScanResultHandle hBSSList = NULL; |
| 977 | tCsrScanResultFilter *pScanFilter = NULL; |
| 978 | tANI_U32 roamId = 0; |
| 979 | tCsrRoamProfile *pProfile = NULL; |
| 980 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 981 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 982 | if(!pSession) |
| 983 | { |
| 984 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 985 | return eHAL_STATUS_FAILURE; |
| 986 | } |
| 987 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 988 | do |
| 989 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 990 | smsLog(pMac, LOG1, " csrIssueRoamAfterLostlinkScan called"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 991 | if(pSession->fCancelRoaming) |
| 992 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 993 | smsLog(pMac, LOGW, " lostlink roaming is cancelled"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 994 | csrScanStartIdleScan(pMac); |
| 995 | status = eHAL_STATUS_SUCCESS; |
| 996 | break; |
| 997 | } |
| 998 | //Here is the profile we need to connect to |
| 999 | status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter)); |
| 1000 | if(!HAL_STATUS_SUCCESS(status)) |
| 1001 | break; |
| 1002 | palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter)); |
| 1003 | if(NULL == pSession->pCurRoamProfile) |
| 1004 | { |
| 1005 | pScanFilter->EncryptionType.numEntries = 1; |
| 1006 | pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE; |
| 1007 | } |
| 1008 | else |
| 1009 | { |
| 1010 | //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect |
| 1011 | status = palAllocateMemory(pMac->hHdd, (void **)&pProfile, sizeof(tCsrRoamProfile)); |
| 1012 | if(!HAL_STATUS_SUCCESS(status)) |
| 1013 | break; |
| 1014 | palZeroMemory(pMac->hHdd, pProfile, sizeof(tCsrRoamProfile)); |
| 1015 | status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile); |
| 1016 | if(!HAL_STATUS_SUCCESS(status)) |
| 1017 | break; |
| 1018 | status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter); |
| 1019 | }//We have a profile |
| 1020 | roamId = GET_NEXT_ROAM_ID(&pMac->roam); |
| 1021 | if(HAL_STATUS_SUCCESS(status)) |
| 1022 | { |
| 1023 | status = csrScanGetResult(pMac, pScanFilter, &hBSSList); |
| 1024 | if(HAL_STATUS_SUCCESS(status)) |
| 1025 | { |
| 1026 | if(eCsrLostLink1 == reason) |
| 1027 | { |
| 1028 | //we want to put the last connected BSS to the very beginning, if possible |
| 1029 | csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList); |
| 1030 | } |
| 1031 | status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, reason, |
| 1032 | roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE); |
| 1033 | if(!HAL_STATUS_SUCCESS(status)) |
| 1034 | { |
| 1035 | csrScanResultPurge(pMac, hBSSList); |
| 1036 | } |
| 1037 | }//Have scan result |
| 1038 | } |
| 1039 | }while(0); |
| 1040 | if(pScanFilter) |
| 1041 | { |
| 1042 | //we need to free memory for filter if profile exists |
| 1043 | csrFreeScanFilter(pMac, pScanFilter); |
| 1044 | palFreeMemory(pMac->hHdd, pScanFilter); |
| 1045 | } |
| 1046 | if(NULL != pProfile) |
| 1047 | { |
| 1048 | csrReleaseProfile(pMac, pProfile); |
| 1049 | palFreeMemory(pMac->hHdd, (void *)pProfile); |
| 1050 | } |
| 1051 | |
| 1052 | return (status); |
| 1053 | } |
| 1054 | |
| 1055 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1056 | eHalStatus csrScanGetScanChnInfo(tpAniSirGlobal pMac, void *callback, void *pContext) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1057 | { |
| 1058 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1059 | tSmeCmd *pScanCmd; |
| 1060 | |
| 1061 | if(pMac->scan.fScanEnable) |
| 1062 | { |
| 1063 | pScanCmd = csrGetCommandBuffer(pMac); |
| 1064 | if(pScanCmd) |
| 1065 | { |
| 1066 | pScanCmd->command = eSmeCommandScan; |
| 1067 | palZeroMemory(pMac->hHdd, &pScanCmd->u.scanCmd, sizeof(tScanCmd)); |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1068 | pScanCmd->u.scanCmd.callback = callback; |
| 1069 | pScanCmd->u.scanCmd.pContext = pContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1070 | pScanCmd->u.scanCmd.reason = eCsrScanGetScanChnInfo; |
| 1071 | //Need to make the following atomic |
| 1072 | pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around |
| 1073 | status = csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_FALSE); |
| 1074 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 1075 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 1076 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1077 | csrReleaseCommandScan(pMac, pScanCmd); |
| 1078 | } |
| 1079 | } |
| 1080 | else |
| 1081 | { |
| 1082 | //log error |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 1083 | smsLog(pMac, LOGE, FL("can not obtain a common buffer")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1084 | status = eHAL_STATUS_RESOURCES; |
| 1085 | } |
| 1086 | } |
| 1087 | |
| 1088 | return (status); |
| 1089 | } |
| 1090 | |
| 1091 | |
| 1092 | eHalStatus csrScanHandleFailedLostlink1(tpAniSirGlobal pMac, tANI_U32 sessionId) |
| 1093 | { |
| 1094 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 1095 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 1096 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1097 | if(!pSession) |
| 1098 | { |
| 1099 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 1100 | return eHAL_STATUS_FAILURE; |
| 1101 | } |
| 1102 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 1103 | smsLog(pMac, LOGW, " Lostlink scan 1 failed"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1104 | if(pSession->fCancelRoaming) |
| 1105 | { |
| 1106 | csrScanStartIdleScan(pMac); |
| 1107 | } |
| 1108 | else if(pSession->pCurRoamProfile) |
| 1109 | { |
| 1110 | //We fail lostlink1 but there may be other BSS in the cached result fit the profile. Give it a try first |
| 1111 | if(pSession->pCurRoamProfile->SSIDs.numOfSSIDs == 0 || |
| 1112 | pSession->pCurRoamProfile->SSIDs.numOfSSIDs > 1) |
| 1113 | { |
| 1114 | //try lostlink scan2 |
| 1115 | status = csrScanRequestLostLink2(pMac, sessionId); |
| 1116 | } |
| 1117 | else if(!pSession->pCurRoamProfile->ChannelInfo.ChannelList || |
| 1118 | pSession->pCurRoamProfile->ChannelInfo.ChannelList[0] == 0) |
| 1119 | { |
| 1120 | //go straight to lostlink scan3 |
| 1121 | status = csrScanRequestLostLink3(pMac, sessionId); |
| 1122 | } |
| 1123 | else |
| 1124 | { |
| 1125 | //we are done with lostlink |
| 1126 | if(csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_FALSE, eCSR_ROAM_RESULT_FAILURE)) |
| 1127 | { |
| 1128 | csrScanStartIdleScan(pMac); |
| 1129 | } |
| 1130 | status = eHAL_STATUS_SUCCESS; |
| 1131 | } |
| 1132 | } |
| 1133 | else |
| 1134 | { |
| 1135 | status = csrScanRequestLostLink3(pMac, sessionId); |
| 1136 | } |
| 1137 | |
| 1138 | return (status); |
| 1139 | } |
| 1140 | |
| 1141 | |
| 1142 | |
| 1143 | eHalStatus csrScanHandleFailedLostlink2(tpAniSirGlobal pMac, tANI_U32 sessionId) |
| 1144 | { |
| 1145 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 1146 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 1147 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1148 | if(!pSession) |
| 1149 | { |
| 1150 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 1151 | return eHAL_STATUS_FAILURE; |
| 1152 | } |
| 1153 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 1154 | smsLog(pMac, LOGW, " Lostlink scan 2 failed"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1155 | if(pSession->fCancelRoaming) |
| 1156 | { |
| 1157 | csrScanStartIdleScan(pMac); |
| 1158 | } |
| 1159 | else if(!pSession->pCurRoamProfile || !pSession->pCurRoamProfile->ChannelInfo.ChannelList || |
| 1160 | pSession->pCurRoamProfile->ChannelInfo.ChannelList[0] == 0) |
| 1161 | { |
| 1162 | //try lostlink scan3 |
| 1163 | status = csrScanRequestLostLink3(pMac, sessionId); |
| 1164 | } |
| 1165 | else |
| 1166 | { |
| 1167 | //we are done with lostlink |
| 1168 | if(csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_FALSE, eCSR_ROAM_RESULT_FAILURE)) |
| 1169 | { |
| 1170 | csrScanStartIdleScan(pMac); |
| 1171 | } |
| 1172 | } |
| 1173 | |
| 1174 | return (status); |
| 1175 | } |
| 1176 | |
| 1177 | |
| 1178 | |
| 1179 | eHalStatus csrScanHandleFailedLostlink3(tpAniSirGlobal pMac, tANI_U32 sessionId) |
| 1180 | { |
| 1181 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1182 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 1183 | smsLog(pMac, LOGW, " Lostlink scan 3 failed"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1184 | if(eANI_BOOLEAN_TRUE == csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_FALSE, eCSR_ROAM_RESULT_FAILURE)) |
| 1185 | { |
| 1186 | //we are done with lostlink |
| 1187 | csrScanStartIdleScan(pMac); |
| 1188 | } |
| 1189 | |
| 1190 | return (status); |
| 1191 | } |
| 1192 | |
| 1193 | |
| 1194 | |
| 1195 | |
| 1196 | //Lostlink1 scan is to actively scan the last connected profile's SSID on all matched BSS channels. |
| 1197 | //If no roam profile (it should not), it is like lostlinkscan3 |
| 1198 | eHalStatus csrScanRequestLostLink1( tpAniSirGlobal pMac, tANI_U32 sessionId ) |
| 1199 | { |
| 1200 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1201 | tSmeCmd *pCommand = NULL; |
| 1202 | tANI_U8 bAddr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; |
| 1203 | tCsrScanResultFilter *pScanFilter = NULL; |
| 1204 | tScanResultHandle hBSSList = NULL; |
| 1205 | tCsrScanResultInfo *pScanResult = NULL; |
| 1206 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 1207 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1208 | if(!pSession) |
| 1209 | { |
| 1210 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 1211 | return eHAL_STATUS_FAILURE; |
| 1212 | } |
| 1213 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 1214 | smsLog(pMac, LOGW, FL(" called")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1215 | do |
| 1216 | { |
| 1217 | pCommand = csrGetCommandBuffer(pMac); |
| 1218 | if(!pCommand) |
| 1219 | { |
| 1220 | status = eHAL_STATUS_RESOURCES; |
| 1221 | break; |
| 1222 | } |
| 1223 | palZeroMemory(pMac->hHdd, &pCommand->u.scanCmd, sizeof(tScanCmd)); |
| 1224 | pCommand->command = eSmeCommandScan; |
| 1225 | pCommand->sessionId = (tANI_U8)sessionId; |
| 1226 | pCommand->u.scanCmd.reason = eCsrScanLostLink1; |
| 1227 | pCommand->u.scanCmd.callback = NULL; |
| 1228 | pCommand->u.scanCmd.pContext = NULL; |
| 1229 | pCommand->u.scanCmd.u.scanRequest.maxChnTime = pMac->roam.configParam.nActiveMaxChnTime; |
| 1230 | pCommand->u.scanCmd.u.scanRequest.minChnTime = pMac->roam.configParam.nActiveMinChnTime; |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 1231 | pCommand->u.scanCmd.u.scanRequest.maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc; |
| 1232 | pCommand->u.scanCmd.u.scanRequest.minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1233 | pCommand->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 1234 | if(pSession->connectedProfile.SSID.length) |
| 1235 | { |
| 1236 | status = palAllocateMemory(pMac->hHdd, (void **)&pCommand->u.scanCmd.u.scanRequest.SSIDs.SSIDList, sizeof(tCsrSSIDInfo)); |
| 1237 | if(!HAL_STATUS_SUCCESS(status)) |
| 1238 | { |
| 1239 | break; |
| 1240 | } |
| 1241 | pCommand->u.scanCmd.u.scanRequest.SSIDs.numOfSSIDs = 1; |
| 1242 | palCopyMemory(pMac->hHdd, &pCommand->u.scanCmd.u.scanRequest.SSIDs.SSIDList[0].SSID, |
| 1243 | &pSession->connectedProfile.SSID, sizeof(tSirMacSSid)); |
| 1244 | } |
| 1245 | else |
| 1246 | { |
| 1247 | pCommand->u.scanCmd.u.scanRequest.SSIDs.numOfSSIDs = 0; |
| 1248 | } |
| 1249 | if(pSession->pCurRoamProfile) |
| 1250 | { |
| 1251 | status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter)); |
| 1252 | if(!HAL_STATUS_SUCCESS(status)) |
| 1253 | { |
| 1254 | break; |
| 1255 | } |
| 1256 | palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter)); |
| 1257 | status = csrRoamPrepareFilterFromProfile(pMac, pSession->pCurRoamProfile, pScanFilter); |
| 1258 | if(!HAL_STATUS_SUCCESS(status)) |
| 1259 | { |
| 1260 | break; |
| 1261 | } |
| 1262 | //Don't change variable status here because whether we can get result or not, the command goes to PE. |
| 1263 | //The status is also used to indicate whether the command is queued. Not success meaning not queue |
| 1264 | if(HAL_STATUS_SUCCESS((csrScanGetResult(pMac, pScanFilter, &hBSSList))) && hBSSList) |
| 1265 | { |
| 1266 | tANI_U8 i, nChn = 0; |
| 1267 | status = palAllocateMemory(pMac->hHdd, (void **)&pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList, |
| 1268 | WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 1269 | if(!HAL_STATUS_SUCCESS(status)) |
| 1270 | { |
| 1271 | break; |
| 1272 | } |
| 1273 | while(((pScanResult = csrScanResultGetNext(pMac, hBSSList)) != NULL) && |
| 1274 | nChn < WNI_CFG_VALID_CHANNEL_LIST_LEN) |
| 1275 | { |
| 1276 | for(i = 0; i < nChn; i++) |
| 1277 | { |
| 1278 | if(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[i] == |
| 1279 | pScanResult->BssDescriptor.channelId) |
| 1280 | { |
| 1281 | break; |
| 1282 | } |
| 1283 | } |
| 1284 | if(i == nChn) |
| 1285 | { |
| 1286 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[nChn++] = pScanResult->BssDescriptor.channelId; |
| 1287 | } |
| 1288 | } |
| 1289 | //Include the last connected BSS' channel |
| 1290 | if(csrRoamIsChannelValid(pMac, pSession->connectedProfile.operationChannel)) |
| 1291 | { |
| 1292 | for(i = 0; i < nChn; i++) |
| 1293 | { |
| 1294 | if(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[i] == |
| 1295 | pSession->connectedProfile.operationChannel) |
| 1296 | { |
| 1297 | break; |
| 1298 | } |
| 1299 | } |
| 1300 | if(i == nChn) |
| 1301 | { |
| 1302 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[nChn++] = pSession->connectedProfile.operationChannel; |
| 1303 | } |
| 1304 | } |
| 1305 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = nChn; |
| 1306 | } |
| 1307 | else |
| 1308 | { |
| 1309 | if(csrRoamIsChannelValid(pMac, pSession->connectedProfile.operationChannel)) |
| 1310 | { |
| 1311 | status = palAllocateMemory(pMac->hHdd, (void **)&pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList, |
| 1312 | 1); |
| 1313 | //just try the last connected channel |
| 1314 | if(HAL_STATUS_SUCCESS(status)) |
| 1315 | { |
| 1316 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[0] = pSession->connectedProfile.operationChannel; |
| 1317 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = 1; |
| 1318 | } |
| 1319 | else |
| 1320 | { |
| 1321 | break; |
| 1322 | } |
| 1323 | } |
| 1324 | } |
| 1325 | } |
| 1326 | palCopyMemory(pMac->hHdd, &pCommand->u.scanCmd.u.scanRequest.bssid, bAddr, sizeof(tCsrBssid)); |
| 1327 | status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE); |
| 1328 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 1329 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 1330 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1331 | break; |
| 1332 | } |
| 1333 | } while( 0 ); |
| 1334 | |
| 1335 | if(!HAL_STATUS_SUCCESS(status)) |
| 1336 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 1337 | smsLog(pMac, LOGW, " csrScanRequestLostLink1 failed with status %d", status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1338 | if(pCommand) |
| 1339 | { |
| 1340 | csrReleaseCommandScan(pMac, pCommand); |
| 1341 | } |
| 1342 | status = csrScanHandleFailedLostlink1( pMac, sessionId ); |
| 1343 | } |
| 1344 | if(pScanFilter) |
| 1345 | { |
| 1346 | csrFreeScanFilter(pMac, pScanFilter); |
| 1347 | palFreeMemory(pMac->hHdd, pScanFilter); |
| 1348 | } |
| 1349 | if(hBSSList) |
| 1350 | { |
| 1351 | csrScanResultPurge(pMac, hBSSList); |
| 1352 | } |
| 1353 | |
| 1354 | return( status ); |
| 1355 | } |
| 1356 | |
| 1357 | |
| 1358 | //Lostlink2 scan is to actively scan the all SSIDs of the last roaming profile's on all matched BSS channels. |
| 1359 | //Since MAC doesn't support multiple SSID, we scan all SSIDs and filter them afterwards |
| 1360 | eHalStatus csrScanRequestLostLink2( tpAniSirGlobal pMac, tANI_U32 sessionId ) |
| 1361 | { |
| 1362 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1363 | tANI_U8 bAddr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; |
| 1364 | tCsrScanResultFilter *pScanFilter = NULL; |
| 1365 | tScanResultHandle hBSSList = NULL; |
| 1366 | tCsrScanResultInfo *pScanResult = NULL; |
| 1367 | tSmeCmd *pCommand = NULL; |
| 1368 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 1369 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1370 | if(!pSession) |
| 1371 | { |
| 1372 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 1373 | return eHAL_STATUS_FAILURE; |
| 1374 | } |
| 1375 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 1376 | smsLog(pMac, LOGW, FL(" called")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1377 | do |
| 1378 | { |
| 1379 | pCommand = csrGetCommandBuffer(pMac); |
| 1380 | if(!pCommand) |
| 1381 | { |
| 1382 | status = eHAL_STATUS_RESOURCES; |
| 1383 | break; |
| 1384 | } |
| 1385 | palZeroMemory(pMac->hHdd, &pCommand->u.scanCmd, sizeof(tScanCmd)); |
| 1386 | pCommand->command = eSmeCommandScan; |
| 1387 | pCommand->sessionId = (tANI_U8)sessionId; |
| 1388 | pCommand->u.scanCmd.reason = eCsrScanLostLink2; |
| 1389 | pCommand->u.scanCmd.callback = NULL; |
| 1390 | pCommand->u.scanCmd.pContext = NULL; |
| 1391 | pCommand->u.scanCmd.u.scanRequest.maxChnTime = pMac->roam.configParam.nActiveMaxChnTime; |
| 1392 | pCommand->u.scanCmd.u.scanRequest.minChnTime = pMac->roam.configParam.nActiveMinChnTime; |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 1393 | pCommand->u.scanCmd.u.scanRequest.maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc; |
| 1394 | pCommand->u.scanCmd.u.scanRequest.minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1395 | pCommand->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 1396 | if(pSession->pCurRoamProfile) |
| 1397 | { |
| 1398 | status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter)); |
| 1399 | if(!HAL_STATUS_SUCCESS(status)) |
| 1400 | { |
| 1401 | break; |
| 1402 | } |
| 1403 | palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter)); |
| 1404 | status = csrRoamPrepareFilterFromProfile(pMac, pSession->pCurRoamProfile, pScanFilter); |
| 1405 | if(!HAL_STATUS_SUCCESS(status)) |
| 1406 | { |
| 1407 | break; |
| 1408 | } |
| 1409 | status = csrScanGetResult(pMac, pScanFilter, &hBSSList); |
| 1410 | if(!HAL_STATUS_SUCCESS(status)) |
| 1411 | { |
| 1412 | break; |
| 1413 | } |
| 1414 | if(hBSSList) |
| 1415 | { |
| 1416 | tANI_U8 i, nChn = 0; |
| 1417 | status = palAllocateMemory(pMac->hHdd, (void **)&pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList, |
| 1418 | WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 1419 | if(!HAL_STATUS_SUCCESS(status)) |
| 1420 | { |
| 1421 | break; |
| 1422 | } |
| 1423 | while(((pScanResult = csrScanResultGetNext(pMac, hBSSList)) != NULL) && |
| 1424 | nChn < WNI_CFG_VALID_CHANNEL_LIST_LEN) |
| 1425 | { |
| 1426 | for(i = 0; i < nChn; i++) |
| 1427 | { |
| 1428 | if(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[i] == |
| 1429 | pScanResult->BssDescriptor.channelId) |
| 1430 | { |
| 1431 | break; |
| 1432 | } |
| 1433 | } |
| 1434 | if(i == nChn) |
| 1435 | { |
| 1436 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[nChn++] = pScanResult->BssDescriptor.channelId; |
| 1437 | } |
| 1438 | } |
| 1439 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = nChn; |
| 1440 | } |
| 1441 | } |
| 1442 | palCopyMemory(pMac->hHdd, &pCommand->u.scanCmd.u.scanRequest.bssid, bAddr, sizeof(tCsrBssid)); |
| 1443 | //Put to the head in pending queue |
| 1444 | status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE); |
| 1445 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 1446 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 1447 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1448 | break; |
| 1449 | } |
| 1450 | } while( 0 ); |
| 1451 | |
| 1452 | if(!HAL_STATUS_SUCCESS(status)) |
| 1453 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 1454 | smsLog(pMac, LOGW, " csrScanRequestLostLink2 failed with status %d", status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1455 | if(pCommand) |
| 1456 | { |
| 1457 | csrReleaseCommandScan(pMac, pCommand); |
| 1458 | } |
| 1459 | status = csrScanHandleFailedLostlink2( pMac, sessionId ); |
| 1460 | } |
| 1461 | if(pScanFilter) |
| 1462 | { |
| 1463 | csrFreeScanFilter(pMac, pScanFilter); |
| 1464 | palFreeMemory(pMac->hHdd, pScanFilter); |
| 1465 | } |
| 1466 | if(hBSSList) |
| 1467 | { |
| 1468 | csrScanResultPurge(pMac, hBSSList); |
| 1469 | } |
| 1470 | |
| 1471 | return( status ); |
| 1472 | } |
| 1473 | |
| 1474 | |
| 1475 | //To actively scan all valid channels |
| 1476 | eHalStatus csrScanRequestLostLink3( tpAniSirGlobal pMac, tANI_U32 sessionId ) |
| 1477 | { |
| 1478 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1479 | tSmeCmd *pCommand; |
| 1480 | tANI_U8 bAddr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; |
| 1481 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 1482 | smsLog(pMac, LOGW, FL(" called")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1483 | do |
| 1484 | { |
| 1485 | pCommand = csrGetCommandBuffer(pMac); |
| 1486 | if(!pCommand) |
| 1487 | { |
| 1488 | status = eHAL_STATUS_RESOURCES; |
| 1489 | break; |
| 1490 | } |
| 1491 | palZeroMemory(pMac->hHdd, &pCommand->u.scanCmd, sizeof(tScanCmd)); |
| 1492 | pCommand->command = eSmeCommandScan; |
| 1493 | pCommand->sessionId = (tANI_U8)sessionId; |
| 1494 | pCommand->u.scanCmd.reason = eCsrScanLostLink3; |
| 1495 | pCommand->u.scanCmd.callback = NULL; |
| 1496 | pCommand->u.scanCmd.pContext = NULL; |
| 1497 | pCommand->u.scanCmd.u.scanRequest.maxChnTime = pMac->roam.configParam.nActiveMaxChnTime; |
| 1498 | pCommand->u.scanCmd.u.scanRequest.minChnTime = pMac->roam.configParam.nActiveMinChnTime; |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 1499 | pCommand->u.scanCmd.u.scanRequest.maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc; |
| 1500 | pCommand->u.scanCmd.u.scanRequest.minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1501 | pCommand->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 1502 | palCopyMemory(pMac->hHdd, &pCommand->u.scanCmd.u.scanRequest.bssid, bAddr, sizeof(tCsrBssid)); |
| 1503 | //Put to the head of pending queue |
| 1504 | status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE); |
| 1505 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 1506 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 1507 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1508 | break; |
| 1509 | } |
| 1510 | } while( 0 ); |
| 1511 | if(!HAL_STATUS_SUCCESS(status)) |
| 1512 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 1513 | smsLog(pMac, LOGW, " csrScanRequestLostLink3 failed with status %d", status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1514 | if(csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_FALSE, eCSR_ROAM_RESULT_FAILURE)) |
| 1515 | { |
| 1516 | csrScanStartIdleScan(pMac); |
| 1517 | } |
| 1518 | if(pCommand) |
| 1519 | { |
| 1520 | csrReleaseCommandScan(pMac, pCommand); |
| 1521 | } |
| 1522 | } |
| 1523 | |
| 1524 | return( status ); |
| 1525 | } |
| 1526 | |
| 1527 | |
| 1528 | eHalStatus csrScanHandleSearchForSSID(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
| 1529 | { |
| 1530 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 1531 | tScanResultHandle hBSSList = CSR_INVALID_SCANRESULT_HANDLE; |
| 1532 | tCsrScanResultFilter *pScanFilter = NULL; |
| 1533 | tCsrRoamProfile *pProfile = pCommand->u.scanCmd.pToRoamProfile; |
| 1534 | tANI_U32 sessionId = pCommand->sessionId; |
| 1535 | #ifdef FEATURE_WLAN_BTAMP_UT_RF |
| 1536 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 1537 | #endif |
| 1538 | do |
| 1539 | { |
| 1540 | //If there is roam command waiting, ignore this roam because the newer roam command is the one to execute |
| 1541 | if(csrIsRoamCommandWaitingForSession(pMac, sessionId)) |
| 1542 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 1543 | smsLog(pMac, LOGW, FL(" aborts because roam command waiting")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1544 | break; |
| 1545 | } |
| 1546 | if(pProfile == NULL) |
| 1547 | break; |
| 1548 | status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter)); |
| 1549 | if(!HAL_STATUS_SUCCESS(status)) |
| 1550 | break; |
| 1551 | palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter)); |
| 1552 | status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter); |
| 1553 | if(!HAL_STATUS_SUCCESS(status)) |
| 1554 | break; |
| 1555 | status = csrScanGetResult(pMac, pScanFilter, &hBSSList); |
| 1556 | if(!HAL_STATUS_SUCCESS(status)) |
| 1557 | break; |
| 1558 | status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued, |
| 1559 | pCommand->u.scanCmd.roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE); |
| 1560 | if(!HAL_STATUS_SUCCESS(status)) |
| 1561 | { |
| 1562 | break; |
| 1563 | } |
| 1564 | }while(0); |
| 1565 | if(!HAL_STATUS_SUCCESS(status)) |
| 1566 | { |
| 1567 | if(CSR_INVALID_SCANRESULT_HANDLE != hBSSList) |
| 1568 | { |
| 1569 | csrScanResultPurge(pMac, hBSSList); |
| 1570 | } |
| 1571 | //We haven't done anything to this profile |
| 1572 | csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.scanCmd.roamId, |
| 1573 | eCSR_ROAM_ASSOCIATION_FAILURE, eCSR_ROAM_RESULT_FAILURE); |
| 1574 | //In case we have nothing else to do, restart idle scan |
| 1575 | if(csrIsConnStateDisconnected(pMac, sessionId) && !csrIsRoamCommandWaiting(pMac)) |
| 1576 | { |
| 1577 | status = csrScanStartIdleScan(pMac); |
| 1578 | } |
| 1579 | #ifdef FEATURE_WLAN_BTAMP_UT_RF |
| 1580 | //In case of WDS station, let it retry. |
| 1581 | if( CSR_IS_WDS_STA(pProfile) ) |
| 1582 | { |
| 1583 | //Save the roma profile so we can retry |
| 1584 | csrFreeRoamProfile( pMac, sessionId ); |
| 1585 | if (HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, |
| 1586 | (void **)&pSession->pCurRoamProfile, |
| 1587 | sizeof(tCsrRoamProfile)))) |
| 1588 | { |
| 1589 | palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile)); |
| 1590 | csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile); |
| 1591 | } |
| 1592 | csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD); |
| 1593 | } |
| 1594 | #endif |
| 1595 | } |
| 1596 | if(pScanFilter) |
| 1597 | { |
| 1598 | csrFreeScanFilter(pMac, pScanFilter); |
| 1599 | palFreeMemory(pMac->hHdd, pScanFilter); |
| 1600 | } |
| 1601 | |
| 1602 | return (status); |
| 1603 | } |
| 1604 | |
| 1605 | |
| 1606 | eHalStatus csrScanHandleSearchForSSIDFailure(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
| 1607 | { |
| 1608 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1609 | tANI_U32 sessionId = pCommand->sessionId; |
| 1610 | tCsrRoamProfile *pProfile = pCommand->u.scanCmd.pToRoamProfile; |
| 1611 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 1612 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1613 | if(!pSession) |
| 1614 | { |
| 1615 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 1616 | return eHAL_STATUS_FAILURE; |
| 1617 | } |
| 1618 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1619 | #if defined(WLAN_DEBUG) |
| 1620 | if(pCommand->u.scanCmd.u.scanRequest.SSIDs.numOfSSIDs == 1) |
| 1621 | { |
| 1622 | char str[36]; |
| 1623 | palCopyMemory(pMac->hHdd, str, pCommand->u.scanCmd.u.scanRequest.SSIDs.SSIDList[0].SSID.ssId, |
| 1624 | pCommand->u.scanCmd.u.scanRequest.SSIDs.SSIDList[0].SSID.length); |
| 1625 | 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^] | 1626 | smsLog(pMac, LOGW, FL(" SSID = %s"), str); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1627 | } |
| 1628 | #endif |
| 1629 | //Check whether it is for start ibss. No need to do anything if it is a JOIN request |
| 1630 | if(pProfile && CSR_IS_START_IBSS(pProfile)) |
| 1631 | { |
| 1632 | status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued, |
| 1633 | pCommand->u.scanCmd.roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE); |
| 1634 | if(!HAL_STATUS_SUCCESS(status)) |
| 1635 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 1636 | 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] | 1637 | csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.scanCmd.roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE); |
| 1638 | } |
| 1639 | } |
| 1640 | else |
| 1641 | { |
| 1642 | eCsrRoamResult roamResult = eCSR_ROAM_RESULT_FAILURE; |
| 1643 | |
| 1644 | if(csrIsConnStateDisconnected(pMac, sessionId) && |
| 1645 | !csrIsRoamCommandWaitingForSession(pMac, sessionId)) |
| 1646 | { |
| 1647 | status = csrScanStartIdleScan(pMac); |
| 1648 | } |
| 1649 | if((NULL == pProfile) || !csrIsBssTypeIBSS(pProfile->BSSType)) |
| 1650 | { |
| 1651 | //Only indicate assoc_completion if we indicate assoc_start. |
| 1652 | if(pSession->bRefAssocStartCnt > 0) |
| 1653 | { |
| 1654 | tCsrRoamInfo *pRoamInfo = NULL, roamInfo; |
| 1655 | palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo)); |
| 1656 | pRoamInfo = &roamInfo; |
| 1657 | if(pCommand->u.roamCmd.pRoamBssEntry) |
| 1658 | { |
| 1659 | tCsrScanResult *pScanResult = |
| 1660 | GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, |
| 1661 | tCsrScanResult, Link); |
| 1662 | roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor; |
| 1663 | } |
| 1664 | roamInfo.statusCode = pSession->joinFailStatusCode.statusCode; |
| 1665 | roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode; |
| 1666 | pSession->bRefAssocStartCnt--; |
| 1667 | csrRoamCallCallback(pMac, sessionId, pRoamInfo, |
| 1668 | pCommand->u.scanCmd.roamId, |
| 1669 | eCSR_ROAM_ASSOCIATION_COMPLETION, |
| 1670 | eCSR_ROAM_RESULT_FAILURE); |
| 1671 | } |
Madan Mohan Koyyalamudi | ee255f1 | 2012-09-28 15:41:19 -0700 | [diff] [blame] | 1672 | else |
| 1673 | { |
| 1674 | csrRoamCallCallback(pMac, sessionId, NULL, |
| 1675 | pCommand->u.scanCmd.roamId, |
| 1676 | eCSR_ROAM_ASSOCIATION_FAILURE, |
| 1677 | eCSR_ROAM_RESULT_FAILURE); |
| 1678 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1679 | #ifdef FEATURE_WLAN_BTAMP_UT_RF |
| 1680 | //In case of WDS station, let it retry. |
| 1681 | if( CSR_IS_WDS_STA(pProfile) ) |
| 1682 | { |
| 1683 | //Save the roma profile so we can retry |
| 1684 | csrFreeRoamProfile( pMac, sessionId ); |
| 1685 | if (HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, |
| 1686 | (void **)&pSession->pCurRoamProfile, |
| 1687 | sizeof(tCsrRoamProfile)))) |
| 1688 | { |
| 1689 | palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile)); |
| 1690 | csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile); |
| 1691 | } |
| 1692 | csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD); |
| 1693 | } |
| 1694 | #endif |
| 1695 | } |
| 1696 | else |
| 1697 | { |
| 1698 | roamResult = eCSR_ROAM_RESULT_IBSS_START_FAILED; |
| 1699 | } |
| 1700 | csrRoamCompletion(pMac, sessionId, NULL, pCommand, roamResult, eANI_BOOLEAN_FALSE); |
| 1701 | } |
| 1702 | |
| 1703 | return (status); |
| 1704 | } |
| 1705 | |
| 1706 | |
| 1707 | //After scan for cap changes, issue a roaming command to either reconnect to the AP or pick another one to connect |
| 1708 | eHalStatus csrScanHandleCapChangeScanComplete(tpAniSirGlobal pMac, tANI_U32 sessionId) |
| 1709 | { |
| 1710 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 1711 | tScanResultHandle hBSSList = NULL; |
| 1712 | tCsrScanResultFilter *pScanFilter = NULL; |
| 1713 | tANI_U32 roamId = 0; |
| 1714 | tCsrRoamProfile *pProfile = NULL; |
| 1715 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 1716 | |
| 1717 | do |
| 1718 | { |
| 1719 | //Here is the profile we need to connect to |
| 1720 | status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter)); |
| 1721 | if(!HAL_STATUS_SUCCESS(status)) |
| 1722 | break; |
| 1723 | palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter)); |
| 1724 | if(NULL == pSession) break; |
| 1725 | if(NULL == pSession->pCurRoamProfile) |
| 1726 | { |
| 1727 | pScanFilter->EncryptionType.numEntries = 1; |
| 1728 | pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE; |
| 1729 | } |
| 1730 | else |
| 1731 | { |
| 1732 | //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect |
| 1733 | status = palAllocateMemory(pMac->hHdd, (void **)&pProfile, sizeof(tCsrRoamProfile)); |
| 1734 | if(!HAL_STATUS_SUCCESS(status)) |
| 1735 | break; |
| 1736 | status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile); |
| 1737 | if(!HAL_STATUS_SUCCESS(status)) |
| 1738 | break; |
| 1739 | status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter); |
| 1740 | }//We have a profile |
| 1741 | roamId = GET_NEXT_ROAM_ID(&pMac->roam); |
| 1742 | if(HAL_STATUS_SUCCESS(status)) |
| 1743 | { |
| 1744 | status = csrScanGetResult(pMac, pScanFilter, &hBSSList); |
| 1745 | if(HAL_STATUS_SUCCESS(status)) |
| 1746 | { |
| 1747 | //we want to put the last connected BSS to the very beginning, if possible |
| 1748 | csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList); |
| 1749 | status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, |
| 1750 | eCsrCapsChange, 0, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE); |
| 1751 | if(!HAL_STATUS_SUCCESS(status)) |
| 1752 | { |
| 1753 | csrScanResultPurge(pMac, hBSSList); |
| 1754 | } |
| 1755 | }//Have scan result |
| 1756 | else |
| 1757 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 1758 | smsLog(pMac, LOGW, FL("cannot find matching BSS of %02X-%02X-%02X-%02X-%02X-%02X"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1759 | pSession->connectedProfile.bssid[0], |
| 1760 | pSession->connectedProfile.bssid[1], |
| 1761 | pSession->connectedProfile.bssid[2], |
| 1762 | pSession->connectedProfile.bssid[3], |
| 1763 | pSession->connectedProfile.bssid[4], |
| 1764 | pSession->connectedProfile.bssid[5]); |
| 1765 | //Disconnect |
| 1766 | csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED); |
| 1767 | } |
| 1768 | } |
| 1769 | }while(0); |
| 1770 | if(pScanFilter) |
| 1771 | { |
| 1772 | csrFreeScanFilter(pMac, pScanFilter); |
| 1773 | palFreeMemory(pMac->hHdd, pScanFilter); |
| 1774 | } |
| 1775 | if(NULL != pProfile) |
| 1776 | { |
| 1777 | csrReleaseProfile(pMac, pProfile); |
| 1778 | palFreeMemory(pMac->hHdd, pProfile); |
| 1779 | } |
| 1780 | |
| 1781 | return (status); |
| 1782 | } |
| 1783 | |
| 1784 | |
| 1785 | |
| 1786 | eHalStatus csrScanResultPurge(tpAniSirGlobal pMac, tScanResultHandle hScanList) |
| 1787 | { |
| 1788 | eHalStatus status = eHAL_STATUS_INVALID_PARAMETER; |
| 1789 | tScanResultList *pScanList = (tScanResultList *)hScanList; |
| 1790 | |
| 1791 | if(pScanList) |
| 1792 | { |
| 1793 | status = csrLLScanPurgeResult(pMac, &pScanList->List); |
| 1794 | csrLLClose(&pScanList->List); |
| 1795 | palFreeMemory(pMac->hHdd, pScanList); |
| 1796 | } |
| 1797 | return (status); |
| 1798 | } |
| 1799 | |
| 1800 | |
| 1801 | static tANI_U32 csrGetBssPreferValue(tpAniSirGlobal pMac, int rssi) |
| 1802 | { |
| 1803 | tANI_U32 ret = 0; |
| 1804 | int i = CSR_NUM_RSSI_CAT - 1; |
| 1805 | |
| 1806 | while(i >= 0) |
| 1807 | { |
| 1808 | if(rssi >= pMac->roam.configParam.RSSICat[i]) |
| 1809 | { |
| 1810 | ret = pMac->roam.configParam.BssPreferValue[i]; |
| 1811 | break; |
| 1812 | } |
| 1813 | i--; |
| 1814 | }; |
| 1815 | |
| 1816 | return (ret); |
| 1817 | } |
| 1818 | |
| 1819 | |
| 1820 | //Return a CapValue base on the capabilities of a BSS |
| 1821 | static tANI_U32 csrGetBssCapValue(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes) |
| 1822 | { |
| 1823 | tANI_U32 ret = CSR_BSS_CAP_VALUE_NONE; |
Madan Mohan Koyyalamudi | d502607 | 2012-11-30 14:56:21 -0800 | [diff] [blame] | 1824 | #if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR) |
| 1825 | if(CSR_IS_ROAM_PREFER_5GHZ(pMac)) |
| 1826 | { |
| 1827 | if((pBssDesc) && CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId)) |
| 1828 | { |
| 1829 | ret += CSR_BSS_CAP_VALUE_5GHZ; |
| 1830 | } |
| 1831 | } |
| 1832 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1833 | if( pIes ) |
| 1834 | { |
| 1835 | //We only care about 11N capability |
| 1836 | if(pIes->HTCaps.present) |
| 1837 | { |
| 1838 | ret += CSR_BSS_CAP_VALUE_HT; |
| 1839 | } |
| 1840 | if(CSR_IS_QOS_BSS(pIes)) |
| 1841 | { |
| 1842 | ret += CSR_BSS_CAP_VALUE_WMM; |
| 1843 | //Give advantage to UAPSD |
| 1844 | if(CSR_IS_UAPSD_BSS(pIes)) |
| 1845 | { |
| 1846 | ret += CSR_BSS_CAP_VALUE_UAPSD; |
| 1847 | } |
| 1848 | } |
| 1849 | } |
| 1850 | |
| 1851 | return (ret); |
| 1852 | } |
| 1853 | |
| 1854 | |
| 1855 | //To check whther pBss1 is better than pBss2 |
| 1856 | static tANI_BOOLEAN csrIsBetterBss(tCsrScanResult *pBss1, tCsrScanResult *pBss2) |
| 1857 | { |
| 1858 | tANI_BOOLEAN ret; |
| 1859 | |
| 1860 | if(CSR_IS_BETTER_PREFER_VALUE(pBss1->preferValue, pBss2->preferValue)) |
| 1861 | { |
| 1862 | ret = eANI_BOOLEAN_TRUE; |
| 1863 | } |
| 1864 | else if(CSR_IS_EQUAL_PREFER_VALUE(pBss1->preferValue, pBss2->preferValue)) |
| 1865 | { |
| 1866 | if(CSR_IS_BETTER_CAP_VALUE(pBss1->capValue, pBss2->capValue)) |
| 1867 | { |
| 1868 | ret = eANI_BOOLEAN_TRUE; |
| 1869 | } |
| 1870 | else |
| 1871 | { |
| 1872 | ret = eANI_BOOLEAN_FALSE; |
| 1873 | } |
| 1874 | } |
| 1875 | else |
| 1876 | { |
| 1877 | ret = eANI_BOOLEAN_FALSE; |
| 1878 | } |
| 1879 | |
| 1880 | return (ret); |
| 1881 | } |
| 1882 | |
| 1883 | |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 1884 | #ifdef FEATURE_WLAN_LFR |
Madan Mohan Koyyalamudi | 470d2cf | 2012-09-28 14:43:44 -0700 | [diff] [blame] | 1885 | //Add the channel to the occupiedChannels array |
| 1886 | static void csrScanAddToOccupiedChannels( |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 1887 | tpAniSirGlobal pMac, |
| 1888 | tCsrScanResult *pResult, |
| 1889 | tCsrChannel *pOccupiedChannels, |
Madan Mohan Koyyalamudi | 470d2cf | 2012-09-28 14:43:44 -0700 | [diff] [blame] | 1890 | tDot11fBeaconIEs *pIes) |
| 1891 | { |
| 1892 | eHalStatus status; |
| 1893 | tANI_U8 channel; |
| 1894 | tANI_U8 numOccupiedChannels = pOccupiedChannels->numChannels; |
| 1895 | tANI_U8 *pOccupiedChannelList = pOccupiedChannels->channelList; |
| 1896 | |
| 1897 | channel = pResult->Result.BssDescriptor.channelId; |
| 1898 | |
| 1899 | if (!csrIsChannelPresentInList(pOccupiedChannelList, numOccupiedChannels, channel) |
Madan Mohan Koyyalamudi | dd3c966 | 2012-11-09 17:39:30 -0800 | [diff] [blame] | 1900 | && csrNeighborRoamConnectedProfileMatch(pMac, pResult, pIes)) |
Madan Mohan Koyyalamudi | 470d2cf | 2012-09-28 14:43:44 -0700 | [diff] [blame] | 1901 | { |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 1902 | status = csrAddToChannelListFront(pOccupiedChannelList, numOccupiedChannels, channel); |
Madan Mohan Koyyalamudi | 470d2cf | 2012-09-28 14:43:44 -0700 | [diff] [blame] | 1903 | if(HAL_STATUS_SUCCESS(status)) |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 1904 | { |
Madan Mohan Koyyalamudi | 470d2cf | 2012-09-28 14:43:44 -0700 | [diff] [blame] | 1905 | pOccupiedChannels->numChannels++; |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 1906 | 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] | 1907 | __func__, channel, pOccupiedChannels->numChannels); |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 1908 | if (pOccupiedChannels->numChannels > CSR_BG_SCAN_OCCUPIED_CHANNEL_LIST_LEN) |
| 1909 | pOccupiedChannels->numChannels = CSR_BG_SCAN_OCCUPIED_CHANNEL_LIST_LEN; |
| 1910 | } |
Madan Mohan Koyyalamudi | 470d2cf | 2012-09-28 14:43:44 -0700 | [diff] [blame] | 1911 | } |
| 1912 | } |
| 1913 | #endif |
| 1914 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1915 | //Put the BSS into the scan result list |
| 1916 | //pIes can not be NULL |
| 1917 | static void csrScanAddResult(tpAniSirGlobal pMac, tCsrScanResult *pResult, tDot11fBeaconIEs *pIes) |
| 1918 | { |
Srinivas | 28b5b4e | 2012-12-12 13:07:53 -0800 | [diff] [blame] | 1919 | #ifdef FEATURE_WLAN_LFR |
| 1920 | tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo; |
| 1921 | #endif |
| 1922 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1923 | pResult->preferValue = csrGetBssPreferValue(pMac, (int)pResult->Result.BssDescriptor.rssi); |
| 1924 | pResult->capValue = csrGetBssCapValue(pMac, &pResult->Result.BssDescriptor, pIes); |
| 1925 | csrLLInsertTail( &pMac->scan.scanResultList, &pResult->Link, LL_ACCESS_LOCK ); |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 1926 | #ifdef FEATURE_WLAN_LFR |
Srinivas | 28b5b4e | 2012-12-12 13:07:53 -0800 | [diff] [blame] | 1927 | if(0 == pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels) |
| 1928 | { |
| 1929 | /* Build the occupied channel list, only if "gNeighborScanChannelList" is |
| 1930 | NOT set in the cfg.ini file */ |
| 1931 | csrScanAddToOccupiedChannels(pMac, pResult, &pMac->scan.occupiedChannels, pIes); |
| 1932 | } |
Madan Mohan Koyyalamudi | 470d2cf | 2012-09-28 14:43:44 -0700 | [diff] [blame] | 1933 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1934 | } |
| 1935 | |
| 1936 | |
| 1937 | eHalStatus csrScanGetResult(tpAniSirGlobal pMac, tCsrScanResultFilter *pFilter, tScanResultHandle *phResult) |
| 1938 | { |
| 1939 | eHalStatus status; |
| 1940 | tScanResultList *pRetList; |
| 1941 | tCsrScanResult *pResult, *pBssDesc; |
| 1942 | tANI_U32 count = 0; |
| 1943 | tListElem *pEntry; |
| 1944 | tANI_U32 bssLen, allocLen; |
| 1945 | eCsrEncryptionType uc = eCSR_ENCRYPT_TYPE_NONE, mc = eCSR_ENCRYPT_TYPE_NONE; |
| 1946 | eCsrAuthType auth = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 1947 | tDot11fBeaconIEs *pIes, *pNewIes; |
| 1948 | tANI_BOOLEAN fMatch; |
| 1949 | |
| 1950 | if(phResult) |
| 1951 | { |
| 1952 | *phResult = CSR_INVALID_SCANRESULT_HANDLE; |
| 1953 | } |
| 1954 | status = palAllocateMemory(pMac->hHdd, (void **)&pRetList, sizeof(tScanResultList)); |
| 1955 | if(HAL_STATUS_SUCCESS(status)) |
| 1956 | { |
| 1957 | palZeroMemory(pMac->hHdd, pRetList, sizeof(tScanResultList)); |
| 1958 | csrLLOpen(pMac->hHdd, &pRetList->List); |
| 1959 | pRetList->pCurEntry = NULL; |
| 1960 | |
| 1961 | csrLLLock(&pMac->scan.scanResultList); |
| 1962 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK ); |
| 1963 | while( pEntry ) |
| 1964 | { |
| 1965 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 1966 | pIes = (tDot11fBeaconIEs *)( pBssDesc->Result.pvIes ); |
| 1967 | //if pBssDesc->Result.pvIes is NULL, we need to free any memory allocated by csrMatchBSS |
| 1968 | //for any error condition, otherwiase, it will be freed later. |
| 1969 | //reset |
| 1970 | fMatch = eANI_BOOLEAN_FALSE; |
| 1971 | pNewIes = NULL; |
| 1972 | |
| 1973 | if(pFilter) |
| 1974 | { |
| 1975 | fMatch = csrMatchBSS(pMac, &pBssDesc->Result.BssDescriptor, pFilter, &auth, &uc, &mc, &pIes); |
| 1976 | if( NULL != pIes ) |
| 1977 | { |
| 1978 | //Only save it when matching |
| 1979 | if(fMatch) |
| 1980 | { |
| 1981 | if( !pBssDesc->Result.pvIes ) |
| 1982 | { |
| 1983 | //csrMatchBSS allocates the memory. Simply pass it and it is freed later |
| 1984 | pNewIes = pIes; |
| 1985 | } |
| 1986 | else |
| 1987 | { |
| 1988 | //The pIes is allocated by someone else. make a copy |
| 1989 | //Only to save parsed IEs if caller provides a filter. Most likely the caller |
| 1990 | //is using to for association, hence save the parsed IEs |
| 1991 | status = palAllocateMemory(pMac->hHdd, (void **)&pNewIes, sizeof(tDot11fBeaconIEs)); |
| 1992 | if( HAL_STATUS_SUCCESS( status ) ) |
| 1993 | { |
| 1994 | palCopyMemory( pMac->hHdd, pNewIes, pIes, sizeof( tDot11fBeaconIEs ) ); |
| 1995 | } |
| 1996 | else |
| 1997 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 1998 | smsLog(pMac, LOGE, FL(" fail to allocate memory for IEs")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1999 | //Need to free memory allocated by csrMatchBSS |
| 2000 | if( !pBssDesc->Result.pvIes ) |
| 2001 | { |
| 2002 | palFreeMemory(pMac->hHdd, pIes); |
| 2003 | } |
| 2004 | break; |
| 2005 | } |
| 2006 | } |
| 2007 | }//fMatch |
| 2008 | else if( !pBssDesc->Result.pvIes ) |
| 2009 | { |
| 2010 | palFreeMemory(pMac->hHdd, pIes); |
| 2011 | } |
| 2012 | } |
| 2013 | } |
| 2014 | if(NULL == pFilter || fMatch) |
| 2015 | { |
| 2016 | bssLen = pBssDesc->Result.BssDescriptor.length + sizeof(pBssDesc->Result.BssDescriptor.length); |
| 2017 | allocLen = sizeof( tCsrScanResult ) + bssLen; |
| 2018 | status = palAllocateMemory(pMac->hHdd, (void **)&pResult, allocLen); |
| 2019 | if(!HAL_STATUS_SUCCESS(status)) |
| 2020 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 2021 | 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] | 2022 | if(pNewIes) |
| 2023 | { |
| 2024 | palFreeMemory(pMac->hHdd, pNewIes); |
| 2025 | } |
| 2026 | break; |
| 2027 | } |
| 2028 | palZeroMemory(pMac->hHdd, pResult, allocLen); |
| 2029 | pResult->capValue = pBssDesc->capValue; |
| 2030 | pResult->preferValue = pBssDesc->preferValue; |
| 2031 | pResult->ucEncryptionType = uc; |
| 2032 | pResult->mcEncryptionType = mc; |
| 2033 | pResult->authType = auth; |
| 2034 | pResult->Result.ssId = pBssDesc->Result.ssId; |
| 2035 | pResult->Result.timer = 0; |
| 2036 | //save the pIes for later use |
| 2037 | pResult->Result.pvIes = pNewIes; |
| 2038 | //save bss description |
| 2039 | status = palCopyMemory(pMac->hHdd, &pResult->Result.BssDescriptor, &pBssDesc->Result.BssDescriptor, bssLen); |
| 2040 | if(!HAL_STATUS_SUCCESS(status)) |
| 2041 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 2042 | smsLog(pMac, LOGE, FL(" fail to copy memory for scan result")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2043 | palFreeMemory(pMac->hHdd, pResult); |
| 2044 | if(pNewIes) |
| 2045 | { |
| 2046 | palFreeMemory(pMac->hHdd, pNewIes); |
| 2047 | } |
| 2048 | break; |
| 2049 | } |
| 2050 | //No need to lock pRetList because it is locally allocated and no outside can access it at this time |
| 2051 | if(csrLLIsListEmpty(&pRetList->List, LL_ACCESS_NOLOCK)) |
| 2052 | { |
| 2053 | csrLLInsertTail(&pRetList->List, &pResult->Link, LL_ACCESS_NOLOCK); |
| 2054 | } |
| 2055 | else |
| 2056 | { |
| 2057 | //To sort the list |
| 2058 | tListElem *pTmpEntry; |
| 2059 | tCsrScanResult *pTmpResult; |
| 2060 | |
| 2061 | pTmpEntry = csrLLPeekHead(&pRetList->List, LL_ACCESS_NOLOCK); |
| 2062 | while(pTmpEntry) |
| 2063 | { |
| 2064 | pTmpResult = GET_BASE_ADDR( pTmpEntry, tCsrScanResult, Link ); |
| 2065 | if(csrIsBetterBss(pResult, pTmpResult)) |
| 2066 | { |
| 2067 | csrLLInsertEntry(&pRetList->List, pTmpEntry, &pResult->Link, LL_ACCESS_NOLOCK); |
| 2068 | //To indicate we are done |
| 2069 | pResult = NULL; |
| 2070 | break; |
| 2071 | } |
| 2072 | pTmpEntry = csrLLNext(&pRetList->List, pTmpEntry, LL_ACCESS_NOLOCK); |
| 2073 | } |
| 2074 | if(pResult != NULL) |
| 2075 | { |
| 2076 | //This one is not better than any one |
| 2077 | csrLLInsertTail(&pRetList->List, &pResult->Link, LL_ACCESS_NOLOCK); |
| 2078 | } |
| 2079 | } |
| 2080 | count++; |
| 2081 | } |
| 2082 | pEntry = csrLLNext( &pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK ); |
| 2083 | }//while |
| 2084 | csrLLUnlock(&pMac->scan.scanResultList); |
| 2085 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 2086 | smsLog(pMac, LOG2, FL("return %d BSS"), csrLLCount(&pRetList->List)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2087 | |
| 2088 | if( !HAL_STATUS_SUCCESS(status) || (phResult == NULL) ) |
| 2089 | { |
| 2090 | //Fail or No one wants the result. |
| 2091 | csrScanResultPurge(pMac, (tScanResultHandle)pRetList); |
| 2092 | } |
| 2093 | else |
| 2094 | { |
| 2095 | if(0 == count) |
| 2096 | { |
| 2097 | //We are here meaning the there is no match |
| 2098 | csrLLClose(&pRetList->List); |
| 2099 | palFreeMemory(pMac->hHdd, pRetList); |
| 2100 | status = eHAL_STATUS_E_NULL_VALUE; |
| 2101 | } |
| 2102 | else if(phResult) |
| 2103 | { |
| 2104 | *phResult = pRetList; |
| 2105 | } |
| 2106 | } |
| 2107 | }//Allocated pRetList |
| 2108 | |
| 2109 | return (status); |
| 2110 | } |
| 2111 | |
Madan Mohan Koyyalamudi | ab41d0f | 2012-10-31 17:17:10 -0700 | [diff] [blame] | 2112 | /* |
| 2113 | * NOTE: This routine is being added to make |
| 2114 | * sure that scan results are not being flushed |
| 2115 | * while roaming. If the scan results are flushed, |
| 2116 | * we are unable to recover from |
| 2117 | * csrRoamRoamingStateDisassocRspProcessor. |
| 2118 | * If it is needed to remove this routine, |
| 2119 | * first ensure that we recover gracefully from |
| 2120 | * csrRoamRoamingStateDisassocRspProcessor if |
| 2121 | * csrScanGetResult returns with a failure because |
| 2122 | * of not being able to find the roaming BSS. |
| 2123 | */ |
| 2124 | tANI_U8 csrScanFlushDenied(tpAniSirGlobal pMac) |
| 2125 | { |
| 2126 | switch(pMac->roam.neighborRoamInfo.neighborRoamState) { |
| 2127 | case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN: |
| 2128 | case eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING: |
| 2129 | case eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE: |
| 2130 | case eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING: |
| 2131 | return (pMac->roam.neighborRoamInfo.neighborRoamState); |
| 2132 | default: |
| 2133 | return 0; |
| 2134 | } |
| 2135 | } |
| 2136 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2137 | eHalStatus csrScanFlushResult(tpAniSirGlobal pMac) |
| 2138 | { |
Madan Mohan Koyyalamudi | ab41d0f | 2012-10-31 17:17:10 -0700 | [diff] [blame] | 2139 | tANI_U8 isFlushDenied = csrScanFlushDenied(pMac); |
| 2140 | if (isFlushDenied) { |
| 2141 | smsLog(pMac, LOGW, "%s: scan flush denied in roam state %d", |
| 2142 | __func__, isFlushDenied); |
| 2143 | return eHAL_STATUS_FAILURE; |
| 2144 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2145 | return ( csrLLScanPurgeResult(pMac, &pMac->scan.scanResultList) ); |
| 2146 | } |
| 2147 | |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2148 | eHalStatus csrScanFlushSelectiveResult(tpAniSirGlobal pMac, v_BOOL_t flushP2P) |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2149 | { |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2150 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2151 | tListElem *pEntry,*pFreeElem; |
| 2152 | tCsrScanResult *pBssDesc; |
| 2153 | tDblLinkList *pList = &pMac->scan.scanResultList; |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2154 | |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2155 | csrLLLock(pList); |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2156 | |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2157 | pEntry = csrLLPeekHead( pList, LL_ACCESS_NOLOCK ); |
| 2158 | while( pEntry != NULL) |
| 2159 | { |
| 2160 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 2161 | if( flushP2P == vos_mem_compare( pBssDesc->Result.ssId.ssId, |
| 2162 | "DIRECT-", 7) ) |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2163 | { |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2164 | pFreeElem = pEntry; |
| 2165 | pEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK); |
| 2166 | csrLLRemoveEntry(pList, pFreeElem, LL_ACCESS_NOLOCK); |
| 2167 | csrFreeScanResultEntry( pMac, pBssDesc ); |
| 2168 | continue; |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2169 | } |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2170 | pEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK); |
| 2171 | } |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2172 | |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2173 | csrLLUnlock(pList); |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2174 | |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2175 | return (status); |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2176 | } |
| 2177 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2178 | /** |
| 2179 | * csrCheck11dChannel |
| 2180 | * |
| 2181 | *FUNCTION: |
| 2182 | * This function is called from csrScanFilter11dResult function and |
| 2183 | * compare channel number with given channel list. |
| 2184 | * |
| 2185 | *LOGIC: |
| 2186 | * Check Scan result channel number with CFG channel list |
| 2187 | * |
| 2188 | *ASSUMPTIONS: |
| 2189 | * |
| 2190 | * |
| 2191 | *NOTE: |
| 2192 | * |
| 2193 | * @param channelId channel number |
| 2194 | * @param pChannelList Pointer to channel list |
| 2195 | * @param numChannels Number of channel in channel list |
| 2196 | * |
| 2197 | * @return Status |
| 2198 | */ |
| 2199 | |
| 2200 | eHalStatus csrCheck11dChannel(tANI_U8 channelId, tANI_U8 *pChannelList, tANI_U32 numChannels) |
| 2201 | { |
| 2202 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 2203 | tANI_U8 i = 0; |
| 2204 | |
| 2205 | for (i = 0; i < numChannels; i++) |
| 2206 | { |
| 2207 | if(pChannelList[ i ] == channelId) |
| 2208 | { |
| 2209 | status = eHAL_STATUS_SUCCESS; |
| 2210 | break; |
| 2211 | } |
| 2212 | } |
| 2213 | return status; |
| 2214 | } |
| 2215 | |
| 2216 | /** |
| 2217 | * csrScanFilter11dResult |
| 2218 | * |
| 2219 | *FUNCTION: |
| 2220 | * This function is called from csrApplyCountryInformation function and |
| 2221 | * filter scan result based on valid channel list number. |
| 2222 | * |
| 2223 | *LOGIC: |
| 2224 | * Get scan result from scan list and Check Scan result channel number |
| 2225 | * with 11d channel list if channel number is found in 11d channel list |
| 2226 | * then do not remove scan result entry from scan list |
| 2227 | * |
| 2228 | *ASSUMPTIONS: |
| 2229 | * |
| 2230 | * |
| 2231 | *NOTE: |
| 2232 | * |
| 2233 | * @param pMac Pointer to Global MAC structure |
| 2234 | * |
| 2235 | * @return Status |
| 2236 | */ |
| 2237 | |
| 2238 | eHalStatus csrScanFilter11dResult(tpAniSirGlobal pMac) |
| 2239 | { |
| 2240 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2241 | tListElem *pEntry,*pTempEntry; |
| 2242 | tCsrScanResult *pBssDesc; |
| 2243 | tANI_U32 len = sizeof(pMac->roam.validChannelList); |
| 2244 | |
| 2245 | /* Get valid channels list from CFG */ |
| 2246 | if (!HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, |
| 2247 | pMac->roam.validChannelList, &len))) |
| 2248 | { |
| 2249 | smsLog( pMac, LOG1, "Failed to get Channel list from CFG"); |
| 2250 | } |
| 2251 | |
| 2252 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_LOCK ); |
| 2253 | while( pEntry ) |
| 2254 | { |
| 2255 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 2256 | pTempEntry = csrLLNext( &pMac->scan.scanResultList, pEntry, |
| 2257 | LL_ACCESS_LOCK ); |
| 2258 | if(csrCheck11dChannel(pBssDesc->Result.BssDescriptor.channelId, |
| 2259 | pMac->roam.validChannelList, len)) |
| 2260 | { |
| 2261 | /* Remove Scan result which does not have 11d channel */ |
| 2262 | if( csrLLRemoveEntry( &pMac->scan.scanResultList, pEntry, |
| 2263 | LL_ACCESS_LOCK )) |
| 2264 | { |
| 2265 | csrFreeScanResultEntry( pMac, pBssDesc ); |
| 2266 | } |
| 2267 | } |
| 2268 | pEntry = pTempEntry; |
| 2269 | } |
| 2270 | return status; |
| 2271 | } |
| 2272 | |
| 2273 | |
| 2274 | eHalStatus csrScanCopyResultList(tpAniSirGlobal pMac, tScanResultHandle hIn, tScanResultHandle *phResult) |
| 2275 | { |
| 2276 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2277 | tScanResultList *pRetList, *pInList = (tScanResultList *)hIn; |
| 2278 | tCsrScanResult *pResult, *pScanResult; |
| 2279 | tANI_U32 count = 0; |
| 2280 | tListElem *pEntry; |
| 2281 | tANI_U32 bssLen, allocLen; |
| 2282 | |
| 2283 | if(phResult) |
| 2284 | { |
| 2285 | *phResult = CSR_INVALID_SCANRESULT_HANDLE; |
| 2286 | } |
| 2287 | status = palAllocateMemory(pMac->hHdd, (void **)&pRetList, sizeof(tScanResultList)); |
| 2288 | if(HAL_STATUS_SUCCESS(status)) |
| 2289 | { |
| 2290 | palZeroMemory(pMac->hHdd, pRetList, sizeof(tScanResultList)); |
| 2291 | csrLLOpen(pMac->hHdd, &pRetList->List); |
| 2292 | pRetList->pCurEntry = NULL; |
| 2293 | csrLLLock(&pMac->scan.scanResultList); |
| 2294 | csrLLLock(&pInList->List); |
| 2295 | |
| 2296 | pEntry = csrLLPeekHead( &pInList->List, LL_ACCESS_NOLOCK ); |
| 2297 | while( pEntry ) |
| 2298 | { |
| 2299 | pScanResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 2300 | bssLen = pScanResult->Result.BssDescriptor.length + sizeof(pScanResult->Result.BssDescriptor.length); |
| 2301 | allocLen = sizeof( tCsrScanResult ) + bssLen; |
| 2302 | status = palAllocateMemory(pMac->hHdd, (void **)&pResult, allocLen); |
| 2303 | if(!HAL_STATUS_SUCCESS(status)) |
| 2304 | { |
| 2305 | csrScanResultPurge(pMac, (tScanResultHandle *)pRetList); |
| 2306 | count = 0; |
| 2307 | break; |
| 2308 | } |
| 2309 | palZeroMemory(pMac->hHdd, pResult, allocLen); |
| 2310 | status = palCopyMemory(pMac->hHdd, &pResult->Result.BssDescriptor, &pScanResult->Result.BssDescriptor, bssLen); |
| 2311 | if(!HAL_STATUS_SUCCESS(status)) |
| 2312 | { |
| 2313 | csrScanResultPurge(pMac, (tScanResultHandle *)pRetList); |
| 2314 | count = 0; |
| 2315 | break; |
| 2316 | } |
| 2317 | if( pScanResult->Result.pvIes ) |
| 2318 | { |
| 2319 | status = palAllocateMemory(pMac->hHdd, (void **)&pResult->Result.pvIes, sizeof( tDot11fBeaconIEs )); |
| 2320 | if(!HAL_STATUS_SUCCESS(status)) |
| 2321 | { |
| 2322 | //Free the memory we allocate above first |
| 2323 | palFreeMemory( pMac->hHdd, pResult ); |
| 2324 | csrScanResultPurge(pMac, (tScanResultHandle *)pRetList); |
| 2325 | count = 0; |
| 2326 | break; |
| 2327 | } |
| 2328 | status = palCopyMemory(pMac->hHdd, pResult->Result.pvIes, |
| 2329 | pScanResult->Result.pvIes, sizeof( tDot11fBeaconIEs )); |
| 2330 | if(!HAL_STATUS_SUCCESS(status)) |
| 2331 | { |
| 2332 | //Free the memory we allocate above first |
| 2333 | palFreeMemory( pMac->hHdd, pResult ); |
| 2334 | csrScanResultPurge(pMac, (tScanResultHandle *)pRetList); |
| 2335 | count = 0; |
| 2336 | break; |
| 2337 | } |
| 2338 | } |
| 2339 | csrLLInsertTail(&pRetList->List, &pResult->Link, LL_ACCESS_LOCK); |
| 2340 | count++; |
| 2341 | pEntry = csrLLNext( &pInList->List, pEntry, LL_ACCESS_NOLOCK ); |
| 2342 | }//while |
| 2343 | csrLLUnlock(&pInList->List); |
| 2344 | csrLLUnlock(&pMac->scan.scanResultList); |
| 2345 | |
| 2346 | if(HAL_STATUS_SUCCESS(status)) |
| 2347 | { |
| 2348 | if(0 == count) |
| 2349 | { |
| 2350 | csrLLClose(&pRetList->List); |
| 2351 | palFreeMemory(pMac->hHdd, pRetList); |
| 2352 | status = eHAL_STATUS_E_NULL_VALUE; |
| 2353 | } |
| 2354 | else if(phResult) |
| 2355 | { |
| 2356 | *phResult = pRetList; |
| 2357 | } |
| 2358 | } |
| 2359 | }//Allocated pRetList |
| 2360 | |
| 2361 | return (status); |
| 2362 | } |
| 2363 | |
| 2364 | |
| 2365 | |
| 2366 | eHalStatus csrScanningStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf ) |
| 2367 | { |
| 2368 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2369 | tSirMbMsg *pMsg = (tSirMbMsg *)pMsgBuf; |
| 2370 | |
| 2371 | if((eWNI_SME_SCAN_RSP == pMsg->type) || (eWNI_SME_GET_SCANNED_CHANNEL_RSP == pMsg->type)) |
| 2372 | { |
| 2373 | status = csrScanSmeScanResponse( pMac, pMsgBuf ); |
| 2374 | } |
| 2375 | else |
| 2376 | { |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 2377 | if(pMsg->type == eWNI_SME_UPPER_LAYER_ASSOC_CNF) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2378 | { |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 2379 | tCsrRoamSession *pSession; |
| 2380 | tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf; |
| 2381 | tCsrRoamInfo roamInfo; |
| 2382 | tCsrRoamInfo *pRoamInfo = NULL; |
| 2383 | tANI_U32 sessionId; |
| 2384 | eHalStatus status; |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 2385 | smsLog( pMac, LOG1, FL("Scanning : ASSOCIATION confirmation can be given to upper layer ")); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 2386 | palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo)); |
| 2387 | pRoamInfo = &roamInfo; |
| 2388 | pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf; |
| 2389 | status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId ); |
| 2390 | pSession = CSR_GET_SESSION(pMac, sessionId); |
| 2391 | |
| 2392 | if(!pSession) |
| 2393 | { |
| 2394 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 2395 | return eHAL_STATUS_FAILURE; |
| 2396 | } |
| 2397 | |
| 2398 | pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success |
| 2399 | pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile; |
| 2400 | pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid; |
| 2401 | pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length; |
| 2402 | pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata; |
| 2403 | pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length; |
| 2404 | pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata; |
| 2405 | palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr, sizeof(tSirMacAddr)); |
| 2406 | palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pUpperLayerAssocCnf->bssId, sizeof(tCsrBssid)); |
| 2407 | pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta; |
| 2408 | if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) ) |
| 2409 | { |
| 2410 | pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED; |
| 2411 | pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq; |
| 2412 | status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF); |
| 2413 | } |
| 2414 | if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile)) |
| 2415 | { |
| 2416 | vos_sleep( 100 ); |
| 2417 | pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta |
| 2418 | status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta |
| 2419 | } |
| 2420 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2421 | } |
| 2422 | else |
| 2423 | { |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 2424 | |
| 2425 | if( csrIsAnySessionInConnectState( pMac ) ) |
| 2426 | { |
| 2427 | //In case of we are connected, we need to check whether connect status changes |
| 2428 | //because scan may also run while connected. |
| 2429 | csrRoamCheckForLinkStatusChange( pMac, ( tSirSmeRsp * )pMsgBuf ); |
| 2430 | } |
| 2431 | else |
| 2432 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 2433 | smsLog( pMac, LOGW, "Message [0x%04x] received in state, when expecting Scan Response", pMsg->type ); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 2434 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2435 | } |
| 2436 | } |
| 2437 | |
| 2438 | return (status); |
| 2439 | } |
| 2440 | |
| 2441 | |
| 2442 | |
| 2443 | void csrCheckNSaveWscIe(tpAniSirGlobal pMac, tSirBssDescription *pNewBssDescr, tSirBssDescription *pOldBssDescr) |
| 2444 | { |
| 2445 | int idx, len; |
| 2446 | tANI_U8 *pbIe; |
| 2447 | |
| 2448 | //If failed to remove, assuming someone else got it. |
| 2449 | if((pNewBssDescr->fProbeRsp != pOldBssDescr->fProbeRsp) && |
| 2450 | (0 == pNewBssDescr->WscIeLen)) |
| 2451 | { |
| 2452 | idx = 0; |
| 2453 | len = pOldBssDescr->length - sizeof(tSirBssDescription) + |
| 2454 | sizeof(tANI_U16) + sizeof(tANI_U32) - DOT11F_IE_WSCPROBERES_MIN_LEN - 2; |
| 2455 | pbIe = (tANI_U8 *)pOldBssDescr->ieFields; |
| 2456 | //Save WPS IE if it exists |
| 2457 | pNewBssDescr->WscIeLen = 0; |
| 2458 | while(idx < len) |
| 2459 | { |
| 2460 | if((DOT11F_EID_WSCPROBERES == pbIe[0]) && |
| 2461 | (0x00 == pbIe[2]) && (0x50 == pbIe[3]) && (0xf2 == pbIe[4]) && (0x04 == pbIe[5])) |
| 2462 | { |
| 2463 | //Founrd it |
| 2464 | if((DOT11F_IE_WSCPROBERES_MAX_LEN - 2) >= pbIe[1]) |
| 2465 | { |
| 2466 | palCopyMemory(pMac->hHdd, pNewBssDescr->WscIeProbeRsp, |
| 2467 | pbIe, pbIe[1] + 2); |
| 2468 | pNewBssDescr->WscIeLen = pbIe[1] + 2; |
| 2469 | } |
| 2470 | break; |
| 2471 | } |
| 2472 | idx += pbIe[1] + 2; |
| 2473 | pbIe += pbIe[1] + 2; |
| 2474 | } |
| 2475 | } |
| 2476 | } |
| 2477 | |
| 2478 | |
| 2479 | |
| 2480 | //pIes may be NULL |
| 2481 | tANI_BOOLEAN csrRemoveDupBssDescription( tpAniSirGlobal pMac, tSirBssDescription *pSirBssDescr, |
| 2482 | tDot11fBeaconIEs *pIes, tAniSSID *pSsid , v_TIME_t *timer ) |
| 2483 | { |
| 2484 | tListElem *pEntry; |
| 2485 | |
| 2486 | tCsrScanResult *pBssDesc; |
| 2487 | tANI_BOOLEAN fRC = FALSE; |
| 2488 | |
| 2489 | // Walk through all the chained BssDescriptions. If we find a chained BssDescription that |
| 2490 | // matches the BssID of the BssDescription passed in, then these must be duplicate scan |
| 2491 | // results for this Bss. In that case, remove the 'old' Bss description from the linked list. |
| 2492 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_LOCK ); |
| 2493 | |
| 2494 | while( pEntry ) |
| 2495 | { |
| 2496 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 2497 | |
| 2498 | // we have a duplicate scan results only when BSSID, SSID, Channel and NetworkType |
| 2499 | // matches |
| 2500 | if ( csrIsDuplicateBssDescription( pMac, &pBssDesc->Result.BssDescriptor, |
| 2501 | pSirBssDescr, pIes ) ) |
| 2502 | { |
| 2503 | pSirBssDescr->rssi = (tANI_S8)( (((tANI_S32)pSirBssDescr->rssi * CSR_SCAN_RESULT_RSSI_WEIGHT ) + |
| 2504 | ((tANI_S32)pBssDesc->Result.BssDescriptor.rssi * (100 - CSR_SCAN_RESULT_RSSI_WEIGHT) )) / 100 ); |
| 2505 | // Remove the 'old' entry from the list.... |
| 2506 | if( csrLLRemoveEntry( &pMac->scan.scanResultList, pEntry, LL_ACCESS_LOCK ) ) |
| 2507 | { |
| 2508 | // !we need to free the memory associated with this node |
| 2509 | //If failed to remove, assuming someone else got it. |
| 2510 | *pSsid = pBssDesc->Result.ssId; |
| 2511 | *timer = pBssDesc->Result.timer; |
| 2512 | csrCheckNSaveWscIe(pMac, pSirBssDescr, &pBssDesc->Result.BssDescriptor); |
| 2513 | |
| 2514 | csrFreeScanResultEntry( pMac, pBssDesc ); |
| 2515 | } |
| 2516 | else |
| 2517 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 2518 | smsLog( pMac, LOGW, FL( " fail to remove entry" ) ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2519 | } |
| 2520 | fRC = TRUE; |
| 2521 | |
| 2522 | // If we found a match, we can stop looking through the list. |
| 2523 | break; |
| 2524 | } |
| 2525 | |
| 2526 | pEntry = csrLLNext( &pMac->scan.scanResultList, pEntry, LL_ACCESS_LOCK ); |
| 2527 | } |
| 2528 | |
| 2529 | return fRC; |
| 2530 | } |
| 2531 | |
| 2532 | |
| 2533 | eHalStatus csrAddPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId, |
| 2534 | tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes ) |
| 2535 | { |
| 2536 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 2537 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 2538 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2539 | if(!pSession) |
| 2540 | { |
| 2541 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 2542 | return eHAL_STATUS_FAILURE; |
| 2543 | } |
| 2544 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 2545 | smsLog(pMac, LOGW, "csrAddPMKIDCandidateList called pMac->scan.NumPmkidCandidate = %d", pSession->NumPmkidCandidate); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2546 | if( pIes ) |
| 2547 | { |
| 2548 | // check if this is a RSN BSS |
| 2549 | if( pIes->RSN.present ) |
| 2550 | { |
| 2551 | // Check if the BSS is capable of doing pre-authentication |
| 2552 | if( pSession->NumPmkidCandidate < CSR_MAX_PMKID_ALLOWED ) |
| 2553 | { |
| 2554 | |
| 2555 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 2556 | { |
| 2557 | WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type); |
| 2558 | palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type)); |
| 2559 | secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_CANDIDATE_FOUND; |
| 2560 | secEvent.encryptionModeMulticast = |
| 2561 | (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType); |
| 2562 | secEvent.encryptionModeUnicast = |
| 2563 | (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType); |
| 2564 | palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 ); |
| 2565 | secEvent.authMode = |
| 2566 | (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType); |
| 2567 | WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY); |
| 2568 | } |
| 2569 | #endif//#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 2570 | |
| 2571 | // if yes, then add to PMKIDCandidateList |
| 2572 | status = palCopyMemory(pMac->hHdd, pSession->PmkidCandidateInfo[pSession->NumPmkidCandidate].BSSID, |
| 2573 | pBssDesc->bssId, WNI_CFG_BSSID_LEN); |
| 2574 | |
| 2575 | if( HAL_STATUS_SUCCESS( status ) ) |
| 2576 | { |
Venkata Prathyusha Kuntupalli | ea7098e | 2013-01-31 16:08:13 -0800 | [diff] [blame] | 2577 | if ( (pIes->RSN.RSN_Cap[0] >> 0) & 0x1 ) // Bit 0 offirst byte - PreAuthentication Capability |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2578 | { |
| 2579 | pSession->PmkidCandidateInfo[pSession->NumPmkidCandidate].preAuthSupported = eANI_BOOLEAN_TRUE; |
| 2580 | } |
| 2581 | else |
| 2582 | { |
| 2583 | pSession->PmkidCandidateInfo[pSession->NumPmkidCandidate].preAuthSupported = eANI_BOOLEAN_FALSE; |
| 2584 | } |
| 2585 | pSession->NumPmkidCandidate++; |
| 2586 | } |
| 2587 | } |
| 2588 | else |
| 2589 | { |
| 2590 | status = eHAL_STATUS_FAILURE; |
| 2591 | } |
| 2592 | } |
| 2593 | } |
| 2594 | |
| 2595 | return (status); |
| 2596 | } |
| 2597 | |
| 2598 | //This function checks whether new AP is found for the current connected profile |
| 2599 | //If it is found, it return the sessionId, else it return invalid sessionID |
| 2600 | tANI_U32 csrProcessBSSDescForPMKIDList(tpAniSirGlobal pMac, |
| 2601 | tSirBssDescription *pBssDesc, |
| 2602 | tDot11fBeaconIEs *pIes) |
| 2603 | { |
| 2604 | tANI_U32 i, bRet = CSR_SESSION_ID_INVALID; |
| 2605 | tCsrRoamSession *pSession; |
| 2606 | tDot11fBeaconIEs *pIesLocal = pIes; |
| 2607 | |
| 2608 | if( pIesLocal || HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal)) ) |
| 2609 | { |
| 2610 | for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ ) |
| 2611 | { |
| 2612 | if( CSR_IS_SESSION_VALID( pMac, i ) ) |
| 2613 | { |
| 2614 | pSession = CSR_GET_SESSION( pMac, i ); |
| 2615 | if( csrIsConnStateConnectedInfra( pMac, i ) && |
| 2616 | ( eCSR_AUTH_TYPE_RSN == pSession->connectedProfile.AuthType ) ) |
| 2617 | { |
| 2618 | if(csrMatchBSSToConnectProfile(pMac, &pSession->connectedProfile, pBssDesc, pIesLocal)) |
| 2619 | { |
| 2620 | //this new BSS fits the current profile connected |
| 2621 | if(HAL_STATUS_SUCCESS(csrAddPMKIDCandidateList(pMac, i, pBssDesc, pIesLocal))) |
| 2622 | { |
| 2623 | bRet = i; |
| 2624 | } |
| 2625 | break; |
| 2626 | } |
| 2627 | } |
| 2628 | } |
| 2629 | } |
| 2630 | if( !pIes ) |
| 2631 | { |
| 2632 | palFreeMemory(pMac->hHdd, pIesLocal); |
| 2633 | } |
| 2634 | } |
| 2635 | |
| 2636 | return (tANI_U8)bRet; |
| 2637 | } |
| 2638 | |
| 2639 | #ifdef FEATURE_WLAN_WAPI |
| 2640 | eHalStatus csrAddBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId, |
| 2641 | tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes ) |
| 2642 | { |
| 2643 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 2644 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 2645 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2646 | if(!pSession) |
| 2647 | { |
| 2648 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 2649 | return eHAL_STATUS_FAILURE; |
| 2650 | } |
| 2651 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 2652 | smsLog(pMac, LOGW, "csrAddBKIDCandidateList called pMac->scan.NumBkidCandidate = %d", pSession->NumBkidCandidate); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2653 | if( pIes ) |
| 2654 | { |
| 2655 | // check if this is a WAPI BSS |
| 2656 | if( pIes->WAPI.present ) |
| 2657 | { |
| 2658 | // Check if the BSS is capable of doing pre-authentication |
| 2659 | if( pSession->NumBkidCandidate < CSR_MAX_BKID_ALLOWED ) |
| 2660 | { |
| 2661 | |
| 2662 | // if yes, then add to BKIDCandidateList |
| 2663 | status = palCopyMemory(pMac->hHdd, pSession->BkidCandidateInfo[pSession->NumBkidCandidate].BSSID, |
| 2664 | pBssDesc->bssId, WNI_CFG_BSSID_LEN); |
| 2665 | |
| 2666 | if( HAL_STATUS_SUCCESS( status ) ) |
| 2667 | { |
| 2668 | if ( pIes->WAPI.preauth ) |
| 2669 | { |
| 2670 | pSession->BkidCandidateInfo[pSession->NumBkidCandidate].preAuthSupported = eANI_BOOLEAN_TRUE; |
| 2671 | } |
| 2672 | else |
| 2673 | { |
| 2674 | pSession->BkidCandidateInfo[pSession->NumBkidCandidate].preAuthSupported = eANI_BOOLEAN_FALSE; |
| 2675 | } |
| 2676 | pSession->NumBkidCandidate++; |
| 2677 | } |
| 2678 | } |
| 2679 | else |
| 2680 | { |
| 2681 | status = eHAL_STATUS_FAILURE; |
| 2682 | } |
| 2683 | } |
| 2684 | } |
| 2685 | |
| 2686 | return (status); |
| 2687 | } |
| 2688 | |
| 2689 | //This function checks whether new AP is found for the current connected profile |
| 2690 | //if so add to BKIDCandidateList |
| 2691 | tANI_BOOLEAN csrProcessBSSDescForBKIDList(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc, |
| 2692 | tDot11fBeaconIEs *pIes) |
| 2693 | { |
| 2694 | tANI_BOOLEAN fRC = FALSE; |
| 2695 | tDot11fBeaconIEs *pIesLocal = pIes; |
| 2696 | tANI_U32 sessionId; |
| 2697 | tCsrRoamSession *pSession; |
| 2698 | |
| 2699 | if( pIesLocal || HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal)) ) |
| 2700 | { |
| 2701 | for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ ) |
| 2702 | { |
| 2703 | if( CSR_IS_SESSION_VALID( pMac, sessionId) ) |
| 2704 | { |
| 2705 | pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 2706 | if( csrIsConnStateConnectedInfra( pMac, sessionId ) && |
| 2707 | eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == pSession->connectedProfile.AuthType) |
| 2708 | { |
| 2709 | if(csrMatchBSSToConnectProfile(pMac, &pSession->connectedProfile,pBssDesc, pIesLocal)) |
| 2710 | { |
| 2711 | //this new BSS fits the current profile connected |
| 2712 | if(HAL_STATUS_SUCCESS(csrAddBKIDCandidateList(pMac, sessionId, pBssDesc, pIesLocal))) |
| 2713 | { |
| 2714 | fRC = TRUE; |
| 2715 | } |
| 2716 | } |
| 2717 | } |
| 2718 | } |
| 2719 | } |
| 2720 | if(!pIes) |
| 2721 | { |
| 2722 | palFreeMemory(pMac->hHdd, pIesLocal); |
| 2723 | } |
| 2724 | |
| 2725 | } |
| 2726 | return fRC; |
| 2727 | } |
| 2728 | |
| 2729 | #endif |
| 2730 | |
| 2731 | |
| 2732 | static void csrMoveTempScanResultsToMainList( tpAniSirGlobal pMac ) |
| 2733 | { |
| 2734 | tListElem *pEntry; |
| 2735 | tCsrScanResult *pBssDescription; |
| 2736 | tANI_S8 cand_Bss_rssi; |
| 2737 | tANI_BOOLEAN fDupBss; |
| 2738 | #ifdef FEATURE_WLAN_WAPI |
| 2739 | tANI_BOOLEAN fNewWapiBSSForCurConnection = eANI_BOOLEAN_FALSE; |
| 2740 | #endif /* FEATURE_WLAN_WAPI */ |
| 2741 | tDot11fBeaconIEs *pIesLocal = NULL; |
| 2742 | tANI_U32 sessionId = CSR_SESSION_ID_INVALID; |
| 2743 | tAniSSID tmpSsid; |
| 2744 | v_TIME_t timer=0; |
| 2745 | |
| 2746 | tmpSsid.length = 0; |
| 2747 | cand_Bss_rssi = -128; // RSSI coming from PE is -ve |
| 2748 | |
| 2749 | // remove the BSS descriptions from temporary list |
| 2750 | while( ( pEntry = csrLLRemoveTail( &pMac->scan.tempScanResults, LL_ACCESS_LOCK ) ) != NULL) |
| 2751 | { |
| 2752 | pBssDescription = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 2753 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 2754 | smsLog( pMac, LOGW, "...Bssid= %02x-%02x-%02x-%02x-%02x-%02x chan= %d, rssi = -%d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2755 | pBssDescription->Result.BssDescriptor.bssId[ 0 ], pBssDescription->Result.BssDescriptor.bssId[ 1 ], |
| 2756 | pBssDescription->Result.BssDescriptor.bssId[ 2 ], pBssDescription->Result.BssDescriptor.bssId[ 3 ], |
| 2757 | pBssDescription->Result.BssDescriptor.bssId[ 4 ], pBssDescription->Result.BssDescriptor.bssId[ 5 ], |
| 2758 | pBssDescription->Result.BssDescriptor.channelId, |
| 2759 | pBssDescription->Result.BssDescriptor.rssi * (-1) ); |
| 2760 | |
| 2761 | //At this time, pBssDescription->Result.pvIes may be NULL |
| 2762 | pIesLocal = (tDot11fBeaconIEs *)( pBssDescription->Result.pvIes ); |
| 2763 | if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pBssDescription->Result.BssDescriptor, &pIesLocal))) ) |
| 2764 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 2765 | smsLog(pMac, LOGE, FL(" Cannot pared IEs")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2766 | csrFreeScanResultEntry(pMac, pBssDescription); |
| 2767 | continue; |
| 2768 | } |
| 2769 | fDupBss = csrRemoveDupBssDescription( pMac, &pBssDescription->Result.BssDescriptor, pIesLocal, &tmpSsid , &timer ); |
| 2770 | //Check whether we have reach out limit |
| 2771 | if( CSR_SCAN_IS_OVER_BSS_LIMIT(pMac) ) |
| 2772 | { |
| 2773 | //Limit reach |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 2774 | smsLog(pMac, LOGW, FL(" BSS limit reached")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2775 | //Free the resources |
| 2776 | if( (pBssDescription->Result.pvIes == NULL) && pIesLocal ) |
| 2777 | { |
| 2778 | palFreeMemory(pMac->hHdd, pIesLocal); |
| 2779 | } |
| 2780 | csrFreeScanResultEntry(pMac, pBssDescription); |
| 2781 | //Continue because there may be duplicated BSS |
| 2782 | continue; |
| 2783 | } |
| 2784 | // check for duplicate scan results |
| 2785 | if ( !fDupBss ) |
| 2786 | { |
| 2787 | //Found a new BSS |
| 2788 | sessionId = csrProcessBSSDescForPMKIDList(pMac, |
| 2789 | &pBssDescription->Result.BssDescriptor, pIesLocal); |
| 2790 | if( CSR_SESSION_ID_INVALID != sessionId) |
| 2791 | { |
| 2792 | csrRoamCallCallback(pMac, sessionId, NULL, 0, |
| 2793 | eCSR_ROAM_SCAN_FOUND_NEW_BSS, eCSR_ROAM_RESULT_NONE); |
| 2794 | } |
| 2795 | } |
| 2796 | else |
| 2797 | { |
| 2798 | //Check if the new one has SSID it it, if not, use the older SSID if it exists. |
| 2799 | if( (0 == pBssDescription->Result.ssId.length) && tmpSsid.length ) |
| 2800 | { |
| 2801 | //New BSS has a hidden SSID and old one has the SSID. Keep the SSID only |
| 2802 | //if diff of saved SSID time and current time is less than 1 min to avoid |
| 2803 | //side effect of saving SSID with old one is that if AP changes its SSID while remain |
| 2804 | //hidden, we may never see it and also to address the requirement of |
| 2805 | //When we remove hidden ssid from the profile i.e., forget the SSID via |
| 2806 | // GUI that SSID shouldn't see in the profile |
| 2807 | if( (vos_timer_get_system_time() - timer) <= HIDDEN_TIMER) |
| 2808 | { |
| 2809 | pBssDescription->Result.timer = timer; |
| 2810 | pBssDescription->Result.ssId = tmpSsid; |
| 2811 | } |
| 2812 | } |
| 2813 | } |
| 2814 | |
| 2815 | //Tush: find a good AP for 11d info |
| 2816 | if( csrIs11dSupported( pMac ) ) |
| 2817 | { |
| 2818 | if(cand_Bss_rssi < pBssDescription->Result.BssDescriptor.rssi) |
| 2819 | { |
| 2820 | // check if country information element is present |
| 2821 | if(pIesLocal->Country.present) |
| 2822 | { |
| 2823 | cand_Bss_rssi = pBssDescription->Result.BssDescriptor.rssi; |
| 2824 | // learn country information |
| 2825 | csrLearnCountryInformation( pMac, &pBssDescription->Result.BssDescriptor, |
| 2826 | pIesLocal, eANI_BOOLEAN_FALSE ); |
| 2827 | } |
| 2828 | |
| 2829 | } |
| 2830 | } |
| 2831 | |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 2832 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2833 | // append to main list |
| 2834 | csrScanAddResult(pMac, pBssDescription, pIesLocal); |
| 2835 | if( (pBssDescription->Result.pvIes == NULL) && pIesLocal ) |
| 2836 | { |
| 2837 | palFreeMemory(pMac->hHdd, pIesLocal); |
| 2838 | } |
| 2839 | } |
| 2840 | |
| 2841 | //Tush: If we can find the current 11d info in any of the scan results, or |
| 2842 | // a good enough AP with the 11d info from the scan results then no need to |
| 2843 | // get into ambiguous state |
| 2844 | if(pMac->scan.fAmbiguous11dInfoFound) |
| 2845 | { |
| 2846 | if((pMac->scan.fCurrent11dInfoMatch) || (cand_Bss_rssi != -128)) |
| 2847 | { |
| 2848 | pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE; |
| 2849 | } |
| 2850 | } |
| 2851 | |
| 2852 | #ifdef FEATURE_WLAN_WAPI |
| 2853 | if(fNewWapiBSSForCurConnection) |
| 2854 | { |
| 2855 | //remember it first |
| 2856 | csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_SCAN_FOUND_NEW_BSS, eCSR_ROAM_RESULT_NEW_WAPI_BSS); |
| 2857 | } |
| 2858 | #endif /* FEATURE_WLAN_WAPI */ |
| 2859 | |
| 2860 | return; |
| 2861 | } |
| 2862 | |
| 2863 | |
| 2864 | static tCsrScanResult *csrScanSaveBssDescription( tpAniSirGlobal pMac, tSirBssDescription *pBSSDescription, |
| 2865 | tDot11fBeaconIEs *pIes) |
| 2866 | { |
| 2867 | tCsrScanResult *pCsrBssDescription = NULL; |
| 2868 | tANI_U32 cbBSSDesc; |
| 2869 | tANI_U32 cbAllocated; |
| 2870 | eHalStatus halStatus; |
| 2871 | |
| 2872 | // figure out how big the BSS description is (the BSSDesc->length does NOT |
| 2873 | // include the size of the length field itself). |
| 2874 | cbBSSDesc = pBSSDescription->length + sizeof( pBSSDescription->length ); |
| 2875 | |
| 2876 | cbAllocated = sizeof( tCsrScanResult ) + cbBSSDesc; |
| 2877 | |
| 2878 | halStatus = palAllocateMemory( pMac->hHdd, (void **)&pCsrBssDescription, cbAllocated ); |
| 2879 | if ( HAL_STATUS_SUCCESS(halStatus) ) |
| 2880 | { |
| 2881 | palZeroMemory( pMac->hHdd, pCsrBssDescription, cbAllocated ); |
| 2882 | pCsrBssDescription->AgingCount = (tANI_S32)pMac->roam.configParam.agingCount; |
| 2883 | palCopyMemory(pMac->hHdd, &pCsrBssDescription->Result.BssDescriptor, pBSSDescription, cbBSSDesc ); |
| 2884 | #if defined(VOSS_ENSBALED) |
| 2885 | VOS_ASSERT( pCsrBssDescription->Result.pvIes == NULL ); |
| 2886 | #endif |
| 2887 | csrScanAddResult(pMac, pCsrBssDescription, pIes); |
| 2888 | } |
| 2889 | |
| 2890 | return( pCsrBssDescription ); |
| 2891 | } |
| 2892 | |
| 2893 | // Append a Bss Description... |
| 2894 | tCsrScanResult *csrScanAppendBssDescription( tpAniSirGlobal pMac, |
| 2895 | tSirBssDescription *pSirBssDescription, |
| 2896 | tDot11fBeaconIEs *pIes ) |
| 2897 | { |
| 2898 | tCsrScanResult *pCsrBssDescription = NULL; |
| 2899 | tAniSSID tmpSsid; |
| 2900 | v_TIME_t timer = 0; |
| 2901 | int result; |
| 2902 | |
| 2903 | tmpSsid.length = 0; |
| 2904 | result = csrRemoveDupBssDescription( pMac, pSirBssDescription, pIes, &tmpSsid, &timer ); |
| 2905 | pCsrBssDescription = csrScanSaveBssDescription( pMac, pSirBssDescription, pIes ); |
| 2906 | if (result && (pCsrBssDescription != NULL)) |
| 2907 | { |
| 2908 | //Check if the new one has SSID it it, if not, use the older SSID if it exists. |
| 2909 | if( (0 == pCsrBssDescription->Result.ssId.length) && tmpSsid.length ) |
| 2910 | { |
| 2911 | //New BSS has a hidden SSID and old one has the SSID. Keep the SSID only |
| 2912 | //if diff of saved SSID time and current time is less than 1 min to avoid |
| 2913 | //side effect of saving SSID with old one is that if AP changes its SSID while remain |
| 2914 | //hidden, we may never see it and also to address the requirement of |
| 2915 | //When we remove hidden ssid from the profile i.e., forget the SSID via |
| 2916 | // GUI that SSID shouldn't see in the profile |
| 2917 | if((vos_timer_get_system_time()-timer) <= HIDDEN_TIMER) |
| 2918 | { |
| 2919 | pCsrBssDescription->Result.ssId = tmpSsid; |
| 2920 | pCsrBssDescription->Result.timer = timer; |
| 2921 | } |
| 2922 | } |
| 2923 | } |
| 2924 | |
| 2925 | |
| 2926 | return( pCsrBssDescription ); |
| 2927 | } |
| 2928 | |
| 2929 | |
| 2930 | |
| 2931 | void csrPurgeChannelPower( tpAniSirGlobal pMac, tDblLinkList *pChannelList ) |
| 2932 | { |
| 2933 | tCsrChannelPowerInfo *pChannelSet; |
| 2934 | tListElem *pEntry; |
| 2935 | |
| 2936 | csrLLLock(pChannelList); |
| 2937 | // Remove the channel sets from the learned list and put them in the free list |
| 2938 | while( ( pEntry = csrLLRemoveHead( pChannelList, LL_ACCESS_NOLOCK ) ) != NULL) |
| 2939 | { |
| 2940 | pChannelSet = GET_BASE_ADDR( pEntry, tCsrChannelPowerInfo, link ); |
| 2941 | if( pChannelSet ) |
| 2942 | { |
| 2943 | palFreeMemory( pMac->hHdd, pChannelSet ); |
| 2944 | } |
| 2945 | } |
| 2946 | csrLLUnlock(pChannelList); |
| 2947 | return; |
| 2948 | } |
| 2949 | |
| 2950 | |
| 2951 | /* |
| 2952 | * Save the channelList into the ultimate storage as the final stage of channel |
| 2953 | * Input: pCountryInfo -- the country code (e.g. "USI"), channel list, and power limit are all stored inside this data structure |
| 2954 | */ |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2955 | eHalStatus csrSaveToChannelPower2G_5G( tpAniSirGlobal pMac, tANI_U32 tableSize, tSirMacChanInfo *channelTable ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2956 | { |
| 2957 | tANI_U32 i = tableSize / sizeof( tSirMacChanInfo ); |
| 2958 | tSirMacChanInfo *pChannelInfo; |
| 2959 | tCsrChannelPowerInfo *pChannelSet; |
| 2960 | tANI_BOOLEAN f2GHzInfoFound = FALSE; |
| 2961 | tANI_BOOLEAN f2GListPurged = FALSE, f5GListPurged = FALSE; |
| 2962 | eHalStatus halStatus; |
| 2963 | |
| 2964 | pChannelInfo = channelTable; |
| 2965 | // atleast 3 bytes have to be remaining -- from "countryString" |
| 2966 | while ( i-- ) |
| 2967 | { |
| 2968 | halStatus = palAllocateMemory( pMac->hHdd, (void **)&pChannelSet, sizeof(tCsrChannelPowerInfo) ); |
| 2969 | if ( eHAL_STATUS_SUCCESS == halStatus ) |
| 2970 | { |
| 2971 | palZeroMemory(pMac->hHdd, pChannelSet, sizeof(tCsrChannelPowerInfo)); |
| 2972 | pChannelSet->firstChannel = pChannelInfo->firstChanNum; |
| 2973 | pChannelSet->numChannels = pChannelInfo->numChannels; |
| 2974 | |
| 2975 | // 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] | 2976 | if( (CSR_IS_CHANNEL_24GHZ(pChannelSet->firstChannel)) && |
Madan Mohan Koyyalamudi | 5904d7c | 2012-09-24 13:49:03 -0700 | [diff] [blame] | 2977 | ((pChannelSet->firstChannel + (pChannelSet->numChannels - 1)) <= CSR_MAX_24GHz_CHANNEL_NUMBER) ) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2978 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2979 | { |
| 2980 | pChannelSet->interChannelOffset = 1; |
| 2981 | f2GHzInfoFound = TRUE; |
| 2982 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2983 | else if ( (CSR_IS_CHANNEL_5GHZ(pChannelSet->firstChannel)) && |
Madan Mohan Koyyalamudi | 5904d7c | 2012-09-24 13:49:03 -0700 | [diff] [blame] | 2984 | ((pChannelSet->firstChannel + ((pChannelSet->numChannels - 1) * 4)) <= CSR_MAX_5GHz_CHANNEL_NUMBER) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2985 | { |
| 2986 | pChannelSet->interChannelOffset = 4; |
| 2987 | f2GHzInfoFound = FALSE; |
| 2988 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2989 | else |
| 2990 | { |
Madan Mohan Koyyalamudi | 5904d7c | 2012-09-24 13:49:03 -0700 | [diff] [blame] | 2991 | smsLog( pMac, LOGW, FL("Invalid Channel %d Present in Country IE"), |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2992 | pChannelSet->firstChannel); |
| 2993 | palFreeMemory(pMac->hHdd, pChannelSet); |
| 2994 | return eHAL_STATUS_FAILURE; |
| 2995 | } |
| 2996 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2997 | pChannelSet->txPower = CSR_ROAM_MIN( pChannelInfo->maxTxPower, pMac->roam.configParam.nTxPowerCap ); |
| 2998 | |
| 2999 | if( f2GHzInfoFound ) |
| 3000 | { |
| 3001 | if( !f2GListPurged ) |
| 3002 | { |
| 3003 | // purge previous results if found new |
| 3004 | csrPurgeChannelPower( pMac, &pMac->scan.channelPowerInfoList24 ); |
| 3005 | f2GListPurged = TRUE; |
| 3006 | } |
| 3007 | |
| 3008 | if(CSR_IS_OPERATING_BG_BAND(pMac)) |
| 3009 | { |
| 3010 | // add to the list of 2.4 GHz channel sets |
| 3011 | csrLLInsertTail( &pMac->scan.channelPowerInfoList24, &pChannelSet->link, LL_ACCESS_LOCK ); |
| 3012 | } |
| 3013 | else { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 3014 | 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] | 3015 | pChannelSet->firstChannel); |
| 3016 | palFreeMemory(pMac->hHdd, pChannelSet); |
| 3017 | } |
| 3018 | } |
| 3019 | else |
| 3020 | { |
| 3021 | // 5GHz info found |
| 3022 | if( !f5GListPurged ) |
| 3023 | { |
| 3024 | // purge previous results if found new |
| 3025 | csrPurgeChannelPower( pMac, &pMac->scan.channelPowerInfoList5G ); |
| 3026 | f5GListPurged = TRUE; |
| 3027 | } |
| 3028 | |
| 3029 | if(CSR_IS_OPERATING_A_BAND(pMac)) |
| 3030 | { |
| 3031 | // add to the list of 5GHz channel sets |
| 3032 | csrLLInsertTail( &pMac->scan.channelPowerInfoList5G, &pChannelSet->link, LL_ACCESS_LOCK ); |
| 3033 | } |
| 3034 | else { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 3035 | 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] | 3036 | pChannelSet->firstChannel); |
| 3037 | palFreeMemory(pMac->hHdd, pChannelSet); |
| 3038 | } |
| 3039 | } |
| 3040 | } |
| 3041 | |
| 3042 | pChannelInfo++; // move to next entry |
| 3043 | } |
| 3044 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3045 | return eHAL_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3046 | } |
| 3047 | |
| 3048 | |
| 3049 | |
| 3050 | void csrApplyPower2Current( tpAniSirGlobal pMac ) |
| 3051 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 3052 | smsLog( pMac, LOG3, FL(" Updating Cfg with power settings")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3053 | csrSaveTxPowerToCfg( pMac, &pMac->scan.channelPowerInfoList24, WNI_CFG_MAX_TX_POWER_2_4 ); |
| 3054 | csrSaveTxPowerToCfg( pMac, &pMac->scan.channelPowerInfoList5G, WNI_CFG_MAX_TX_POWER_5 ); |
| 3055 | } |
| 3056 | |
| 3057 | |
Gopichand Nakkala | b9185f2 | 2012-12-21 08:03:42 -0800 | [diff] [blame] | 3058 | void csrApplyChannelPowerCountryInfo( tpAniSirGlobal pMac, tCsrChannel *pChannelList, tANI_U8 *countryCode, tANI_BOOLEAN updateRiva) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3059 | { |
| 3060 | int i; |
| 3061 | eNVChannelEnabledType channelEnabledType; |
| 3062 | tANI_U8 numChannels = 0; |
| 3063 | tANI_U8 tempNumChannels = 0; |
| 3064 | tCsrChannel ChannelList; |
| 3065 | if( pChannelList->numChannels ) |
| 3066 | { |
| 3067 | tempNumChannels = CSR_MIN(pChannelList->numChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 3068 | /* If user doesn't want to scan the DFS channels lets trim them from |
| 3069 | the valid channel list*/ |
Madan Mohan Koyyalamudi | 3f65e31 | 2012-11-06 15:31:12 -0800 | [diff] [blame] | 3070 | for(i = 0; i< tempNumChannels; i++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3071 | { |
Madan Mohan Koyyalamudi | 3f65e31 | 2012-11-06 15:31:12 -0800 | [diff] [blame] | 3072 | if(FALSE == pMac->scan.fEnableDFSChnlScan) |
| 3073 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3074 | channelEnabledType = |
| 3075 | vos_nv_getChannelEnabledState(pChannelList->channelList[i]); |
Madan Mohan Koyyalamudi | 3f65e31 | 2012-11-06 15:31:12 -0800 | [diff] [blame] | 3076 | } |
| 3077 | else |
| 3078 | { |
| 3079 | channelEnabledType = NV_CHANNEL_ENABLE; |
| 3080 | } |
| 3081 | if( NV_CHANNEL_ENABLE == channelEnabledType) |
| 3082 | { |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 3083 | // Ignore the channel 165 for the country INDONESIA |
Madan Mohan Koyyalamudi | 895cdee | 2012-11-06 19:13:19 -0800 | [diff] [blame] | 3084 | if (( pChannelList->channelList[i] == 165 ) |
| 3085 | && ( pMac->scan.fIgnore_chan165 == VOS_TRUE ) |
| 3086 | && vos_mem_compare(countryCode, "ID", VOS_COUNTRY_CODE_LEN )) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3087 | { |
Madan Mohan Koyyalamudi | 3f65e31 | 2012-11-06 15:31:12 -0800 | [diff] [blame] | 3088 | continue; |
| 3089 | } |
| 3090 | else |
| 3091 | { |
| 3092 | ChannelList.channelList[numChannels] = pChannelList->channelList[i]; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3093 | numChannels++; |
| 3094 | } |
Madan Mohan Koyyalamudi | 3f65e31 | 2012-11-06 15:31:12 -0800 | [diff] [blame] | 3095 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3096 | } |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 3097 | ChannelList.numChannels = numChannels; |
| 3098 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3099 | csrSetCfgValidChannelList(pMac, ChannelList.channelList, ChannelList.numChannels); |
| 3100 | // extend scan capability |
| 3101 | csrSetCfgScanControlList(pMac, countryCode, &ChannelList); // build a scan list based on the channel list : channel# + active/passive scan |
| 3102 | #ifdef FEATURE_WLAN_SCAN_PNO |
Gopichand Nakkala | b9185f2 | 2012-12-21 08:03:42 -0800 | [diff] [blame] | 3103 | if (updateRiva) |
| 3104 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 3105 | 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] | 3106 | // Send HAL UpdateScanParams message |
| 3107 | pmcUpdateScanParams(pMac, &(pMac->roam.configParam), &ChannelList, TRUE); |
| 3108 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3109 | #endif // FEATURE_WLAN_SCAN_PNO |
| 3110 | } |
| 3111 | else |
| 3112 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 3113 | smsLog( pMac, LOGE, FL(" 11D channel list is empty")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3114 | } |
| 3115 | csrApplyPower2Current( pMac ); // Store the channel+power info in the global place: Cfg |
| 3116 | csrSetCfgCountryCode(pMac, countryCode); |
| 3117 | } |
| 3118 | |
| 3119 | |
Gopichand Nakkala | b9185f2 | 2012-12-21 08:03:42 -0800 | [diff] [blame] | 3120 | void csrResetCountryInformation( tpAniSirGlobal pMac, tANI_BOOLEAN fForce, tANI_BOOLEAN updateRiva ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3121 | { |
| 3122 | if( fForce || (csrIs11dSupported( pMac ) && (!pMac->scan.f11dInfoReset))) |
| 3123 | { |
| 3124 | |
| 3125 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 3126 | { |
| 3127 | vos_log_802_11d_pkt_type *p11dLog; |
| 3128 | int Index; |
| 3129 | |
| 3130 | WLAN_VOS_DIAG_LOG_ALLOC(p11dLog, vos_log_802_11d_pkt_type, LOG_WLAN_80211D_C); |
| 3131 | if(p11dLog) |
| 3132 | { |
| 3133 | p11dLog->eventId = WLAN_80211D_EVENT_RESET; |
| 3134 | palCopyMemory(pMac->hHdd, p11dLog->countryCode, pMac->scan.countryCodeCurrent, 3); |
| 3135 | p11dLog->numChannel = pMac->scan.base20MHzChannels.numChannels; |
| 3136 | if(p11dLog->numChannel <= VOS_LOG_MAX_NUM_CHANNEL) |
| 3137 | { |
| 3138 | palCopyMemory(pMac->hHdd, p11dLog->Channels, pMac->scan.base20MHzChannels.channelList, |
| 3139 | p11dLog->numChannel); |
| 3140 | for (Index=0; Index < pMac->scan.base20MHzChannels.numChannels; Index++) |
| 3141 | { |
| 3142 | p11dLog->TxPwr[Index] = CSR_ROAM_MIN( pMac->scan.defaultPowerTable[Index].pwr, pMac->roam.configParam.nTxPowerCap ); |
| 3143 | } |
| 3144 | } |
| 3145 | if(!pMac->roam.configParam.Is11dSupportEnabled) |
| 3146 | { |
| 3147 | p11dLog->supportMultipleDomain = WLAN_80211D_DISABLED; |
| 3148 | } |
| 3149 | else if(pMac->roam.configParam.fEnforceDefaultDomain) |
| 3150 | { |
| 3151 | p11dLog->supportMultipleDomain = WLAN_80211D_NOT_SUPPORT_MULTI_DOMAIN; |
| 3152 | } |
| 3153 | else |
| 3154 | { |
| 3155 | p11dLog->supportMultipleDomain = WLAN_80211D_SUPPORT_MULTI_DOMAIN; |
| 3156 | } |
| 3157 | WLAN_VOS_DIAG_LOG_REPORT(p11dLog); |
| 3158 | } |
| 3159 | } |
| 3160 | #endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 3161 | |
| 3162 | // switch to passive scans only when 11d is enabled |
| 3163 | if( csrIs11dSupported( pMac ) ) |
| 3164 | { |
| 3165 | pMac->scan.curScanType = eSIR_PASSIVE_SCAN; |
| 3166 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3167 | |
| 3168 | csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels); |
| 3169 | csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels); |
| 3170 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3171 | csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE); |
| 3172 | csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE); |
| 3173 | // ... and apply the channel list, power settings, and the country code. |
Gopichand Nakkala | b9185f2 | 2012-12-21 08:03:42 -0800 | [diff] [blame] | 3174 | csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, updateRiva ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3175 | // clear the 11d channel list |
| 3176 | palZeroMemory( pMac->hHdd, &pMac->scan.channels11d, sizeof(pMac->scan.channels11d) ); |
| 3177 | pMac->scan.f11dInfoReset = eANI_BOOLEAN_TRUE; |
| 3178 | pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE; |
| 3179 | } |
| 3180 | |
| 3181 | return; |
| 3182 | } |
| 3183 | |
| 3184 | |
| 3185 | eHalStatus csrResetCountryCodeInformation(tpAniSirGlobal pMac, tANI_BOOLEAN *pfRestartNeeded) |
| 3186 | { |
| 3187 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 3188 | tANI_BOOLEAN fRestart = eANI_BOOLEAN_FALSE; |
| 3189 | |
| 3190 | //Use the Country code and domain from EEPROM |
| 3191 | palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN); |
| 3192 | csrSetRegulatoryDomain(pMac, pMac->scan.domainIdCurrent, &fRestart); |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 3193 | if( ((eANI_BOOLEAN_FALSE == fRestart) || (pfRestartNeeded == NULL) ) |
| 3194 | && !csrIsInfraConnected(pMac)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3195 | { |
| 3196 | //Only reset the country info if we don't need to restart |
Gopichand Nakkala | b9185f2 | 2012-12-21 08:03:42 -0800 | [diff] [blame] | 3197 | csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3198 | } |
| 3199 | if(pfRestartNeeded) |
| 3200 | { |
| 3201 | *pfRestartNeeded = fRestart; |
| 3202 | } |
| 3203 | |
| 3204 | return (status); |
| 3205 | } |
| 3206 | |
| 3207 | |
| 3208 | eHalStatus csrSetCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry, tANI_BOOLEAN *pfRestartNeeded) |
| 3209 | { |
| 3210 | eHalStatus status = eHAL_STATUS_INVALID_PARAMETER; |
| 3211 | v_REGDOMAIN_t domainId; |
| 3212 | |
| 3213 | if(pCountry) |
| 3214 | { |
| 3215 | status = csrGetRegulatoryDomainForCountry(pMac, pCountry, &domainId); |
| 3216 | if(HAL_STATUS_SUCCESS(status)) |
| 3217 | { |
| 3218 | status = csrSetRegulatoryDomain(pMac, domainId, pfRestartNeeded); |
| 3219 | if(HAL_STATUS_SUCCESS(status)) |
| 3220 | { |
| 3221 | //We don't need to check the pMac->roam.configParam.fEnforceDefaultDomain flag here, |
| 3222 | //csrSetRegulatoryDomain will fail if the country doesn't fit our domain criteria. |
| 3223 | palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent, pCountry, WNI_CFG_COUNTRY_CODE_LEN); |
| 3224 | if((pfRestartNeeded == NULL) || !(*pfRestartNeeded)) |
| 3225 | { |
| 3226 | //Simply set it to cfg. If we need to restart, restart will apply it to the CFG |
| 3227 | csrSetCfgCountryCode(pMac, pCountry); |
| 3228 | } |
| 3229 | } |
| 3230 | } |
| 3231 | } |
| 3232 | |
| 3233 | return (status); |
| 3234 | } |
| 3235 | |
| 3236 | |
| 3237 | |
| 3238 | //caller allocated memory for pNumChn and pChnPowerInfo |
| 3239 | //As input, *pNumChn has the size of the array of pChnPowerInfo |
| 3240 | //Upon return, *pNumChn has the number of channels assigned. |
| 3241 | void csrGetChannelPowerInfo( tpAniSirGlobal pMac, tDblLinkList *pList, |
| 3242 | tANI_U32 *pNumChn, tChannelListWithPower *pChnPowerInfo) |
| 3243 | { |
| 3244 | tListElem *pEntry; |
| 3245 | tANI_U32 chnIdx = 0, idx; |
| 3246 | tCsrChannelPowerInfo *pChannelSet; |
| 3247 | |
| 3248 | //Get 2.4Ghz first |
| 3249 | pEntry = csrLLPeekHead( pList, LL_ACCESS_LOCK ); |
| 3250 | while( pEntry && (chnIdx < *pNumChn) ) |
| 3251 | { |
| 3252 | pChannelSet = GET_BASE_ADDR( pEntry, tCsrChannelPowerInfo, link ); |
| 3253 | if ( 1 != pChannelSet->interChannelOffset ) |
| 3254 | { |
| 3255 | for( idx = 0; (idx < pChannelSet->numChannels) && (chnIdx < *pNumChn); idx++ ) |
| 3256 | { |
| 3257 | pChnPowerInfo[chnIdx].chanId = (tANI_U8)(pChannelSet->firstChannel + ( idx * pChannelSet->interChannelOffset )); |
| 3258 | pChnPowerInfo[chnIdx++].pwr = pChannelSet->txPower; |
| 3259 | } |
| 3260 | } |
| 3261 | else |
| 3262 | { |
| 3263 | for( idx = 0; (idx < pChannelSet->numChannels) && (chnIdx < *pNumChn); idx++ ) |
| 3264 | { |
| 3265 | pChnPowerInfo[chnIdx].chanId = (tANI_U8)(pChannelSet->firstChannel + idx); |
| 3266 | pChnPowerInfo[chnIdx++].pwr = pChannelSet->txPower; |
| 3267 | } |
| 3268 | } |
| 3269 | |
| 3270 | pEntry = csrLLNext( pList, pEntry, LL_ACCESS_LOCK ); |
| 3271 | } |
| 3272 | *pNumChn = chnIdx; |
| 3273 | |
| 3274 | return ; |
| 3275 | } |
| 3276 | |
| 3277 | |
| 3278 | |
| 3279 | void csrApplyCountryInformation( tpAniSirGlobal pMac, tANI_BOOLEAN fForce ) |
| 3280 | { |
| 3281 | v_REGDOMAIN_t domainId; |
| 3282 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 3283 | |
| 3284 | do |
| 3285 | { |
| 3286 | if( !csrIs11dSupported( pMac ) || 0 == pMac->scan.channelOf11dInfo) break; |
| 3287 | if( pMac->scan.fAmbiguous11dInfoFound ) |
| 3288 | { |
| 3289 | // ambiguous info found |
| 3290 | //Restore te default domain as well |
| 3291 | if(HAL_STATUS_SUCCESS(csrGetRegulatoryDomainForCountry( pMac, pMac->scan.countryCodeCurrent, &domainId ))) |
| 3292 | { |
| 3293 | pMac->scan.domainIdCurrent = domainId; |
| 3294 | } |
| 3295 | else |
| 3296 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 3297 | smsLog(pMac, LOGE, FL(" failed to get domain from currentCountryCode %02X%02X"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3298 | pMac->scan.countryCodeCurrent[0], pMac->scan.countryCodeCurrent[1]); |
| 3299 | } |
Gopichand Nakkala | b9185f2 | 2012-12-21 08:03:42 -0800 | [diff] [blame] | 3300 | csrResetCountryInformation( pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_TRUE ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3301 | break; |
| 3302 | } |
| 3303 | if ( pMac->scan.f11dInfoApplied && !fForce ) break; |
| 3304 | if(HAL_STATUS_SUCCESS(csrGetRegulatoryDomainForCountry( pMac, pMac->scan.countryCode11d, &domainId ))) |
| 3305 | { |
| 3306 | //Check whether we need to enforce default domain |
| 3307 | if( ( !pMac->roam.configParam.fEnforceDefaultDomain ) || |
| 3308 | (pMac->scan.domainIdCurrent == domainId) ) |
| 3309 | { |
| 3310 | |
| 3311 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 3312 | { |
| 3313 | vos_log_802_11d_pkt_type *p11dLog; |
| 3314 | tChannelListWithPower chnPwrInfo[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 3315 | tANI_U32 nChnInfo = WNI_CFG_VALID_CHANNEL_LIST_LEN, nTmp; |
| 3316 | |
| 3317 | WLAN_VOS_DIAG_LOG_ALLOC(p11dLog, vos_log_802_11d_pkt_type, LOG_WLAN_80211D_C); |
| 3318 | if(p11dLog) |
| 3319 | { |
| 3320 | p11dLog->eventId = WLAN_80211D_EVENT_COUNTRY_SET; |
| 3321 | palCopyMemory(pMac->hHdd, p11dLog->countryCode, pMac->scan.countryCode11d, 3); |
| 3322 | p11dLog->numChannel = pMac->scan.channels11d.numChannels; |
| 3323 | if(p11dLog->numChannel <= VOS_LOG_MAX_NUM_CHANNEL) |
| 3324 | { |
| 3325 | palCopyMemory(pMac->hHdd, p11dLog->Channels, pMac->scan.channels11d.channelList, |
| 3326 | p11dLog->numChannel); |
| 3327 | csrGetChannelPowerInfo(pMac, &pMac->scan.channelPowerInfoList24, |
| 3328 | &nChnInfo, chnPwrInfo); |
| 3329 | nTmp = nChnInfo; |
| 3330 | nChnInfo = WNI_CFG_VALID_CHANNEL_LIST_LEN - nTmp; |
| 3331 | csrGetChannelPowerInfo(pMac, &pMac->scan.channelPowerInfoList5G, |
| 3332 | &nChnInfo, &chnPwrInfo[nTmp]); |
| 3333 | for(nTmp = 0; nTmp < p11dLog->numChannel; nTmp++) |
| 3334 | { |
| 3335 | for(nChnInfo = 0; nChnInfo < WNI_CFG_VALID_CHANNEL_LIST_LEN; nChnInfo++) |
| 3336 | { |
| 3337 | if(p11dLog->Channels[nTmp] == chnPwrInfo[nChnInfo].chanId) |
| 3338 | { |
| 3339 | p11dLog->TxPwr[nTmp] = chnPwrInfo[nChnInfo].pwr; |
| 3340 | break; |
| 3341 | } |
| 3342 | } |
| 3343 | } |
| 3344 | } |
| 3345 | if(!pMac->roam.configParam.Is11dSupportEnabled) |
| 3346 | { |
| 3347 | p11dLog->supportMultipleDomain = WLAN_80211D_DISABLED; |
| 3348 | } |
| 3349 | else if(pMac->roam.configParam.fEnforceDefaultDomain) |
| 3350 | { |
| 3351 | p11dLog->supportMultipleDomain = WLAN_80211D_NOT_SUPPORT_MULTI_DOMAIN; |
| 3352 | } |
| 3353 | else |
| 3354 | { |
| 3355 | p11dLog->supportMultipleDomain = WLAN_80211D_SUPPORT_MULTI_DOMAIN; |
| 3356 | } |
| 3357 | WLAN_VOS_DIAG_LOG_REPORT(p11dLog); |
| 3358 | } |
| 3359 | } |
| 3360 | #endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 3361 | if(pMac->scan.domainIdCurrent != domainId) |
| 3362 | { |
| 3363 | /* Regulatory Domain Changed, Purge Only scan result |
| 3364 | * which does not have channel number belong to 11d |
| 3365 | * channel list |
| 3366 | * */ |
| 3367 | smsLog(pMac, LOGW, FL("Domain Changed Old %d, new %d"), |
| 3368 | pMac->scan.domainIdCurrent, domainId); |
| 3369 | csrScanFilter11dResult(pMac); |
| 3370 | } |
| 3371 | status = WDA_SetRegDomain(pMac, domainId); |
| 3372 | if (status != eHAL_STATUS_SUCCESS) |
| 3373 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 3374 | smsLog( pMac, LOGE, FL(" fail to set regId %d"), domainId ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3375 | } |
| 3376 | pMac->scan.domainIdCurrent = domainId; |
Gopichand Nakkala | b9185f2 | 2012-12-21 08:03:42 -0800 | [diff] [blame] | 3377 | csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.channels11d, pMac->scan.countryCode11d, eANI_BOOLEAN_TRUE ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3378 | // switch to active scans using this new channel list |
| 3379 | pMac->scan.curScanType = eSIR_ACTIVE_SCAN; |
| 3380 | pMac->scan.f11dInfoApplied = eANI_BOOLEAN_TRUE; |
| 3381 | pMac->scan.f11dInfoReset = eANI_BOOLEAN_FALSE; |
| 3382 | } |
| 3383 | } |
| 3384 | |
| 3385 | } while( 0 ); |
| 3386 | |
| 3387 | return; |
| 3388 | } |
| 3389 | |
| 3390 | |
| 3391 | |
| 3392 | tANI_BOOLEAN csrSave11dCountryString( tpAniSirGlobal pMac, tANI_U8 *pCountryCode, |
| 3393 | tANI_BOOLEAN fForce) |
| 3394 | { |
| 3395 | tANI_BOOLEAN fCountryStringChanged = FALSE, fUnknownCountryCode = FALSE; |
| 3396 | tANI_U32 i; |
| 3397 | |
| 3398 | // convert to UPPER here so we are assured the strings are always in upper case. |
| 3399 | for( i = 0; i < 3; i++ ) |
| 3400 | { |
| 3401 | pCountryCode[ i ] = (tANI_U8)csrToUpper( pCountryCode[ i ] ); |
| 3402 | } |
| 3403 | |
| 3404 | // Some of the 'old' Cisco 350 series AP's advertise NA as the country code (for North America ??). |
| 3405 | // NA is not a valid country code or domain so let's allow this by changing it to the proper |
| 3406 | // country code (which is US). We've also seen some NETGEAR AP's that have "XX " as the country code |
| 3407 | // with valid 2.4 GHz US channel information. If we cannot find the country code advertised in the |
| 3408 | // 11d information element, let's default to US. |
| 3409 | if ( !HAL_STATUS_SUCCESS(csrGetRegulatoryDomainForCountry( pMac, pCountryCode, NULL ) ) ) |
| 3410 | { |
| 3411 | // Check the enforcement first |
| 3412 | if( pMac->roam.configParam.fEnforceDefaultDomain || pMac->roam.configParam.fEnforceCountryCodeMatch ) |
| 3413 | { |
| 3414 | fUnknownCountryCode = TRUE; |
| 3415 | } |
| 3416 | else |
| 3417 | { |
| 3418 | pCountryCode[ 0 ] = 'U'; |
| 3419 | pCountryCode[ 1 ] = 'S'; |
| 3420 | } |
| 3421 | } |
| 3422 | |
| 3423 | // We've seen some of the AP's improperly put a 0 for the third character of the country code. |
| 3424 | // spec says valid charcters are 'O' (for outdoor), 'I' for Indoor, or ' ' (space; for either). |
| 3425 | // if we see a 0 in this third character, let's change it to a ' '. |
| 3426 | if ( 0 == pCountryCode[ 2 ] ) |
| 3427 | { |
| 3428 | pCountryCode[ 2 ] = ' '; |
| 3429 | } |
| 3430 | |
| 3431 | if( !fUnknownCountryCode ) |
| 3432 | { |
| 3433 | fCountryStringChanged = (!palEqualMemory( pMac->hHdd, |
| 3434 | pMac->scan.countryCode11d, pCountryCode, 2)); |
| 3435 | |
| 3436 | |
| 3437 | if(( 0 == pMac->scan.countryCode11d[ 0 ] && 0 == pMac->scan.countryCode11d[ 1 ] ) |
| 3438 | || (fForce)) |
| 3439 | { |
| 3440 | // this is the first .11d information |
| 3441 | palCopyMemory( pMac->hHdd, pMac->scan.countryCode11d, pCountryCode, sizeof( pMac->scan.countryCode11d ) ); |
| 3442 | } |
| 3443 | } |
| 3444 | |
| 3445 | return( fCountryStringChanged ); |
| 3446 | } |
| 3447 | |
| 3448 | |
| 3449 | void csrSaveChannelPowerForBand( tpAniSirGlobal pMac, tANI_BOOLEAN fPopulate5GBand ) |
| 3450 | { |
| 3451 | tANI_U32 Index, count=0; |
| 3452 | tSirMacChanInfo *pChanInfo; |
| 3453 | tSirMacChanInfo *pChanInfoStart; |
Leela V Kiran Kumar Reddy Chirala | 6a45875 | 2013-02-16 15:41:27 -0800 | [diff] [blame] | 3454 | tANI_S32 maxChannelIndex; |
| 3455 | |
| 3456 | maxChannelIndex = ( pMac->scan.base20MHzChannels.numChannels < WNI_CFG_VALID_CHANNEL_LIST_LEN ) ? |
| 3457 | pMac->scan.base20MHzChannels.numChannels : WNI_CFG_VALID_CHANNEL_LIST_LEN ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3458 | |
| 3459 | if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN))) |
| 3460 | { |
| 3461 | palZeroMemory(pMac->hHdd, pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 3462 | pChanInfoStart = pChanInfo; |
Leela V Kiran Kumar Reddy Chirala | 6a45875 | 2013-02-16 15:41:27 -0800 | [diff] [blame] | 3463 | for (Index=0; Index < maxChannelIndex; Index++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3464 | { |
| 3465 | if ((fPopulate5GBand && (CSR_IS_CHANNEL_5GHZ(pMac->scan.defaultPowerTable[Index].chanId))) || |
| 3466 | (!fPopulate5GBand && (CSR_IS_CHANNEL_24GHZ(pMac->scan.defaultPowerTable[Index].chanId))) ) |
| 3467 | { |
Leela V Kiran Kumar Reddy Chirala | 6a45875 | 2013-02-16 15:41:27 -0800 | [diff] [blame] | 3468 | if(count >= WNI_CFG_VALID_CHANNEL_LIST_LEN) |
| 3469 | { |
| 3470 | smsLog( pMac, LOGW, FL(" csrSaveChannelPowerForBand, count exceeded, count = %d"), count); |
| 3471 | break; |
| 3472 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3473 | pChanInfo->firstChanNum = pMac->scan.defaultPowerTable[Index].chanId; |
| 3474 | pChanInfo->numChannels = 1; |
| 3475 | pChanInfo->maxTxPower = CSR_ROAM_MIN( pMac->scan.defaultPowerTable[Index].pwr, pMac->roam.configParam.nTxPowerCap ); |
| 3476 | pChanInfo++; |
| 3477 | count++; |
| 3478 | } |
| 3479 | } |
| 3480 | if(count) |
| 3481 | { |
| 3482 | csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart ); |
| 3483 | } |
| 3484 | palFreeMemory(pMac->hHdd, pChanInfoStart); |
| 3485 | } |
| 3486 | } |
| 3487 | |
| 3488 | |
| 3489 | void csrSetOppositeBandChannelInfo( tpAniSirGlobal pMac ) |
| 3490 | { |
| 3491 | tANI_BOOLEAN fPopulate5GBand = FALSE; |
| 3492 | |
| 3493 | do |
| 3494 | { |
| 3495 | // if this is not a dual band product, then we don't need to set the opposite |
| 3496 | // band info. We only work in one band so no need to look in the other band. |
| 3497 | if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) ) break; |
| 3498 | // if we found channel info on the 5.0 band and... |
| 3499 | if ( CSR_IS_CHANNEL_5GHZ( pMac->scan.channelOf11dInfo ) ) |
| 3500 | { |
| 3501 | // and the 2.4 band is empty, then populate the 2.4 channel info |
| 3502 | if ( !csrLLIsListEmpty( &pMac->scan.channelPowerInfoList24, LL_ACCESS_LOCK ) ) break; |
| 3503 | fPopulate5GBand = FALSE; |
| 3504 | } |
| 3505 | else |
| 3506 | { |
| 3507 | // else, we found channel info in the 2.4 GHz band. If the 5.0 band is empty |
| 3508 | // set the 5.0 band info from the 2.4 country code. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3509 | fPopulate5GBand = TRUE; |
| 3510 | } |
| 3511 | csrSaveChannelPowerForBand( pMac, fPopulate5GBand ); |
| 3512 | |
| 3513 | } while( 0 ); |
| 3514 | } |
| 3515 | |
| 3516 | |
| 3517 | tANI_BOOLEAN csrIsSupportedChannel(tpAniSirGlobal pMac, tANI_U8 channelId) |
| 3518 | { |
| 3519 | tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE; |
| 3520 | tANI_U32 i; |
| 3521 | |
| 3522 | //Make sure it is a channel that is in our supported list. |
| 3523 | for ( i = 0; i < pMac->scan.baseChannels.numChannels; i++ ) |
| 3524 | { |
| 3525 | if ( channelId == pMac->scan.baseChannels.channelList[i] ) |
| 3526 | { |
| 3527 | fRet = eANI_BOOLEAN_TRUE; |
| 3528 | break; |
| 3529 | } |
| 3530 | } |
| 3531 | |
| 3532 | //If it is configured to limit a set of the channels |
| 3533 | if( fRet && pMac->roam.configParam.fEnforce11dChannels ) |
| 3534 | { |
| 3535 | fRet = eANI_BOOLEAN_FALSE; |
| 3536 | for ( i = 0; i < pMac->scan.base20MHzChannels.numChannels; i++ ) |
| 3537 | { |
| 3538 | if ( channelId == pMac->scan.base20MHzChannels.channelList[i] ) |
| 3539 | { |
| 3540 | fRet = eANI_BOOLEAN_TRUE; |
| 3541 | break; |
| 3542 | } |
| 3543 | } |
| 3544 | } |
| 3545 | |
| 3546 | return (fRet); |
| 3547 | } |
| 3548 | |
| 3549 | |
| 3550 | |
| 3551 | //bSize specify the buffer size of pChannelList |
| 3552 | tANI_U8 csrGetChannelListFromChannelSet( tpAniSirGlobal pMac, tANI_U8 *pChannelList, tANI_U8 bSize, tCsrChannelPowerInfo *pChannelSet ) |
| 3553 | { |
| 3554 | tANI_U8 i, j = 0, chnId; |
| 3555 | |
| 3556 | bSize = CSR_MIN(bSize, pChannelSet->numChannels); |
| 3557 | for( i = 0; i < bSize; i++ ) |
| 3558 | { |
| 3559 | chnId = (tANI_U8)(pChannelSet->firstChannel + ( i * pChannelSet->interChannelOffset )); |
| 3560 | if ( csrIsSupportedChannel( pMac, chnId ) ) |
| 3561 | { |
| 3562 | pChannelList[j++] = chnId; |
| 3563 | } |
| 3564 | } |
| 3565 | |
| 3566 | return (j); |
| 3567 | } |
| 3568 | |
| 3569 | |
| 3570 | |
| 3571 | //bSize -- specify the buffer size of pChannelList |
| 3572 | void csrConstructCurrentValidChannelList( tpAniSirGlobal pMac, tDblLinkList *pChannelSetList, |
| 3573 | tANI_U8 *pChannelList, tANI_U8 bSize, tANI_U8 *pNumChannels ) |
| 3574 | { |
| 3575 | tListElem *pEntry; |
| 3576 | tCsrChannelPowerInfo *pChannelSet; |
| 3577 | tANI_U8 numChannels; |
| 3578 | tANI_U8 *pChannels; |
| 3579 | |
| 3580 | if( pChannelSetList && pChannelList && pNumChannels ) |
| 3581 | { |
| 3582 | pChannels = pChannelList; |
| 3583 | *pNumChannels = 0; |
| 3584 | pEntry = csrLLPeekHead( pChannelSetList, LL_ACCESS_LOCK ); |
| 3585 | while( pEntry ) |
| 3586 | { |
| 3587 | pChannelSet = GET_BASE_ADDR( pEntry, tCsrChannelPowerInfo, link ); |
| 3588 | numChannels = csrGetChannelListFromChannelSet( pMac, pChannels, bSize, pChannelSet ); |
| 3589 | pChannels += numChannels; |
| 3590 | *pNumChannels += numChannels; |
| 3591 | pEntry = csrLLNext( pChannelSetList, pEntry, LL_ACCESS_LOCK ); |
| 3592 | } |
| 3593 | } |
| 3594 | } |
| 3595 | |
| 3596 | |
| 3597 | /* |
| 3598 | * 802.11D only: Gather 11d IE via beacon or Probe response and store them in pAdapter->channels11d |
| 3599 | */ |
| 3600 | tANI_BOOLEAN csrLearnCountryInformation( tpAniSirGlobal pMac, tSirBssDescription *pSirBssDesc, |
| 3601 | tDot11fBeaconIEs *pIes, tANI_BOOLEAN fForce) |
| 3602 | { |
| 3603 | tANI_U8 Num2GChannels, bMaxNumChn; |
| 3604 | eHalStatus status; |
| 3605 | tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE; |
| 3606 | v_REGDOMAIN_t domainId; |
| 3607 | tDot11fBeaconIEs *pIesLocal = pIes; |
| 3608 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3609 | if (VOS_STA_SAP_MODE == vos_get_conparam ()) |
| 3610 | return eHAL_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3611 | |
| 3612 | do |
| 3613 | { |
| 3614 | // check if .11d support is enabled |
| 3615 | if( !csrIs11dSupported( pMac ) ) break; |
| 3616 | if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) ) |
| 3617 | { |
| 3618 | break; |
| 3619 | } |
| 3620 | // check if country information element is present |
| 3621 | if(!pIesLocal->Country.present) |
| 3622 | { |
| 3623 | //No country info |
| 3624 | break; |
| 3625 | } |
| 3626 | |
| 3627 | if( csrSave11dCountryString( pMac, pIesLocal->Country.country, fForce ) ) |
| 3628 | { |
| 3629 | // country string changed, this should not happen |
| 3630 | //Need to check whether we care about this BSS' domain info |
| 3631 | //If it doesn't match of the connected profile or roaming profile, let's ignore it |
| 3632 | tANI_U32 i; |
| 3633 | tCsrRoamSession *pSession; |
| 3634 | |
| 3635 | for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ ) |
| 3636 | { |
| 3637 | if( CSR_IS_SESSION_VALID( pMac, i ) ) |
| 3638 | { |
| 3639 | pSession = CSR_GET_SESSION( pMac, i ); |
| 3640 | if(pSession->pCurRoamProfile) |
| 3641 | { |
| 3642 | tCsrScanResultFilter filter; |
| 3643 | |
| 3644 | palZeroMemory(pMac->hHdd, &filter, sizeof(tCsrScanResultFilter)); |
| 3645 | status = csrRoamPrepareFilterFromProfile(pMac, pSession->pCurRoamProfile, &filter); |
| 3646 | if(HAL_STATUS_SUCCESS(status)) |
| 3647 | { |
| 3648 | tANI_BOOLEAN fMatch = csrMatchBSS(pMac, pSirBssDesc, &filter, NULL, NULL, NULL, NULL); |
| 3649 | //Free the resource first |
| 3650 | csrFreeScanFilter( pMac, &filter ); |
| 3651 | if(fMatch) |
| 3652 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 3653 | smsLog(pMac, LOGW, " Matching roam profile BSSID %02X-%02X-%02X-%02X-%02X-%02X causing ambiguous domain info", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3654 | pSirBssDesc->bssId[0], pSirBssDesc->bssId[1], pSirBssDesc->bssId[2], |
| 3655 | pSirBssDesc->bssId[3], pSirBssDesc->bssId[4], pSirBssDesc->bssId[5]); |
| 3656 | pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_TRUE; |
| 3657 | break; |
| 3658 | } |
| 3659 | } |
| 3660 | } |
| 3661 | else if( csrIsConnStateConnected(pMac, i)) |
| 3662 | { |
| 3663 | //Reach here only when the currention is base on no profile. |
| 3664 | //User doesn't give profile and just connect to anything. |
| 3665 | if(csrMatchBSSToConnectProfile(pMac, &pSession->connectedProfile, pSirBssDesc, pIesLocal)) |
| 3666 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 3667 | smsLog(pMac, LOGW, " Matching connect profile BSSID %02X-%02X-%02X-%02X-%02X-%02X causing ambiguous domain info", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3668 | pSirBssDesc->bssId[0], pSirBssDesc->bssId[1], pSirBssDesc->bssId[2], |
| 3669 | pSirBssDesc->bssId[3], pSirBssDesc->bssId[4], pSirBssDesc->bssId[5]); |
| 3670 | //Tush |
| 3671 | pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_TRUE; |
| 3672 | if(csrIsBssidMatch(pMac, (tCsrBssid *)&pSirBssDesc->bssId, |
| 3673 | &pSession->connectedProfile.bssid)) |
| 3674 | { |
| 3675 | //AP changed the 11d info on the fly, modify cfg |
| 3676 | pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE; |
| 3677 | fRet = eANI_BOOLEAN_TRUE; |
| 3678 | } |
| 3679 | break; |
| 3680 | } |
| 3681 | } |
| 3682 | } //valid session |
| 3683 | } //for |
| 3684 | if ( i == CSR_ROAM_SESSION_MAX ) |
| 3685 | { |
| 3686 | //Check whether we can use this country's 11d information |
| 3687 | if( !pMac->roam.configParam.fEnforceDefaultDomain ) |
| 3688 | { |
| 3689 | pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_TRUE; |
| 3690 | } |
| 3691 | else |
| 3692 | { |
| 3693 | VOS_ASSERT( pMac->scan.domainIdCurrent == pMac->scan.domainIdDefault ); |
| 3694 | if( HAL_STATUS_SUCCESS(csrGetRegulatoryDomainForCountry( |
| 3695 | pMac, pIesLocal->Country.country, &domainId )) && |
| 3696 | ( domainId == pMac->scan.domainIdCurrent ) ) |
| 3697 | { |
| 3698 | //Two countries in the same domain |
| 3699 | } |
| 3700 | } |
| 3701 | } |
| 3702 | } |
| 3703 | else //Tush |
| 3704 | { |
| 3705 | pMac->scan.fCurrent11dInfoMatch = eANI_BOOLEAN_TRUE; |
| 3706 | } |
| 3707 | |
| 3708 | //In case that some channels in 5GHz have the same channel number as 2.4GHz (<= 14) |
| 3709 | if(CSR_IS_CHANNEL_5GHZ(pSirBssDesc->channelId)) |
| 3710 | { |
| 3711 | tANI_U8 iC; |
| 3712 | tSirMacChanInfo* pMacChnSet = (tSirMacChanInfo *)(&pIesLocal->Country.triplets[0]); |
| 3713 | |
| 3714 | for(iC = 0; iC < pIesLocal->Country.num_triplets; iC++) |
| 3715 | { |
| 3716 | if(CSR_IS_CHANNEL_24GHZ(pMacChnSet[iC].firstChanNum)) |
| 3717 | { |
| 3718 | pMacChnSet[iC].firstChanNum += 200; //*** Where is this 200 defined? |
| 3719 | } |
| 3720 | } |
| 3721 | } |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 3722 | smsLog(pMac, LOG3, FL(" %d sets each one is %d"), pIesLocal->Country.num_triplets, sizeof(tSirMacChanInfo)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3723 | // save the channel/power information from the Channel IE. |
| 3724 | //sizeof(tSirMacChanInfo) has to be 3 |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3725 | if (eHAL_STATUS_SUCCESS != csrSaveToChannelPower2G_5G( pMac, pIesLocal->Country.num_triplets * sizeof(tSirMacChanInfo), |
| 3726 | (tSirMacChanInfo *)(&pIesLocal->Country.triplets[0]) )) |
| 3727 | { |
| 3728 | fRet = eANI_BOOLEAN_FALSE; |
| 3729 | return fRet; |
| 3730 | } |
| 3731 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3732 | // set the indicator of the channel where the country IE was found... |
| 3733 | pMac->scan.channelOf11dInfo = pSirBssDesc->channelId; |
Venkata Prathyusha Kuntupalli | 9778fb3 | 2013-02-26 22:16:52 -0800 | [diff] [blame] | 3734 | csrGetRegulatoryDomainForCountry(pMac, pIesLocal->Country.country, &domainId ); |
| 3735 | if ( domainId != pMac->scan.domainIdCurrent ) |
| 3736 | { |
| 3737 | WDA_SetRegDomain(pMac, domainId); |
| 3738 | csrGet5GChannels(pMac ); |
| 3739 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3740 | // Populate both band channel lists based on what we found in the country information... |
| 3741 | csrSetOppositeBandChannelInfo( pMac ); |
| 3742 | bMaxNumChn = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 3743 | // construct 2GHz channel list first |
| 3744 | csrConstructCurrentValidChannelList( pMac, &pMac->scan.channelPowerInfoList24, pMac->scan.channels11d.channelList, |
| 3745 | bMaxNumChn, &Num2GChannels ); |
| 3746 | // construct 5GHz channel list now |
| 3747 | if(bMaxNumChn > Num2GChannels) |
| 3748 | { |
| 3749 | csrConstructCurrentValidChannelList( pMac, &pMac->scan.channelPowerInfoList5G, pMac->scan.channels11d.channelList + Num2GChannels, |
| 3750 | bMaxNumChn - Num2GChannels, |
| 3751 | &pMac->scan.channels11d.numChannels ); |
| 3752 | } |
| 3753 | |
| 3754 | pMac->scan.channels11d.numChannels += Num2GChannels; |
| 3755 | fRet = eANI_BOOLEAN_TRUE; |
| 3756 | |
| 3757 | } while( 0 ); |
| 3758 | |
| 3759 | if( !pIes && pIesLocal ) |
| 3760 | { |
| 3761 | //locally allocated |
| 3762 | palFreeMemory(pMac->hHdd, pIesLocal); |
| 3763 | } |
| 3764 | |
| 3765 | return( fRet ); |
| 3766 | } |
| 3767 | |
| 3768 | |
| 3769 | static void csrSaveScanResults( tpAniSirGlobal pMac ) |
| 3770 | { |
| 3771 | // initialize this to FALSE. profMoveInterimScanResultsToMainList() routine |
| 3772 | // will set this to the channel where an .11d beacon is seen |
| 3773 | pMac->scan.channelOf11dInfo = 0; |
| 3774 | // if we get any ambiguous .11d information then this will be set to TRUE |
| 3775 | pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE; |
| 3776 | //Tush |
| 3777 | // if we get any ambiguous .11d information, then this will be set to TRUE |
| 3778 | // only if the applied 11d info could be found in one of the scan results |
| 3779 | pMac->scan.fCurrent11dInfoMatch = eANI_BOOLEAN_FALSE; |
| 3780 | // move the scan results from interim list to the main scan list |
| 3781 | csrMoveTempScanResultsToMainList( pMac ); |
| 3782 | |
| 3783 | // Now check if we gathered any domain/country specific information |
| 3784 | // If so, we should update channel list and apply Tx power settings |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3785 | if( csrIs11dSupported(pMac) ) |
| 3786 | { |
| 3787 | csrApplyCountryInformation( pMac, FALSE ); |
| 3788 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3789 | } |
| 3790 | |
| 3791 | |
| 3792 | void csrReinitScanCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
| 3793 | { |
| 3794 | switch (pCommand->u.scanCmd.reason) |
| 3795 | { |
| 3796 | case eCsrScanSetBGScanParam: |
| 3797 | case eCsrScanAbortBgScan: |
| 3798 | if(pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList) |
| 3799 | { |
| 3800 | palFreeMemory(pMac->hHdd, pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList); |
| 3801 | pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList = NULL; |
| 3802 | } |
| 3803 | break; |
| 3804 | case eCsrScanBGScanAbort: |
| 3805 | case eCsrScanBGScanEnable: |
| 3806 | case eCsrScanGetScanChnInfo: |
| 3807 | break; |
| 3808 | case eCsrScanAbortNormalScan: |
| 3809 | default: |
| 3810 | csrScanFreeRequest(pMac, &pCommand->u.scanCmd.u.scanRequest); |
| 3811 | break; |
| 3812 | } |
| 3813 | if(pCommand->u.scanCmd.pToRoamProfile) |
| 3814 | { |
| 3815 | csrReleaseProfile(pMac, pCommand->u.scanCmd.pToRoamProfile); |
| 3816 | palFreeMemory(pMac->hHdd, pCommand->u.scanCmd.pToRoamProfile); |
| 3817 | } |
| 3818 | palZeroMemory(pMac->hHdd, &pCommand->u.scanCmd, sizeof(tScanCmd)); |
| 3819 | } |
| 3820 | |
| 3821 | |
| 3822 | tANI_BOOLEAN csrGetRemainingChannelsFor11dScan( tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U8 *pcChannels ) |
| 3823 | { |
| 3824 | tANI_U32 index11dChannels, index; |
| 3825 | tANI_U32 indexCurrentChannels; |
| 3826 | tANI_BOOLEAN fChannelAlreadyScanned; |
| 3827 | tANI_U32 len = sizeof(pMac->roam.validChannelList); |
| 3828 | |
| 3829 | *pcChannels = 0; |
| 3830 | if ( CSR_IS_11D_INFO_FOUND(pMac) && csrRoamIsChannelValid(pMac, pMac->scan.channelOf11dInfo) ) |
| 3831 | { |
| 3832 | if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len))) |
| 3833 | { |
| 3834 | //Find the channel index where we found the 11d info |
| 3835 | for(index = 0; index < len; index++) |
| 3836 | { |
| 3837 | if(pMac->scan.channelOf11dInfo == pMac->roam.validChannelList[index]) |
| 3838 | break; |
| 3839 | } |
| 3840 | //check whether we found the channel index |
| 3841 | if(index < len) |
| 3842 | { |
| 3843 | // Now, look through the 11d channel list and create a list of all channels in the 11d list that are |
| 3844 | // NOT in the current channel list. This gives us a list of the new channels that have not been |
| 3845 | // scanned. We'll scan this new list so we have a complete set of scan results on all of the domain channels |
| 3846 | // initially. |
| 3847 | for ( index11dChannels = 0; index11dChannels < pMac->scan.channels11d.numChannels; index11dChannels++ ) |
| 3848 | { |
| 3849 | fChannelAlreadyScanned = eANI_BOOLEAN_FALSE; |
| 3850 | |
| 3851 | for( indexCurrentChannels = 0; indexCurrentChannels < index; indexCurrentChannels++ ) |
| 3852 | { |
| 3853 | if ( pMac->roam.validChannelList[ indexCurrentChannels ] == pMac->scan.channels11d.channelList[ index11dChannels ] ) |
| 3854 | { |
| 3855 | fChannelAlreadyScanned = eANI_BOOLEAN_TRUE; |
| 3856 | break; |
| 3857 | } |
| 3858 | } |
| 3859 | |
| 3860 | if ( !fChannelAlreadyScanned ) |
| 3861 | { |
| 3862 | pChannels[ *pcChannels ] = pMac->scan.channels11d.channelList[ index11dChannels ]; |
| 3863 | ( *pcChannels )++; |
| 3864 | } |
| 3865 | } |
| 3866 | } |
| 3867 | }//GetCFG |
| 3868 | } |
| 3869 | return( *pcChannels ); |
| 3870 | } |
| 3871 | |
| 3872 | |
| 3873 | eCsrScanCompleteNextCommand csrScanGetNextCommandState( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fSuccess ) |
| 3874 | { |
| 3875 | eCsrScanCompleteNextCommand NextCommand = eCsrNextScanNothing; |
| 3876 | |
| 3877 | switch( pCommand->u.scanCmd.reason ) |
| 3878 | { |
| 3879 | case eCsrScan11d1: |
| 3880 | NextCommand = (fSuccess) ? eCsrNext11dScan1Success : eCsrNext11dScan1Failure; |
| 3881 | break; |
| 3882 | case eCsrScan11d2: |
| 3883 | NextCommand = (fSuccess) ? eCsrNext11dScan2Success : eCsrNext11dScan2Failure; |
| 3884 | break; |
| 3885 | case eCsrScan11dDone: |
| 3886 | NextCommand = eCsrNext11dScanComplete; |
| 3887 | break; |
| 3888 | case eCsrScanLostLink1: |
| 3889 | NextCommand = (fSuccess) ? eCsrNextLostLinkScan1Success : eCsrNextLostLinkScan1Failed; |
| 3890 | break; |
| 3891 | case eCsrScanLostLink2: |
| 3892 | NextCommand = (fSuccess) ? eCsrNextLostLinkScan2Success : eCsrNextLostLinkScan2Failed; |
| 3893 | break; |
| 3894 | case eCsrScanLostLink3: |
| 3895 | NextCommand = (fSuccess) ? eCsrNextLostLinkScan3Success : eCsrNextLostLinkScan3Failed; |
| 3896 | break; |
| 3897 | case eCsrScanForSsid: |
| 3898 | NextCommand = (fSuccess) ? eCsrNexteScanForSsidSuccess : eCsrNexteScanForSsidFailure; |
| 3899 | break; |
| 3900 | case eCsrScanForCapsChange: |
| 3901 | NextCommand = eCsrNextCapChangeScanComplete; //don't care success or not |
| 3902 | break; |
| 3903 | case eCsrScanIdleScan: |
| 3904 | NextCommand = eCsrNextIdleScanComplete; |
| 3905 | break; |
| 3906 | default: |
| 3907 | NextCommand = eCsrNextScanNothing; |
| 3908 | break; |
| 3909 | } |
| 3910 | return( NextCommand ); |
| 3911 | } |
| 3912 | |
| 3913 | |
| 3914 | //Return whether the pCommand is finished. |
| 3915 | tANI_BOOLEAN csrHandleScan11d1Failure(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
| 3916 | { |
| 3917 | tANI_BOOLEAN fRet = eANI_BOOLEAN_TRUE; |
| 3918 | |
| 3919 | //Apply back the default setting and passively scan one more time. |
Gopichand Nakkala | b9185f2 | 2012-12-21 08:03:42 -0800 | [diff] [blame] | 3920 | csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_TRUE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3921 | pCommand->u.scanCmd.reason = eCsrScan11d2; |
| 3922 | if(HAL_STATUS_SUCCESS(csrScanChannels(pMac, pCommand))) |
| 3923 | { |
| 3924 | fRet = eANI_BOOLEAN_FALSE; |
| 3925 | } |
| 3926 | |
| 3927 | return (fRet); |
| 3928 | } |
| 3929 | |
| 3930 | |
| 3931 | tANI_BOOLEAN csrHandleScan11dSuccess(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
| 3932 | { |
| 3933 | tANI_BOOLEAN fRet = eANI_BOOLEAN_TRUE; |
| 3934 | tANI_U8 *pChannels; |
| 3935 | tANI_U8 cChannels; |
| 3936 | |
| 3937 | if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN))) |
| 3938 | { |
| 3939 | palZeroMemory(pMac->hHdd, pChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 3940 | if ( csrGetRemainingChannelsFor11dScan( pMac, pChannels, &cChannels ) ) |
| 3941 | { |
| 3942 | pCommand->u.scanCmd.reason = eCsrScan11dDone; |
| 3943 | if(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList) |
| 3944 | { |
| 3945 | palFreeMemory(pMac->hHdd, pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList); |
| 3946 | } |
| 3947 | if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList, cChannels))) |
| 3948 | { |
| 3949 | palCopyMemory(pMac->hHdd, pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList, pChannels, cChannels); |
| 3950 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = cChannels; |
| 3951 | pCommand->u.scanCmd.u.scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN; |
| 3952 | pCommand->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 3953 | if(HAL_STATUS_SUCCESS(csrScanChannels(pMac, pCommand))) |
| 3954 | { |
| 3955 | //Reuse the same command buffer |
| 3956 | fRet = eANI_BOOLEAN_FALSE; |
| 3957 | } |
| 3958 | } |
| 3959 | } |
| 3960 | palFreeMemory(pMac->hHdd, pChannels); |
| 3961 | } |
| 3962 | |
| 3963 | return (fRet); |
| 3964 | } |
| 3965 | |
| 3966 | //Return whether the command should be removed |
| 3967 | tANI_BOOLEAN csrScanComplete( tpAniSirGlobal pMac, tSirSmeScanRsp *pScanRsp ) |
| 3968 | { |
| 3969 | eCsrScanCompleteNextCommand NextCommand = eCsrNextScanNothing; |
| 3970 | tListElem *pEntry; |
| 3971 | tSmeCmd *pCommand; |
| 3972 | tANI_BOOLEAN fRemoveCommand = eANI_BOOLEAN_TRUE; |
| 3973 | tANI_BOOLEAN fSuccess; |
| 3974 | |
| 3975 | pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK ); |
| 3976 | |
| 3977 | if ( pEntry ) |
| 3978 | { |
| 3979 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 3980 | |
| 3981 | // If the head of the queue is Active and it is a SCAN command, remove |
| 3982 | // and put this on the Free queue. |
| 3983 | if ( eSmeCommandScan == pCommand->command ) |
| 3984 | { |
| 3985 | tANI_U32 sessionId = pCommand->sessionId; |
| 3986 | |
| 3987 | if(eSIR_SME_SUCCESS != pScanRsp->statusCode) |
| 3988 | { |
| 3989 | fSuccess = eANI_BOOLEAN_FALSE; |
| 3990 | } |
| 3991 | else |
| 3992 | { |
| 3993 | //pMac->scan.tempScanResults is not empty meaning the scan found something |
| 3994 | //This check only valid here because csrSaveScanresults is not yet called |
| 3995 | fSuccess = (!csrLLIsListEmpty(&pMac->scan.tempScanResults, LL_ACCESS_LOCK)); |
| 3996 | } |
| 3997 | csrSaveScanResults(pMac); |
| 3998 | |
| 3999 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 4000 | { |
| 4001 | vos_log_scan_pkt_type *pScanLog = NULL; |
| 4002 | tScanResultHandle hScanResult; |
| 4003 | tCsrScanResultInfo *pScanResult; |
| 4004 | tDot11fBeaconIEs *pIes; |
| 4005 | int n = 0, c = 0; |
| 4006 | |
| 4007 | WLAN_VOS_DIAG_LOG_ALLOC(pScanLog, vos_log_scan_pkt_type, LOG_WLAN_SCAN_C); |
| 4008 | if(pScanLog) |
| 4009 | { |
| 4010 | if(eCsrScanBgScan == pCommand->u.scanCmd.reason || |
| 4011 | eCsrScanProbeBss == pCommand->u.scanCmd.reason || |
| 4012 | eCsrScanSetBGScanParam == pCommand->u.scanCmd.reason) |
| 4013 | { |
| 4014 | pScanLog->eventId = WLAN_SCAN_EVENT_HO_SCAN_RSP; |
| 4015 | } |
| 4016 | else |
| 4017 | { |
| 4018 | if( eSIR_PASSIVE_SCAN != pMac->scan.curScanType ) |
| 4019 | { |
| 4020 | pScanLog->eventId = WLAN_SCAN_EVENT_ACTIVE_SCAN_RSP; |
| 4021 | } |
| 4022 | else |
| 4023 | { |
| 4024 | pScanLog->eventId = WLAN_SCAN_EVENT_PASSIVE_SCAN_RSP; |
| 4025 | } |
| 4026 | } |
| 4027 | if(eSIR_SME_SUCCESS == pScanRsp->statusCode) |
| 4028 | { |
| 4029 | if(HAL_STATUS_SUCCESS(csrScanGetResult(pMac, NULL, &hScanResult))) |
| 4030 | { |
| 4031 | while(((pScanResult = csrScanResultGetNext(pMac, hScanResult)) != NULL)) |
| 4032 | { |
| 4033 | if( n < VOS_LOG_MAX_NUM_BSSID ) |
| 4034 | { |
| 4035 | if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->BssDescriptor, &pIes))) |
| 4036 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 4037 | smsLog(pMac, LOGE, FL(" fail to parse IEs")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4038 | break; |
| 4039 | } |
| 4040 | palCopyMemory(pMac->hHdd, pScanLog->bssid[n], pScanResult->BssDescriptor.bssId, 6); |
| 4041 | if(pIes && pIes->SSID.present && VOS_LOG_MAX_SSID_SIZE >= pIes->SSID.num_ssid) |
| 4042 | { |
| 4043 | palCopyMemory(pMac->hHdd, pScanLog->ssid[n], |
| 4044 | pIes->SSID.ssid, pIes->SSID.num_ssid); |
| 4045 | } |
| 4046 | palFreeMemory(pMac->hHdd, pIes); |
| 4047 | n++; |
| 4048 | } |
| 4049 | c++; |
| 4050 | } |
| 4051 | pScanLog->numSsid = (v_U8_t)n; |
| 4052 | pScanLog->totalSsid = (v_U8_t)c; |
| 4053 | csrScanResultPurge(pMac, hScanResult); |
| 4054 | } |
| 4055 | } |
| 4056 | else |
| 4057 | { |
| 4058 | pScanLog->status = WLAN_SCAN_STATUS_FAILURE; |
| 4059 | } |
| 4060 | WLAN_VOS_DIAG_LOG_REPORT(pScanLog); |
| 4061 | } |
| 4062 | } |
| 4063 | #endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 4064 | |
| 4065 | NextCommand = csrScanGetNextCommandState(pMac, pCommand, fSuccess); |
| 4066 | //We reuse the command here instead reissue a new command |
| 4067 | switch(NextCommand) |
| 4068 | { |
| 4069 | case eCsrNext11dScan1Success: |
| 4070 | case eCsrNext11dScan2Success: |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 4071 | smsLog( pMac, LOG2, FL("11dScan1/3 produced results. Reissue Active scan...")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4072 | // if we found country information, no need to continue scanning further, bail out |
| 4073 | fRemoveCommand = eANI_BOOLEAN_TRUE; |
| 4074 | NextCommand = eCsrNext11dScanComplete; |
| 4075 | break; |
| 4076 | case eCsrNext11dScan1Failure: |
| 4077 | //We are not done yet. 11d scan fail once. We will try to reset anything and do it over again |
| 4078 | //The only meaningful thing for this retry is that we cannot find 11d information after a reset so |
| 4079 | //we clear the "old" 11d info and give it once more chance |
| 4080 | fRemoveCommand = csrHandleScan11d1Failure(pMac, pCommand); |
| 4081 | if(fRemoveCommand) |
| 4082 | { |
| 4083 | NextCommand = eCsrNext11dScanComplete; |
| 4084 | } |
| 4085 | break; |
| 4086 | case eCsrNextLostLinkScan1Success: |
| 4087 | if(!HAL_STATUS_SUCCESS(csrIssueRoamAfterLostlinkScan(pMac, sessionId, eCsrLostLink1))) |
| 4088 | { |
| 4089 | csrScanHandleFailedLostlink1(pMac, sessionId); |
| 4090 | } |
| 4091 | break; |
| 4092 | case eCsrNextLostLinkScan2Success: |
| 4093 | if(!HAL_STATUS_SUCCESS(csrIssueRoamAfterLostlinkScan(pMac, sessionId, eCsrLostLink2))) |
| 4094 | { |
| 4095 | csrScanHandleFailedLostlink2(pMac, sessionId); |
| 4096 | } |
| 4097 | break; |
| 4098 | case eCsrNextLostLinkScan3Success: |
| 4099 | if(!HAL_STATUS_SUCCESS(csrIssueRoamAfterLostlinkScan(pMac, sessionId, eCsrLostLink3))) |
| 4100 | { |
| 4101 | csrScanHandleFailedLostlink3(pMac, sessionId); |
| 4102 | } |
| 4103 | break; |
| 4104 | case eCsrNextLostLinkScan1Failed: |
| 4105 | csrScanHandleFailedLostlink1(pMac, sessionId); |
| 4106 | break; |
| 4107 | case eCsrNextLostLinkScan2Failed: |
| 4108 | csrScanHandleFailedLostlink2(pMac, sessionId); |
| 4109 | break; |
| 4110 | case eCsrNextLostLinkScan3Failed: |
| 4111 | csrScanHandleFailedLostlink3(pMac, sessionId); |
| 4112 | break; |
| 4113 | case eCsrNexteScanForSsidSuccess: |
| 4114 | csrScanHandleSearchForSSID(pMac, pCommand); |
| 4115 | break; |
| 4116 | case eCsrNexteScanForSsidFailure: |
| 4117 | csrScanHandleSearchForSSIDFailure(pMac, pCommand); |
| 4118 | break; |
| 4119 | case eCsrNextIdleScanComplete: |
| 4120 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 4121 | break; |
| 4122 | case eCsrNextCapChangeScanComplete: |
| 4123 | csrScanHandleCapChangeScanComplete(pMac, sessionId); |
| 4124 | break; |
| 4125 | default: |
| 4126 | |
| 4127 | break; |
| 4128 | } |
| 4129 | } |
| 4130 | else |
| 4131 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 4132 | 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] | 4133 | fRemoveCommand = eANI_BOOLEAN_FALSE; |
| 4134 | } |
| 4135 | } |
| 4136 | else |
| 4137 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 4138 | smsLog( pMac, LOGW, FL("Scan Completion called but NO commands are ACTIVE ...")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4139 | fRemoveCommand = eANI_BOOLEAN_FALSE; |
| 4140 | } |
| 4141 | |
| 4142 | return( fRemoveCommand ); |
| 4143 | } |
| 4144 | |
| 4145 | |
| 4146 | |
| 4147 | static void csrScanRemoveDupBssDescriptionFromInterimList( tpAniSirGlobal pMac, |
| 4148 | tSirBssDescription *pSirBssDescr, |
| 4149 | tDot11fBeaconIEs *pIes) |
| 4150 | { |
| 4151 | tListElem *pEntry; |
| 4152 | tCsrScanResult *pCsrBssDescription; |
| 4153 | |
| 4154 | // Walk through all the chained BssDescriptions. If we find a chained BssDescription that |
| 4155 | // matches the BssID of the BssDescription passed in, then these must be duplicate scan |
| 4156 | // results for this Bss. In that case, remove the 'old' Bss description from the linked list. |
| 4157 | pEntry = csrLLPeekHead( &pMac->scan.tempScanResults, LL_ACCESS_LOCK ); |
| 4158 | while( pEntry ) |
| 4159 | { |
| 4160 | pCsrBssDescription = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 4161 | |
| 4162 | // we have a duplicate scan results only when BSSID, SSID, Channel and NetworkType |
| 4163 | // matches |
| 4164 | |
| 4165 | if ( csrIsDuplicateBssDescription( pMac, &pCsrBssDescription->Result.BssDescriptor, |
| 4166 | pSirBssDescr, pIes ) ) |
| 4167 | { |
| 4168 | pSirBssDescr->rssi = (tANI_S8)( (((tANI_S32)pSirBssDescr->rssi * CSR_SCAN_RESULT_RSSI_WEIGHT ) + |
| 4169 | ((tANI_S32)pCsrBssDescription->Result.BssDescriptor.rssi * (100 - CSR_SCAN_RESULT_RSSI_WEIGHT) )) / 100 ); |
| 4170 | |
| 4171 | // Remove the 'old' entry from the list.... |
| 4172 | if( csrLLRemoveEntry( &pMac->scan.tempScanResults, pEntry, LL_ACCESS_LOCK ) ) |
| 4173 | { |
| 4174 | csrCheckNSaveWscIe(pMac, pSirBssDescr, &pCsrBssDescription->Result.BssDescriptor); |
| 4175 | // we need to free the memory associated with this node |
| 4176 | csrFreeScanResultEntry( pMac, pCsrBssDescription ); |
| 4177 | } |
| 4178 | |
| 4179 | // If we found a match, we can stop looking through the list. |
| 4180 | break; |
| 4181 | } |
| 4182 | |
| 4183 | pEntry = csrLLNext( &pMac->scan.tempScanResults, pEntry, LL_ACCESS_LOCK ); |
| 4184 | } |
| 4185 | } |
| 4186 | |
| 4187 | |
| 4188 | |
| 4189 | //Caller allocated memory pfNewBssForConn to return whether new candidate for |
| 4190 | //current connection is found. Cannot be NULL |
| 4191 | tCsrScanResult *csrScanSaveBssDescriptionToInterimList( tpAniSirGlobal pMac, |
| 4192 | tSirBssDescription *pBSSDescription, |
| 4193 | tDot11fBeaconIEs *pIes) |
| 4194 | { |
| 4195 | tCsrScanResult *pCsrBssDescription = NULL; |
| 4196 | tANI_U32 cbBSSDesc; |
| 4197 | tANI_U32 cbAllocated; |
| 4198 | eHalStatus halStatus; |
| 4199 | |
| 4200 | // figure out how big the BSS description is (the BSSDesc->length does NOT |
| 4201 | // include the size of the length field itself). |
| 4202 | cbBSSDesc = pBSSDescription->length + sizeof( pBSSDescription->length ); |
| 4203 | |
| 4204 | cbAllocated = sizeof( tCsrScanResult ) + cbBSSDesc; |
| 4205 | |
| 4206 | halStatus = palAllocateMemory( pMac->hHdd, (void **)&pCsrBssDescription, cbAllocated ); |
| 4207 | if ( HAL_STATUS_SUCCESS(halStatus) ) |
| 4208 | { |
| 4209 | palZeroMemory(pMac->hHdd, pCsrBssDescription, cbAllocated); |
| 4210 | pCsrBssDescription->AgingCount = (tANI_S32)pMac->roam.configParam.agingCount; |
| 4211 | palCopyMemory(pMac->hHdd, &pCsrBssDescription->Result.BssDescriptor, pBSSDescription, cbBSSDesc ); |
| 4212 | //Save SSID separately for later use |
| 4213 | if( pIes->SSID.present && !csrIsNULLSSID(pIes->SSID.ssid, pIes->SSID.num_ssid) ) |
| 4214 | { |
| 4215 | //SSID not hidden |
Madan Mohan Koyyalamudi | 4e31b13 | 2012-11-02 13:13:52 -0700 | [diff] [blame] | 4216 | tANI_U32 len = pIes->SSID.num_ssid; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4217 | if (len > SIR_MAC_MAX_SSID_LENGTH) |
| 4218 | { |
| 4219 | // truncate to fit in our struct |
| 4220 | len = SIR_MAC_MAX_SSID_LENGTH; |
| 4221 | } |
| 4222 | pCsrBssDescription->Result.ssId.length = len; |
| 4223 | pCsrBssDescription->Result.timer = vos_timer_get_system_time(); |
| 4224 | palCopyMemory(pMac->hHdd, pCsrBssDescription->Result.ssId.ssId, |
| 4225 | pIes->SSID.ssid, len ); |
| 4226 | } |
| 4227 | csrLLInsertTail( &pMac->scan.tempScanResults, &pCsrBssDescription->Link, LL_ACCESS_LOCK ); |
| 4228 | } |
| 4229 | |
| 4230 | return( pCsrBssDescription ); |
| 4231 | } |
| 4232 | |
| 4233 | |
| 4234 | |
| 4235 | |
| 4236 | tANI_BOOLEAN csrIsDuplicateBssDescription( tpAniSirGlobal pMac, tSirBssDescription *pSirBssDesc1, |
| 4237 | tSirBssDescription *pSirBssDesc2, tDot11fBeaconIEs *pIes2 ) |
| 4238 | { |
| 4239 | tANI_BOOLEAN fMatch = FALSE; |
| 4240 | tSirMacCapabilityInfo *pCap1, *pCap2; |
| 4241 | tDot11fBeaconIEs *pIes1 = NULL; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4242 | tDot11fBeaconIEs *pIesTemp = pIes2; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4243 | |
| 4244 | pCap1 = (tSirMacCapabilityInfo *)&pSirBssDesc1->capabilityInfo; |
| 4245 | pCap2 = (tSirMacCapabilityInfo *)&pSirBssDesc2->capabilityInfo; |
| 4246 | if(pCap1->ess == pCap2->ess) |
| 4247 | { |
| 4248 | if (pCap1->ess && |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4249 | csrIsMacAddressEqual( pMac, (tCsrBssid *)pSirBssDesc1->bssId, (tCsrBssid *)pSirBssDesc2->bssId)&& |
| 4250 | (pSirBssDesc1->channelId == pSirBssDesc2->channelId)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4251 | { |
| 4252 | fMatch = TRUE; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4253 | // Check for SSID match, if exists |
| 4254 | do |
| 4255 | { |
| 4256 | if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc1, &pIes1))) |
| 4257 | { |
| 4258 | break; |
| 4259 | } |
| 4260 | if( NULL == pIesTemp ) |
| 4261 | { |
| 4262 | if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc2, &pIesTemp))) |
| 4263 | { |
| 4264 | break; |
| 4265 | } |
| 4266 | } |
| 4267 | if(pIes1->SSID.present && pIesTemp->SSID.present) |
| 4268 | { |
| 4269 | fMatch = csrIsSsidMatch(pMac, pIes1->SSID.ssid, pIes1->SSID.num_ssid, |
| 4270 | pIesTemp->SSID.ssid, pIesTemp->SSID.num_ssid, eANI_BOOLEAN_TRUE); |
| 4271 | } |
| 4272 | }while(0); |
| 4273 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4274 | } |
| 4275 | else if (pCap1->ibss && (pSirBssDesc1->channelId == pSirBssDesc2->channelId)) |
| 4276 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4277 | |
| 4278 | do |
| 4279 | { |
| 4280 | if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc1, &pIes1))) |
| 4281 | { |
| 4282 | break; |
| 4283 | } |
| 4284 | if( NULL == pIesTemp ) |
| 4285 | { |
| 4286 | if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc2, &pIesTemp))) |
| 4287 | { |
| 4288 | break; |
| 4289 | } |
| 4290 | } |
| 4291 | //Same channel cannot have same SSID for different IBSS |
| 4292 | if(pIes1->SSID.present && pIesTemp->SSID.present) |
| 4293 | { |
| 4294 | fMatch = csrIsSsidMatch(pMac, pIes1->SSID.ssid, pIes1->SSID.num_ssid, |
| 4295 | pIesTemp->SSID.ssid, pIesTemp->SSID.num_ssid, eANI_BOOLEAN_TRUE); |
| 4296 | } |
| 4297 | }while(0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4298 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4299 | /* In case of P2P devices, ess and ibss will be set to zero */ |
| 4300 | else if (!pCap1->ess && |
| 4301 | csrIsMacAddressEqual( pMac, (tCsrBssid *)pSirBssDesc1->bssId, (tCsrBssid *)pSirBssDesc2->bssId)) |
| 4302 | { |
| 4303 | fMatch = TRUE; |
| 4304 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4305 | } |
| 4306 | |
| 4307 | if(pIes1) |
| 4308 | { |
| 4309 | palFreeMemory(pMac->hHdd, pIes1); |
| 4310 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4311 | |
| 4312 | if( (NULL == pIes2) && pIesTemp ) |
| 4313 | { |
| 4314 | //locally allocated |
| 4315 | palFreeMemory(pMac->hHdd, pIesTemp); |
| 4316 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4317 | |
| 4318 | return( fMatch ); |
| 4319 | } |
| 4320 | |
| 4321 | |
| 4322 | tANI_BOOLEAN csrIsNetworkTypeEqual( tSirBssDescription *pSirBssDesc1, tSirBssDescription *pSirBssDesc2 ) |
| 4323 | { |
| 4324 | return( pSirBssDesc1->nwType == pSirBssDesc2->nwType ); |
| 4325 | } |
| 4326 | |
| 4327 | |
| 4328 | //to check whether the BSS matches the dot11Mode |
| 4329 | static tANI_BOOLEAN csrScanIsBssAllowed(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc, |
| 4330 | tDot11fBeaconIEs *pIes) |
| 4331 | { |
| 4332 | tANI_BOOLEAN fAllowed = eANI_BOOLEAN_FALSE; |
| 4333 | eCsrPhyMode phyMode; |
| 4334 | |
| 4335 | if(HAL_STATUS_SUCCESS(csrGetPhyModeFromBss(pMac, pBssDesc, &phyMode, pIes))) |
| 4336 | { |
| 4337 | switch(pMac->roam.configParam.phyMode) |
| 4338 | { |
| 4339 | case eCSR_DOT11_MODE_11b: |
| 4340 | fAllowed = (tANI_BOOLEAN)(eCSR_DOT11_MODE_11a != phyMode); |
| 4341 | break; |
| 4342 | case eCSR_DOT11_MODE_11g: |
| 4343 | fAllowed = (tANI_BOOLEAN)(eCSR_DOT11_MODE_11a != phyMode); |
| 4344 | break; |
| 4345 | case eCSR_DOT11_MODE_11g_ONLY: |
| 4346 | fAllowed = (tANI_BOOLEAN)(eCSR_DOT11_MODE_11g == phyMode); |
| 4347 | break; |
| 4348 | case eCSR_DOT11_MODE_11a: |
| 4349 | fAllowed = (tANI_BOOLEAN)((eCSR_DOT11_MODE_11b != phyMode) && (eCSR_DOT11_MODE_11g != phyMode)); |
| 4350 | break; |
| 4351 | case eCSR_DOT11_MODE_11n_ONLY: |
| 4352 | fAllowed = (tANI_BOOLEAN)((eCSR_DOT11_MODE_11n == phyMode) || (eCSR_DOT11_MODE_TAURUS == phyMode)); |
| 4353 | break; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4354 | |
| 4355 | #ifdef WLAN_FEATURE_11AC |
| 4356 | case eCSR_DOT11_MODE_11ac_ONLY: |
| 4357 | fAllowed = (tANI_BOOLEAN)((eCSR_DOT11_MODE_11ac == phyMode) || (eCSR_DOT11_MODE_TAURUS == phyMode)); |
| 4358 | break; |
| 4359 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4360 | case eCSR_DOT11_MODE_11b_ONLY: |
| 4361 | fAllowed = (tANI_BOOLEAN)(eCSR_DOT11_MODE_11b == phyMode); |
| 4362 | break; |
| 4363 | case eCSR_DOT11_MODE_11a_ONLY: |
| 4364 | fAllowed = (tANI_BOOLEAN)(eCSR_DOT11_MODE_11a == phyMode); |
| 4365 | break; |
| 4366 | case eCSR_DOT11_MODE_11n: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4367 | #ifdef WLAN_FEATURE_11AC |
| 4368 | case eCSR_DOT11_MODE_11ac: |
| 4369 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4370 | case eCSR_DOT11_MODE_TAURUS: |
| 4371 | default: |
| 4372 | fAllowed = eANI_BOOLEAN_TRUE; |
| 4373 | break; |
| 4374 | } |
| 4375 | } |
| 4376 | |
| 4377 | return (fAllowed); |
| 4378 | } |
| 4379 | |
| 4380 | |
| 4381 | |
| 4382 | //Return pIes to caller for future use when returning TRUE. |
| 4383 | static tANI_BOOLEAN csrScanValidateScanResult( tpAniSirGlobal pMac, tANI_U8 *pChannels, |
| 4384 | tANI_U8 numChn, tSirBssDescription *pBssDesc, |
| 4385 | tDot11fBeaconIEs **ppIes ) |
| 4386 | { |
| 4387 | tANI_BOOLEAN fValidChannel = FALSE; |
| 4388 | tDot11fBeaconIEs *pIes = NULL; |
| 4389 | tANI_U8 index; |
| 4390 | |
| 4391 | for( index = 0; index < numChn; index++ ) |
| 4392 | { |
| 4393 | // This check relies on the fact that a single BSS description is returned in each |
| 4394 | // ScanRsp call, which is the way LIM implemented the scan req/rsp funtions. We changed |
| 4395 | // to this model when we ran with a large number of APs. If this were to change, then |
| 4396 | // this check would have to mess with removing the bssDescription from somewhere in an |
| 4397 | // arbitrary index in the bssDescription array. |
| 4398 | if ( pChannels[ index ] == pBssDesc->channelId ) |
| 4399 | { |
| 4400 | fValidChannel = TRUE; |
| 4401 | break; |
| 4402 | } |
| 4403 | } |
| 4404 | *ppIes = NULL; |
| 4405 | if(fValidChannel) |
| 4406 | { |
| 4407 | if( HAL_STATUS_SUCCESS( csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes) ) ) |
| 4408 | { |
| 4409 | fValidChannel = csrScanIsBssAllowed(pMac, pBssDesc, pIes); |
| 4410 | if( fValidChannel ) |
| 4411 | { |
| 4412 | *ppIes = pIes; |
| 4413 | } |
| 4414 | else |
| 4415 | { |
| 4416 | palFreeMemory( pMac->hHdd, pIes ); |
| 4417 | } |
| 4418 | } |
| 4419 | else |
| 4420 | { |
| 4421 | fValidChannel = FALSE; |
| 4422 | } |
| 4423 | } |
| 4424 | |
| 4425 | return( fValidChannel ); |
| 4426 | } |
| 4427 | |
| 4428 | |
| 4429 | //Return whether last scan result is received |
| 4430 | static tANI_BOOLEAN csrScanProcessScanResults( tpAniSirGlobal pMac, tSmeCmd *pCommand, |
| 4431 | tSirSmeScanRsp *pScanRsp, tANI_BOOLEAN *pfRemoveCommand ) |
| 4432 | { |
| 4433 | tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE, fRemoveCommand = eANI_BOOLEAN_FALSE; |
| 4434 | tDot11fBeaconIEs *pIes = NULL; |
| 4435 | tANI_U32 cbParsed; |
| 4436 | tSirBssDescription *pSirBssDescription; |
| 4437 | tANI_U32 cbBssDesc; |
| 4438 | tANI_U32 cbScanResult = GET_FIELD_OFFSET( tSirSmeScanRsp, bssDescription ) |
| 4439 | + sizeof(tSirBssDescription); //We need at least one CB |
| 4440 | |
| 4441 | // don't consider the scan rsp to be valid if the status code is Scan Failure. Scan Failure |
| 4442 | // is returned when the scan could not find anything. so if we get scan failure return that |
| 4443 | // the scan response is invalid. Also check the lenght in the scan result for valid scan |
| 4444 | // BssDescriptions.... |
| 4445 | do |
| 4446 | { |
| 4447 | if ( ( cbScanResult <= pScanRsp->length ) && |
| 4448 | (( eSIR_SME_SUCCESS == pScanRsp->statusCode ) || |
| 4449 | ( eSIR_SME_MORE_SCAN_RESULTS_FOLLOW == pScanRsp->statusCode ) ) ) |
| 4450 | { |
| 4451 | tANI_U8 *pChannelList = NULL; |
| 4452 | tANI_U8 cChannels = 0; |
| 4453 | |
| 4454 | //Different scan type can reach this point, we need to distinguish it |
| 4455 | if( eCsrScanSetBGScanParam == pCommand->u.scanCmd.reason ) |
| 4456 | { |
| 4457 | //eCsrScanSetBGScanParam uses different structure |
| 4458 | tCsrBGScanRequest *pBgScanReq = &pCommand->u.scanCmd.u.bgScanRequest; |
| 4459 | |
| 4460 | cChannels = pBgScanReq->ChannelInfo.numOfChannels; |
| 4461 | pChannelList = pBgScanReq->ChannelInfo.ChannelList; |
| 4462 | } |
| 4463 | else |
| 4464 | { |
| 4465 | //the rest use generic scan request |
| 4466 | cChannels = pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels; |
| 4467 | pChannelList = pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList; |
| 4468 | } |
| 4469 | |
| 4470 | // if the scan result is not on one of the channels in the Valid channel list, then it |
| 4471 | // must have come from an AP on an overlapping channel (in the 2.4GHz band). In this case, |
| 4472 | // let's drop the scan result. |
| 4473 | // |
| 4474 | // The other situation is where the scan request is for a scan on a particular channel set |
| 4475 | // and the scan result is from a |
| 4476 | |
| 4477 | // if the NumChannels is 0, then we are supposed to be scanning all channels. Use the full channel |
| 4478 | // list as the 'valid' channel list. Otherwise, use the specific channel list in the scan parms |
| 4479 | // as the valid channels. |
| 4480 | if ( 0 == cChannels ) |
| 4481 | { |
| 4482 | tANI_U32 len = sizeof(pMac->roam.validChannelList); |
| 4483 | |
| 4484 | if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len))) |
| 4485 | { |
| 4486 | pChannelList = pMac->roam.validChannelList; |
| 4487 | cChannels = (tANI_U8)len; |
| 4488 | } |
| 4489 | else |
| 4490 | { |
| 4491 | //Cannot continue |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 4492 | smsLog( pMac, LOGE, "CSR: Processing internal SCAN results...csrGetCfgValidChannels failed" ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4493 | break; |
| 4494 | } |
| 4495 | } |
| 4496 | |
| 4497 | smsLog( pMac, LOG2, "CSR: Processing internal SCAN results..." ); |
| 4498 | cbParsed = GET_FIELD_OFFSET( tSirSmeScanRsp, bssDescription ); |
| 4499 | pSirBssDescription = pScanRsp->bssDescription; |
| 4500 | while( cbParsed < pScanRsp->length ) |
| 4501 | { |
| 4502 | if ( csrScanValidateScanResult( pMac, pChannelList, cChannels, pSirBssDescription, &pIes ) ) |
| 4503 | { |
| 4504 | csrScanRemoveDupBssDescriptionFromInterimList(pMac, pSirBssDescription, pIes); |
| 4505 | csrScanSaveBssDescriptionToInterimList( pMac, pSirBssDescription, pIes ); |
| 4506 | if( eSIR_PASSIVE_SCAN == pMac->scan.curScanType ) |
| 4507 | { |
| 4508 | if( csrIs11dSupported( pMac) ) |
| 4509 | { |
| 4510 | //Check whether the BSS is acceptable base on 11d info and our configs. |
| 4511 | if( csrMatchCountryCode( pMac, NULL, pIes ) ) |
| 4512 | { |
| 4513 | //Double check whether the channel is acceptable by us. |
| 4514 | if( csrIsSupportedChannel( pMac, pSirBssDescription->channelId ) ) |
| 4515 | { |
| 4516 | pMac->scan.curScanType = eSIR_ACTIVE_SCAN; |
| 4517 | } |
| 4518 | } |
| 4519 | } |
| 4520 | else |
| 4521 | { |
| 4522 | pMac->scan.curScanType = eSIR_ACTIVE_SCAN; |
| 4523 | } |
| 4524 | } |
| 4525 | //Free the resource |
| 4526 | palFreeMemory( pMac->hHdd, pIes ); |
| 4527 | } |
| 4528 | // skip over the BSS description to the next one... |
| 4529 | cbBssDesc = pSirBssDescription->length + sizeof( pSirBssDescription->length ); |
| 4530 | |
| 4531 | cbParsed += cbBssDesc; |
| 4532 | pSirBssDescription = (tSirBssDescription *)((tANI_U8 *)pSirBssDescription + cbBssDesc ); |
| 4533 | |
| 4534 | } //while |
| 4535 | } |
| 4536 | else |
| 4537 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 4538 | smsLog( pMac, LOGW, " Scanrsp fail (0x%08X), length = %d (expected %d)", |
Madan Mohan Koyyalamudi | dd3c966 | 2012-11-09 17:39:30 -0800 | [diff] [blame] | 4539 | pScanRsp->statusCode, pScanRsp->length, cbScanResult); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4540 | //HO bg scan/probe failed no need to try autonomously |
| 4541 | if(eCsrScanBgScan == pCommand->u.scanCmd.reason || |
| 4542 | eCsrScanProbeBss == pCommand->u.scanCmd.reason || |
| 4543 | eCsrScanSetBGScanParam == pCommand->u.scanCmd.reason) |
| 4544 | { |
| 4545 | fRemoveCommand = eANI_BOOLEAN_TRUE; |
| 4546 | } |
| 4547 | } |
| 4548 | }while(0); |
| 4549 | if ( eSIR_SME_MORE_SCAN_RESULTS_FOLLOW != pScanRsp->statusCode ) |
| 4550 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 4551 | 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] | 4552 | fRemoveCommand = csrScanComplete( pMac, pScanRsp ); |
| 4553 | fRet = eANI_BOOLEAN_TRUE; |
| 4554 | }//if ( eSIR_SME_MORE_SCAN_RESULTS_FOLLOW != pScanRsp->statusCode ) |
| 4555 | if(pfRemoveCommand) |
| 4556 | { |
| 4557 | *pfRemoveCommand = fRemoveCommand; |
| 4558 | } |
| 4559 | |
| 4560 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 4561 | if (!csrLLIsListEmpty( &pMac->scan.scanCmdPendingList, LL_ACCESS_LOCK )) |
| 4562 | { |
Madan Mohan Koyyalamudi | 48081ef | 2012-12-04 16:49:55 -0800 | [diff] [blame] | 4563 | /* Pending scan commands in the list because the previous scan command |
| 4564 | * was split into a scan command on one channel + a scan command for all |
| 4565 | * remaining channels. |
| 4566 | * |
| 4567 | * Start timer to trigger processing of the next scan command. |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 4568 | * NOTE for LFR: |
| 4569 | * Do not split scans if no concurrent infra connections are |
| 4570 | * active and if the scan is a BG scan triggered by LFR (OR) |
| 4571 | * any scan if LFR is in the middle of a BG scan. Splitting |
| 4572 | * the scan is delaying the time it takes for LFR to find |
| 4573 | * candidates and resulting in disconnects. |
Madan Mohan Koyyalamudi | 48081ef | 2012-12-04 16:49:55 -0800 | [diff] [blame] | 4574 | */ |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 4575 | if ( (csrIsStaSessionConnected(pMac) && |
| 4576 | #ifdef FEATURE_WLAN_LFR |
| 4577 | (csrIsConcurrentInfraConnected(pMac) || |
| 4578 | ((pCommand->u.scanCmd.reason != eCsrScanBgScan) && |
| 4579 | (pMac->roam.neighborRoamInfo.neighborRoamState != |
| 4580 | eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN))) && |
| 4581 | #endif |
| 4582 | (pCommand->u.scanCmd.u.scanRequest.p2pSearch != 1)) || |
Madan Mohan Koyyalamudi | 48081ef | 2012-12-04 16:49:55 -0800 | [diff] [blame] | 4583 | (csrIsP2pSessionConnected(pMac)) ) |
| 4584 | { |
Madan Mohan Koyyalamudi | d671358 | 2012-11-09 16:56:56 -0800 | [diff] [blame] | 4585 | /* if active connected sessions present then continue to split scan |
| 4586 | * with specified interval between consecutive scans */ |
| 4587 | csrSetDefaultScanTiming(pMac, pCommand->u.scanCmd.u.scanRequest.scanType, &(pCommand->u.scanCmd.u.scanRequest)); |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 4588 | palTimerStart(pMac->hHdd, pMac->scan.hTimerStaApConcTimer, |
Madan Mohan Koyyalamudi | d671358 | 2012-11-09 16:56:56 -0800 | [diff] [blame] | 4589 | pCommand->u.scanCmd.u.scanRequest.restTime * PAL_TIMER_TO_MS_UNIT, eANI_BOOLEAN_FALSE); |
| 4590 | } else { |
| 4591 | /* if no connected sessions present then initiate next scan command immediately */ |
| 4592 | /* minimum timer granularity is 10ms */ |
| 4593 | palTimerStart(pMac->hHdd, pMac->scan.hTimerStaApConcTimer, 10 * 1000, eANI_BOOLEAN_FALSE); |
| 4594 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4595 | } |
| 4596 | #endif |
| 4597 | return (fRet); |
| 4598 | } |
| 4599 | |
| 4600 | |
| 4601 | tANI_BOOLEAN csrScanIsWildCardScan( tpAniSirGlobal pMac, tSmeCmd *pCommand ) |
| 4602 | { |
| 4603 | tANI_U8 bssid[WNI_CFG_BSSID_LEN] = {0, 0, 0, 0, 0, 0}; |
| 4604 | tANI_BOOLEAN f = palEqualMemory( pMac->hHdd, pCommand->u.scanCmd.u.scanRequest.bssid, |
| 4605 | bssid, sizeof(tCsrBssid) ); |
| 4606 | |
| 4607 | //It is not a wild card scan if the bssid is not broadcast and the number of SSID is 1. |
| 4608 | return ((tANI_BOOLEAN)( (f || (0xff == pCommand->u.scanCmd.u.scanRequest.bssid[0])) && |
| 4609 | (pCommand->u.scanCmd.u.scanRequest.SSIDs.numOfSSIDs != 1) )); |
| 4610 | } |
| 4611 | |
| 4612 | |
| 4613 | eHalStatus csrScanSmeScanResponse( tpAniSirGlobal pMac, void *pMsgBuf ) |
| 4614 | { |
| 4615 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 4616 | tListElem *pEntry; |
| 4617 | tSmeCmd *pCommand; |
| 4618 | eCsrScanStatus scanStatus; |
| 4619 | tSirSmeScanRsp *pScanRsp = (tSirSmeScanRsp *)pMsgBuf; |
| 4620 | tSmeGetScanChnRsp *pScanChnInfo; |
| 4621 | tANI_BOOLEAN fRemoveCommand = eANI_BOOLEAN_TRUE; |
| 4622 | eCsrScanReason reason = eCsrScanOther; |
| 4623 | |
| 4624 | pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK ); |
| 4625 | |
| 4626 | if ( pEntry ) |
| 4627 | { |
| 4628 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 4629 | if ( eSmeCommandScan == pCommand->command ) |
| 4630 | { |
| 4631 | scanStatus = (eSIR_SME_SUCCESS == pScanRsp->statusCode) ? eCSR_SCAN_SUCCESS : eCSR_SCAN_FAILURE; |
| 4632 | reason = pCommand->u.scanCmd.reason; |
| 4633 | switch(pCommand->u.scanCmd.reason) |
| 4634 | { |
| 4635 | case eCsrScanAbortBgScan: |
| 4636 | case eCsrScanAbortNormalScan: |
| 4637 | case eCsrScanBGScanAbort: |
| 4638 | case eCsrScanBGScanEnable: |
| 4639 | break; |
| 4640 | case eCsrScanGetScanChnInfo: |
| 4641 | pScanChnInfo = (tSmeGetScanChnRsp *)pMsgBuf; |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 4642 | /* |
| 4643 | * status code not available in tSmeGetScanChnRsp, so |
| 4644 | * by default considereing it to be success |
| 4645 | */ |
| 4646 | scanStatus = eSIR_SME_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4647 | csrScanAgeResults(pMac, pScanChnInfo); |
| 4648 | break; |
| 4649 | case eCsrScanForCapsChange: |
| 4650 | csrScanProcessScanResults( pMac, pCommand, pScanRsp, &fRemoveCommand ); |
| 4651 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4652 | case eCsrScanP2PFindPeer: |
| 4653 | scanStatus = ((eSIR_SME_SUCCESS == pScanRsp->statusCode) && (pScanRsp->length > 50)) ? eCSR_SCAN_FOUND_PEER : eCSR_SCAN_FAILURE; |
| 4654 | csrScanProcessScanResults( pMac, pCommand, pScanRsp, NULL ); |
| 4655 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4656 | case eCsrScanSetBGScanParam: |
| 4657 | default: |
| 4658 | if(csrScanProcessScanResults( pMac, pCommand, pScanRsp, &fRemoveCommand )) |
| 4659 | { |
| 4660 | //Not to get channel info if the scan is not a wildcard scan because |
| 4661 | //it may cause scan results got aged out incorrectly. |
| 4662 | if( csrScanIsWildCardScan( pMac, pCommand ) && (!pCommand->u.scanCmd.u.scanRequest.p2pSearch) ) |
| 4663 | { |
| 4664 | //Get the list of channels scanned |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4665 | if( pCommand->u.scanCmd.reason != eCsrScanUserRequest) |
| 4666 | { |
| 4667 | csrScanGetScanChnInfo(pMac, NULL, NULL); |
| 4668 | } |
| 4669 | else |
| 4670 | { |
| 4671 | csrScanGetScanChnInfo(pMac, pCommand->u.scanCmd.callback, pCommand->u.scanCmd.pContext); |
| 4672 | pCommand->u.scanCmd.callback = NULL; |
| 4673 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4674 | } |
| 4675 | } |
| 4676 | break; |
| 4677 | }//switch |
| 4678 | if(fRemoveCommand) |
| 4679 | { |
| 4680 | |
| 4681 | csrReleaseScanCommand(pMac, pCommand, scanStatus); |
| 4682 | |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 4683 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4684 | smeProcessPendingQueue( pMac ); |
| 4685 | } |
| 4686 | else |
| 4687 | { |
| 4688 | smsLog( pMac, LOGW, "CSR: Scan Completion called but SCAN command is not ACTIVE ..." ); |
| 4689 | status = eHAL_STATUS_FAILURE; |
| 4690 | } |
| 4691 | } |
| 4692 | else |
| 4693 | { |
| 4694 | smsLog( pMac, LOGW, "CSR: Scan Completion called but NO commands are ACTIVE ..." ); |
| 4695 | status = eHAL_STATUS_FAILURE; |
| 4696 | } |
| 4697 | |
| 4698 | return (status); |
| 4699 | } |
| 4700 | |
| 4701 | |
| 4702 | |
| 4703 | |
| 4704 | tCsrScanResultInfo *csrScanResultGetFirst(tpAniSirGlobal pMac, tScanResultHandle hScanResult) |
| 4705 | { |
| 4706 | tListElem *pEntry; |
| 4707 | tCsrScanResult *pResult; |
| 4708 | tCsrScanResultInfo *pRet = NULL; |
| 4709 | tScanResultList *pResultList = (tScanResultList *)hScanResult; |
| 4710 | |
| 4711 | if(pResultList) |
| 4712 | { |
| 4713 | csrLLLock(&pResultList->List); |
| 4714 | pEntry = csrLLPeekHead(&pResultList->List, LL_ACCESS_NOLOCK); |
| 4715 | if(pEntry) |
| 4716 | { |
| 4717 | pResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link); |
| 4718 | pRet = &pResult->Result; |
| 4719 | } |
| 4720 | pResultList->pCurEntry = pEntry; |
| 4721 | csrLLUnlock(&pResultList->List); |
| 4722 | } |
| 4723 | |
| 4724 | return pRet; |
| 4725 | } |
| 4726 | |
| 4727 | |
| 4728 | tCsrScanResultInfo *csrScanResultGetNext(tpAniSirGlobal pMac, tScanResultHandle hScanResult) |
| 4729 | { |
| 4730 | tListElem *pEntry = NULL; |
| 4731 | tCsrScanResult *pResult = NULL; |
| 4732 | tCsrScanResultInfo *pRet = NULL; |
| 4733 | tScanResultList *pResultList = (tScanResultList *)hScanResult; |
| 4734 | |
| 4735 | if(pResultList) |
| 4736 | { |
| 4737 | csrLLLock(&pResultList->List); |
| 4738 | if(NULL == pResultList->pCurEntry) |
| 4739 | { |
| 4740 | pEntry = csrLLPeekHead(&pResultList->List, LL_ACCESS_NOLOCK); |
| 4741 | } |
| 4742 | else |
| 4743 | { |
| 4744 | pEntry = csrLLNext(&pResultList->List, pResultList->pCurEntry, LL_ACCESS_NOLOCK); |
| 4745 | } |
| 4746 | if(pEntry) |
| 4747 | { |
| 4748 | pResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link); |
| 4749 | pRet = &pResult->Result; |
| 4750 | } |
| 4751 | pResultList->pCurEntry = pEntry; |
| 4752 | csrLLUnlock(&pResultList->List); |
| 4753 | } |
| 4754 | |
| 4755 | return pRet; |
| 4756 | } |
| 4757 | |
| 4758 | |
| 4759 | //This function moves the first BSS that matches the bssid to the head of the result |
| 4760 | eHalStatus csrMoveBssToHeadFromBSSID(tpAniSirGlobal pMac, tCsrBssid *bssid, tScanResultHandle hScanResult) |
| 4761 | { |
| 4762 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 4763 | tScanResultList *pResultList = (tScanResultList *)hScanResult; |
| 4764 | tCsrScanResult *pResult = NULL; |
| 4765 | tListElem *pEntry = NULL; |
| 4766 | |
| 4767 | if(pResultList && bssid) |
| 4768 | { |
| 4769 | csrLLLock(&pResultList->List); |
| 4770 | pEntry = csrLLPeekHead(&pResultList->List, LL_ACCESS_NOLOCK); |
| 4771 | while(pEntry) |
| 4772 | { |
| 4773 | pResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link); |
| 4774 | if(palEqualMemory(pMac->hHdd, bssid, pResult->Result.BssDescriptor.bssId, sizeof(tCsrBssid))) |
| 4775 | { |
| 4776 | status = eHAL_STATUS_SUCCESS; |
| 4777 | csrLLRemoveEntry(&pResultList->List, pEntry, LL_ACCESS_NOLOCK); |
| 4778 | csrLLInsertHead(&pResultList->List, pEntry, LL_ACCESS_NOLOCK); |
| 4779 | break; |
| 4780 | } |
| 4781 | pEntry = csrLLNext(&pResultList->List, pResultList->pCurEntry, LL_ACCESS_NOLOCK); |
| 4782 | } |
| 4783 | csrLLUnlock(&pResultList->List); |
| 4784 | } |
| 4785 | |
| 4786 | return (status); |
| 4787 | } |
| 4788 | |
| 4789 | |
| 4790 | //Remove the BSS if possible. |
| 4791 | //Return -- TRUE == the BSS is remove. False == Fail to remove it |
| 4792 | //This function is called when list lock is held. Be caution what functions it can call. |
| 4793 | tANI_BOOLEAN csrScanAgeOutBss(tpAniSirGlobal pMac, tCsrScanResult *pResult) |
| 4794 | { |
| 4795 | tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE; |
| 4796 | tANI_U32 i; |
| 4797 | tCsrRoamSession *pSession; |
| 4798 | |
| 4799 | for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ ) |
| 4800 | { |
| 4801 | if( CSR_IS_SESSION_VALID( pMac, i ) ) |
| 4802 | { |
| 4803 | pSession = CSR_GET_SESSION( pMac, i ); |
| 4804 | //Not to remove the BSS we are connected to. |
| 4805 | if(csrIsConnStateDisconnected(pMac, i) || (NULL == pSession->pConnectBssDesc) || |
| 4806 | (!csrIsDuplicateBssDescription(pMac, &pResult->Result.BssDescriptor, |
| 4807 | pSession->pConnectBssDesc, NULL)) |
| 4808 | ) |
| 4809 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 4810 | smsLog(pMac, LOGW, "Aging out BSS %02X-%02X-%02X-%02X-%02X-%02X Channel %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4811 | pResult->Result.BssDescriptor.bssId[0], |
| 4812 | pResult->Result.BssDescriptor.bssId[1], |
| 4813 | pResult->Result.BssDescriptor.bssId[2], |
| 4814 | pResult->Result.BssDescriptor.bssId[3], |
| 4815 | pResult->Result.BssDescriptor.bssId[4], |
| 4816 | pResult->Result.BssDescriptor.bssId[5], |
| 4817 | pResult->Result.BssDescriptor.channelId); |
| 4818 | //No need to hold the spin lock because caller should hold the lock for pMac->scan.scanResultList |
| 4819 | if( csrLLRemoveEntry(&pMac->scan.scanResultList, &pResult->Link, LL_ACCESS_NOLOCK) ) |
| 4820 | { |
| 4821 | csrFreeScanResultEntry(pMac, pResult); |
Madan Mohan Koyyalamudi | 2e068bc | 2012-10-22 14:58:47 -0700 | [diff] [blame] | 4822 | fRet = eANI_BOOLEAN_TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4823 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4824 | break; |
| 4825 | } |
| 4826 | } //valid session |
| 4827 | } //for |
Madan Mohan Koyyalamudi | 2e068bc | 2012-10-22 14:58:47 -0700 | [diff] [blame] | 4828 | if( CSR_ROAM_SESSION_MAX == i && fRet != eANI_BOOLEAN_TRUE ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4829 | { |
| 4830 | //reset the counter so this won't hapeen too soon |
| 4831 | pResult->AgingCount = (tANI_S32)pMac->roam.configParam.agingCount; |
| 4832 | pResult->Result.BssDescriptor.nReceivedTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd); |
| 4833 | } |
| 4834 | |
| 4835 | return (fRet); |
| 4836 | } |
| 4837 | |
| 4838 | |
| 4839 | eHalStatus csrScanAgeResults(tpAniSirGlobal pMac, tSmeGetScanChnRsp *pScanChnInfo) |
| 4840 | { |
| 4841 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 4842 | tListElem *pEntry, *tmpEntry; |
| 4843 | tCsrScanResult *pResult; |
| 4844 | tLimScanChn *pChnInfo; |
| 4845 | tANI_U8 i; |
| 4846 | |
| 4847 | csrLLLock(&pMac->scan.scanResultList); |
| 4848 | for(i = 0; i < pScanChnInfo->numChn; i++) |
| 4849 | { |
| 4850 | pChnInfo = &pScanChnInfo->scanChn[i]; |
| 4851 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK ); |
| 4852 | while( pEntry ) |
| 4853 | { |
| 4854 | tmpEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK); |
| 4855 | pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 4856 | if(pResult->Result.BssDescriptor.channelId == pChnInfo->channelId) |
| 4857 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4858 | if(pResult->AgingCount <= 0) |
| 4859 | { |
| 4860 | smsLog(pMac, LOGW, " age out due to ref count"); |
| 4861 | csrScanAgeOutBss(pMac, pResult); |
| 4862 | } |
Madan Mohan Koyyalamudi | b9d3dcc | 2012-09-28 16:47:50 -0700 | [diff] [blame] | 4863 | else |
| 4864 | { |
| 4865 | pResult->AgingCount--; |
| 4866 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4867 | } |
| 4868 | pEntry = tmpEntry; |
| 4869 | } |
| 4870 | } |
| 4871 | csrLLUnlock(&pMac->scan.scanResultList); |
| 4872 | |
| 4873 | return (status); |
| 4874 | } |
| 4875 | |
| 4876 | |
| 4877 | eHalStatus csrSendMBScanReq( tpAniSirGlobal pMac, tANI_U16 sessionId, |
| 4878 | tCsrScanRequest *pScanReq, tScanReqParam *pScanReqParam ) |
| 4879 | { |
| 4880 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 4881 | tSirSmeScanReq *pMsg; |
| 4882 | tANI_U16 msgLen; |
| 4883 | tANI_U8 bssid[WNI_CFG_BSSID_LEN] = {0, 0, 0, 0, 0, 0}; |
| 4884 | tSirScanType scanType = pScanReq->scanType; |
| 4885 | tANI_U32 minChnTime; //in units of milliseconds |
| 4886 | tANI_U32 maxChnTime; //in units of milliseconds |
| 4887 | tANI_U32 i; |
| 4888 | tANI_U8 selfMacAddr[WNI_CFG_BSSID_LEN]; |
| 4889 | tANI_U8 *pSelfMac = NULL; |
| 4890 | |
| 4891 | msgLen = (tANI_U16)(sizeof( tSirSmeScanReq ) - sizeof( pMsg->channelList.channelNumber ) + |
| 4892 | ( sizeof( pMsg->channelList.channelNumber ) * pScanReq->ChannelInfo.numOfChannels )) + |
| 4893 | ( pScanReq->uIEFieldLen ) ; |
| 4894 | |
| 4895 | status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen); |
| 4896 | if(HAL_STATUS_SUCCESS(status)) |
| 4897 | { |
| 4898 | do |
| 4899 | { |
| 4900 | palZeroMemory(pMac->hHdd, pMsg, msgLen); |
| 4901 | pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SCAN_REQ); |
| 4902 | pMsg->length = pal_cpu_to_be16(msgLen); |
| 4903 | //ToDO: Fill in session info when we need to do scan base on session. |
| 4904 | pMsg->sessionId = 0; |
| 4905 | pMsg->transactionId = 0; |
| 4906 | pMsg->dot11mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac, csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode )); |
| 4907 | pMsg->bssType = pal_cpu_to_be32(csrTranslateBsstypeToMacType(pScanReq->BSSType)); |
| 4908 | |
| 4909 | if ( CSR_IS_SESSION_VALID( pMac, sessionId ) ) |
| 4910 | { |
| 4911 | pSelfMac = (tANI_U8 *)&pMac->roam.roamSession[sessionId].selfMacAddr; |
| 4912 | } |
| 4913 | else |
| 4914 | { |
| 4915 | // Since we don't have session for the scanning, we find a valid session. In case we fail to |
| 4916 | // do so, get the WNI_CFG_STA_ID |
| 4917 | for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ ) |
| 4918 | { |
| 4919 | if( CSR_IS_SESSION_VALID( pMac, i ) ) |
| 4920 | { |
| 4921 | pSelfMac = (tANI_U8 *)&pMac->roam.roamSession[i].selfMacAddr; |
| 4922 | break; |
| 4923 | } |
| 4924 | } |
| 4925 | if( CSR_ROAM_SESSION_MAX == i ) |
| 4926 | { |
| 4927 | tANI_U32 len = WNI_CFG_BSSID_LEN; |
| 4928 | pSelfMac = selfMacAddr; |
| 4929 | status = ccmCfgGetStr( pMac, WNI_CFG_STA_ID, pSelfMac, &len ); |
| 4930 | if( !HAL_STATUS_SUCCESS( status ) || |
| 4931 | ( len < WNI_CFG_BSSID_LEN ) ) |
| 4932 | { |
| 4933 | smsLog( pMac, LOGE, FL(" Can not get self MAC address from CFG status = %d"), status ); |
| 4934 | //Force failed status |
| 4935 | status = eHAL_STATUS_FAILURE; |
| 4936 | break; |
| 4937 | } |
| 4938 | } |
| 4939 | } |
| 4940 | palCopyMemory( pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr, pSelfMac, sizeof(tSirMacAddr) ); |
| 4941 | |
| 4942 | //sirCopyMacAddr |
| 4943 | palCopyMemory( pMac->hHdd, (tANI_U8 *)pMsg->bssId, (tANI_U8 *)&pScanReq->bssid, sizeof(tSirMacAddr) ); |
| 4944 | if( palEqualMemory( pMac->hHdd, pScanReq->bssid, bssid, sizeof(tCsrBssid) ) ) |
| 4945 | { |
| 4946 | palFillMemory( pMac->hHdd, pMsg->bssId, sizeof(tSirMacAddr), 0xff ); |
| 4947 | } |
| 4948 | else |
| 4949 | { |
| 4950 | palCopyMemory(pMac->hHdd, pMsg->bssId, pScanReq->bssid, WNI_CFG_BSSID_LEN); |
| 4951 | } |
| 4952 | minChnTime = pScanReq->minChnTime; |
| 4953 | maxChnTime = pScanReq->maxChnTime; |
| 4954 | |
| 4955 | //Verify the scan type first, if the scan is active scan, we need to make sure we |
| 4956 | //are allowed to do so. |
| 4957 | /* if 11d is enabled & we don't see any beacon around, scan type falls |
| 4958 | back to passive. But in BT AMP STA mode we need to send out a |
| 4959 | directed probe*/ |
| 4960 | if( (eSIR_PASSIVE_SCAN != scanType) && (eCSR_SCAN_P2P_DISCOVERY != pScanReq->requestType) |
| 4961 | && (eCSR_BSS_TYPE_WDS_STA != pScanReq->BSSType) |
| 4962 | && (eANI_BOOLEAN_FALSE == pMac->scan.fEnableBypass11d)) |
| 4963 | { |
| 4964 | scanType = pMac->scan.curScanType; |
| 4965 | if(eSIR_PASSIVE_SCAN == pMac->scan.curScanType) |
| 4966 | { |
| 4967 | if(minChnTime < pMac->roam.configParam.nPassiveMinChnTime) |
| 4968 | { |
| 4969 | minChnTime = pMac->roam.configParam.nPassiveMinChnTime; |
| 4970 | } |
| 4971 | if(maxChnTime < pMac->roam.configParam.nPassiveMaxChnTime) |
| 4972 | { |
| 4973 | maxChnTime = pMac->roam.configParam.nPassiveMaxChnTime; |
| 4974 | } |
| 4975 | } |
| 4976 | } |
| 4977 | pMsg->scanType = pal_cpu_to_be32(scanType); |
| 4978 | |
| 4979 | pMsg->numSsid = (pScanReq->SSIDs.numOfSSIDs < SIR_SCAN_MAX_NUM_SSID) ? pScanReq->SSIDs.numOfSSIDs : |
| 4980 | SIR_SCAN_MAX_NUM_SSID; |
| 4981 | if((pScanReq->SSIDs.numOfSSIDs != 0) && ( eSIR_PASSIVE_SCAN != scanType )) |
| 4982 | { |
| 4983 | for (i = 0; i < pMsg->numSsid; i++) |
| 4984 | { |
| 4985 | palCopyMemory(pMac->hHdd, &pMsg->ssId[i], &pScanReq->SSIDs.SSIDList[i].SSID, sizeof(tSirMacSSid)); |
| 4986 | } |
| 4987 | } |
| 4988 | else |
| 4989 | { |
| 4990 | //Otherwise we scan all SSID and let the result filter later |
| 4991 | for (i = 0; i < SIR_SCAN_MAX_NUM_SSID; i++) |
| 4992 | { |
| 4993 | pMsg->ssId[i].length = 0; |
| 4994 | } |
| 4995 | } |
| 4996 | |
| 4997 | //TODO: This preprocessor macro should be removed from CSR for production driver |
| 4998 | //This is a temperarory fix for scanning on FPGA. |
| 4999 | #if defined (ANI_CHIPSET_VIRGO) || defined (LIBRA_FPGA)|| defined (VOLANS_FPGA) |
| 5000 | pMsg->minChannelTime = pal_cpu_to_be32(minChnTime * 8); |
| 5001 | pMsg->maxChannelTime = pal_cpu_to_be32(maxChnTime * 8); |
| 5002 | #elif defined (ANI_CHIPSET_TAURUS) || defined(ANI_CHIPSET_LIBRA) || defined(ANI_CHIPSET_VOLANS) |
| 5003 | pMsg->minChannelTime = pal_cpu_to_be32(minChnTime); |
| 5004 | pMsg->maxChannelTime = pal_cpu_to_be32(maxChnTime); |
| 5005 | #else |
| 5006 | #error unknown chipset |
| 5007 | #endif |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 5008 | pMsg->minChannelTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc; |
| 5009 | pMsg->maxChannelTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5010 | //hidden SSID option |
| 5011 | pMsg->hiddenSsid = pScanReqParam->hiddenSsid; |
| 5012 | //rest time |
| 5013 | //pMsg->restTime = pScanReq->restTime; |
| 5014 | pMsg->returnAfterFirstMatch = pScanReqParam->bReturnAfter1stMatch; |
| 5015 | // All the scan results caching will be done by Roaming |
| 5016 | // We do not want LIM to do any caching of scan results, |
| 5017 | // so delete the LIM cache on all scan requests |
| 5018 | pMsg->returnFreshResults = pScanReqParam->freshScan; |
| 5019 | //Always ask for unique result |
| 5020 | pMsg->returnUniqueResults = pScanReqParam->fUniqueResult; |
| 5021 | pMsg->channelList.numChannels = (tANI_U8)pScanReq->ChannelInfo.numOfChannels; |
| 5022 | if(pScanReq->ChannelInfo.numOfChannels) |
| 5023 | { |
| 5024 | //Assuming the channelNumber is tANI_U8 (1 byte) |
| 5025 | status = palCopyMemory(pMac->hHdd, pMsg->channelList.channelNumber, pScanReq->ChannelInfo.ChannelList, |
| 5026 | pScanReq->ChannelInfo.numOfChannels); |
| 5027 | } |
| 5028 | |
| 5029 | pMsg->uIEFieldLen = (tANI_U16) pScanReq->uIEFieldLen; |
| 5030 | pMsg->uIEFieldOffset = (tANI_U16)(sizeof( tSirSmeScanReq ) - sizeof( pMsg->channelList.channelNumber ) + |
| 5031 | ( sizeof( pMsg->channelList.channelNumber ) * pScanReq->ChannelInfo.numOfChannels )) ; |
| 5032 | if(pScanReq->uIEFieldLen != 0) |
| 5033 | { |
| 5034 | palCopyMemory(pMac->hHdd, (tANI_U8 *)pMsg+pMsg->uIEFieldOffset, |
| 5035 | pScanReq->pIEField, pScanReq->uIEFieldLen ); |
| 5036 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5037 | pMsg->p2pSearch = pScanReq->p2pSearch; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5038 | |
Madan Mohan Koyyalamudi | 9b87678 | 2012-10-11 16:22:51 -0700 | [diff] [blame] | 5039 | if (pScanReq->requestType == eCSR_SCAN_HO_BG_SCAN) |
| 5040 | { |
| 5041 | pMsg->backgroundScanMode = eSIR_ROAMING_SCAN; |
| 5042 | } |
| 5043 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5044 | }while(0); |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 5045 | smsLog(pMac, LOG1, FL("domainIdCurrent %d scanType %d bssType %d requestType %d numChannels %d "), |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 5046 | pMac->scan.domainIdCurrent, pMsg->scanType, pMsg->bssType, |
| 5047 | pScanReq->requestType, pMsg->channelList.numChannels); |
| 5048 | |
| 5049 | for(i = 0; i < pMsg->channelList.numChannels; i++) |
| 5050 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 5051 | smsLog(pMac, LOG3, FL("channelNumber[%d]= %d"), i, pMsg->channelList.channelNumber[i]); |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 5052 | } |
| 5053 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5054 | if(HAL_STATUS_SUCCESS(status)) |
| 5055 | { |
| 5056 | status = palSendMBMessage(pMac->hHdd, pMsg); |
| 5057 | } |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 5058 | else |
| 5059 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 5060 | smsLog( pMac, LOGE, FL(" failed to send down scan req with status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5061 | palFreeMemory(pMac->hHdd, pMsg); |
| 5062 | } |
| 5063 | }//Success allocated memory |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 5064 | else |
| 5065 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 5066 | smsLog( pMac, LOGE, FL(" memory allocation failure")); |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 5067 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5068 | |
| 5069 | return( status ); |
| 5070 | } |
| 5071 | |
| 5072 | eHalStatus csrSendMBScanResultReq( tpAniSirGlobal pMac, tScanReqParam *pScanReqParam ) |
| 5073 | { |
| 5074 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 5075 | tSirSmeScanReq *pMsg; |
| 5076 | tANI_U16 msgLen; |
| 5077 | |
| 5078 | msgLen = (tANI_U16)(sizeof( tSirSmeScanReq )); |
| 5079 | status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen); |
| 5080 | if(HAL_STATUS_SUCCESS(status)) |
| 5081 | { |
| 5082 | palZeroMemory(pMac->hHdd, pMsg, msgLen); |
| 5083 | pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SCAN_REQ); |
| 5084 | pMsg->length = pal_cpu_to_be16(msgLen); |
| 5085 | pMsg->sessionId = 0; |
| 5086 | pMsg->returnFreshResults = pScanReqParam->freshScan; |
| 5087 | //Always ask for unique result |
| 5088 | pMsg->returnUniqueResults = pScanReqParam->fUniqueResult; |
| 5089 | pMsg->returnAfterFirstMatch = pScanReqParam->bReturnAfter1stMatch; |
| 5090 | status = palSendMBMessage(pMac->hHdd, pMsg); |
| 5091 | } |
| 5092 | |
| 5093 | return( status ); |
| 5094 | } |
| 5095 | |
| 5096 | |
| 5097 | |
| 5098 | eHalStatus csrScanChannels( tpAniSirGlobal pMac, tSmeCmd *pCommand ) |
| 5099 | { |
| 5100 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 5101 | tScanReqParam scanReq; |
| 5102 | |
| 5103 | do |
| 5104 | { |
| 5105 | scanReq.freshScan = CSR_SME_SCAN_FLAGS_DELETE_CACHE | TRUE; |
| 5106 | scanReq.fUniqueResult = TRUE; |
| 5107 | scanReq.hiddenSsid = SIR_SCAN_NO_HIDDEN_SSID; |
| 5108 | if(eCsrScanForSsid == pCommand->u.scanCmd.reason) |
| 5109 | { |
| 5110 | scanReq.bReturnAfter1stMatch = CSR_SCAN_RETURN_AFTER_FIRST_MATCH; |
| 5111 | } |
| 5112 | else |
| 5113 | { |
| 5114 | // Basically do scan on all channels even for 11D 1st scan case. |
| 5115 | scanReq.bReturnAfter1stMatch = CSR_SCAN_RETURN_AFTER_ALL_CHANNELS; |
| 5116 | } |
| 5117 | if((eCsrScanBgScan == pCommand->u.scanCmd.reason)|| |
| 5118 | (eCsrScanProbeBss == pCommand->u.scanCmd.reason)) |
| 5119 | { |
| 5120 | scanReq.hiddenSsid = SIR_SCAN_HIDDEN_SSID_PE_DECISION; |
| 5121 | } |
| 5122 | |
| 5123 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 5124 | { |
| 5125 | vos_log_scan_pkt_type *pScanLog = NULL; |
| 5126 | |
| 5127 | WLAN_VOS_DIAG_LOG_ALLOC(pScanLog, vos_log_scan_pkt_type, LOG_WLAN_SCAN_C); |
| 5128 | if(pScanLog) |
| 5129 | { |
| 5130 | if(eCsrScanBgScan == pCommand->u.scanCmd.reason || |
| 5131 | eCsrScanProbeBss == pCommand->u.scanCmd.reason) |
| 5132 | { |
| 5133 | pScanLog->eventId = WLAN_SCAN_EVENT_HO_SCAN_REQ; |
| 5134 | } |
| 5135 | else |
| 5136 | { |
| 5137 | if( (eSIR_PASSIVE_SCAN != pCommand->u.scanCmd.u.scanRequest.scanType) && |
| 5138 | (eSIR_PASSIVE_SCAN != pMac->scan.curScanType) ) |
| 5139 | { |
| 5140 | pScanLog->eventId = WLAN_SCAN_EVENT_ACTIVE_SCAN_REQ; |
| 5141 | } |
| 5142 | else |
| 5143 | { |
| 5144 | pScanLog->eventId = WLAN_SCAN_EVENT_PASSIVE_SCAN_REQ; |
| 5145 | } |
| 5146 | } |
| 5147 | pScanLog->minChnTime = (v_U8_t)pCommand->u.scanCmd.u.scanRequest.minChnTime; |
| 5148 | pScanLog->maxChnTime = (v_U8_t)pCommand->u.scanCmd.u.scanRequest.maxChnTime; |
| 5149 | pScanLog->numChannel = (v_U8_t)pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels; |
| 5150 | if(pScanLog->numChannel && (pScanLog->numChannel < VOS_LOG_MAX_NUM_CHANNEL)) |
| 5151 | { |
| 5152 | palCopyMemory(pMac->hHdd, pScanLog->channels, |
| 5153 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList, |
| 5154 | pScanLog->numChannel); |
| 5155 | } |
| 5156 | WLAN_VOS_DIAG_LOG_REPORT(pScanLog); |
| 5157 | } |
| 5158 | } |
| 5159 | #endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 5160 | |
| 5161 | |
| 5162 | status = csrSendMBScanReq(pMac, pCommand->sessionId, |
| 5163 | &pCommand->u.scanCmd.u.scanRequest, &scanReq); |
| 5164 | }while(0); |
| 5165 | |
| 5166 | return( status ); |
| 5167 | } |
| 5168 | |
| 5169 | |
| 5170 | eHalStatus csrScanRetrieveResult(tpAniSirGlobal pMac) |
| 5171 | { |
| 5172 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 5173 | tScanReqParam scanReq; |
| 5174 | |
| 5175 | do |
| 5176 | { |
| 5177 | //not a fresh scan |
| 5178 | scanReq.freshScan = CSR_SME_SCAN_FLAGS_DELETE_CACHE; |
| 5179 | scanReq.fUniqueResult = TRUE; |
| 5180 | scanReq.bReturnAfter1stMatch = CSR_SCAN_RETURN_AFTER_ALL_CHANNELS; |
| 5181 | status = csrSendMBScanResultReq(pMac, &scanReq); |
| 5182 | }while(0); |
| 5183 | |
| 5184 | return (status); |
| 5185 | } |
| 5186 | |
| 5187 | |
| 5188 | |
| 5189 | eHalStatus csrProcessScanCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand ) |
| 5190 | { |
| 5191 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 5192 | tCsrChannelInfo newChannelInfo = {0, NULL}; |
| 5193 | int i, j; |
| 5194 | tANI_U8 *pChannel = NULL; |
| 5195 | tANI_U32 len = 0; |
| 5196 | |
| 5197 | // Transition to Scanning state... |
| 5198 | for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ ) |
| 5199 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5200 | pCommand->u.scanCmd.lastRoamState[i] = csrRoamStateChange( pMac, eCSR_ROAMING_STATE_SCANNING, i); |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 5201 | smsLog( pMac, LOG3, "starting SCAN command from %d state.... reason is %d", pCommand->u.scanCmd.lastRoamState[i], pCommand->u.scanCmd.reason ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5202 | } |
| 5203 | |
| 5204 | switch(pCommand->u.scanCmd.reason) |
| 5205 | { |
| 5206 | case eCsrScanGetResult: |
| 5207 | case eCsrScanForCapsChange: //For cap change, LIM already save BSS description |
| 5208 | status = csrScanRetrieveResult(pMac); |
| 5209 | break; |
| 5210 | case eCsrScanSetBGScanParam: |
| 5211 | status = csrProcessSetBGScanParam(pMac, pCommand); |
| 5212 | break; |
| 5213 | case eCsrScanBGScanAbort: |
| 5214 | status = csrSetCfgBackgroundScanPeriod(pMac, 0); |
| 5215 | break; |
| 5216 | case eCsrScanBGScanEnable: |
| 5217 | status = csrSetCfgBackgroundScanPeriod(pMac, pMac->roam.configParam.bgScanInterval); |
| 5218 | break; |
| 5219 | case eCsrScanGetScanChnInfo: |
| 5220 | status = csrScanGetScanChannelInfo(pMac); |
| 5221 | break; |
| 5222 | case eCsrScanUserRequest: |
| 5223 | if(pMac->roam.configParam.fScanTwice) |
| 5224 | { |
| 5225 | //We scan 2.4 channel twice |
| 5226 | if(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels && |
| 5227 | (NULL != pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList)) |
| 5228 | { |
| 5229 | len = pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels; |
| 5230 | //allocate twice the channel |
| 5231 | newChannelInfo.ChannelList = (tANI_U8 *)vos_mem_malloc(newChannelInfo.numOfChannels * 2); |
| 5232 | pChannel = pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList; |
| 5233 | } |
| 5234 | else |
| 5235 | { |
| 5236 | //get the valid channel list to scan all. |
| 5237 | len = sizeof(pMac->roam.validChannelList); |
| 5238 | |
| 5239 | if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len))) |
| 5240 | { |
| 5241 | //allocate twice the channel |
| 5242 | newChannelInfo.ChannelList = (tANI_U8 *)vos_mem_malloc(len * 2); |
| 5243 | pChannel = pMac->roam.validChannelList; |
| 5244 | } |
| 5245 | } |
| 5246 | if(NULL == newChannelInfo.ChannelList) |
| 5247 | { |
| 5248 | newChannelInfo.numOfChannels = 0; |
| 5249 | } |
| 5250 | else |
| 5251 | { |
| 5252 | j = 0; |
| 5253 | for(i = 0; i < len; i++) |
| 5254 | { |
| 5255 | newChannelInfo.ChannelList[j++] = pChannel[i]; |
| 5256 | if(CSR_MAX_24GHz_CHANNEL_NUMBER >= pChannel[i]) |
| 5257 | { |
| 5258 | newChannelInfo.ChannelList[j++] = pChannel[i]; |
| 5259 | } |
| 5260 | } |
| 5261 | if(NULL != pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList) |
| 5262 | { |
| 5263 | //pChannel points to the channellist from the command, free it. |
| 5264 | vos_mem_free(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList); |
| 5265 | } |
| 5266 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = j; |
| 5267 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = newChannelInfo.ChannelList; |
| 5268 | } |
| 5269 | } //if(pMac->roam.configParam.fScanTwice) |
| 5270 | |
| 5271 | status = csrScanChannels(pMac, pCommand); |
| 5272 | |
| 5273 | break; |
| 5274 | default: |
| 5275 | status = csrScanChannels(pMac, pCommand); |
| 5276 | break; |
| 5277 | } |
| 5278 | |
| 5279 | if(!HAL_STATUS_SUCCESS(status)) |
| 5280 | { |
| 5281 | csrReleaseScanCommand(pMac, pCommand, eCSR_SCAN_FAILURE); |
| 5282 | } |
| 5283 | |
| 5284 | return (status); |
| 5285 | } |
| 5286 | |
| 5287 | |
| 5288 | eHalStatus csrScanSetBGScanparams(tpAniSirGlobal pMac, tCsrBGScanRequest *pScanReq) |
| 5289 | { |
| 5290 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 5291 | tSmeCmd *pCommand = NULL; |
| 5292 | |
| 5293 | if(pScanReq) |
| 5294 | { |
| 5295 | do |
| 5296 | { |
| 5297 | pCommand = csrGetCommandBuffer(pMac); |
| 5298 | if(!pCommand) |
| 5299 | { |
| 5300 | status = eHAL_STATUS_RESOURCES; |
| 5301 | break; |
| 5302 | } |
| 5303 | palZeroMemory(pMac->hHdd, &pCommand->u.scanCmd, sizeof(tScanCmd)); |
| 5304 | pCommand->command = eSmeCommandScan; |
| 5305 | pCommand->u.scanCmd.reason = eCsrScanSetBGScanParam; |
| 5306 | pCommand->u.scanCmd.callback = NULL; |
| 5307 | pCommand->u.scanCmd.pContext = NULL; |
| 5308 | palCopyMemory(pMac->hHdd, &pCommand->u.scanCmd.u.bgScanRequest, pScanReq, sizeof(tCsrBGScanRequest)); |
| 5309 | //we have to do the follow |
| 5310 | if(pScanReq->ChannelInfo.numOfChannels == 0) |
| 5311 | { |
| 5312 | pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList = NULL; |
| 5313 | } |
| 5314 | else |
| 5315 | { |
| 5316 | status = palAllocateMemory(pMac->hHdd, (void **)&pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList, |
| 5317 | pScanReq->ChannelInfo.numOfChannels); |
| 5318 | if(HAL_STATUS_SUCCESS(status)) |
| 5319 | { |
| 5320 | palCopyMemory(pMac->hHdd, pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList, |
| 5321 | pScanReq->ChannelInfo.ChannelList, pScanReq->ChannelInfo.numOfChannels); |
| 5322 | } |
| 5323 | else |
| 5324 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 5325 | smsLog(pMac, LOGE, FL("ran out of memory")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5326 | csrReleaseCommandScan(pMac, pCommand); |
| 5327 | break; |
| 5328 | } |
| 5329 | } |
| 5330 | |
| 5331 | //scan req for SSID |
| 5332 | if(pScanReq->SSID.length) |
| 5333 | { |
| 5334 | palCopyMemory(pMac->hHdd, |
| 5335 | pCommand->u.scanCmd.u.bgScanRequest.SSID.ssId, |
| 5336 | pScanReq->SSID.ssId, |
| 5337 | pScanReq->SSID.length); |
| 5338 | pCommand->u.scanCmd.u.bgScanRequest.SSID.length = pScanReq->SSID.length; |
| 5339 | |
| 5340 | } |
| 5341 | pCommand->u.scanCmd.u.bgScanRequest.maxChnTime= pScanReq->maxChnTime; |
| 5342 | pCommand->u.scanCmd.u.bgScanRequest.minChnTime = pScanReq->minChnTime; |
| 5343 | pCommand->u.scanCmd.u.bgScanRequest.scanInterval = pScanReq->scanInterval; |
| 5344 | |
| 5345 | |
| 5346 | status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE); |
| 5347 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 5348 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 5349 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5350 | csrReleaseCommandScan( pMac, pCommand ); |
| 5351 | break; |
| 5352 | } |
| 5353 | }while(0); |
| 5354 | } |
| 5355 | |
| 5356 | return (status); |
| 5357 | } |
| 5358 | |
| 5359 | eHalStatus csrScanBGScanAbort( tpAniSirGlobal pMac ) |
| 5360 | { |
| 5361 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 5362 | tSmeCmd *pCommand = NULL; |
| 5363 | |
| 5364 | do |
| 5365 | { |
| 5366 | pCommand = csrGetCommandBuffer(pMac); |
| 5367 | if(!pCommand) |
| 5368 | { |
| 5369 | status = eHAL_STATUS_RESOURCES; |
| 5370 | break; |
| 5371 | } |
| 5372 | palZeroMemory(pMac->hHdd, &pCommand->u.scanCmd, sizeof(tScanCmd)); |
| 5373 | pCommand->command = eSmeCommandScan; |
| 5374 | pCommand->u.scanCmd.reason = eCsrScanBGScanAbort; |
| 5375 | pCommand->u.scanCmd.callback = NULL; |
| 5376 | pCommand->u.scanCmd.pContext = NULL; |
| 5377 | status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE); |
| 5378 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 5379 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 5380 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5381 | csrReleaseCommandScan( pMac, pCommand ); |
| 5382 | break; |
| 5383 | } |
| 5384 | }while(0); |
| 5385 | |
| 5386 | return (status); |
| 5387 | } |
| 5388 | |
| 5389 | |
| 5390 | //This will enable the background scan with the non-zero interval |
| 5391 | eHalStatus csrScanBGScanEnable(tpAniSirGlobal pMac) |
| 5392 | { |
| 5393 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 5394 | tSmeCmd *pCommand = NULL; |
| 5395 | |
| 5396 | if(pMac->roam.configParam.bgScanInterval) |
| 5397 | { |
| 5398 | do |
| 5399 | { |
| 5400 | pCommand = csrGetCommandBuffer(pMac); |
| 5401 | if(!pCommand) |
| 5402 | { |
| 5403 | status = eHAL_STATUS_RESOURCES; |
| 5404 | break; |
| 5405 | } |
| 5406 | palZeroMemory(pMac->hHdd, &pCommand->u.scanCmd, sizeof(tScanCmd)); |
| 5407 | pCommand->command = eSmeCommandScan; |
| 5408 | pCommand->u.scanCmd.reason = eCsrScanBGScanEnable; |
| 5409 | pCommand->u.scanCmd.callback = NULL; |
| 5410 | pCommand->u.scanCmd.pContext = NULL; |
| 5411 | status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE); |
| 5412 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 5413 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 5414 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5415 | csrReleaseCommandScan( pMac, pCommand ); |
| 5416 | break; |
| 5417 | } |
| 5418 | }while(0); |
| 5419 | //BG scan results are reported automatically by PE to SME once the scan is done. |
| 5420 | //No need to fetch the results explicitly. |
| 5421 | //csrScanStartGetResultTimer(pMac); |
| 5422 | csrScanStartResultAgingTimer(pMac); |
| 5423 | } |
| 5424 | else |
| 5425 | { |
| 5426 | //We don't have BG scan so stop the aging timer |
| 5427 | csrScanStopResultAgingTimer(pMac); |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 5428 | smsLog(pMac, LOGE, FL("cannot continue because the bgscan interval is 0")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5429 | status = eHAL_STATUS_INVALID_PARAMETER; |
| 5430 | } |
| 5431 | |
| 5432 | return (status); |
| 5433 | } |
| 5434 | |
| 5435 | |
| 5436 | eHalStatus csrScanCopyRequest(tpAniSirGlobal pMac, tCsrScanRequest *pDstReq, tCsrScanRequest *pSrcReq) |
| 5437 | { |
| 5438 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 5439 | tANI_U32 len = sizeof(pMac->roam.validChannelList); |
| 5440 | tANI_U32 index = 0; |
| 5441 | tANI_U32 new_index = 0; |
| 5442 | |
| 5443 | do |
| 5444 | { |
| 5445 | status = csrScanFreeRequest(pMac, pDstReq); |
| 5446 | if(HAL_STATUS_SUCCESS(status)) |
| 5447 | { |
| 5448 | status = palCopyMemory(pMac->hHdd, pDstReq, pSrcReq, sizeof(tCsrScanRequest)); |
Gopichand Nakkala | c7b1d3e | 2012-12-31 14:07:19 -0800 | [diff] [blame] | 5449 | /* Re-initialize the pointers to NULL since we did a copy */ |
| 5450 | pDstReq->pIEField = NULL; |
| 5451 | pDstReq->ChannelInfo.ChannelList = NULL; |
| 5452 | pDstReq->SSIDs.SSIDList = NULL; |
| 5453 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5454 | if(pSrcReq->uIEFieldLen == 0) |
| 5455 | { |
| 5456 | pDstReq->pIEField = NULL; |
| 5457 | } |
| 5458 | else |
| 5459 | { |
| 5460 | status = palAllocateMemory(pMac->hHdd, (void **)&pDstReq->pIEField, pSrcReq->uIEFieldLen); |
| 5461 | if(HAL_STATUS_SUCCESS(status)) |
| 5462 | { |
| 5463 | palCopyMemory(pMac->hHdd, pDstReq->pIEField, pSrcReq->pIEField, pSrcReq->uIEFieldLen); |
| 5464 | pDstReq->uIEFieldLen = pSrcReq->uIEFieldLen; |
| 5465 | } |
| 5466 | else |
| 5467 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 5468 | smsLog(pMac, LOGE, "No memory for scanning IE fields"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5469 | break; |
| 5470 | } |
| 5471 | }//Allocate memory for IE field |
| 5472 | { |
| 5473 | if(pSrcReq->ChannelInfo.numOfChannels == 0) |
| 5474 | { |
| 5475 | pDstReq->ChannelInfo.ChannelList = NULL; |
| 5476 | pDstReq->ChannelInfo.numOfChannels = 0; |
| 5477 | } |
| 5478 | else |
| 5479 | { |
| 5480 | status = palAllocateMemory(pMac->hHdd, (void **)&pDstReq->ChannelInfo.ChannelList, |
| 5481 | pSrcReq->ChannelInfo.numOfChannels * sizeof(*pDstReq->ChannelInfo.ChannelList)); |
| 5482 | if(!HAL_STATUS_SUCCESS(status)) |
| 5483 | { |
| 5484 | pDstReq->ChannelInfo.numOfChannels = 0; |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 5485 | smsLog(pMac, LOGE, "No memory for scanning Channel List"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5486 | break; |
| 5487 | } |
| 5488 | |
| 5489 | if((pSrcReq->scanType == eSIR_PASSIVE_SCAN) && (pSrcReq->requestType == eCSR_SCAN_REQUEST_11D_SCAN)) |
| 5490 | { |
| 5491 | for ( index = 0; index < pSrcReq->ChannelInfo.numOfChannels ; index++ ) |
| 5492 | { |
| 5493 | pDstReq->ChannelInfo.ChannelList[new_index] = |
| 5494 | pSrcReq->ChannelInfo.ChannelList[index]; |
| 5495 | new_index++; |
| 5496 | } |
| 5497 | pDstReq->ChannelInfo.numOfChannels = new_index; |
| 5498 | } |
| 5499 | else if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len))) |
| 5500 | { |
| 5501 | new_index = 0; |
| 5502 | pMac->roam.numValidChannels = len; |
| 5503 | for ( index = 0; index < pSrcReq->ChannelInfo.numOfChannels ; index++ ) |
| 5504 | { |
Madan Mohan Koyyalamudi | 783b236 | 2012-10-21 11:54:41 -0700 | [diff] [blame] | 5505 | /* Allow scan on valid channels only. |
| 5506 | * If it is p2p scan and valid channel list doesnt contain |
| 5507 | * social channels, enforce scan on social channels because |
| 5508 | * that is the only way to find p2p peers. |
| 5509 | * This can happen only if band is set to 5Ghz mode. |
| 5510 | */ |
Madan Mohan Koyyalamudi | c5992c9 | 2012-11-15 16:40:57 -0800 | [diff] [blame] | 5511 | if((csrRoamIsValidChannel(pMac, pSrcReq->ChannelInfo.ChannelList[index])) || |
| 5512 | ((eCSR_SCAN_P2P_DISCOVERY == pSrcReq->requestType) && |
Madan Mohan Koyyalamudi | 783b236 | 2012-10-21 11:54:41 -0700 | [diff] [blame] | 5513 | CSR_IS_SOCIAL_CHANNEL(pSrcReq->ChannelInfo.ChannelList[index]))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5514 | { |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 5515 | if( (pSrcReq->skipDfsChnlInP2pSearch && |
Madan Mohan Koyyalamudi | c5992c9 | 2012-11-15 16:40:57 -0800 | [diff] [blame] | 5516 | (NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(pSrcReq->ChannelInfo.ChannelList[index])) ) |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 5517 | #ifdef FEATURE_WLAN_LFR |
| 5518 | /* |
| 5519 | * If LFR is requesting a contiguous scan |
| 5520 | * (i.e. numOfChannels > 1), then ignore |
| 5521 | * DFS channels. |
| 5522 | * TODO: vos_nv_getChannelEnabledState is returning |
| 5523 | * 120, 124 and 128 as non-DFS channels. Hence, the |
| 5524 | * use of direct check for channels below. |
| 5525 | */ |
| 5526 | || ((eCSR_SCAN_HO_BG_SCAN == pSrcReq->requestType) && |
| 5527 | (pSrcReq->ChannelInfo.numOfChannels > 1) && |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 5528 | (CSR_IS_CHANNEL_DFS(pSrcReq->ChannelInfo.ChannelList[index]))) |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 5529 | #endif |
| 5530 | ) |
| 5531 | { |
| 5532 | #ifdef FEATURE_WLAN_LFR |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 5533 | smsLog(pMac, LOG2, |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 5534 | "%s: reqType=%d, numOfChannels=%d," |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 5535 | " ignoring DFS channel %d", |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 5536 | __func__, pSrcReq->requestType, |
| 5537 | pSrcReq->ChannelInfo.numOfChannels, |
| 5538 | pSrcReq->ChannelInfo.ChannelList[index]); |
| 5539 | #endif |
Madan Mohan Koyyalamudi | c5992c9 | 2012-11-15 16:40:57 -0800 | [diff] [blame] | 5540 | continue; |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 5541 | } |
Madan Mohan Koyyalamudi | c5992c9 | 2012-11-15 16:40:57 -0800 | [diff] [blame] | 5542 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5543 | pDstReq->ChannelInfo.ChannelList[new_index] = |
| 5544 | pSrcReq->ChannelInfo.ChannelList[index]; |
| 5545 | new_index++; |
| 5546 | } |
| 5547 | } |
| 5548 | pDstReq->ChannelInfo.numOfChannels = new_index; |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 5549 | #ifdef FEATURE_WLAN_LFR |
| 5550 | if ((eCSR_SCAN_HO_BG_SCAN == pSrcReq->requestType) && |
| 5551 | (0 == pDstReq->ChannelInfo.numOfChannels)) |
| 5552 | { |
| 5553 | /* |
| 5554 | * No valid channels found in the request. |
| 5555 | * Only perform scan on the channels passed |
| 5556 | * pSrcReq if it is a eCSR_SCAN_HO_BG_SCAN. |
| 5557 | * Passing 0 to LIM will trigger a scan on |
| 5558 | * all valid channels which is not desirable. |
| 5559 | */ |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 5560 | smsLog(pMac, LOGE, "%s: no valid channels found (request=%d)", |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 5561 | __func__, pSrcReq->requestType); |
| 5562 | for ( index = 0; index < pSrcReq->ChannelInfo.numOfChannels ; index++ ) |
| 5563 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 5564 | smsLog(pMac, LOGE, "pSrcReq index=%d channel=%d", |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 5565 | index, pSrcReq->ChannelInfo.ChannelList[index]); |
| 5566 | } |
| 5567 | status = eHAL_STATUS_FAILURE; |
| 5568 | break; |
| 5569 | } |
| 5570 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5571 | } |
| 5572 | else |
| 5573 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 5574 | smsLog(pMac, LOGE, "Couldn't get the valid Channel List, keeping requester's list"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5575 | palCopyMemory(pMac->hHdd, pDstReq->ChannelInfo.ChannelList, pSrcReq->ChannelInfo.ChannelList, |
| 5576 | pSrcReq->ChannelInfo.numOfChannels * sizeof(*pDstReq->ChannelInfo.ChannelList)); |
| 5577 | pDstReq->ChannelInfo.numOfChannels = pSrcReq->ChannelInfo.numOfChannels; |
| 5578 | } |
| 5579 | }//Allocate memory for Channel List |
| 5580 | } |
| 5581 | if(pSrcReq->SSIDs.numOfSSIDs == 0) |
| 5582 | { |
| 5583 | pDstReq->SSIDs.numOfSSIDs = 0; |
| 5584 | pDstReq->SSIDs.SSIDList = NULL; |
| 5585 | } |
| 5586 | else |
| 5587 | { |
| 5588 | status = palAllocateMemory(pMac->hHdd, (void **)&pDstReq->SSIDs.SSIDList, |
| 5589 | pSrcReq->SSIDs.numOfSSIDs * sizeof(*pDstReq->SSIDs.SSIDList)); |
| 5590 | if(HAL_STATUS_SUCCESS(status)) |
| 5591 | { |
| 5592 | pDstReq->SSIDs.numOfSSIDs = pSrcReq->SSIDs.numOfSSIDs; |
| 5593 | palCopyMemory(pMac->hHdd, pDstReq->SSIDs.SSIDList, pSrcReq->SSIDs.SSIDList, |
| 5594 | pSrcReq->SSIDs.numOfSSIDs * sizeof(*pDstReq->SSIDs.SSIDList)); |
| 5595 | } |
| 5596 | else |
| 5597 | { |
| 5598 | pDstReq->SSIDs.numOfSSIDs = 0; |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 5599 | smsLog(pMac, LOGE, "No memory for scanning SSID List"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5600 | break; |
| 5601 | } |
| 5602 | }//Allocate memory for SSID List |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5603 | pDstReq->p2pSearch = pSrcReq->p2pSearch; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5604 | pDstReq->skipDfsChnlInP2pSearch = pSrcReq->skipDfsChnlInP2pSearch; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5605 | |
| 5606 | } |
| 5607 | }while(0); |
| 5608 | |
| 5609 | if(!HAL_STATUS_SUCCESS(status)) |
| 5610 | { |
| 5611 | csrScanFreeRequest(pMac, pDstReq); |
| 5612 | } |
| 5613 | |
| 5614 | return (status); |
| 5615 | } |
| 5616 | |
| 5617 | |
| 5618 | eHalStatus csrScanFreeRequest(tpAniSirGlobal pMac, tCsrScanRequest *pReq) |
| 5619 | { |
| 5620 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 5621 | |
| 5622 | if(pReq->ChannelInfo.ChannelList) |
| 5623 | { |
| 5624 | status = palFreeMemory(pMac->hHdd, pReq->ChannelInfo.ChannelList); |
| 5625 | pReq->ChannelInfo.ChannelList = NULL; |
| 5626 | } |
| 5627 | pReq->ChannelInfo.numOfChannels = 0; |
| 5628 | if(pReq->pIEField) |
| 5629 | { |
| 5630 | status = palFreeMemory(pMac->hHdd, pReq->pIEField); |
| 5631 | pReq->pIEField = NULL; |
| 5632 | } |
| 5633 | pReq->uIEFieldLen = 0; |
| 5634 | if(pReq->SSIDs.SSIDList) |
| 5635 | { |
| 5636 | palFreeMemory(pMac->hHdd, pReq->SSIDs.SSIDList); |
| 5637 | pReq->SSIDs.SSIDList = NULL; |
| 5638 | } |
| 5639 | pReq->SSIDs.numOfSSIDs = 0; |
| 5640 | |
| 5641 | return (status); |
| 5642 | } |
| 5643 | |
| 5644 | |
| 5645 | void csrScanCallCallback(tpAniSirGlobal pMac, tSmeCmd *pCommand, eCsrScanStatus scanStatus) |
| 5646 | { |
| 5647 | if(pCommand->u.scanCmd.callback) |
| 5648 | { |
| 5649 | // sme_ReleaseGlobalLock( &pMac->sme ); |
| 5650 | pCommand->u.scanCmd.callback(pMac, pCommand->u.scanCmd.pContext, pCommand->u.scanCmd.scanID, scanStatus); |
| 5651 | // sme_AcquireGlobalLock( &pMac->sme ); |
| 5652 | } else { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 5653 | smsLog( pMac, LOG2, "%s:%d - Callback NULL!!!", __func__, __LINE__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5654 | } |
| 5655 | } |
| 5656 | |
| 5657 | |
| 5658 | void csrScanStopTimers(tpAniSirGlobal pMac) |
| 5659 | { |
| 5660 | csrScanStopResultAgingTimer(pMac); |
| 5661 | csrScanStopIdleScanTimer(pMac); |
| 5662 | csrScanStopGetResultTimer(pMac); |
Sandeep Puligilla | 2b6dc63 | 2012-12-17 14:44:16 -0800 | [diff] [blame] | 5663 | if(0 != pMac->scan.scanResultCfgAgingTime ) |
| 5664 | { |
| 5665 | csrScanStopResultCfgAgingTimer(pMac); |
| 5666 | } |
| 5667 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5668 | } |
| 5669 | |
| 5670 | |
| 5671 | eHalStatus csrScanStartGetResultTimer(tpAniSirGlobal pMac) |
| 5672 | { |
| 5673 | eHalStatus status; |
| 5674 | |
| 5675 | if(pMac->scan.fScanEnable) |
| 5676 | { |
| 5677 | status = palTimerStart(pMac->hHdd, pMac->scan.hTimerGetResult, CSR_SCAN_GET_RESULT_INTERVAL, eANI_BOOLEAN_TRUE); |
| 5678 | } |
| 5679 | else |
| 5680 | { |
| 5681 | status = eHAL_STATUS_FAILURE; |
| 5682 | } |
| 5683 | |
| 5684 | return (status); |
| 5685 | } |
| 5686 | |
| 5687 | |
| 5688 | eHalStatus csrScanStopGetResultTimer(tpAniSirGlobal pMac) |
| 5689 | { |
| 5690 | return (palTimerStop(pMac->hHdd, pMac->scan.hTimerGetResult)); |
| 5691 | } |
| 5692 | |
| 5693 | |
| 5694 | void csrScanGetResultTimerHandler(void *pv) |
| 5695 | { |
| 5696 | tpAniSirGlobal pMac = PMAC_STRUCT( pv ); |
| 5697 | |
| 5698 | csrScanRequestResult(pMac); |
| 5699 | } |
| 5700 | |
| 5701 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 5702 | static void csrStaApConcTimerHandler(void *pv) |
| 5703 | { |
| 5704 | tpAniSirGlobal pMac = PMAC_STRUCT( pv ); |
| 5705 | tListElem *pEntry; |
| 5706 | tSmeCmd *pScanCmd; |
| 5707 | |
| 5708 | csrLLLock(&pMac->scan.scanCmdPendingList); |
| 5709 | |
| 5710 | if ( NULL != ( pEntry = csrLLPeekHead( &pMac->scan.scanCmdPendingList, LL_ACCESS_NOLOCK) ) ) |
| 5711 | { |
| 5712 | tCsrScanRequest scanReq; |
| 5713 | tSmeCmd *pSendScanCmd = NULL; |
| 5714 | tANI_U8 numChn = 0; |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 5715 | tANI_U8 i, j; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5716 | tCsrChannelInfo *pChnInfo = &scanReq.ChannelInfo; |
| 5717 | tANI_U8 channelToScan[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 5718 | eHalStatus status; |
| 5719 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5720 | pScanCmd = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 5721 | numChn = pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels; |
Madan Mohan Koyyalamudi | d671358 | 2012-11-09 16:56:56 -0800 | [diff] [blame] | 5722 | |
| 5723 | /* if any session is connected and the number of channels to scan is |
| 5724 | * greater than 1 then split the scan into multiple scan operations |
| 5725 | * on each individual channel else continue to perform scan on all |
| 5726 | * specified channels */ |
Madan Mohan Koyyalamudi | 48081ef | 2012-12-04 16:49:55 -0800 | [diff] [blame] | 5727 | |
| 5728 | /* split scan if number of channels to scan is greater than 1 and |
| 5729 | * any one of the following: |
| 5730 | * - STA session is connected and the scan is not a P2P search |
| 5731 | * - any P2P session is connected |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 5732 | * Do not split scans if no concurrent infra connections are |
| 5733 | * active and if the scan is a BG scan triggered by LFR (OR) |
| 5734 | * any scan if LFR is in the middle of a BG scan. Splitting |
| 5735 | * the scan is delaying the time it takes for LFR to find |
| 5736 | * candidates and resulting in disconnects. |
Madan Mohan Koyyalamudi | 48081ef | 2012-12-04 16:49:55 -0800 | [diff] [blame] | 5737 | */ |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 5738 | if ( (numChn > pMac->roam.configParam.nNumChanCombinedConc) && |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 5739 | ((csrIsStaSessionConnected(pMac) && |
| 5740 | #ifdef FEATURE_WLAN_LFR |
| 5741 | (csrIsConcurrentInfraConnected(pMac) || |
| 5742 | ((pScanCmd->u.scanCmd.reason != eCsrScanBgScan) && |
| 5743 | (pMac->roam.neighborRoamInfo.neighborRoamState != |
| 5744 | eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN))) && |
| 5745 | #endif |
| 5746 | (pScanCmd->u.scanCmd.u.scanRequest.p2pSearch != 1)) || |
Madan Mohan Koyyalamudi | 48081ef | 2012-12-04 16:49:55 -0800 | [diff] [blame] | 5747 | (csrIsP2pSessionConnected(pMac)))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5748 | { |
| 5749 | palZeroMemory(pMac->hHdd, &scanReq, sizeof(tCsrScanRequest)); |
| 5750 | |
| 5751 | pSendScanCmd = csrGetCommandBuffer(pMac); //optimize this to use 2 command buffer only |
| 5752 | if (!pSendScanCmd) |
| 5753 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 5754 | smsLog( pMac, LOGE, FL(" Failed to get Queue command buffer") ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5755 | csrLLUnlock(&pMac->scan.scanCmdPendingList); |
| 5756 | return; |
| 5757 | } |
| 5758 | pSendScanCmd->command = pScanCmd->command; |
| 5759 | pSendScanCmd->sessionId = pScanCmd->sessionId; |
| 5760 | pSendScanCmd->u.scanCmd.callback = NULL; |
| 5761 | pSendScanCmd->u.scanCmd.pContext = pScanCmd->u.scanCmd.pContext; |
| 5762 | pSendScanCmd->u.scanCmd.reason = pScanCmd->u.scanCmd.reason; |
| 5763 | pSendScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around |
| 5764 | |
Madan Mohan Koyyalamudi | af2a8b9 | 2012-10-09 14:58:07 -0700 | [diff] [blame] | 5765 | /* First copy all the parameters to local variable of scan request */ |
| 5766 | csrScanCopyRequest(pMac, &scanReq, &pScanCmd->u.scanCmd.u.scanRequest); |
| 5767 | |
| 5768 | /* 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] | 5769 | if(scanReq.ChannelInfo.ChannelList != NULL) |
| 5770 | { |
| 5771 | palFreeMemory(pMac->hHdd,scanReq.ChannelInfo.ChannelList); |
| 5772 | scanReq.ChannelInfo.ChannelList = NULL; |
| 5773 | } |
| 5774 | |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 5775 | pChnInfo->numOfChannels = pMac->roam.configParam.nNumChanCombinedConc; |
| 5776 | palCopyMemory(pMac->hHdd, &channelToScan[0], &pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[0], |
| 5777 | pChnInfo->numOfChannels * sizeof(tANI_U8)); //just send one channel |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5778 | pChnInfo->ChannelList = &channelToScan[0]; |
| 5779 | |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 5780 | for (i = 0, j = pMac->roam.configParam.nNumChanCombinedConc; i < (numChn-pMac->roam.configParam.nNumChanCombinedConc); i++, j++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5781 | { |
| 5782 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[i] = |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 5783 | 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] | 5784 | } |
| 5785 | |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 5786 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = numChn - pMac->roam.configParam.nNumChanCombinedConc; //reduce outstanding # of channels to be scanned |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5787 | |
| 5788 | scanReq.BSSType = eCSR_BSS_TYPE_ANY; |
| 5789 | //Modify callers parameters in case of concurrency |
| 5790 | scanReq.scanType = eSIR_ACTIVE_SCAN; |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 5791 | //Use concurrency values for min/maxChnTime. |
| 5792 | //We know csrIsAnySessionConnected(pMac) returns TRUE here |
| 5793 | csrSetDefaultScanTiming(pMac, scanReq.scanType, &scanReq); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5794 | |
| 5795 | status = csrScanCopyRequest(pMac, &pSendScanCmd->u.scanCmd.u.scanRequest, &scanReq); |
| 5796 | if(!HAL_STATUS_SUCCESS(status)) |
| 5797 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 5798 | smsLog( pMac, LOGE, FL(" Failed to get copy csrScanRequest = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5799 | csrLLUnlock(&pMac->scan.scanCmdPendingList); |
| 5800 | return; |
Madan Mohan Koyyalamudi | 0c626f3 | 2012-11-30 15:10:25 -0800 | [diff] [blame] | 5801 | } |
| 5802 | /* Clean the local scan variable */ |
| 5803 | scanReq.ChannelInfo.ChannelList = NULL; |
| 5804 | scanReq.ChannelInfo.numOfChannels = 0; |
| 5805 | csrScanFreeRequest(pMac, &scanReq); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5806 | } |
| 5807 | else |
Madan Mohan Koyyalamudi | d671358 | 2012-11-09 16:56:56 -0800 | [diff] [blame] | 5808 | { |
| 5809 | /* no active connected session present or numChn == 1 |
| 5810 | * scan all remaining channels */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5811 | pSendScanCmd = pScanCmd; |
| 5812 | //remove this command from pending list |
| 5813 | if (csrLLRemoveHead( &pMac->scan.scanCmdPendingList, LL_ACCESS_NOLOCK) == NULL) |
| 5814 | { //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^] | 5815 | smsLog( pMac, LOGE, FL(" Failed to remove entry from scanCmdPendingList")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5816 | } |
| 5817 | |
| 5818 | } |
| 5819 | csrQueueSmeCommand(pMac, pSendScanCmd, eANI_BOOLEAN_FALSE); |
| 5820 | |
| 5821 | } |
| 5822 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5823 | csrLLUnlock(&pMac->scan.scanCmdPendingList); |
| 5824 | |
| 5825 | } |
| 5826 | #endif |
| 5827 | |
| 5828 | eHalStatus csrScanStartResultAgingTimer(tpAniSirGlobal pMac) |
| 5829 | { |
Sandeep Puligilla | 2b6dc63 | 2012-12-17 14:44:16 -0800 | [diff] [blame] | 5830 | eHalStatus status = eHAL_STATUS_FAILURE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5831 | |
| 5832 | if(pMac->scan.fScanEnable) |
| 5833 | { |
| 5834 | status = palTimerStart(pMac->hHdd, pMac->scan.hTimerResultAging, CSR_SCAN_RESULT_AGING_INTERVAL, eANI_BOOLEAN_TRUE); |
| 5835 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5836 | return (status); |
| 5837 | } |
| 5838 | |
Sandeep Puligilla | 2b6dc63 | 2012-12-17 14:44:16 -0800 | [diff] [blame] | 5839 | eHalStatus csrScanStartResultCfgAgingTimer(tpAniSirGlobal pMac) |
| 5840 | { |
| 5841 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 5842 | |
| 5843 | if(pMac->scan.fScanEnable) |
| 5844 | { |
| 5845 | status = palTimerStart(pMac->hHdd, pMac->scan.hTimerResultCfgAging, |
| 5846 | CSR_SCAN_RESULT_CFG_AGING_INTERVAL, eANI_BOOLEAN_TRUE); |
| 5847 | } |
| 5848 | return (status); |
| 5849 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5850 | |
| 5851 | eHalStatus csrScanStopResultAgingTimer(tpAniSirGlobal pMac) |
| 5852 | { |
| 5853 | return (palTimerStop(pMac->hHdd, pMac->scan.hTimerResultAging)); |
| 5854 | } |
| 5855 | |
Sandeep Puligilla | 2b6dc63 | 2012-12-17 14:44:16 -0800 | [diff] [blame] | 5856 | eHalStatus csrScanStopResultCfgAgingTimer(tpAniSirGlobal pMac) |
| 5857 | { |
| 5858 | return (palTimerStop(pMac->hHdd, pMac->scan.hTimerResultCfgAging)); |
| 5859 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5860 | |
| 5861 | //This function returns the maximum time a BSS is allowed in the scan result. |
| 5862 | //The time varies base on connection and power saving factors. |
| 5863 | //Not connected, No PS |
| 5864 | //Not connected, with PS |
| 5865 | //Connected w/o traffic, No PS |
| 5866 | //Connected w/o traffic, with PS |
| 5867 | //Connected w/ traffic, no PS -- Not supported |
| 5868 | //Connected w/ traffic, with PS -- Not supported |
| 5869 | //the return unit is in seconds. |
| 5870 | tANI_U32 csrScanGetAgeOutTime(tpAniSirGlobal pMac) |
| 5871 | { |
| 5872 | tANI_U32 nRet; |
| 5873 | |
| 5874 | if(pMac->scan.nAgingCountDown) |
| 5875 | { |
| 5876 | //Calculate what should be the timeout value for this |
| 5877 | nRet = pMac->scan.nLastAgeTimeOut * pMac->scan.nAgingCountDown; |
| 5878 | pMac->scan.nAgingCountDown--; |
| 5879 | } |
| 5880 | else |
| 5881 | { |
| 5882 | if( csrIsAllSessionDisconnected( pMac ) ) |
| 5883 | { |
| 5884 | if(pmcIsPowerSaveEnabled(pMac, ePMC_IDLE_MODE_POWER_SAVE)) |
| 5885 | { |
| 5886 | nRet = pMac->roam.configParam.scanAgeTimeNCPS; |
| 5887 | } |
| 5888 | else |
| 5889 | { |
| 5890 | nRet = pMac->roam.configParam.scanAgeTimeNCNPS; |
| 5891 | } |
| 5892 | } |
| 5893 | else |
| 5894 | { |
| 5895 | if(pmcIsPowerSaveEnabled(pMac, ePMC_BEACON_MODE_POWER_SAVE)) |
| 5896 | { |
| 5897 | nRet = pMac->roam.configParam.scanAgeTimeCPS; |
| 5898 | } |
| 5899 | else |
| 5900 | { |
| 5901 | nRet = pMac->roam.configParam.scanAgeTimeCNPS; |
| 5902 | } |
| 5903 | } |
| 5904 | //If state-change causing aging time out change, we want to delay it somewhat to avoid |
| 5905 | //unnecessary removal of BSS. This is mostly due to transition from connect to disconnect. |
| 5906 | if(pMac->scan.nLastAgeTimeOut > nRet) |
| 5907 | { |
| 5908 | if(nRet) |
| 5909 | { |
| 5910 | pMac->scan.nAgingCountDown = (pMac->scan.nLastAgeTimeOut / nRet); |
| 5911 | } |
| 5912 | pMac->scan.nLastAgeTimeOut = nRet; |
| 5913 | nRet *= pMac->scan.nAgingCountDown; |
| 5914 | } |
| 5915 | else |
| 5916 | { |
| 5917 | pMac->scan.nLastAgeTimeOut = nRet; |
| 5918 | } |
| 5919 | } |
| 5920 | |
| 5921 | return (nRet); |
| 5922 | } |
| 5923 | |
| 5924 | |
| 5925 | void csrScanResultAgingTimerHandler(void *pv) |
| 5926 | { |
| 5927 | tpAniSirGlobal pMac = PMAC_STRUCT( pv ); |
| 5928 | tANI_BOOLEAN fDisconnected = csrIsAllSessionDisconnected(pMac); |
| 5929 | |
| 5930 | //no scan, no aging |
| 5931 | if(pMac->scan.fScanEnable && |
| 5932 | (((eANI_BOOLEAN_FALSE == fDisconnected) && pMac->roam.configParam.bgScanInterval) |
| 5933 | || (fDisconnected && (pMac->scan.fCancelIdleScan == eANI_BOOLEAN_FALSE))) |
| 5934 | ) |
| 5935 | { |
| 5936 | tListElem *pEntry, *tmpEntry; |
| 5937 | tCsrScanResult *pResult; |
| 5938 | tANI_TIMESTAMP ageOutTime = (tANI_TIMESTAMP)(csrScanGetAgeOutTime(pMac) * PAL_TICKS_PER_SECOND); //turn it into 10ms units |
| 5939 | tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd); |
| 5940 | |
| 5941 | csrLLLock(&pMac->scan.scanResultList); |
| 5942 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK ); |
| 5943 | while( pEntry ) |
| 5944 | { |
| 5945 | tmpEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK); |
| 5946 | pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 5947 | if((curTime - pResult->Result.BssDescriptor.nReceivedTime) > ageOutTime) |
| 5948 | { |
| 5949 | smsLog(pMac, LOGW, " age out due to time out"); |
| 5950 | csrScanAgeOutBss(pMac, pResult); |
| 5951 | } |
| 5952 | pEntry = tmpEntry; |
| 5953 | } |
| 5954 | csrLLUnlock(&pMac->scan.scanResultList); |
| 5955 | } |
| 5956 | } |
| 5957 | |
Sandeep Puligilla | 2b6dc63 | 2012-12-17 14:44:16 -0800 | [diff] [blame] | 5958 | static void csrScanResultCfgAgingTimerHandler(void *pv) |
| 5959 | { |
| 5960 | tpAniSirGlobal pMac = PMAC_STRUCT( pv ); |
| 5961 | tListElem *pEntry, *tmpEntry; |
| 5962 | tCsrScanResult *pResult; |
| 5963 | tANI_TIMESTAMP ageOutTime = pMac->scan.scanResultCfgAgingTime * PAL_TICKS_PER_SECOND; |
| 5964 | tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd); |
| 5965 | |
| 5966 | csrLLLock(&pMac->scan.scanResultList); |
| 5967 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK ); |
| 5968 | while( pEntry ) |
| 5969 | { |
| 5970 | tmpEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK); |
| 5971 | pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 5972 | if((curTime - pResult->Result.BssDescriptor.nReceivedTime) > ageOutTime) |
| 5973 | { |
| 5974 | smsLog(pMac, LOGW, " age out due to time out"); |
| 5975 | csrScanAgeOutBss(pMac, pResult); |
| 5976 | } |
| 5977 | pEntry = tmpEntry; |
| 5978 | } |
| 5979 | csrLLUnlock(&pMac->scan.scanResultList); |
| 5980 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5981 | |
| 5982 | eHalStatus csrScanStartIdleScanTimer(tpAniSirGlobal pMac, tANI_U32 interval) |
| 5983 | { |
| 5984 | eHalStatus status; |
| 5985 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 5986 | smsLog(pMac, LOG1, " csrScanStartIdleScanTimer"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5987 | if((pMac->scan.fScanEnable) && (eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan) && interval) |
| 5988 | { |
| 5989 | pMac->scan.nIdleScanTimeGap += interval; |
| 5990 | palTimerStop(pMac->hHdd, pMac->scan.hTimerIdleScan); |
| 5991 | status = palTimerStart(pMac->hHdd, pMac->scan.hTimerIdleScan, interval, eANI_BOOLEAN_FALSE); |
| 5992 | if( !HAL_STATUS_SUCCESS(status) ) |
| 5993 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 5994 | 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] | 5995 | //This should not happen but set the flag to restart when ready |
| 5996 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 5997 | } |
| 5998 | } |
| 5999 | else |
| 6000 | { |
| 6001 | if( pMac->scan.fScanEnable && (eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan) ) |
| 6002 | { |
| 6003 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 6004 | } |
| 6005 | status = eHAL_STATUS_FAILURE; |
| 6006 | } |
| 6007 | |
| 6008 | return (status); |
| 6009 | } |
| 6010 | |
| 6011 | |
| 6012 | eHalStatus csrScanStopIdleScanTimer(tpAniSirGlobal pMac) |
| 6013 | { |
| 6014 | return (palTimerStop(pMac->hHdd, pMac->scan.hTimerIdleScan)); |
| 6015 | } |
| 6016 | |
| 6017 | |
| 6018 | //Stop CSR from asking for IMPS, This function doesn't disable IMPS from CSR |
| 6019 | void csrScanSuspendIMPS( tpAniSirGlobal pMac ) |
| 6020 | { |
| 6021 | csrScanCancelIdleScan(pMac); |
| 6022 | } |
| 6023 | |
| 6024 | |
| 6025 | //Start CSR from asking for IMPS. This function doesn't trigger CSR to request entering IMPS |
| 6026 | //because IMPS maybe disabled. |
| 6027 | void csrScanResumeIMPS( tpAniSirGlobal pMac ) |
| 6028 | { |
| 6029 | csrScanStartIdleScan( pMac ); |
| 6030 | } |
| 6031 | |
| 6032 | |
| 6033 | void csrScanIMPSCallback(void *callbackContext, eHalStatus status) |
| 6034 | { |
| 6035 | tpAniSirGlobal pMac = PMAC_STRUCT( callbackContext ); |
| 6036 | |
| 6037 | if(eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan) |
| 6038 | { |
| 6039 | if(pMac->roam.configParam.IsIdleScanEnabled) |
| 6040 | { |
| 6041 | if(HAL_STATUS_SUCCESS(status)) |
| 6042 | { |
| 6043 | if(csrIsAllSessionDisconnected(pMac) && !csrIsRoamCommandWaiting(pMac)) |
| 6044 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 6045 | smsLog(pMac, LOGW, FL("starts idle mode full scan")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6046 | csrScanAllChannels(pMac, eCSR_SCAN_IDLE_MODE_SCAN); |
| 6047 | } |
| 6048 | else |
| 6049 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 6050 | smsLog(pMac, LOGW, FL("cannot start idle mode full scan")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6051 | //even though we are in timer handle, calling stop timer will make sure the timer |
| 6052 | //doesn't get to restart. |
| 6053 | csrScanStopIdleScanTimer(pMac); |
| 6054 | } |
| 6055 | } |
| 6056 | else |
| 6057 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 6058 | smsLog(pMac, LOGE, FL("sees not success status (%d)"), status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6059 | } |
| 6060 | } |
| 6061 | else |
| 6062 | {//we might need another flag to check if CSR needs to request imps at all |
| 6063 | |
| 6064 | tANI_U32 nTime = 0; |
| 6065 | |
| 6066 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE; |
| 6067 | if(!HAL_STATUS_SUCCESS(csrScanTriggerIdleScan(pMac, &nTime))) |
| 6068 | { |
| 6069 | csrScanStartIdleScanTimer(pMac, nTime); |
| 6070 | } |
| 6071 | } |
| 6072 | } |
| 6073 | } |
| 6074 | |
| 6075 | |
| 6076 | //Param: pTimeInterval -- Caller allocated memory in return, if failed, to specify the nxt time interval for |
| 6077 | //idle scan timer interval |
| 6078 | //Return: Not success -- meaning it cannot start IMPS, caller needs to start a timer for idle scan |
| 6079 | eHalStatus csrScanTriggerIdleScan(tpAniSirGlobal pMac, tANI_U32 *pTimeInterval) |
| 6080 | { |
| 6081 | eHalStatus status = eHAL_STATUS_CSR_WRONG_STATE; |
| 6082 | |
| 6083 | //Do not trigger IMPS in case of concurrency |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6084 | if (vos_concurrent_sessions_running() && csrIsAnySessionInConnectState(pMac)) |
| 6085 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 6086 | smsLog( pMac, LOG1, FL("Cannot request IMPS because Concurrent Sessions Running") ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6087 | return (status); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6088 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6089 | |
| 6090 | if(pTimeInterval) |
| 6091 | { |
| 6092 | *pTimeInterval = 0; |
| 6093 | } |
| 6094 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 6095 | smsLog(pMac, LOG3, FL("called")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6096 | if( smeCommandPending( pMac ) ) |
| 6097 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 6098 | smsLog( pMac, LOG1, FL(" Cannot request IMPS because command pending") ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6099 | //Not to enter IMPS because more work to do |
| 6100 | if(pTimeInterval) |
| 6101 | { |
| 6102 | *pTimeInterval = 0; |
| 6103 | } |
| 6104 | //restart when ready |
| 6105 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 6106 | |
| 6107 | return (status); |
| 6108 | } |
| 6109 | |
| 6110 | if((pMac->scan.fScanEnable) && (eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan) |
| 6111 | /*&& pMac->roam.configParam.impsSleepTime*/) |
| 6112 | { |
| 6113 | //Stop get result timer because idle scan gets scan result out of PE |
| 6114 | csrScanStopGetResultTimer(pMac); |
| 6115 | if(pTimeInterval) |
| 6116 | { |
| 6117 | *pTimeInterval = pMac->roam.configParam.impsSleepTime; |
| 6118 | } |
| 6119 | //pmcRequestImps take a period in millisecond unit. |
| 6120 | status = pmcRequestImps(pMac, pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_MS_UNIT, csrScanIMPSCallback, pMac); |
| 6121 | if(!HAL_STATUS_SUCCESS(status)) |
| 6122 | { |
| 6123 | if(eHAL_STATUS_PMC_ALREADY_IN_IMPS != status) |
| 6124 | { |
| 6125 | //Do restart the timer if CSR thinks it cannot do IMPS |
| 6126 | if( !csrCheckPSReady( pMac ) ) |
| 6127 | { |
| 6128 | if(pTimeInterval) |
| 6129 | { |
| 6130 | *pTimeInterval = 0; |
| 6131 | } |
| 6132 | //Set the restart flag to true because that idle scan |
| 6133 | //can be restarted even though the timer will not be running |
| 6134 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 6135 | } |
| 6136 | else |
| 6137 | { |
| 6138 | //For not now, we do a quicker retry |
| 6139 | if(pTimeInterval) |
| 6140 | { |
| 6141 | *pTimeInterval = CSR_IDLE_SCAN_WAIT_TIME; |
| 6142 | } |
| 6143 | } |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 6144 | 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] | 6145 | } |
| 6146 | else |
| 6147 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 6148 | smsLog(pMac, LOGW, FL("already in IMPS")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6149 | //Since CSR is the only module to request for IMPS. If it is already in IMPS, CSR assumes |
| 6150 | //the callback will be called in the future. Should not happen though. |
| 6151 | status = eHAL_STATUS_SUCCESS; |
| 6152 | pMac->scan.nIdleScanTimeGap = 0; |
| 6153 | } |
| 6154 | } |
| 6155 | else |
| 6156 | { |
| 6157 | //requested so let's reset the value |
| 6158 | pMac->scan.nIdleScanTimeGap = 0; |
| 6159 | } |
| 6160 | } |
| 6161 | |
| 6162 | return (status); |
| 6163 | } |
| 6164 | |
| 6165 | |
| 6166 | eHalStatus csrScanStartIdleScan(tpAniSirGlobal pMac) |
| 6167 | { |
| 6168 | eHalStatus status = eHAL_STATUS_CSR_WRONG_STATE; |
| 6169 | tANI_U32 nTime = 0; |
| 6170 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 6171 | smsLog(pMac, LOGW, FL("called")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6172 | if(pMac->roam.configParam.IsIdleScanEnabled) |
| 6173 | { |
| 6174 | //stop bg scan first |
| 6175 | csrScanBGScanAbort(pMac); |
| 6176 | //Stop get result timer because idle scan gets scan result out of PE |
| 6177 | csrScanStopGetResultTimer(pMac); |
| 6178 | //Enable aging timer since idle scan is going on |
| 6179 | csrScanStartResultAgingTimer(pMac); |
| 6180 | } |
| 6181 | pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE; |
| 6182 | status = csrScanTriggerIdleScan(pMac, &nTime); |
| 6183 | if(!HAL_STATUS_SUCCESS(status)) |
| 6184 | { |
| 6185 | csrScanStartIdleScanTimer(pMac, nTime); |
| 6186 | } |
| 6187 | |
| 6188 | return (status); |
| 6189 | } |
| 6190 | |
| 6191 | |
| 6192 | void csrScanCancelIdleScan(tpAniSirGlobal pMac) |
| 6193 | { |
| 6194 | if(eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan) |
| 6195 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6196 | if (vos_concurrent_sessions_running()) { |
| 6197 | return; |
| 6198 | } |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 6199 | smsLog(pMac, LOG1, " csrScanCancelIdleScan"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6200 | pMac->scan.fCancelIdleScan = eANI_BOOLEAN_TRUE; |
| 6201 | //Set the restart flag in case later on it is uncancelled |
| 6202 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 6203 | csrScanStopIdleScanTimer(pMac); |
| 6204 | csrScanRemoveNotRoamingScanCommand(pMac); |
| 6205 | } |
| 6206 | } |
| 6207 | |
| 6208 | |
| 6209 | void csrScanIdleScanTimerHandler(void *pv) |
| 6210 | { |
| 6211 | tpAniSirGlobal pMac = PMAC_STRUCT( pv ); |
| 6212 | eHalStatus status; |
| 6213 | tANI_U32 nTime = 0; |
| 6214 | |
| 6215 | smsLog(pMac, LOGW, " csrScanIdleScanTimerHandler called "); |
| 6216 | status = csrScanTriggerIdleScan(pMac, &nTime); |
| 6217 | if(!HAL_STATUS_SUCCESS(status) && (eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan)) |
| 6218 | { |
| 6219 | //Check whether it is time to actually do an idle scan |
| 6220 | if(pMac->scan.nIdleScanTimeGap >= pMac->roam.configParam.impsSleepTime) |
| 6221 | { |
| 6222 | pMac->scan.nIdleScanTimeGap = 0; |
| 6223 | csrScanIMPSCallback(pMac, eHAL_STATUS_SUCCESS); |
| 6224 | } |
| 6225 | else |
| 6226 | { |
| 6227 | csrScanStartIdleScanTimer(pMac, nTime); |
| 6228 | } |
| 6229 | } |
| 6230 | } |
| 6231 | |
| 6232 | |
| 6233 | |
| 6234 | |
| 6235 | tANI_BOOLEAN csrScanRemoveNotRoamingScanCommand(tpAniSirGlobal pMac) |
| 6236 | { |
| 6237 | tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE; |
| 6238 | tListElem *pEntry, *pEntryTmp; |
| 6239 | tSmeCmd *pCommand; |
| 6240 | tDblLinkList localList; |
| 6241 | |
| 6242 | vos_mem_zero(&localList, sizeof(tDblLinkList)); |
| 6243 | if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList))) |
| 6244 | { |
| 6245 | smsLog(pMac, LOGE, FL(" failed to open list")); |
| 6246 | return fRet; |
| 6247 | } |
| 6248 | |
| 6249 | csrLLLock(&pMac->sme.smeCmdPendingList); |
| 6250 | pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK); |
| 6251 | while(pEntry) |
| 6252 | { |
| 6253 | pEntryTmp = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK); |
| 6254 | pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link); |
| 6255 | if( eSmeCommandScan == pCommand->command ) |
| 6256 | { |
| 6257 | switch( pCommand->u.scanCmd.reason ) |
| 6258 | { |
| 6259 | case eCsrScanIdleScan: |
| 6260 | if( csrLLRemoveEntry(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK) ) |
| 6261 | { |
| 6262 | csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK); |
| 6263 | } |
| 6264 | fRet = eANI_BOOLEAN_TRUE; |
| 6265 | break; |
| 6266 | |
| 6267 | default: |
| 6268 | break; |
| 6269 | } //switch |
| 6270 | } |
| 6271 | pEntry = pEntryTmp; |
| 6272 | } |
| 6273 | |
| 6274 | csrLLUnlock(&pMac->sme.smeCmdPendingList); |
| 6275 | |
| 6276 | while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) ) |
| 6277 | { |
| 6278 | pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link); |
| 6279 | csrReleaseCommandScan( pMac, pCommand ); |
| 6280 | } |
| 6281 | |
| 6282 | csrLLClose(&localList); |
| 6283 | |
| 6284 | return (fRet); |
| 6285 | } |
| 6286 | |
| 6287 | |
| 6288 | tANI_BOOLEAN csrScanRemoveFreshScanCommand(tpAniSirGlobal pMac, tANI_U8 sessionId) |
| 6289 | { |
| 6290 | tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE; |
| 6291 | tListElem *pEntry, *pEntryTmp; |
| 6292 | tSmeCmd *pCommand; |
| 6293 | tDblLinkList localList; |
| 6294 | |
| 6295 | vos_mem_zero(&localList, sizeof(tDblLinkList)); |
| 6296 | if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList))) |
| 6297 | { |
| 6298 | smsLog(pMac, LOGE, FL(" failed to open list")); |
| 6299 | return fRet; |
| 6300 | } |
| 6301 | |
| 6302 | csrLLLock(&pMac->sme.smeCmdPendingList); |
| 6303 | pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK); |
| 6304 | while(pEntry) |
| 6305 | { |
| 6306 | pEntryTmp = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK); |
| 6307 | pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link); |
| 6308 | if( (eSmeCommandScan == pCommand->command) && (sessionId == pCommand->sessionId) ) |
| 6309 | { |
| 6310 | switch(pCommand->u.scanCmd.reason) |
| 6311 | { |
| 6312 | case eCsrScanGetResult: |
| 6313 | case eCsrScanSetBGScanParam: |
| 6314 | case eCsrScanBGScanAbort: |
| 6315 | case eCsrScanBGScanEnable: |
| 6316 | case eCsrScanGetScanChnInfo: |
| 6317 | break; |
| 6318 | default: |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 6319 | smsLog (pMac, LOGW, "%s: -------- abort scan command reason = %d", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 6320 | __func__, pCommand->u.scanCmd.reason); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6321 | //The rest are fresh scan requests |
| 6322 | if( csrLLRemoveEntry(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK) ) |
| 6323 | { |
| 6324 | csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK); |
| 6325 | } |
| 6326 | fRet = eANI_BOOLEAN_TRUE; |
| 6327 | break; |
| 6328 | } |
| 6329 | } |
| 6330 | pEntry = pEntryTmp; |
| 6331 | } |
| 6332 | |
| 6333 | csrLLUnlock(&pMac->sme.smeCmdPendingList); |
| 6334 | |
| 6335 | while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) ) |
| 6336 | { |
| 6337 | pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link); |
| 6338 | if (pCommand->u.scanCmd.callback) |
| 6339 | { |
| 6340 | /* User scan request is pending, |
| 6341 | * send response with status eCSR_SCAN_ABORT*/ |
| 6342 | pCommand->u.scanCmd.callback(pMac, |
| 6343 | pCommand->u.scanCmd.pContext, |
| 6344 | pCommand->u.scanCmd.scanID, |
| 6345 | eCSR_SCAN_ABORT); |
| 6346 | } |
| 6347 | csrReleaseCommandScan( pMac, pCommand ); |
| 6348 | } |
| 6349 | csrLLClose(&localList); |
| 6350 | |
| 6351 | return (fRet); |
| 6352 | } |
| 6353 | |
| 6354 | |
| 6355 | void csrReleaseScanCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand, eCsrScanStatus scanStatus) |
| 6356 | { |
| 6357 | eCsrScanReason reason = pCommand->u.scanCmd.reason; |
| 6358 | tANI_U32 i; |
| 6359 | for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ ) |
| 6360 | { |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 6361 | csrRoamStateChange( pMac, pCommand->u.scanCmd.lastRoamState[i], i); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6362 | } |
| 6363 | |
| 6364 | csrScanCallCallback(pMac, pCommand, scanStatus); |
| 6365 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 6366 | smsLog(pMac, LOG3, " Remove Scan command reason = %d", reason); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6367 | if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, &pCommand->Link, LL_ACCESS_LOCK ) ) |
| 6368 | { |
| 6369 | csrReleaseCommandScan( pMac, pCommand ); |
| 6370 | } |
| 6371 | else |
| 6372 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 6373 | smsLog(pMac, LOGE, " ********csrReleaseScanCommand cannot release command reason %d", pCommand->u.scanCmd.reason ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6374 | } |
| 6375 | } |
| 6376 | |
| 6377 | |
| 6378 | eHalStatus csrScanGetPMKIDCandidateList(tpAniSirGlobal pMac, tANI_U32 sessionId, |
| 6379 | tPmkidCandidateInfo *pPmkidList, tANI_U32 *pNumItems ) |
| 6380 | { |
| 6381 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 6382 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 6383 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 6384 | if(!pSession) |
| 6385 | { |
| 6386 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 6387 | return eHAL_STATUS_FAILURE; |
| 6388 | } |
| 6389 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 6390 | smsLog(pMac, LOGW, " pMac->scan.NumPmkidCandidate = %d", pSession->NumPmkidCandidate); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6391 | csrResetPMKIDCandidateList(pMac, sessionId); |
| 6392 | if(csrIsConnStateConnected(pMac, sessionId) && pSession->pCurRoamProfile) |
| 6393 | { |
| 6394 | tCsrScanResultFilter *pScanFilter; |
| 6395 | tCsrScanResultInfo *pScanResult; |
| 6396 | tScanResultHandle hBSSList; |
| 6397 | tANI_U32 nItems = *pNumItems; |
| 6398 | |
| 6399 | *pNumItems = 0; |
| 6400 | status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter)); |
| 6401 | if(HAL_STATUS_SUCCESS(status)) |
| 6402 | { |
| 6403 | palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter)); |
| 6404 | //Here is the profile we need to connect to |
| 6405 | status = csrRoamPrepareFilterFromProfile(pMac, pSession->pCurRoamProfile, pScanFilter); |
| 6406 | if(HAL_STATUS_SUCCESS(status)) |
| 6407 | { |
| 6408 | status = csrScanGetResult(pMac, pScanFilter, &hBSSList); |
| 6409 | if(HAL_STATUS_SUCCESS(status)) |
| 6410 | { |
| 6411 | while(((pScanResult = csrScanResultGetNext(pMac, hBSSList)) != NULL) && ( pSession->NumPmkidCandidate < nItems)) |
| 6412 | { |
| 6413 | //NumPmkidCandidate adds up here |
| 6414 | csrProcessBSSDescForPMKIDList(pMac, &pScanResult->BssDescriptor, |
| 6415 | (tDot11fBeaconIEs *)( pScanResult->pvIes )); |
| 6416 | } |
| 6417 | if(pSession->NumPmkidCandidate) |
| 6418 | { |
| 6419 | *pNumItems = pSession->NumPmkidCandidate; |
| 6420 | palCopyMemory(pMac->hHdd, pPmkidList, pSession->PmkidCandidateInfo, |
| 6421 | pSession->NumPmkidCandidate * sizeof(tPmkidCandidateInfo)); |
| 6422 | } |
| 6423 | csrScanResultPurge(pMac, hBSSList); |
| 6424 | }//Have scan result |
| 6425 | csrFreeScanFilter(pMac, pScanFilter); |
| 6426 | } |
| 6427 | palFreeMemory(pMac->hHdd, pScanFilter); |
| 6428 | } |
| 6429 | } |
| 6430 | |
| 6431 | return (status); |
| 6432 | } |
| 6433 | |
| 6434 | |
| 6435 | |
| 6436 | #ifdef FEATURE_WLAN_WAPI |
| 6437 | eHalStatus csrScanGetBKIDCandidateList(tpAniSirGlobal pMac, tANI_U32 sessionId, |
| 6438 | tBkidCandidateInfo *pBkidList, tANI_U32 *pNumItems ) |
| 6439 | { |
| 6440 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 6441 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 6442 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 6443 | if(!pSession) |
| 6444 | { |
| 6445 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 6446 | return eHAL_STATUS_FAILURE; |
| 6447 | } |
| 6448 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 6449 | smsLog(pMac, LOGW, " pMac->scan.NumBkidCandidate = %d", pSession->NumBkidCandidate); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6450 | csrResetBKIDCandidateList(pMac, sessionId); |
| 6451 | if(csrIsConnStateConnected(pMac, sessionId) && pSession->pCurRoamProfile) |
| 6452 | { |
| 6453 | tCsrScanResultFilter *pScanFilter; |
| 6454 | tCsrScanResultInfo *pScanResult; |
| 6455 | tScanResultHandle hBSSList; |
| 6456 | tANI_U32 nItems = *pNumItems; |
| 6457 | *pNumItems = 0; |
| 6458 | status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter)); |
| 6459 | if(HAL_STATUS_SUCCESS(status)) |
| 6460 | { |
| 6461 | palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter)); |
| 6462 | //Here is the profile we need to connect to |
| 6463 | status = csrRoamPrepareFilterFromProfile(pMac, pSession->pCurRoamProfile, pScanFilter); |
| 6464 | if(HAL_STATUS_SUCCESS(status)) |
| 6465 | { |
| 6466 | status = csrScanGetResult(pMac, pScanFilter, &hBSSList); |
| 6467 | if(HAL_STATUS_SUCCESS(status)) |
| 6468 | { |
| 6469 | while(((pScanResult = csrScanResultGetNext(pMac, hBSSList)) != NULL) && ( pSession->NumBkidCandidate < nItems)) |
| 6470 | { |
| 6471 | //pMac->scan.NumBkidCandidate adds up here |
| 6472 | csrProcessBSSDescForBKIDList(pMac, &pScanResult->BssDescriptor, |
| 6473 | (tDot11fBeaconIEs *)( pScanResult->pvIes )); |
| 6474 | |
| 6475 | } |
| 6476 | if(pSession->NumBkidCandidate) |
| 6477 | { |
| 6478 | *pNumItems = pSession->NumBkidCandidate; |
| 6479 | palCopyMemory(pMac->hHdd, pBkidList, pSession->BkidCandidateInfo, pSession->NumBkidCandidate * sizeof(tBkidCandidateInfo)); |
| 6480 | } |
| 6481 | csrScanResultPurge(pMac, hBSSList); |
| 6482 | }//Have scan result |
| 6483 | } |
| 6484 | palFreeMemory(pMac->hHdd, pScanFilter); |
| 6485 | } |
| 6486 | } |
| 6487 | |
| 6488 | return (status); |
| 6489 | } |
| 6490 | #endif /* FEATURE_WLAN_WAPI */ |
| 6491 | |
| 6492 | |
| 6493 | |
| 6494 | //This function is usually used for BSSs that suppresses SSID so the profile |
| 6495 | //shall have one and only one SSID |
| 6496 | eHalStatus csrScanForSSID(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tANI_U32 roamId) |
| 6497 | { |
| 6498 | eHalStatus status = eHAL_STATUS_INVALID_PARAMETER; |
| 6499 | tSmeCmd *pScanCmd = NULL; |
| 6500 | tANI_U8 bAddr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; |
| 6501 | tANI_U8 index = 0; |
| 6502 | tANI_U32 numSsid = pProfile->SSIDs.numOfSSIDs; |
| 6503 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 6504 | smsLog(pMac, LOG2, FL("called")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6505 | //For WDS, we use the index 0. There must be at least one in there |
| 6506 | if( CSR_IS_WDS_STA( pProfile ) && numSsid ) |
| 6507 | { |
| 6508 | numSsid = 1; |
| 6509 | } |
| 6510 | if(pMac->scan.fScanEnable && ( numSsid == 1 ) ) |
| 6511 | { |
| 6512 | do |
| 6513 | { |
| 6514 | pScanCmd = csrGetCommandBuffer(pMac); |
| 6515 | if(!pScanCmd) |
| 6516 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 6517 | smsLog(pMac, LOGE, FL("failed to allocate command buffer")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6518 | break; |
| 6519 | } |
| 6520 | palZeroMemory(pMac->hHdd, &pScanCmd->u.scanCmd, sizeof(tScanCmd)); |
| 6521 | status = palAllocateMemory(pMac->hHdd, (void **)&pScanCmd->u.scanCmd.pToRoamProfile, sizeof(tCsrRoamProfile)); |
| 6522 | if(!HAL_STATUS_SUCCESS(status)) |
| 6523 | break; |
| 6524 | status = csrRoamCopyProfile(pMac, pScanCmd->u.scanCmd.pToRoamProfile, pProfile); |
| 6525 | if(!HAL_STATUS_SUCCESS(status)) |
| 6526 | break; |
| 6527 | pScanCmd->u.scanCmd.roamId = roamId; |
| 6528 | pScanCmd->command = eSmeCommandScan; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6529 | pScanCmd->sessionId = (tANI_U8)sessionId; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6530 | pScanCmd->u.scanCmd.callback = NULL; |
| 6531 | pScanCmd->u.scanCmd.pContext = NULL; |
| 6532 | pScanCmd->u.scanCmd.reason = eCsrScanForSsid; |
| 6533 | pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around |
| 6534 | palZeroMemory(pMac->hHdd, &pScanCmd->u.scanCmd.u.scanRequest, sizeof(tCsrScanRequest)); |
| 6535 | pScanCmd->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6536 | pScanCmd->u.scanCmd.u.scanRequest.BSSType = pProfile->BSSType; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6537 | // To avoid 11b rate in probe request Set p2pSearch flag as 1 for P2P Client Mode |
| 6538 | if(VOS_P2P_CLIENT_MODE == pProfile->csrPersona) |
| 6539 | { |
| 6540 | pScanCmd->u.scanCmd.u.scanRequest.p2pSearch = 1; |
| 6541 | } |
| 6542 | if(pProfile->pAddIEScan) |
| 6543 | { |
| 6544 | status = palAllocateMemory(pMac->hHdd, |
| 6545 | (void **)&pScanCmd->u.scanCmd.u.scanRequest.pIEField, |
| 6546 | pProfile->nAddIEScanLength); |
| 6547 | palZeroMemory(pMac->hHdd, pScanCmd->u.scanCmd.u.scanRequest.pIEField, pProfile->nAddIEScanLength); |
| 6548 | if(HAL_STATUS_SUCCESS(status)) |
| 6549 | { |
| 6550 | palCopyMemory(pMac->hHdd, pScanCmd->u.scanCmd.u.scanRequest.pIEField, pProfile->pAddIEScan, pProfile->nAddIEScanLength); |
| 6551 | pScanCmd->u.scanCmd.u.scanRequest.uIEFieldLen = pProfile->nAddIEScanLength; |
| 6552 | } |
| 6553 | else |
| 6554 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 6555 | smsLog(pMac, LOGE, "No memory for scanning IE fields"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6556 | } |
| 6557 | } //Allocate memory for IE field |
| 6558 | else |
| 6559 | { |
| 6560 | pScanCmd->u.scanCmd.u.scanRequest.uIEFieldLen = 0; |
| 6561 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 6562 | /* For one channel be good enpugh time to receive beacon atleast */ |
| 6563 | if( 1 == pProfile->ChannelInfo.numOfChannels ) |
| 6564 | { |
| 6565 | pScanCmd->u.scanCmd.u.scanRequest.maxChnTime = MAX_ACTIVE_SCAN_FOR_ONE_CHANNEL; |
| 6566 | pScanCmd->u.scanCmd.u.scanRequest.minChnTime = MIN_ACTIVE_SCAN_FOR_ONE_CHANNEL; |
| 6567 | } |
| 6568 | else |
| 6569 | { |
| 6570 | pScanCmd->u.scanCmd.u.scanRequest.maxChnTime = pMac->roam.configParam.nActiveMaxChnTime; |
| 6571 | pScanCmd->u.scanCmd.u.scanRequest.minChnTime = pMac->roam.configParam.nActiveMinChnTime; |
| 6572 | } |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 6573 | pScanCmd->u.scanCmd.u.scanRequest.maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc; |
| 6574 | pScanCmd->u.scanCmd.u.scanRequest.minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6575 | if(pProfile->BSSIDs.numOfBSSIDs == 1) |
| 6576 | { |
| 6577 | palCopyMemory(pMac->hHdd, pScanCmd->u.scanCmd.u.scanRequest.bssid, pProfile->BSSIDs.bssid, sizeof(tCsrBssid)); |
| 6578 | } |
| 6579 | else |
| 6580 | { |
| 6581 | palCopyMemory(pMac->hHdd, pScanCmd->u.scanCmd.u.scanRequest.bssid, bAddr, 6); |
| 6582 | } |
| 6583 | if(pProfile->ChannelInfo.numOfChannels) |
| 6584 | { |
| 6585 | status = palAllocateMemory(pMac->hHdd, (void **)&pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList, sizeof(*pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList) * pProfile->ChannelInfo.numOfChannels); |
| 6586 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = 0; |
| 6587 | if(HAL_STATUS_SUCCESS(status)) |
| 6588 | { |
| 6589 | csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[0]); |
| 6590 | for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++) |
| 6591 | { |
| 6592 | if(csrRoamIsValidChannel(pMac, pProfile->ChannelInfo.ChannelList[index])) |
| 6593 | { |
| 6594 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels] |
| 6595 | = pProfile->ChannelInfo.ChannelList[index]; |
| 6596 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels++; |
| 6597 | } |
| 6598 | else |
| 6599 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 6600 | 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] | 6601 | } |
| 6602 | |
| 6603 | } |
| 6604 | } |
| 6605 | else |
| 6606 | { |
| 6607 | break; |
| 6608 | } |
| 6609 | |
| 6610 | } |
| 6611 | else |
| 6612 | { |
| 6613 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = 0; |
| 6614 | } |
| 6615 | if(pProfile->SSIDs.numOfSSIDs) |
| 6616 | { |
| 6617 | status = palAllocateMemory(pMac->hHdd, (void **)&pScanCmd->u.scanCmd.u.scanRequest.SSIDs.SSIDList, |
| 6618 | pProfile->SSIDs.numOfSSIDs * sizeof(tCsrSSIDInfo)); |
| 6619 | if(!HAL_STATUS_SUCCESS(status)) |
| 6620 | { |
| 6621 | break; |
| 6622 | } |
| 6623 | pScanCmd->u.scanCmd.u.scanRequest.SSIDs.numOfSSIDs = 1; |
| 6624 | palCopyMemory(pMac->hHdd, pScanCmd->u.scanCmd.u.scanRequest.SSIDs.SSIDList, pProfile->SSIDs.SSIDList, |
| 6625 | sizeof(tCsrSSIDInfo)); |
| 6626 | } |
| 6627 | //Start process the command |
| 6628 | status = csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_FALSE); |
| 6629 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 6630 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 6631 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6632 | break; |
| 6633 | } |
| 6634 | }while(0); |
| 6635 | if(!HAL_STATUS_SUCCESS(status)) |
| 6636 | { |
| 6637 | if(pScanCmd) |
| 6638 | { |
| 6639 | csrReleaseCommandScan(pMac, pScanCmd); |
| 6640 | //TODO:free the memory that is allocated in this function |
| 6641 | } |
| 6642 | csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE); |
| 6643 | } |
| 6644 | }//valid |
| 6645 | else |
| 6646 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 6647 | 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] | 6648 | pMac->scan.fScanEnable, pProfile->SSIDs.numOfSSIDs); |
| 6649 | } |
| 6650 | |
| 6651 | return (status); |
| 6652 | } |
| 6653 | |
| 6654 | |
| 6655 | //Issue a scan base on the new capability infomation |
| 6656 | //This should only happen when the associated AP changes its capability. |
| 6657 | //After this scan is done, CSR reroams base on the new scan results |
| 6658 | eHalStatus csrScanForCapabilityChange(tpAniSirGlobal pMac, tSirSmeApNewCaps *pNewCaps) |
| 6659 | { |
| 6660 | eHalStatus status = eHAL_STATUS_INVALID_PARAMETER; |
| 6661 | tSmeCmd *pScanCmd = NULL; |
| 6662 | |
| 6663 | if(pNewCaps) |
| 6664 | { |
| 6665 | do |
| 6666 | { |
| 6667 | pScanCmd = csrGetCommandBuffer(pMac); |
| 6668 | if(!pScanCmd) |
| 6669 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 6670 | smsLog(pMac, LOGE, FL("failed to allocate command buffer")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6671 | status = eHAL_STATUS_RESOURCES; |
| 6672 | break; |
| 6673 | } |
| 6674 | palZeroMemory(pMac->hHdd, &pScanCmd->u.scanCmd, sizeof(tScanCmd)); |
| 6675 | status = eHAL_STATUS_SUCCESS; |
| 6676 | pScanCmd->u.scanCmd.roamId = 0; |
| 6677 | pScanCmd->command = eSmeCommandScan; |
| 6678 | pScanCmd->u.scanCmd.callback = NULL; |
| 6679 | pScanCmd->u.scanCmd.pContext = NULL; |
| 6680 | pScanCmd->u.scanCmd.reason = eCsrScanForCapsChange; |
| 6681 | pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around |
| 6682 | status = csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_FALSE); |
| 6683 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 6684 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 6685 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6686 | break; |
| 6687 | } |
| 6688 | }while(0); |
| 6689 | if(!HAL_STATUS_SUCCESS(status)) |
| 6690 | { |
| 6691 | if(pScanCmd) |
| 6692 | { |
| 6693 | csrReleaseCommandScan(pMac, pScanCmd); |
| 6694 | } |
| 6695 | } |
| 6696 | } |
| 6697 | |
| 6698 | return (status); |
| 6699 | } |
| 6700 | |
| 6701 | |
| 6702 | |
| 6703 | void csrInitBGScanChannelList(tpAniSirGlobal pMac) |
| 6704 | { |
| 6705 | tANI_U32 len = CSR_MIN(sizeof(pMac->roam.validChannelList), sizeof(pMac->scan.bgScanChannelList)); |
| 6706 | |
| 6707 | palZeroMemory(pMac->hHdd, pMac->scan.bgScanChannelList, len); |
| 6708 | pMac->scan.numBGScanChannel = 0; |
| 6709 | |
| 6710 | if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len))) |
| 6711 | { |
| 6712 | pMac->roam.numValidChannels = len; |
| 6713 | pMac->scan.numBGScanChannel = (tANI_U8)CSR_MIN(len, WNI_CFG_BG_SCAN_CHANNEL_LIST_LEN); |
| 6714 | palCopyMemory(pMac->hHdd, pMac->scan.bgScanChannelList, pMac->roam.validChannelList, pMac->scan.numBGScanChannel); |
| 6715 | csrSetBGScanChannelList(pMac, pMac->scan.bgScanChannelList, pMac->scan.numBGScanChannel); |
| 6716 | } |
| 6717 | } |
| 6718 | |
| 6719 | |
| 6720 | //This function return TRUE if background scan channel list is adjusted. |
| 6721 | //this function will only shrink the background scan channel list |
| 6722 | tANI_BOOLEAN csrAdjustBGScanChannelList(tpAniSirGlobal pMac, tANI_U8 *pChannelList, tANI_U8 NumChannels, |
| 6723 | tANI_U8 *pAdjustChannels, tANI_U8 *pNumAdjustChannels) |
| 6724 | { |
| 6725 | tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE; |
| 6726 | tANI_U8 i, j, count = *pNumAdjustChannels; |
| 6727 | |
| 6728 | i = 0; |
| 6729 | while(i < count) |
| 6730 | { |
| 6731 | for(j = 0; j < NumChannels; j++) |
| 6732 | { |
| 6733 | if(pChannelList[j] == pAdjustChannels[i]) |
| 6734 | break; |
| 6735 | } |
| 6736 | if(j == NumChannels) |
| 6737 | { |
| 6738 | //This channel is not in the list, remove it |
| 6739 | fRet = eANI_BOOLEAN_TRUE; |
| 6740 | count--; |
| 6741 | if(count - i) |
| 6742 | { |
| 6743 | palCopyMemory(pMac->hHdd, &pAdjustChannels[i], &pAdjustChannels[i+1], count - i); |
| 6744 | } |
| 6745 | else |
| 6746 | { |
| 6747 | //already remove the last one. Done. |
| 6748 | break; |
| 6749 | } |
| 6750 | } |
| 6751 | else |
| 6752 | { |
| 6753 | i++; |
| 6754 | } |
| 6755 | }//while(i<count) |
| 6756 | *pNumAdjustChannels = count; |
| 6757 | |
| 6758 | return (fRet); |
| 6759 | } |
| 6760 | |
| 6761 | |
| 6762 | //Get the list of the base channels to scan for passively 11d info |
| 6763 | eHalStatus csrScanGetSupportedChannels( tpAniSirGlobal pMac ) |
| 6764 | { |
| 6765 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 6766 | int n = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 6767 | |
| 6768 | status = vos_nv_getSupportedChannels( pMac->scan.baseChannels.channelList, &n, NULL, NULL ); |
| 6769 | if( HAL_STATUS_SUCCESS(status) ) |
| 6770 | { |
| 6771 | pMac->scan.baseChannels.numChannels = (tANI_U8)n; |
| 6772 | } |
| 6773 | else |
| 6774 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 6775 | smsLog( pMac, LOGE, FL(" failed") ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6776 | pMac->scan.baseChannels.numChannels = 0; |
| 6777 | } |
| 6778 | |
| 6779 | return ( status ); |
| 6780 | } |
| 6781 | |
| 6782 | //This function use the input pChannelList to validate the current saved channel list |
| 6783 | eHalStatus csrSetBGScanChannelList( tpAniSirGlobal pMac, tANI_U8 *pAdjustChannels, tANI_U8 NumAdjustChannels) |
| 6784 | { |
| 6785 | tANI_U32 dataLen = sizeof( tANI_U8 ) * NumAdjustChannels; |
| 6786 | |
| 6787 | return (ccmCfgSetStr(pMac, WNI_CFG_BG_SCAN_CHANNEL_LIST, pAdjustChannels, dataLen, NULL, eANI_BOOLEAN_FALSE)); |
| 6788 | } |
| 6789 | |
| 6790 | |
| 6791 | void csrSetCfgValidChannelList( tpAniSirGlobal pMac, tANI_U8 *pChannelList, tANI_U8 NumChannels ) |
| 6792 | { |
| 6793 | tANI_U32 dataLen = sizeof( tANI_U8 ) * NumChannels; |
| 6794 | |
| 6795 | |
| 6796 | ccmCfgSetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST, pChannelList, dataLen, NULL, eANI_BOOLEAN_FALSE); |
| 6797 | |
| 6798 | return; |
| 6799 | } |
| 6800 | |
| 6801 | |
| 6802 | |
| 6803 | /* |
| 6804 | * The Tx power limits are saved in the cfg for future usage. |
| 6805 | */ |
| 6806 | void csrSaveTxPowerToCfg( tpAniSirGlobal pMac, tDblLinkList *pList, tANI_U32 cfgId ) |
| 6807 | { |
| 6808 | tListElem *pEntry; |
| 6809 | tANI_U32 cbLen = 0, dataLen; |
| 6810 | tCsrChannelPowerInfo *pChannelSet; |
| 6811 | tANI_U32 idx; |
| 6812 | tSirMacChanInfo *pChannelPowerSet; |
| 6813 | tANI_U8 *pBuf = NULL; |
| 6814 | |
| 6815 | //allocate maximum space for all channels |
| 6816 | dataLen = WNI_CFG_VALID_CHANNEL_LIST_LEN * sizeof(tSirMacChanInfo); |
| 6817 | if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pBuf, dataLen))) |
| 6818 | { |
| 6819 | palZeroMemory(pMac->hHdd, pBuf, dataLen); |
| 6820 | pChannelPowerSet = (tSirMacChanInfo *)(pBuf); |
| 6821 | |
| 6822 | pEntry = csrLLPeekHead( pList, LL_ACCESS_LOCK ); |
| 6823 | // write the tuples (startChan, numChan, txPower) for each channel found in the channel power list. |
| 6824 | while( pEntry ) |
| 6825 | { |
| 6826 | pChannelSet = GET_BASE_ADDR( pEntry, tCsrChannelPowerInfo, link ); |
| 6827 | if ( 1 != pChannelSet->interChannelOffset ) |
| 6828 | { |
| 6829 | // we keep the 5G channel sets internally with an interchannel offset of 4. Expand these |
| 6830 | // to the right format... (inter channel offset of 1 is the only option for the triplets |
| 6831 | // that 11d advertises. |
| 6832 | if ((cbLen + (pChannelSet->numChannels * sizeof(tSirMacChanInfo))) >= dataLen) |
| 6833 | { |
| 6834 | // expanding this entry will overflow our allocation |
| 6835 | smsLog(pMac, LOGE, |
| 6836 | "%s: Buffer overflow, start %d, num %d, offset %d", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 6837 | __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6838 | pChannelSet->firstChannel, |
| 6839 | pChannelSet->numChannels, |
| 6840 | pChannelSet->interChannelOffset); |
| 6841 | break; |
| 6842 | } |
| 6843 | |
| 6844 | for( idx = 0; idx < pChannelSet->numChannels; idx++ ) |
| 6845 | { |
| 6846 | pChannelPowerSet->firstChanNum = (tSirMacChanNum)(pChannelSet->firstChannel + ( idx * pChannelSet->interChannelOffset )); |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 6847 | smsLog(pMac, LOG3, " Setting Channel Number %d", pChannelPowerSet->firstChanNum); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6848 | pChannelPowerSet->numChannels = 1; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6849 | pChannelPowerSet->maxTxPower = CSR_ROAM_MIN( pChannelSet->txPower, pMac->roam.configParam.nTxPowerCap ); |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 6850 | smsLog(pMac, LOG3, " Setting Max Transmit Power %d", pChannelPowerSet->maxTxPower); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6851 | cbLen += sizeof( tSirMacChanInfo ); |
| 6852 | pChannelPowerSet++; |
| 6853 | } |
| 6854 | } |
| 6855 | else |
| 6856 | { |
| 6857 | if (cbLen >= dataLen) |
| 6858 | { |
| 6859 | // this entry will overflow our allocation |
| 6860 | smsLog(pMac, LOGE, |
| 6861 | "%s: Buffer overflow, start %d, num %d, offset %d", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 6862 | __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6863 | pChannelSet->firstChannel, |
| 6864 | pChannelSet->numChannels, |
| 6865 | pChannelSet->interChannelOffset); |
| 6866 | break; |
| 6867 | } |
| 6868 | pChannelPowerSet->firstChanNum = pChannelSet->firstChannel; |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 6869 | smsLog(pMac, LOG3, " Setting Channel Number %d", pChannelPowerSet->firstChanNum); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6870 | pChannelPowerSet->numChannels = pChannelSet->numChannels; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6871 | pChannelPowerSet->maxTxPower = CSR_ROAM_MIN( pChannelSet->txPower, pMac->roam.configParam.nTxPowerCap ); |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 6872 | 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] | 6873 | |
| 6874 | |
| 6875 | cbLen += sizeof( tSirMacChanInfo ); |
| 6876 | pChannelPowerSet++; |
| 6877 | } |
| 6878 | |
| 6879 | pEntry = csrLLNext( pList, pEntry, LL_ACCESS_LOCK ); |
| 6880 | } |
| 6881 | |
| 6882 | if(cbLen) |
| 6883 | { |
| 6884 | ccmCfgSetStr(pMac, cfgId, (tANI_U8 *)pBuf, cbLen, NULL, eANI_BOOLEAN_FALSE); |
| 6885 | } |
| 6886 | palFreeMemory( pMac->hHdd, pBuf ); |
| 6887 | }//Allocate memory |
| 6888 | } |
| 6889 | |
| 6890 | |
| 6891 | void csrSetCfgCountryCode( tpAniSirGlobal pMac, tANI_U8 *countryCode ) |
| 6892 | { |
| 6893 | tANI_U8 cc[WNI_CFG_COUNTRY_CODE_LEN]; |
| 6894 | ///v_REGDOMAIN_t DomainId; |
| 6895 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 6896 | smsLog( pMac, LOG3, "Setting Country Code in Cfg from csrSetCfgCountryCode %s",countryCode ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6897 | palCopyMemory( pMac->hHdd, cc, countryCode, WNI_CFG_COUNTRY_CODE_LEN ); |
| 6898 | |
| 6899 | // don't program the bogus country codes that we created for Korea in the MAC. if we see |
| 6900 | // the bogus country codes, program the MAC with the right country code. |
| 6901 | if ( ( 'K' == countryCode[ 0 ] && '1' == countryCode[ 1 ] ) || |
| 6902 | ( 'K' == countryCode[ 0 ] && '2' == countryCode[ 1 ] ) || |
| 6903 | ( 'K' == countryCode[ 0 ] && '3' == countryCode[ 1 ] ) || |
| 6904 | ( 'K' == countryCode[ 0 ] && '4' == countryCode[ 1 ] ) ) |
| 6905 | { |
| 6906 | // replace the alternate Korea country codes, 'K1', 'K2', .. with 'KR' for Korea |
| 6907 | cc[ 1 ] = 'R'; |
| 6908 | } |
| 6909 | ccmCfgSetStr(pMac, WNI_CFG_COUNTRY_CODE, cc, WNI_CFG_COUNTRY_CODE_LEN, NULL, eANI_BOOLEAN_FALSE); |
| 6910 | |
| 6911 | //Need to let HALPHY know about the current domain so it can apply some |
| 6912 | //domain-specific settings (TX filter...) |
| 6913 | /*if(HAL_STATUS_SUCCESS(csrGetRegulatoryDomainForCountry(pMac, cc, &DomainId))) |
| 6914 | { |
| 6915 | halPhySetRegDomain(pMac, DomainId); |
| 6916 | }*/ |
| 6917 | } |
| 6918 | |
| 6919 | |
| 6920 | |
| 6921 | eHalStatus csrGetCountryCode(tpAniSirGlobal pMac, tANI_U8 *pBuf, tANI_U8 *pbLen) |
| 6922 | { |
| 6923 | eHalStatus status = eHAL_STATUS_INVALID_PARAMETER; |
| 6924 | tANI_U32 len; |
| 6925 | |
| 6926 | if(pBuf && pbLen && (*pbLen >= WNI_CFG_COUNTRY_CODE_LEN)) |
| 6927 | { |
| 6928 | len = *pbLen; |
| 6929 | status = ccmCfgGetStr(pMac, WNI_CFG_COUNTRY_CODE, pBuf, &len); |
| 6930 | if(HAL_STATUS_SUCCESS(status)) |
| 6931 | { |
| 6932 | *pbLen = (tANI_U8)len; |
| 6933 | } |
| 6934 | } |
| 6935 | |
| 6936 | return (status); |
| 6937 | } |
| 6938 | |
| 6939 | |
| 6940 | void csrSetCfgScanControlList( tpAniSirGlobal pMac, tANI_U8 *countryCode, tCsrChannel *pChannelList ) |
| 6941 | { |
| 6942 | tANI_U8 i, j; |
| 6943 | tANI_BOOLEAN found=FALSE; |
| 6944 | tANI_U8 *pControlList = NULL; |
| 6945 | tANI_U32 len = WNI_CFG_SCAN_CONTROL_LIST_LEN; |
| 6946 | |
| 6947 | if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pControlList, WNI_CFG_SCAN_CONTROL_LIST_LEN))) |
| 6948 | { |
| 6949 | palZeroMemory(pMac->hHdd, (void *)pControlList, WNI_CFG_SCAN_CONTROL_LIST_LEN); |
| 6950 | if(HAL_STATUS_SUCCESS(ccmCfgGetStr(pMac, WNI_CFG_SCAN_CONTROL_LIST, pControlList, &len))) |
| 6951 | { |
| 6952 | for (i = 0; i < pChannelList->numChannels; i++) |
| 6953 | { |
| 6954 | for (j = 0; j < len; j += 2) |
| 6955 | { |
| 6956 | if (pControlList[j] == pChannelList->channelList[i]) |
| 6957 | { |
| 6958 | found = TRUE; |
| 6959 | break; |
| 6960 | } |
| 6961 | } |
| 6962 | |
| 6963 | if (found) // insert a pair(channel#, flag) |
| 6964 | { |
| 6965 | if (CSR_IS_CHANNEL_5GHZ(pControlList[j])) |
| 6966 | { |
| 6967 | pControlList[j+1] = csrGetScanType(pMac, pControlList[j]); |
| 6968 | } |
| 6969 | else |
| 6970 | { |
| 6971 | pControlList[j+1] = eSIR_ACTIVE_SCAN; |
| 6972 | } |
| 6973 | |
| 6974 | found = FALSE; // reset the flag |
| 6975 | } |
| 6976 | |
| 6977 | } |
| 6978 | |
| 6979 | ccmCfgSetStr(pMac, WNI_CFG_SCAN_CONTROL_LIST, pControlList, len, NULL, eANI_BOOLEAN_FALSE); |
| 6980 | }//Successfully getting scan control list |
| 6981 | palFreeMemory(pMac->hHdd, pControlList); |
| 6982 | }//AllocateMemory |
| 6983 | } |
| 6984 | |
| 6985 | |
| 6986 | //if bgPeriod is 0, background scan is disabled. It is in millisecond units |
| 6987 | eHalStatus csrSetCfgBackgroundScanPeriod(tpAniSirGlobal pMac, tANI_U32 bgPeriod) |
| 6988 | { |
| 6989 | return (ccmCfgSetInt(pMac, WNI_CFG_BACKGROUND_SCAN_PERIOD, bgPeriod, (tCcmCfgSetCallback) csrScanCcmCfgSetCallback, eANI_BOOLEAN_FALSE)); |
| 6990 | } |
| 6991 | |
| 6992 | |
| 6993 | void csrScanCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result) |
| 6994 | { |
| 6995 | tListElem *pEntry = NULL; |
| 6996 | tSmeCmd *pCommand = NULL; |
| 6997 | tpAniSirGlobal pMac = PMAC_STRUCT( hHal ); |
| 6998 | |
| 6999 | pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK ); |
| 7000 | if ( pEntry ) |
| 7001 | { |
| 7002 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 7003 | if ( eSmeCommandScan == pCommand->command ) |
| 7004 | { |
| 7005 | eCsrScanStatus scanStatus = (CCM_IS_RESULT_SUCCESS(result)) ? eCSR_SCAN_SUCCESS : eCSR_SCAN_FAILURE; |
| 7006 | csrReleaseScanCommand(pMac, pCommand, scanStatus); |
| 7007 | } |
| 7008 | else |
| 7009 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame^] | 7010 | 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] | 7011 | } |
| 7012 | } |
| 7013 | smeProcessPendingQueue( pMac ); |
| 7014 | } |
| 7015 | |
| 7016 | eHalStatus csrProcessSetBGScanParam(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
| 7017 | { |
| 7018 | eHalStatus status; |
| 7019 | tCsrBGScanRequest *pScanReq = &pCommand->u.scanCmd.u.bgScanRequest; |
| 7020 | tANI_U32 dataLen = sizeof( tANI_U8 ) * pScanReq->ChannelInfo.numOfChannels; |
| 7021 | |
| 7022 | //***setcfg for background scan channel list |
| 7023 | status = ccmCfgSetInt(pMac, WNI_CFG_ACTIVE_MINIMUM_CHANNEL_TIME, pScanReq->minChnTime, NULL, eANI_BOOLEAN_FALSE); |
| 7024 | status = ccmCfgSetInt(pMac, WNI_CFG_ACTIVE_MAXIMUM_CHANNEL_TIME, pScanReq->maxChnTime, NULL, eANI_BOOLEAN_FALSE); |
| 7025 | //Not set the background scan interval if not connected because bd scan should not be run if not connected |
| 7026 | if(!csrIsAllSessionDisconnected(pMac)) |
| 7027 | { |
| 7028 | //If disbaling BG scan here, we need to stop aging as well |
| 7029 | if(pScanReq->scanInterval == 0) |
| 7030 | { |
| 7031 | //Stop aging because no new result is coming in |
| 7032 | csrScanStopResultAgingTimer(pMac); |
| 7033 | } |
| 7034 | |
| 7035 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 7036 | { |
| 7037 | vos_log_scan_pkt_type *pScanLog = NULL; |
| 7038 | |
| 7039 | WLAN_VOS_DIAG_LOG_ALLOC(pScanLog, vos_log_scan_pkt_type, LOG_WLAN_SCAN_C); |
| 7040 | if(pScanLog) |
| 7041 | { |
| 7042 | pScanLog->eventId = WLAN_SCAN_EVENT_HO_SCAN_REQ; |
| 7043 | pScanLog->minChnTime = (v_U8_t)pScanReq->minChnTime; |
| 7044 | pScanLog->maxChnTime = (v_U8_t)pScanReq->maxChnTime; |
| 7045 | pScanLog->timeBetweenBgScan = (v_U8_t)pScanReq->scanInterval; |
| 7046 | pScanLog->numChannel = pScanReq->ChannelInfo.numOfChannels; |
| 7047 | if(pScanLog->numChannel && (pScanLog->numChannel < VOS_LOG_MAX_NUM_CHANNEL)) |
| 7048 | { |
| 7049 | palCopyMemory(pMac->hHdd, pScanLog->channels, pScanReq->ChannelInfo.ChannelList, |
| 7050 | pScanLog->numChannel); |
| 7051 | } |
| 7052 | WLAN_VOS_DIAG_LOG_REPORT(pScanLog); |
| 7053 | } |
| 7054 | } |
| 7055 | #endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 7056 | |
| 7057 | status = ccmCfgSetInt(pMac, WNI_CFG_BACKGROUND_SCAN_PERIOD, pScanReq->scanInterval, NULL, eANI_BOOLEAN_FALSE); |
| 7058 | } |
| 7059 | else |
| 7060 | { |
| 7061 | //No need to stop aging because IDLE scan is still running |
| 7062 | status = ccmCfgSetInt(pMac, WNI_CFG_BACKGROUND_SCAN_PERIOD, 0, NULL, eANI_BOOLEAN_FALSE); |
| 7063 | } |
| 7064 | |
| 7065 | if(pScanReq->SSID.length > WNI_CFG_SSID_LEN) |
| 7066 | { |
| 7067 | pScanReq->SSID.length = WNI_CFG_SSID_LEN; |
| 7068 | } |
| 7069 | |
| 7070 | status = ccmCfgSetStr(pMac, WNI_CFG_BG_SCAN_CHANNEL_LIST, pScanReq->ChannelInfo.ChannelList, dataLen, NULL, eANI_BOOLEAN_FALSE); |
| 7071 | status = ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pScanReq->SSID.ssId, pScanReq->SSID.length, NULL, eANI_BOOLEAN_FALSE); |
| 7072 | |
| 7073 | |
| 7074 | |
| 7075 | return (status); |
| 7076 | } |
| 7077 | |
| 7078 | |
| 7079 | eHalStatus csrScanAbortMacScan(tpAniSirGlobal pMac) |
| 7080 | { |
| 7081 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 7082 | tSirMbMsg *pMsg; |
| 7083 | tANI_U16 msgLen; |
| 7084 | tListElem *pEntry; |
| 7085 | tSmeCmd *pCommand; |
| 7086 | |
| 7087 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 7088 | csrLLLock(&pMac->scan.scanCmdPendingList); |
| 7089 | while( NULL != ( pEntry = csrLLRemoveHead( &pMac->scan.scanCmdPendingList, LL_ACCESS_NOLOCK) ) ) |
| 7090 | { |
| 7091 | |
| 7092 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 7093 | csrAbortCommand( pMac, pCommand, eANI_BOOLEAN_FALSE); |
| 7094 | } |
| 7095 | csrLLUnlock(&pMac->scan.scanCmdPendingList); |
| 7096 | #endif |
| 7097 | |
| 7098 | pMac->scan.fDropScanCmd = eANI_BOOLEAN_TRUE; |
| 7099 | csrRemoveCmdFromPendingList( pMac, &pMac->roam.roamCmdPendingList, eSmeCommandScan); |
| 7100 | csrRemoveCmdFromPendingList( pMac, &pMac->sme.smeCmdPendingList, eSmeCommandScan); |
| 7101 | pMac->scan.fDropScanCmd = eANI_BOOLEAN_FALSE; |
| 7102 | |
| 7103 | //We need to abort scan only if we are scanning |
| 7104 | if(NULL != (pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK))) |
| 7105 | { |
| 7106 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 7107 | if(eSmeCommandScan == pCommand->command) |
| 7108 | { |
| 7109 | msgLen = (tANI_U16)(sizeof( tSirMbMsg )); |
| 7110 | status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen); |
| 7111 | if(HAL_STATUS_SUCCESS(status)) |
| 7112 | { |
| 7113 | palZeroMemory(pMac->hHdd, (void *)pMsg, msgLen); |
| 7114 | pMsg->type = pal_cpu_to_be16((tANI_U16)eWNI_SME_SCAN_ABORT_IND); |
| 7115 | pMsg->msgLen = pal_cpu_to_be16(msgLen); |
| 7116 | status = palSendMBMessage(pMac->hHdd, pMsg); |
| 7117 | } |
| 7118 | } |
| 7119 | } |
| 7120 | |
| 7121 | return( status ); |
| 7122 | } |
| 7123 | |
| 7124 | void csrRemoveCmdFromPendingList(tpAniSirGlobal pMac, tDblLinkList *pList, |
| 7125 | eSmeCommandType commandType ) |
| 7126 | { |
| 7127 | tDblLinkList localList; |
| 7128 | tListElem *pEntry; |
| 7129 | tSmeCmd *pCommand; |
| 7130 | tListElem *pEntryToRemove; |
| 7131 | |
| 7132 | vos_mem_zero(&localList, sizeof(tDblLinkList)); |
| 7133 | if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList))) |
| 7134 | { |
| 7135 | smsLog(pMac, LOGE, FL(" failed to open list")); |
| 7136 | return; |
| 7137 | } |
| 7138 | |
| 7139 | csrLLLock(pList); |
| 7140 | if( !csrLLIsListEmpty( pList, LL_ACCESS_NOLOCK ) ) |
| 7141 | { |
| 7142 | pEntry = csrLLPeekHead( pList, LL_ACCESS_NOLOCK); |
| 7143 | |
| 7144 | // Have to make sure we don't loop back to the head of the list, which will |
| 7145 | // happen if the entry is NOT on the list... |
| 7146 | while( pEntry ) |
| 7147 | { |
| 7148 | pEntryToRemove = pEntry; |
| 7149 | pEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK); |
| 7150 | pCommand = GET_BASE_ADDR( pEntryToRemove, tSmeCmd, Link ); |
| 7151 | if ( pCommand->command == commandType ) |
| 7152 | { |
| 7153 | // Remove that entry only |
| 7154 | if(csrLLRemoveEntry( pList, pEntryToRemove, LL_ACCESS_NOLOCK)) |
| 7155 | { |
| 7156 | csrLLInsertTail(&localList, pEntryToRemove, LL_ACCESS_NOLOCK); |
| 7157 | } |
| 7158 | } |
| 7159 | } |
| 7160 | |
| 7161 | |
| 7162 | } |
| 7163 | csrLLUnlock(pList); |
| 7164 | |
| 7165 | while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) ) |
| 7166 | { |
| 7167 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 7168 | csrAbortCommand( pMac, pCommand, eANI_BOOLEAN_FALSE); |
| 7169 | } |
| 7170 | csrLLClose(&localList); |
| 7171 | |
| 7172 | } |
| 7173 | |
| 7174 | |
| 7175 | eHalStatus csrScanAbortMacScanNotForConnect(tpAniSirGlobal pMac) |
| 7176 | { |
| 7177 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 7178 | |
| 7179 | if( !csrIsScanForRoamCommandActive( pMac ) ) |
| 7180 | { |
| 7181 | //Only abort the scan if it is not used for other roam/connect purpose |
| 7182 | status = csrScanAbortMacScan(pMac); |
| 7183 | } |
| 7184 | |
| 7185 | return (status); |
| 7186 | } |
| 7187 | |
| 7188 | |
| 7189 | eHalStatus csrScanGetScanChannelInfo(tpAniSirGlobal pMac) |
| 7190 | { |
| 7191 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 7192 | tSirMbMsg *pMsg; |
| 7193 | tANI_U16 msgLen; |
| 7194 | |
| 7195 | msgLen = (tANI_U16)(sizeof( tSirMbMsg )); |
| 7196 | status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen); |
| 7197 | if(HAL_STATUS_SUCCESS(status)) |
| 7198 | { |
| 7199 | palZeroMemory(pMac->hHdd, pMsg, msgLen); |
| 7200 | pMsg->type = eWNI_SME_GET_SCANNED_CHANNEL_REQ; |
| 7201 | pMsg->msgLen = msgLen; |
| 7202 | status = palSendMBMessage(pMac->hHdd, pMsg); |
| 7203 | } |
| 7204 | |
| 7205 | return( status ); |
| 7206 | } |
| 7207 | |
| 7208 | tANI_BOOLEAN csrRoamIsValidChannel( tpAniSirGlobal pMac, tANI_U8 channel ) |
| 7209 | { |
| 7210 | tANI_BOOLEAN fValid = FALSE; |
| 7211 | tANI_U32 idxValidChannels; |
| 7212 | tANI_U32 len = pMac->roam.numValidChannels; |
| 7213 | |
| 7214 | for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ ) |
| 7215 | { |
| 7216 | if ( channel == pMac->roam.validChannelList[ idxValidChannels ] ) |
| 7217 | { |
| 7218 | fValid = TRUE; |
| 7219 | break; |
| 7220 | } |
| 7221 | } |
| 7222 | |
| 7223 | return fValid; |
| 7224 | } |
| 7225 | |
Madan Mohan Koyyalamudi | dd3c966 | 2012-11-09 17:39:30 -0800 | [diff] [blame] | 7226 | #ifdef FEATURE_WLAN_LFR |
| 7227 | void csrInitOccupiedChannelsList(tpAniSirGlobal pMac) |
| 7228 | { |
| 7229 | tListElem *pEntry = NULL; |
| 7230 | tCsrScanResult *pBssDesc = NULL; |
| 7231 | tDot11fBeaconIEs *pIes = NULL; |
Srinivas | 28b5b4e | 2012-12-12 13:07:53 -0800 | [diff] [blame] | 7232 | tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo; |
| 7233 | |
| 7234 | if (0 != pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels) |
| 7235 | { |
| 7236 | 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^] | 7237 | " hence NO need to build occupied channel list (numChannels = %d)"), |
Srinivas | 28b5b4e | 2012-12-12 13:07:53 -0800 | [diff] [blame] | 7238 | __func__, pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels); |
| 7239 | return; |
| 7240 | } |
Madan Mohan Koyyalamudi | dd3c966 | 2012-11-09 17:39:30 -0800 | [diff] [blame] | 7241 | |
| 7242 | if (!csrNeighborRoamIsNewConnectedProfile(pMac)) |
| 7243 | { |
| 7244 | 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^] | 7245 | " matches previous (numChannels = %d)"), |
Madan Mohan Koyyalamudi | dd3c966 | 2012-11-09 17:39:30 -0800 | [diff] [blame] | 7246 | __func__, pMac->scan.occupiedChannels.numChannels); |
| 7247 | return; |
| 7248 | } |
| 7249 | |
| 7250 | /* Empty occupied channels here */ |
| 7251 | pMac->scan.occupiedChannels.numChannels = 0; |
| 7252 | |
| 7253 | csrLLLock(&pMac->scan.scanResultList); |
| 7254 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK ); |
| 7255 | while( pEntry ) |
| 7256 | { |
| 7257 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 7258 | pIes = (tDot11fBeaconIEs *)( pBssDesc->Result.pvIes ); |
| 7259 | |
| 7260 | //At this time, pBssDescription->Result.pvIes may be NULL |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 7261 | if( !pIes && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, |
Madan Mohan Koyyalamudi | dd3c966 | 2012-11-09 17:39:30 -0800 | [diff] [blame] | 7262 | &pBssDesc->Result.BssDescriptor, &pIes))) ) |
| 7263 | { |
| 7264 | continue; |
| 7265 | } |
| 7266 | |
| 7267 | csrScanAddToOccupiedChannels(pMac, pBssDesc, &pMac->scan.occupiedChannels, pIes); |
| 7268 | |
| 7269 | /* |
| 7270 | * Free the memory allocated for pIes in csrGetParsedBssDescriptionIEs |
| 7271 | */ |
| 7272 | if( (pBssDesc->Result.pvIes == NULL) && pIes ) |
| 7273 | { |
| 7274 | palFreeMemory(pMac->hHdd, pIes); |
| 7275 | } |
| 7276 | |
| 7277 | pEntry = csrLLNext( &pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK ); |
| 7278 | }//while |
| 7279 | csrLLUnlock(&pMac->scan.scanResultList); |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 7280 | |
Madan Mohan Koyyalamudi | dd3c966 | 2012-11-09 17:39:30 -0800 | [diff] [blame] | 7281 | } |
| 7282 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7283 | |