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 | |
Jeff Johnson | 40b59aa | 2013-03-19 14:43:18 -0700 | [diff] [blame] | 42 | /** ------------------------------------------------------------------------- * |
| 43 | ------------------------------------------------------------------------- * |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 44 | |
Jeff Johnson | 40b59aa | 2013-03-19 14:43:18 -0700 | [diff] [blame] | 45 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 46 | \file csrApiScan.c |
Jeff Johnson | 40b59aa | 2013-03-19 14:43:18 -0700 | [diff] [blame] | 47 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 48 | Implementation for the Common Scan interfaces. |
Jeff Johnson | 40b59aa | 2013-03-19 14:43:18 -0700 | [diff] [blame] | 49 | |
| 50 | Copyright (C) 2006 Airgo Networks, Incorporated |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 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" |
Jeff Johnson | 40b59aa | 2013-03-19 14:43:18 -0700 | [diff] [blame] | 68 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 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 | |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 117 | /* Maximum number of channels per country can be ignored */ |
| 118 | #define MAX_CHANNELS_IGNORE 10 |
| 119 | |
Madan Mohan Koyyalamudi | 28dd042 | 2013-08-12 15:06:21 +0530 | [diff] [blame^] | 120 | #define MAX_COUNTRY_IGNORE 4 |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 121 | |
| 122 | /*struct to hold the ignored channel list based on country */ |
| 123 | typedef struct sCsrIgnoreChannels |
| 124 | { |
| 125 | tANI_U8 countryCode[NV_FIELD_COUNTRY_CODE_SIZE]; |
| 126 | tANI_U16 channelList[MAX_CHANNELS_IGNORE]; |
| 127 | tANI_U16 channelCount; |
| 128 | }tCsrIgnoreChannels; |
| 129 | |
| 130 | static tCsrIgnoreChannels countryIgnoreList[MAX_COUNTRY_IGNORE] = { |
| 131 | { {'U','A'}, { 136, 140}, 2}, |
| 132 | { {'T','W'}, { 36, 40, 44, 48, 52}, 5}, |
Madan Mohan Koyyalamudi | 28dd042 | 2013-08-12 15:06:21 +0530 | [diff] [blame^] | 133 | { {'I','D'}, { 165}, 1 }, |
| 134 | { {'A','U'}, { 120, 124, 128}, 3 } |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 135 | }; |
| 136 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 137 | //*** This is temporary work around. It need to call CCM api to get to CFG later |
| 138 | /// Get string parameter value |
| 139 | extern tSirRetStatus wlan_cfgGetStr(tpAniSirGlobal, tANI_U16, tANI_U8*, tANI_U32*); |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 140 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 141 | void csrScanGetResultTimerHandler(void *); |
| 142 | void csrScanResultAgingTimerHandler(void *pv); |
Sandeep Puligilla | 2b6dc63 | 2012-12-17 14:44:16 -0800 | [diff] [blame] | 143 | static void csrScanResultCfgAgingTimerHandler(void *pv); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 144 | void csrScanIdleScanTimerHandler(void *); |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 145 | static void csrSetDefaultScanTiming( tpAniSirGlobal pMac, tSirScanType scanType, tCsrScanRequest *pScanRequest); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 146 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 147 | static void csrStaApConcTimerHandler(void *); |
| 148 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 149 | tANI_BOOLEAN csrIsSupportedChannel(tpAniSirGlobal pMac, tANI_U8 channelId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 150 | eHalStatus csrScanChannels( tpAniSirGlobal pMac, tSmeCmd *pCommand ); |
| 151 | void csrSetCfgValidChannelList( tpAniSirGlobal pMac, tANI_U8 *pChannelList, tANI_U8 NumChannels ); |
| 152 | void csrSaveTxPowerToCfg( tpAniSirGlobal pMac, tDblLinkList *pList, tANI_U32 cfgId ); |
| 153 | void csrSetCfgCountryCode( tpAniSirGlobal pMac, tANI_U8 *countryCode ); |
| 154 | void csrPurgeChannelPower( tpAniSirGlobal pMac, tDblLinkList *pChannelList ); |
| 155 | //if bgPeriod is 0, background scan is disabled. It is in millisecond units |
| 156 | eHalStatus csrSetCfgBackgroundScanPeriod(tpAniSirGlobal pMac, tANI_U32 bgPeriod); |
| 157 | eHalStatus csrProcessSetBGScanParam(tpAniSirGlobal pMac, tSmeCmd *pCommand); |
| 158 | void csrReleaseScanCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand, eCsrScanStatus scanStatus); |
| 159 | static tANI_BOOLEAN csrScanValidateScanResult( tpAniSirGlobal pMac, tANI_U8 *pChannels, |
| 160 | tANI_U8 numChn, tSirBssDescription *pBssDesc, |
| 161 | tDot11fBeaconIEs **ppIes ); |
| 162 | eHalStatus csrSetBGScanChannelList( tpAniSirGlobal pMac, tANI_U8 *pAdjustChannels, tANI_U8 NumAdjustChannels); |
| 163 | void csrReleaseCmdSingle(tpAniSirGlobal pMac, tSmeCmd *pCommand); |
| 164 | tANI_BOOLEAN csrRoamIsValidChannel( tpAniSirGlobal pMac, tANI_U8 channel ); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 165 | void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 166 | |
Madan Mohan Koyyalamudi | 783b236 | 2012-10-21 11:54:41 -0700 | [diff] [blame] | 167 | #define CSR_IS_SOCIAL_CHANNEL(channel) (((channel) == 1) || ((channel) == 6) || ((channel) == 11) ) |
| 168 | |
Madan Mohan Koyyalamudi | 783b236 | 2012-10-21 11:54:41 -0700 | [diff] [blame] | 169 | |
Madan Mohan Koyyalamudi | 783b236 | 2012-10-21 11:54:41 -0700 | [diff] [blame] | 170 | |
Madan Mohan Koyyalamudi | 923c1e1 | 2012-11-30 17:53:27 -0800 | [diff] [blame] | 171 | static void csrReleaseScanCmdPendingList(tpAniSirGlobal pMac) |
| 172 | { |
| 173 | tListElem *pEntry; |
| 174 | tSmeCmd *pCommand; |
| 175 | |
| 176 | while((pEntry = csrLLRemoveHead( &pMac->scan.scanCmdPendingList, LL_ACCESS_LOCK)) != NULL) |
| 177 | { |
| 178 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 179 | if ( eSmeCsrCommandMask & pCommand->command ) |
| 180 | { |
| 181 | csrAbortCommand( pMac, pCommand, eANI_BOOLEAN_TRUE ); |
| 182 | } |
| 183 | else |
| 184 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 185 | smsLog(pMac, LOGE, FL("Error: Received command : %d"),pCommand->command); |
Madan Mohan Koyyalamudi | 923c1e1 | 2012-11-30 17:53:27 -0800 | [diff] [blame] | 186 | } |
| 187 | } |
| 188 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 189 | //pResult is invalid calling this function. |
| 190 | void csrFreeScanResultEntry( tpAniSirGlobal pMac, tCsrScanResult *pResult ) |
| 191 | { |
| 192 | if( NULL != pResult->Result.pvIes ) |
| 193 | { |
| 194 | palFreeMemory( pMac->hHdd, pResult->Result.pvIes ); |
| 195 | } |
| 196 | palFreeMemory(pMac->hHdd, pResult); |
| 197 | } |
| 198 | |
| 199 | |
| 200 | static eHalStatus csrLLScanPurgeResult(tpAniSirGlobal pMac, tDblLinkList *pList) |
| 201 | { |
| 202 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 203 | tListElem *pEntry; |
| 204 | tCsrScanResult *pBssDesc; |
| 205 | |
| 206 | csrLLLock(pList); |
| 207 | |
| 208 | while((pEntry = csrLLRemoveHead(pList, LL_ACCESS_NOLOCK)) != NULL) |
| 209 | { |
| 210 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 211 | csrFreeScanResultEntry( pMac, pBssDesc ); |
| 212 | } |
| 213 | |
| 214 | csrLLUnlock(pList); |
| 215 | |
| 216 | return (status); |
| 217 | } |
| 218 | |
| 219 | |
| 220 | int csrCheckValidateLists(void * dest, const void *src, v_SIZE_t num, int idx) |
| 221 | { |
| 222 | #ifdef CSR_VALIDATE_LIST |
| 223 | |
| 224 | int ii = 1; |
| 225 | |
| 226 | if( (NULL == g_pMac) || (!g_pMac->scan.fValidateList ) ) |
| 227 | { |
| 228 | return ii; |
| 229 | } |
| 230 | if(g_pchannelPowerInfoList24) |
| 231 | { |
| 232 | //check 2.4 list |
| 233 | tListElem *pElem, *pHead; |
| 234 | int count; |
| 235 | |
| 236 | count = (int)(g_pchannelPowerInfoList24->Count); |
| 237 | pHead = &g_pchannelPowerInfoList24->ListHead; |
| 238 | pElem = pHead->next; |
| 239 | if((tANI_U32)(pHead->next) > 0x00010000) //Assuming kernel address is not that low. |
| 240 | { |
| 241 | //this loop crashes if the pointer is not right |
| 242 | while(pElem->next != pHead) |
| 243 | { |
| 244 | if((tANI_U32)(pElem->next) > 0x00010000) |
| 245 | { |
| 246 | pElem = pElem->next; |
| 247 | VOS_ASSERT(count > 0); |
| 248 | count--; |
| 249 | } |
| 250 | else |
| 251 | { |
| 252 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL, |
| 253 | " %d Detect 1 list(0x%X) error Head(0x%X) next(0x%X) Count %d, dest(0x%X) src(0x%X) numBytes(%d)", |
| 254 | idx, (unsigned int)g_pchannelPowerInfoList24, (unsigned int)pHead, |
| 255 | (unsigned int)(pHead->next), (int)g_pchannelPowerInfoList24->Count, |
| 256 | (unsigned int)dest, (unsigned int)src, (int)num); |
| 257 | VOS_ASSERT(0); |
| 258 | ii = 0; |
| 259 | break; |
| 260 | } |
| 261 | } |
| 262 | } |
| 263 | else |
| 264 | { |
| 265 | //Bad list |
| 266 | 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)", |
| 267 | idx, (unsigned int)g_pchannelPowerInfoList24, (unsigned int)pHead, |
| 268 | (unsigned int)(pHead->next), (int)g_pchannelPowerInfoList24->Count, |
| 269 | (unsigned int)dest, (unsigned int)src, (int)num); |
| 270 | VOS_ASSERT(0); |
| 271 | ii = 0; |
| 272 | } |
| 273 | } |
| 274 | else |
| 275 | { |
| 276 | //list ok |
| 277 | ii = 1; |
| 278 | } |
| 279 | |
| 280 | |
| 281 | return ii; |
| 282 | |
| 283 | #else |
| 284 | return 1; |
| 285 | #endif //#ifdef CSR_VALIDATE_LIST |
| 286 | } |
| 287 | |
| 288 | |
| 289 | eHalStatus csrScanOpen( tpAniSirGlobal pMac ) |
| 290 | { |
| 291 | eHalStatus status; |
| 292 | |
| 293 | do |
| 294 | { |
| 295 | csrLLOpen(pMac->hHdd, &pMac->scan.scanResultList); |
| 296 | csrLLOpen(pMac->hHdd, &pMac->scan.tempScanResults); |
| 297 | csrLLOpen(pMac->hHdd, &pMac->scan.channelPowerInfoList24); |
| 298 | csrLLOpen(pMac->hHdd, &pMac->scan.channelPowerInfoList5G); |
| 299 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 300 | csrLLOpen(pMac->hHdd, &pMac->scan.scanCmdPendingList); |
| 301 | #endif |
| 302 | #ifdef CSR_VALIDATE_LIST |
| 303 | g_pchannelPowerInfoList5 = &pMac->scan.channelPowerInfoList5G; |
| 304 | g_pMac = pMac; |
| 305 | g_pchannelPowerInfoList24 = &pMac->scan.channelPowerInfoList24; |
| 306 | #endif |
| 307 | pMac->scan.fFullScanIssued = eANI_BOOLEAN_FALSE; |
| 308 | pMac->scan.nBssLimit = CSR_MAX_BSS_SUPPORT; |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 309 | status = vos_timer_init(&pMac->scan.hTimerGetResult, VOS_TIMER_TYPE_SW, csrScanGetResultTimerHandler, pMac); |
| 310 | if (!HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 311 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 312 | smsLog(pMac, LOGE, FL("cannot allocate memory for getResult timer")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 313 | break; |
| 314 | } |
| 315 | #ifdef WLAN_AP_STA_CONCURRENCY |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 316 | status = vos_timer_init(&pMac->scan.hTimerStaApConcTimer, VOS_TIMER_TYPE_SW, csrStaApConcTimerHandler, pMac); |
| 317 | if (!HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 318 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 319 | smsLog(pMac, LOGE, FL("cannot allocate memory for hTimerStaApConcTimer timer")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 320 | break; |
| 321 | } |
| 322 | #endif |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 323 | status = vos_timer_init(&pMac->scan.hTimerIdleScan, VOS_TIMER_TYPE_SW, csrScanIdleScanTimerHandler, pMac); |
| 324 | if (!HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 325 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 326 | smsLog(pMac, LOGE, FL("cannot allocate memory for idleScan timer")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 327 | break; |
| 328 | } |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 329 | status = vos_timer_init(&pMac->scan.hTimerResultAging, VOS_TIMER_TYPE_SW, csrScanResultAgingTimerHandler, pMac); |
| 330 | if (!HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 331 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 332 | smsLog(pMac, LOGE, FL("cannot allocate memory for ResultAging timer")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 333 | break; |
| 334 | } |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 335 | status = vos_timer_init(&pMac->scan.hTimerResultCfgAging, VOS_TIMER_TYPE_SW, |
| 336 | csrScanResultCfgAgingTimerHandler, pMac); |
| 337 | if (!HAL_STATUS_SUCCESS(status)) |
Sandeep Puligilla | 2b6dc63 | 2012-12-17 14:44:16 -0800 | [diff] [blame] | 338 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 339 | smsLog(pMac, LOGE, FL("cannot allocate memory for CFG ResultAging timer")); |
Sandeep Puligilla | 2b6dc63 | 2012-12-17 14:44:16 -0800 | [diff] [blame] | 340 | break; |
| 341 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 342 | }while(0); |
| 343 | |
| 344 | return (status); |
| 345 | } |
| 346 | |
| 347 | |
| 348 | eHalStatus csrScanClose( tpAniSirGlobal pMac ) |
| 349 | { |
| 350 | #ifdef CSR_VALIDATE_LIST |
| 351 | g_pchannelPowerInfoList24 = NULL; |
| 352 | g_pchannelPowerInfoList5 = NULL; |
| 353 | g_pMac = NULL; |
| 354 | #endif |
| 355 | csrLLScanPurgeResult(pMac, &pMac->scan.tempScanResults); |
| 356 | csrLLScanPurgeResult(pMac, &pMac->scan.scanResultList); |
| 357 | #ifdef WLAN_AP_STA_CONCURRENCY |
Madan Mohan Koyyalamudi | 923c1e1 | 2012-11-30 17:53:27 -0800 | [diff] [blame] | 358 | csrReleaseScanCmdPendingList(pMac); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 359 | #endif |
| 360 | csrLLClose(&pMac->scan.scanResultList); |
| 361 | csrLLClose(&pMac->scan.tempScanResults); |
| 362 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 363 | csrLLClose(&pMac->scan.scanCmdPendingList); |
| 364 | #endif |
| 365 | csrPurgeChannelPower(pMac, &pMac->scan.channelPowerInfoList24); |
| 366 | csrPurgeChannelPower(pMac, &pMac->scan.channelPowerInfoList5G); |
| 367 | csrLLClose(&pMac->scan.channelPowerInfoList24); |
| 368 | csrLLClose(&pMac->scan.channelPowerInfoList5G); |
| 369 | csrScanDisable(pMac); |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 370 | vos_timer_destroy(&pMac->scan.hTimerResultAging); |
| 371 | vos_timer_destroy(&pMac->scan.hTimerResultCfgAging); |
| 372 | vos_timer_destroy(&pMac->scan.hTimerGetResult); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 373 | #ifdef WLAN_AP_STA_CONCURRENCY |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 374 | vos_timer_destroy(&pMac->scan.hTimerStaApConcTimer); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 375 | #endif |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 376 | vos_timer_destroy(&pMac->scan.hTimerIdleScan); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 377 | return eHAL_STATUS_SUCCESS; |
| 378 | } |
| 379 | |
| 380 | |
| 381 | eHalStatus csrScanEnable( tpAniSirGlobal pMac ) |
| 382 | { |
| 383 | |
| 384 | pMac->scan.fScanEnable = eANI_BOOLEAN_TRUE; |
| 385 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 386 | |
| 387 | return eHAL_STATUS_SUCCESS; |
| 388 | } |
| 389 | |
| 390 | |
| 391 | eHalStatus csrScanDisable( tpAniSirGlobal pMac ) |
| 392 | { |
| 393 | |
| 394 | csrScanStopTimers(pMac); |
| 395 | pMac->scan.fScanEnable = eANI_BOOLEAN_FALSE; |
| 396 | |
| 397 | return eHAL_STATUS_SUCCESS; |
| 398 | } |
| 399 | |
| 400 | |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 401 | //Set scan timing parameters according to state of other driver sessions |
| 402 | //No validation of the parameters is performed. |
| 403 | static void csrSetDefaultScanTiming( tpAniSirGlobal pMac, tSirScanType scanType, tCsrScanRequest *pScanRequest) |
| 404 | { |
| 405 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 406 | if(csrIsAnySessionConnected(pMac)) |
| 407 | { |
| 408 | //If multi-session, use the appropriate default scan times |
| 409 | if(scanType == eSIR_ACTIVE_SCAN) |
| 410 | { |
| 411 | pScanRequest->maxChnTime = pMac->roam.configParam.nActiveMaxChnTimeConc; |
| 412 | pScanRequest->minChnTime = pMac->roam.configParam.nActiveMinChnTimeConc; |
| 413 | } |
| 414 | else |
| 415 | { |
| 416 | pScanRequest->maxChnTime = pMac->roam.configParam.nPassiveMaxChnTimeConc; |
| 417 | pScanRequest->minChnTime = pMac->roam.configParam.nPassiveMinChnTimeConc; |
| 418 | } |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 419 | pScanRequest->maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc; |
| 420 | pScanRequest->minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc; |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 421 | |
| 422 | pScanRequest->restTime = pMac->roam.configParam.nRestTimeConc; |
| 423 | |
| 424 | //Return so that fields set above will not be overwritten. |
| 425 | return; |
| 426 | } |
| 427 | #endif |
| 428 | |
| 429 | //This portion of the code executed if multi-session not supported |
| 430 | //(WLAN_AP_STA_CONCURRENCY not defined) or no multi-session. |
| 431 | //Use the "regular" (non-concurrency) default scan timing. |
| 432 | if(pScanRequest->scanType == eSIR_ACTIVE_SCAN) |
| 433 | { |
| 434 | pScanRequest->maxChnTime = pMac->roam.configParam.nActiveMaxChnTime; |
| 435 | pScanRequest->minChnTime = pMac->roam.configParam.nActiveMinChnTime; |
| 436 | } |
| 437 | else |
| 438 | { |
| 439 | pScanRequest->maxChnTime = pMac->roam.configParam.nPassiveMaxChnTime; |
| 440 | pScanRequest->minChnTime = pMac->roam.configParam.nPassiveMinChnTime; |
| 441 | } |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 442 | pScanRequest->maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc; |
| 443 | pScanRequest->minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc; |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 444 | |
| 445 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 446 | //No rest time if no sessions are connected. |
| 447 | pScanRequest->restTime = 0; |
| 448 | #endif |
| 449 | } |
| 450 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 451 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 452 | //Return SUCCESS is the command is queued, else returns eHAL_STATUS_FAILURE |
| 453 | eHalStatus csrQueueScanRequest( tpAniSirGlobal pMac, tSmeCmd *pScanCmd ) |
| 454 | { |
| 455 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 456 | |
| 457 | tANI_BOOLEAN fNoCmdPending; |
| 458 | tSmeCmd *pQueueScanCmd=NULL; |
| 459 | tSmeCmd *pSendScanCmd=NULL; |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 460 | tANI_U8 nNumChanCombinedConc = 0; |
Gopichand Nakkala | 114718f | 2013-03-25 19:19:46 -0700 | [diff] [blame] | 461 | if (NULL == pScanCmd) |
| 462 | { |
| 463 | smsLog (pMac, LOGE, FL("Scan Req cmd is NULL")); |
| 464 | return eHAL_STATUS_FAILURE; |
| 465 | } |
Madan Mohan Koyyalamudi | 48081ef | 2012-12-04 16:49:55 -0800 | [diff] [blame] | 466 | /* split scan if any one of the following: |
| 467 | * - STA session is connected and the scan is not a P2P search |
| 468 | * - any P2P session is connected |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 469 | * Do not split scans if no concurrent infra connections are |
| 470 | * active and if the scan is a BG scan triggered by LFR (OR) |
| 471 | * any scan if LFR is in the middle of a BG scan. Splitting |
| 472 | * the scan is delaying the time it takes for LFR to find |
| 473 | * candidates and resulting in disconnects. |
Madan Mohan Koyyalamudi | 48081ef | 2012-12-04 16:49:55 -0800 | [diff] [blame] | 474 | */ |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 475 | |
| 476 | if(csrIsStaSessionConnected(pMac) && |
| 477 | !csrIsP2pSessionConnected(pMac)) |
| 478 | { |
| 479 | nNumChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc; |
| 480 | } |
| 481 | else if(csrIsP2pSessionConnected(pMac)) |
| 482 | { |
| 483 | nNumChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc; |
| 484 | } |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 485 | if ( (csrIsStaSessionConnected(pMac) && |
| 486 | #ifdef FEATURE_WLAN_LFR |
| 487 | (csrIsConcurrentInfraConnected(pMac) || |
| 488 | ((pScanCmd->u.scanCmd.reason != eCsrScanBgScan) && |
| 489 | (pMac->roam.neighborRoamInfo.neighborRoamState != |
| 490 | eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN))) && |
| 491 | #endif |
| 492 | (pScanCmd->u.scanCmd.u.scanRequest.p2pSearch != 1)) || |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 493 | (csrIsP2pSessionConnected(pMac)) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 494 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 495 | tCsrScanRequest scanReq; |
| 496 | tANI_U8 numChn = pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels; |
| 497 | tCsrChannelInfo *pChnInfo = &scanReq.ChannelInfo; |
| 498 | tANI_U8 channelToScan[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 499 | tANI_BOOLEAN bMemAlloc = eANI_BOOLEAN_FALSE; |
| 500 | |
| 501 | if (numChn == 0) |
| 502 | { |
| 503 | |
| 504 | numChn = pMac->scan.baseChannels.numChannels; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 505 | |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 506 | status = palAllocateMemory( pMac->hHdd, (void **)&pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList, numChn ); |
| 507 | if( !HAL_STATUS_SUCCESS( status ) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 508 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 509 | smsLog( pMac, LOGE, FL(" Failed to get memory for channel list ") ); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 510 | return eHAL_STATUS_FAILURE; |
| 511 | } |
| 512 | bMemAlloc = eANI_BOOLEAN_TRUE; |
| 513 | status = palCopyMemory( pMac->hHdd, pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList, |
| 514 | pMac->scan.baseChannels.channelList, numChn ); |
| 515 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 516 | { |
| 517 | palFreeMemory( pMac->hHdd, pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList ); |
| 518 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = NULL; |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 519 | smsLog( pMac, LOGE, FL(" Failed to copy memory to channel list ") ); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 520 | return eHAL_STATUS_FAILURE; |
| 521 | } |
| 522 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = numChn; |
| 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 | //Whenever we get a scan request with multiple channels we break it up into 2 requests |
| 526 | //First request for first channel to scan and second request to scan remaining channels |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 527 | if ( numChn > nNumChanCombinedConc) |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 528 | { |
| 529 | palZeroMemory(pMac->hHdd, &scanReq, sizeof(tCsrScanRequest)); |
| 530 | |
| 531 | pQueueScanCmd = csrGetCommandBuffer(pMac); //optimize this to use 2 command buffer only |
| 532 | if (!pQueueScanCmd) |
| 533 | { |
| 534 | if (bMemAlloc) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 535 | { |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 536 | palFreeMemory( pMac->hHdd, pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList ); |
| 537 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = NULL; |
| 538 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 539 | } |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 540 | smsLog( pMac, LOGE, FL(" Failed to get Queue command buffer") ); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 541 | return eHAL_STATUS_FAILURE; |
| 542 | } |
| 543 | pQueueScanCmd->command = pScanCmd->command; |
| 544 | pQueueScanCmd->sessionId = pScanCmd->sessionId; |
| 545 | pQueueScanCmd->u.scanCmd.callback = pScanCmd->u.scanCmd.callback; |
| 546 | pQueueScanCmd->u.scanCmd.pContext = pScanCmd->u.scanCmd.pContext; |
| 547 | pQueueScanCmd->u.scanCmd.reason = pScanCmd->u.scanCmd.reason; |
| 548 | pQueueScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 549 | |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 550 | /* First copy all the parameters to local variable of scan request */ |
| 551 | csrScanCopyRequest(pMac, &scanReq, &pScanCmd->u.scanCmd.u.scanRequest); |
Madan Mohan Koyyalamudi | af2a8b9 | 2012-10-09 14:58:07 -0700 | [diff] [blame] | 552 | |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 553 | /* Now modify the elements of local var scan request required to be modified for split scan */ |
| 554 | if(scanReq.ChannelInfo.ChannelList != NULL) |
| 555 | { |
| 556 | palFreeMemory(pMac->hHdd, scanReq.ChannelInfo.ChannelList); |
Madan Mohan Koyyalamudi | 0c626f3 | 2012-11-30 15:10:25 -0800 | [diff] [blame] | 557 | scanReq.ChannelInfo.ChannelList = NULL; |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 558 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 559 | |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 560 | pChnInfo->numOfChannels = pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels - nNumChanCombinedConc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 561 | |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 562 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN, |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 563 | FL(" &channelToScan %p pScanCmd(%p) pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList(%p)numChn(%d)"), |
| 564 | &channelToScan[0], pScanCmd, |
| 565 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList, numChn); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 566 | |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 567 | palCopyMemory(pMac->hHdd, &channelToScan[0], &pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[nNumChanCombinedConc], |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 568 | pChnInfo->numOfChannels * sizeof(tANI_U8)); |
| 569 | |
| 570 | pChnInfo->ChannelList = &channelToScan[0]; |
| 571 | |
| 572 | scanReq.BSSType = eCSR_BSS_TYPE_ANY; |
| 573 | //Modify callers parameters in case of concurrency |
Madan Mohan Koyyalamudi | 04a65f0 | 2013-07-26 13:58:38 +0530 | [diff] [blame] | 574 | if (!pScanCmd->u.scanCmd.u.scanRequest.bcnRptReqScan) |
| 575 | scanReq.scanType = eSIR_ACTIVE_SCAN; |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 576 | //Use concurrency values for min/maxChnTime. |
| 577 | //We know csrIsAnySessionConnected(pMac) returns TRUE here |
| 578 | csrSetDefaultScanTiming(pMac, scanReq.scanType, &scanReq); |
| 579 | |
| 580 | status = csrScanCopyRequest(pMac, &pQueueScanCmd->u.scanCmd.u.scanRequest, &scanReq); |
| 581 | |
| 582 | if(!HAL_STATUS_SUCCESS(status)) |
| 583 | { |
| 584 | if (bMemAlloc) |
| 585 | { |
| 586 | palFreeMemory( pMac->hHdd, pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList ); |
| 587 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = NULL; |
| 588 | |
| 589 | } |
| 590 | if( scanReq.pIEField != NULL) |
| 591 | { |
| 592 | palFreeMemory(pMac->hHdd, scanReq.pIEField); |
| 593 | scanReq.pIEField = NULL; |
| 594 | } |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 595 | smsLog( pMac, LOGE, FL(" Failed to get copy csrScanRequest = %d"), status ); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 596 | return eHAL_STATUS_FAILURE; |
| 597 | } |
| 598 | /* Clean the local scan variable */ |
| 599 | scanReq.ChannelInfo.ChannelList = NULL; |
| 600 | scanReq.ChannelInfo.numOfChannels = 0; |
| 601 | csrScanFreeRequest(pMac, &scanReq); |
| 602 | |
| 603 | /* setup the command to scan 2 channels */ |
| 604 | pSendScanCmd = pScanCmd; |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 605 | pSendScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = nNumChanCombinedConc; |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 606 | pSendScanCmd->u.scanCmd.u.scanRequest.BSSType = eCSR_BSS_TYPE_ANY; |
Madan Mohan Koyyalamudi | 04a65f0 | 2013-07-26 13:58:38 +0530 | [diff] [blame] | 607 | if (!pSendScanCmd->u.scanCmd.u.scanRequest.bcnRptReqScan) |
| 608 | pSendScanCmd->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN; |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 609 | //Use concurrency values for min/maxChnTime. |
| 610 | //We know csrIsAnySessionConnected(pMac) returns TRUE here |
| 611 | csrSetDefaultScanTiming(pMac, pSendScanCmd->u.scanCmd.u.scanRequest.scanType, &pSendScanCmd->u.scanCmd.u.scanRequest); |
| 612 | pSendScanCmd->u.scanCmd.callback = NULL; |
| 613 | } else { |
| 614 | pSendScanCmd = pScanCmd; |
| 615 | pSendScanCmd->u.scanCmd.u.scanRequest.BSSType = eCSR_BSS_TYPE_ANY; |
Madan Mohan Koyyalamudi | 04a65f0 | 2013-07-26 13:58:38 +0530 | [diff] [blame] | 616 | if (!pSendScanCmd->u.scanCmd.u.scanRequest.bcnRptReqScan) |
| 617 | pSendScanCmd->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN; |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 618 | //Use concurrency values for min/maxChnTime. |
| 619 | //We know csrIsAnySessionConnected(pMac) returns TRUE here |
| 620 | csrSetDefaultScanTiming(pMac, pSendScanCmd->u.scanCmd.u.scanRequest.scanType, &pSendScanCmd->u.scanCmd.u.scanRequest); |
| 621 | } |
| 622 | |
| 623 | fNoCmdPending = csrLLIsListEmpty( &pMac->scan.scanCmdPendingList, LL_ACCESS_LOCK ); |
| 624 | |
| 625 | //Logic Below is as follows |
| 626 | // If the scanCmdPendingList is empty then we directly send that command |
| 627 | // to smeCommandQueue else we buffer it in our scanCmdPendingList Queue |
| 628 | if( fNoCmdPending ) |
| 629 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 630 | if (pQueueScanCmd != NULL) |
| 631 | { |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 632 | csrLLInsertTail( &pMac->scan.scanCmdPendingList, &pQueueScanCmd->Link, LL_ACCESS_LOCK ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 633 | } |
| 634 | |
| 635 | if (pSendScanCmd != NULL) |
| 636 | { |
| 637 | return csrQueueSmeCommand(pMac, pSendScanCmd, eANI_BOOLEAN_FALSE); |
| 638 | } |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 639 | } |
| 640 | else |
| 641 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 642 | if (pSendScanCmd != NULL) |
| 643 | { |
| 644 | csrLLInsertTail( &pMac->scan.scanCmdPendingList, &pSendScanCmd->Link, LL_ACCESS_LOCK ); |
| 645 | } |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 646 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 647 | if (pQueueScanCmd != NULL) |
| 648 | { |
| 649 | csrLLInsertTail( &pMac->scan.scanCmdPendingList, &pQueueScanCmd->Link, LL_ACCESS_LOCK ); |
| 650 | } |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 651 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 652 | } |
| 653 | else |
| 654 | { //No concurrency case |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 655 | smsLog( pMac, LOG2, FL("Queuing scan command (reason=%d, roamState=%d" |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 656 | " numOfChannels=%d)"), |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 657 | pScanCmd->u.scanCmd.reason, |
| 658 | pMac->roam.neighborRoamInfo.neighborRoamState, |
| 659 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 660 | return csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_FALSE); |
| 661 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 662 | |
| 663 | return ( status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 664 | } |
| 665 | #endif |
| 666 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 667 | /* --------------------------------------------------------------------------- |
| 668 | \fn csrScan2GOnyRequest |
| 669 | \brief This function will update the scan request with only |
Jeff Johnson | b88db98 | 2012-12-10 13:34:59 -0800 | [diff] [blame] | 670 | 2.4GHz valid channel list. |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 671 | \param pMac |
| 672 | \param pScanCmd |
| 673 | \param pScanRequest |
| 674 | \return None |
| 675 | -------------------------------------------------------------------------------*/ |
| 676 | static void csrScan2GOnyRequest(tpAniSirGlobal pMac,tSmeCmd *pScanCmd, |
| 677 | tCsrScanRequest *pScanRequest) |
| 678 | { |
| 679 | tANI_U8 index, channelId, channelListSize = 0; |
| 680 | tANI_U8 channelList2G[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}; |
| 681 | static tANI_U8 validchannelList[CSR_MAX_2_4_GHZ_SUPPORTED_CHANNELS] = {0}; |
| 682 | |
| 683 | VOS_ASSERT(pScanCmd && pScanRequest); |
Madan Mohan Koyyalamudi | 33ef6a2 | 2012-10-30 17:44:43 -0700 | [diff] [blame] | 684 | /* To silence the KW tool null check is added */ |
| 685 | if((pScanCmd == NULL) || (pScanRequest == NULL)) |
| 686 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 687 | smsLog( pMac, LOGE, FL(" pScanCmd or pScanRequest is NULL ")); |
Madan Mohan Koyyalamudi | 33ef6a2 | 2012-10-30 17:44:43 -0700 | [diff] [blame] | 688 | return; |
| 689 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 690 | |
| 691 | if (pScanCmd->u.scanCmd.scanID || |
| 692 | (eCSR_SCAN_REQUEST_FULL_SCAN != pScanRequest->requestType)) |
| 693 | return; |
| 694 | |
| 695 | //Contsruct valid Supported 2.4 GHz Channel List |
| 696 | for( index = 0; index < ARRAY_SIZE(channelList2G); index++ ) |
| 697 | { |
| 698 | channelId = channelList2G[index]; |
| 699 | if ( csrIsSupportedChannel( pMac, channelId ) ) |
| 700 | { |
| 701 | validchannelList[channelListSize++] = channelId; |
| 702 | } |
| 703 | } |
| 704 | |
| 705 | pScanRequest->ChannelInfo.numOfChannels = channelListSize; |
| 706 | pScanRequest->ChannelInfo.ChannelList = validchannelList; |
| 707 | } |
| 708 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 709 | eHalStatus csrScanRequest(tpAniSirGlobal pMac, tANI_U16 sessionId, |
| 710 | tCsrScanRequest *pScanRequest, tANI_U32 *pScanRequestID, |
| 711 | csrScanCompleteCallback callback, void *pContext) |
| 712 | { |
| 713 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 714 | tSmeCmd *pScanCmd = NULL; |
Madan Mohan Koyyalamudi | cb90bb2 | 2012-10-30 18:24:43 -0700 | [diff] [blame] | 715 | eCsrConnectState ConnectState; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 716 | |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 717 | if(pScanRequest == NULL) |
| 718 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 719 | smsLog( pMac, LOGE, FL(" pScanRequest is NULL")); |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 720 | VOS_ASSERT(0); |
| 721 | } |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 722 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 723 | do |
| 724 | { |
| 725 | if(pMac->scan.fScanEnable) |
| 726 | { |
| 727 | pScanCmd = csrGetCommandBuffer(pMac); |
| 728 | if(pScanCmd) |
| 729 | { |
| 730 | palZeroMemory(pMac->hHdd, &pScanCmd->u.scanCmd, sizeof(tScanCmd)); |
| 731 | pScanCmd->command = eSmeCommandScan; |
| 732 | pScanCmd->sessionId = sessionId; |
| 733 | pScanCmd->u.scanCmd.callback = callback; |
| 734 | pScanCmd->u.scanCmd.pContext = pContext; |
| 735 | if(eCSR_SCAN_REQUEST_11D_SCAN == pScanRequest->requestType) |
| 736 | { |
| 737 | pScanCmd->u.scanCmd.reason = eCsrScan11d1; |
| 738 | } |
| 739 | else if((eCSR_SCAN_REQUEST_FULL_SCAN == pScanRequest->requestType) || |
| 740 | (eCSR_SCAN_P2P_DISCOVERY == pScanRequest->requestType) |
| 741 | #ifdef SOFTAP_CHANNEL_RANGE |
| 742 | ||(eCSR_SCAN_SOFTAP_CHANNEL_RANGE == pScanRequest->requestType) |
| 743 | #endif |
| 744 | ) |
| 745 | { |
| 746 | pScanCmd->u.scanCmd.reason = eCsrScanUserRequest; |
| 747 | } |
| 748 | else if(eCSR_SCAN_HO_BG_SCAN == pScanRequest->requestType) |
| 749 | { |
| 750 | pScanCmd->u.scanCmd.reason = eCsrScanBgScan; |
| 751 | } |
| 752 | else if(eCSR_SCAN_HO_PROBE_SCAN == pScanRequest->requestType) |
| 753 | { |
| 754 | pScanCmd->u.scanCmd.reason = eCsrScanProbeBss; |
| 755 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 756 | else if(eCSR_SCAN_P2P_FIND_PEER == pScanRequest->requestType) |
| 757 | { |
| 758 | pScanCmd->u.scanCmd.reason = eCsrScanP2PFindPeer; |
| 759 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 760 | else |
| 761 | { |
| 762 | pScanCmd->u.scanCmd.reason = eCsrScanIdleScan; |
| 763 | } |
| 764 | if(pScanRequest->minChnTime == 0 && pScanRequest->maxChnTime == 0) |
| 765 | { |
| 766 | //The caller doesn't set the time correctly. Set it here |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 767 | csrSetDefaultScanTiming(pMac, pScanRequest->scanType, pScanRequest); |
| 768 | } |
| 769 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 770 | if(pScanRequest->restTime == 0) |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 771 | { |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 772 | //Need to set restTime only if at least one session is connected |
| 773 | if(csrIsAnySessionConnected(pMac)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 774 | { |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 775 | pScanRequest->restTime = pMac->roam.configParam.nRestTimeConc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 776 | } |
| 777 | } |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 778 | #endif |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 779 | /*For Standalone wlan : channel time will remain the same. |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 780 | For BTC with A2DP up: Channel time = Channel time * 2, if station is not already associated. |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 781 | This has been done to provide a larger scan window for faster connection during btc.Else Scan is seen |
| 782 | to take a long time. |
| 783 | For BTC with A2DP up: Channel time will not be doubled, if station is already associated. |
| 784 | */ |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 785 | status = csrRoamGetConnectState(pMac,sessionId,&ConnectState); |
Srinivas Girigowda | c84c57c | 2013-02-19 17:41:56 -0800 | [diff] [blame] | 786 | if (HAL_STATUS_SUCCESS(status) && |
| 787 | pMac->btc.fA2DPUp && |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 788 | (eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED != ConnectState) && |
| 789 | (eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED != ConnectState)) |
| 790 | { |
| 791 | pScanRequest->maxChnTime = pScanRequest->maxChnTime << 1; |
| 792 | pScanRequest->minChnTime = pScanRequest->minChnTime << 1; |
| 793 | } |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 794 | |
| 795 | pScanRequest->maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc; |
| 796 | pScanRequest->minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 797 | //Need to make the following atomic |
| 798 | pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around |
| 799 | |
| 800 | if(pScanRequestID) |
| 801 | { |
| 802 | *pScanRequestID = pScanCmd->u.scanCmd.scanID; |
| 803 | } |
| 804 | |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 805 | // 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] | 806 | // If it is not, CSR will save the scan request in the pending cmd queue |
| 807 | // & issue an 11d scan request to PE. |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 808 | if (((0 == pScanCmd->u.scanCmd.scanID) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 809 | && (eCSR_SCAN_REQUEST_11D_SCAN != pScanRequest->requestType)) |
| 810 | #ifdef SOFTAP_CHANNEL_RANGE |
| 811 | && (eCSR_SCAN_SOFTAP_CHANNEL_RANGE != pScanRequest->requestType) |
| 812 | #endif |
| 813 | && (eANI_BOOLEAN_FALSE == pMac->scan.fEnableBypass11d) |
| 814 | ) |
| 815 | { |
| 816 | tSmeCmd *p11dScanCmd; |
| 817 | tCsrScanRequest scanReq; |
| 818 | tCsrChannelInfo *pChnInfo = &scanReq.ChannelInfo; |
| 819 | |
| 820 | palZeroMemory(pMac->hHdd, &scanReq, sizeof(tCsrScanRequest)); |
| 821 | |
| 822 | p11dScanCmd = csrGetCommandBuffer(pMac); |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 823 | if (p11dScanCmd) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 824 | { |
| 825 | tANI_U32 numChn = pMac->scan.baseChannels.numChannels; |
| 826 | |
| 827 | palZeroMemory(pMac->hHdd, &p11dScanCmd->u.scanCmd, sizeof(tScanCmd)); |
| 828 | status = palAllocateMemory( pMac->hHdd, (void **)&pChnInfo->ChannelList, numChn ); |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 829 | if ( !HAL_STATUS_SUCCESS( status ) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 830 | { |
| 831 | break; |
| 832 | } |
| 833 | status = palCopyMemory( pMac->hHdd, pChnInfo->ChannelList, |
| 834 | pMac->scan.baseChannels.channelList, numChn ); |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 835 | if ( !HAL_STATUS_SUCCESS( status ) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 836 | { |
| 837 | palFreeMemory( pMac->hHdd, pChnInfo->ChannelList ); |
| 838 | pChnInfo->ChannelList = NULL; |
| 839 | break; |
| 840 | } |
| 841 | pChnInfo->numOfChannels = (tANI_U8)numChn; |
| 842 | p11dScanCmd->command = eSmeCommandScan; |
| 843 | p11dScanCmd->u.scanCmd.callback = NULL; |
| 844 | p11dScanCmd->u.scanCmd.pContext = NULL; |
| 845 | p11dScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; |
| 846 | scanReq.BSSType = eCSR_BSS_TYPE_ANY; |
| 847 | |
| 848 | if ( csrIs11dSupported(pMac) ) |
| 849 | { |
Madan Mohan Koyyalamudi | 04a65f0 | 2013-07-26 13:58:38 +0530 | [diff] [blame] | 850 | scanReq.bcnRptReqScan = pScanRequest->bcnRptReqScan; |
| 851 | if (pScanRequest->bcnRptReqScan) |
| 852 | scanReq.scanType = pScanRequest->scanType ? |
| 853 | eSIR_PASSIVE_SCAN : |
| 854 | pScanRequest->scanType; |
| 855 | else |
| 856 | scanReq.scanType = eSIR_PASSIVE_SCAN; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 857 | scanReq.requestType = eCSR_SCAN_REQUEST_11D_SCAN; |
| 858 | p11dScanCmd->u.scanCmd.reason = eCsrScan11d1; |
| 859 | scanReq.maxChnTime = pMac->roam.configParam.nPassiveMaxChnTime; |
| 860 | scanReq.minChnTime = pMac->roam.configParam.nPassiveMinChnTime; |
| 861 | } |
| 862 | else |
| 863 | { |
Madan Mohan Koyyalamudi | 04a65f0 | 2013-07-26 13:58:38 +0530 | [diff] [blame] | 864 | scanReq.bcnRptReqScan = pScanRequest->bcnRptReqScan; |
| 865 | if (pScanRequest->bcnRptReqScan) |
| 866 | scanReq.scanType = pScanRequest->scanType; |
| 867 | else |
| 868 | scanReq.scanType = eSIR_ACTIVE_SCAN; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 869 | scanReq.requestType = eCSR_SCAN_IDLE_MODE_SCAN; |
| 870 | p11dScanCmd->u.scanCmd.reason = eCsrScanIdleScan; |
| 871 | scanReq.maxChnTime = pMac->roam.configParam.nActiveMaxChnTime; |
| 872 | scanReq.minChnTime = pMac->roam.configParam.nActiveMinChnTime; |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 873 | |
Madan Mohan Koyyalamudi | 04a65f0 | 2013-07-26 13:58:38 +0530 | [diff] [blame] | 874 | scanReq.maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc; |
| 875 | scanReq.minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 876 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 877 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 878 | status = csrScanCopyRequest(pMac, &p11dScanCmd->u.scanCmd.u.scanRequest, &scanReq); |
| 879 | //Free the channel list |
| 880 | palFreeMemory( pMac->hHdd, pChnInfo->ChannelList ); |
James Zmuda | 9ea1edd | 2013-04-18 18:20:54 -0700 | [diff] [blame] | 881 | pChnInfo->ChannelList = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 882 | |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 883 | if (HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 884 | { |
| 885 | //Start process the command |
| 886 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 887 | status = csrQueueScanRequest(pMac, p11dScanCmd); |
| 888 | #else |
| 889 | status = csrQueueSmeCommand(pMac, p11dScanCmd, eANI_BOOLEAN_FALSE); |
| 890 | #endif |
| 891 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 892 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 893 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 894 | break; |
| 895 | } |
| 896 | } |
| 897 | else |
| 898 | { |
| 899 | break; |
| 900 | } |
| 901 | } |
| 902 | else |
| 903 | { |
| 904 | //error |
| 905 | break; |
| 906 | } |
| 907 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 908 | |
| 909 | //Scan only 2G Channels if set in ini file |
| 910 | //This is mainly to reduce the First Scan duration |
| 911 | //Once we turn on Wifi |
| 912 | if(pMac->scan.fFirstScanOnly2GChnl) |
| 913 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 914 | smsLog( pMac, LOG1, FL("Scanning only 2G Channels during first scan")); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 915 | csrScan2GOnyRequest(pMac, pScanCmd, pScanRequest); |
| 916 | } |
| 917 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 918 | status = csrScanCopyRequest(pMac, &pScanCmd->u.scanCmd.u.scanRequest, pScanRequest); |
| 919 | if(HAL_STATUS_SUCCESS(status)) |
| 920 | { |
| 921 | //Start process the command |
| 922 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 923 | status = csrQueueScanRequest(pMac,pScanCmd); |
| 924 | #else |
| 925 | status = csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_FALSE); |
| 926 | #endif |
| 927 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 928 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 929 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 930 | break; |
| 931 | } |
| 932 | } |
| 933 | else |
| 934 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 935 | smsLog( pMac, LOGE, FL(" fail to copy request status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 936 | break; |
| 937 | } |
| 938 | } |
| 939 | else |
| 940 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 941 | smsLog( pMac, LOGE, FL(" pScanCmd is NULL")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 942 | break; |
| 943 | } |
| 944 | } |
| 945 | } while(0); |
| 946 | if(!HAL_STATUS_SUCCESS(status) && pScanCmd) |
| 947 | { |
| 948 | if( eCsrScanIdleScan == pScanCmd->u.scanCmd.reason ) |
| 949 | { |
| 950 | //Set the flag back for restarting idle scan |
| 951 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 952 | } |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 953 | smsLog( pMac, LOGE, FL(" failed with status = %d, releasing scan cmd"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 954 | csrReleaseCommandScan(pMac, pScanCmd); |
| 955 | } |
| 956 | |
| 957 | return (status); |
| 958 | } |
| 959 | |
| 960 | |
| 961 | eHalStatus csrScanRequestResult(tpAniSirGlobal pMac) |
| 962 | { |
| 963 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 964 | tSmeCmd *pScanCmd; |
| 965 | |
| 966 | if(pMac->scan.fScanEnable) |
| 967 | { |
| 968 | pScanCmd = csrGetCommandBuffer(pMac); |
| 969 | if(pScanCmd) |
| 970 | { |
| 971 | pScanCmd->command = eSmeCommandScan; |
| 972 | palZeroMemory(pMac->hHdd, &pScanCmd->u.scanCmd, sizeof(tScanCmd)); |
| 973 | pScanCmd->u.scanCmd.callback = NULL; |
| 974 | pScanCmd->u.scanCmd.pContext = NULL; |
| 975 | pScanCmd->u.scanCmd.reason = eCsrScanGetResult; |
| 976 | //Need to make the following atomic |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 977 | pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID; //let it wrap around |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 978 | status = csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_FALSE); |
| 979 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 980 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 981 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 982 | csrReleaseCommandScan(pMac, pScanCmd); |
| 983 | } |
| 984 | } |
| 985 | else |
| 986 | { |
| 987 | //log error |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 988 | smsLog(pMac, LOGE, FL("can not obtain a common buffer")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 989 | status = eHAL_STATUS_RESOURCES; |
| 990 | } |
| 991 | } |
| 992 | |
| 993 | return (status); |
| 994 | } |
| 995 | |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 996 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 997 | eHalStatus csrScanRequestLfrResult(tpAniSirGlobal pMac, tANI_U32 sessionId, |
| 998 | csrScanCompleteCallback callback, void *pContext) |
| 999 | { |
| 1000 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1001 | tSmeCmd *pScanCmd; |
| 1002 | |
| 1003 | if (pMac->scan.fScanEnable) |
| 1004 | { |
| 1005 | pScanCmd = csrGetCommandBuffer(pMac); |
| 1006 | if (pScanCmd) |
| 1007 | { |
| 1008 | pScanCmd->command = eSmeCommandScan; |
| 1009 | pScanCmd->sessionId = sessionId; |
| 1010 | palZeroMemory(pMac->hHdd, &pScanCmd->u.scanCmd, sizeof(tScanCmd)); |
| 1011 | pScanCmd->u.scanCmd.callback = callback; |
| 1012 | pScanCmd->u.scanCmd.pContext = pContext; |
| 1013 | pScanCmd->u.scanCmd.reason = eCsrScanGetLfrResult; |
| 1014 | //Need to make the following atomic |
| 1015 | pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID; //let it wrap around |
| 1016 | status = csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_TRUE); |
| 1017 | if ( !HAL_STATUS_SUCCESS( status ) ) |
| 1018 | { |
| 1019 | smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status ); |
| 1020 | csrReleaseCommandScan(pMac, pScanCmd); |
| 1021 | } |
| 1022 | } |
| 1023 | else |
| 1024 | { |
| 1025 | //log error |
| 1026 | smsLog(pMac, LOGE, FL("can not obtain a common buffer\n")); |
| 1027 | status = eHAL_STATUS_RESOURCES; |
| 1028 | } |
| 1029 | } |
| 1030 | |
| 1031 | return (status); |
| 1032 | } |
| 1033 | #endif //WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1034 | |
| 1035 | eHalStatus csrScanAllChannels(tpAniSirGlobal pMac, eCsrRequestType reqType) |
| 1036 | { |
| 1037 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1038 | tANI_U32 scanId; |
| 1039 | tCsrScanRequest scanReq; |
| 1040 | |
| 1041 | palZeroMemory(pMac->hHdd, &scanReq, sizeof(tCsrScanRequest)); |
| 1042 | scanReq.BSSType = eCSR_BSS_TYPE_ANY; |
| 1043 | scanReq.scanType = eSIR_ACTIVE_SCAN; |
| 1044 | scanReq.requestType = reqType; |
| 1045 | scanReq.maxChnTime = pMac->roam.configParam.nActiveMaxChnTime; |
| 1046 | scanReq.minChnTime = pMac->roam.configParam.nActiveMinChnTime; |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 1047 | scanReq.maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc; |
| 1048 | scanReq.minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1049 | //Scan with invalid sessionId. |
| 1050 | //This results in SME using the first available session to scan. |
| 1051 | status = csrScanRequest(pMac, CSR_SESSION_ID_INVALID, &scanReq, |
| 1052 | &scanId, NULL, NULL); |
| 1053 | |
| 1054 | return (status); |
| 1055 | } |
| 1056 | |
| 1057 | |
| 1058 | |
| 1059 | |
| 1060 | eHalStatus csrIssueRoamAfterLostlinkScan(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamReason reason) |
| 1061 | { |
| 1062 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 1063 | tScanResultHandle hBSSList = NULL; |
| 1064 | tCsrScanResultFilter *pScanFilter = NULL; |
| 1065 | tANI_U32 roamId = 0; |
| 1066 | tCsrRoamProfile *pProfile = NULL; |
| 1067 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 1068 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1069 | if(!pSession) |
| 1070 | { |
| 1071 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 1072 | return eHAL_STATUS_FAILURE; |
| 1073 | } |
| 1074 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1075 | do |
| 1076 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1077 | smsLog(pMac, LOG1, " csrIssueRoamAfterLostlinkScan called"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1078 | if(pSession->fCancelRoaming) |
| 1079 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1080 | smsLog(pMac, LOGW, " lostlink roaming is cancelled"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1081 | csrScanStartIdleScan(pMac); |
| 1082 | status = eHAL_STATUS_SUCCESS; |
| 1083 | break; |
| 1084 | } |
| 1085 | //Here is the profile we need to connect to |
| 1086 | status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter)); |
| 1087 | if(!HAL_STATUS_SUCCESS(status)) |
| 1088 | break; |
| 1089 | palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter)); |
| 1090 | if(NULL == pSession->pCurRoamProfile) |
| 1091 | { |
| 1092 | pScanFilter->EncryptionType.numEntries = 1; |
| 1093 | pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE; |
| 1094 | } |
| 1095 | else |
| 1096 | { |
| 1097 | //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect |
| 1098 | status = palAllocateMemory(pMac->hHdd, (void **)&pProfile, sizeof(tCsrRoamProfile)); |
| 1099 | if(!HAL_STATUS_SUCCESS(status)) |
| 1100 | break; |
| 1101 | palZeroMemory(pMac->hHdd, pProfile, sizeof(tCsrRoamProfile)); |
| 1102 | status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile); |
| 1103 | if(!HAL_STATUS_SUCCESS(status)) |
| 1104 | break; |
| 1105 | status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter); |
| 1106 | }//We have a profile |
| 1107 | roamId = GET_NEXT_ROAM_ID(&pMac->roam); |
| 1108 | if(HAL_STATUS_SUCCESS(status)) |
| 1109 | { |
| 1110 | status = csrScanGetResult(pMac, pScanFilter, &hBSSList); |
| 1111 | if(HAL_STATUS_SUCCESS(status)) |
| 1112 | { |
| 1113 | if(eCsrLostLink1 == reason) |
| 1114 | { |
| 1115 | //we want to put the last connected BSS to the very beginning, if possible |
| 1116 | csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList); |
| 1117 | } |
| 1118 | status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, reason, |
| 1119 | roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE); |
| 1120 | if(!HAL_STATUS_SUCCESS(status)) |
| 1121 | { |
| 1122 | csrScanResultPurge(pMac, hBSSList); |
| 1123 | } |
| 1124 | }//Have scan result |
| 1125 | } |
| 1126 | }while(0); |
| 1127 | if(pScanFilter) |
| 1128 | { |
| 1129 | //we need to free memory for filter if profile exists |
| 1130 | csrFreeScanFilter(pMac, pScanFilter); |
| 1131 | palFreeMemory(pMac->hHdd, pScanFilter); |
| 1132 | } |
| 1133 | if(NULL != pProfile) |
| 1134 | { |
| 1135 | csrReleaseProfile(pMac, pProfile); |
| 1136 | palFreeMemory(pMac->hHdd, (void *)pProfile); |
| 1137 | } |
| 1138 | |
| 1139 | return (status); |
| 1140 | } |
| 1141 | |
| 1142 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1143 | eHalStatus csrScanGetScanChnInfo(tpAniSirGlobal pMac, void *callback, void *pContext) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1144 | { |
| 1145 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1146 | tSmeCmd *pScanCmd; |
| 1147 | |
| 1148 | if(pMac->scan.fScanEnable) |
| 1149 | { |
| 1150 | pScanCmd = csrGetCommandBuffer(pMac); |
| 1151 | if(pScanCmd) |
| 1152 | { |
| 1153 | pScanCmd->command = eSmeCommandScan; |
| 1154 | palZeroMemory(pMac->hHdd, &pScanCmd->u.scanCmd, sizeof(tScanCmd)); |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1155 | pScanCmd->u.scanCmd.callback = callback; |
| 1156 | pScanCmd->u.scanCmd.pContext = pContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1157 | pScanCmd->u.scanCmd.reason = eCsrScanGetScanChnInfo; |
| 1158 | //Need to make the following atomic |
| 1159 | pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around |
| 1160 | status = csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_FALSE); |
| 1161 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 1162 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1163 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1164 | csrReleaseCommandScan(pMac, pScanCmd); |
| 1165 | } |
| 1166 | } |
| 1167 | else |
| 1168 | { |
| 1169 | //log error |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1170 | smsLog(pMac, LOGE, FL("can not obtain a common buffer")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1171 | status = eHAL_STATUS_RESOURCES; |
| 1172 | } |
| 1173 | } |
| 1174 | |
| 1175 | return (status); |
| 1176 | } |
| 1177 | |
| 1178 | |
| 1179 | eHalStatus csrScanHandleFailedLostlink1(tpAniSirGlobal pMac, tANI_U32 sessionId) |
| 1180 | { |
| 1181 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 1182 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 1183 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1184 | if(!pSession) |
| 1185 | { |
| 1186 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 1187 | return eHAL_STATUS_FAILURE; |
| 1188 | } |
| 1189 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1190 | smsLog(pMac, LOGW, " Lostlink scan 1 failed"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1191 | if(pSession->fCancelRoaming) |
| 1192 | { |
| 1193 | csrScanStartIdleScan(pMac); |
| 1194 | } |
| 1195 | else if(pSession->pCurRoamProfile) |
| 1196 | { |
| 1197 | //We fail lostlink1 but there may be other BSS in the cached result fit the profile. Give it a try first |
| 1198 | if(pSession->pCurRoamProfile->SSIDs.numOfSSIDs == 0 || |
| 1199 | pSession->pCurRoamProfile->SSIDs.numOfSSIDs > 1) |
| 1200 | { |
| 1201 | //try lostlink scan2 |
| 1202 | status = csrScanRequestLostLink2(pMac, sessionId); |
| 1203 | } |
| 1204 | else if(!pSession->pCurRoamProfile->ChannelInfo.ChannelList || |
| 1205 | pSession->pCurRoamProfile->ChannelInfo.ChannelList[0] == 0) |
| 1206 | { |
| 1207 | //go straight to lostlink scan3 |
| 1208 | status = csrScanRequestLostLink3(pMac, sessionId); |
| 1209 | } |
| 1210 | else |
| 1211 | { |
| 1212 | //we are done with lostlink |
| 1213 | if(csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_FALSE, eCSR_ROAM_RESULT_FAILURE)) |
| 1214 | { |
| 1215 | csrScanStartIdleScan(pMac); |
| 1216 | } |
| 1217 | status = eHAL_STATUS_SUCCESS; |
| 1218 | } |
| 1219 | } |
| 1220 | else |
| 1221 | { |
| 1222 | status = csrScanRequestLostLink3(pMac, sessionId); |
| 1223 | } |
| 1224 | |
| 1225 | return (status); |
| 1226 | } |
| 1227 | |
| 1228 | |
| 1229 | |
| 1230 | eHalStatus csrScanHandleFailedLostlink2(tpAniSirGlobal pMac, tANI_U32 sessionId) |
| 1231 | { |
| 1232 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 1233 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 1234 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1235 | if(!pSession) |
| 1236 | { |
| 1237 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 1238 | return eHAL_STATUS_FAILURE; |
| 1239 | } |
| 1240 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1241 | smsLog(pMac, LOGW, " Lostlink scan 2 failed"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1242 | if(pSession->fCancelRoaming) |
| 1243 | { |
| 1244 | csrScanStartIdleScan(pMac); |
| 1245 | } |
| 1246 | else if(!pSession->pCurRoamProfile || !pSession->pCurRoamProfile->ChannelInfo.ChannelList || |
| 1247 | pSession->pCurRoamProfile->ChannelInfo.ChannelList[0] == 0) |
| 1248 | { |
| 1249 | //try lostlink scan3 |
| 1250 | status = csrScanRequestLostLink3(pMac, sessionId); |
| 1251 | } |
| 1252 | else |
| 1253 | { |
| 1254 | //we are done with lostlink |
| 1255 | if(csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_FALSE, eCSR_ROAM_RESULT_FAILURE)) |
| 1256 | { |
| 1257 | csrScanStartIdleScan(pMac); |
| 1258 | } |
| 1259 | } |
| 1260 | |
| 1261 | return (status); |
| 1262 | } |
| 1263 | |
| 1264 | |
| 1265 | |
| 1266 | eHalStatus csrScanHandleFailedLostlink3(tpAniSirGlobal pMac, tANI_U32 sessionId) |
| 1267 | { |
| 1268 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1269 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1270 | smsLog(pMac, LOGW, " Lostlink scan 3 failed"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1271 | if(eANI_BOOLEAN_TRUE == csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_FALSE, eCSR_ROAM_RESULT_FAILURE)) |
| 1272 | { |
| 1273 | //we are done with lostlink |
| 1274 | csrScanStartIdleScan(pMac); |
| 1275 | } |
| 1276 | |
| 1277 | return (status); |
| 1278 | } |
| 1279 | |
| 1280 | |
| 1281 | |
| 1282 | |
| 1283 | //Lostlink1 scan is to actively scan the last connected profile's SSID on all matched BSS channels. |
| 1284 | //If no roam profile (it should not), it is like lostlinkscan3 |
| 1285 | eHalStatus csrScanRequestLostLink1( tpAniSirGlobal pMac, tANI_U32 sessionId ) |
| 1286 | { |
| 1287 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1288 | tSmeCmd *pCommand = NULL; |
| 1289 | tANI_U8 bAddr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; |
| 1290 | tCsrScanResultFilter *pScanFilter = NULL; |
| 1291 | tScanResultHandle hBSSList = NULL; |
| 1292 | tCsrScanResultInfo *pScanResult = NULL; |
| 1293 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 1294 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1295 | if(!pSession) |
| 1296 | { |
| 1297 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 1298 | return eHAL_STATUS_FAILURE; |
| 1299 | } |
| 1300 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1301 | smsLog(pMac, LOGW, FL(" called")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1302 | do |
| 1303 | { |
| 1304 | pCommand = csrGetCommandBuffer(pMac); |
| 1305 | if(!pCommand) |
| 1306 | { |
| 1307 | status = eHAL_STATUS_RESOURCES; |
| 1308 | break; |
| 1309 | } |
| 1310 | palZeroMemory(pMac->hHdd, &pCommand->u.scanCmd, sizeof(tScanCmd)); |
| 1311 | pCommand->command = eSmeCommandScan; |
| 1312 | pCommand->sessionId = (tANI_U8)sessionId; |
| 1313 | pCommand->u.scanCmd.reason = eCsrScanLostLink1; |
| 1314 | pCommand->u.scanCmd.callback = NULL; |
| 1315 | pCommand->u.scanCmd.pContext = NULL; |
| 1316 | pCommand->u.scanCmd.u.scanRequest.maxChnTime = pMac->roam.configParam.nActiveMaxChnTime; |
| 1317 | pCommand->u.scanCmd.u.scanRequest.minChnTime = pMac->roam.configParam.nActiveMinChnTime; |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 1318 | pCommand->u.scanCmd.u.scanRequest.maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc; |
| 1319 | pCommand->u.scanCmd.u.scanRequest.minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1320 | pCommand->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 1321 | if(pSession->connectedProfile.SSID.length) |
| 1322 | { |
| 1323 | status = palAllocateMemory(pMac->hHdd, (void **)&pCommand->u.scanCmd.u.scanRequest.SSIDs.SSIDList, sizeof(tCsrSSIDInfo)); |
| 1324 | if(!HAL_STATUS_SUCCESS(status)) |
| 1325 | { |
| 1326 | break; |
| 1327 | } |
| 1328 | pCommand->u.scanCmd.u.scanRequest.SSIDs.numOfSSIDs = 1; |
| 1329 | palCopyMemory(pMac->hHdd, &pCommand->u.scanCmd.u.scanRequest.SSIDs.SSIDList[0].SSID, |
| 1330 | &pSession->connectedProfile.SSID, sizeof(tSirMacSSid)); |
| 1331 | } |
| 1332 | else |
| 1333 | { |
| 1334 | pCommand->u.scanCmd.u.scanRequest.SSIDs.numOfSSIDs = 0; |
| 1335 | } |
| 1336 | if(pSession->pCurRoamProfile) |
| 1337 | { |
| 1338 | status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter)); |
| 1339 | if(!HAL_STATUS_SUCCESS(status)) |
| 1340 | { |
| 1341 | break; |
| 1342 | } |
| 1343 | palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter)); |
| 1344 | status = csrRoamPrepareFilterFromProfile(pMac, pSession->pCurRoamProfile, pScanFilter); |
| 1345 | if(!HAL_STATUS_SUCCESS(status)) |
| 1346 | { |
| 1347 | break; |
| 1348 | } |
| 1349 | //Don't change variable status here because whether we can get result or not, the command goes to PE. |
| 1350 | //The status is also used to indicate whether the command is queued. Not success meaning not queue |
| 1351 | if(HAL_STATUS_SUCCESS((csrScanGetResult(pMac, pScanFilter, &hBSSList))) && hBSSList) |
| 1352 | { |
| 1353 | tANI_U8 i, nChn = 0; |
| 1354 | status = palAllocateMemory(pMac->hHdd, (void **)&pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList, |
| 1355 | WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 1356 | if(!HAL_STATUS_SUCCESS(status)) |
| 1357 | { |
| 1358 | break; |
| 1359 | } |
| 1360 | while(((pScanResult = csrScanResultGetNext(pMac, hBSSList)) != NULL) && |
| 1361 | nChn < WNI_CFG_VALID_CHANNEL_LIST_LEN) |
| 1362 | { |
| 1363 | for(i = 0; i < nChn; i++) |
| 1364 | { |
| 1365 | if(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[i] == |
| 1366 | pScanResult->BssDescriptor.channelId) |
| 1367 | { |
| 1368 | break; |
| 1369 | } |
| 1370 | } |
| 1371 | if(i == nChn) |
| 1372 | { |
| 1373 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[nChn++] = pScanResult->BssDescriptor.channelId; |
| 1374 | } |
| 1375 | } |
| 1376 | //Include the last connected BSS' channel |
| 1377 | if(csrRoamIsChannelValid(pMac, pSession->connectedProfile.operationChannel)) |
| 1378 | { |
| 1379 | for(i = 0; i < nChn; i++) |
| 1380 | { |
| 1381 | if(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[i] == |
| 1382 | pSession->connectedProfile.operationChannel) |
| 1383 | { |
| 1384 | break; |
| 1385 | } |
| 1386 | } |
| 1387 | if(i == nChn) |
| 1388 | { |
| 1389 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[nChn++] = pSession->connectedProfile.operationChannel; |
| 1390 | } |
| 1391 | } |
| 1392 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = nChn; |
| 1393 | } |
| 1394 | else |
| 1395 | { |
| 1396 | if(csrRoamIsChannelValid(pMac, pSession->connectedProfile.operationChannel)) |
| 1397 | { |
| 1398 | status = palAllocateMemory(pMac->hHdd, (void **)&pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList, |
| 1399 | 1); |
| 1400 | //just try the last connected channel |
| 1401 | if(HAL_STATUS_SUCCESS(status)) |
| 1402 | { |
| 1403 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[0] = pSession->connectedProfile.operationChannel; |
| 1404 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = 1; |
| 1405 | } |
| 1406 | else |
| 1407 | { |
| 1408 | break; |
| 1409 | } |
| 1410 | } |
| 1411 | } |
| 1412 | } |
| 1413 | palCopyMemory(pMac->hHdd, &pCommand->u.scanCmd.u.scanRequest.bssid, bAddr, sizeof(tCsrBssid)); |
| 1414 | status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE); |
| 1415 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 1416 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1417 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1418 | break; |
| 1419 | } |
| 1420 | } while( 0 ); |
| 1421 | |
| 1422 | if(!HAL_STATUS_SUCCESS(status)) |
| 1423 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1424 | smsLog(pMac, LOGW, " csrScanRequestLostLink1 failed with status %d", status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1425 | if(pCommand) |
| 1426 | { |
| 1427 | csrReleaseCommandScan(pMac, pCommand); |
| 1428 | } |
| 1429 | status = csrScanHandleFailedLostlink1( pMac, sessionId ); |
| 1430 | } |
| 1431 | if(pScanFilter) |
| 1432 | { |
| 1433 | csrFreeScanFilter(pMac, pScanFilter); |
| 1434 | palFreeMemory(pMac->hHdd, pScanFilter); |
| 1435 | } |
| 1436 | if(hBSSList) |
| 1437 | { |
| 1438 | csrScanResultPurge(pMac, hBSSList); |
| 1439 | } |
| 1440 | |
| 1441 | return( status ); |
| 1442 | } |
| 1443 | |
| 1444 | |
| 1445 | //Lostlink2 scan is to actively scan the all SSIDs of the last roaming profile's on all matched BSS channels. |
| 1446 | //Since MAC doesn't support multiple SSID, we scan all SSIDs and filter them afterwards |
| 1447 | eHalStatus csrScanRequestLostLink2( tpAniSirGlobal pMac, tANI_U32 sessionId ) |
| 1448 | { |
| 1449 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1450 | tANI_U8 bAddr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; |
| 1451 | tCsrScanResultFilter *pScanFilter = NULL; |
| 1452 | tScanResultHandle hBSSList = NULL; |
| 1453 | tCsrScanResultInfo *pScanResult = NULL; |
| 1454 | tSmeCmd *pCommand = NULL; |
| 1455 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 1456 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1457 | if(!pSession) |
| 1458 | { |
| 1459 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 1460 | return eHAL_STATUS_FAILURE; |
| 1461 | } |
| 1462 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1463 | smsLog(pMac, LOGW, FL(" called")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1464 | do |
| 1465 | { |
| 1466 | pCommand = csrGetCommandBuffer(pMac); |
| 1467 | if(!pCommand) |
| 1468 | { |
| 1469 | status = eHAL_STATUS_RESOURCES; |
| 1470 | break; |
| 1471 | } |
| 1472 | palZeroMemory(pMac->hHdd, &pCommand->u.scanCmd, sizeof(tScanCmd)); |
| 1473 | pCommand->command = eSmeCommandScan; |
| 1474 | pCommand->sessionId = (tANI_U8)sessionId; |
| 1475 | pCommand->u.scanCmd.reason = eCsrScanLostLink2; |
| 1476 | pCommand->u.scanCmd.callback = NULL; |
| 1477 | pCommand->u.scanCmd.pContext = NULL; |
| 1478 | pCommand->u.scanCmd.u.scanRequest.maxChnTime = pMac->roam.configParam.nActiveMaxChnTime; |
| 1479 | pCommand->u.scanCmd.u.scanRequest.minChnTime = pMac->roam.configParam.nActiveMinChnTime; |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 1480 | pCommand->u.scanCmd.u.scanRequest.maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc; |
| 1481 | pCommand->u.scanCmd.u.scanRequest.minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1482 | pCommand->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 1483 | if(pSession->pCurRoamProfile) |
| 1484 | { |
| 1485 | status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter)); |
| 1486 | if(!HAL_STATUS_SUCCESS(status)) |
| 1487 | { |
| 1488 | break; |
| 1489 | } |
| 1490 | palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter)); |
| 1491 | status = csrRoamPrepareFilterFromProfile(pMac, pSession->pCurRoamProfile, pScanFilter); |
| 1492 | if(!HAL_STATUS_SUCCESS(status)) |
| 1493 | { |
| 1494 | break; |
| 1495 | } |
| 1496 | status = csrScanGetResult(pMac, pScanFilter, &hBSSList); |
| 1497 | if(!HAL_STATUS_SUCCESS(status)) |
| 1498 | { |
| 1499 | break; |
| 1500 | } |
| 1501 | if(hBSSList) |
| 1502 | { |
| 1503 | tANI_U8 i, nChn = 0; |
| 1504 | status = palAllocateMemory(pMac->hHdd, (void **)&pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList, |
| 1505 | WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 1506 | if(!HAL_STATUS_SUCCESS(status)) |
| 1507 | { |
| 1508 | break; |
| 1509 | } |
| 1510 | while(((pScanResult = csrScanResultGetNext(pMac, hBSSList)) != NULL) && |
| 1511 | nChn < WNI_CFG_VALID_CHANNEL_LIST_LEN) |
| 1512 | { |
| 1513 | for(i = 0; i < nChn; i++) |
| 1514 | { |
| 1515 | if(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[i] == |
| 1516 | pScanResult->BssDescriptor.channelId) |
| 1517 | { |
| 1518 | break; |
| 1519 | } |
| 1520 | } |
| 1521 | if(i == nChn) |
| 1522 | { |
| 1523 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[nChn++] = pScanResult->BssDescriptor.channelId; |
| 1524 | } |
| 1525 | } |
| 1526 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = nChn; |
| 1527 | } |
| 1528 | } |
| 1529 | palCopyMemory(pMac->hHdd, &pCommand->u.scanCmd.u.scanRequest.bssid, bAddr, sizeof(tCsrBssid)); |
| 1530 | //Put to the head in pending queue |
| 1531 | status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE); |
| 1532 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 1533 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1534 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1535 | break; |
| 1536 | } |
| 1537 | } while( 0 ); |
| 1538 | |
| 1539 | if(!HAL_STATUS_SUCCESS(status)) |
| 1540 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1541 | smsLog(pMac, LOGW, " csrScanRequestLostLink2 failed with status %d", status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1542 | if(pCommand) |
| 1543 | { |
| 1544 | csrReleaseCommandScan(pMac, pCommand); |
| 1545 | } |
| 1546 | status = csrScanHandleFailedLostlink2( pMac, sessionId ); |
| 1547 | } |
| 1548 | if(pScanFilter) |
| 1549 | { |
| 1550 | csrFreeScanFilter(pMac, pScanFilter); |
| 1551 | palFreeMemory(pMac->hHdd, pScanFilter); |
| 1552 | } |
| 1553 | if(hBSSList) |
| 1554 | { |
| 1555 | csrScanResultPurge(pMac, hBSSList); |
| 1556 | } |
| 1557 | |
| 1558 | return( status ); |
| 1559 | } |
| 1560 | |
| 1561 | |
| 1562 | //To actively scan all valid channels |
| 1563 | eHalStatus csrScanRequestLostLink3( tpAniSirGlobal pMac, tANI_U32 sessionId ) |
| 1564 | { |
| 1565 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1566 | tSmeCmd *pCommand; |
| 1567 | tANI_U8 bAddr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; |
| 1568 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1569 | smsLog(pMac, LOGW, FL(" called")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1570 | do |
| 1571 | { |
| 1572 | pCommand = csrGetCommandBuffer(pMac); |
| 1573 | if(!pCommand) |
| 1574 | { |
| 1575 | status = eHAL_STATUS_RESOURCES; |
| 1576 | break; |
| 1577 | } |
| 1578 | palZeroMemory(pMac->hHdd, &pCommand->u.scanCmd, sizeof(tScanCmd)); |
| 1579 | pCommand->command = eSmeCommandScan; |
| 1580 | pCommand->sessionId = (tANI_U8)sessionId; |
| 1581 | pCommand->u.scanCmd.reason = eCsrScanLostLink3; |
| 1582 | pCommand->u.scanCmd.callback = NULL; |
| 1583 | pCommand->u.scanCmd.pContext = NULL; |
| 1584 | pCommand->u.scanCmd.u.scanRequest.maxChnTime = pMac->roam.configParam.nActiveMaxChnTime; |
| 1585 | pCommand->u.scanCmd.u.scanRequest.minChnTime = pMac->roam.configParam.nActiveMinChnTime; |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 1586 | pCommand->u.scanCmd.u.scanRequest.maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc; |
| 1587 | pCommand->u.scanCmd.u.scanRequest.minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1588 | pCommand->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 1589 | palCopyMemory(pMac->hHdd, &pCommand->u.scanCmd.u.scanRequest.bssid, bAddr, sizeof(tCsrBssid)); |
| 1590 | //Put to the head of pending queue |
| 1591 | status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE); |
| 1592 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 1593 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1594 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1595 | break; |
| 1596 | } |
| 1597 | } while( 0 ); |
| 1598 | if(!HAL_STATUS_SUCCESS(status)) |
| 1599 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1600 | smsLog(pMac, LOGW, " csrScanRequestLostLink3 failed with status %d", status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1601 | if(csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_FALSE, eCSR_ROAM_RESULT_FAILURE)) |
| 1602 | { |
| 1603 | csrScanStartIdleScan(pMac); |
| 1604 | } |
| 1605 | if(pCommand) |
| 1606 | { |
| 1607 | csrReleaseCommandScan(pMac, pCommand); |
| 1608 | } |
| 1609 | } |
| 1610 | |
| 1611 | return( status ); |
| 1612 | } |
| 1613 | |
| 1614 | |
| 1615 | eHalStatus csrScanHandleSearchForSSID(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
| 1616 | { |
| 1617 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 1618 | tScanResultHandle hBSSList = CSR_INVALID_SCANRESULT_HANDLE; |
| 1619 | tCsrScanResultFilter *pScanFilter = NULL; |
| 1620 | tCsrRoamProfile *pProfile = pCommand->u.scanCmd.pToRoamProfile; |
| 1621 | tANI_U32 sessionId = pCommand->sessionId; |
| 1622 | #ifdef FEATURE_WLAN_BTAMP_UT_RF |
| 1623 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 1624 | #endif |
| 1625 | do |
| 1626 | { |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 1627 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 1628 | //if this scan is for LFR |
| 1629 | if(pMac->roam.neighborRoamInfo.uOsRequestedHandoff) |
| 1630 | { |
| 1631 | //notify LFR state m/c |
| 1632 | if(eHAL_STATUS_SUCCESS != csrNeighborRoamSssidScanDone(pMac, eHAL_STATUS_SUCCESS)) |
| 1633 | { |
Varun Reddy Yeturu | e3af428 | 2013-06-07 00:56:52 -0700 | [diff] [blame] | 1634 | csrNeighborRoamStartLfrScan(pMac); |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 1635 | } |
| 1636 | status = eHAL_STATUS_SUCCESS; |
| 1637 | break; |
| 1638 | } |
| 1639 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1640 | //If there is roam command waiting, ignore this roam because the newer roam command is the one to execute |
| 1641 | if(csrIsRoamCommandWaitingForSession(pMac, sessionId)) |
| 1642 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1643 | smsLog(pMac, LOGW, FL(" aborts because roam command waiting")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1644 | break; |
| 1645 | } |
| 1646 | if(pProfile == NULL) |
| 1647 | break; |
| 1648 | status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter)); |
| 1649 | if(!HAL_STATUS_SUCCESS(status)) |
| 1650 | break; |
| 1651 | palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter)); |
| 1652 | status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter); |
| 1653 | if(!HAL_STATUS_SUCCESS(status)) |
| 1654 | break; |
| 1655 | status = csrScanGetResult(pMac, pScanFilter, &hBSSList); |
| 1656 | if(!HAL_STATUS_SUCCESS(status)) |
| 1657 | break; |
| 1658 | status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued, |
| 1659 | pCommand->u.scanCmd.roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE); |
| 1660 | if(!HAL_STATUS_SUCCESS(status)) |
| 1661 | { |
| 1662 | break; |
| 1663 | } |
| 1664 | }while(0); |
| 1665 | if(!HAL_STATUS_SUCCESS(status)) |
| 1666 | { |
| 1667 | if(CSR_INVALID_SCANRESULT_HANDLE != hBSSList) |
| 1668 | { |
| 1669 | csrScanResultPurge(pMac, hBSSList); |
| 1670 | } |
| 1671 | //We haven't done anything to this profile |
| 1672 | csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.scanCmd.roamId, |
| 1673 | eCSR_ROAM_ASSOCIATION_FAILURE, eCSR_ROAM_RESULT_FAILURE); |
| 1674 | //In case we have nothing else to do, restart idle scan |
| 1675 | if(csrIsConnStateDisconnected(pMac, sessionId) && !csrIsRoamCommandWaiting(pMac)) |
| 1676 | { |
| 1677 | status = csrScanStartIdleScan(pMac); |
| 1678 | } |
| 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 | if(pScanFilter) |
| 1697 | { |
| 1698 | csrFreeScanFilter(pMac, pScanFilter); |
| 1699 | palFreeMemory(pMac->hHdd, pScanFilter); |
| 1700 | } |
| 1701 | |
| 1702 | return (status); |
| 1703 | } |
| 1704 | |
| 1705 | |
| 1706 | eHalStatus csrScanHandleSearchForSSIDFailure(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
| 1707 | { |
| 1708 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1709 | tANI_U32 sessionId = pCommand->sessionId; |
| 1710 | tCsrRoamProfile *pProfile = pCommand->u.scanCmd.pToRoamProfile; |
| 1711 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 1712 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 1713 | //if this scan is for LFR |
| 1714 | if(pMac->roam.neighborRoamInfo.uOsRequestedHandoff) |
| 1715 | { |
| 1716 | //notify LFR state m/c |
| 1717 | if(eHAL_STATUS_SUCCESS != csrNeighborRoamSssidScanDone(pMac, eHAL_STATUS_FAILURE)) |
| 1718 | { |
Varun Reddy Yeturu | e3af428 | 2013-06-07 00:56:52 -0700 | [diff] [blame] | 1719 | csrNeighborRoamStartLfrScan(pMac); |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 1720 | } |
| 1721 | return eHAL_STATUS_SUCCESS; |
| 1722 | } |
| 1723 | #endif |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1724 | if(!pSession) |
| 1725 | { |
| 1726 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 1727 | return eHAL_STATUS_FAILURE; |
| 1728 | } |
| 1729 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1730 | #if defined(WLAN_DEBUG) |
| 1731 | if(pCommand->u.scanCmd.u.scanRequest.SSIDs.numOfSSIDs == 1) |
| 1732 | { |
| 1733 | char str[36]; |
| 1734 | palCopyMemory(pMac->hHdd, str, pCommand->u.scanCmd.u.scanRequest.SSIDs.SSIDList[0].SSID.ssId, |
| 1735 | pCommand->u.scanCmd.u.scanRequest.SSIDs.SSIDList[0].SSID.length); |
| 1736 | 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] | 1737 | smsLog(pMac, LOGW, FL(" SSID = %s"), str); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1738 | } |
| 1739 | #endif |
| 1740 | //Check whether it is for start ibss. No need to do anything if it is a JOIN request |
| 1741 | if(pProfile && CSR_IS_START_IBSS(pProfile)) |
| 1742 | { |
| 1743 | status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued, |
| 1744 | pCommand->u.scanCmd.roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE); |
| 1745 | if(!HAL_STATUS_SUCCESS(status)) |
| 1746 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1747 | 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] | 1748 | csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.scanCmd.roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE); |
| 1749 | } |
| 1750 | } |
| 1751 | else |
| 1752 | { |
| 1753 | eCsrRoamResult roamResult = eCSR_ROAM_RESULT_FAILURE; |
| 1754 | |
| 1755 | if(csrIsConnStateDisconnected(pMac, sessionId) && |
| 1756 | !csrIsRoamCommandWaitingForSession(pMac, sessionId)) |
| 1757 | { |
| 1758 | status = csrScanStartIdleScan(pMac); |
| 1759 | } |
| 1760 | if((NULL == pProfile) || !csrIsBssTypeIBSS(pProfile->BSSType)) |
| 1761 | { |
| 1762 | //Only indicate assoc_completion if we indicate assoc_start. |
| 1763 | if(pSession->bRefAssocStartCnt > 0) |
| 1764 | { |
| 1765 | tCsrRoamInfo *pRoamInfo = NULL, roamInfo; |
| 1766 | palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo)); |
| 1767 | pRoamInfo = &roamInfo; |
| 1768 | if(pCommand->u.roamCmd.pRoamBssEntry) |
| 1769 | { |
| 1770 | tCsrScanResult *pScanResult = |
| 1771 | GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, |
| 1772 | tCsrScanResult, Link); |
| 1773 | roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor; |
| 1774 | } |
| 1775 | roamInfo.statusCode = pSession->joinFailStatusCode.statusCode; |
| 1776 | roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode; |
| 1777 | pSession->bRefAssocStartCnt--; |
| 1778 | csrRoamCallCallback(pMac, sessionId, pRoamInfo, |
| 1779 | pCommand->u.scanCmd.roamId, |
| 1780 | eCSR_ROAM_ASSOCIATION_COMPLETION, |
| 1781 | eCSR_ROAM_RESULT_FAILURE); |
| 1782 | } |
Madan Mohan Koyyalamudi | ee255f1 | 2012-09-28 15:41:19 -0700 | [diff] [blame] | 1783 | else |
| 1784 | { |
| 1785 | csrRoamCallCallback(pMac, sessionId, NULL, |
| 1786 | pCommand->u.scanCmd.roamId, |
| 1787 | eCSR_ROAM_ASSOCIATION_FAILURE, |
| 1788 | eCSR_ROAM_RESULT_FAILURE); |
| 1789 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1790 | #ifdef FEATURE_WLAN_BTAMP_UT_RF |
| 1791 | //In case of WDS station, let it retry. |
| 1792 | if( CSR_IS_WDS_STA(pProfile) ) |
| 1793 | { |
| 1794 | //Save the roma profile so we can retry |
| 1795 | csrFreeRoamProfile( pMac, sessionId ); |
| 1796 | if (HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, |
| 1797 | (void **)&pSession->pCurRoamProfile, |
| 1798 | sizeof(tCsrRoamProfile)))) |
| 1799 | { |
| 1800 | palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile)); |
| 1801 | csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile); |
| 1802 | } |
| 1803 | csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD); |
| 1804 | } |
| 1805 | #endif |
| 1806 | } |
| 1807 | else |
| 1808 | { |
| 1809 | roamResult = eCSR_ROAM_RESULT_IBSS_START_FAILED; |
| 1810 | } |
| 1811 | csrRoamCompletion(pMac, sessionId, NULL, pCommand, roamResult, eANI_BOOLEAN_FALSE); |
| 1812 | } |
| 1813 | |
| 1814 | return (status); |
| 1815 | } |
| 1816 | |
| 1817 | |
| 1818 | //After scan for cap changes, issue a roaming command to either reconnect to the AP or pick another one to connect |
| 1819 | eHalStatus csrScanHandleCapChangeScanComplete(tpAniSirGlobal pMac, tANI_U32 sessionId) |
| 1820 | { |
| 1821 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 1822 | tScanResultHandle hBSSList = NULL; |
| 1823 | tCsrScanResultFilter *pScanFilter = NULL; |
| 1824 | tANI_U32 roamId = 0; |
| 1825 | tCsrRoamProfile *pProfile = NULL; |
| 1826 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 1827 | |
| 1828 | do |
| 1829 | { |
| 1830 | //Here is the profile we need to connect to |
| 1831 | status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter)); |
| 1832 | if(!HAL_STATUS_SUCCESS(status)) |
| 1833 | break; |
| 1834 | palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter)); |
| 1835 | if(NULL == pSession) break; |
| 1836 | if(NULL == pSession->pCurRoamProfile) |
| 1837 | { |
| 1838 | pScanFilter->EncryptionType.numEntries = 1; |
| 1839 | pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE; |
| 1840 | } |
| 1841 | else |
| 1842 | { |
| 1843 | //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect |
| 1844 | status = palAllocateMemory(pMac->hHdd, (void **)&pProfile, sizeof(tCsrRoamProfile)); |
| 1845 | if(!HAL_STATUS_SUCCESS(status)) |
| 1846 | break; |
| 1847 | status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile); |
| 1848 | if(!HAL_STATUS_SUCCESS(status)) |
| 1849 | break; |
| 1850 | status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter); |
| 1851 | }//We have a profile |
| 1852 | roamId = GET_NEXT_ROAM_ID(&pMac->roam); |
| 1853 | if(HAL_STATUS_SUCCESS(status)) |
| 1854 | { |
| 1855 | status = csrScanGetResult(pMac, pScanFilter, &hBSSList); |
| 1856 | if(HAL_STATUS_SUCCESS(status)) |
| 1857 | { |
| 1858 | //we want to put the last connected BSS to the very beginning, if possible |
| 1859 | csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList); |
| 1860 | status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, |
| 1861 | eCsrCapsChange, 0, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE); |
| 1862 | if(!HAL_STATUS_SUCCESS(status)) |
| 1863 | { |
| 1864 | csrScanResultPurge(pMac, hBSSList); |
| 1865 | } |
| 1866 | }//Have scan result |
| 1867 | else |
| 1868 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1869 | 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] | 1870 | pSession->connectedProfile.bssid[0], |
| 1871 | pSession->connectedProfile.bssid[1], |
| 1872 | pSession->connectedProfile.bssid[2], |
| 1873 | pSession->connectedProfile.bssid[3], |
| 1874 | pSession->connectedProfile.bssid[4], |
| 1875 | pSession->connectedProfile.bssid[5]); |
| 1876 | //Disconnect |
| 1877 | csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED); |
| 1878 | } |
| 1879 | } |
| 1880 | }while(0); |
| 1881 | if(pScanFilter) |
| 1882 | { |
| 1883 | csrFreeScanFilter(pMac, pScanFilter); |
| 1884 | palFreeMemory(pMac->hHdd, pScanFilter); |
| 1885 | } |
| 1886 | if(NULL != pProfile) |
| 1887 | { |
| 1888 | csrReleaseProfile(pMac, pProfile); |
| 1889 | palFreeMemory(pMac->hHdd, pProfile); |
| 1890 | } |
| 1891 | |
| 1892 | return (status); |
| 1893 | } |
| 1894 | |
| 1895 | |
| 1896 | |
| 1897 | eHalStatus csrScanResultPurge(tpAniSirGlobal pMac, tScanResultHandle hScanList) |
| 1898 | { |
| 1899 | eHalStatus status = eHAL_STATUS_INVALID_PARAMETER; |
| 1900 | tScanResultList *pScanList = (tScanResultList *)hScanList; |
| 1901 | |
| 1902 | if(pScanList) |
| 1903 | { |
| 1904 | status = csrLLScanPurgeResult(pMac, &pScanList->List); |
| 1905 | csrLLClose(&pScanList->List); |
| 1906 | palFreeMemory(pMac->hHdd, pScanList); |
| 1907 | } |
| 1908 | return (status); |
| 1909 | } |
| 1910 | |
| 1911 | |
| 1912 | static tANI_U32 csrGetBssPreferValue(tpAniSirGlobal pMac, int rssi) |
| 1913 | { |
| 1914 | tANI_U32 ret = 0; |
| 1915 | int i = CSR_NUM_RSSI_CAT - 1; |
| 1916 | |
| 1917 | while(i >= 0) |
| 1918 | { |
| 1919 | if(rssi >= pMac->roam.configParam.RSSICat[i]) |
| 1920 | { |
| 1921 | ret = pMac->roam.configParam.BssPreferValue[i]; |
| 1922 | break; |
| 1923 | } |
| 1924 | i--; |
| 1925 | }; |
| 1926 | |
| 1927 | return (ret); |
| 1928 | } |
| 1929 | |
| 1930 | |
| 1931 | //Return a CapValue base on the capabilities of a BSS |
| 1932 | static tANI_U32 csrGetBssCapValue(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes) |
| 1933 | { |
| 1934 | tANI_U32 ret = CSR_BSS_CAP_VALUE_NONE; |
Madan Mohan Koyyalamudi | d502607 | 2012-11-30 14:56:21 -0800 | [diff] [blame] | 1935 | #if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR) |
| 1936 | if(CSR_IS_ROAM_PREFER_5GHZ(pMac)) |
| 1937 | { |
| 1938 | if((pBssDesc) && CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId)) |
| 1939 | { |
| 1940 | ret += CSR_BSS_CAP_VALUE_5GHZ; |
| 1941 | } |
| 1942 | } |
| 1943 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1944 | if( pIes ) |
| 1945 | { |
| 1946 | //We only care about 11N capability |
| 1947 | if(pIes->HTCaps.present) |
| 1948 | { |
| 1949 | ret += CSR_BSS_CAP_VALUE_HT; |
| 1950 | } |
| 1951 | if(CSR_IS_QOS_BSS(pIes)) |
| 1952 | { |
| 1953 | ret += CSR_BSS_CAP_VALUE_WMM; |
| 1954 | //Give advantage to UAPSD |
| 1955 | if(CSR_IS_UAPSD_BSS(pIes)) |
| 1956 | { |
| 1957 | ret += CSR_BSS_CAP_VALUE_UAPSD; |
| 1958 | } |
| 1959 | } |
| 1960 | } |
| 1961 | |
| 1962 | return (ret); |
| 1963 | } |
| 1964 | |
| 1965 | |
| 1966 | //To check whther pBss1 is better than pBss2 |
| 1967 | static tANI_BOOLEAN csrIsBetterBss(tCsrScanResult *pBss1, tCsrScanResult *pBss2) |
| 1968 | { |
| 1969 | tANI_BOOLEAN ret; |
| 1970 | |
| 1971 | if(CSR_IS_BETTER_PREFER_VALUE(pBss1->preferValue, pBss2->preferValue)) |
| 1972 | { |
| 1973 | ret = eANI_BOOLEAN_TRUE; |
| 1974 | } |
| 1975 | else if(CSR_IS_EQUAL_PREFER_VALUE(pBss1->preferValue, pBss2->preferValue)) |
| 1976 | { |
| 1977 | if(CSR_IS_BETTER_CAP_VALUE(pBss1->capValue, pBss2->capValue)) |
| 1978 | { |
| 1979 | ret = eANI_BOOLEAN_TRUE; |
| 1980 | } |
| 1981 | else |
| 1982 | { |
| 1983 | ret = eANI_BOOLEAN_FALSE; |
| 1984 | } |
| 1985 | } |
| 1986 | else |
| 1987 | { |
| 1988 | ret = eANI_BOOLEAN_FALSE; |
| 1989 | } |
| 1990 | |
| 1991 | return (ret); |
| 1992 | } |
| 1993 | |
| 1994 | |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 1995 | #ifdef FEATURE_WLAN_LFR |
Madan Mohan Koyyalamudi | 470d2cf | 2012-09-28 14:43:44 -0700 | [diff] [blame] | 1996 | //Add the channel to the occupiedChannels array |
| 1997 | static void csrScanAddToOccupiedChannels( |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 1998 | tpAniSirGlobal pMac, |
| 1999 | tCsrScanResult *pResult, |
| 2000 | tCsrChannel *pOccupiedChannels, |
Madan Mohan Koyyalamudi | 470d2cf | 2012-09-28 14:43:44 -0700 | [diff] [blame] | 2001 | tDot11fBeaconIEs *pIes) |
| 2002 | { |
| 2003 | eHalStatus status; |
| 2004 | tANI_U8 channel; |
| 2005 | tANI_U8 numOccupiedChannels = pOccupiedChannels->numChannels; |
| 2006 | tANI_U8 *pOccupiedChannelList = pOccupiedChannels->channelList; |
| 2007 | |
| 2008 | channel = pResult->Result.BssDescriptor.channelId; |
| 2009 | |
| 2010 | if (!csrIsChannelPresentInList(pOccupiedChannelList, numOccupiedChannels, channel) |
Madan Mohan Koyyalamudi | dd3c966 | 2012-11-09 17:39:30 -0800 | [diff] [blame] | 2011 | && csrNeighborRoamConnectedProfileMatch(pMac, pResult, pIes)) |
Madan Mohan Koyyalamudi | 470d2cf | 2012-09-28 14:43:44 -0700 | [diff] [blame] | 2012 | { |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 2013 | status = csrAddToChannelListFront(pOccupiedChannelList, numOccupiedChannels, channel); |
Madan Mohan Koyyalamudi | 470d2cf | 2012-09-28 14:43:44 -0700 | [diff] [blame] | 2014 | if(HAL_STATUS_SUCCESS(status)) |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 2015 | { |
Madan Mohan Koyyalamudi | 470d2cf | 2012-09-28 14:43:44 -0700 | [diff] [blame] | 2016 | pOccupiedChannels->numChannels++; |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 2017 | 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] | 2018 | __func__, channel, pOccupiedChannels->numChannels); |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 2019 | if (pOccupiedChannels->numChannels > CSR_BG_SCAN_OCCUPIED_CHANNEL_LIST_LEN) |
| 2020 | pOccupiedChannels->numChannels = CSR_BG_SCAN_OCCUPIED_CHANNEL_LIST_LEN; |
| 2021 | } |
Madan Mohan Koyyalamudi | 470d2cf | 2012-09-28 14:43:44 -0700 | [diff] [blame] | 2022 | } |
| 2023 | } |
| 2024 | #endif |
| 2025 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2026 | //Put the BSS into the scan result list |
| 2027 | //pIes can not be NULL |
| 2028 | static void csrScanAddResult(tpAniSirGlobal pMac, tCsrScanResult *pResult, tDot11fBeaconIEs *pIes) |
| 2029 | { |
Srinivas | 28b5b4e | 2012-12-12 13:07:53 -0800 | [diff] [blame] | 2030 | #ifdef FEATURE_WLAN_LFR |
| 2031 | tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo; |
| 2032 | #endif |
| 2033 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2034 | pResult->preferValue = csrGetBssPreferValue(pMac, (int)pResult->Result.BssDescriptor.rssi); |
| 2035 | pResult->capValue = csrGetBssCapValue(pMac, &pResult->Result.BssDescriptor, pIes); |
| 2036 | csrLLInsertTail( &pMac->scan.scanResultList, &pResult->Link, LL_ACCESS_LOCK ); |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 2037 | #ifdef FEATURE_WLAN_LFR |
Srinivas | 28b5b4e | 2012-12-12 13:07:53 -0800 | [diff] [blame] | 2038 | if(0 == pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels) |
| 2039 | { |
| 2040 | /* Build the occupied channel list, only if "gNeighborScanChannelList" is |
| 2041 | NOT set in the cfg.ini file */ |
| 2042 | csrScanAddToOccupiedChannels(pMac, pResult, &pMac->scan.occupiedChannels, pIes); |
| 2043 | } |
Madan Mohan Koyyalamudi | 470d2cf | 2012-09-28 14:43:44 -0700 | [diff] [blame] | 2044 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2045 | } |
| 2046 | |
| 2047 | |
| 2048 | eHalStatus csrScanGetResult(tpAniSirGlobal pMac, tCsrScanResultFilter *pFilter, tScanResultHandle *phResult) |
| 2049 | { |
| 2050 | eHalStatus status; |
| 2051 | tScanResultList *pRetList; |
| 2052 | tCsrScanResult *pResult, *pBssDesc; |
| 2053 | tANI_U32 count = 0; |
| 2054 | tListElem *pEntry; |
| 2055 | tANI_U32 bssLen, allocLen; |
| 2056 | eCsrEncryptionType uc = eCSR_ENCRYPT_TYPE_NONE, mc = eCSR_ENCRYPT_TYPE_NONE; |
| 2057 | eCsrAuthType auth = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 2058 | tDot11fBeaconIEs *pIes, *pNewIes; |
| 2059 | tANI_BOOLEAN fMatch; |
| 2060 | |
| 2061 | if(phResult) |
| 2062 | { |
| 2063 | *phResult = CSR_INVALID_SCANRESULT_HANDLE; |
| 2064 | } |
| 2065 | status = palAllocateMemory(pMac->hHdd, (void **)&pRetList, sizeof(tScanResultList)); |
| 2066 | if(HAL_STATUS_SUCCESS(status)) |
| 2067 | { |
| 2068 | palZeroMemory(pMac->hHdd, pRetList, sizeof(tScanResultList)); |
| 2069 | csrLLOpen(pMac->hHdd, &pRetList->List); |
| 2070 | pRetList->pCurEntry = NULL; |
| 2071 | |
| 2072 | csrLLLock(&pMac->scan.scanResultList); |
| 2073 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK ); |
| 2074 | while( pEntry ) |
| 2075 | { |
| 2076 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 2077 | pIes = (tDot11fBeaconIEs *)( pBssDesc->Result.pvIes ); |
| 2078 | //if pBssDesc->Result.pvIes is NULL, we need to free any memory allocated by csrMatchBSS |
| 2079 | //for any error condition, otherwiase, it will be freed later. |
| 2080 | //reset |
| 2081 | fMatch = eANI_BOOLEAN_FALSE; |
| 2082 | pNewIes = NULL; |
| 2083 | |
| 2084 | if(pFilter) |
| 2085 | { |
| 2086 | fMatch = csrMatchBSS(pMac, &pBssDesc->Result.BssDescriptor, pFilter, &auth, &uc, &mc, &pIes); |
| 2087 | if( NULL != pIes ) |
| 2088 | { |
| 2089 | //Only save it when matching |
| 2090 | if(fMatch) |
| 2091 | { |
| 2092 | if( !pBssDesc->Result.pvIes ) |
| 2093 | { |
| 2094 | //csrMatchBSS allocates the memory. Simply pass it and it is freed later |
| 2095 | pNewIes = pIes; |
| 2096 | } |
| 2097 | else |
| 2098 | { |
| 2099 | //The pIes is allocated by someone else. make a copy |
| 2100 | //Only to save parsed IEs if caller provides a filter. Most likely the caller |
| 2101 | //is using to for association, hence save the parsed IEs |
| 2102 | status = palAllocateMemory(pMac->hHdd, (void **)&pNewIes, sizeof(tDot11fBeaconIEs)); |
| 2103 | if( HAL_STATUS_SUCCESS( status ) ) |
| 2104 | { |
| 2105 | palCopyMemory( pMac->hHdd, pNewIes, pIes, sizeof( tDot11fBeaconIEs ) ); |
| 2106 | } |
| 2107 | else |
| 2108 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 2109 | smsLog(pMac, LOGE, FL(" fail to allocate memory for IEs")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2110 | //Need to free memory allocated by csrMatchBSS |
| 2111 | if( !pBssDesc->Result.pvIes ) |
| 2112 | { |
| 2113 | palFreeMemory(pMac->hHdd, pIes); |
| 2114 | } |
| 2115 | break; |
| 2116 | } |
| 2117 | } |
| 2118 | }//fMatch |
| 2119 | else if( !pBssDesc->Result.pvIes ) |
| 2120 | { |
| 2121 | palFreeMemory(pMac->hHdd, pIes); |
| 2122 | } |
| 2123 | } |
| 2124 | } |
| 2125 | if(NULL == pFilter || fMatch) |
| 2126 | { |
| 2127 | bssLen = pBssDesc->Result.BssDescriptor.length + sizeof(pBssDesc->Result.BssDescriptor.length); |
| 2128 | allocLen = sizeof( tCsrScanResult ) + bssLen; |
| 2129 | status = palAllocateMemory(pMac->hHdd, (void **)&pResult, allocLen); |
| 2130 | if(!HAL_STATUS_SUCCESS(status)) |
| 2131 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 2132 | 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] | 2133 | if(pNewIes) |
| 2134 | { |
| 2135 | palFreeMemory(pMac->hHdd, pNewIes); |
| 2136 | } |
| 2137 | break; |
| 2138 | } |
| 2139 | palZeroMemory(pMac->hHdd, pResult, allocLen); |
| 2140 | pResult->capValue = pBssDesc->capValue; |
| 2141 | pResult->preferValue = pBssDesc->preferValue; |
| 2142 | pResult->ucEncryptionType = uc; |
| 2143 | pResult->mcEncryptionType = mc; |
| 2144 | pResult->authType = auth; |
| 2145 | pResult->Result.ssId = pBssDesc->Result.ssId; |
| 2146 | pResult->Result.timer = 0; |
| 2147 | //save the pIes for later use |
| 2148 | pResult->Result.pvIes = pNewIes; |
| 2149 | //save bss description |
| 2150 | status = palCopyMemory(pMac->hHdd, &pResult->Result.BssDescriptor, &pBssDesc->Result.BssDescriptor, bssLen); |
| 2151 | if(!HAL_STATUS_SUCCESS(status)) |
| 2152 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 2153 | smsLog(pMac, LOGE, FL(" fail to copy memory for scan result")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2154 | palFreeMemory(pMac->hHdd, pResult); |
| 2155 | if(pNewIes) |
| 2156 | { |
| 2157 | palFreeMemory(pMac->hHdd, pNewIes); |
| 2158 | } |
| 2159 | break; |
| 2160 | } |
| 2161 | //No need to lock pRetList because it is locally allocated and no outside can access it at this time |
| 2162 | if(csrLLIsListEmpty(&pRetList->List, LL_ACCESS_NOLOCK)) |
| 2163 | { |
| 2164 | csrLLInsertTail(&pRetList->List, &pResult->Link, LL_ACCESS_NOLOCK); |
| 2165 | } |
| 2166 | else |
| 2167 | { |
| 2168 | //To sort the list |
| 2169 | tListElem *pTmpEntry; |
| 2170 | tCsrScanResult *pTmpResult; |
| 2171 | |
| 2172 | pTmpEntry = csrLLPeekHead(&pRetList->List, LL_ACCESS_NOLOCK); |
| 2173 | while(pTmpEntry) |
| 2174 | { |
| 2175 | pTmpResult = GET_BASE_ADDR( pTmpEntry, tCsrScanResult, Link ); |
| 2176 | if(csrIsBetterBss(pResult, pTmpResult)) |
| 2177 | { |
| 2178 | csrLLInsertEntry(&pRetList->List, pTmpEntry, &pResult->Link, LL_ACCESS_NOLOCK); |
| 2179 | //To indicate we are done |
| 2180 | pResult = NULL; |
| 2181 | break; |
| 2182 | } |
| 2183 | pTmpEntry = csrLLNext(&pRetList->List, pTmpEntry, LL_ACCESS_NOLOCK); |
| 2184 | } |
| 2185 | if(pResult != NULL) |
| 2186 | { |
| 2187 | //This one is not better than any one |
| 2188 | csrLLInsertTail(&pRetList->List, &pResult->Link, LL_ACCESS_NOLOCK); |
| 2189 | } |
| 2190 | } |
| 2191 | count++; |
| 2192 | } |
| 2193 | pEntry = csrLLNext( &pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK ); |
| 2194 | }//while |
| 2195 | csrLLUnlock(&pMac->scan.scanResultList); |
| 2196 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 2197 | smsLog(pMac, LOG2, FL("return %d BSS"), csrLLCount(&pRetList->List)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2198 | |
| 2199 | if( !HAL_STATUS_SUCCESS(status) || (phResult == NULL) ) |
| 2200 | { |
| 2201 | //Fail or No one wants the result. |
| 2202 | csrScanResultPurge(pMac, (tScanResultHandle)pRetList); |
| 2203 | } |
| 2204 | else |
| 2205 | { |
| 2206 | if(0 == count) |
| 2207 | { |
| 2208 | //We are here meaning the there is no match |
| 2209 | csrLLClose(&pRetList->List); |
| 2210 | palFreeMemory(pMac->hHdd, pRetList); |
| 2211 | status = eHAL_STATUS_E_NULL_VALUE; |
| 2212 | } |
| 2213 | else if(phResult) |
| 2214 | { |
| 2215 | *phResult = pRetList; |
| 2216 | } |
| 2217 | } |
| 2218 | }//Allocated pRetList |
| 2219 | |
| 2220 | return (status); |
| 2221 | } |
| 2222 | |
Madan Mohan Koyyalamudi | ab41d0f | 2012-10-31 17:17:10 -0700 | [diff] [blame] | 2223 | /* |
| 2224 | * NOTE: This routine is being added to make |
| 2225 | * sure that scan results are not being flushed |
| 2226 | * while roaming. If the scan results are flushed, |
| 2227 | * we are unable to recover from |
| 2228 | * csrRoamRoamingStateDisassocRspProcessor. |
| 2229 | * If it is needed to remove this routine, |
| 2230 | * first ensure that we recover gracefully from |
| 2231 | * csrRoamRoamingStateDisassocRspProcessor if |
| 2232 | * csrScanGetResult returns with a failure because |
| 2233 | * of not being able to find the roaming BSS. |
| 2234 | */ |
| 2235 | tANI_U8 csrScanFlushDenied(tpAniSirGlobal pMac) |
| 2236 | { |
| 2237 | switch(pMac->roam.neighborRoamInfo.neighborRoamState) { |
| 2238 | case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN: |
| 2239 | case eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING: |
| 2240 | case eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE: |
| 2241 | case eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING: |
| 2242 | return (pMac->roam.neighborRoamInfo.neighborRoamState); |
| 2243 | default: |
| 2244 | return 0; |
| 2245 | } |
| 2246 | } |
| 2247 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2248 | eHalStatus csrScanFlushResult(tpAniSirGlobal pMac) |
| 2249 | { |
Madan Mohan Koyyalamudi | ab41d0f | 2012-10-31 17:17:10 -0700 | [diff] [blame] | 2250 | tANI_U8 isFlushDenied = csrScanFlushDenied(pMac); |
| 2251 | if (isFlushDenied) { |
| 2252 | smsLog(pMac, LOGW, "%s: scan flush denied in roam state %d", |
| 2253 | __func__, isFlushDenied); |
| 2254 | return eHAL_STATUS_FAILURE; |
| 2255 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2256 | return ( csrLLScanPurgeResult(pMac, &pMac->scan.scanResultList) ); |
| 2257 | } |
| 2258 | |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2259 | eHalStatus csrScanFlushSelectiveResult(tpAniSirGlobal pMac, v_BOOL_t flushP2P) |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2260 | { |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2261 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2262 | tListElem *pEntry,*pFreeElem; |
| 2263 | tCsrScanResult *pBssDesc; |
| 2264 | tDblLinkList *pList = &pMac->scan.scanResultList; |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2265 | |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2266 | csrLLLock(pList); |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2267 | |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2268 | pEntry = csrLLPeekHead( pList, LL_ACCESS_NOLOCK ); |
| 2269 | while( pEntry != NULL) |
| 2270 | { |
| 2271 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 2272 | if( flushP2P == vos_mem_compare( pBssDesc->Result.ssId.ssId, |
| 2273 | "DIRECT-", 7) ) |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2274 | { |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2275 | pFreeElem = pEntry; |
| 2276 | pEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK); |
| 2277 | csrLLRemoveEntry(pList, pFreeElem, LL_ACCESS_NOLOCK); |
| 2278 | csrFreeScanResultEntry( pMac, pBssDesc ); |
| 2279 | continue; |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2280 | } |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2281 | pEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK); |
| 2282 | } |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2283 | |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2284 | csrLLUnlock(pList); |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2285 | |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2286 | return (status); |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2287 | } |
| 2288 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2289 | /** |
| 2290 | * csrCheck11dChannel |
| 2291 | * |
| 2292 | *FUNCTION: |
| 2293 | * This function is called from csrScanFilter11dResult function and |
| 2294 | * compare channel number with given channel list. |
| 2295 | * |
| 2296 | *LOGIC: |
| 2297 | * Check Scan result channel number with CFG channel list |
| 2298 | * |
| 2299 | *ASSUMPTIONS: |
| 2300 | * |
| 2301 | * |
| 2302 | *NOTE: |
| 2303 | * |
| 2304 | * @param channelId channel number |
| 2305 | * @param pChannelList Pointer to channel list |
| 2306 | * @param numChannels Number of channel in channel list |
| 2307 | * |
| 2308 | * @return Status |
| 2309 | */ |
| 2310 | |
| 2311 | eHalStatus csrCheck11dChannel(tANI_U8 channelId, tANI_U8 *pChannelList, tANI_U32 numChannels) |
| 2312 | { |
| 2313 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 2314 | tANI_U8 i = 0; |
| 2315 | |
| 2316 | for (i = 0; i < numChannels; i++) |
| 2317 | { |
| 2318 | if(pChannelList[ i ] == channelId) |
| 2319 | { |
| 2320 | status = eHAL_STATUS_SUCCESS; |
| 2321 | break; |
| 2322 | } |
| 2323 | } |
| 2324 | return status; |
| 2325 | } |
| 2326 | |
| 2327 | /** |
| 2328 | * csrScanFilter11dResult |
| 2329 | * |
| 2330 | *FUNCTION: |
| 2331 | * This function is called from csrApplyCountryInformation function and |
| 2332 | * filter scan result based on valid channel list number. |
| 2333 | * |
| 2334 | *LOGIC: |
| 2335 | * Get scan result from scan list and Check Scan result channel number |
| 2336 | * with 11d channel list if channel number is found in 11d channel list |
| 2337 | * then do not remove scan result entry from scan list |
| 2338 | * |
| 2339 | *ASSUMPTIONS: |
| 2340 | * |
| 2341 | * |
| 2342 | *NOTE: |
| 2343 | * |
| 2344 | * @param pMac Pointer to Global MAC structure |
| 2345 | * |
| 2346 | * @return Status |
| 2347 | */ |
| 2348 | |
| 2349 | eHalStatus csrScanFilter11dResult(tpAniSirGlobal pMac) |
| 2350 | { |
| 2351 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2352 | tListElem *pEntry,*pTempEntry; |
| 2353 | tCsrScanResult *pBssDesc; |
| 2354 | tANI_U32 len = sizeof(pMac->roam.validChannelList); |
| 2355 | |
| 2356 | /* Get valid channels list from CFG */ |
| 2357 | if (!HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, |
| 2358 | pMac->roam.validChannelList, &len))) |
| 2359 | { |
| 2360 | smsLog( pMac, LOG1, "Failed to get Channel list from CFG"); |
| 2361 | } |
| 2362 | |
| 2363 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_LOCK ); |
| 2364 | while( pEntry ) |
| 2365 | { |
| 2366 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 2367 | pTempEntry = csrLLNext( &pMac->scan.scanResultList, pEntry, |
| 2368 | LL_ACCESS_LOCK ); |
| 2369 | if(csrCheck11dChannel(pBssDesc->Result.BssDescriptor.channelId, |
| 2370 | pMac->roam.validChannelList, len)) |
| 2371 | { |
| 2372 | /* Remove Scan result which does not have 11d channel */ |
| 2373 | if( csrLLRemoveEntry( &pMac->scan.scanResultList, pEntry, |
| 2374 | LL_ACCESS_LOCK )) |
| 2375 | { |
| 2376 | csrFreeScanResultEntry( pMac, pBssDesc ); |
| 2377 | } |
| 2378 | } |
| 2379 | pEntry = pTempEntry; |
| 2380 | } |
| 2381 | return status; |
| 2382 | } |
| 2383 | |
| 2384 | |
| 2385 | eHalStatus csrScanCopyResultList(tpAniSirGlobal pMac, tScanResultHandle hIn, tScanResultHandle *phResult) |
| 2386 | { |
| 2387 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2388 | tScanResultList *pRetList, *pInList = (tScanResultList *)hIn; |
| 2389 | tCsrScanResult *pResult, *pScanResult; |
| 2390 | tANI_U32 count = 0; |
| 2391 | tListElem *pEntry; |
| 2392 | tANI_U32 bssLen, allocLen; |
| 2393 | |
| 2394 | if(phResult) |
| 2395 | { |
| 2396 | *phResult = CSR_INVALID_SCANRESULT_HANDLE; |
| 2397 | } |
| 2398 | status = palAllocateMemory(pMac->hHdd, (void **)&pRetList, sizeof(tScanResultList)); |
| 2399 | if(HAL_STATUS_SUCCESS(status)) |
| 2400 | { |
| 2401 | palZeroMemory(pMac->hHdd, pRetList, sizeof(tScanResultList)); |
| 2402 | csrLLOpen(pMac->hHdd, &pRetList->List); |
| 2403 | pRetList->pCurEntry = NULL; |
| 2404 | csrLLLock(&pMac->scan.scanResultList); |
| 2405 | csrLLLock(&pInList->List); |
| 2406 | |
| 2407 | pEntry = csrLLPeekHead( &pInList->List, LL_ACCESS_NOLOCK ); |
| 2408 | while( pEntry ) |
| 2409 | { |
| 2410 | pScanResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 2411 | bssLen = pScanResult->Result.BssDescriptor.length + sizeof(pScanResult->Result.BssDescriptor.length); |
| 2412 | allocLen = sizeof( tCsrScanResult ) + bssLen; |
| 2413 | status = palAllocateMemory(pMac->hHdd, (void **)&pResult, allocLen); |
| 2414 | if(!HAL_STATUS_SUCCESS(status)) |
| 2415 | { |
| 2416 | csrScanResultPurge(pMac, (tScanResultHandle *)pRetList); |
| 2417 | count = 0; |
| 2418 | break; |
| 2419 | } |
| 2420 | palZeroMemory(pMac->hHdd, pResult, allocLen); |
| 2421 | status = palCopyMemory(pMac->hHdd, &pResult->Result.BssDescriptor, &pScanResult->Result.BssDescriptor, bssLen); |
| 2422 | if(!HAL_STATUS_SUCCESS(status)) |
| 2423 | { |
| 2424 | csrScanResultPurge(pMac, (tScanResultHandle *)pRetList); |
| 2425 | count = 0; |
| 2426 | break; |
| 2427 | } |
| 2428 | if( pScanResult->Result.pvIes ) |
| 2429 | { |
| 2430 | status = palAllocateMemory(pMac->hHdd, (void **)&pResult->Result.pvIes, sizeof( tDot11fBeaconIEs )); |
| 2431 | if(!HAL_STATUS_SUCCESS(status)) |
| 2432 | { |
| 2433 | //Free the memory we allocate above first |
| 2434 | palFreeMemory( pMac->hHdd, pResult ); |
| 2435 | csrScanResultPurge(pMac, (tScanResultHandle *)pRetList); |
| 2436 | count = 0; |
| 2437 | break; |
| 2438 | } |
| 2439 | status = palCopyMemory(pMac->hHdd, pResult->Result.pvIes, |
| 2440 | pScanResult->Result.pvIes, sizeof( tDot11fBeaconIEs )); |
| 2441 | if(!HAL_STATUS_SUCCESS(status)) |
| 2442 | { |
| 2443 | //Free the memory we allocate above first |
| 2444 | palFreeMemory( pMac->hHdd, pResult ); |
| 2445 | csrScanResultPurge(pMac, (tScanResultHandle *)pRetList); |
| 2446 | count = 0; |
| 2447 | break; |
| 2448 | } |
| 2449 | } |
| 2450 | csrLLInsertTail(&pRetList->List, &pResult->Link, LL_ACCESS_LOCK); |
| 2451 | count++; |
| 2452 | pEntry = csrLLNext( &pInList->List, pEntry, LL_ACCESS_NOLOCK ); |
| 2453 | }//while |
| 2454 | csrLLUnlock(&pInList->List); |
| 2455 | csrLLUnlock(&pMac->scan.scanResultList); |
| 2456 | |
| 2457 | if(HAL_STATUS_SUCCESS(status)) |
| 2458 | { |
| 2459 | if(0 == count) |
| 2460 | { |
| 2461 | csrLLClose(&pRetList->List); |
| 2462 | palFreeMemory(pMac->hHdd, pRetList); |
| 2463 | status = eHAL_STATUS_E_NULL_VALUE; |
| 2464 | } |
| 2465 | else if(phResult) |
| 2466 | { |
| 2467 | *phResult = pRetList; |
| 2468 | } |
| 2469 | } |
| 2470 | }//Allocated pRetList |
| 2471 | |
| 2472 | return (status); |
| 2473 | } |
| 2474 | |
| 2475 | |
| 2476 | |
| 2477 | eHalStatus csrScanningStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf ) |
| 2478 | { |
| 2479 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2480 | tSirMbMsg *pMsg = (tSirMbMsg *)pMsgBuf; |
| 2481 | |
| 2482 | if((eWNI_SME_SCAN_RSP == pMsg->type) || (eWNI_SME_GET_SCANNED_CHANNEL_RSP == pMsg->type)) |
| 2483 | { |
| 2484 | status = csrScanSmeScanResponse( pMac, pMsgBuf ); |
| 2485 | } |
| 2486 | else |
| 2487 | { |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 2488 | if(pMsg->type == eWNI_SME_UPPER_LAYER_ASSOC_CNF) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2489 | { |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 2490 | tCsrRoamSession *pSession; |
| 2491 | tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf; |
| 2492 | tCsrRoamInfo roamInfo; |
| 2493 | tCsrRoamInfo *pRoamInfo = NULL; |
| 2494 | tANI_U32 sessionId; |
| 2495 | eHalStatus status; |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 2496 | 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] | 2497 | palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo)); |
| 2498 | pRoamInfo = &roamInfo; |
| 2499 | pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf; |
| 2500 | status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId ); |
| 2501 | pSession = CSR_GET_SESSION(pMac, sessionId); |
| 2502 | |
| 2503 | if(!pSession) |
| 2504 | { |
| 2505 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 2506 | return eHAL_STATUS_FAILURE; |
| 2507 | } |
| 2508 | |
| 2509 | pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success |
| 2510 | pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile; |
| 2511 | pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid; |
| 2512 | pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length; |
| 2513 | pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata; |
| 2514 | pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length; |
| 2515 | pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata; |
| 2516 | palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr, sizeof(tSirMacAddr)); |
| 2517 | palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pUpperLayerAssocCnf->bssId, sizeof(tCsrBssid)); |
| 2518 | pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta; |
| 2519 | if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) ) |
| 2520 | { |
| 2521 | pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED; |
| 2522 | pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq; |
| 2523 | status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF); |
| 2524 | } |
| 2525 | if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile)) |
| 2526 | { |
| 2527 | vos_sleep( 100 ); |
| 2528 | pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta |
| 2529 | status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta |
| 2530 | } |
| 2531 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2532 | } |
| 2533 | else |
| 2534 | { |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 2535 | |
| 2536 | if( csrIsAnySessionInConnectState( pMac ) ) |
| 2537 | { |
| 2538 | //In case of we are connected, we need to check whether connect status changes |
| 2539 | //because scan may also run while connected. |
| 2540 | csrRoamCheckForLinkStatusChange( pMac, ( tSirSmeRsp * )pMsgBuf ); |
| 2541 | } |
| 2542 | else |
| 2543 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 2544 | 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] | 2545 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2546 | } |
| 2547 | } |
| 2548 | |
| 2549 | return (status); |
| 2550 | } |
| 2551 | |
| 2552 | |
| 2553 | |
| 2554 | void csrCheckNSaveWscIe(tpAniSirGlobal pMac, tSirBssDescription *pNewBssDescr, tSirBssDescription *pOldBssDescr) |
| 2555 | { |
| 2556 | int idx, len; |
| 2557 | tANI_U8 *pbIe; |
| 2558 | |
| 2559 | //If failed to remove, assuming someone else got it. |
| 2560 | if((pNewBssDescr->fProbeRsp != pOldBssDescr->fProbeRsp) && |
| 2561 | (0 == pNewBssDescr->WscIeLen)) |
| 2562 | { |
| 2563 | idx = 0; |
| 2564 | len = pOldBssDescr->length - sizeof(tSirBssDescription) + |
| 2565 | sizeof(tANI_U16) + sizeof(tANI_U32) - DOT11F_IE_WSCPROBERES_MIN_LEN - 2; |
| 2566 | pbIe = (tANI_U8 *)pOldBssDescr->ieFields; |
| 2567 | //Save WPS IE if it exists |
| 2568 | pNewBssDescr->WscIeLen = 0; |
| 2569 | while(idx < len) |
| 2570 | { |
| 2571 | if((DOT11F_EID_WSCPROBERES == pbIe[0]) && |
| 2572 | (0x00 == pbIe[2]) && (0x50 == pbIe[3]) && (0xf2 == pbIe[4]) && (0x04 == pbIe[5])) |
| 2573 | { |
| 2574 | //Founrd it |
| 2575 | if((DOT11F_IE_WSCPROBERES_MAX_LEN - 2) >= pbIe[1]) |
| 2576 | { |
| 2577 | palCopyMemory(pMac->hHdd, pNewBssDescr->WscIeProbeRsp, |
| 2578 | pbIe, pbIe[1] + 2); |
| 2579 | pNewBssDescr->WscIeLen = pbIe[1] + 2; |
| 2580 | } |
| 2581 | break; |
| 2582 | } |
| 2583 | idx += pbIe[1] + 2; |
| 2584 | pbIe += pbIe[1] + 2; |
| 2585 | } |
| 2586 | } |
| 2587 | } |
| 2588 | |
| 2589 | |
| 2590 | |
| 2591 | //pIes may be NULL |
| 2592 | tANI_BOOLEAN csrRemoveDupBssDescription( tpAniSirGlobal pMac, tSirBssDescription *pSirBssDescr, |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 2593 | tDot11fBeaconIEs *pIes, tAniSSID *pSsid, v_TIME_t *timer, tANI_BOOLEAN fForced ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2594 | { |
| 2595 | tListElem *pEntry; |
| 2596 | |
| 2597 | tCsrScanResult *pBssDesc; |
| 2598 | tANI_BOOLEAN fRC = FALSE; |
| 2599 | |
| 2600 | // Walk through all the chained BssDescriptions. If we find a chained BssDescription that |
| 2601 | // matches the BssID of the BssDescription passed in, then these must be duplicate scan |
| 2602 | // results for this Bss. In that case, remove the 'old' Bss description from the linked list. |
| 2603 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_LOCK ); |
| 2604 | |
| 2605 | while( pEntry ) |
| 2606 | { |
| 2607 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 2608 | |
| 2609 | // we have a duplicate scan results only when BSSID, SSID, Channel and NetworkType |
| 2610 | // matches |
| 2611 | if ( csrIsDuplicateBssDescription( pMac, &pBssDesc->Result.BssDescriptor, |
Tushnim Bhattacharyya | 5128d75 | 2013-06-26 23:23:18 -0700 | [diff] [blame] | 2612 | pSirBssDescr, pIes, fForced ) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2613 | { |
| 2614 | pSirBssDescr->rssi = (tANI_S8)( (((tANI_S32)pSirBssDescr->rssi * CSR_SCAN_RESULT_RSSI_WEIGHT ) + |
| 2615 | ((tANI_S32)pBssDesc->Result.BssDescriptor.rssi * (100 - CSR_SCAN_RESULT_RSSI_WEIGHT) )) / 100 ); |
| 2616 | // Remove the 'old' entry from the list.... |
| 2617 | if( csrLLRemoveEntry( &pMac->scan.scanResultList, pEntry, LL_ACCESS_LOCK ) ) |
| 2618 | { |
| 2619 | // !we need to free the memory associated with this node |
| 2620 | //If failed to remove, assuming someone else got it. |
| 2621 | *pSsid = pBssDesc->Result.ssId; |
| 2622 | *timer = pBssDesc->Result.timer; |
| 2623 | csrCheckNSaveWscIe(pMac, pSirBssDescr, &pBssDesc->Result.BssDescriptor); |
| 2624 | |
| 2625 | csrFreeScanResultEntry( pMac, pBssDesc ); |
| 2626 | } |
| 2627 | else |
| 2628 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 2629 | smsLog( pMac, LOGW, FL( " fail to remove entry" ) ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2630 | } |
| 2631 | fRC = TRUE; |
| 2632 | |
| 2633 | // If we found a match, we can stop looking through the list. |
| 2634 | break; |
| 2635 | } |
| 2636 | |
| 2637 | pEntry = csrLLNext( &pMac->scan.scanResultList, pEntry, LL_ACCESS_LOCK ); |
| 2638 | } |
| 2639 | |
| 2640 | return fRC; |
| 2641 | } |
| 2642 | |
| 2643 | |
| 2644 | eHalStatus csrAddPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId, |
| 2645 | tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes ) |
| 2646 | { |
| 2647 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 2648 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 2649 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2650 | if(!pSession) |
| 2651 | { |
| 2652 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 2653 | return eHAL_STATUS_FAILURE; |
| 2654 | } |
| 2655 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 2656 | smsLog(pMac, LOGW, "csrAddPMKIDCandidateList called pMac->scan.NumPmkidCandidate = %d", pSession->NumPmkidCandidate); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2657 | if( pIes ) |
| 2658 | { |
| 2659 | // check if this is a RSN BSS |
| 2660 | if( pIes->RSN.present ) |
| 2661 | { |
| 2662 | // Check if the BSS is capable of doing pre-authentication |
| 2663 | if( pSession->NumPmkidCandidate < CSR_MAX_PMKID_ALLOWED ) |
| 2664 | { |
| 2665 | |
| 2666 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 2667 | { |
| 2668 | WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type); |
| 2669 | palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type)); |
| 2670 | secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_CANDIDATE_FOUND; |
| 2671 | secEvent.encryptionModeMulticast = |
| 2672 | (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType); |
| 2673 | secEvent.encryptionModeUnicast = |
| 2674 | (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType); |
| 2675 | palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 ); |
| 2676 | secEvent.authMode = |
| 2677 | (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType); |
| 2678 | WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY); |
| 2679 | } |
| 2680 | #endif//#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 2681 | |
| 2682 | // if yes, then add to PMKIDCandidateList |
| 2683 | status = palCopyMemory(pMac->hHdd, pSession->PmkidCandidateInfo[pSession->NumPmkidCandidate].BSSID, |
| 2684 | pBssDesc->bssId, WNI_CFG_BSSID_LEN); |
| 2685 | |
| 2686 | if( HAL_STATUS_SUCCESS( status ) ) |
| 2687 | { |
Venkata Prathyusha Kuntupalli | ea7098e | 2013-01-31 16:08:13 -0800 | [diff] [blame] | 2688 | 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] | 2689 | { |
| 2690 | pSession->PmkidCandidateInfo[pSession->NumPmkidCandidate].preAuthSupported = eANI_BOOLEAN_TRUE; |
| 2691 | } |
| 2692 | else |
| 2693 | { |
| 2694 | pSession->PmkidCandidateInfo[pSession->NumPmkidCandidate].preAuthSupported = eANI_BOOLEAN_FALSE; |
| 2695 | } |
| 2696 | pSession->NumPmkidCandidate++; |
| 2697 | } |
| 2698 | } |
| 2699 | else |
| 2700 | { |
| 2701 | status = eHAL_STATUS_FAILURE; |
| 2702 | } |
| 2703 | } |
| 2704 | } |
| 2705 | |
| 2706 | return (status); |
| 2707 | } |
| 2708 | |
| 2709 | //This function checks whether new AP is found for the current connected profile |
| 2710 | //If it is found, it return the sessionId, else it return invalid sessionID |
| 2711 | tANI_U32 csrProcessBSSDescForPMKIDList(tpAniSirGlobal pMac, |
| 2712 | tSirBssDescription *pBssDesc, |
| 2713 | tDot11fBeaconIEs *pIes) |
| 2714 | { |
| 2715 | tANI_U32 i, bRet = CSR_SESSION_ID_INVALID; |
| 2716 | tCsrRoamSession *pSession; |
| 2717 | tDot11fBeaconIEs *pIesLocal = pIes; |
| 2718 | |
| 2719 | if( pIesLocal || HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal)) ) |
| 2720 | { |
| 2721 | for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ ) |
| 2722 | { |
| 2723 | if( CSR_IS_SESSION_VALID( pMac, i ) ) |
| 2724 | { |
| 2725 | pSession = CSR_GET_SESSION( pMac, i ); |
| 2726 | if( csrIsConnStateConnectedInfra( pMac, i ) && |
| 2727 | ( eCSR_AUTH_TYPE_RSN == pSession->connectedProfile.AuthType ) ) |
| 2728 | { |
| 2729 | if(csrMatchBSSToConnectProfile(pMac, &pSession->connectedProfile, pBssDesc, pIesLocal)) |
| 2730 | { |
| 2731 | //this new BSS fits the current profile connected |
| 2732 | if(HAL_STATUS_SUCCESS(csrAddPMKIDCandidateList(pMac, i, pBssDesc, pIesLocal))) |
| 2733 | { |
| 2734 | bRet = i; |
| 2735 | } |
| 2736 | break; |
| 2737 | } |
| 2738 | } |
| 2739 | } |
| 2740 | } |
| 2741 | if( !pIes ) |
| 2742 | { |
| 2743 | palFreeMemory(pMac->hHdd, pIesLocal); |
| 2744 | } |
| 2745 | } |
| 2746 | |
| 2747 | return (tANI_U8)bRet; |
| 2748 | } |
| 2749 | |
| 2750 | #ifdef FEATURE_WLAN_WAPI |
| 2751 | eHalStatus csrAddBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId, |
| 2752 | tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes ) |
| 2753 | { |
| 2754 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 2755 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 2756 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2757 | if(!pSession) |
| 2758 | { |
| 2759 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 2760 | return eHAL_STATUS_FAILURE; |
| 2761 | } |
| 2762 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 2763 | smsLog(pMac, LOGW, "csrAddBKIDCandidateList called pMac->scan.NumBkidCandidate = %d", pSession->NumBkidCandidate); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2764 | if( pIes ) |
| 2765 | { |
| 2766 | // check if this is a WAPI BSS |
| 2767 | if( pIes->WAPI.present ) |
| 2768 | { |
| 2769 | // Check if the BSS is capable of doing pre-authentication |
| 2770 | if( pSession->NumBkidCandidate < CSR_MAX_BKID_ALLOWED ) |
| 2771 | { |
| 2772 | |
| 2773 | // if yes, then add to BKIDCandidateList |
| 2774 | status = palCopyMemory(pMac->hHdd, pSession->BkidCandidateInfo[pSession->NumBkidCandidate].BSSID, |
| 2775 | pBssDesc->bssId, WNI_CFG_BSSID_LEN); |
| 2776 | |
| 2777 | if( HAL_STATUS_SUCCESS( status ) ) |
| 2778 | { |
| 2779 | if ( pIes->WAPI.preauth ) |
| 2780 | { |
| 2781 | pSession->BkidCandidateInfo[pSession->NumBkidCandidate].preAuthSupported = eANI_BOOLEAN_TRUE; |
| 2782 | } |
| 2783 | else |
| 2784 | { |
| 2785 | pSession->BkidCandidateInfo[pSession->NumBkidCandidate].preAuthSupported = eANI_BOOLEAN_FALSE; |
| 2786 | } |
| 2787 | pSession->NumBkidCandidate++; |
| 2788 | } |
| 2789 | } |
| 2790 | else |
| 2791 | { |
| 2792 | status = eHAL_STATUS_FAILURE; |
| 2793 | } |
| 2794 | } |
| 2795 | } |
| 2796 | |
| 2797 | return (status); |
| 2798 | } |
| 2799 | |
| 2800 | //This function checks whether new AP is found for the current connected profile |
| 2801 | //if so add to BKIDCandidateList |
| 2802 | tANI_BOOLEAN csrProcessBSSDescForBKIDList(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc, |
| 2803 | tDot11fBeaconIEs *pIes) |
| 2804 | { |
| 2805 | tANI_BOOLEAN fRC = FALSE; |
| 2806 | tDot11fBeaconIEs *pIesLocal = pIes; |
| 2807 | tANI_U32 sessionId; |
| 2808 | tCsrRoamSession *pSession; |
| 2809 | |
| 2810 | if( pIesLocal || HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal)) ) |
| 2811 | { |
| 2812 | for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ ) |
| 2813 | { |
| 2814 | if( CSR_IS_SESSION_VALID( pMac, sessionId) ) |
| 2815 | { |
| 2816 | pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 2817 | if( csrIsConnStateConnectedInfra( pMac, sessionId ) && |
| 2818 | eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == pSession->connectedProfile.AuthType) |
| 2819 | { |
| 2820 | if(csrMatchBSSToConnectProfile(pMac, &pSession->connectedProfile,pBssDesc, pIesLocal)) |
| 2821 | { |
| 2822 | //this new BSS fits the current profile connected |
| 2823 | if(HAL_STATUS_SUCCESS(csrAddBKIDCandidateList(pMac, sessionId, pBssDesc, pIesLocal))) |
| 2824 | { |
| 2825 | fRC = TRUE; |
| 2826 | } |
| 2827 | } |
| 2828 | } |
| 2829 | } |
| 2830 | } |
| 2831 | if(!pIes) |
| 2832 | { |
| 2833 | palFreeMemory(pMac->hHdd, pIesLocal); |
| 2834 | } |
| 2835 | |
| 2836 | } |
| 2837 | return fRC; |
| 2838 | } |
| 2839 | |
| 2840 | #endif |
| 2841 | |
| 2842 | |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 2843 | static void csrMoveTempScanResultsToMainList( tpAniSirGlobal pMac, tANI_U8 reason ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2844 | { |
| 2845 | tListElem *pEntry; |
| 2846 | tCsrScanResult *pBssDescription; |
| 2847 | tANI_S8 cand_Bss_rssi; |
| 2848 | tANI_BOOLEAN fDupBss; |
| 2849 | #ifdef FEATURE_WLAN_WAPI |
| 2850 | tANI_BOOLEAN fNewWapiBSSForCurConnection = eANI_BOOLEAN_FALSE; |
| 2851 | #endif /* FEATURE_WLAN_WAPI */ |
| 2852 | tDot11fBeaconIEs *pIesLocal = NULL; |
| 2853 | tANI_U32 sessionId = CSR_SESSION_ID_INVALID; |
| 2854 | tAniSSID tmpSsid; |
| 2855 | v_TIME_t timer=0; |
| 2856 | |
| 2857 | tmpSsid.length = 0; |
| 2858 | cand_Bss_rssi = -128; // RSSI coming from PE is -ve |
| 2859 | |
| 2860 | // remove the BSS descriptions from temporary list |
| 2861 | while( ( pEntry = csrLLRemoveTail( &pMac->scan.tempScanResults, LL_ACCESS_LOCK ) ) != NULL) |
| 2862 | { |
| 2863 | pBssDescription = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 2864 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 2865 | 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] | 2866 | pBssDescription->Result.BssDescriptor.bssId[ 0 ], pBssDescription->Result.BssDescriptor.bssId[ 1 ], |
| 2867 | pBssDescription->Result.BssDescriptor.bssId[ 2 ], pBssDescription->Result.BssDescriptor.bssId[ 3 ], |
| 2868 | pBssDescription->Result.BssDescriptor.bssId[ 4 ], pBssDescription->Result.BssDescriptor.bssId[ 5 ], |
| 2869 | pBssDescription->Result.BssDescriptor.channelId, |
| 2870 | pBssDescription->Result.BssDescriptor.rssi * (-1) ); |
| 2871 | |
| 2872 | //At this time, pBssDescription->Result.pvIes may be NULL |
| 2873 | pIesLocal = (tDot11fBeaconIEs *)( pBssDescription->Result.pvIes ); |
| 2874 | if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pBssDescription->Result.BssDescriptor, &pIesLocal))) ) |
| 2875 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 2876 | smsLog(pMac, LOGE, FL(" Cannot pared IEs")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2877 | csrFreeScanResultEntry(pMac, pBssDescription); |
| 2878 | continue; |
| 2879 | } |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 2880 | fDupBss = csrRemoveDupBssDescription( pMac, &pBssDescription->Result.BssDescriptor, pIesLocal, &tmpSsid, &timer, FALSE ); |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 2881 | //Check whether we have reach out limit, but don't lose the LFR candidates came from FW |
| 2882 | if( CSR_SCAN_IS_OVER_BSS_LIMIT(pMac) |
| 2883 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 2884 | && !( eCsrScanGetLfrResult == reason ) |
| 2885 | #endif |
| 2886 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2887 | { |
| 2888 | //Limit reach |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 2889 | smsLog(pMac, LOGW, FL(" BSS limit reached")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2890 | //Free the resources |
| 2891 | if( (pBssDescription->Result.pvIes == NULL) && pIesLocal ) |
| 2892 | { |
| 2893 | palFreeMemory(pMac->hHdd, pIesLocal); |
| 2894 | } |
| 2895 | csrFreeScanResultEntry(pMac, pBssDescription); |
| 2896 | //Continue because there may be duplicated BSS |
| 2897 | continue; |
| 2898 | } |
| 2899 | // check for duplicate scan results |
| 2900 | if ( !fDupBss ) |
| 2901 | { |
| 2902 | //Found a new BSS |
| 2903 | sessionId = csrProcessBSSDescForPMKIDList(pMac, |
| 2904 | &pBssDescription->Result.BssDescriptor, pIesLocal); |
| 2905 | if( CSR_SESSION_ID_INVALID != sessionId) |
| 2906 | { |
| 2907 | csrRoamCallCallback(pMac, sessionId, NULL, 0, |
| 2908 | eCSR_ROAM_SCAN_FOUND_NEW_BSS, eCSR_ROAM_RESULT_NONE); |
| 2909 | } |
| 2910 | } |
| 2911 | else |
| 2912 | { |
| 2913 | //Check if the new one has SSID it it, if not, use the older SSID if it exists. |
| 2914 | if( (0 == pBssDescription->Result.ssId.length) && tmpSsid.length ) |
| 2915 | { |
| 2916 | //New BSS has a hidden SSID and old one has the SSID. Keep the SSID only |
| 2917 | //if diff of saved SSID time and current time is less than 1 min to avoid |
| 2918 | //side effect of saving SSID with old one is that if AP changes its SSID while remain |
| 2919 | //hidden, we may never see it and also to address the requirement of |
| 2920 | //When we remove hidden ssid from the profile i.e., forget the SSID via |
| 2921 | // GUI that SSID shouldn't see in the profile |
| 2922 | if( (vos_timer_get_system_time() - timer) <= HIDDEN_TIMER) |
| 2923 | { |
| 2924 | pBssDescription->Result.timer = timer; |
| 2925 | pBssDescription->Result.ssId = tmpSsid; |
| 2926 | } |
| 2927 | } |
| 2928 | } |
| 2929 | |
| 2930 | //Tush: find a good AP for 11d info |
| 2931 | if( csrIs11dSupported( pMac ) ) |
| 2932 | { |
| 2933 | if(cand_Bss_rssi < pBssDescription->Result.BssDescriptor.rssi) |
| 2934 | { |
| 2935 | // check if country information element is present |
| 2936 | if(pIesLocal->Country.present) |
| 2937 | { |
| 2938 | cand_Bss_rssi = pBssDescription->Result.BssDescriptor.rssi; |
| 2939 | // learn country information |
| 2940 | csrLearnCountryInformation( pMac, &pBssDescription->Result.BssDescriptor, |
| 2941 | pIesLocal, eANI_BOOLEAN_FALSE ); |
| 2942 | } |
| 2943 | |
| 2944 | } |
| 2945 | } |
| 2946 | |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 2947 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2948 | // append to main list |
| 2949 | csrScanAddResult(pMac, pBssDescription, pIesLocal); |
| 2950 | if( (pBssDescription->Result.pvIes == NULL) && pIesLocal ) |
| 2951 | { |
| 2952 | palFreeMemory(pMac->hHdd, pIesLocal); |
| 2953 | } |
| 2954 | } |
| 2955 | |
| 2956 | //Tush: If we can find the current 11d info in any of the scan results, or |
| 2957 | // a good enough AP with the 11d info from the scan results then no need to |
| 2958 | // get into ambiguous state |
| 2959 | if(pMac->scan.fAmbiguous11dInfoFound) |
| 2960 | { |
| 2961 | if((pMac->scan.fCurrent11dInfoMatch) || (cand_Bss_rssi != -128)) |
| 2962 | { |
| 2963 | pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE; |
| 2964 | } |
| 2965 | } |
| 2966 | |
| 2967 | #ifdef FEATURE_WLAN_WAPI |
| 2968 | if(fNewWapiBSSForCurConnection) |
| 2969 | { |
| 2970 | //remember it first |
| 2971 | csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_SCAN_FOUND_NEW_BSS, eCSR_ROAM_RESULT_NEW_WAPI_BSS); |
| 2972 | } |
| 2973 | #endif /* FEATURE_WLAN_WAPI */ |
| 2974 | |
| 2975 | return; |
| 2976 | } |
| 2977 | |
| 2978 | |
| 2979 | static tCsrScanResult *csrScanSaveBssDescription( tpAniSirGlobal pMac, tSirBssDescription *pBSSDescription, |
| 2980 | tDot11fBeaconIEs *pIes) |
| 2981 | { |
| 2982 | tCsrScanResult *pCsrBssDescription = NULL; |
| 2983 | tANI_U32 cbBSSDesc; |
| 2984 | tANI_U32 cbAllocated; |
| 2985 | eHalStatus halStatus; |
| 2986 | |
| 2987 | // figure out how big the BSS description is (the BSSDesc->length does NOT |
| 2988 | // include the size of the length field itself). |
| 2989 | cbBSSDesc = pBSSDescription->length + sizeof( pBSSDescription->length ); |
| 2990 | |
| 2991 | cbAllocated = sizeof( tCsrScanResult ) + cbBSSDesc; |
| 2992 | |
| 2993 | halStatus = palAllocateMemory( pMac->hHdd, (void **)&pCsrBssDescription, cbAllocated ); |
| 2994 | if ( HAL_STATUS_SUCCESS(halStatus) ) |
| 2995 | { |
| 2996 | palZeroMemory( pMac->hHdd, pCsrBssDescription, cbAllocated ); |
| 2997 | pCsrBssDescription->AgingCount = (tANI_S32)pMac->roam.configParam.agingCount; |
| 2998 | palCopyMemory(pMac->hHdd, &pCsrBssDescription->Result.BssDescriptor, pBSSDescription, cbBSSDesc ); |
| 2999 | #if defined(VOSS_ENSBALED) |
| 3000 | VOS_ASSERT( pCsrBssDescription->Result.pvIes == NULL ); |
| 3001 | #endif |
| 3002 | csrScanAddResult(pMac, pCsrBssDescription, pIes); |
| 3003 | } |
| 3004 | |
| 3005 | return( pCsrBssDescription ); |
| 3006 | } |
| 3007 | |
| 3008 | // Append a Bss Description... |
| 3009 | tCsrScanResult *csrScanAppendBssDescription( tpAniSirGlobal pMac, |
| 3010 | tSirBssDescription *pSirBssDescription, |
Tushnim Bhattacharyya | 5128d75 | 2013-06-26 23:23:18 -0700 | [diff] [blame] | 3011 | tDot11fBeaconIEs *pIes, tANI_BOOLEAN fForced ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3012 | { |
| 3013 | tCsrScanResult *pCsrBssDescription = NULL; |
| 3014 | tAniSSID tmpSsid; |
| 3015 | v_TIME_t timer = 0; |
| 3016 | int result; |
| 3017 | |
| 3018 | tmpSsid.length = 0; |
Tushnim Bhattacharyya | 5128d75 | 2013-06-26 23:23:18 -0700 | [diff] [blame] | 3019 | result = csrRemoveDupBssDescription( pMac, pSirBssDescription, pIes, &tmpSsid, &timer, fForced ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3020 | pCsrBssDescription = csrScanSaveBssDescription( pMac, pSirBssDescription, pIes ); |
| 3021 | if (result && (pCsrBssDescription != NULL)) |
| 3022 | { |
| 3023 | //Check if the new one has SSID it it, if not, use the older SSID if it exists. |
| 3024 | if( (0 == pCsrBssDescription->Result.ssId.length) && tmpSsid.length ) |
| 3025 | { |
| 3026 | //New BSS has a hidden SSID and old one has the SSID. Keep the SSID only |
| 3027 | //if diff of saved SSID time and current time is less than 1 min to avoid |
| 3028 | //side effect of saving SSID with old one is that if AP changes its SSID while remain |
| 3029 | //hidden, we may never see it and also to address the requirement of |
| 3030 | //When we remove hidden ssid from the profile i.e., forget the SSID via |
| 3031 | // GUI that SSID shouldn't see in the profile |
| 3032 | if((vos_timer_get_system_time()-timer) <= HIDDEN_TIMER) |
| 3033 | { |
| 3034 | pCsrBssDescription->Result.ssId = tmpSsid; |
| 3035 | pCsrBssDescription->Result.timer = timer; |
| 3036 | } |
| 3037 | } |
| 3038 | } |
| 3039 | |
| 3040 | |
| 3041 | return( pCsrBssDescription ); |
| 3042 | } |
| 3043 | |
| 3044 | |
| 3045 | |
| 3046 | void csrPurgeChannelPower( tpAniSirGlobal pMac, tDblLinkList *pChannelList ) |
| 3047 | { |
| 3048 | tCsrChannelPowerInfo *pChannelSet; |
| 3049 | tListElem *pEntry; |
| 3050 | |
| 3051 | csrLLLock(pChannelList); |
| 3052 | // Remove the channel sets from the learned list and put them in the free list |
| 3053 | while( ( pEntry = csrLLRemoveHead( pChannelList, LL_ACCESS_NOLOCK ) ) != NULL) |
| 3054 | { |
| 3055 | pChannelSet = GET_BASE_ADDR( pEntry, tCsrChannelPowerInfo, link ); |
| 3056 | if( pChannelSet ) |
| 3057 | { |
| 3058 | palFreeMemory( pMac->hHdd, pChannelSet ); |
| 3059 | } |
| 3060 | } |
| 3061 | csrLLUnlock(pChannelList); |
| 3062 | return; |
| 3063 | } |
| 3064 | |
| 3065 | |
| 3066 | /* |
| 3067 | * Save the channelList into the ultimate storage as the final stage of channel |
| 3068 | * Input: pCountryInfo -- the country code (e.g. "USI"), channel list, and power limit are all stored inside this data structure |
| 3069 | */ |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3070 | eHalStatus csrSaveToChannelPower2G_5G( tpAniSirGlobal pMac, tANI_U32 tableSize, tSirMacChanInfo *channelTable ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3071 | { |
| 3072 | tANI_U32 i = tableSize / sizeof( tSirMacChanInfo ); |
| 3073 | tSirMacChanInfo *pChannelInfo; |
| 3074 | tCsrChannelPowerInfo *pChannelSet; |
| 3075 | tANI_BOOLEAN f2GHzInfoFound = FALSE; |
| 3076 | tANI_BOOLEAN f2GListPurged = FALSE, f5GListPurged = FALSE; |
| 3077 | eHalStatus halStatus; |
| 3078 | |
| 3079 | pChannelInfo = channelTable; |
| 3080 | // atleast 3 bytes have to be remaining -- from "countryString" |
| 3081 | while ( i-- ) |
| 3082 | { |
| 3083 | halStatus = palAllocateMemory( pMac->hHdd, (void **)&pChannelSet, sizeof(tCsrChannelPowerInfo) ); |
| 3084 | if ( eHAL_STATUS_SUCCESS == halStatus ) |
| 3085 | { |
| 3086 | palZeroMemory(pMac->hHdd, pChannelSet, sizeof(tCsrChannelPowerInfo)); |
| 3087 | pChannelSet->firstChannel = pChannelInfo->firstChanNum; |
| 3088 | pChannelSet->numChannels = pChannelInfo->numChannels; |
| 3089 | |
| 3090 | // 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] | 3091 | if( (CSR_IS_CHANNEL_24GHZ(pChannelSet->firstChannel)) && |
Madan Mohan Koyyalamudi | 5904d7c | 2012-09-24 13:49:03 -0700 | [diff] [blame] | 3092 | ((pChannelSet->firstChannel + (pChannelSet->numChannels - 1)) <= CSR_MAX_24GHz_CHANNEL_NUMBER) ) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3093 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3094 | { |
| 3095 | pChannelSet->interChannelOffset = 1; |
| 3096 | f2GHzInfoFound = TRUE; |
| 3097 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3098 | else if ( (CSR_IS_CHANNEL_5GHZ(pChannelSet->firstChannel)) && |
Madan Mohan Koyyalamudi | 5904d7c | 2012-09-24 13:49:03 -0700 | [diff] [blame] | 3099 | ((pChannelSet->firstChannel + ((pChannelSet->numChannels - 1) * 4)) <= CSR_MAX_5GHz_CHANNEL_NUMBER) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3100 | { |
| 3101 | pChannelSet->interChannelOffset = 4; |
| 3102 | f2GHzInfoFound = FALSE; |
| 3103 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3104 | else |
| 3105 | { |
Madan Mohan Koyyalamudi | 5904d7c | 2012-09-24 13:49:03 -0700 | [diff] [blame] | 3106 | smsLog( pMac, LOGW, FL("Invalid Channel %d Present in Country IE"), |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3107 | pChannelSet->firstChannel); |
| 3108 | palFreeMemory(pMac->hHdd, pChannelSet); |
| 3109 | return eHAL_STATUS_FAILURE; |
| 3110 | } |
| 3111 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3112 | pChannelSet->txPower = CSR_ROAM_MIN( pChannelInfo->maxTxPower, pMac->roam.configParam.nTxPowerCap ); |
| 3113 | |
| 3114 | if( f2GHzInfoFound ) |
| 3115 | { |
| 3116 | if( !f2GListPurged ) |
| 3117 | { |
| 3118 | // purge previous results if found new |
| 3119 | csrPurgeChannelPower( pMac, &pMac->scan.channelPowerInfoList24 ); |
| 3120 | f2GListPurged = TRUE; |
| 3121 | } |
| 3122 | |
| 3123 | if(CSR_IS_OPERATING_BG_BAND(pMac)) |
| 3124 | { |
| 3125 | // add to the list of 2.4 GHz channel sets |
| 3126 | csrLLInsertTail( &pMac->scan.channelPowerInfoList24, &pChannelSet->link, LL_ACCESS_LOCK ); |
| 3127 | } |
| 3128 | else { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 3129 | 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] | 3130 | pChannelSet->firstChannel); |
| 3131 | palFreeMemory(pMac->hHdd, pChannelSet); |
| 3132 | } |
| 3133 | } |
| 3134 | else |
| 3135 | { |
| 3136 | // 5GHz info found |
| 3137 | if( !f5GListPurged ) |
| 3138 | { |
| 3139 | // purge previous results if found new |
| 3140 | csrPurgeChannelPower( pMac, &pMac->scan.channelPowerInfoList5G ); |
| 3141 | f5GListPurged = TRUE; |
| 3142 | } |
| 3143 | |
| 3144 | if(CSR_IS_OPERATING_A_BAND(pMac)) |
| 3145 | { |
| 3146 | // add to the list of 5GHz channel sets |
| 3147 | csrLLInsertTail( &pMac->scan.channelPowerInfoList5G, &pChannelSet->link, LL_ACCESS_LOCK ); |
| 3148 | } |
| 3149 | else { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 3150 | 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] | 3151 | pChannelSet->firstChannel); |
| 3152 | palFreeMemory(pMac->hHdd, pChannelSet); |
| 3153 | } |
| 3154 | } |
| 3155 | } |
| 3156 | |
| 3157 | pChannelInfo++; // move to next entry |
| 3158 | } |
| 3159 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3160 | return eHAL_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3161 | } |
| 3162 | |
Gopichand Nakkala | c178ac8 | 2013-05-30 19:53:39 +0530 | [diff] [blame] | 3163 | static void csrClearDfsChannelList( tpAniSirGlobal pMac ) |
| 3164 | { |
| 3165 | tSirMbMsg *pMsg; |
| 3166 | tANI_U16 msgLen; |
| 3167 | eHalStatus status = eHAL_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3168 | |
Gopichand Nakkala | c178ac8 | 2013-05-30 19:53:39 +0530 | [diff] [blame] | 3169 | msgLen = (tANI_U16)(sizeof( tSirMbMsg )); |
| 3170 | status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen); |
| 3171 | if(HAL_STATUS_SUCCESS(status)) |
| 3172 | { |
| 3173 | palZeroMemory(pMac->hHdd, (void *)pMsg, msgLen); |
| 3174 | pMsg->type = pal_cpu_to_be16((tANI_U16)eWNI_SME_CLEAR_DFS_CHANNEL_LIST); |
| 3175 | pMsg->msgLen = pal_cpu_to_be16(msgLen); |
| 3176 | palSendMBMessage(pMac->hHdd, pMsg); |
| 3177 | } |
| 3178 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3179 | |
| 3180 | void csrApplyPower2Current( tpAniSirGlobal pMac ) |
| 3181 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 3182 | smsLog( pMac, LOG3, FL(" Updating Cfg with power settings")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3183 | csrSaveTxPowerToCfg( pMac, &pMac->scan.channelPowerInfoList24, WNI_CFG_MAX_TX_POWER_2_4 ); |
| 3184 | csrSaveTxPowerToCfg( pMac, &pMac->scan.channelPowerInfoList5G, WNI_CFG_MAX_TX_POWER_5 ); |
| 3185 | } |
| 3186 | |
| 3187 | |
Gopichand Nakkala | b9185f2 | 2012-12-21 08:03:42 -0800 | [diff] [blame] | 3188 | void csrApplyChannelPowerCountryInfo( tpAniSirGlobal pMac, tCsrChannel *pChannelList, tANI_U8 *countryCode, tANI_BOOLEAN updateRiva) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3189 | { |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 3190 | int i, j, count, countryIndex = -1; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3191 | eNVChannelEnabledType channelEnabledType; |
| 3192 | tANI_U8 numChannels = 0; |
| 3193 | tANI_U8 tempNumChannels = 0; |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 3194 | tANI_U8 channelIgnore = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3195 | tCsrChannel ChannelList; |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 3196 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3197 | if( pChannelList->numChannels ) |
| 3198 | { |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 3199 | for(count=0; count < MAX_COUNTRY_IGNORE; count++) |
| 3200 | { |
| 3201 | if(vos_mem_compare(countryCode, countryIgnoreList[count].countryCode, |
| 3202 | VOS_COUNTRY_CODE_LEN)) |
| 3203 | { |
| 3204 | countryIndex = count; |
| 3205 | break; |
| 3206 | } |
| 3207 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3208 | tempNumChannels = CSR_MIN(pChannelList->numChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 3209 | /* If user doesn't want to scan the DFS channels lets trim them from |
| 3210 | the valid channel list*/ |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 3211 | for(i=0; i < tempNumChannels; i++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3212 | { |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 3213 | channelIgnore = FALSE; |
| 3214 | if( FALSE == pMac->scan.fEnableDFSChnlScan ) |
| 3215 | { |
| 3216 | channelEnabledType = |
| 3217 | vos_nv_getChannelEnabledState(pChannelList->channelList[i]); |
| 3218 | } |
| 3219 | else |
| 3220 | { |
Madan Mohan Koyyalamudi | 3f65e31 | 2012-11-06 15:31:12 -0800 | [diff] [blame] | 3221 | channelEnabledType = NV_CHANNEL_ENABLE; |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 3222 | } |
| 3223 | if( NV_CHANNEL_ENABLE == channelEnabledType ) |
| 3224 | { |
| 3225 | if( countryIndex != -1 ) |
| 3226 | { |
| 3227 | for(j=0; j < countryIgnoreList[countryIndex].channelCount; j++) |
| 3228 | { |
| 3229 | if( pChannelList->channelList[i] == |
| 3230 | countryIgnoreList[countryIndex].channelList[j] ) |
| 3231 | { |
| 3232 | channelIgnore = TRUE; |
| 3233 | break; |
| 3234 | } |
| 3235 | } |
| 3236 | } |
| 3237 | if( FALSE == channelIgnore ) |
| 3238 | { |
| 3239 | ChannelList.channelList[numChannels] = pChannelList->channelList[i]; |
| 3240 | numChannels++; |
| 3241 | } |
| 3242 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3243 | } |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 3244 | ChannelList.numChannels = numChannels; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3245 | csrSetCfgValidChannelList(pMac, ChannelList.channelList, ChannelList.numChannels); |
| 3246 | // extend scan capability |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 3247 | // build a scan list based on the channel list : channel# + active/passive scan |
| 3248 | csrSetCfgScanControlList(pMac, countryCode, &ChannelList); |
Gopichand Nakkala | c178ac8 | 2013-05-30 19:53:39 +0530 | [diff] [blame] | 3249 | /*Send msg to Lim to clear DFS channel list */ |
| 3250 | csrClearDfsChannelList(pMac); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3251 | #ifdef FEATURE_WLAN_SCAN_PNO |
Gopichand Nakkala | b9185f2 | 2012-12-21 08:03:42 -0800 | [diff] [blame] | 3252 | if (updateRiva) |
| 3253 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 3254 | 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] | 3255 | // Send HAL UpdateScanParams message |
| 3256 | pmcUpdateScanParams(pMac, &(pMac->roam.configParam), &ChannelList, TRUE); |
| 3257 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3258 | #endif // FEATURE_WLAN_SCAN_PNO |
| 3259 | } |
| 3260 | else |
| 3261 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 3262 | smsLog( pMac, LOGE, FL(" 11D channel list is empty")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3263 | } |
| 3264 | csrApplyPower2Current( pMac ); // Store the channel+power info in the global place: Cfg |
| 3265 | csrSetCfgCountryCode(pMac, countryCode); |
| 3266 | } |
| 3267 | |
| 3268 | |
Gopichand Nakkala | b9185f2 | 2012-12-21 08:03:42 -0800 | [diff] [blame] | 3269 | void csrResetCountryInformation( tpAniSirGlobal pMac, tANI_BOOLEAN fForce, tANI_BOOLEAN updateRiva ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3270 | { |
| 3271 | if( fForce || (csrIs11dSupported( pMac ) && (!pMac->scan.f11dInfoReset))) |
| 3272 | { |
| 3273 | |
| 3274 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 3275 | { |
| 3276 | vos_log_802_11d_pkt_type *p11dLog; |
| 3277 | int Index; |
| 3278 | |
| 3279 | WLAN_VOS_DIAG_LOG_ALLOC(p11dLog, vos_log_802_11d_pkt_type, LOG_WLAN_80211D_C); |
| 3280 | if(p11dLog) |
| 3281 | { |
| 3282 | p11dLog->eventId = WLAN_80211D_EVENT_RESET; |
| 3283 | palCopyMemory(pMac->hHdd, p11dLog->countryCode, pMac->scan.countryCodeCurrent, 3); |
| 3284 | p11dLog->numChannel = pMac->scan.base20MHzChannels.numChannels; |
| 3285 | if(p11dLog->numChannel <= VOS_LOG_MAX_NUM_CHANNEL) |
| 3286 | { |
| 3287 | palCopyMemory(pMac->hHdd, p11dLog->Channels, pMac->scan.base20MHzChannels.channelList, |
| 3288 | p11dLog->numChannel); |
| 3289 | for (Index=0; Index < pMac->scan.base20MHzChannels.numChannels; Index++) |
| 3290 | { |
| 3291 | p11dLog->TxPwr[Index] = CSR_ROAM_MIN( pMac->scan.defaultPowerTable[Index].pwr, pMac->roam.configParam.nTxPowerCap ); |
| 3292 | } |
| 3293 | } |
| 3294 | if(!pMac->roam.configParam.Is11dSupportEnabled) |
| 3295 | { |
| 3296 | p11dLog->supportMultipleDomain = WLAN_80211D_DISABLED; |
| 3297 | } |
| 3298 | else if(pMac->roam.configParam.fEnforceDefaultDomain) |
| 3299 | { |
| 3300 | p11dLog->supportMultipleDomain = WLAN_80211D_NOT_SUPPORT_MULTI_DOMAIN; |
| 3301 | } |
| 3302 | else |
| 3303 | { |
| 3304 | p11dLog->supportMultipleDomain = WLAN_80211D_SUPPORT_MULTI_DOMAIN; |
| 3305 | } |
| 3306 | WLAN_VOS_DIAG_LOG_REPORT(p11dLog); |
| 3307 | } |
| 3308 | } |
| 3309 | #endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 3310 | |
| 3311 | // switch to passive scans only when 11d is enabled |
| 3312 | if( csrIs11dSupported( pMac ) ) |
| 3313 | { |
| 3314 | pMac->scan.curScanType = eSIR_PASSIVE_SCAN; |
| 3315 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3316 | |
| 3317 | csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels); |
| 3318 | csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels); |
| 3319 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3320 | csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE); |
| 3321 | csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE); |
| 3322 | // ... and apply the channel list, power settings, and the country code. |
Gopichand Nakkala | b9185f2 | 2012-12-21 08:03:42 -0800 | [diff] [blame] | 3323 | csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, updateRiva ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3324 | // clear the 11d channel list |
| 3325 | palZeroMemory( pMac->hHdd, &pMac->scan.channels11d, sizeof(pMac->scan.channels11d) ); |
| 3326 | pMac->scan.f11dInfoReset = eANI_BOOLEAN_TRUE; |
| 3327 | pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE; |
| 3328 | } |
| 3329 | |
| 3330 | return; |
| 3331 | } |
| 3332 | |
| 3333 | |
| 3334 | eHalStatus csrResetCountryCodeInformation(tpAniSirGlobal pMac, tANI_BOOLEAN *pfRestartNeeded) |
| 3335 | { |
| 3336 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 3337 | tANI_BOOLEAN fRestart = eANI_BOOLEAN_FALSE; |
| 3338 | |
| 3339 | //Use the Country code and domain from EEPROM |
| 3340 | palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN); |
| 3341 | csrSetRegulatoryDomain(pMac, pMac->scan.domainIdCurrent, &fRestart); |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 3342 | if( ((eANI_BOOLEAN_FALSE == fRestart) || (pfRestartNeeded == NULL) ) |
| 3343 | && !csrIsInfraConnected(pMac)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3344 | { |
| 3345 | //Only reset the country info if we don't need to restart |
Gopichand Nakkala | b9185f2 | 2012-12-21 08:03:42 -0800 | [diff] [blame] | 3346 | csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3347 | } |
| 3348 | if(pfRestartNeeded) |
| 3349 | { |
| 3350 | *pfRestartNeeded = fRestart; |
| 3351 | } |
| 3352 | |
| 3353 | return (status); |
| 3354 | } |
| 3355 | |
| 3356 | |
| 3357 | eHalStatus csrSetCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry, tANI_BOOLEAN *pfRestartNeeded) |
| 3358 | { |
| 3359 | eHalStatus status = eHAL_STATUS_INVALID_PARAMETER; |
| 3360 | v_REGDOMAIN_t domainId; |
| 3361 | |
| 3362 | if(pCountry) |
| 3363 | { |
| 3364 | status = csrGetRegulatoryDomainForCountry(pMac, pCountry, &domainId); |
| 3365 | if(HAL_STATUS_SUCCESS(status)) |
| 3366 | { |
| 3367 | status = csrSetRegulatoryDomain(pMac, domainId, pfRestartNeeded); |
| 3368 | if(HAL_STATUS_SUCCESS(status)) |
| 3369 | { |
| 3370 | //We don't need to check the pMac->roam.configParam.fEnforceDefaultDomain flag here, |
| 3371 | //csrSetRegulatoryDomain will fail if the country doesn't fit our domain criteria. |
| 3372 | palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent, pCountry, WNI_CFG_COUNTRY_CODE_LEN); |
| 3373 | if((pfRestartNeeded == NULL) || !(*pfRestartNeeded)) |
| 3374 | { |
| 3375 | //Simply set it to cfg. If we need to restart, restart will apply it to the CFG |
| 3376 | csrSetCfgCountryCode(pMac, pCountry); |
| 3377 | } |
| 3378 | } |
| 3379 | } |
| 3380 | } |
| 3381 | |
| 3382 | return (status); |
| 3383 | } |
| 3384 | |
| 3385 | |
| 3386 | |
| 3387 | //caller allocated memory for pNumChn and pChnPowerInfo |
| 3388 | //As input, *pNumChn has the size of the array of pChnPowerInfo |
| 3389 | //Upon return, *pNumChn has the number of channels assigned. |
| 3390 | void csrGetChannelPowerInfo( tpAniSirGlobal pMac, tDblLinkList *pList, |
| 3391 | tANI_U32 *pNumChn, tChannelListWithPower *pChnPowerInfo) |
| 3392 | { |
| 3393 | tListElem *pEntry; |
| 3394 | tANI_U32 chnIdx = 0, idx; |
| 3395 | tCsrChannelPowerInfo *pChannelSet; |
| 3396 | |
| 3397 | //Get 2.4Ghz first |
| 3398 | pEntry = csrLLPeekHead( pList, LL_ACCESS_LOCK ); |
| 3399 | while( pEntry && (chnIdx < *pNumChn) ) |
| 3400 | { |
| 3401 | pChannelSet = GET_BASE_ADDR( pEntry, tCsrChannelPowerInfo, link ); |
| 3402 | if ( 1 != pChannelSet->interChannelOffset ) |
| 3403 | { |
| 3404 | for( idx = 0; (idx < pChannelSet->numChannels) && (chnIdx < *pNumChn); idx++ ) |
| 3405 | { |
| 3406 | pChnPowerInfo[chnIdx].chanId = (tANI_U8)(pChannelSet->firstChannel + ( idx * pChannelSet->interChannelOffset )); |
| 3407 | pChnPowerInfo[chnIdx++].pwr = pChannelSet->txPower; |
| 3408 | } |
| 3409 | } |
| 3410 | else |
| 3411 | { |
| 3412 | for( idx = 0; (idx < pChannelSet->numChannels) && (chnIdx < *pNumChn); idx++ ) |
| 3413 | { |
| 3414 | pChnPowerInfo[chnIdx].chanId = (tANI_U8)(pChannelSet->firstChannel + idx); |
| 3415 | pChnPowerInfo[chnIdx++].pwr = pChannelSet->txPower; |
| 3416 | } |
| 3417 | } |
| 3418 | |
| 3419 | pEntry = csrLLNext( pList, pEntry, LL_ACCESS_LOCK ); |
| 3420 | } |
| 3421 | *pNumChn = chnIdx; |
| 3422 | |
| 3423 | return ; |
| 3424 | } |
| 3425 | |
| 3426 | |
| 3427 | |
| 3428 | void csrApplyCountryInformation( tpAniSirGlobal pMac, tANI_BOOLEAN fForce ) |
| 3429 | { |
| 3430 | v_REGDOMAIN_t domainId; |
| 3431 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 3432 | |
| 3433 | do |
| 3434 | { |
| 3435 | if( !csrIs11dSupported( pMac ) || 0 == pMac->scan.channelOf11dInfo) break; |
| 3436 | if( pMac->scan.fAmbiguous11dInfoFound ) |
| 3437 | { |
| 3438 | // ambiguous info found |
| 3439 | //Restore te default domain as well |
| 3440 | if(HAL_STATUS_SUCCESS(csrGetRegulatoryDomainForCountry( pMac, pMac->scan.countryCodeCurrent, &domainId ))) |
| 3441 | { |
| 3442 | pMac->scan.domainIdCurrent = domainId; |
| 3443 | } |
| 3444 | else |
| 3445 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 3446 | smsLog(pMac, LOGE, FL(" failed to get domain from currentCountryCode %02X%02X"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3447 | pMac->scan.countryCodeCurrent[0], pMac->scan.countryCodeCurrent[1]); |
| 3448 | } |
Gopichand Nakkala | b9185f2 | 2012-12-21 08:03:42 -0800 | [diff] [blame] | 3449 | csrResetCountryInformation( pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_TRUE ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3450 | break; |
| 3451 | } |
| 3452 | if ( pMac->scan.f11dInfoApplied && !fForce ) break; |
| 3453 | if(HAL_STATUS_SUCCESS(csrGetRegulatoryDomainForCountry( pMac, pMac->scan.countryCode11d, &domainId ))) |
| 3454 | { |
| 3455 | //Check whether we need to enforce default domain |
| 3456 | if( ( !pMac->roam.configParam.fEnforceDefaultDomain ) || |
| 3457 | (pMac->scan.domainIdCurrent == domainId) ) |
| 3458 | { |
| 3459 | |
| 3460 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 3461 | { |
| 3462 | vos_log_802_11d_pkt_type *p11dLog; |
| 3463 | tChannelListWithPower chnPwrInfo[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 3464 | tANI_U32 nChnInfo = WNI_CFG_VALID_CHANNEL_LIST_LEN, nTmp; |
| 3465 | |
| 3466 | WLAN_VOS_DIAG_LOG_ALLOC(p11dLog, vos_log_802_11d_pkt_type, LOG_WLAN_80211D_C); |
| 3467 | if(p11dLog) |
| 3468 | { |
| 3469 | p11dLog->eventId = WLAN_80211D_EVENT_COUNTRY_SET; |
| 3470 | palCopyMemory(pMac->hHdd, p11dLog->countryCode, pMac->scan.countryCode11d, 3); |
| 3471 | p11dLog->numChannel = pMac->scan.channels11d.numChannels; |
| 3472 | if(p11dLog->numChannel <= VOS_LOG_MAX_NUM_CHANNEL) |
| 3473 | { |
| 3474 | palCopyMemory(pMac->hHdd, p11dLog->Channels, pMac->scan.channels11d.channelList, |
| 3475 | p11dLog->numChannel); |
| 3476 | csrGetChannelPowerInfo(pMac, &pMac->scan.channelPowerInfoList24, |
| 3477 | &nChnInfo, chnPwrInfo); |
| 3478 | nTmp = nChnInfo; |
| 3479 | nChnInfo = WNI_CFG_VALID_CHANNEL_LIST_LEN - nTmp; |
| 3480 | csrGetChannelPowerInfo(pMac, &pMac->scan.channelPowerInfoList5G, |
| 3481 | &nChnInfo, &chnPwrInfo[nTmp]); |
| 3482 | for(nTmp = 0; nTmp < p11dLog->numChannel; nTmp++) |
| 3483 | { |
| 3484 | for(nChnInfo = 0; nChnInfo < WNI_CFG_VALID_CHANNEL_LIST_LEN; nChnInfo++) |
| 3485 | { |
| 3486 | if(p11dLog->Channels[nTmp] == chnPwrInfo[nChnInfo].chanId) |
| 3487 | { |
| 3488 | p11dLog->TxPwr[nTmp] = chnPwrInfo[nChnInfo].pwr; |
| 3489 | break; |
| 3490 | } |
| 3491 | } |
| 3492 | } |
| 3493 | } |
| 3494 | if(!pMac->roam.configParam.Is11dSupportEnabled) |
| 3495 | { |
| 3496 | p11dLog->supportMultipleDomain = WLAN_80211D_DISABLED; |
| 3497 | } |
| 3498 | else if(pMac->roam.configParam.fEnforceDefaultDomain) |
| 3499 | { |
| 3500 | p11dLog->supportMultipleDomain = WLAN_80211D_NOT_SUPPORT_MULTI_DOMAIN; |
| 3501 | } |
| 3502 | else |
| 3503 | { |
| 3504 | p11dLog->supportMultipleDomain = WLAN_80211D_SUPPORT_MULTI_DOMAIN; |
| 3505 | } |
| 3506 | WLAN_VOS_DIAG_LOG_REPORT(p11dLog); |
| 3507 | } |
| 3508 | } |
| 3509 | #endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 3510 | if(pMac->scan.domainIdCurrent != domainId) |
| 3511 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3512 | smsLog(pMac, LOGW, FL("Domain Changed Old %d, new %d"), |
| 3513 | pMac->scan.domainIdCurrent, domainId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3514 | } |
| 3515 | status = WDA_SetRegDomain(pMac, domainId); |
| 3516 | if (status != eHAL_STATUS_SUCCESS) |
| 3517 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 3518 | smsLog( pMac, LOGE, FL(" fail to set regId %d"), domainId ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3519 | } |
| 3520 | pMac->scan.domainIdCurrent = domainId; |
Gopichand Nakkala | b9185f2 | 2012-12-21 08:03:42 -0800 | [diff] [blame] | 3521 | csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.channels11d, pMac->scan.countryCode11d, eANI_BOOLEAN_TRUE ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3522 | // switch to active scans using this new channel list |
| 3523 | pMac->scan.curScanType = eSIR_ACTIVE_SCAN; |
| 3524 | pMac->scan.f11dInfoApplied = eANI_BOOLEAN_TRUE; |
| 3525 | pMac->scan.f11dInfoReset = eANI_BOOLEAN_FALSE; |
| 3526 | } |
| 3527 | } |
| 3528 | |
| 3529 | } while( 0 ); |
| 3530 | |
| 3531 | return; |
| 3532 | } |
| 3533 | |
| 3534 | |
| 3535 | |
| 3536 | tANI_BOOLEAN csrSave11dCountryString( tpAniSirGlobal pMac, tANI_U8 *pCountryCode, |
| 3537 | tANI_BOOLEAN fForce) |
| 3538 | { |
| 3539 | tANI_BOOLEAN fCountryStringChanged = FALSE, fUnknownCountryCode = FALSE; |
| 3540 | tANI_U32 i; |
| 3541 | |
| 3542 | // convert to UPPER here so we are assured the strings are always in upper case. |
| 3543 | for( i = 0; i < 3; i++ ) |
| 3544 | { |
| 3545 | pCountryCode[ i ] = (tANI_U8)csrToUpper( pCountryCode[ i ] ); |
| 3546 | } |
| 3547 | |
| 3548 | // Some of the 'old' Cisco 350 series AP's advertise NA as the country code (for North America ??). |
| 3549 | // NA is not a valid country code or domain so let's allow this by changing it to the proper |
| 3550 | // country code (which is US). We've also seen some NETGEAR AP's that have "XX " as the country code |
| 3551 | // with valid 2.4 GHz US channel information. If we cannot find the country code advertised in the |
| 3552 | // 11d information element, let's default to US. |
| 3553 | if ( !HAL_STATUS_SUCCESS(csrGetRegulatoryDomainForCountry( pMac, pCountryCode, NULL ) ) ) |
| 3554 | { |
| 3555 | // Check the enforcement first |
| 3556 | if( pMac->roam.configParam.fEnforceDefaultDomain || pMac->roam.configParam.fEnforceCountryCodeMatch ) |
| 3557 | { |
| 3558 | fUnknownCountryCode = TRUE; |
| 3559 | } |
| 3560 | else |
| 3561 | { |
| 3562 | pCountryCode[ 0 ] = 'U'; |
| 3563 | pCountryCode[ 1 ] = 'S'; |
| 3564 | } |
| 3565 | } |
| 3566 | |
| 3567 | // We've seen some of the AP's improperly put a 0 for the third character of the country code. |
| 3568 | // spec says valid charcters are 'O' (for outdoor), 'I' for Indoor, or ' ' (space; for either). |
| 3569 | // if we see a 0 in this third character, let's change it to a ' '. |
| 3570 | if ( 0 == pCountryCode[ 2 ] ) |
| 3571 | { |
| 3572 | pCountryCode[ 2 ] = ' '; |
| 3573 | } |
| 3574 | |
| 3575 | if( !fUnknownCountryCode ) |
| 3576 | { |
| 3577 | fCountryStringChanged = (!palEqualMemory( pMac->hHdd, |
| 3578 | pMac->scan.countryCode11d, pCountryCode, 2)); |
| 3579 | |
| 3580 | |
| 3581 | if(( 0 == pMac->scan.countryCode11d[ 0 ] && 0 == pMac->scan.countryCode11d[ 1 ] ) |
| 3582 | || (fForce)) |
| 3583 | { |
| 3584 | // this is the first .11d information |
| 3585 | palCopyMemory( pMac->hHdd, pMac->scan.countryCode11d, pCountryCode, sizeof( pMac->scan.countryCode11d ) ); |
| 3586 | } |
| 3587 | } |
| 3588 | |
| 3589 | return( fCountryStringChanged ); |
| 3590 | } |
| 3591 | |
| 3592 | |
| 3593 | void csrSaveChannelPowerForBand( tpAniSirGlobal pMac, tANI_BOOLEAN fPopulate5GBand ) |
| 3594 | { |
| 3595 | tANI_U32 Index, count=0; |
| 3596 | tSirMacChanInfo *pChanInfo; |
| 3597 | tSirMacChanInfo *pChanInfoStart; |
Leela V Kiran Kumar Reddy Chirala | 6a45875 | 2013-02-16 15:41:27 -0800 | [diff] [blame] | 3598 | tANI_S32 maxChannelIndex; |
| 3599 | |
| 3600 | maxChannelIndex = ( pMac->scan.base20MHzChannels.numChannels < WNI_CFG_VALID_CHANNEL_LIST_LEN ) ? |
| 3601 | pMac->scan.base20MHzChannels.numChannels : WNI_CFG_VALID_CHANNEL_LIST_LEN ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3602 | |
| 3603 | if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN))) |
| 3604 | { |
| 3605 | palZeroMemory(pMac->hHdd, pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 3606 | pChanInfoStart = pChanInfo; |
Leela V Kiran Kumar Reddy Chirala | 6a45875 | 2013-02-16 15:41:27 -0800 | [diff] [blame] | 3607 | for (Index=0; Index < maxChannelIndex; Index++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3608 | { |
| 3609 | if ((fPopulate5GBand && (CSR_IS_CHANNEL_5GHZ(pMac->scan.defaultPowerTable[Index].chanId))) || |
| 3610 | (!fPopulate5GBand && (CSR_IS_CHANNEL_24GHZ(pMac->scan.defaultPowerTable[Index].chanId))) ) |
| 3611 | { |
Leela V Kiran Kumar Reddy Chirala | 6a45875 | 2013-02-16 15:41:27 -0800 | [diff] [blame] | 3612 | if(count >= WNI_CFG_VALID_CHANNEL_LIST_LEN) |
| 3613 | { |
| 3614 | smsLog( pMac, LOGW, FL(" csrSaveChannelPowerForBand, count exceeded, count = %d"), count); |
| 3615 | break; |
| 3616 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3617 | pChanInfo->firstChanNum = pMac->scan.defaultPowerTable[Index].chanId; |
| 3618 | pChanInfo->numChannels = 1; |
| 3619 | pChanInfo->maxTxPower = CSR_ROAM_MIN( pMac->scan.defaultPowerTable[Index].pwr, pMac->roam.configParam.nTxPowerCap ); |
| 3620 | pChanInfo++; |
| 3621 | count++; |
| 3622 | } |
| 3623 | } |
| 3624 | if(count) |
| 3625 | { |
| 3626 | csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart ); |
| 3627 | } |
| 3628 | palFreeMemory(pMac->hHdd, pChanInfoStart); |
| 3629 | } |
| 3630 | } |
| 3631 | |
| 3632 | |
| 3633 | void csrSetOppositeBandChannelInfo( tpAniSirGlobal pMac ) |
| 3634 | { |
| 3635 | tANI_BOOLEAN fPopulate5GBand = FALSE; |
| 3636 | |
| 3637 | do |
| 3638 | { |
| 3639 | // if this is not a dual band product, then we don't need to set the opposite |
| 3640 | // band info. We only work in one band so no need to look in the other band. |
| 3641 | if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) ) break; |
| 3642 | // if we found channel info on the 5.0 band and... |
| 3643 | if ( CSR_IS_CHANNEL_5GHZ( pMac->scan.channelOf11dInfo ) ) |
| 3644 | { |
| 3645 | // and the 2.4 band is empty, then populate the 2.4 channel info |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3646 | fPopulate5GBand = FALSE; |
| 3647 | } |
| 3648 | else |
| 3649 | { |
| 3650 | // else, we found channel info in the 2.4 GHz band. If the 5.0 band is empty |
| 3651 | // set the 5.0 band info from the 2.4 country code. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3652 | fPopulate5GBand = TRUE; |
| 3653 | } |
| 3654 | csrSaveChannelPowerForBand( pMac, fPopulate5GBand ); |
| 3655 | |
| 3656 | } while( 0 ); |
| 3657 | } |
| 3658 | |
| 3659 | |
| 3660 | tANI_BOOLEAN csrIsSupportedChannel(tpAniSirGlobal pMac, tANI_U8 channelId) |
| 3661 | { |
| 3662 | tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE; |
| 3663 | tANI_U32 i; |
| 3664 | |
| 3665 | //Make sure it is a channel that is in our supported list. |
| 3666 | for ( i = 0; i < pMac->scan.baseChannels.numChannels; i++ ) |
| 3667 | { |
| 3668 | if ( channelId == pMac->scan.baseChannels.channelList[i] ) |
| 3669 | { |
| 3670 | fRet = eANI_BOOLEAN_TRUE; |
| 3671 | break; |
| 3672 | } |
| 3673 | } |
| 3674 | |
| 3675 | //If it is configured to limit a set of the channels |
| 3676 | if( fRet && pMac->roam.configParam.fEnforce11dChannels ) |
| 3677 | { |
| 3678 | fRet = eANI_BOOLEAN_FALSE; |
| 3679 | for ( i = 0; i < pMac->scan.base20MHzChannels.numChannels; i++ ) |
| 3680 | { |
| 3681 | if ( channelId == pMac->scan.base20MHzChannels.channelList[i] ) |
| 3682 | { |
| 3683 | fRet = eANI_BOOLEAN_TRUE; |
| 3684 | break; |
| 3685 | } |
| 3686 | } |
| 3687 | } |
| 3688 | |
| 3689 | return (fRet); |
| 3690 | } |
| 3691 | |
| 3692 | |
| 3693 | |
| 3694 | //bSize specify the buffer size of pChannelList |
| 3695 | tANI_U8 csrGetChannelListFromChannelSet( tpAniSirGlobal pMac, tANI_U8 *pChannelList, tANI_U8 bSize, tCsrChannelPowerInfo *pChannelSet ) |
| 3696 | { |
| 3697 | tANI_U8 i, j = 0, chnId; |
| 3698 | |
| 3699 | bSize = CSR_MIN(bSize, pChannelSet->numChannels); |
| 3700 | for( i = 0; i < bSize; i++ ) |
| 3701 | { |
| 3702 | chnId = (tANI_U8)(pChannelSet->firstChannel + ( i * pChannelSet->interChannelOffset )); |
| 3703 | if ( csrIsSupportedChannel( pMac, chnId ) ) |
| 3704 | { |
| 3705 | pChannelList[j++] = chnId; |
| 3706 | } |
| 3707 | } |
| 3708 | |
| 3709 | return (j); |
| 3710 | } |
| 3711 | |
| 3712 | |
| 3713 | |
| 3714 | //bSize -- specify the buffer size of pChannelList |
| 3715 | void csrConstructCurrentValidChannelList( tpAniSirGlobal pMac, tDblLinkList *pChannelSetList, |
| 3716 | tANI_U8 *pChannelList, tANI_U8 bSize, tANI_U8 *pNumChannels ) |
| 3717 | { |
| 3718 | tListElem *pEntry; |
| 3719 | tCsrChannelPowerInfo *pChannelSet; |
| 3720 | tANI_U8 numChannels; |
| 3721 | tANI_U8 *pChannels; |
| 3722 | |
| 3723 | if( pChannelSetList && pChannelList && pNumChannels ) |
| 3724 | { |
| 3725 | pChannels = pChannelList; |
| 3726 | *pNumChannels = 0; |
| 3727 | pEntry = csrLLPeekHead( pChannelSetList, LL_ACCESS_LOCK ); |
| 3728 | while( pEntry ) |
| 3729 | { |
| 3730 | pChannelSet = GET_BASE_ADDR( pEntry, tCsrChannelPowerInfo, link ); |
| 3731 | numChannels = csrGetChannelListFromChannelSet( pMac, pChannels, bSize, pChannelSet ); |
| 3732 | pChannels += numChannels; |
| 3733 | *pNumChannels += numChannels; |
| 3734 | pEntry = csrLLNext( pChannelSetList, pEntry, LL_ACCESS_LOCK ); |
| 3735 | } |
| 3736 | } |
| 3737 | } |
| 3738 | |
| 3739 | |
| 3740 | /* |
| 3741 | * 802.11D only: Gather 11d IE via beacon or Probe response and store them in pAdapter->channels11d |
| 3742 | */ |
| 3743 | tANI_BOOLEAN csrLearnCountryInformation( tpAniSirGlobal pMac, tSirBssDescription *pSirBssDesc, |
| 3744 | tDot11fBeaconIEs *pIes, tANI_BOOLEAN fForce) |
| 3745 | { |
| 3746 | tANI_U8 Num2GChannels, bMaxNumChn; |
| 3747 | eHalStatus status; |
| 3748 | tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE; |
| 3749 | v_REGDOMAIN_t domainId; |
| 3750 | tDot11fBeaconIEs *pIesLocal = pIes; |
| 3751 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3752 | if (VOS_STA_SAP_MODE == vos_get_conparam ()) |
| 3753 | return eHAL_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3754 | |
| 3755 | do |
| 3756 | { |
| 3757 | // check if .11d support is enabled |
| 3758 | if( !csrIs11dSupported( pMac ) ) break; |
| 3759 | if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) ) |
| 3760 | { |
| 3761 | break; |
| 3762 | } |
| 3763 | // check if country information element is present |
| 3764 | if(!pIesLocal->Country.present) |
| 3765 | { |
| 3766 | //No country info |
| 3767 | break; |
| 3768 | } |
| 3769 | |
| 3770 | if( csrSave11dCountryString( pMac, pIesLocal->Country.country, fForce ) ) |
| 3771 | { |
| 3772 | // country string changed, this should not happen |
| 3773 | //Need to check whether we care about this BSS' domain info |
| 3774 | //If it doesn't match of the connected profile or roaming profile, let's ignore it |
| 3775 | tANI_U32 i; |
| 3776 | tCsrRoamSession *pSession; |
| 3777 | |
| 3778 | for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ ) |
| 3779 | { |
| 3780 | if( CSR_IS_SESSION_VALID( pMac, i ) ) |
| 3781 | { |
| 3782 | pSession = CSR_GET_SESSION( pMac, i ); |
| 3783 | if(pSession->pCurRoamProfile) |
| 3784 | { |
| 3785 | tCsrScanResultFilter filter; |
| 3786 | |
| 3787 | palZeroMemory(pMac->hHdd, &filter, sizeof(tCsrScanResultFilter)); |
| 3788 | status = csrRoamPrepareFilterFromProfile(pMac, pSession->pCurRoamProfile, &filter); |
| 3789 | if(HAL_STATUS_SUCCESS(status)) |
| 3790 | { |
| 3791 | tANI_BOOLEAN fMatch = csrMatchBSS(pMac, pSirBssDesc, &filter, NULL, NULL, NULL, NULL); |
| 3792 | //Free the resource first |
| 3793 | csrFreeScanFilter( pMac, &filter ); |
| 3794 | if(fMatch) |
| 3795 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 3796 | 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] | 3797 | pSirBssDesc->bssId[0], pSirBssDesc->bssId[1], pSirBssDesc->bssId[2], |
| 3798 | pSirBssDesc->bssId[3], pSirBssDesc->bssId[4], pSirBssDesc->bssId[5]); |
| 3799 | pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_TRUE; |
| 3800 | break; |
| 3801 | } |
| 3802 | } |
| 3803 | } |
| 3804 | else if( csrIsConnStateConnected(pMac, i)) |
| 3805 | { |
| 3806 | //Reach here only when the currention is base on no profile. |
| 3807 | //User doesn't give profile and just connect to anything. |
| 3808 | if(csrMatchBSSToConnectProfile(pMac, &pSession->connectedProfile, pSirBssDesc, pIesLocal)) |
| 3809 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 3810 | 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] | 3811 | pSirBssDesc->bssId[0], pSirBssDesc->bssId[1], pSirBssDesc->bssId[2], |
| 3812 | pSirBssDesc->bssId[3], pSirBssDesc->bssId[4], pSirBssDesc->bssId[5]); |
| 3813 | //Tush |
| 3814 | pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_TRUE; |
| 3815 | if(csrIsBssidMatch(pMac, (tCsrBssid *)&pSirBssDesc->bssId, |
| 3816 | &pSession->connectedProfile.bssid)) |
| 3817 | { |
| 3818 | //AP changed the 11d info on the fly, modify cfg |
| 3819 | pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE; |
| 3820 | fRet = eANI_BOOLEAN_TRUE; |
| 3821 | } |
| 3822 | break; |
| 3823 | } |
| 3824 | } |
| 3825 | } //valid session |
| 3826 | } //for |
| 3827 | if ( i == CSR_ROAM_SESSION_MAX ) |
| 3828 | { |
| 3829 | //Check whether we can use this country's 11d information |
| 3830 | if( !pMac->roam.configParam.fEnforceDefaultDomain ) |
| 3831 | { |
| 3832 | pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_TRUE; |
| 3833 | } |
| 3834 | else |
| 3835 | { |
| 3836 | VOS_ASSERT( pMac->scan.domainIdCurrent == pMac->scan.domainIdDefault ); |
| 3837 | if( HAL_STATUS_SUCCESS(csrGetRegulatoryDomainForCountry( |
| 3838 | pMac, pIesLocal->Country.country, &domainId )) && |
| 3839 | ( domainId == pMac->scan.domainIdCurrent ) ) |
| 3840 | { |
| 3841 | //Two countries in the same domain |
| 3842 | } |
| 3843 | } |
| 3844 | } |
| 3845 | } |
| 3846 | else //Tush |
| 3847 | { |
| 3848 | pMac->scan.fCurrent11dInfoMatch = eANI_BOOLEAN_TRUE; |
| 3849 | } |
| 3850 | |
| 3851 | //In case that some channels in 5GHz have the same channel number as 2.4GHz (<= 14) |
| 3852 | if(CSR_IS_CHANNEL_5GHZ(pSirBssDesc->channelId)) |
| 3853 | { |
| 3854 | tANI_U8 iC; |
| 3855 | tSirMacChanInfo* pMacChnSet = (tSirMacChanInfo *)(&pIesLocal->Country.triplets[0]); |
| 3856 | |
| 3857 | for(iC = 0; iC < pIesLocal->Country.num_triplets; iC++) |
| 3858 | { |
| 3859 | if(CSR_IS_CHANNEL_24GHZ(pMacChnSet[iC].firstChanNum)) |
| 3860 | { |
| 3861 | pMacChnSet[iC].firstChanNum += 200; //*** Where is this 200 defined? |
| 3862 | } |
| 3863 | } |
| 3864 | } |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 3865 | 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] | 3866 | // save the channel/power information from the Channel IE. |
| 3867 | //sizeof(tSirMacChanInfo) has to be 3 |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3868 | if (eHAL_STATUS_SUCCESS != csrSaveToChannelPower2G_5G( pMac, pIesLocal->Country.num_triplets * sizeof(tSirMacChanInfo), |
| 3869 | (tSirMacChanInfo *)(&pIesLocal->Country.triplets[0]) )) |
| 3870 | { |
| 3871 | fRet = eANI_BOOLEAN_FALSE; |
| 3872 | return fRet; |
| 3873 | } |
| 3874 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3875 | // set the indicator of the channel where the country IE was found... |
| 3876 | pMac->scan.channelOf11dInfo = pSirBssDesc->channelId; |
Venkata Prathyusha Kuntupalli | 316247e | 2013-03-15 17:45:25 -0700 | [diff] [blame] | 3877 | csrGetRegulatoryDomainForCountry(pMac, pIesLocal->Country.country, &domainId ); |
| 3878 | // Checking for Domain Id change |
| 3879 | if ( domainId != pMac->scan.domainIdCurrent ) |
| 3880 | { |
| 3881 | tSirMacChanInfo* pMacChnSet = (tSirMacChanInfo *)(&pIesLocal->Country.triplets[0]); |
| 3882 | WDA_SetRegDomain(pMac, domainId); |
| 3883 | // Check weather AP provided the 2.4GHZ list or 5GHZ list |
| 3884 | if(CSR_IS_CHANNEL_24GHZ(pMacChnSet[0].firstChanNum)) |
| 3885 | { |
| 3886 | // AP Provided the 2.4 Channels, Update the 5GHz channels from nv.bin |
| 3887 | csrGet5GChannels(pMac ); |
| 3888 | } |
| 3889 | else |
| 3890 | { |
| 3891 | // AP Provided the 5G Channels, Update the 2.4GHZ channel list from nv.bin |
| 3892 | csrGet24GChannels(pMac ); |
| 3893 | } |
| 3894 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3895 | // Populate both band channel lists based on what we found in the country information... |
| 3896 | csrSetOppositeBandChannelInfo( pMac ); |
| 3897 | bMaxNumChn = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 3898 | // construct 2GHz channel list first |
| 3899 | csrConstructCurrentValidChannelList( pMac, &pMac->scan.channelPowerInfoList24, pMac->scan.channels11d.channelList, |
| 3900 | bMaxNumChn, &Num2GChannels ); |
| 3901 | // construct 5GHz channel list now |
| 3902 | if(bMaxNumChn > Num2GChannels) |
| 3903 | { |
| 3904 | csrConstructCurrentValidChannelList( pMac, &pMac->scan.channelPowerInfoList5G, pMac->scan.channels11d.channelList + Num2GChannels, |
| 3905 | bMaxNumChn - Num2GChannels, |
| 3906 | &pMac->scan.channels11d.numChannels ); |
| 3907 | } |
| 3908 | |
| 3909 | pMac->scan.channels11d.numChannels += Num2GChannels; |
| 3910 | fRet = eANI_BOOLEAN_TRUE; |
| 3911 | |
| 3912 | } while( 0 ); |
| 3913 | |
| 3914 | if( !pIes && pIesLocal ) |
| 3915 | { |
| 3916 | //locally allocated |
| 3917 | palFreeMemory(pMac->hHdd, pIesLocal); |
| 3918 | } |
| 3919 | |
| 3920 | return( fRet ); |
| 3921 | } |
| 3922 | |
| 3923 | |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 3924 | static void csrSaveScanResults( tpAniSirGlobal pMac, tANI_U8 reason ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3925 | { |
| 3926 | // initialize this to FALSE. profMoveInterimScanResultsToMainList() routine |
| 3927 | // will set this to the channel where an .11d beacon is seen |
| 3928 | pMac->scan.channelOf11dInfo = 0; |
| 3929 | // if we get any ambiguous .11d information then this will be set to TRUE |
| 3930 | pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE; |
| 3931 | //Tush |
| 3932 | // if we get any ambiguous .11d information, then this will be set to TRUE |
| 3933 | // only if the applied 11d info could be found in one of the scan results |
| 3934 | pMac->scan.fCurrent11dInfoMatch = eANI_BOOLEAN_FALSE; |
| 3935 | // move the scan results from interim list to the main scan list |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 3936 | csrMoveTempScanResultsToMainList( pMac, reason ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3937 | |
| 3938 | // Now check if we gathered any domain/country specific information |
| 3939 | // If so, we should update channel list and apply Tx power settings |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3940 | if( csrIs11dSupported(pMac) ) |
| 3941 | { |
| 3942 | csrApplyCountryInformation( pMac, FALSE ); |
| 3943 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3944 | } |
| 3945 | |
| 3946 | |
| 3947 | void csrReinitScanCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
| 3948 | { |
| 3949 | switch (pCommand->u.scanCmd.reason) |
| 3950 | { |
| 3951 | case eCsrScanSetBGScanParam: |
| 3952 | case eCsrScanAbortBgScan: |
| 3953 | if(pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList) |
| 3954 | { |
| 3955 | palFreeMemory(pMac->hHdd, pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList); |
| 3956 | pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList = NULL; |
| 3957 | } |
| 3958 | break; |
| 3959 | case eCsrScanBGScanAbort: |
| 3960 | case eCsrScanBGScanEnable: |
| 3961 | case eCsrScanGetScanChnInfo: |
| 3962 | break; |
| 3963 | case eCsrScanAbortNormalScan: |
| 3964 | default: |
| 3965 | csrScanFreeRequest(pMac, &pCommand->u.scanCmd.u.scanRequest); |
| 3966 | break; |
| 3967 | } |
| 3968 | if(pCommand->u.scanCmd.pToRoamProfile) |
| 3969 | { |
| 3970 | csrReleaseProfile(pMac, pCommand->u.scanCmd.pToRoamProfile); |
| 3971 | palFreeMemory(pMac->hHdd, pCommand->u.scanCmd.pToRoamProfile); |
| 3972 | } |
| 3973 | palZeroMemory(pMac->hHdd, &pCommand->u.scanCmd, sizeof(tScanCmd)); |
| 3974 | } |
| 3975 | |
| 3976 | |
| 3977 | tANI_BOOLEAN csrGetRemainingChannelsFor11dScan( tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U8 *pcChannels ) |
| 3978 | { |
| 3979 | tANI_U32 index11dChannels, index; |
| 3980 | tANI_U32 indexCurrentChannels; |
| 3981 | tANI_BOOLEAN fChannelAlreadyScanned; |
| 3982 | tANI_U32 len = sizeof(pMac->roam.validChannelList); |
| 3983 | |
| 3984 | *pcChannels = 0; |
| 3985 | if ( CSR_IS_11D_INFO_FOUND(pMac) && csrRoamIsChannelValid(pMac, pMac->scan.channelOf11dInfo) ) |
| 3986 | { |
| 3987 | if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len))) |
| 3988 | { |
| 3989 | //Find the channel index where we found the 11d info |
| 3990 | for(index = 0; index < len; index++) |
| 3991 | { |
| 3992 | if(pMac->scan.channelOf11dInfo == pMac->roam.validChannelList[index]) |
| 3993 | break; |
| 3994 | } |
| 3995 | //check whether we found the channel index |
| 3996 | if(index < len) |
| 3997 | { |
| 3998 | // Now, look through the 11d channel list and create a list of all channels in the 11d list that are |
| 3999 | // NOT in the current channel list. This gives us a list of the new channels that have not been |
| 4000 | // scanned. We'll scan this new list so we have a complete set of scan results on all of the domain channels |
| 4001 | // initially. |
| 4002 | for ( index11dChannels = 0; index11dChannels < pMac->scan.channels11d.numChannels; index11dChannels++ ) |
| 4003 | { |
| 4004 | fChannelAlreadyScanned = eANI_BOOLEAN_FALSE; |
| 4005 | |
| 4006 | for( indexCurrentChannels = 0; indexCurrentChannels < index; indexCurrentChannels++ ) |
| 4007 | { |
| 4008 | if ( pMac->roam.validChannelList[ indexCurrentChannels ] == pMac->scan.channels11d.channelList[ index11dChannels ] ) |
| 4009 | { |
| 4010 | fChannelAlreadyScanned = eANI_BOOLEAN_TRUE; |
| 4011 | break; |
| 4012 | } |
| 4013 | } |
| 4014 | |
| 4015 | if ( !fChannelAlreadyScanned ) |
| 4016 | { |
| 4017 | pChannels[ *pcChannels ] = pMac->scan.channels11d.channelList[ index11dChannels ]; |
| 4018 | ( *pcChannels )++; |
| 4019 | } |
| 4020 | } |
| 4021 | } |
| 4022 | }//GetCFG |
| 4023 | } |
| 4024 | return( *pcChannels ); |
| 4025 | } |
| 4026 | |
| 4027 | |
| 4028 | eCsrScanCompleteNextCommand csrScanGetNextCommandState( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fSuccess ) |
| 4029 | { |
| 4030 | eCsrScanCompleteNextCommand NextCommand = eCsrNextScanNothing; |
| 4031 | |
| 4032 | switch( pCommand->u.scanCmd.reason ) |
| 4033 | { |
| 4034 | case eCsrScan11d1: |
| 4035 | NextCommand = (fSuccess) ? eCsrNext11dScan1Success : eCsrNext11dScan1Failure; |
| 4036 | break; |
| 4037 | case eCsrScan11d2: |
| 4038 | NextCommand = (fSuccess) ? eCsrNext11dScan2Success : eCsrNext11dScan2Failure; |
| 4039 | break; |
| 4040 | case eCsrScan11dDone: |
| 4041 | NextCommand = eCsrNext11dScanComplete; |
| 4042 | break; |
| 4043 | case eCsrScanLostLink1: |
| 4044 | NextCommand = (fSuccess) ? eCsrNextLostLinkScan1Success : eCsrNextLostLinkScan1Failed; |
| 4045 | break; |
| 4046 | case eCsrScanLostLink2: |
| 4047 | NextCommand = (fSuccess) ? eCsrNextLostLinkScan2Success : eCsrNextLostLinkScan2Failed; |
| 4048 | break; |
| 4049 | case eCsrScanLostLink3: |
| 4050 | NextCommand = (fSuccess) ? eCsrNextLostLinkScan3Success : eCsrNextLostLinkScan3Failed; |
| 4051 | break; |
| 4052 | case eCsrScanForSsid: |
| 4053 | NextCommand = (fSuccess) ? eCsrNexteScanForSsidSuccess : eCsrNexteScanForSsidFailure; |
| 4054 | break; |
| 4055 | case eCsrScanForCapsChange: |
| 4056 | NextCommand = eCsrNextCapChangeScanComplete; //don't care success or not |
| 4057 | break; |
| 4058 | case eCsrScanIdleScan: |
| 4059 | NextCommand = eCsrNextIdleScanComplete; |
| 4060 | break; |
| 4061 | default: |
| 4062 | NextCommand = eCsrNextScanNothing; |
| 4063 | break; |
| 4064 | } |
| 4065 | return( NextCommand ); |
| 4066 | } |
| 4067 | |
| 4068 | |
| 4069 | //Return whether the pCommand is finished. |
| 4070 | tANI_BOOLEAN csrHandleScan11d1Failure(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
| 4071 | { |
| 4072 | tANI_BOOLEAN fRet = eANI_BOOLEAN_TRUE; |
| 4073 | |
| 4074 | //Apply back the default setting and passively scan one more time. |
Gopichand Nakkala | b9185f2 | 2012-12-21 08:03:42 -0800 | [diff] [blame] | 4075 | csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_TRUE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4076 | pCommand->u.scanCmd.reason = eCsrScan11d2; |
| 4077 | if(HAL_STATUS_SUCCESS(csrScanChannels(pMac, pCommand))) |
| 4078 | { |
| 4079 | fRet = eANI_BOOLEAN_FALSE; |
| 4080 | } |
| 4081 | |
| 4082 | return (fRet); |
| 4083 | } |
| 4084 | |
| 4085 | |
| 4086 | tANI_BOOLEAN csrHandleScan11dSuccess(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
| 4087 | { |
| 4088 | tANI_BOOLEAN fRet = eANI_BOOLEAN_TRUE; |
| 4089 | tANI_U8 *pChannels; |
| 4090 | tANI_U8 cChannels; |
| 4091 | |
| 4092 | if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN))) |
| 4093 | { |
| 4094 | palZeroMemory(pMac->hHdd, pChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 4095 | if ( csrGetRemainingChannelsFor11dScan( pMac, pChannels, &cChannels ) ) |
| 4096 | { |
| 4097 | pCommand->u.scanCmd.reason = eCsrScan11dDone; |
| 4098 | if(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList) |
| 4099 | { |
| 4100 | palFreeMemory(pMac->hHdd, pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList); |
James Zmuda | 9ea1edd | 2013-04-18 18:20:54 -0700 | [diff] [blame] | 4101 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4102 | } |
| 4103 | if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList, cChannels))) |
| 4104 | { |
| 4105 | palCopyMemory(pMac->hHdd, pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList, pChannels, cChannels); |
| 4106 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = cChannels; |
| 4107 | pCommand->u.scanCmd.u.scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN; |
| 4108 | pCommand->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 4109 | if(HAL_STATUS_SUCCESS(csrScanChannels(pMac, pCommand))) |
| 4110 | { |
| 4111 | //Reuse the same command buffer |
| 4112 | fRet = eANI_BOOLEAN_FALSE; |
| 4113 | } |
| 4114 | } |
| 4115 | } |
| 4116 | palFreeMemory(pMac->hHdd, pChannels); |
| 4117 | } |
| 4118 | |
| 4119 | return (fRet); |
| 4120 | } |
| 4121 | |
| 4122 | //Return whether the command should be removed |
| 4123 | tANI_BOOLEAN csrScanComplete( tpAniSirGlobal pMac, tSirSmeScanRsp *pScanRsp ) |
| 4124 | { |
| 4125 | eCsrScanCompleteNextCommand NextCommand = eCsrNextScanNothing; |
| 4126 | tListElem *pEntry; |
| 4127 | tSmeCmd *pCommand; |
| 4128 | tANI_BOOLEAN fRemoveCommand = eANI_BOOLEAN_TRUE; |
| 4129 | tANI_BOOLEAN fSuccess; |
| 4130 | |
| 4131 | pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK ); |
| 4132 | |
| 4133 | if ( pEntry ) |
| 4134 | { |
| 4135 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 4136 | |
| 4137 | // If the head of the queue is Active and it is a SCAN command, remove |
| 4138 | // and put this on the Free queue. |
| 4139 | if ( eSmeCommandScan == pCommand->command ) |
| 4140 | { |
| 4141 | tANI_U32 sessionId = pCommand->sessionId; |
| 4142 | |
| 4143 | if(eSIR_SME_SUCCESS != pScanRsp->statusCode) |
| 4144 | { |
| 4145 | fSuccess = eANI_BOOLEAN_FALSE; |
| 4146 | } |
| 4147 | else |
| 4148 | { |
| 4149 | //pMac->scan.tempScanResults is not empty meaning the scan found something |
| 4150 | //This check only valid here because csrSaveScanresults is not yet called |
| 4151 | fSuccess = (!csrLLIsListEmpty(&pMac->scan.tempScanResults, LL_ACCESS_LOCK)); |
| 4152 | } |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 4153 | csrSaveScanResults(pMac, pCommand->u.scanCmd.reason); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4154 | |
| 4155 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 4156 | { |
| 4157 | vos_log_scan_pkt_type *pScanLog = NULL; |
| 4158 | tScanResultHandle hScanResult; |
| 4159 | tCsrScanResultInfo *pScanResult; |
| 4160 | tDot11fBeaconIEs *pIes; |
| 4161 | int n = 0, c = 0; |
| 4162 | |
| 4163 | WLAN_VOS_DIAG_LOG_ALLOC(pScanLog, vos_log_scan_pkt_type, LOG_WLAN_SCAN_C); |
| 4164 | if(pScanLog) |
| 4165 | { |
| 4166 | if(eCsrScanBgScan == pCommand->u.scanCmd.reason || |
| 4167 | eCsrScanProbeBss == pCommand->u.scanCmd.reason || |
| 4168 | eCsrScanSetBGScanParam == pCommand->u.scanCmd.reason) |
| 4169 | { |
| 4170 | pScanLog->eventId = WLAN_SCAN_EVENT_HO_SCAN_RSP; |
| 4171 | } |
| 4172 | else |
| 4173 | { |
| 4174 | if( eSIR_PASSIVE_SCAN != pMac->scan.curScanType ) |
| 4175 | { |
| 4176 | pScanLog->eventId = WLAN_SCAN_EVENT_ACTIVE_SCAN_RSP; |
| 4177 | } |
| 4178 | else |
| 4179 | { |
| 4180 | pScanLog->eventId = WLAN_SCAN_EVENT_PASSIVE_SCAN_RSP; |
| 4181 | } |
| 4182 | } |
| 4183 | if(eSIR_SME_SUCCESS == pScanRsp->statusCode) |
| 4184 | { |
| 4185 | if(HAL_STATUS_SUCCESS(csrScanGetResult(pMac, NULL, &hScanResult))) |
| 4186 | { |
| 4187 | while(((pScanResult = csrScanResultGetNext(pMac, hScanResult)) != NULL)) |
| 4188 | { |
| 4189 | if( n < VOS_LOG_MAX_NUM_BSSID ) |
| 4190 | { |
| 4191 | if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->BssDescriptor, &pIes))) |
| 4192 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 4193 | smsLog(pMac, LOGE, FL(" fail to parse IEs")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4194 | break; |
| 4195 | } |
| 4196 | palCopyMemory(pMac->hHdd, pScanLog->bssid[n], pScanResult->BssDescriptor.bssId, 6); |
| 4197 | if(pIes && pIes->SSID.present && VOS_LOG_MAX_SSID_SIZE >= pIes->SSID.num_ssid) |
| 4198 | { |
| 4199 | palCopyMemory(pMac->hHdd, pScanLog->ssid[n], |
| 4200 | pIes->SSID.ssid, pIes->SSID.num_ssid); |
| 4201 | } |
| 4202 | palFreeMemory(pMac->hHdd, pIes); |
| 4203 | n++; |
| 4204 | } |
| 4205 | c++; |
| 4206 | } |
| 4207 | pScanLog->numSsid = (v_U8_t)n; |
| 4208 | pScanLog->totalSsid = (v_U8_t)c; |
| 4209 | csrScanResultPurge(pMac, hScanResult); |
| 4210 | } |
| 4211 | } |
| 4212 | else |
| 4213 | { |
| 4214 | pScanLog->status = WLAN_SCAN_STATUS_FAILURE; |
| 4215 | } |
| 4216 | WLAN_VOS_DIAG_LOG_REPORT(pScanLog); |
| 4217 | } |
| 4218 | } |
| 4219 | #endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 4220 | |
| 4221 | NextCommand = csrScanGetNextCommandState(pMac, pCommand, fSuccess); |
| 4222 | //We reuse the command here instead reissue a new command |
| 4223 | switch(NextCommand) |
| 4224 | { |
| 4225 | case eCsrNext11dScan1Success: |
| 4226 | case eCsrNext11dScan2Success: |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 4227 | smsLog( pMac, LOG2, FL("11dScan1/3 produced results. Reissue Active scan...")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4228 | // if we found country information, no need to continue scanning further, bail out |
| 4229 | fRemoveCommand = eANI_BOOLEAN_TRUE; |
| 4230 | NextCommand = eCsrNext11dScanComplete; |
| 4231 | break; |
| 4232 | case eCsrNext11dScan1Failure: |
| 4233 | //We are not done yet. 11d scan fail once. We will try to reset anything and do it over again |
| 4234 | //The only meaningful thing for this retry is that we cannot find 11d information after a reset so |
| 4235 | //we clear the "old" 11d info and give it once more chance |
| 4236 | fRemoveCommand = csrHandleScan11d1Failure(pMac, pCommand); |
| 4237 | if(fRemoveCommand) |
| 4238 | { |
| 4239 | NextCommand = eCsrNext11dScanComplete; |
| 4240 | } |
| 4241 | break; |
| 4242 | case eCsrNextLostLinkScan1Success: |
| 4243 | if(!HAL_STATUS_SUCCESS(csrIssueRoamAfterLostlinkScan(pMac, sessionId, eCsrLostLink1))) |
| 4244 | { |
| 4245 | csrScanHandleFailedLostlink1(pMac, sessionId); |
| 4246 | } |
| 4247 | break; |
| 4248 | case eCsrNextLostLinkScan2Success: |
| 4249 | if(!HAL_STATUS_SUCCESS(csrIssueRoamAfterLostlinkScan(pMac, sessionId, eCsrLostLink2))) |
| 4250 | { |
| 4251 | csrScanHandleFailedLostlink2(pMac, sessionId); |
| 4252 | } |
| 4253 | break; |
| 4254 | case eCsrNextLostLinkScan3Success: |
| 4255 | if(!HAL_STATUS_SUCCESS(csrIssueRoamAfterLostlinkScan(pMac, sessionId, eCsrLostLink3))) |
| 4256 | { |
| 4257 | csrScanHandleFailedLostlink3(pMac, sessionId); |
| 4258 | } |
| 4259 | break; |
| 4260 | case eCsrNextLostLinkScan1Failed: |
| 4261 | csrScanHandleFailedLostlink1(pMac, sessionId); |
| 4262 | break; |
| 4263 | case eCsrNextLostLinkScan2Failed: |
| 4264 | csrScanHandleFailedLostlink2(pMac, sessionId); |
| 4265 | break; |
| 4266 | case eCsrNextLostLinkScan3Failed: |
| 4267 | csrScanHandleFailedLostlink3(pMac, sessionId); |
| 4268 | break; |
| 4269 | case eCsrNexteScanForSsidSuccess: |
| 4270 | csrScanHandleSearchForSSID(pMac, pCommand); |
| 4271 | break; |
| 4272 | case eCsrNexteScanForSsidFailure: |
| 4273 | csrScanHandleSearchForSSIDFailure(pMac, pCommand); |
| 4274 | break; |
| 4275 | case eCsrNextIdleScanComplete: |
| 4276 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 4277 | break; |
| 4278 | case eCsrNextCapChangeScanComplete: |
| 4279 | csrScanHandleCapChangeScanComplete(pMac, sessionId); |
| 4280 | break; |
| 4281 | default: |
| 4282 | |
| 4283 | break; |
| 4284 | } |
| 4285 | } |
| 4286 | else |
| 4287 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 4288 | 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] | 4289 | fRemoveCommand = eANI_BOOLEAN_FALSE; |
| 4290 | } |
| 4291 | } |
| 4292 | else |
| 4293 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 4294 | smsLog( pMac, LOGW, FL("Scan Completion called but NO commands are ACTIVE ...")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4295 | fRemoveCommand = eANI_BOOLEAN_FALSE; |
| 4296 | } |
| 4297 | |
| 4298 | return( fRemoveCommand ); |
| 4299 | } |
| 4300 | |
| 4301 | |
| 4302 | |
| 4303 | static void csrScanRemoveDupBssDescriptionFromInterimList( tpAniSirGlobal pMac, |
| 4304 | tSirBssDescription *pSirBssDescr, |
| 4305 | tDot11fBeaconIEs *pIes) |
| 4306 | { |
| 4307 | tListElem *pEntry; |
| 4308 | tCsrScanResult *pCsrBssDescription; |
| 4309 | |
| 4310 | // Walk through all the chained BssDescriptions. If we find a chained BssDescription that |
| 4311 | // matches the BssID of the BssDescription passed in, then these must be duplicate scan |
| 4312 | // results for this Bss. In that case, remove the 'old' Bss description from the linked list. |
| 4313 | pEntry = csrLLPeekHead( &pMac->scan.tempScanResults, LL_ACCESS_LOCK ); |
| 4314 | while( pEntry ) |
| 4315 | { |
| 4316 | pCsrBssDescription = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 4317 | |
| 4318 | // we have a duplicate scan results only when BSSID, SSID, Channel and NetworkType |
| 4319 | // matches |
| 4320 | |
| 4321 | if ( csrIsDuplicateBssDescription( pMac, &pCsrBssDescription->Result.BssDescriptor, |
Tushnim Bhattacharyya | 5128d75 | 2013-06-26 23:23:18 -0700 | [diff] [blame] | 4322 | pSirBssDescr, pIes, FALSE ) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4323 | { |
| 4324 | pSirBssDescr->rssi = (tANI_S8)( (((tANI_S32)pSirBssDescr->rssi * CSR_SCAN_RESULT_RSSI_WEIGHT ) + |
| 4325 | ((tANI_S32)pCsrBssDescription->Result.BssDescriptor.rssi * (100 - CSR_SCAN_RESULT_RSSI_WEIGHT) )) / 100 ); |
| 4326 | |
| 4327 | // Remove the 'old' entry from the list.... |
| 4328 | if( csrLLRemoveEntry( &pMac->scan.tempScanResults, pEntry, LL_ACCESS_LOCK ) ) |
| 4329 | { |
| 4330 | csrCheckNSaveWscIe(pMac, pSirBssDescr, &pCsrBssDescription->Result.BssDescriptor); |
| 4331 | // we need to free the memory associated with this node |
| 4332 | csrFreeScanResultEntry( pMac, pCsrBssDescription ); |
| 4333 | } |
| 4334 | |
| 4335 | // If we found a match, we can stop looking through the list. |
| 4336 | break; |
| 4337 | } |
| 4338 | |
| 4339 | pEntry = csrLLNext( &pMac->scan.tempScanResults, pEntry, LL_ACCESS_LOCK ); |
| 4340 | } |
| 4341 | } |
| 4342 | |
| 4343 | |
| 4344 | |
| 4345 | //Caller allocated memory pfNewBssForConn to return whether new candidate for |
| 4346 | //current connection is found. Cannot be NULL |
| 4347 | tCsrScanResult *csrScanSaveBssDescriptionToInterimList( tpAniSirGlobal pMac, |
| 4348 | tSirBssDescription *pBSSDescription, |
| 4349 | tDot11fBeaconIEs *pIes) |
| 4350 | { |
| 4351 | tCsrScanResult *pCsrBssDescription = NULL; |
| 4352 | tANI_U32 cbBSSDesc; |
| 4353 | tANI_U32 cbAllocated; |
| 4354 | eHalStatus halStatus; |
| 4355 | |
| 4356 | // figure out how big the BSS description is (the BSSDesc->length does NOT |
| 4357 | // include the size of the length field itself). |
| 4358 | cbBSSDesc = pBSSDescription->length + sizeof( pBSSDescription->length ); |
| 4359 | |
| 4360 | cbAllocated = sizeof( tCsrScanResult ) + cbBSSDesc; |
| 4361 | |
| 4362 | halStatus = palAllocateMemory( pMac->hHdd, (void **)&pCsrBssDescription, cbAllocated ); |
| 4363 | if ( HAL_STATUS_SUCCESS(halStatus) ) |
| 4364 | { |
| 4365 | palZeroMemory(pMac->hHdd, pCsrBssDescription, cbAllocated); |
| 4366 | pCsrBssDescription->AgingCount = (tANI_S32)pMac->roam.configParam.agingCount; |
| 4367 | palCopyMemory(pMac->hHdd, &pCsrBssDescription->Result.BssDescriptor, pBSSDescription, cbBSSDesc ); |
| 4368 | //Save SSID separately for later use |
| 4369 | if( pIes->SSID.present && !csrIsNULLSSID(pIes->SSID.ssid, pIes->SSID.num_ssid) ) |
| 4370 | { |
| 4371 | //SSID not hidden |
Madan Mohan Koyyalamudi | 4e31b13 | 2012-11-02 13:13:52 -0700 | [diff] [blame] | 4372 | tANI_U32 len = pIes->SSID.num_ssid; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4373 | if (len > SIR_MAC_MAX_SSID_LENGTH) |
| 4374 | { |
| 4375 | // truncate to fit in our struct |
| 4376 | len = SIR_MAC_MAX_SSID_LENGTH; |
| 4377 | } |
| 4378 | pCsrBssDescription->Result.ssId.length = len; |
| 4379 | pCsrBssDescription->Result.timer = vos_timer_get_system_time(); |
| 4380 | palCopyMemory(pMac->hHdd, pCsrBssDescription->Result.ssId.ssId, |
| 4381 | pIes->SSID.ssid, len ); |
| 4382 | } |
| 4383 | csrLLInsertTail( &pMac->scan.tempScanResults, &pCsrBssDescription->Link, LL_ACCESS_LOCK ); |
| 4384 | } |
| 4385 | |
| 4386 | return( pCsrBssDescription ); |
| 4387 | } |
| 4388 | |
| 4389 | |
| 4390 | |
| 4391 | |
| 4392 | tANI_BOOLEAN csrIsDuplicateBssDescription( tpAniSirGlobal pMac, tSirBssDescription *pSirBssDesc1, |
Tushnim Bhattacharyya | 5128d75 | 2013-06-26 23:23:18 -0700 | [diff] [blame] | 4393 | tSirBssDescription *pSirBssDesc2, tDot11fBeaconIEs *pIes2, tANI_BOOLEAN fForced ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4394 | { |
| 4395 | tANI_BOOLEAN fMatch = FALSE; |
| 4396 | tSirMacCapabilityInfo *pCap1, *pCap2; |
| 4397 | tDot11fBeaconIEs *pIes1 = NULL; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4398 | tDot11fBeaconIEs *pIesTemp = pIes2; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4399 | |
| 4400 | pCap1 = (tSirMacCapabilityInfo *)&pSirBssDesc1->capabilityInfo; |
| 4401 | pCap2 = (tSirMacCapabilityInfo *)&pSirBssDesc2->capabilityInfo; |
| 4402 | if(pCap1->ess == pCap2->ess) |
| 4403 | { |
| 4404 | if (pCap1->ess && |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4405 | csrIsMacAddressEqual( pMac, (tCsrBssid *)pSirBssDesc1->bssId, (tCsrBssid *)pSirBssDesc2->bssId)&& |
Tushnim Bhattacharyya | 5128d75 | 2013-06-26 23:23:18 -0700 | [diff] [blame] | 4406 | (fForced || (pSirBssDesc1->channelId == pSirBssDesc2->channelId))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4407 | { |
| 4408 | fMatch = TRUE; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4409 | // Check for SSID match, if exists |
| 4410 | do |
| 4411 | { |
| 4412 | if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc1, &pIes1))) |
| 4413 | { |
| 4414 | break; |
| 4415 | } |
| 4416 | if( NULL == pIesTemp ) |
| 4417 | { |
| 4418 | if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc2, &pIesTemp))) |
| 4419 | { |
| 4420 | break; |
| 4421 | } |
| 4422 | } |
| 4423 | if(pIes1->SSID.present && pIesTemp->SSID.present) |
| 4424 | { |
| 4425 | fMatch = csrIsSsidMatch(pMac, pIes1->SSID.ssid, pIes1->SSID.num_ssid, |
| 4426 | pIesTemp->SSID.ssid, pIesTemp->SSID.num_ssid, eANI_BOOLEAN_TRUE); |
| 4427 | } |
| 4428 | }while(0); |
| 4429 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4430 | } |
| 4431 | else if (pCap1->ibss && (pSirBssDesc1->channelId == pSirBssDesc2->channelId)) |
| 4432 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4433 | |
| 4434 | do |
| 4435 | { |
| 4436 | if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc1, &pIes1))) |
| 4437 | { |
| 4438 | break; |
| 4439 | } |
| 4440 | if( NULL == pIesTemp ) |
| 4441 | { |
| 4442 | if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc2, &pIesTemp))) |
| 4443 | { |
| 4444 | break; |
| 4445 | } |
| 4446 | } |
| 4447 | //Same channel cannot have same SSID for different IBSS |
| 4448 | if(pIes1->SSID.present && pIesTemp->SSID.present) |
| 4449 | { |
| 4450 | fMatch = csrIsSsidMatch(pMac, pIes1->SSID.ssid, pIes1->SSID.num_ssid, |
| 4451 | pIesTemp->SSID.ssid, pIesTemp->SSID.num_ssid, eANI_BOOLEAN_TRUE); |
| 4452 | } |
| 4453 | }while(0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4454 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4455 | /* In case of P2P devices, ess and ibss will be set to zero */ |
| 4456 | else if (!pCap1->ess && |
| 4457 | csrIsMacAddressEqual( pMac, (tCsrBssid *)pSirBssDesc1->bssId, (tCsrBssid *)pSirBssDesc2->bssId)) |
| 4458 | { |
| 4459 | fMatch = TRUE; |
| 4460 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4461 | } |
| 4462 | |
| 4463 | if(pIes1) |
| 4464 | { |
| 4465 | palFreeMemory(pMac->hHdd, pIes1); |
| 4466 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4467 | |
| 4468 | if( (NULL == pIes2) && pIesTemp ) |
| 4469 | { |
| 4470 | //locally allocated |
| 4471 | palFreeMemory(pMac->hHdd, pIesTemp); |
| 4472 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4473 | |
| 4474 | return( fMatch ); |
| 4475 | } |
| 4476 | |
| 4477 | |
| 4478 | tANI_BOOLEAN csrIsNetworkTypeEqual( tSirBssDescription *pSirBssDesc1, tSirBssDescription *pSirBssDesc2 ) |
| 4479 | { |
| 4480 | return( pSirBssDesc1->nwType == pSirBssDesc2->nwType ); |
| 4481 | } |
| 4482 | |
| 4483 | |
| 4484 | //to check whether the BSS matches the dot11Mode |
| 4485 | static tANI_BOOLEAN csrScanIsBssAllowed(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc, |
| 4486 | tDot11fBeaconIEs *pIes) |
| 4487 | { |
| 4488 | tANI_BOOLEAN fAllowed = eANI_BOOLEAN_FALSE; |
| 4489 | eCsrPhyMode phyMode; |
| 4490 | |
| 4491 | if(HAL_STATUS_SUCCESS(csrGetPhyModeFromBss(pMac, pBssDesc, &phyMode, pIes))) |
| 4492 | { |
| 4493 | switch(pMac->roam.configParam.phyMode) |
| 4494 | { |
| 4495 | case eCSR_DOT11_MODE_11b: |
| 4496 | fAllowed = (tANI_BOOLEAN)(eCSR_DOT11_MODE_11a != phyMode); |
| 4497 | break; |
| 4498 | case eCSR_DOT11_MODE_11g: |
| 4499 | fAllowed = (tANI_BOOLEAN)(eCSR_DOT11_MODE_11a != phyMode); |
| 4500 | break; |
| 4501 | case eCSR_DOT11_MODE_11g_ONLY: |
| 4502 | fAllowed = (tANI_BOOLEAN)(eCSR_DOT11_MODE_11g == phyMode); |
| 4503 | break; |
| 4504 | case eCSR_DOT11_MODE_11a: |
| 4505 | fAllowed = (tANI_BOOLEAN)((eCSR_DOT11_MODE_11b != phyMode) && (eCSR_DOT11_MODE_11g != phyMode)); |
| 4506 | break; |
| 4507 | case eCSR_DOT11_MODE_11n_ONLY: |
| 4508 | fAllowed = (tANI_BOOLEAN)((eCSR_DOT11_MODE_11n == phyMode) || (eCSR_DOT11_MODE_TAURUS == phyMode)); |
| 4509 | break; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4510 | |
| 4511 | #ifdef WLAN_FEATURE_11AC |
| 4512 | case eCSR_DOT11_MODE_11ac_ONLY: |
| 4513 | fAllowed = (tANI_BOOLEAN)((eCSR_DOT11_MODE_11ac == phyMode) || (eCSR_DOT11_MODE_TAURUS == phyMode)); |
| 4514 | break; |
| 4515 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4516 | case eCSR_DOT11_MODE_11b_ONLY: |
| 4517 | fAllowed = (tANI_BOOLEAN)(eCSR_DOT11_MODE_11b == phyMode); |
| 4518 | break; |
| 4519 | case eCSR_DOT11_MODE_11a_ONLY: |
| 4520 | fAllowed = (tANI_BOOLEAN)(eCSR_DOT11_MODE_11a == phyMode); |
| 4521 | break; |
| 4522 | case eCSR_DOT11_MODE_11n: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4523 | #ifdef WLAN_FEATURE_11AC |
| 4524 | case eCSR_DOT11_MODE_11ac: |
| 4525 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4526 | case eCSR_DOT11_MODE_TAURUS: |
| 4527 | default: |
| 4528 | fAllowed = eANI_BOOLEAN_TRUE; |
| 4529 | break; |
| 4530 | } |
| 4531 | } |
| 4532 | |
| 4533 | return (fAllowed); |
| 4534 | } |
| 4535 | |
| 4536 | |
| 4537 | |
| 4538 | //Return pIes to caller for future use when returning TRUE. |
| 4539 | static tANI_BOOLEAN csrScanValidateScanResult( tpAniSirGlobal pMac, tANI_U8 *pChannels, |
| 4540 | tANI_U8 numChn, tSirBssDescription *pBssDesc, |
| 4541 | tDot11fBeaconIEs **ppIes ) |
| 4542 | { |
| 4543 | tANI_BOOLEAN fValidChannel = FALSE; |
| 4544 | tDot11fBeaconIEs *pIes = NULL; |
| 4545 | tANI_U8 index; |
| 4546 | |
| 4547 | for( index = 0; index < numChn; index++ ) |
| 4548 | { |
| 4549 | // This check relies on the fact that a single BSS description is returned in each |
| 4550 | // ScanRsp call, which is the way LIM implemented the scan req/rsp funtions. We changed |
| 4551 | // to this model when we ran with a large number of APs. If this were to change, then |
| 4552 | // this check would have to mess with removing the bssDescription from somewhere in an |
| 4553 | // arbitrary index in the bssDescription array. |
| 4554 | if ( pChannels[ index ] == pBssDesc->channelId ) |
| 4555 | { |
| 4556 | fValidChannel = TRUE; |
| 4557 | break; |
| 4558 | } |
| 4559 | } |
| 4560 | *ppIes = NULL; |
| 4561 | if(fValidChannel) |
| 4562 | { |
| 4563 | if( HAL_STATUS_SUCCESS( csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes) ) ) |
| 4564 | { |
| 4565 | fValidChannel = csrScanIsBssAllowed(pMac, pBssDesc, pIes); |
| 4566 | if( fValidChannel ) |
| 4567 | { |
| 4568 | *ppIes = pIes; |
| 4569 | } |
| 4570 | else |
| 4571 | { |
| 4572 | palFreeMemory( pMac->hHdd, pIes ); |
| 4573 | } |
| 4574 | } |
| 4575 | else |
| 4576 | { |
| 4577 | fValidChannel = FALSE; |
| 4578 | } |
| 4579 | } |
| 4580 | |
| 4581 | return( fValidChannel ); |
| 4582 | } |
| 4583 | |
| 4584 | |
| 4585 | //Return whether last scan result is received |
| 4586 | static tANI_BOOLEAN csrScanProcessScanResults( tpAniSirGlobal pMac, tSmeCmd *pCommand, |
| 4587 | tSirSmeScanRsp *pScanRsp, tANI_BOOLEAN *pfRemoveCommand ) |
| 4588 | { |
| 4589 | tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE, fRemoveCommand = eANI_BOOLEAN_FALSE; |
| 4590 | tDot11fBeaconIEs *pIes = NULL; |
| 4591 | tANI_U32 cbParsed; |
| 4592 | tSirBssDescription *pSirBssDescription; |
| 4593 | tANI_U32 cbBssDesc; |
| 4594 | tANI_U32 cbScanResult = GET_FIELD_OFFSET( tSirSmeScanRsp, bssDescription ) |
| 4595 | + sizeof(tSirBssDescription); //We need at least one CB |
| 4596 | |
| 4597 | // don't consider the scan rsp to be valid if the status code is Scan Failure. Scan Failure |
| 4598 | // is returned when the scan could not find anything. so if we get scan failure return that |
| 4599 | // the scan response is invalid. Also check the lenght in the scan result for valid scan |
| 4600 | // BssDescriptions.... |
| 4601 | do |
| 4602 | { |
| 4603 | if ( ( cbScanResult <= pScanRsp->length ) && |
| 4604 | (( eSIR_SME_SUCCESS == pScanRsp->statusCode ) || |
| 4605 | ( eSIR_SME_MORE_SCAN_RESULTS_FOLLOW == pScanRsp->statusCode ) ) ) |
| 4606 | { |
| 4607 | tANI_U8 *pChannelList = NULL; |
| 4608 | tANI_U8 cChannels = 0; |
| 4609 | |
| 4610 | //Different scan type can reach this point, we need to distinguish it |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 4611 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 4612 | if( eCsrScanGetLfrResult == pCommand->u.scanCmd.reason ) |
| 4613 | { |
| 4614 | pChannelList = NULL; |
| 4615 | cChannels = 0; |
| 4616 | } |
| 4617 | else |
| 4618 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4619 | if( eCsrScanSetBGScanParam == pCommand->u.scanCmd.reason ) |
| 4620 | { |
| 4621 | //eCsrScanSetBGScanParam uses different structure |
| 4622 | tCsrBGScanRequest *pBgScanReq = &pCommand->u.scanCmd.u.bgScanRequest; |
| 4623 | |
| 4624 | cChannels = pBgScanReq->ChannelInfo.numOfChannels; |
| 4625 | pChannelList = pBgScanReq->ChannelInfo.ChannelList; |
| 4626 | } |
| 4627 | else |
| 4628 | { |
| 4629 | //the rest use generic scan request |
| 4630 | cChannels = pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels; |
| 4631 | pChannelList = pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList; |
| 4632 | } |
| 4633 | |
| 4634 | // if the scan result is not on one of the channels in the Valid channel list, then it |
| 4635 | // must have come from an AP on an overlapping channel (in the 2.4GHz band). In this case, |
| 4636 | // let's drop the scan result. |
| 4637 | // |
| 4638 | // The other situation is where the scan request is for a scan on a particular channel set |
| 4639 | // and the scan result is from a |
| 4640 | |
| 4641 | // if the NumChannels is 0, then we are supposed to be scanning all channels. Use the full channel |
| 4642 | // list as the 'valid' channel list. Otherwise, use the specific channel list in the scan parms |
| 4643 | // as the valid channels. |
| 4644 | if ( 0 == cChannels ) |
| 4645 | { |
| 4646 | tANI_U32 len = sizeof(pMac->roam.validChannelList); |
| 4647 | |
| 4648 | if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len))) |
| 4649 | { |
| 4650 | pChannelList = pMac->roam.validChannelList; |
| 4651 | cChannels = (tANI_U8)len; |
| 4652 | } |
| 4653 | else |
| 4654 | { |
| 4655 | //Cannot continue |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 4656 | smsLog( pMac, LOGE, "CSR: Processing internal SCAN results...csrGetCfgValidChannels failed" ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4657 | break; |
| 4658 | } |
| 4659 | } |
| 4660 | |
| 4661 | smsLog( pMac, LOG2, "CSR: Processing internal SCAN results..." ); |
| 4662 | cbParsed = GET_FIELD_OFFSET( tSirSmeScanRsp, bssDescription ); |
| 4663 | pSirBssDescription = pScanRsp->bssDescription; |
| 4664 | while( cbParsed < pScanRsp->length ) |
| 4665 | { |
| 4666 | if ( csrScanValidateScanResult( pMac, pChannelList, cChannels, pSirBssDescription, &pIes ) ) |
| 4667 | { |
| 4668 | csrScanRemoveDupBssDescriptionFromInterimList(pMac, pSirBssDescription, pIes); |
| 4669 | csrScanSaveBssDescriptionToInterimList( pMac, pSirBssDescription, pIes ); |
| 4670 | if( eSIR_PASSIVE_SCAN == pMac->scan.curScanType ) |
| 4671 | { |
| 4672 | if( csrIs11dSupported( pMac) ) |
| 4673 | { |
| 4674 | //Check whether the BSS is acceptable base on 11d info and our configs. |
| 4675 | if( csrMatchCountryCode( pMac, NULL, pIes ) ) |
| 4676 | { |
| 4677 | //Double check whether the channel is acceptable by us. |
| 4678 | if( csrIsSupportedChannel( pMac, pSirBssDescription->channelId ) ) |
| 4679 | { |
| 4680 | pMac->scan.curScanType = eSIR_ACTIVE_SCAN; |
| 4681 | } |
| 4682 | } |
| 4683 | } |
| 4684 | else |
| 4685 | { |
| 4686 | pMac->scan.curScanType = eSIR_ACTIVE_SCAN; |
| 4687 | } |
| 4688 | } |
| 4689 | //Free the resource |
| 4690 | palFreeMemory( pMac->hHdd, pIes ); |
| 4691 | } |
| 4692 | // skip over the BSS description to the next one... |
| 4693 | cbBssDesc = pSirBssDescription->length + sizeof( pSirBssDescription->length ); |
| 4694 | |
| 4695 | cbParsed += cbBssDesc; |
| 4696 | pSirBssDescription = (tSirBssDescription *)((tANI_U8 *)pSirBssDescription + cbBssDesc ); |
| 4697 | |
| 4698 | } //while |
| 4699 | } |
| 4700 | else |
| 4701 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 4702 | smsLog( pMac, LOGW, " Scanrsp fail (0x%08X), length = %d (expected %d)", |
Madan Mohan Koyyalamudi | dd3c966 | 2012-11-09 17:39:30 -0800 | [diff] [blame] | 4703 | pScanRsp->statusCode, pScanRsp->length, cbScanResult); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4704 | //HO bg scan/probe failed no need to try autonomously |
| 4705 | if(eCsrScanBgScan == pCommand->u.scanCmd.reason || |
| 4706 | eCsrScanProbeBss == pCommand->u.scanCmd.reason || |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 4707 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 4708 | eCsrScanGetLfrResult == pCommand->u.scanCmd.reason || |
| 4709 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4710 | eCsrScanSetBGScanParam == pCommand->u.scanCmd.reason) |
| 4711 | { |
| 4712 | fRemoveCommand = eANI_BOOLEAN_TRUE; |
| 4713 | } |
| 4714 | } |
| 4715 | }while(0); |
| 4716 | if ( eSIR_SME_MORE_SCAN_RESULTS_FOLLOW != pScanRsp->statusCode ) |
| 4717 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 4718 | 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] | 4719 | fRemoveCommand = csrScanComplete( pMac, pScanRsp ); |
| 4720 | fRet = eANI_BOOLEAN_TRUE; |
| 4721 | }//if ( eSIR_SME_MORE_SCAN_RESULTS_FOLLOW != pScanRsp->statusCode ) |
| 4722 | if(pfRemoveCommand) |
| 4723 | { |
| 4724 | *pfRemoveCommand = fRemoveCommand; |
| 4725 | } |
| 4726 | |
| 4727 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 4728 | if (!csrLLIsListEmpty( &pMac->scan.scanCmdPendingList, LL_ACCESS_LOCK )) |
| 4729 | { |
Madan Mohan Koyyalamudi | 48081ef | 2012-12-04 16:49:55 -0800 | [diff] [blame] | 4730 | /* Pending scan commands in the list because the previous scan command |
| 4731 | * was split into a scan command on one channel + a scan command for all |
| 4732 | * remaining channels. |
| 4733 | * |
| 4734 | * Start timer to trigger processing of the next scan command. |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 4735 | * NOTE for LFR: |
| 4736 | * Do not split scans if no concurrent infra connections are |
| 4737 | * active and if the scan is a BG scan triggered by LFR (OR) |
| 4738 | * any scan if LFR is in the middle of a BG scan. Splitting |
| 4739 | * the scan is delaying the time it takes for LFR to find |
| 4740 | * candidates and resulting in disconnects. |
Madan Mohan Koyyalamudi | 48081ef | 2012-12-04 16:49:55 -0800 | [diff] [blame] | 4741 | */ |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 4742 | if ( (csrIsStaSessionConnected(pMac) && |
| 4743 | #ifdef FEATURE_WLAN_LFR |
| 4744 | (csrIsConcurrentInfraConnected(pMac) || |
| 4745 | ((pCommand->u.scanCmd.reason != eCsrScanBgScan) && |
| 4746 | (pMac->roam.neighborRoamInfo.neighborRoamState != |
| 4747 | eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN))) && |
| 4748 | #endif |
| 4749 | (pCommand->u.scanCmd.u.scanRequest.p2pSearch != 1)) || |
Madan Mohan Koyyalamudi | 48081ef | 2012-12-04 16:49:55 -0800 | [diff] [blame] | 4750 | (csrIsP2pSessionConnected(pMac)) ) |
| 4751 | { |
Madan Mohan Koyyalamudi | d671358 | 2012-11-09 16:56:56 -0800 | [diff] [blame] | 4752 | /* if active connected sessions present then continue to split scan |
| 4753 | * with specified interval between consecutive scans */ |
| 4754 | csrSetDefaultScanTiming(pMac, pCommand->u.scanCmd.u.scanRequest.scanType, &(pCommand->u.scanCmd.u.scanRequest)); |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 4755 | vos_timer_start(&pMac->scan.hTimerStaApConcTimer, |
| 4756 | pCommand->u.scanCmd.u.scanRequest.restTime); |
Madan Mohan Koyyalamudi | d671358 | 2012-11-09 16:56:56 -0800 | [diff] [blame] | 4757 | } else { |
| 4758 | /* if no connected sessions present then initiate next scan command immediately */ |
| 4759 | /* minimum timer granularity is 10ms */ |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 4760 | vos_timer_start(&pMac->scan.hTimerStaApConcTimer, 10); |
Madan Mohan Koyyalamudi | d671358 | 2012-11-09 16:56:56 -0800 | [diff] [blame] | 4761 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4762 | } |
| 4763 | #endif |
| 4764 | return (fRet); |
| 4765 | } |
| 4766 | |
| 4767 | |
| 4768 | tANI_BOOLEAN csrScanIsWildCardScan( tpAniSirGlobal pMac, tSmeCmd *pCommand ) |
| 4769 | { |
| 4770 | tANI_U8 bssid[WNI_CFG_BSSID_LEN] = {0, 0, 0, 0, 0, 0}; |
| 4771 | tANI_BOOLEAN f = palEqualMemory( pMac->hHdd, pCommand->u.scanCmd.u.scanRequest.bssid, |
| 4772 | bssid, sizeof(tCsrBssid) ); |
| 4773 | |
| 4774 | //It is not a wild card scan if the bssid is not broadcast and the number of SSID is 1. |
| 4775 | return ((tANI_BOOLEAN)( (f || (0xff == pCommand->u.scanCmd.u.scanRequest.bssid[0])) && |
| 4776 | (pCommand->u.scanCmd.u.scanRequest.SSIDs.numOfSSIDs != 1) )); |
| 4777 | } |
| 4778 | |
| 4779 | |
| 4780 | eHalStatus csrScanSmeScanResponse( tpAniSirGlobal pMac, void *pMsgBuf ) |
| 4781 | { |
| 4782 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 4783 | tListElem *pEntry; |
| 4784 | tSmeCmd *pCommand; |
| 4785 | eCsrScanStatus scanStatus; |
| 4786 | tSirSmeScanRsp *pScanRsp = (tSirSmeScanRsp *)pMsgBuf; |
| 4787 | tSmeGetScanChnRsp *pScanChnInfo; |
| 4788 | tANI_BOOLEAN fRemoveCommand = eANI_BOOLEAN_TRUE; |
| 4789 | eCsrScanReason reason = eCsrScanOther; |
| 4790 | |
| 4791 | pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK ); |
| 4792 | |
| 4793 | if ( pEntry ) |
| 4794 | { |
| 4795 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 4796 | if ( eSmeCommandScan == pCommand->command ) |
| 4797 | { |
| 4798 | scanStatus = (eSIR_SME_SUCCESS == pScanRsp->statusCode) ? eCSR_SCAN_SUCCESS : eCSR_SCAN_FAILURE; |
| 4799 | reason = pCommand->u.scanCmd.reason; |
| 4800 | switch(pCommand->u.scanCmd.reason) |
| 4801 | { |
| 4802 | case eCsrScanAbortBgScan: |
| 4803 | case eCsrScanAbortNormalScan: |
| 4804 | case eCsrScanBGScanAbort: |
| 4805 | case eCsrScanBGScanEnable: |
| 4806 | break; |
| 4807 | case eCsrScanGetScanChnInfo: |
| 4808 | pScanChnInfo = (tSmeGetScanChnRsp *)pMsgBuf; |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 4809 | /* |
| 4810 | * status code not available in tSmeGetScanChnRsp, so |
| 4811 | * by default considereing it to be success |
| 4812 | */ |
| 4813 | scanStatus = eSIR_SME_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4814 | csrScanAgeResults(pMac, pScanChnInfo); |
| 4815 | break; |
| 4816 | case eCsrScanForCapsChange: |
| 4817 | csrScanProcessScanResults( pMac, pCommand, pScanRsp, &fRemoveCommand ); |
| 4818 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4819 | case eCsrScanP2PFindPeer: |
| 4820 | scanStatus = ((eSIR_SME_SUCCESS == pScanRsp->statusCode) && (pScanRsp->length > 50)) ? eCSR_SCAN_FOUND_PEER : eCSR_SCAN_FAILURE; |
| 4821 | csrScanProcessScanResults( pMac, pCommand, pScanRsp, NULL ); |
| 4822 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4823 | case eCsrScanSetBGScanParam: |
| 4824 | default: |
| 4825 | if(csrScanProcessScanResults( pMac, pCommand, pScanRsp, &fRemoveCommand )) |
| 4826 | { |
| 4827 | //Not to get channel info if the scan is not a wildcard scan because |
| 4828 | //it may cause scan results got aged out incorrectly. |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 4829 | if( csrScanIsWildCardScan( pMac, pCommand ) && (!pCommand->u.scanCmd.u.scanRequest.p2pSearch) |
| 4830 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 4831 | && (pCommand->u.scanCmd.reason != eCsrScanGetLfrResult) |
| 4832 | #endif |
| 4833 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4834 | { |
| 4835 | //Get the list of channels scanned |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 4836 | if( pCommand->u.scanCmd.reason != eCsrScanUserRequest) |
| 4837 | { |
| 4838 | csrScanGetScanChnInfo(pMac, NULL, NULL); |
| 4839 | } |
| 4840 | else |
| 4841 | { |
| 4842 | csrScanGetScanChnInfo(pMac, pCommand->u.scanCmd.callback, pCommand->u.scanCmd.pContext); |
| 4843 | pCommand->u.scanCmd.callback = NULL; |
| 4844 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4845 | } |
| 4846 | } |
| 4847 | break; |
| 4848 | }//switch |
| 4849 | if(fRemoveCommand) |
| 4850 | { |
| 4851 | |
| 4852 | csrReleaseScanCommand(pMac, pCommand, scanStatus); |
| 4853 | |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 4854 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4855 | smeProcessPendingQueue( pMac ); |
| 4856 | } |
| 4857 | else |
| 4858 | { |
| 4859 | smsLog( pMac, LOGW, "CSR: Scan Completion called but SCAN command is not ACTIVE ..." ); |
| 4860 | status = eHAL_STATUS_FAILURE; |
| 4861 | } |
| 4862 | } |
| 4863 | else |
| 4864 | { |
| 4865 | smsLog( pMac, LOGW, "CSR: Scan Completion called but NO commands are ACTIVE ..." ); |
| 4866 | status = eHAL_STATUS_FAILURE; |
| 4867 | } |
| 4868 | |
| 4869 | return (status); |
| 4870 | } |
| 4871 | |
| 4872 | |
| 4873 | |
| 4874 | |
| 4875 | tCsrScanResultInfo *csrScanResultGetFirst(tpAniSirGlobal pMac, tScanResultHandle hScanResult) |
| 4876 | { |
| 4877 | tListElem *pEntry; |
| 4878 | tCsrScanResult *pResult; |
| 4879 | tCsrScanResultInfo *pRet = NULL; |
| 4880 | tScanResultList *pResultList = (tScanResultList *)hScanResult; |
| 4881 | |
| 4882 | if(pResultList) |
| 4883 | { |
| 4884 | csrLLLock(&pResultList->List); |
| 4885 | pEntry = csrLLPeekHead(&pResultList->List, LL_ACCESS_NOLOCK); |
| 4886 | if(pEntry) |
| 4887 | { |
| 4888 | pResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link); |
| 4889 | pRet = &pResult->Result; |
| 4890 | } |
| 4891 | pResultList->pCurEntry = pEntry; |
| 4892 | csrLLUnlock(&pResultList->List); |
| 4893 | } |
| 4894 | |
| 4895 | return pRet; |
| 4896 | } |
| 4897 | |
| 4898 | |
| 4899 | tCsrScanResultInfo *csrScanResultGetNext(tpAniSirGlobal pMac, tScanResultHandle hScanResult) |
| 4900 | { |
| 4901 | tListElem *pEntry = NULL; |
| 4902 | tCsrScanResult *pResult = NULL; |
| 4903 | tCsrScanResultInfo *pRet = NULL; |
| 4904 | tScanResultList *pResultList = (tScanResultList *)hScanResult; |
| 4905 | |
| 4906 | if(pResultList) |
| 4907 | { |
| 4908 | csrLLLock(&pResultList->List); |
| 4909 | if(NULL == pResultList->pCurEntry) |
| 4910 | { |
| 4911 | pEntry = csrLLPeekHead(&pResultList->List, LL_ACCESS_NOLOCK); |
| 4912 | } |
| 4913 | else |
| 4914 | { |
| 4915 | pEntry = csrLLNext(&pResultList->List, pResultList->pCurEntry, LL_ACCESS_NOLOCK); |
| 4916 | } |
| 4917 | if(pEntry) |
| 4918 | { |
| 4919 | pResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link); |
| 4920 | pRet = &pResult->Result; |
| 4921 | } |
| 4922 | pResultList->pCurEntry = pEntry; |
| 4923 | csrLLUnlock(&pResultList->List); |
| 4924 | } |
| 4925 | |
| 4926 | return pRet; |
| 4927 | } |
| 4928 | |
| 4929 | |
| 4930 | //This function moves the first BSS that matches the bssid to the head of the result |
| 4931 | eHalStatus csrMoveBssToHeadFromBSSID(tpAniSirGlobal pMac, tCsrBssid *bssid, tScanResultHandle hScanResult) |
| 4932 | { |
| 4933 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 4934 | tScanResultList *pResultList = (tScanResultList *)hScanResult; |
| 4935 | tCsrScanResult *pResult = NULL; |
| 4936 | tListElem *pEntry = NULL; |
| 4937 | |
| 4938 | if(pResultList && bssid) |
| 4939 | { |
| 4940 | csrLLLock(&pResultList->List); |
| 4941 | pEntry = csrLLPeekHead(&pResultList->List, LL_ACCESS_NOLOCK); |
| 4942 | while(pEntry) |
| 4943 | { |
| 4944 | pResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link); |
| 4945 | if(palEqualMemory(pMac->hHdd, bssid, pResult->Result.BssDescriptor.bssId, sizeof(tCsrBssid))) |
| 4946 | { |
| 4947 | status = eHAL_STATUS_SUCCESS; |
| 4948 | csrLLRemoveEntry(&pResultList->List, pEntry, LL_ACCESS_NOLOCK); |
| 4949 | csrLLInsertHead(&pResultList->List, pEntry, LL_ACCESS_NOLOCK); |
| 4950 | break; |
| 4951 | } |
| 4952 | pEntry = csrLLNext(&pResultList->List, pResultList->pCurEntry, LL_ACCESS_NOLOCK); |
| 4953 | } |
| 4954 | csrLLUnlock(&pResultList->List); |
| 4955 | } |
| 4956 | |
| 4957 | return (status); |
| 4958 | } |
| 4959 | |
| 4960 | |
| 4961 | //Remove the BSS if possible. |
| 4962 | //Return -- TRUE == the BSS is remove. False == Fail to remove it |
| 4963 | //This function is called when list lock is held. Be caution what functions it can call. |
| 4964 | tANI_BOOLEAN csrScanAgeOutBss(tpAniSirGlobal pMac, tCsrScanResult *pResult) |
| 4965 | { |
| 4966 | tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE; |
| 4967 | tANI_U32 i; |
| 4968 | tCsrRoamSession *pSession; |
| 4969 | |
| 4970 | for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ ) |
| 4971 | { |
| 4972 | if( CSR_IS_SESSION_VALID( pMac, i ) ) |
| 4973 | { |
| 4974 | pSession = CSR_GET_SESSION( pMac, i ); |
| 4975 | //Not to remove the BSS we are connected to. |
| 4976 | if(csrIsConnStateDisconnected(pMac, i) || (NULL == pSession->pConnectBssDesc) || |
| 4977 | (!csrIsDuplicateBssDescription(pMac, &pResult->Result.BssDescriptor, |
Tushnim Bhattacharyya | 5128d75 | 2013-06-26 23:23:18 -0700 | [diff] [blame] | 4978 | pSession->pConnectBssDesc, NULL, FALSE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4979 | ) |
| 4980 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 4981 | 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] | 4982 | pResult->Result.BssDescriptor.bssId[0], |
| 4983 | pResult->Result.BssDescriptor.bssId[1], |
| 4984 | pResult->Result.BssDescriptor.bssId[2], |
| 4985 | pResult->Result.BssDescriptor.bssId[3], |
| 4986 | pResult->Result.BssDescriptor.bssId[4], |
| 4987 | pResult->Result.BssDescriptor.bssId[5], |
| 4988 | pResult->Result.BssDescriptor.channelId); |
| 4989 | //No need to hold the spin lock because caller should hold the lock for pMac->scan.scanResultList |
| 4990 | if( csrLLRemoveEntry(&pMac->scan.scanResultList, &pResult->Link, LL_ACCESS_NOLOCK) ) |
| 4991 | { |
| 4992 | csrFreeScanResultEntry(pMac, pResult); |
Madan Mohan Koyyalamudi | 2e068bc | 2012-10-22 14:58:47 -0700 | [diff] [blame] | 4993 | fRet = eANI_BOOLEAN_TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4994 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4995 | break; |
| 4996 | } |
| 4997 | } //valid session |
| 4998 | } //for |
Madan Mohan Koyyalamudi | 2e068bc | 2012-10-22 14:58:47 -0700 | [diff] [blame] | 4999 | if( CSR_ROAM_SESSION_MAX == i && fRet != eANI_BOOLEAN_TRUE ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5000 | { |
| 5001 | //reset the counter so this won't hapeen too soon |
| 5002 | pResult->AgingCount = (tANI_S32)pMac->roam.configParam.agingCount; |
| 5003 | pResult->Result.BssDescriptor.nReceivedTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd); |
| 5004 | } |
| 5005 | |
| 5006 | return (fRet); |
| 5007 | } |
| 5008 | |
| 5009 | |
| 5010 | eHalStatus csrScanAgeResults(tpAniSirGlobal pMac, tSmeGetScanChnRsp *pScanChnInfo) |
| 5011 | { |
| 5012 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 5013 | tListElem *pEntry, *tmpEntry; |
| 5014 | tCsrScanResult *pResult; |
| 5015 | tLimScanChn *pChnInfo; |
| 5016 | tANI_U8 i; |
| 5017 | |
| 5018 | csrLLLock(&pMac->scan.scanResultList); |
| 5019 | for(i = 0; i < pScanChnInfo->numChn; i++) |
| 5020 | { |
| 5021 | pChnInfo = &pScanChnInfo->scanChn[i]; |
| 5022 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK ); |
| 5023 | while( pEntry ) |
| 5024 | { |
| 5025 | tmpEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK); |
| 5026 | pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 5027 | if(pResult->Result.BssDescriptor.channelId == pChnInfo->channelId) |
| 5028 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5029 | if(pResult->AgingCount <= 0) |
| 5030 | { |
| 5031 | smsLog(pMac, LOGW, " age out due to ref count"); |
| 5032 | csrScanAgeOutBss(pMac, pResult); |
| 5033 | } |
Madan Mohan Koyyalamudi | b9d3dcc | 2012-09-28 16:47:50 -0700 | [diff] [blame] | 5034 | else |
| 5035 | { |
| 5036 | pResult->AgingCount--; |
| 5037 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5038 | } |
| 5039 | pEntry = tmpEntry; |
| 5040 | } |
| 5041 | } |
| 5042 | csrLLUnlock(&pMac->scan.scanResultList); |
| 5043 | |
| 5044 | return (status); |
| 5045 | } |
| 5046 | |
| 5047 | |
| 5048 | eHalStatus csrSendMBScanReq( tpAniSirGlobal pMac, tANI_U16 sessionId, |
| 5049 | tCsrScanRequest *pScanReq, tScanReqParam *pScanReqParam ) |
| 5050 | { |
| 5051 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 5052 | tSirSmeScanReq *pMsg; |
| 5053 | tANI_U16 msgLen; |
| 5054 | tANI_U8 bssid[WNI_CFG_BSSID_LEN] = {0, 0, 0, 0, 0, 0}; |
| 5055 | tSirScanType scanType = pScanReq->scanType; |
| 5056 | tANI_U32 minChnTime; //in units of milliseconds |
| 5057 | tANI_U32 maxChnTime; //in units of milliseconds |
| 5058 | tANI_U32 i; |
| 5059 | tANI_U8 selfMacAddr[WNI_CFG_BSSID_LEN]; |
| 5060 | tANI_U8 *pSelfMac = NULL; |
| 5061 | |
| 5062 | msgLen = (tANI_U16)(sizeof( tSirSmeScanReq ) - sizeof( pMsg->channelList.channelNumber ) + |
| 5063 | ( sizeof( pMsg->channelList.channelNumber ) * pScanReq->ChannelInfo.numOfChannels )) + |
| 5064 | ( pScanReq->uIEFieldLen ) ; |
| 5065 | |
| 5066 | status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen); |
| 5067 | if(HAL_STATUS_SUCCESS(status)) |
| 5068 | { |
| 5069 | do |
| 5070 | { |
| 5071 | palZeroMemory(pMac->hHdd, pMsg, msgLen); |
| 5072 | pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SCAN_REQ); |
| 5073 | pMsg->length = pal_cpu_to_be16(msgLen); |
| 5074 | //ToDO: Fill in session info when we need to do scan base on session. |
| 5075 | pMsg->sessionId = 0; |
| 5076 | pMsg->transactionId = 0; |
| 5077 | pMsg->dot11mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac, csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode )); |
| 5078 | pMsg->bssType = pal_cpu_to_be32(csrTranslateBsstypeToMacType(pScanReq->BSSType)); |
| 5079 | |
| 5080 | if ( CSR_IS_SESSION_VALID( pMac, sessionId ) ) |
| 5081 | { |
| 5082 | pSelfMac = (tANI_U8 *)&pMac->roam.roamSession[sessionId].selfMacAddr; |
| 5083 | } |
| 5084 | else |
| 5085 | { |
| 5086 | // Since we don't have session for the scanning, we find a valid session. In case we fail to |
| 5087 | // do so, get the WNI_CFG_STA_ID |
| 5088 | for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ ) |
| 5089 | { |
| 5090 | if( CSR_IS_SESSION_VALID( pMac, i ) ) |
| 5091 | { |
| 5092 | pSelfMac = (tANI_U8 *)&pMac->roam.roamSession[i].selfMacAddr; |
| 5093 | break; |
| 5094 | } |
| 5095 | } |
| 5096 | if( CSR_ROAM_SESSION_MAX == i ) |
| 5097 | { |
| 5098 | tANI_U32 len = WNI_CFG_BSSID_LEN; |
| 5099 | pSelfMac = selfMacAddr; |
| 5100 | status = ccmCfgGetStr( pMac, WNI_CFG_STA_ID, pSelfMac, &len ); |
| 5101 | if( !HAL_STATUS_SUCCESS( status ) || |
| 5102 | ( len < WNI_CFG_BSSID_LEN ) ) |
| 5103 | { |
| 5104 | smsLog( pMac, LOGE, FL(" Can not get self MAC address from CFG status = %d"), status ); |
| 5105 | //Force failed status |
| 5106 | status = eHAL_STATUS_FAILURE; |
| 5107 | break; |
| 5108 | } |
| 5109 | } |
| 5110 | } |
| 5111 | palCopyMemory( pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr, pSelfMac, sizeof(tSirMacAddr) ); |
| 5112 | |
| 5113 | //sirCopyMacAddr |
| 5114 | palCopyMemory( pMac->hHdd, (tANI_U8 *)pMsg->bssId, (tANI_U8 *)&pScanReq->bssid, sizeof(tSirMacAddr) ); |
| 5115 | if( palEqualMemory( pMac->hHdd, pScanReq->bssid, bssid, sizeof(tCsrBssid) ) ) |
| 5116 | { |
| 5117 | palFillMemory( pMac->hHdd, pMsg->bssId, sizeof(tSirMacAddr), 0xff ); |
| 5118 | } |
| 5119 | else |
| 5120 | { |
| 5121 | palCopyMemory(pMac->hHdd, pMsg->bssId, pScanReq->bssid, WNI_CFG_BSSID_LEN); |
| 5122 | } |
| 5123 | minChnTime = pScanReq->minChnTime; |
| 5124 | maxChnTime = pScanReq->maxChnTime; |
| 5125 | |
| 5126 | //Verify the scan type first, if the scan is active scan, we need to make sure we |
| 5127 | //are allowed to do so. |
| 5128 | /* if 11d is enabled & we don't see any beacon around, scan type falls |
| 5129 | back to passive. But in BT AMP STA mode we need to send out a |
| 5130 | directed probe*/ |
| 5131 | if( (eSIR_PASSIVE_SCAN != scanType) && (eCSR_SCAN_P2P_DISCOVERY != pScanReq->requestType) |
| 5132 | && (eCSR_BSS_TYPE_WDS_STA != pScanReq->BSSType) |
| 5133 | && (eANI_BOOLEAN_FALSE == pMac->scan.fEnableBypass11d)) |
| 5134 | { |
| 5135 | scanType = pMac->scan.curScanType; |
| 5136 | if(eSIR_PASSIVE_SCAN == pMac->scan.curScanType) |
| 5137 | { |
| 5138 | if(minChnTime < pMac->roam.configParam.nPassiveMinChnTime) |
| 5139 | { |
| 5140 | minChnTime = pMac->roam.configParam.nPassiveMinChnTime; |
| 5141 | } |
| 5142 | if(maxChnTime < pMac->roam.configParam.nPassiveMaxChnTime) |
| 5143 | { |
| 5144 | maxChnTime = pMac->roam.configParam.nPassiveMaxChnTime; |
| 5145 | } |
| 5146 | } |
| 5147 | } |
| 5148 | pMsg->scanType = pal_cpu_to_be32(scanType); |
| 5149 | |
| 5150 | pMsg->numSsid = (pScanReq->SSIDs.numOfSSIDs < SIR_SCAN_MAX_NUM_SSID) ? pScanReq->SSIDs.numOfSSIDs : |
| 5151 | SIR_SCAN_MAX_NUM_SSID; |
| 5152 | if((pScanReq->SSIDs.numOfSSIDs != 0) && ( eSIR_PASSIVE_SCAN != scanType )) |
| 5153 | { |
Jeff Johnson | 40b59aa | 2013-03-19 14:43:18 -0700 | [diff] [blame] | 5154 | for (i = 0; i < pMsg->numSsid; i++) |
| 5155 | { |
| 5156 | palCopyMemory(pMac->hHdd, &pMsg->ssId[i], &pScanReq->SSIDs.SSIDList[i].SSID, sizeof(tSirMacSSid)); |
| 5157 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5158 | } |
| 5159 | else |
| 5160 | { |
| 5161 | //Otherwise we scan all SSID and let the result filter later |
Jeff Johnson | 40b59aa | 2013-03-19 14:43:18 -0700 | [diff] [blame] | 5162 | for (i = 0; i < SIR_SCAN_MAX_NUM_SSID; i++) |
| 5163 | { |
| 5164 | pMsg->ssId[i].length = 0; |
| 5165 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5166 | } |
| 5167 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5168 | pMsg->minChannelTime = pal_cpu_to_be32(minChnTime); |
| 5169 | pMsg->maxChannelTime = pal_cpu_to_be32(maxChnTime); |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 5170 | pMsg->minChannelTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc; |
| 5171 | pMsg->maxChannelTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5172 | //hidden SSID option |
| 5173 | pMsg->hiddenSsid = pScanReqParam->hiddenSsid; |
| 5174 | //rest time |
| 5175 | //pMsg->restTime = pScanReq->restTime; |
| 5176 | pMsg->returnAfterFirstMatch = pScanReqParam->bReturnAfter1stMatch; |
| 5177 | // All the scan results caching will be done by Roaming |
| 5178 | // We do not want LIM to do any caching of scan results, |
| 5179 | // so delete the LIM cache on all scan requests |
| 5180 | pMsg->returnFreshResults = pScanReqParam->freshScan; |
| 5181 | //Always ask for unique result |
| 5182 | pMsg->returnUniqueResults = pScanReqParam->fUniqueResult; |
| 5183 | pMsg->channelList.numChannels = (tANI_U8)pScanReq->ChannelInfo.numOfChannels; |
| 5184 | if(pScanReq->ChannelInfo.numOfChannels) |
| 5185 | { |
| 5186 | //Assuming the channelNumber is tANI_U8 (1 byte) |
| 5187 | status = palCopyMemory(pMac->hHdd, pMsg->channelList.channelNumber, pScanReq->ChannelInfo.ChannelList, |
| 5188 | pScanReq->ChannelInfo.numOfChannels); |
| 5189 | } |
| 5190 | |
| 5191 | pMsg->uIEFieldLen = (tANI_U16) pScanReq->uIEFieldLen; |
| 5192 | pMsg->uIEFieldOffset = (tANI_U16)(sizeof( tSirSmeScanReq ) - sizeof( pMsg->channelList.channelNumber ) + |
| 5193 | ( sizeof( pMsg->channelList.channelNumber ) * pScanReq->ChannelInfo.numOfChannels )) ; |
| 5194 | if(pScanReq->uIEFieldLen != 0) |
| 5195 | { |
| 5196 | palCopyMemory(pMac->hHdd, (tANI_U8 *)pMsg+pMsg->uIEFieldOffset, |
| 5197 | pScanReq->pIEField, pScanReq->uIEFieldLen ); |
| 5198 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5199 | pMsg->p2pSearch = pScanReq->p2pSearch; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5200 | |
Madan Mohan Koyyalamudi | 9b87678 | 2012-10-11 16:22:51 -0700 | [diff] [blame] | 5201 | if (pScanReq->requestType == eCSR_SCAN_HO_BG_SCAN) |
| 5202 | { |
| 5203 | pMsg->backgroundScanMode = eSIR_ROAMING_SCAN; |
| 5204 | } |
| 5205 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5206 | }while(0); |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5207 | 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] | 5208 | pMac->scan.domainIdCurrent, pMsg->scanType, pMsg->bssType, |
| 5209 | pScanReq->requestType, pMsg->channelList.numChannels); |
| 5210 | |
| 5211 | for(i = 0; i < pMsg->channelList.numChannels; i++) |
| 5212 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5213 | smsLog(pMac, LOG3, FL("channelNumber[%d]= %d"), i, pMsg->channelList.channelNumber[i]); |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 5214 | } |
| 5215 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5216 | if(HAL_STATUS_SUCCESS(status)) |
| 5217 | { |
| 5218 | status = palSendMBMessage(pMac->hHdd, pMsg); |
| 5219 | } |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 5220 | else |
| 5221 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5222 | 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] | 5223 | palFreeMemory(pMac->hHdd, pMsg); |
| 5224 | } |
| 5225 | }//Success allocated memory |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 5226 | else |
| 5227 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5228 | smsLog( pMac, LOGE, FL(" memory allocation failure")); |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 5229 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5230 | |
| 5231 | return( status ); |
| 5232 | } |
| 5233 | |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 5234 | eHalStatus csrSendMBScanResultReq( tpAniSirGlobal pMac, tANI_U32 sessionId, tScanReqParam *pScanReqParam ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5235 | { |
| 5236 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 5237 | tSirSmeScanReq *pMsg; |
| 5238 | tANI_U16 msgLen; |
| 5239 | |
| 5240 | msgLen = (tANI_U16)(sizeof( tSirSmeScanReq )); |
| 5241 | status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen); |
| 5242 | if(HAL_STATUS_SUCCESS(status)) |
| 5243 | { |
| 5244 | palZeroMemory(pMac->hHdd, pMsg, msgLen); |
| 5245 | pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SCAN_REQ); |
| 5246 | pMsg->length = pal_cpu_to_be16(msgLen); |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 5247 | pMsg->sessionId = sessionId; |
| 5248 | pMsg->transactionId = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5249 | pMsg->returnFreshResults = pScanReqParam->freshScan; |
| 5250 | //Always ask for unique result |
| 5251 | pMsg->returnUniqueResults = pScanReqParam->fUniqueResult; |
| 5252 | pMsg->returnAfterFirstMatch = pScanReqParam->bReturnAfter1stMatch; |
| 5253 | status = palSendMBMessage(pMac->hHdd, pMsg); |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 5254 | if (!HAL_STATUS_SUCCESS(status)) |
| 5255 | { |
| 5256 | smsLog( pMac, LOGE, FL(" failed to send down scan req with status = %d\n"), status ); |
| 5257 | } |
| 5258 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5259 | } |
| 5260 | |
| 5261 | return( status ); |
| 5262 | } |
| 5263 | |
| 5264 | |
| 5265 | |
| 5266 | eHalStatus csrScanChannels( tpAniSirGlobal pMac, tSmeCmd *pCommand ) |
| 5267 | { |
| 5268 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 5269 | tScanReqParam scanReq; |
| 5270 | |
| 5271 | do |
| 5272 | { |
| 5273 | scanReq.freshScan = CSR_SME_SCAN_FLAGS_DELETE_CACHE | TRUE; |
| 5274 | scanReq.fUniqueResult = TRUE; |
| 5275 | scanReq.hiddenSsid = SIR_SCAN_NO_HIDDEN_SSID; |
| 5276 | if(eCsrScanForSsid == pCommand->u.scanCmd.reason) |
| 5277 | { |
| 5278 | scanReq.bReturnAfter1stMatch = CSR_SCAN_RETURN_AFTER_FIRST_MATCH; |
| 5279 | } |
| 5280 | else |
| 5281 | { |
| 5282 | // Basically do scan on all channels even for 11D 1st scan case. |
| 5283 | scanReq.bReturnAfter1stMatch = CSR_SCAN_RETURN_AFTER_ALL_CHANNELS; |
| 5284 | } |
| 5285 | if((eCsrScanBgScan == pCommand->u.scanCmd.reason)|| |
| 5286 | (eCsrScanProbeBss == pCommand->u.scanCmd.reason)) |
| 5287 | { |
| 5288 | scanReq.hiddenSsid = SIR_SCAN_HIDDEN_SSID_PE_DECISION; |
| 5289 | } |
| 5290 | |
| 5291 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 5292 | { |
| 5293 | vos_log_scan_pkt_type *pScanLog = NULL; |
| 5294 | |
| 5295 | WLAN_VOS_DIAG_LOG_ALLOC(pScanLog, vos_log_scan_pkt_type, LOG_WLAN_SCAN_C); |
| 5296 | if(pScanLog) |
| 5297 | { |
| 5298 | if(eCsrScanBgScan == pCommand->u.scanCmd.reason || |
| 5299 | eCsrScanProbeBss == pCommand->u.scanCmd.reason) |
| 5300 | { |
| 5301 | pScanLog->eventId = WLAN_SCAN_EVENT_HO_SCAN_REQ; |
| 5302 | } |
| 5303 | else |
| 5304 | { |
| 5305 | if( (eSIR_PASSIVE_SCAN != pCommand->u.scanCmd.u.scanRequest.scanType) && |
| 5306 | (eSIR_PASSIVE_SCAN != pMac->scan.curScanType) ) |
| 5307 | { |
| 5308 | pScanLog->eventId = WLAN_SCAN_EVENT_ACTIVE_SCAN_REQ; |
| 5309 | } |
| 5310 | else |
| 5311 | { |
| 5312 | pScanLog->eventId = WLAN_SCAN_EVENT_PASSIVE_SCAN_REQ; |
| 5313 | } |
| 5314 | } |
| 5315 | pScanLog->minChnTime = (v_U8_t)pCommand->u.scanCmd.u.scanRequest.minChnTime; |
| 5316 | pScanLog->maxChnTime = (v_U8_t)pCommand->u.scanCmd.u.scanRequest.maxChnTime; |
| 5317 | pScanLog->numChannel = (v_U8_t)pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels; |
| 5318 | if(pScanLog->numChannel && (pScanLog->numChannel < VOS_LOG_MAX_NUM_CHANNEL)) |
| 5319 | { |
| 5320 | palCopyMemory(pMac->hHdd, pScanLog->channels, |
| 5321 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList, |
| 5322 | pScanLog->numChannel); |
| 5323 | } |
| 5324 | WLAN_VOS_DIAG_LOG_REPORT(pScanLog); |
| 5325 | } |
| 5326 | } |
| 5327 | #endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 5328 | |
| 5329 | |
| 5330 | status = csrSendMBScanReq(pMac, pCommand->sessionId, |
| 5331 | &pCommand->u.scanCmd.u.scanRequest, &scanReq); |
| 5332 | }while(0); |
| 5333 | |
| 5334 | return( status ); |
| 5335 | } |
| 5336 | |
| 5337 | |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 5338 | eHalStatus csrScanRetrieveResult(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5339 | { |
| 5340 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 5341 | tScanReqParam scanReq; |
| 5342 | |
| 5343 | do |
| 5344 | { |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 5345 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 5346 | if (eCsrScanGetLfrResult == pCommand->u.scanCmd.reason) |
| 5347 | { |
| 5348 | //to get the LFR candidates from PE cache |
| 5349 | scanReq.freshScan = SIR_BG_SCAN_RETURN_LFR_CACHED_RESULTS|SIR_BG_SCAN_PURGE_LFR_RESULTS; |
| 5350 | scanReq.fUniqueResult = TRUE; |
| 5351 | scanReq.bReturnAfter1stMatch = CSR_SCAN_RETURN_AFTER_ALL_CHANNELS; |
| 5352 | } |
| 5353 | else |
| 5354 | #endif |
| 5355 | { |
| 5356 | //not a fresh scan |
| 5357 | scanReq.freshScan = CSR_SME_SCAN_FLAGS_DELETE_CACHE; |
| 5358 | scanReq.fUniqueResult = TRUE; |
| 5359 | scanReq.bReturnAfter1stMatch = CSR_SCAN_RETURN_AFTER_ALL_CHANNELS; |
| 5360 | } |
| 5361 | status = csrSendMBScanResultReq(pMac, pCommand->sessionId, &scanReq); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5362 | }while(0); |
| 5363 | |
| 5364 | return (status); |
| 5365 | } |
| 5366 | |
| 5367 | |
| 5368 | |
| 5369 | eHalStatus csrProcessScanCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand ) |
| 5370 | { |
| 5371 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 5372 | tCsrChannelInfo newChannelInfo = {0, NULL}; |
| 5373 | int i, j; |
| 5374 | tANI_U8 *pChannel = NULL; |
| 5375 | tANI_U32 len = 0; |
| 5376 | |
| 5377 | // Transition to Scanning state... |
| 5378 | for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ ) |
| 5379 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5380 | 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] | 5381 | 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] | 5382 | } |
| 5383 | |
| 5384 | switch(pCommand->u.scanCmd.reason) |
| 5385 | { |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 5386 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 5387 | case eCsrScanGetLfrResult: |
| 5388 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5389 | case eCsrScanGetResult: |
| 5390 | case eCsrScanForCapsChange: //For cap change, LIM already save BSS description |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 5391 | status = csrScanRetrieveResult(pMac, pCommand); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5392 | break; |
| 5393 | case eCsrScanSetBGScanParam: |
| 5394 | status = csrProcessSetBGScanParam(pMac, pCommand); |
| 5395 | break; |
| 5396 | case eCsrScanBGScanAbort: |
| 5397 | status = csrSetCfgBackgroundScanPeriod(pMac, 0); |
| 5398 | break; |
| 5399 | case eCsrScanBGScanEnable: |
| 5400 | status = csrSetCfgBackgroundScanPeriod(pMac, pMac->roam.configParam.bgScanInterval); |
| 5401 | break; |
| 5402 | case eCsrScanGetScanChnInfo: |
| 5403 | status = csrScanGetScanChannelInfo(pMac); |
| 5404 | break; |
| 5405 | case eCsrScanUserRequest: |
| 5406 | if(pMac->roam.configParam.fScanTwice) |
| 5407 | { |
| 5408 | //We scan 2.4 channel twice |
| 5409 | if(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels && |
| 5410 | (NULL != pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList)) |
| 5411 | { |
| 5412 | len = pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels; |
| 5413 | //allocate twice the channel |
| 5414 | newChannelInfo.ChannelList = (tANI_U8 *)vos_mem_malloc(newChannelInfo.numOfChannels * 2); |
| 5415 | pChannel = pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList; |
| 5416 | } |
| 5417 | else |
| 5418 | { |
| 5419 | //get the valid channel list to scan all. |
| 5420 | len = sizeof(pMac->roam.validChannelList); |
| 5421 | |
| 5422 | if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len))) |
| 5423 | { |
| 5424 | //allocate twice the channel |
| 5425 | newChannelInfo.ChannelList = (tANI_U8 *)vos_mem_malloc(len * 2); |
| 5426 | pChannel = pMac->roam.validChannelList; |
| 5427 | } |
| 5428 | } |
| 5429 | if(NULL == newChannelInfo.ChannelList) |
| 5430 | { |
| 5431 | newChannelInfo.numOfChannels = 0; |
| 5432 | } |
| 5433 | else |
| 5434 | { |
| 5435 | j = 0; |
| 5436 | for(i = 0; i < len; i++) |
| 5437 | { |
| 5438 | newChannelInfo.ChannelList[j++] = pChannel[i]; |
| 5439 | if(CSR_MAX_24GHz_CHANNEL_NUMBER >= pChannel[i]) |
| 5440 | { |
| 5441 | newChannelInfo.ChannelList[j++] = pChannel[i]; |
| 5442 | } |
| 5443 | } |
| 5444 | if(NULL != pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList) |
| 5445 | { |
| 5446 | //pChannel points to the channellist from the command, free it. |
| 5447 | vos_mem_free(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList); |
James Zmuda | 9ea1edd | 2013-04-18 18:20:54 -0700 | [diff] [blame] | 5448 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5449 | } |
| 5450 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = j; |
| 5451 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = newChannelInfo.ChannelList; |
| 5452 | } |
| 5453 | } //if(pMac->roam.configParam.fScanTwice) |
| 5454 | |
| 5455 | status = csrScanChannels(pMac, pCommand); |
| 5456 | |
| 5457 | break; |
| 5458 | default: |
| 5459 | status = csrScanChannels(pMac, pCommand); |
| 5460 | break; |
| 5461 | } |
| 5462 | |
| 5463 | if(!HAL_STATUS_SUCCESS(status)) |
| 5464 | { |
| 5465 | csrReleaseScanCommand(pMac, pCommand, eCSR_SCAN_FAILURE); |
| 5466 | } |
| 5467 | |
| 5468 | return (status); |
| 5469 | } |
| 5470 | |
| 5471 | |
| 5472 | eHalStatus csrScanSetBGScanparams(tpAniSirGlobal pMac, tCsrBGScanRequest *pScanReq) |
| 5473 | { |
| 5474 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 5475 | tSmeCmd *pCommand = NULL; |
| 5476 | |
| 5477 | if(pScanReq) |
| 5478 | { |
| 5479 | do |
| 5480 | { |
| 5481 | pCommand = csrGetCommandBuffer(pMac); |
| 5482 | if(!pCommand) |
| 5483 | { |
| 5484 | status = eHAL_STATUS_RESOURCES; |
| 5485 | break; |
| 5486 | } |
| 5487 | palZeroMemory(pMac->hHdd, &pCommand->u.scanCmd, sizeof(tScanCmd)); |
| 5488 | pCommand->command = eSmeCommandScan; |
| 5489 | pCommand->u.scanCmd.reason = eCsrScanSetBGScanParam; |
| 5490 | pCommand->u.scanCmd.callback = NULL; |
| 5491 | pCommand->u.scanCmd.pContext = NULL; |
| 5492 | palCopyMemory(pMac->hHdd, &pCommand->u.scanCmd.u.bgScanRequest, pScanReq, sizeof(tCsrBGScanRequest)); |
| 5493 | //we have to do the follow |
| 5494 | if(pScanReq->ChannelInfo.numOfChannels == 0) |
| 5495 | { |
| 5496 | pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList = NULL; |
| 5497 | } |
| 5498 | else |
| 5499 | { |
| 5500 | status = palAllocateMemory(pMac->hHdd, (void **)&pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList, |
| 5501 | pScanReq->ChannelInfo.numOfChannels); |
| 5502 | if(HAL_STATUS_SUCCESS(status)) |
| 5503 | { |
| 5504 | palCopyMemory(pMac->hHdd, pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList, |
| 5505 | pScanReq->ChannelInfo.ChannelList, pScanReq->ChannelInfo.numOfChannels); |
| 5506 | } |
| 5507 | else |
| 5508 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5509 | smsLog(pMac, LOGE, FL("ran out of memory")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5510 | csrReleaseCommandScan(pMac, pCommand); |
| 5511 | break; |
| 5512 | } |
| 5513 | } |
| 5514 | |
| 5515 | //scan req for SSID |
| 5516 | if(pScanReq->SSID.length) |
| 5517 | { |
| 5518 | palCopyMemory(pMac->hHdd, |
| 5519 | pCommand->u.scanCmd.u.bgScanRequest.SSID.ssId, |
| 5520 | pScanReq->SSID.ssId, |
| 5521 | pScanReq->SSID.length); |
| 5522 | pCommand->u.scanCmd.u.bgScanRequest.SSID.length = pScanReq->SSID.length; |
| 5523 | |
| 5524 | } |
| 5525 | pCommand->u.scanCmd.u.bgScanRequest.maxChnTime= pScanReq->maxChnTime; |
| 5526 | pCommand->u.scanCmd.u.bgScanRequest.minChnTime = pScanReq->minChnTime; |
| 5527 | pCommand->u.scanCmd.u.bgScanRequest.scanInterval = pScanReq->scanInterval; |
| 5528 | |
| 5529 | |
| 5530 | status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE); |
| 5531 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 5532 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5533 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5534 | csrReleaseCommandScan( pMac, pCommand ); |
| 5535 | break; |
| 5536 | } |
| 5537 | }while(0); |
| 5538 | } |
| 5539 | |
| 5540 | return (status); |
| 5541 | } |
| 5542 | |
| 5543 | eHalStatus csrScanBGScanAbort( tpAniSirGlobal pMac ) |
| 5544 | { |
| 5545 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 5546 | tSmeCmd *pCommand = NULL; |
| 5547 | |
| 5548 | do |
| 5549 | { |
| 5550 | pCommand = csrGetCommandBuffer(pMac); |
| 5551 | if(!pCommand) |
| 5552 | { |
| 5553 | status = eHAL_STATUS_RESOURCES; |
| 5554 | break; |
| 5555 | } |
| 5556 | palZeroMemory(pMac->hHdd, &pCommand->u.scanCmd, sizeof(tScanCmd)); |
| 5557 | pCommand->command = eSmeCommandScan; |
| 5558 | pCommand->u.scanCmd.reason = eCsrScanBGScanAbort; |
| 5559 | pCommand->u.scanCmd.callback = NULL; |
| 5560 | pCommand->u.scanCmd.pContext = NULL; |
| 5561 | status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE); |
| 5562 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 5563 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5564 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5565 | csrReleaseCommandScan( pMac, pCommand ); |
| 5566 | break; |
| 5567 | } |
| 5568 | }while(0); |
| 5569 | |
| 5570 | return (status); |
| 5571 | } |
| 5572 | |
| 5573 | |
| 5574 | //This will enable the background scan with the non-zero interval |
| 5575 | eHalStatus csrScanBGScanEnable(tpAniSirGlobal pMac) |
| 5576 | { |
| 5577 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 5578 | tSmeCmd *pCommand = NULL; |
| 5579 | |
| 5580 | if(pMac->roam.configParam.bgScanInterval) |
| 5581 | { |
| 5582 | do |
| 5583 | { |
| 5584 | pCommand = csrGetCommandBuffer(pMac); |
| 5585 | if(!pCommand) |
| 5586 | { |
| 5587 | status = eHAL_STATUS_RESOURCES; |
| 5588 | break; |
| 5589 | } |
| 5590 | palZeroMemory(pMac->hHdd, &pCommand->u.scanCmd, sizeof(tScanCmd)); |
| 5591 | pCommand->command = eSmeCommandScan; |
| 5592 | pCommand->u.scanCmd.reason = eCsrScanBGScanEnable; |
| 5593 | pCommand->u.scanCmd.callback = NULL; |
| 5594 | pCommand->u.scanCmd.pContext = NULL; |
| 5595 | status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE); |
| 5596 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 5597 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5598 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5599 | csrReleaseCommandScan( pMac, pCommand ); |
| 5600 | break; |
| 5601 | } |
| 5602 | }while(0); |
| 5603 | //BG scan results are reported automatically by PE to SME once the scan is done. |
| 5604 | //No need to fetch the results explicitly. |
| 5605 | //csrScanStartGetResultTimer(pMac); |
| 5606 | csrScanStartResultAgingTimer(pMac); |
| 5607 | } |
| 5608 | else |
| 5609 | { |
| 5610 | //We don't have BG scan so stop the aging timer |
| 5611 | csrScanStopResultAgingTimer(pMac); |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5612 | smsLog(pMac, LOGE, FL("cannot continue because the bgscan interval is 0")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5613 | status = eHAL_STATUS_INVALID_PARAMETER; |
| 5614 | } |
| 5615 | |
| 5616 | return (status); |
| 5617 | } |
| 5618 | |
| 5619 | |
| 5620 | eHalStatus csrScanCopyRequest(tpAniSirGlobal pMac, tCsrScanRequest *pDstReq, tCsrScanRequest *pSrcReq) |
| 5621 | { |
| 5622 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 5623 | tANI_U32 len = sizeof(pMac->roam.validChannelList); |
| 5624 | tANI_U32 index = 0; |
| 5625 | tANI_U32 new_index = 0; |
| 5626 | |
| 5627 | do |
| 5628 | { |
| 5629 | status = csrScanFreeRequest(pMac, pDstReq); |
| 5630 | if(HAL_STATUS_SUCCESS(status)) |
| 5631 | { |
| 5632 | status = palCopyMemory(pMac->hHdd, pDstReq, pSrcReq, sizeof(tCsrScanRequest)); |
Gopichand Nakkala | c7b1d3e | 2012-12-31 14:07:19 -0800 | [diff] [blame] | 5633 | /* Re-initialize the pointers to NULL since we did a copy */ |
| 5634 | pDstReq->pIEField = NULL; |
| 5635 | pDstReq->ChannelInfo.ChannelList = NULL; |
| 5636 | pDstReq->SSIDs.SSIDList = NULL; |
| 5637 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5638 | if(pSrcReq->uIEFieldLen == 0) |
| 5639 | { |
| 5640 | pDstReq->pIEField = NULL; |
| 5641 | } |
| 5642 | else |
| 5643 | { |
| 5644 | status = palAllocateMemory(pMac->hHdd, (void **)&pDstReq->pIEField, pSrcReq->uIEFieldLen); |
| 5645 | if(HAL_STATUS_SUCCESS(status)) |
| 5646 | { |
| 5647 | palCopyMemory(pMac->hHdd, pDstReq->pIEField, pSrcReq->pIEField, pSrcReq->uIEFieldLen); |
| 5648 | pDstReq->uIEFieldLen = pSrcReq->uIEFieldLen; |
| 5649 | } |
| 5650 | else |
| 5651 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5652 | smsLog(pMac, LOGE, "No memory for scanning IE fields"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5653 | break; |
| 5654 | } |
| 5655 | }//Allocate memory for IE field |
| 5656 | { |
| 5657 | if(pSrcReq->ChannelInfo.numOfChannels == 0) |
| 5658 | { |
| 5659 | pDstReq->ChannelInfo.ChannelList = NULL; |
| 5660 | pDstReq->ChannelInfo.numOfChannels = 0; |
| 5661 | } |
| 5662 | else |
| 5663 | { |
| 5664 | status = palAllocateMemory(pMac->hHdd, (void **)&pDstReq->ChannelInfo.ChannelList, |
| 5665 | pSrcReq->ChannelInfo.numOfChannels * sizeof(*pDstReq->ChannelInfo.ChannelList)); |
| 5666 | if(!HAL_STATUS_SUCCESS(status)) |
| 5667 | { |
| 5668 | pDstReq->ChannelInfo.numOfChannels = 0; |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5669 | smsLog(pMac, LOGE, "No memory for scanning Channel List"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5670 | break; |
| 5671 | } |
| 5672 | |
| 5673 | if((pSrcReq->scanType == eSIR_PASSIVE_SCAN) && (pSrcReq->requestType == eCSR_SCAN_REQUEST_11D_SCAN)) |
| 5674 | { |
| 5675 | for ( index = 0; index < pSrcReq->ChannelInfo.numOfChannels ; index++ ) |
| 5676 | { |
| 5677 | pDstReq->ChannelInfo.ChannelList[new_index] = |
| 5678 | pSrcReq->ChannelInfo.ChannelList[index]; |
| 5679 | new_index++; |
| 5680 | } |
| 5681 | pDstReq->ChannelInfo.numOfChannels = new_index; |
| 5682 | } |
| 5683 | else if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len))) |
| 5684 | { |
| 5685 | new_index = 0; |
| 5686 | pMac->roam.numValidChannels = len; |
| 5687 | for ( index = 0; index < pSrcReq->ChannelInfo.numOfChannels ; index++ ) |
| 5688 | { |
Madan Mohan Koyyalamudi | 783b236 | 2012-10-21 11:54:41 -0700 | [diff] [blame] | 5689 | /* Allow scan on valid channels only. |
| 5690 | * If it is p2p scan and valid channel list doesnt contain |
| 5691 | * social channels, enforce scan on social channels because |
| 5692 | * that is the only way to find p2p peers. |
| 5693 | * This can happen only if band is set to 5Ghz mode. |
| 5694 | */ |
Madan Mohan Koyyalamudi | c5992c9 | 2012-11-15 16:40:57 -0800 | [diff] [blame] | 5695 | if((csrRoamIsValidChannel(pMac, pSrcReq->ChannelInfo.ChannelList[index])) || |
| 5696 | ((eCSR_SCAN_P2P_DISCOVERY == pSrcReq->requestType) && |
Madan Mohan Koyyalamudi | 783b236 | 2012-10-21 11:54:41 -0700 | [diff] [blame] | 5697 | CSR_IS_SOCIAL_CHANNEL(pSrcReq->ChannelInfo.ChannelList[index]))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5698 | { |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 5699 | if( (pSrcReq->skipDfsChnlInP2pSearch && |
Madan Mohan Koyyalamudi | c5992c9 | 2012-11-15 16:40:57 -0800 | [diff] [blame] | 5700 | (NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(pSrcReq->ChannelInfo.ChannelList[index])) ) |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 5701 | #ifdef FEATURE_WLAN_LFR |
| 5702 | /* |
| 5703 | * If LFR is requesting a contiguous scan |
| 5704 | * (i.e. numOfChannels > 1), then ignore |
| 5705 | * DFS channels. |
| 5706 | * TODO: vos_nv_getChannelEnabledState is returning |
| 5707 | * 120, 124 and 128 as non-DFS channels. Hence, the |
| 5708 | * use of direct check for channels below. |
| 5709 | */ |
| 5710 | || ((eCSR_SCAN_HO_BG_SCAN == pSrcReq->requestType) && |
| 5711 | (pSrcReq->ChannelInfo.numOfChannels > 1) && |
Srinivas Girigowda | de69741 | 2013-02-14 16:31:48 -0800 | [diff] [blame] | 5712 | (CSR_IS_CHANNEL_DFS(pSrcReq->ChannelInfo.ChannelList[index]))) |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 5713 | #endif |
| 5714 | ) |
| 5715 | { |
| 5716 | #ifdef FEATURE_WLAN_LFR |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5717 | smsLog(pMac, LOG2, |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 5718 | "%s: reqType=%d, numOfChannels=%d," |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5719 | " ignoring DFS channel %d", |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 5720 | __func__, pSrcReq->requestType, |
| 5721 | pSrcReq->ChannelInfo.numOfChannels, |
| 5722 | pSrcReq->ChannelInfo.ChannelList[index]); |
| 5723 | #endif |
Madan Mohan Koyyalamudi | c5992c9 | 2012-11-15 16:40:57 -0800 | [diff] [blame] | 5724 | continue; |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 5725 | } |
Madan Mohan Koyyalamudi | c5992c9 | 2012-11-15 16:40:57 -0800 | [diff] [blame] | 5726 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5727 | pDstReq->ChannelInfo.ChannelList[new_index] = |
| 5728 | pSrcReq->ChannelInfo.ChannelList[index]; |
| 5729 | new_index++; |
| 5730 | } |
| 5731 | } |
| 5732 | pDstReq->ChannelInfo.numOfChannels = new_index; |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 5733 | #ifdef FEATURE_WLAN_LFR |
| 5734 | if ((eCSR_SCAN_HO_BG_SCAN == pSrcReq->requestType) && |
| 5735 | (0 == pDstReq->ChannelInfo.numOfChannels)) |
| 5736 | { |
| 5737 | /* |
| 5738 | * No valid channels found in the request. |
| 5739 | * Only perform scan on the channels passed |
| 5740 | * pSrcReq if it is a eCSR_SCAN_HO_BG_SCAN. |
| 5741 | * Passing 0 to LIM will trigger a scan on |
| 5742 | * all valid channels which is not desirable. |
| 5743 | */ |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5744 | smsLog(pMac, LOGE, "%s: no valid channels found (request=%d)", |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 5745 | __func__, pSrcReq->requestType); |
| 5746 | for ( index = 0; index < pSrcReq->ChannelInfo.numOfChannels ; index++ ) |
| 5747 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5748 | smsLog(pMac, LOGE, "pSrcReq index=%d channel=%d", |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 5749 | index, pSrcReq->ChannelInfo.ChannelList[index]); |
| 5750 | } |
| 5751 | status = eHAL_STATUS_FAILURE; |
| 5752 | break; |
| 5753 | } |
| 5754 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5755 | } |
| 5756 | else |
| 5757 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5758 | 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] | 5759 | palCopyMemory(pMac->hHdd, pDstReq->ChannelInfo.ChannelList, pSrcReq->ChannelInfo.ChannelList, |
| 5760 | pSrcReq->ChannelInfo.numOfChannels * sizeof(*pDstReq->ChannelInfo.ChannelList)); |
| 5761 | pDstReq->ChannelInfo.numOfChannels = pSrcReq->ChannelInfo.numOfChannels; |
| 5762 | } |
| 5763 | }//Allocate memory for Channel List |
| 5764 | } |
| 5765 | if(pSrcReq->SSIDs.numOfSSIDs == 0) |
| 5766 | { |
| 5767 | pDstReq->SSIDs.numOfSSIDs = 0; |
| 5768 | pDstReq->SSIDs.SSIDList = NULL; |
| 5769 | } |
| 5770 | else |
| 5771 | { |
| 5772 | status = palAllocateMemory(pMac->hHdd, (void **)&pDstReq->SSIDs.SSIDList, |
| 5773 | pSrcReq->SSIDs.numOfSSIDs * sizeof(*pDstReq->SSIDs.SSIDList)); |
| 5774 | if(HAL_STATUS_SUCCESS(status)) |
| 5775 | { |
| 5776 | pDstReq->SSIDs.numOfSSIDs = pSrcReq->SSIDs.numOfSSIDs; |
| 5777 | palCopyMemory(pMac->hHdd, pDstReq->SSIDs.SSIDList, pSrcReq->SSIDs.SSIDList, |
| 5778 | pSrcReq->SSIDs.numOfSSIDs * sizeof(*pDstReq->SSIDs.SSIDList)); |
| 5779 | } |
| 5780 | else |
| 5781 | { |
| 5782 | pDstReq->SSIDs.numOfSSIDs = 0; |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5783 | smsLog(pMac, LOGE, "No memory for scanning SSID List"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5784 | break; |
| 5785 | } |
| 5786 | }//Allocate memory for SSID List |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5787 | pDstReq->p2pSearch = pSrcReq->p2pSearch; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5788 | pDstReq->skipDfsChnlInP2pSearch = pSrcReq->skipDfsChnlInP2pSearch; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5789 | |
| 5790 | } |
| 5791 | }while(0); |
| 5792 | |
| 5793 | if(!HAL_STATUS_SUCCESS(status)) |
| 5794 | { |
| 5795 | csrScanFreeRequest(pMac, pDstReq); |
| 5796 | } |
| 5797 | |
| 5798 | return (status); |
| 5799 | } |
| 5800 | |
| 5801 | |
| 5802 | eHalStatus csrScanFreeRequest(tpAniSirGlobal pMac, tCsrScanRequest *pReq) |
| 5803 | { |
| 5804 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 5805 | |
| 5806 | if(pReq->ChannelInfo.ChannelList) |
| 5807 | { |
| 5808 | status = palFreeMemory(pMac->hHdd, pReq->ChannelInfo.ChannelList); |
| 5809 | pReq->ChannelInfo.ChannelList = NULL; |
| 5810 | } |
| 5811 | pReq->ChannelInfo.numOfChannels = 0; |
| 5812 | if(pReq->pIEField) |
| 5813 | { |
| 5814 | status = palFreeMemory(pMac->hHdd, pReq->pIEField); |
| 5815 | pReq->pIEField = NULL; |
| 5816 | } |
| 5817 | pReq->uIEFieldLen = 0; |
| 5818 | if(pReq->SSIDs.SSIDList) |
| 5819 | { |
| 5820 | palFreeMemory(pMac->hHdd, pReq->SSIDs.SSIDList); |
| 5821 | pReq->SSIDs.SSIDList = NULL; |
| 5822 | } |
| 5823 | pReq->SSIDs.numOfSSIDs = 0; |
| 5824 | |
| 5825 | return (status); |
| 5826 | } |
| 5827 | |
| 5828 | |
| 5829 | void csrScanCallCallback(tpAniSirGlobal pMac, tSmeCmd *pCommand, eCsrScanStatus scanStatus) |
| 5830 | { |
| 5831 | if(pCommand->u.scanCmd.callback) |
| 5832 | { |
| 5833 | // sme_ReleaseGlobalLock( &pMac->sme ); |
| 5834 | pCommand->u.scanCmd.callback(pMac, pCommand->u.scanCmd.pContext, pCommand->u.scanCmd.scanID, scanStatus); |
| 5835 | // sme_AcquireGlobalLock( &pMac->sme ); |
| 5836 | } else { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5837 | smsLog( pMac, LOG2, "%s:%d - Callback NULL!!!", __func__, __LINE__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5838 | } |
| 5839 | } |
| 5840 | |
| 5841 | |
| 5842 | void csrScanStopTimers(tpAniSirGlobal pMac) |
| 5843 | { |
| 5844 | csrScanStopResultAgingTimer(pMac); |
| 5845 | csrScanStopIdleScanTimer(pMac); |
| 5846 | csrScanStopGetResultTimer(pMac); |
Sandeep Puligilla | 2b6dc63 | 2012-12-17 14:44:16 -0800 | [diff] [blame] | 5847 | if(0 != pMac->scan.scanResultCfgAgingTime ) |
| 5848 | { |
| 5849 | csrScanStopResultCfgAgingTimer(pMac); |
| 5850 | } |
| 5851 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5852 | } |
| 5853 | |
| 5854 | |
| 5855 | eHalStatus csrScanStartGetResultTimer(tpAniSirGlobal pMac) |
| 5856 | { |
| 5857 | eHalStatus status; |
| 5858 | |
| 5859 | if(pMac->scan.fScanEnable) |
| 5860 | { |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 5861 | status = vos_timer_start(&pMac->scan.hTimerGetResult, CSR_SCAN_GET_RESULT_INTERVAL/PAL_TIMER_TO_MS_UNIT); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5862 | } |
| 5863 | else |
| 5864 | { |
| 5865 | status = eHAL_STATUS_FAILURE; |
| 5866 | } |
| 5867 | |
| 5868 | return (status); |
| 5869 | } |
| 5870 | |
| 5871 | |
| 5872 | eHalStatus csrScanStopGetResultTimer(tpAniSirGlobal pMac) |
| 5873 | { |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 5874 | return (vos_timer_stop(&pMac->scan.hTimerGetResult)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5875 | } |
| 5876 | |
| 5877 | |
| 5878 | void csrScanGetResultTimerHandler(void *pv) |
| 5879 | { |
| 5880 | tpAniSirGlobal pMac = PMAC_STRUCT( pv ); |
| 5881 | |
| 5882 | csrScanRequestResult(pMac); |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 5883 | |
| 5884 | vos_timer_start(&pMac->scan.hTimerGetResult, CSR_SCAN_GET_RESULT_INTERVAL/PAL_TIMER_TO_MS_UNIT); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5885 | } |
| 5886 | |
| 5887 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 5888 | static void csrStaApConcTimerHandler(void *pv) |
| 5889 | { |
| 5890 | tpAniSirGlobal pMac = PMAC_STRUCT( pv ); |
| 5891 | tListElem *pEntry; |
| 5892 | tSmeCmd *pScanCmd; |
| 5893 | |
| 5894 | csrLLLock(&pMac->scan.scanCmdPendingList); |
| 5895 | |
| 5896 | if ( NULL != ( pEntry = csrLLPeekHead( &pMac->scan.scanCmdPendingList, LL_ACCESS_NOLOCK) ) ) |
| 5897 | { |
| 5898 | tCsrScanRequest scanReq; |
| 5899 | tSmeCmd *pSendScanCmd = NULL; |
| 5900 | tANI_U8 numChn = 0; |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 5901 | tANI_U8 nNumChanCombinedConc = 0; |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 5902 | tANI_U8 i, j; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5903 | tCsrChannelInfo *pChnInfo = &scanReq.ChannelInfo; |
| 5904 | tANI_U8 channelToScan[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 5905 | eHalStatus status; |
| 5906 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5907 | pScanCmd = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 5908 | numChn = pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels; |
Madan Mohan Koyyalamudi | d671358 | 2012-11-09 16:56:56 -0800 | [diff] [blame] | 5909 | |
| 5910 | /* if any session is connected and the number of channels to scan is |
| 5911 | * greater than 1 then split the scan into multiple scan operations |
| 5912 | * on each individual channel else continue to perform scan on all |
| 5913 | * specified channels */ |
Madan Mohan Koyyalamudi | 48081ef | 2012-12-04 16:49:55 -0800 | [diff] [blame] | 5914 | |
| 5915 | /* split scan if number of channels to scan is greater than 1 and |
| 5916 | * any one of the following: |
| 5917 | * - STA session is connected and the scan is not a P2P search |
| 5918 | * - any P2P session is connected |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 5919 | * Do not split scans if no concurrent infra connections are |
| 5920 | * active and if the scan is a BG scan triggered by LFR (OR) |
| 5921 | * any scan if LFR is in the middle of a BG scan. Splitting |
| 5922 | * the scan is delaying the time it takes for LFR to find |
| 5923 | * candidates and resulting in disconnects. |
Madan Mohan Koyyalamudi | 48081ef | 2012-12-04 16:49:55 -0800 | [diff] [blame] | 5924 | */ |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 5925 | |
| 5926 | if((csrIsStaSessionConnected(pMac) && |
| 5927 | !csrIsP2pSessionConnected(pMac))) |
| 5928 | { |
| 5929 | nNumChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc; |
| 5930 | } |
| 5931 | else if(csrIsP2pSessionConnected(pMac)) |
| 5932 | { |
| 5933 | nNumChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc; |
| 5934 | } |
| 5935 | |
| 5936 | if ( (numChn > nNumChanCombinedConc) && |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 5937 | ((csrIsStaSessionConnected(pMac) && |
| 5938 | #ifdef FEATURE_WLAN_LFR |
| 5939 | (csrIsConcurrentInfraConnected(pMac) || |
| 5940 | ((pScanCmd->u.scanCmd.reason != eCsrScanBgScan) && |
| 5941 | (pMac->roam.neighborRoamInfo.neighborRoamState != |
| 5942 | eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN))) && |
| 5943 | #endif |
| 5944 | (pScanCmd->u.scanCmd.u.scanRequest.p2pSearch != 1)) || |
Madan Mohan Koyyalamudi | 48081ef | 2012-12-04 16:49:55 -0800 | [diff] [blame] | 5945 | (csrIsP2pSessionConnected(pMac)))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5946 | { |
| 5947 | palZeroMemory(pMac->hHdd, &scanReq, sizeof(tCsrScanRequest)); |
| 5948 | |
| 5949 | pSendScanCmd = csrGetCommandBuffer(pMac); //optimize this to use 2 command buffer only |
| 5950 | if (!pSendScanCmd) |
| 5951 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5952 | smsLog( pMac, LOGE, FL(" Failed to get Queue command buffer") ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5953 | csrLLUnlock(&pMac->scan.scanCmdPendingList); |
| 5954 | return; |
| 5955 | } |
| 5956 | pSendScanCmd->command = pScanCmd->command; |
| 5957 | pSendScanCmd->sessionId = pScanCmd->sessionId; |
| 5958 | pSendScanCmd->u.scanCmd.callback = NULL; |
| 5959 | pSendScanCmd->u.scanCmd.pContext = pScanCmd->u.scanCmd.pContext; |
| 5960 | pSendScanCmd->u.scanCmd.reason = pScanCmd->u.scanCmd.reason; |
| 5961 | pSendScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around |
| 5962 | |
Madan Mohan Koyyalamudi | af2a8b9 | 2012-10-09 14:58:07 -0700 | [diff] [blame] | 5963 | /* First copy all the parameters to local variable of scan request */ |
| 5964 | csrScanCopyRequest(pMac, &scanReq, &pScanCmd->u.scanCmd.u.scanRequest); |
| 5965 | |
| 5966 | /* 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] | 5967 | if(scanReq.ChannelInfo.ChannelList != NULL) |
| 5968 | { |
| 5969 | palFreeMemory(pMac->hHdd,scanReq.ChannelInfo.ChannelList); |
| 5970 | scanReq.ChannelInfo.ChannelList = NULL; |
| 5971 | } |
| 5972 | |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 5973 | pChnInfo->numOfChannels = nNumChanCombinedConc; |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 5974 | palCopyMemory(pMac->hHdd, &channelToScan[0], &pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[0], |
| 5975 | pChnInfo->numOfChannels * sizeof(tANI_U8)); //just send one channel |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5976 | pChnInfo->ChannelList = &channelToScan[0]; |
| 5977 | |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 5978 | for (i = 0, j = nNumChanCombinedConc; i < (numChn-nNumChanCombinedConc); i++, j++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5979 | { |
| 5980 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[i] = |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 5981 | 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] | 5982 | } |
| 5983 | |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 5984 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = numChn - nNumChanCombinedConc; //reduce outstanding # of channels to be scanned |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5985 | |
| 5986 | scanReq.BSSType = eCSR_BSS_TYPE_ANY; |
| 5987 | //Modify callers parameters in case of concurrency |
| 5988 | scanReq.scanType = eSIR_ACTIVE_SCAN; |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 5989 | //Use concurrency values for min/maxChnTime. |
| 5990 | //We know csrIsAnySessionConnected(pMac) returns TRUE here |
| 5991 | csrSetDefaultScanTiming(pMac, scanReq.scanType, &scanReq); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5992 | |
| 5993 | status = csrScanCopyRequest(pMac, &pSendScanCmd->u.scanCmd.u.scanRequest, &scanReq); |
| 5994 | if(!HAL_STATUS_SUCCESS(status)) |
| 5995 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5996 | smsLog( pMac, LOGE, FL(" Failed to get copy csrScanRequest = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5997 | csrLLUnlock(&pMac->scan.scanCmdPendingList); |
| 5998 | return; |
Madan Mohan Koyyalamudi | 0c626f3 | 2012-11-30 15:10:25 -0800 | [diff] [blame] | 5999 | } |
| 6000 | /* Clean the local scan variable */ |
| 6001 | scanReq.ChannelInfo.ChannelList = NULL; |
| 6002 | scanReq.ChannelInfo.numOfChannels = 0; |
| 6003 | csrScanFreeRequest(pMac, &scanReq); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6004 | } |
| 6005 | else |
Madan Mohan Koyyalamudi | d671358 | 2012-11-09 16:56:56 -0800 | [diff] [blame] | 6006 | { |
| 6007 | /* no active connected session present or numChn == 1 |
| 6008 | * scan all remaining channels */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6009 | pSendScanCmd = pScanCmd; |
| 6010 | //remove this command from pending list |
| 6011 | if (csrLLRemoveHead( &pMac->scan.scanCmdPendingList, LL_ACCESS_NOLOCK) == NULL) |
| 6012 | { //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] | 6013 | smsLog( pMac, LOGE, FL(" Failed to remove entry from scanCmdPendingList")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6014 | } |
| 6015 | |
| 6016 | } |
| 6017 | csrQueueSmeCommand(pMac, pSendScanCmd, eANI_BOOLEAN_FALSE); |
| 6018 | |
| 6019 | } |
| 6020 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6021 | csrLLUnlock(&pMac->scan.scanCmdPendingList); |
| 6022 | |
| 6023 | } |
| 6024 | #endif |
| 6025 | |
| 6026 | eHalStatus csrScanStartResultAgingTimer(tpAniSirGlobal pMac) |
| 6027 | { |
Sandeep Puligilla | 2b6dc63 | 2012-12-17 14:44:16 -0800 | [diff] [blame] | 6028 | eHalStatus status = eHAL_STATUS_FAILURE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6029 | |
| 6030 | if(pMac->scan.fScanEnable) |
| 6031 | { |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 6032 | status = vos_timer_start(&pMac->scan.hTimerResultAging, CSR_SCAN_RESULT_AGING_INTERVAL/PAL_TIMER_TO_MS_UNIT); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6033 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6034 | return (status); |
| 6035 | } |
| 6036 | |
Sandeep Puligilla | 2b6dc63 | 2012-12-17 14:44:16 -0800 | [diff] [blame] | 6037 | eHalStatus csrScanStartResultCfgAgingTimer(tpAniSirGlobal pMac) |
| 6038 | { |
| 6039 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 6040 | |
| 6041 | if(pMac->scan.fScanEnable) |
| 6042 | { |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 6043 | status = vos_timer_start(&pMac->scan.hTimerResultCfgAging, CSR_SCAN_RESULT_CFG_AGING_INTERVAL/PAL_TIMER_TO_MS_UNIT); |
Sandeep Puligilla | 2b6dc63 | 2012-12-17 14:44:16 -0800 | [diff] [blame] | 6044 | } |
| 6045 | return (status); |
| 6046 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6047 | |
| 6048 | eHalStatus csrScanStopResultAgingTimer(tpAniSirGlobal pMac) |
| 6049 | { |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 6050 | return (vos_timer_stop(&pMac->scan.hTimerResultAging)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6051 | } |
| 6052 | |
Sandeep Puligilla | 2b6dc63 | 2012-12-17 14:44:16 -0800 | [diff] [blame] | 6053 | eHalStatus csrScanStopResultCfgAgingTimer(tpAniSirGlobal pMac) |
| 6054 | { |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 6055 | return (vos_timer_stop(&pMac->scan.hTimerResultCfgAging)); |
Sandeep Puligilla | 2b6dc63 | 2012-12-17 14:44:16 -0800 | [diff] [blame] | 6056 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6057 | |
| 6058 | //This function returns the maximum time a BSS is allowed in the scan result. |
| 6059 | //The time varies base on connection and power saving factors. |
| 6060 | //Not connected, No PS |
| 6061 | //Not connected, with PS |
| 6062 | //Connected w/o traffic, No PS |
| 6063 | //Connected w/o traffic, with PS |
| 6064 | //Connected w/ traffic, no PS -- Not supported |
| 6065 | //Connected w/ traffic, with PS -- Not supported |
| 6066 | //the return unit is in seconds. |
| 6067 | tANI_U32 csrScanGetAgeOutTime(tpAniSirGlobal pMac) |
| 6068 | { |
| 6069 | tANI_U32 nRet; |
| 6070 | |
| 6071 | if(pMac->scan.nAgingCountDown) |
| 6072 | { |
| 6073 | //Calculate what should be the timeout value for this |
| 6074 | nRet = pMac->scan.nLastAgeTimeOut * pMac->scan.nAgingCountDown; |
| 6075 | pMac->scan.nAgingCountDown--; |
| 6076 | } |
| 6077 | else |
| 6078 | { |
| 6079 | if( csrIsAllSessionDisconnected( pMac ) ) |
| 6080 | { |
| 6081 | if(pmcIsPowerSaveEnabled(pMac, ePMC_IDLE_MODE_POWER_SAVE)) |
| 6082 | { |
| 6083 | nRet = pMac->roam.configParam.scanAgeTimeNCPS; |
| 6084 | } |
| 6085 | else |
| 6086 | { |
| 6087 | nRet = pMac->roam.configParam.scanAgeTimeNCNPS; |
| 6088 | } |
| 6089 | } |
| 6090 | else |
| 6091 | { |
| 6092 | if(pmcIsPowerSaveEnabled(pMac, ePMC_BEACON_MODE_POWER_SAVE)) |
| 6093 | { |
| 6094 | nRet = pMac->roam.configParam.scanAgeTimeCPS; |
| 6095 | } |
| 6096 | else |
| 6097 | { |
| 6098 | nRet = pMac->roam.configParam.scanAgeTimeCNPS; |
| 6099 | } |
| 6100 | } |
| 6101 | //If state-change causing aging time out change, we want to delay it somewhat to avoid |
| 6102 | //unnecessary removal of BSS. This is mostly due to transition from connect to disconnect. |
| 6103 | if(pMac->scan.nLastAgeTimeOut > nRet) |
| 6104 | { |
| 6105 | if(nRet) |
| 6106 | { |
| 6107 | pMac->scan.nAgingCountDown = (pMac->scan.nLastAgeTimeOut / nRet); |
| 6108 | } |
| 6109 | pMac->scan.nLastAgeTimeOut = nRet; |
| 6110 | nRet *= pMac->scan.nAgingCountDown; |
| 6111 | } |
| 6112 | else |
| 6113 | { |
| 6114 | pMac->scan.nLastAgeTimeOut = nRet; |
| 6115 | } |
| 6116 | } |
| 6117 | |
| 6118 | return (nRet); |
| 6119 | } |
| 6120 | |
| 6121 | |
| 6122 | void csrScanResultAgingTimerHandler(void *pv) |
| 6123 | { |
| 6124 | tpAniSirGlobal pMac = PMAC_STRUCT( pv ); |
| 6125 | tANI_BOOLEAN fDisconnected = csrIsAllSessionDisconnected(pMac); |
| 6126 | |
| 6127 | //no scan, no aging |
| 6128 | if(pMac->scan.fScanEnable && |
| 6129 | (((eANI_BOOLEAN_FALSE == fDisconnected) && pMac->roam.configParam.bgScanInterval) |
| 6130 | || (fDisconnected && (pMac->scan.fCancelIdleScan == eANI_BOOLEAN_FALSE))) |
| 6131 | ) |
| 6132 | { |
| 6133 | tListElem *pEntry, *tmpEntry; |
| 6134 | tCsrScanResult *pResult; |
| 6135 | tANI_TIMESTAMP ageOutTime = (tANI_TIMESTAMP)(csrScanGetAgeOutTime(pMac) * PAL_TICKS_PER_SECOND); //turn it into 10ms units |
| 6136 | tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd); |
| 6137 | |
| 6138 | csrLLLock(&pMac->scan.scanResultList); |
| 6139 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK ); |
| 6140 | while( pEntry ) |
| 6141 | { |
| 6142 | tmpEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK); |
| 6143 | pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 6144 | if((curTime - pResult->Result.BssDescriptor.nReceivedTime) > ageOutTime) |
| 6145 | { |
| 6146 | smsLog(pMac, LOGW, " age out due to time out"); |
| 6147 | csrScanAgeOutBss(pMac, pResult); |
| 6148 | } |
| 6149 | pEntry = tmpEntry; |
| 6150 | } |
| 6151 | csrLLUnlock(&pMac->scan.scanResultList); |
| 6152 | } |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 6153 | vos_timer_start(&pMac->scan.hTimerResultAging, CSR_SCAN_RESULT_AGING_INTERVAL/PAL_TIMER_TO_MS_UNIT); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6154 | } |
| 6155 | |
Sandeep Puligilla | 2b6dc63 | 2012-12-17 14:44:16 -0800 | [diff] [blame] | 6156 | static void csrScanResultCfgAgingTimerHandler(void *pv) |
| 6157 | { |
| 6158 | tpAniSirGlobal pMac = PMAC_STRUCT( pv ); |
| 6159 | tListElem *pEntry, *tmpEntry; |
| 6160 | tCsrScanResult *pResult; |
| 6161 | tANI_TIMESTAMP ageOutTime = pMac->scan.scanResultCfgAgingTime * PAL_TICKS_PER_SECOND; |
| 6162 | tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd); |
| 6163 | |
| 6164 | csrLLLock(&pMac->scan.scanResultList); |
| 6165 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK ); |
| 6166 | while( pEntry ) |
| 6167 | { |
| 6168 | tmpEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK); |
| 6169 | pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 6170 | if((curTime - pResult->Result.BssDescriptor.nReceivedTime) > ageOutTime) |
| 6171 | { |
| 6172 | smsLog(pMac, LOGW, " age out due to time out"); |
| 6173 | csrScanAgeOutBss(pMac, pResult); |
| 6174 | } |
| 6175 | pEntry = tmpEntry; |
| 6176 | } |
| 6177 | csrLLUnlock(&pMac->scan.scanResultList); |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 6178 | vos_timer_start(&pMac->scan.hTimerResultCfgAging, CSR_SCAN_RESULT_CFG_AGING_INTERVAL/PAL_TIMER_TO_MS_UNIT); |
Sandeep Puligilla | 2b6dc63 | 2012-12-17 14:44:16 -0800 | [diff] [blame] | 6179 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6180 | |
| 6181 | eHalStatus csrScanStartIdleScanTimer(tpAniSirGlobal pMac, tANI_U32 interval) |
| 6182 | { |
| 6183 | eHalStatus status; |
| 6184 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6185 | smsLog(pMac, LOG1, " csrScanStartIdleScanTimer"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6186 | if((pMac->scan.fScanEnable) && (eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan) && interval) |
| 6187 | { |
| 6188 | pMac->scan.nIdleScanTimeGap += interval; |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 6189 | vos_timer_stop(&pMac->scan.hTimerIdleScan); |
| 6190 | status = vos_timer_start(&pMac->scan.hTimerIdleScan, interval/PAL_TIMER_TO_MS_UNIT); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6191 | if( !HAL_STATUS_SUCCESS(status) ) |
| 6192 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6193 | 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] | 6194 | //This should not happen but set the flag to restart when ready |
| 6195 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 6196 | } |
| 6197 | } |
| 6198 | else |
| 6199 | { |
| 6200 | if( pMac->scan.fScanEnable && (eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan) ) |
| 6201 | { |
| 6202 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 6203 | } |
| 6204 | status = eHAL_STATUS_FAILURE; |
| 6205 | } |
| 6206 | |
| 6207 | return (status); |
| 6208 | } |
| 6209 | |
| 6210 | |
| 6211 | eHalStatus csrScanStopIdleScanTimer(tpAniSirGlobal pMac) |
| 6212 | { |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 6213 | return (vos_timer_stop(&pMac->scan.hTimerIdleScan)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6214 | } |
| 6215 | |
| 6216 | |
| 6217 | //Stop CSR from asking for IMPS, This function doesn't disable IMPS from CSR |
| 6218 | void csrScanSuspendIMPS( tpAniSirGlobal pMac ) |
| 6219 | { |
| 6220 | csrScanCancelIdleScan(pMac); |
| 6221 | } |
| 6222 | |
| 6223 | |
| 6224 | //Start CSR from asking for IMPS. This function doesn't trigger CSR to request entering IMPS |
| 6225 | //because IMPS maybe disabled. |
| 6226 | void csrScanResumeIMPS( tpAniSirGlobal pMac ) |
| 6227 | { |
| 6228 | csrScanStartIdleScan( pMac ); |
| 6229 | } |
| 6230 | |
| 6231 | |
| 6232 | void csrScanIMPSCallback(void *callbackContext, eHalStatus status) |
| 6233 | { |
| 6234 | tpAniSirGlobal pMac = PMAC_STRUCT( callbackContext ); |
| 6235 | |
| 6236 | if(eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan) |
| 6237 | { |
| 6238 | if(pMac->roam.configParam.IsIdleScanEnabled) |
| 6239 | { |
| 6240 | if(HAL_STATUS_SUCCESS(status)) |
| 6241 | { |
| 6242 | if(csrIsAllSessionDisconnected(pMac) && !csrIsRoamCommandWaiting(pMac)) |
| 6243 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6244 | smsLog(pMac, LOGW, FL("starts idle mode full scan")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6245 | csrScanAllChannels(pMac, eCSR_SCAN_IDLE_MODE_SCAN); |
| 6246 | } |
| 6247 | else |
| 6248 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6249 | smsLog(pMac, LOGW, FL("cannot start idle mode full scan")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6250 | //even though we are in timer handle, calling stop timer will make sure the timer |
| 6251 | //doesn't get to restart. |
| 6252 | csrScanStopIdleScanTimer(pMac); |
| 6253 | } |
| 6254 | } |
| 6255 | else |
| 6256 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6257 | smsLog(pMac, LOGE, FL("sees not success status (%d)"), status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6258 | } |
| 6259 | } |
| 6260 | else |
| 6261 | {//we might need another flag to check if CSR needs to request imps at all |
| 6262 | |
| 6263 | tANI_U32 nTime = 0; |
| 6264 | |
| 6265 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE; |
| 6266 | if(!HAL_STATUS_SUCCESS(csrScanTriggerIdleScan(pMac, &nTime))) |
| 6267 | { |
| 6268 | csrScanStartIdleScanTimer(pMac, nTime); |
| 6269 | } |
| 6270 | } |
| 6271 | } |
| 6272 | } |
| 6273 | |
| 6274 | |
| 6275 | //Param: pTimeInterval -- Caller allocated memory in return, if failed, to specify the nxt time interval for |
| 6276 | //idle scan timer interval |
| 6277 | //Return: Not success -- meaning it cannot start IMPS, caller needs to start a timer for idle scan |
| 6278 | eHalStatus csrScanTriggerIdleScan(tpAniSirGlobal pMac, tANI_U32 *pTimeInterval) |
| 6279 | { |
| 6280 | eHalStatus status = eHAL_STATUS_CSR_WRONG_STATE; |
| 6281 | |
| 6282 | //Do not trigger IMPS in case of concurrency |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6283 | if (vos_concurrent_sessions_running() && csrIsAnySessionInConnectState(pMac)) |
| 6284 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6285 | smsLog( pMac, LOG1, FL("Cannot request IMPS because Concurrent Sessions Running") ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6286 | return (status); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6287 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6288 | |
| 6289 | if(pTimeInterval) |
| 6290 | { |
| 6291 | *pTimeInterval = 0; |
| 6292 | } |
| 6293 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6294 | smsLog(pMac, LOG3, FL("called")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6295 | if( smeCommandPending( pMac ) ) |
| 6296 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6297 | smsLog( pMac, LOG1, FL(" Cannot request IMPS because command pending") ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6298 | //Not to enter IMPS because more work to do |
| 6299 | if(pTimeInterval) |
| 6300 | { |
| 6301 | *pTimeInterval = 0; |
| 6302 | } |
| 6303 | //restart when ready |
| 6304 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 6305 | |
| 6306 | return (status); |
| 6307 | } |
Kiran Kumar Lokere | f8c3992 | 2013-03-18 11:08:11 -0700 | [diff] [blame] | 6308 | if (IsPmcImpsReqFailed (pMac)) |
| 6309 | { |
| 6310 | if(pTimeInterval) |
| 6311 | { |
| 6312 | *pTimeInterval = 1000000; //usec |
| 6313 | } |
| 6314 | //restart when ready |
| 6315 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6316 | |
Kiran Kumar Lokere | f8c3992 | 2013-03-18 11:08:11 -0700 | [diff] [blame] | 6317 | return status; |
| 6318 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6319 | if((pMac->scan.fScanEnable) && (eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan) |
| 6320 | /*&& pMac->roam.configParam.impsSleepTime*/) |
| 6321 | { |
| 6322 | //Stop get result timer because idle scan gets scan result out of PE |
| 6323 | csrScanStopGetResultTimer(pMac); |
| 6324 | if(pTimeInterval) |
| 6325 | { |
| 6326 | *pTimeInterval = pMac->roam.configParam.impsSleepTime; |
| 6327 | } |
| 6328 | //pmcRequestImps take a period in millisecond unit. |
| 6329 | status = pmcRequestImps(pMac, pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_MS_UNIT, csrScanIMPSCallback, pMac); |
| 6330 | if(!HAL_STATUS_SUCCESS(status)) |
| 6331 | { |
| 6332 | if(eHAL_STATUS_PMC_ALREADY_IN_IMPS != status) |
| 6333 | { |
| 6334 | //Do restart the timer if CSR thinks it cannot do IMPS |
| 6335 | if( !csrCheckPSReady( pMac ) ) |
| 6336 | { |
| 6337 | if(pTimeInterval) |
| 6338 | { |
| 6339 | *pTimeInterval = 0; |
| 6340 | } |
| 6341 | //Set the restart flag to true because that idle scan |
| 6342 | //can be restarted even though the timer will not be running |
| 6343 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 6344 | } |
| 6345 | else |
| 6346 | { |
| 6347 | //For not now, we do a quicker retry |
| 6348 | if(pTimeInterval) |
| 6349 | { |
| 6350 | *pTimeInterval = CSR_IDLE_SCAN_WAIT_TIME; |
| 6351 | } |
| 6352 | } |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6353 | 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] | 6354 | } |
| 6355 | else |
| 6356 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6357 | smsLog(pMac, LOGW, FL("already in IMPS")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6358 | //Since CSR is the only module to request for IMPS. If it is already in IMPS, CSR assumes |
| 6359 | //the callback will be called in the future. Should not happen though. |
| 6360 | status = eHAL_STATUS_SUCCESS; |
| 6361 | pMac->scan.nIdleScanTimeGap = 0; |
| 6362 | } |
| 6363 | } |
| 6364 | else |
| 6365 | { |
| 6366 | //requested so let's reset the value |
| 6367 | pMac->scan.nIdleScanTimeGap = 0; |
| 6368 | } |
| 6369 | } |
| 6370 | |
| 6371 | return (status); |
| 6372 | } |
| 6373 | |
| 6374 | |
| 6375 | eHalStatus csrScanStartIdleScan(tpAniSirGlobal pMac) |
| 6376 | { |
| 6377 | eHalStatus status = eHAL_STATUS_CSR_WRONG_STATE; |
| 6378 | tANI_U32 nTime = 0; |
| 6379 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6380 | smsLog(pMac, LOGW, FL("called")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6381 | if(pMac->roam.configParam.IsIdleScanEnabled) |
| 6382 | { |
| 6383 | //stop bg scan first |
| 6384 | csrScanBGScanAbort(pMac); |
| 6385 | //Stop get result timer because idle scan gets scan result out of PE |
| 6386 | csrScanStopGetResultTimer(pMac); |
| 6387 | //Enable aging timer since idle scan is going on |
| 6388 | csrScanStartResultAgingTimer(pMac); |
| 6389 | } |
| 6390 | pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE; |
| 6391 | status = csrScanTriggerIdleScan(pMac, &nTime); |
| 6392 | if(!HAL_STATUS_SUCCESS(status)) |
| 6393 | { |
| 6394 | csrScanStartIdleScanTimer(pMac, nTime); |
| 6395 | } |
| 6396 | |
| 6397 | return (status); |
| 6398 | } |
| 6399 | |
| 6400 | |
| 6401 | void csrScanCancelIdleScan(tpAniSirGlobal pMac) |
| 6402 | { |
| 6403 | if(eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan) |
| 6404 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6405 | if (vos_concurrent_sessions_running()) { |
| 6406 | return; |
| 6407 | } |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6408 | smsLog(pMac, LOG1, " csrScanCancelIdleScan"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6409 | pMac->scan.fCancelIdleScan = eANI_BOOLEAN_TRUE; |
| 6410 | //Set the restart flag in case later on it is uncancelled |
| 6411 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 6412 | csrScanStopIdleScanTimer(pMac); |
| 6413 | csrScanRemoveNotRoamingScanCommand(pMac); |
| 6414 | } |
| 6415 | } |
| 6416 | |
| 6417 | |
| 6418 | void csrScanIdleScanTimerHandler(void *pv) |
| 6419 | { |
| 6420 | tpAniSirGlobal pMac = PMAC_STRUCT( pv ); |
| 6421 | eHalStatus status; |
| 6422 | tANI_U32 nTime = 0; |
| 6423 | |
| 6424 | smsLog(pMac, LOGW, " csrScanIdleScanTimerHandler called "); |
Kiran Kumar Lokere | f8c3992 | 2013-03-18 11:08:11 -0700 | [diff] [blame] | 6425 | pmcResetImpsFailStatus (pMac); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6426 | status = csrScanTriggerIdleScan(pMac, &nTime); |
| 6427 | if(!HAL_STATUS_SUCCESS(status) && (eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan)) |
| 6428 | { |
| 6429 | //Check whether it is time to actually do an idle scan |
| 6430 | if(pMac->scan.nIdleScanTimeGap >= pMac->roam.configParam.impsSleepTime) |
| 6431 | { |
| 6432 | pMac->scan.nIdleScanTimeGap = 0; |
| 6433 | csrScanIMPSCallback(pMac, eHAL_STATUS_SUCCESS); |
| 6434 | } |
| 6435 | else |
| 6436 | { |
| 6437 | csrScanStartIdleScanTimer(pMac, nTime); |
| 6438 | } |
| 6439 | } |
| 6440 | } |
| 6441 | |
| 6442 | |
| 6443 | |
| 6444 | |
| 6445 | tANI_BOOLEAN csrScanRemoveNotRoamingScanCommand(tpAniSirGlobal pMac) |
| 6446 | { |
| 6447 | tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE; |
| 6448 | tListElem *pEntry, *pEntryTmp; |
| 6449 | tSmeCmd *pCommand; |
| 6450 | tDblLinkList localList; |
| 6451 | |
| 6452 | vos_mem_zero(&localList, sizeof(tDblLinkList)); |
| 6453 | if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList))) |
| 6454 | { |
| 6455 | smsLog(pMac, LOGE, FL(" failed to open list")); |
| 6456 | return fRet; |
| 6457 | } |
| 6458 | |
| 6459 | csrLLLock(&pMac->sme.smeCmdPendingList); |
| 6460 | pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK); |
| 6461 | while(pEntry) |
| 6462 | { |
| 6463 | pEntryTmp = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK); |
| 6464 | pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link); |
| 6465 | if( eSmeCommandScan == pCommand->command ) |
| 6466 | { |
| 6467 | switch( pCommand->u.scanCmd.reason ) |
| 6468 | { |
| 6469 | case eCsrScanIdleScan: |
| 6470 | if( csrLLRemoveEntry(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK) ) |
| 6471 | { |
| 6472 | csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK); |
| 6473 | } |
| 6474 | fRet = eANI_BOOLEAN_TRUE; |
| 6475 | break; |
| 6476 | |
| 6477 | default: |
| 6478 | break; |
| 6479 | } //switch |
| 6480 | } |
| 6481 | pEntry = pEntryTmp; |
| 6482 | } |
| 6483 | |
| 6484 | csrLLUnlock(&pMac->sme.smeCmdPendingList); |
| 6485 | |
| 6486 | while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) ) |
| 6487 | { |
| 6488 | pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link); |
| 6489 | csrReleaseCommandScan( pMac, pCommand ); |
| 6490 | } |
| 6491 | |
| 6492 | csrLLClose(&localList); |
| 6493 | |
| 6494 | return (fRet); |
| 6495 | } |
| 6496 | |
| 6497 | |
| 6498 | tANI_BOOLEAN csrScanRemoveFreshScanCommand(tpAniSirGlobal pMac, tANI_U8 sessionId) |
| 6499 | { |
| 6500 | tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE; |
| 6501 | tListElem *pEntry, *pEntryTmp; |
| 6502 | tSmeCmd *pCommand; |
| 6503 | tDblLinkList localList; |
| 6504 | |
| 6505 | vos_mem_zero(&localList, sizeof(tDblLinkList)); |
| 6506 | if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList))) |
| 6507 | { |
| 6508 | smsLog(pMac, LOGE, FL(" failed to open list")); |
| 6509 | return fRet; |
| 6510 | } |
| 6511 | |
| 6512 | csrLLLock(&pMac->sme.smeCmdPendingList); |
| 6513 | pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK); |
| 6514 | while(pEntry) |
| 6515 | { |
| 6516 | pEntryTmp = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK); |
| 6517 | pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link); |
| 6518 | if( (eSmeCommandScan == pCommand->command) && (sessionId == pCommand->sessionId) ) |
| 6519 | { |
| 6520 | switch(pCommand->u.scanCmd.reason) |
| 6521 | { |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 6522 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 6523 | case eCsrScanGetLfrResult: |
| 6524 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6525 | case eCsrScanGetResult: |
| 6526 | case eCsrScanSetBGScanParam: |
| 6527 | case eCsrScanBGScanAbort: |
| 6528 | case eCsrScanBGScanEnable: |
| 6529 | case eCsrScanGetScanChnInfo: |
| 6530 | break; |
| 6531 | default: |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6532 | smsLog (pMac, LOGW, "%s: -------- abort scan command reason = %d", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 6533 | __func__, pCommand->u.scanCmd.reason); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6534 | //The rest are fresh scan requests |
| 6535 | if( csrLLRemoveEntry(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK) ) |
| 6536 | { |
| 6537 | csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK); |
| 6538 | } |
| 6539 | fRet = eANI_BOOLEAN_TRUE; |
| 6540 | break; |
| 6541 | } |
| 6542 | } |
| 6543 | pEntry = pEntryTmp; |
| 6544 | } |
| 6545 | |
| 6546 | csrLLUnlock(&pMac->sme.smeCmdPendingList); |
| 6547 | |
| 6548 | while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) ) |
| 6549 | { |
| 6550 | pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link); |
| 6551 | if (pCommand->u.scanCmd.callback) |
| 6552 | { |
| 6553 | /* User scan request is pending, |
| 6554 | * send response with status eCSR_SCAN_ABORT*/ |
| 6555 | pCommand->u.scanCmd.callback(pMac, |
| 6556 | pCommand->u.scanCmd.pContext, |
| 6557 | pCommand->u.scanCmd.scanID, |
| 6558 | eCSR_SCAN_ABORT); |
| 6559 | } |
| 6560 | csrReleaseCommandScan( pMac, pCommand ); |
| 6561 | } |
| 6562 | csrLLClose(&localList); |
| 6563 | |
| 6564 | return (fRet); |
| 6565 | } |
| 6566 | |
| 6567 | |
| 6568 | void csrReleaseScanCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand, eCsrScanStatus scanStatus) |
| 6569 | { |
| 6570 | eCsrScanReason reason = pCommand->u.scanCmd.reason; |
| 6571 | tANI_U32 i; |
| 6572 | for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ ) |
| 6573 | { |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 6574 | csrRoamStateChange( pMac, pCommand->u.scanCmd.lastRoamState[i], i); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6575 | } |
| 6576 | |
| 6577 | csrScanCallCallback(pMac, pCommand, scanStatus); |
| 6578 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6579 | smsLog(pMac, LOG3, " Remove Scan command reason = %d", reason); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6580 | if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, &pCommand->Link, LL_ACCESS_LOCK ) ) |
| 6581 | { |
| 6582 | csrReleaseCommandScan( pMac, pCommand ); |
| 6583 | } |
| 6584 | else |
| 6585 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6586 | 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] | 6587 | } |
| 6588 | } |
| 6589 | |
| 6590 | |
| 6591 | eHalStatus csrScanGetPMKIDCandidateList(tpAniSirGlobal pMac, tANI_U32 sessionId, |
| 6592 | tPmkidCandidateInfo *pPmkidList, tANI_U32 *pNumItems ) |
| 6593 | { |
| 6594 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 6595 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 6596 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 6597 | if(!pSession) |
| 6598 | { |
| 6599 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 6600 | return eHAL_STATUS_FAILURE; |
| 6601 | } |
| 6602 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6603 | smsLog(pMac, LOGW, " pMac->scan.NumPmkidCandidate = %d", pSession->NumPmkidCandidate); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6604 | csrResetPMKIDCandidateList(pMac, sessionId); |
| 6605 | if(csrIsConnStateConnected(pMac, sessionId) && pSession->pCurRoamProfile) |
| 6606 | { |
| 6607 | tCsrScanResultFilter *pScanFilter; |
| 6608 | tCsrScanResultInfo *pScanResult; |
| 6609 | tScanResultHandle hBSSList; |
| 6610 | tANI_U32 nItems = *pNumItems; |
| 6611 | |
| 6612 | *pNumItems = 0; |
| 6613 | status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter)); |
| 6614 | if(HAL_STATUS_SUCCESS(status)) |
| 6615 | { |
| 6616 | palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter)); |
| 6617 | //Here is the profile we need to connect to |
| 6618 | status = csrRoamPrepareFilterFromProfile(pMac, pSession->pCurRoamProfile, pScanFilter); |
| 6619 | if(HAL_STATUS_SUCCESS(status)) |
| 6620 | { |
| 6621 | status = csrScanGetResult(pMac, pScanFilter, &hBSSList); |
| 6622 | if(HAL_STATUS_SUCCESS(status)) |
| 6623 | { |
| 6624 | while(((pScanResult = csrScanResultGetNext(pMac, hBSSList)) != NULL) && ( pSession->NumPmkidCandidate < nItems)) |
| 6625 | { |
| 6626 | //NumPmkidCandidate adds up here |
| 6627 | csrProcessBSSDescForPMKIDList(pMac, &pScanResult->BssDescriptor, |
| 6628 | (tDot11fBeaconIEs *)( pScanResult->pvIes )); |
| 6629 | } |
| 6630 | if(pSession->NumPmkidCandidate) |
| 6631 | { |
| 6632 | *pNumItems = pSession->NumPmkidCandidate; |
| 6633 | palCopyMemory(pMac->hHdd, pPmkidList, pSession->PmkidCandidateInfo, |
| 6634 | pSession->NumPmkidCandidate * sizeof(tPmkidCandidateInfo)); |
| 6635 | } |
| 6636 | csrScanResultPurge(pMac, hBSSList); |
| 6637 | }//Have scan result |
| 6638 | csrFreeScanFilter(pMac, pScanFilter); |
| 6639 | } |
| 6640 | palFreeMemory(pMac->hHdd, pScanFilter); |
| 6641 | } |
| 6642 | } |
| 6643 | |
| 6644 | return (status); |
| 6645 | } |
| 6646 | |
| 6647 | |
| 6648 | |
| 6649 | #ifdef FEATURE_WLAN_WAPI |
| 6650 | eHalStatus csrScanGetBKIDCandidateList(tpAniSirGlobal pMac, tANI_U32 sessionId, |
| 6651 | tBkidCandidateInfo *pBkidList, tANI_U32 *pNumItems ) |
| 6652 | { |
| 6653 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 6654 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 6655 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 6656 | if(!pSession) |
| 6657 | { |
| 6658 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 6659 | return eHAL_STATUS_FAILURE; |
| 6660 | } |
| 6661 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6662 | smsLog(pMac, LOGW, " pMac->scan.NumBkidCandidate = %d", pSession->NumBkidCandidate); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6663 | csrResetBKIDCandidateList(pMac, sessionId); |
| 6664 | if(csrIsConnStateConnected(pMac, sessionId) && pSession->pCurRoamProfile) |
| 6665 | { |
| 6666 | tCsrScanResultFilter *pScanFilter; |
| 6667 | tCsrScanResultInfo *pScanResult; |
| 6668 | tScanResultHandle hBSSList; |
| 6669 | tANI_U32 nItems = *pNumItems; |
| 6670 | *pNumItems = 0; |
| 6671 | status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter)); |
| 6672 | if(HAL_STATUS_SUCCESS(status)) |
| 6673 | { |
| 6674 | palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter)); |
| 6675 | //Here is the profile we need to connect to |
| 6676 | status = csrRoamPrepareFilterFromProfile(pMac, pSession->pCurRoamProfile, pScanFilter); |
| 6677 | if(HAL_STATUS_SUCCESS(status)) |
| 6678 | { |
| 6679 | status = csrScanGetResult(pMac, pScanFilter, &hBSSList); |
| 6680 | if(HAL_STATUS_SUCCESS(status)) |
| 6681 | { |
| 6682 | while(((pScanResult = csrScanResultGetNext(pMac, hBSSList)) != NULL) && ( pSession->NumBkidCandidate < nItems)) |
| 6683 | { |
| 6684 | //pMac->scan.NumBkidCandidate adds up here |
| 6685 | csrProcessBSSDescForBKIDList(pMac, &pScanResult->BssDescriptor, |
| 6686 | (tDot11fBeaconIEs *)( pScanResult->pvIes )); |
| 6687 | |
| 6688 | } |
| 6689 | if(pSession->NumBkidCandidate) |
| 6690 | { |
| 6691 | *pNumItems = pSession->NumBkidCandidate; |
| 6692 | palCopyMemory(pMac->hHdd, pBkidList, pSession->BkidCandidateInfo, pSession->NumBkidCandidate * sizeof(tBkidCandidateInfo)); |
| 6693 | } |
| 6694 | csrScanResultPurge(pMac, hBSSList); |
| 6695 | }//Have scan result |
| 6696 | } |
| 6697 | palFreeMemory(pMac->hHdd, pScanFilter); |
| 6698 | } |
| 6699 | } |
| 6700 | |
| 6701 | return (status); |
| 6702 | } |
| 6703 | #endif /* FEATURE_WLAN_WAPI */ |
| 6704 | |
| 6705 | |
| 6706 | |
| 6707 | //This function is usually used for BSSs that suppresses SSID so the profile |
| 6708 | //shall have one and only one SSID |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 6709 | eHalStatus csrScanForSSID(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tANI_U32 roamId, tANI_BOOLEAN notify) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6710 | { |
| 6711 | eHalStatus status = eHAL_STATUS_INVALID_PARAMETER; |
| 6712 | tSmeCmd *pScanCmd = NULL; |
| 6713 | tANI_U8 bAddr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; |
| 6714 | tANI_U8 index = 0; |
| 6715 | tANI_U32 numSsid = pProfile->SSIDs.numOfSSIDs; |
| 6716 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6717 | smsLog(pMac, LOG2, FL("called")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6718 | //For WDS, we use the index 0. There must be at least one in there |
| 6719 | if( CSR_IS_WDS_STA( pProfile ) && numSsid ) |
| 6720 | { |
| 6721 | numSsid = 1; |
| 6722 | } |
| 6723 | if(pMac->scan.fScanEnable && ( numSsid == 1 ) ) |
| 6724 | { |
| 6725 | do |
| 6726 | { |
| 6727 | pScanCmd = csrGetCommandBuffer(pMac); |
| 6728 | if(!pScanCmd) |
| 6729 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6730 | smsLog(pMac, LOGE, FL("failed to allocate command buffer")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6731 | break; |
| 6732 | } |
| 6733 | palZeroMemory(pMac->hHdd, &pScanCmd->u.scanCmd, sizeof(tScanCmd)); |
| 6734 | status = palAllocateMemory(pMac->hHdd, (void **)&pScanCmd->u.scanCmd.pToRoamProfile, sizeof(tCsrRoamProfile)); |
| 6735 | if(!HAL_STATUS_SUCCESS(status)) |
| 6736 | break; |
| 6737 | status = csrRoamCopyProfile(pMac, pScanCmd->u.scanCmd.pToRoamProfile, pProfile); |
| 6738 | if(!HAL_STATUS_SUCCESS(status)) |
| 6739 | break; |
| 6740 | pScanCmd->u.scanCmd.roamId = roamId; |
| 6741 | pScanCmd->command = eSmeCommandScan; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6742 | pScanCmd->sessionId = (tANI_U8)sessionId; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6743 | pScanCmd->u.scanCmd.callback = NULL; |
| 6744 | pScanCmd->u.scanCmd.pContext = NULL; |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 6745 | pScanCmd->u.scanCmd.reason = eCsrScanForSsid;//Need to check: might need a new reason for SSID scan for LFR during multisession with p2p |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6746 | pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around |
| 6747 | palZeroMemory(pMac->hHdd, &pScanCmd->u.scanCmd.u.scanRequest, sizeof(tCsrScanRequest)); |
| 6748 | pScanCmd->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6749 | pScanCmd->u.scanCmd.u.scanRequest.BSSType = pProfile->BSSType; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6750 | // To avoid 11b rate in probe request Set p2pSearch flag as 1 for P2P Client Mode |
| 6751 | if(VOS_P2P_CLIENT_MODE == pProfile->csrPersona) |
| 6752 | { |
| 6753 | pScanCmd->u.scanCmd.u.scanRequest.p2pSearch = 1; |
| 6754 | } |
| 6755 | if(pProfile->pAddIEScan) |
| 6756 | { |
| 6757 | status = palAllocateMemory(pMac->hHdd, |
| 6758 | (void **)&pScanCmd->u.scanCmd.u.scanRequest.pIEField, |
| 6759 | pProfile->nAddIEScanLength); |
| 6760 | palZeroMemory(pMac->hHdd, pScanCmd->u.scanCmd.u.scanRequest.pIEField, pProfile->nAddIEScanLength); |
| 6761 | if(HAL_STATUS_SUCCESS(status)) |
| 6762 | { |
| 6763 | palCopyMemory(pMac->hHdd, pScanCmd->u.scanCmd.u.scanRequest.pIEField, pProfile->pAddIEScan, pProfile->nAddIEScanLength); |
| 6764 | pScanCmd->u.scanCmd.u.scanRequest.uIEFieldLen = pProfile->nAddIEScanLength; |
| 6765 | } |
| 6766 | else |
| 6767 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6768 | smsLog(pMac, LOGE, "No memory for scanning IE fields"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6769 | } |
| 6770 | } //Allocate memory for IE field |
| 6771 | else |
| 6772 | { |
| 6773 | pScanCmd->u.scanCmd.u.scanRequest.uIEFieldLen = 0; |
| 6774 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 6775 | /* For one channel be good enpugh time to receive beacon atleast */ |
| 6776 | if( 1 == pProfile->ChannelInfo.numOfChannels ) |
| 6777 | { |
| 6778 | pScanCmd->u.scanCmd.u.scanRequest.maxChnTime = MAX_ACTIVE_SCAN_FOR_ONE_CHANNEL; |
| 6779 | pScanCmd->u.scanCmd.u.scanRequest.minChnTime = MIN_ACTIVE_SCAN_FOR_ONE_CHANNEL; |
| 6780 | } |
| 6781 | else |
| 6782 | { |
| 6783 | pScanCmd->u.scanCmd.u.scanRequest.maxChnTime = pMac->roam.configParam.nActiveMaxChnTime; |
| 6784 | pScanCmd->u.scanCmd.u.scanRequest.minChnTime = pMac->roam.configParam.nActiveMinChnTime; |
| 6785 | } |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 6786 | pScanCmd->u.scanCmd.u.scanRequest.maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc; |
| 6787 | pScanCmd->u.scanCmd.u.scanRequest.minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6788 | if(pProfile->BSSIDs.numOfBSSIDs == 1) |
| 6789 | { |
| 6790 | palCopyMemory(pMac->hHdd, pScanCmd->u.scanCmd.u.scanRequest.bssid, pProfile->BSSIDs.bssid, sizeof(tCsrBssid)); |
| 6791 | } |
| 6792 | else |
| 6793 | { |
| 6794 | palCopyMemory(pMac->hHdd, pScanCmd->u.scanCmd.u.scanRequest.bssid, bAddr, 6); |
| 6795 | } |
| 6796 | if(pProfile->ChannelInfo.numOfChannels) |
| 6797 | { |
| 6798 | status = palAllocateMemory(pMac->hHdd, (void **)&pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList, sizeof(*pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList) * pProfile->ChannelInfo.numOfChannels); |
| 6799 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = 0; |
| 6800 | if(HAL_STATUS_SUCCESS(status)) |
| 6801 | { |
| 6802 | csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[0]); |
| 6803 | for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++) |
| 6804 | { |
| 6805 | if(csrRoamIsValidChannel(pMac, pProfile->ChannelInfo.ChannelList[index])) |
| 6806 | { |
| 6807 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels] |
| 6808 | = pProfile->ChannelInfo.ChannelList[index]; |
| 6809 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels++; |
| 6810 | } |
| 6811 | else |
| 6812 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6813 | 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] | 6814 | } |
| 6815 | |
| 6816 | } |
| 6817 | } |
| 6818 | else |
| 6819 | { |
| 6820 | break; |
| 6821 | } |
| 6822 | |
| 6823 | } |
| 6824 | else |
| 6825 | { |
| 6826 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = 0; |
| 6827 | } |
| 6828 | if(pProfile->SSIDs.numOfSSIDs) |
| 6829 | { |
| 6830 | status = palAllocateMemory(pMac->hHdd, (void **)&pScanCmd->u.scanCmd.u.scanRequest.SSIDs.SSIDList, |
| 6831 | pProfile->SSIDs.numOfSSIDs * sizeof(tCsrSSIDInfo)); |
| 6832 | if(!HAL_STATUS_SUCCESS(status)) |
| 6833 | { |
| 6834 | break; |
| 6835 | } |
| 6836 | pScanCmd->u.scanCmd.u.scanRequest.SSIDs.numOfSSIDs = 1; |
| 6837 | palCopyMemory(pMac->hHdd, pScanCmd->u.scanCmd.u.scanRequest.SSIDs.SSIDList, pProfile->SSIDs.SSIDList, |
| 6838 | sizeof(tCsrSSIDInfo)); |
| 6839 | } |
| 6840 | //Start process the command |
| 6841 | status = csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_FALSE); |
| 6842 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 6843 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6844 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6845 | break; |
| 6846 | } |
| 6847 | }while(0); |
| 6848 | if(!HAL_STATUS_SUCCESS(status)) |
| 6849 | { |
| 6850 | if(pScanCmd) |
| 6851 | { |
| 6852 | csrReleaseCommandScan(pMac, pScanCmd); |
| 6853 | //TODO:free the memory that is allocated in this function |
| 6854 | } |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 6855 | if(notify) |
| 6856 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6857 | csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE); |
| 6858 | } |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 6859 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6860 | }//valid |
| 6861 | else |
| 6862 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6863 | 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] | 6864 | pMac->scan.fScanEnable, pProfile->SSIDs.numOfSSIDs); |
| 6865 | } |
| 6866 | |
| 6867 | return (status); |
| 6868 | } |
| 6869 | |
| 6870 | |
| 6871 | //Issue a scan base on the new capability infomation |
| 6872 | //This should only happen when the associated AP changes its capability. |
| 6873 | //After this scan is done, CSR reroams base on the new scan results |
| 6874 | eHalStatus csrScanForCapabilityChange(tpAniSirGlobal pMac, tSirSmeApNewCaps *pNewCaps) |
| 6875 | { |
| 6876 | eHalStatus status = eHAL_STATUS_INVALID_PARAMETER; |
| 6877 | tSmeCmd *pScanCmd = NULL; |
| 6878 | |
| 6879 | if(pNewCaps) |
| 6880 | { |
| 6881 | do |
| 6882 | { |
| 6883 | pScanCmd = csrGetCommandBuffer(pMac); |
| 6884 | if(!pScanCmd) |
| 6885 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6886 | smsLog(pMac, LOGE, FL("failed to allocate command buffer")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6887 | status = eHAL_STATUS_RESOURCES; |
| 6888 | break; |
| 6889 | } |
| 6890 | palZeroMemory(pMac->hHdd, &pScanCmd->u.scanCmd, sizeof(tScanCmd)); |
| 6891 | status = eHAL_STATUS_SUCCESS; |
| 6892 | pScanCmd->u.scanCmd.roamId = 0; |
| 6893 | pScanCmd->command = eSmeCommandScan; |
| 6894 | pScanCmd->u.scanCmd.callback = NULL; |
| 6895 | pScanCmd->u.scanCmd.pContext = NULL; |
| 6896 | pScanCmd->u.scanCmd.reason = eCsrScanForCapsChange; |
| 6897 | pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around |
| 6898 | status = csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_FALSE); |
| 6899 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 6900 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6901 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6902 | break; |
| 6903 | } |
| 6904 | }while(0); |
| 6905 | if(!HAL_STATUS_SUCCESS(status)) |
| 6906 | { |
| 6907 | if(pScanCmd) |
| 6908 | { |
| 6909 | csrReleaseCommandScan(pMac, pScanCmd); |
| 6910 | } |
| 6911 | } |
| 6912 | } |
| 6913 | |
| 6914 | return (status); |
| 6915 | } |
| 6916 | |
| 6917 | |
| 6918 | |
| 6919 | void csrInitBGScanChannelList(tpAniSirGlobal pMac) |
| 6920 | { |
| 6921 | tANI_U32 len = CSR_MIN(sizeof(pMac->roam.validChannelList), sizeof(pMac->scan.bgScanChannelList)); |
| 6922 | |
| 6923 | palZeroMemory(pMac->hHdd, pMac->scan.bgScanChannelList, len); |
| 6924 | pMac->scan.numBGScanChannel = 0; |
| 6925 | |
| 6926 | if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len))) |
| 6927 | { |
| 6928 | pMac->roam.numValidChannels = len; |
| 6929 | pMac->scan.numBGScanChannel = (tANI_U8)CSR_MIN(len, WNI_CFG_BG_SCAN_CHANNEL_LIST_LEN); |
| 6930 | palCopyMemory(pMac->hHdd, pMac->scan.bgScanChannelList, pMac->roam.validChannelList, pMac->scan.numBGScanChannel); |
| 6931 | csrSetBGScanChannelList(pMac, pMac->scan.bgScanChannelList, pMac->scan.numBGScanChannel); |
| 6932 | } |
| 6933 | } |
| 6934 | |
| 6935 | |
| 6936 | //This function return TRUE if background scan channel list is adjusted. |
| 6937 | //this function will only shrink the background scan channel list |
| 6938 | tANI_BOOLEAN csrAdjustBGScanChannelList(tpAniSirGlobal pMac, tANI_U8 *pChannelList, tANI_U8 NumChannels, |
| 6939 | tANI_U8 *pAdjustChannels, tANI_U8 *pNumAdjustChannels) |
| 6940 | { |
| 6941 | tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE; |
| 6942 | tANI_U8 i, j, count = *pNumAdjustChannels; |
| 6943 | |
| 6944 | i = 0; |
| 6945 | while(i < count) |
| 6946 | { |
| 6947 | for(j = 0; j < NumChannels; j++) |
| 6948 | { |
| 6949 | if(pChannelList[j] == pAdjustChannels[i]) |
| 6950 | break; |
| 6951 | } |
| 6952 | if(j == NumChannels) |
| 6953 | { |
| 6954 | //This channel is not in the list, remove it |
| 6955 | fRet = eANI_BOOLEAN_TRUE; |
| 6956 | count--; |
| 6957 | if(count - i) |
| 6958 | { |
| 6959 | palCopyMemory(pMac->hHdd, &pAdjustChannels[i], &pAdjustChannels[i+1], count - i); |
| 6960 | } |
| 6961 | else |
| 6962 | { |
| 6963 | //already remove the last one. Done. |
| 6964 | break; |
| 6965 | } |
| 6966 | } |
| 6967 | else |
| 6968 | { |
| 6969 | i++; |
| 6970 | } |
| 6971 | }//while(i<count) |
| 6972 | *pNumAdjustChannels = count; |
| 6973 | |
| 6974 | return (fRet); |
| 6975 | } |
| 6976 | |
| 6977 | |
| 6978 | //Get the list of the base channels to scan for passively 11d info |
| 6979 | eHalStatus csrScanGetSupportedChannels( tpAniSirGlobal pMac ) |
| 6980 | { |
| 6981 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 6982 | int n = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 6983 | |
| 6984 | status = vos_nv_getSupportedChannels( pMac->scan.baseChannels.channelList, &n, NULL, NULL ); |
| 6985 | if( HAL_STATUS_SUCCESS(status) ) |
| 6986 | { |
| 6987 | pMac->scan.baseChannels.numChannels = (tANI_U8)n; |
| 6988 | } |
| 6989 | else |
| 6990 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6991 | smsLog( pMac, LOGE, FL(" failed") ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6992 | pMac->scan.baseChannels.numChannels = 0; |
| 6993 | } |
| 6994 | |
| 6995 | return ( status ); |
| 6996 | } |
| 6997 | |
| 6998 | //This function use the input pChannelList to validate the current saved channel list |
| 6999 | eHalStatus csrSetBGScanChannelList( tpAniSirGlobal pMac, tANI_U8 *pAdjustChannels, tANI_U8 NumAdjustChannels) |
| 7000 | { |
| 7001 | tANI_U32 dataLen = sizeof( tANI_U8 ) * NumAdjustChannels; |
| 7002 | |
| 7003 | return (ccmCfgSetStr(pMac, WNI_CFG_BG_SCAN_CHANNEL_LIST, pAdjustChannels, dataLen, NULL, eANI_BOOLEAN_FALSE)); |
| 7004 | } |
| 7005 | |
| 7006 | |
| 7007 | void csrSetCfgValidChannelList( tpAniSirGlobal pMac, tANI_U8 *pChannelList, tANI_U8 NumChannels ) |
| 7008 | { |
| 7009 | tANI_U32 dataLen = sizeof( tANI_U8 ) * NumChannels; |
Gopichand Nakkala | f72a387 | 2013-06-11 17:51:13 +0530 | [diff] [blame] | 7010 | eHalStatus status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7011 | |
| 7012 | ccmCfgSetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST, pChannelList, dataLen, NULL, eANI_BOOLEAN_FALSE); |
| 7013 | |
Gopichand Nakkala | f72a387 | 2013-06-11 17:51:13 +0530 | [diff] [blame] | 7014 | if (pMac->fScanOffload) |
| 7015 | { |
| 7016 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, |
| 7017 | "Scan offload is enabled, update default chan list"); |
| 7018 | status = csrUpdateChannelList(&pMac->scan); |
| 7019 | if (eHAL_STATUS_SUCCESS != status) |
| 7020 | { |
| 7021 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, |
| 7022 | "failed to update the supported channel list"); |
| 7023 | } |
| 7024 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7025 | return; |
| 7026 | } |
| 7027 | |
| 7028 | |
| 7029 | |
| 7030 | /* |
| 7031 | * The Tx power limits are saved in the cfg for future usage. |
| 7032 | */ |
| 7033 | void csrSaveTxPowerToCfg( tpAniSirGlobal pMac, tDblLinkList *pList, tANI_U32 cfgId ) |
| 7034 | { |
| 7035 | tListElem *pEntry; |
| 7036 | tANI_U32 cbLen = 0, dataLen; |
| 7037 | tCsrChannelPowerInfo *pChannelSet; |
| 7038 | tANI_U32 idx; |
| 7039 | tSirMacChanInfo *pChannelPowerSet; |
| 7040 | tANI_U8 *pBuf = NULL; |
| 7041 | |
| 7042 | //allocate maximum space for all channels |
| 7043 | dataLen = WNI_CFG_VALID_CHANNEL_LIST_LEN * sizeof(tSirMacChanInfo); |
| 7044 | if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pBuf, dataLen))) |
| 7045 | { |
| 7046 | palZeroMemory(pMac->hHdd, pBuf, dataLen); |
| 7047 | pChannelPowerSet = (tSirMacChanInfo *)(pBuf); |
| 7048 | |
| 7049 | pEntry = csrLLPeekHead( pList, LL_ACCESS_LOCK ); |
| 7050 | // write the tuples (startChan, numChan, txPower) for each channel found in the channel power list. |
| 7051 | while( pEntry ) |
| 7052 | { |
| 7053 | pChannelSet = GET_BASE_ADDR( pEntry, tCsrChannelPowerInfo, link ); |
| 7054 | if ( 1 != pChannelSet->interChannelOffset ) |
| 7055 | { |
| 7056 | // we keep the 5G channel sets internally with an interchannel offset of 4. Expand these |
| 7057 | // to the right format... (inter channel offset of 1 is the only option for the triplets |
| 7058 | // that 11d advertises. |
| 7059 | if ((cbLen + (pChannelSet->numChannels * sizeof(tSirMacChanInfo))) >= dataLen) |
| 7060 | { |
| 7061 | // expanding this entry will overflow our allocation |
| 7062 | smsLog(pMac, LOGE, |
| 7063 | "%s: Buffer overflow, start %d, num %d, offset %d", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7064 | __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7065 | pChannelSet->firstChannel, |
| 7066 | pChannelSet->numChannels, |
| 7067 | pChannelSet->interChannelOffset); |
| 7068 | break; |
| 7069 | } |
| 7070 | |
| 7071 | for( idx = 0; idx < pChannelSet->numChannels; idx++ ) |
| 7072 | { |
| 7073 | pChannelPowerSet->firstChanNum = (tSirMacChanNum)(pChannelSet->firstChannel + ( idx * pChannelSet->interChannelOffset )); |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7074 | smsLog(pMac, LOG3, " Setting Channel Number %d", pChannelPowerSet->firstChanNum); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7075 | pChannelPowerSet->numChannels = 1; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7076 | pChannelPowerSet->maxTxPower = CSR_ROAM_MIN( pChannelSet->txPower, pMac->roam.configParam.nTxPowerCap ); |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7077 | smsLog(pMac, LOG3, " Setting Max Transmit Power %d", pChannelPowerSet->maxTxPower); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7078 | cbLen += sizeof( tSirMacChanInfo ); |
| 7079 | pChannelPowerSet++; |
| 7080 | } |
| 7081 | } |
| 7082 | else |
| 7083 | { |
| 7084 | if (cbLen >= dataLen) |
| 7085 | { |
| 7086 | // this entry will overflow our allocation |
| 7087 | smsLog(pMac, LOGE, |
| 7088 | "%s: Buffer overflow, start %d, num %d, offset %d", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7089 | __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7090 | pChannelSet->firstChannel, |
| 7091 | pChannelSet->numChannels, |
| 7092 | pChannelSet->interChannelOffset); |
| 7093 | break; |
| 7094 | } |
| 7095 | pChannelPowerSet->firstChanNum = pChannelSet->firstChannel; |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7096 | smsLog(pMac, LOG3, " Setting Channel Number %d", pChannelPowerSet->firstChanNum); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7097 | pChannelPowerSet->numChannels = pChannelSet->numChannels; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7098 | pChannelPowerSet->maxTxPower = CSR_ROAM_MIN( pChannelSet->txPower, pMac->roam.configParam.nTxPowerCap ); |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7099 | 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] | 7100 | |
| 7101 | |
| 7102 | cbLen += sizeof( tSirMacChanInfo ); |
| 7103 | pChannelPowerSet++; |
| 7104 | } |
| 7105 | |
| 7106 | pEntry = csrLLNext( pList, pEntry, LL_ACCESS_LOCK ); |
| 7107 | } |
| 7108 | |
| 7109 | if(cbLen) |
| 7110 | { |
| 7111 | ccmCfgSetStr(pMac, cfgId, (tANI_U8 *)pBuf, cbLen, NULL, eANI_BOOLEAN_FALSE); |
| 7112 | } |
| 7113 | palFreeMemory( pMac->hHdd, pBuf ); |
| 7114 | }//Allocate memory |
| 7115 | } |
| 7116 | |
| 7117 | |
| 7118 | void csrSetCfgCountryCode( tpAniSirGlobal pMac, tANI_U8 *countryCode ) |
| 7119 | { |
| 7120 | tANI_U8 cc[WNI_CFG_COUNTRY_CODE_LEN]; |
| 7121 | ///v_REGDOMAIN_t DomainId; |
| 7122 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7123 | smsLog( pMac, LOG3, "Setting Country Code in Cfg from csrSetCfgCountryCode %s",countryCode ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7124 | palCopyMemory( pMac->hHdd, cc, countryCode, WNI_CFG_COUNTRY_CODE_LEN ); |
| 7125 | |
| 7126 | // don't program the bogus country codes that we created for Korea in the MAC. if we see |
| 7127 | // the bogus country codes, program the MAC with the right country code. |
| 7128 | if ( ( 'K' == countryCode[ 0 ] && '1' == countryCode[ 1 ] ) || |
| 7129 | ( 'K' == countryCode[ 0 ] && '2' == countryCode[ 1 ] ) || |
| 7130 | ( 'K' == countryCode[ 0 ] && '3' == countryCode[ 1 ] ) || |
| 7131 | ( 'K' == countryCode[ 0 ] && '4' == countryCode[ 1 ] ) ) |
| 7132 | { |
| 7133 | // replace the alternate Korea country codes, 'K1', 'K2', .. with 'KR' for Korea |
| 7134 | cc[ 1 ] = 'R'; |
| 7135 | } |
| 7136 | ccmCfgSetStr(pMac, WNI_CFG_COUNTRY_CODE, cc, WNI_CFG_COUNTRY_CODE_LEN, NULL, eANI_BOOLEAN_FALSE); |
| 7137 | |
| 7138 | //Need to let HALPHY know about the current domain so it can apply some |
| 7139 | //domain-specific settings (TX filter...) |
| 7140 | /*if(HAL_STATUS_SUCCESS(csrGetRegulatoryDomainForCountry(pMac, cc, &DomainId))) |
| 7141 | { |
| 7142 | halPhySetRegDomain(pMac, DomainId); |
| 7143 | }*/ |
| 7144 | } |
| 7145 | |
| 7146 | |
| 7147 | |
| 7148 | eHalStatus csrGetCountryCode(tpAniSirGlobal pMac, tANI_U8 *pBuf, tANI_U8 *pbLen) |
| 7149 | { |
| 7150 | eHalStatus status = eHAL_STATUS_INVALID_PARAMETER; |
| 7151 | tANI_U32 len; |
| 7152 | |
| 7153 | if(pBuf && pbLen && (*pbLen >= WNI_CFG_COUNTRY_CODE_LEN)) |
| 7154 | { |
| 7155 | len = *pbLen; |
| 7156 | status = ccmCfgGetStr(pMac, WNI_CFG_COUNTRY_CODE, pBuf, &len); |
| 7157 | if(HAL_STATUS_SUCCESS(status)) |
| 7158 | { |
| 7159 | *pbLen = (tANI_U8)len; |
| 7160 | } |
| 7161 | } |
| 7162 | |
| 7163 | return (status); |
| 7164 | } |
| 7165 | |
| 7166 | |
| 7167 | void csrSetCfgScanControlList( tpAniSirGlobal pMac, tANI_U8 *countryCode, tCsrChannel *pChannelList ) |
| 7168 | { |
| 7169 | tANI_U8 i, j; |
| 7170 | tANI_BOOLEAN found=FALSE; |
| 7171 | tANI_U8 *pControlList = NULL; |
| 7172 | tANI_U32 len = WNI_CFG_SCAN_CONTROL_LIST_LEN; |
| 7173 | |
| 7174 | if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pControlList, WNI_CFG_SCAN_CONTROL_LIST_LEN))) |
| 7175 | { |
| 7176 | palZeroMemory(pMac->hHdd, (void *)pControlList, WNI_CFG_SCAN_CONTROL_LIST_LEN); |
| 7177 | if(HAL_STATUS_SUCCESS(ccmCfgGetStr(pMac, WNI_CFG_SCAN_CONTROL_LIST, pControlList, &len))) |
| 7178 | { |
| 7179 | for (i = 0; i < pChannelList->numChannels; i++) |
| 7180 | { |
| 7181 | for (j = 0; j < len; j += 2) |
| 7182 | { |
| 7183 | if (pControlList[j] == pChannelList->channelList[i]) |
| 7184 | { |
| 7185 | found = TRUE; |
| 7186 | break; |
| 7187 | } |
| 7188 | } |
| 7189 | |
| 7190 | if (found) // insert a pair(channel#, flag) |
| 7191 | { |
Gopichand Nakkala | 392cbc1 | 2013-05-28 16:15:00 +0530 | [diff] [blame] | 7192 | pControlList[j+1] = csrGetScanType(pMac, pControlList[j]); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7193 | found = FALSE; // reset the flag |
| 7194 | } |
| 7195 | |
| 7196 | } |
| 7197 | |
| 7198 | ccmCfgSetStr(pMac, WNI_CFG_SCAN_CONTROL_LIST, pControlList, len, NULL, eANI_BOOLEAN_FALSE); |
| 7199 | }//Successfully getting scan control list |
| 7200 | palFreeMemory(pMac->hHdd, pControlList); |
| 7201 | }//AllocateMemory |
| 7202 | } |
| 7203 | |
| 7204 | |
| 7205 | //if bgPeriod is 0, background scan is disabled. It is in millisecond units |
| 7206 | eHalStatus csrSetCfgBackgroundScanPeriod(tpAniSirGlobal pMac, tANI_U32 bgPeriod) |
| 7207 | { |
| 7208 | return (ccmCfgSetInt(pMac, WNI_CFG_BACKGROUND_SCAN_PERIOD, bgPeriod, (tCcmCfgSetCallback) csrScanCcmCfgSetCallback, eANI_BOOLEAN_FALSE)); |
| 7209 | } |
| 7210 | |
| 7211 | |
| 7212 | void csrScanCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result) |
| 7213 | { |
| 7214 | tListElem *pEntry = NULL; |
| 7215 | tSmeCmd *pCommand = NULL; |
| 7216 | tpAniSirGlobal pMac = PMAC_STRUCT( hHal ); |
| 7217 | |
| 7218 | pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK ); |
| 7219 | if ( pEntry ) |
| 7220 | { |
| 7221 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 7222 | if ( eSmeCommandScan == pCommand->command ) |
| 7223 | { |
| 7224 | eCsrScanStatus scanStatus = (CCM_IS_RESULT_SUCCESS(result)) ? eCSR_SCAN_SUCCESS : eCSR_SCAN_FAILURE; |
| 7225 | csrReleaseScanCommand(pMac, pCommand, scanStatus); |
| 7226 | } |
| 7227 | else |
| 7228 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7229 | 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] | 7230 | } |
| 7231 | } |
| 7232 | smeProcessPendingQueue( pMac ); |
| 7233 | } |
| 7234 | |
| 7235 | eHalStatus csrProcessSetBGScanParam(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
| 7236 | { |
| 7237 | eHalStatus status; |
| 7238 | tCsrBGScanRequest *pScanReq = &pCommand->u.scanCmd.u.bgScanRequest; |
| 7239 | tANI_U32 dataLen = sizeof( tANI_U8 ) * pScanReq->ChannelInfo.numOfChannels; |
| 7240 | |
| 7241 | //***setcfg for background scan channel list |
| 7242 | status = ccmCfgSetInt(pMac, WNI_CFG_ACTIVE_MINIMUM_CHANNEL_TIME, pScanReq->minChnTime, NULL, eANI_BOOLEAN_FALSE); |
| 7243 | status = ccmCfgSetInt(pMac, WNI_CFG_ACTIVE_MAXIMUM_CHANNEL_TIME, pScanReq->maxChnTime, NULL, eANI_BOOLEAN_FALSE); |
| 7244 | //Not set the background scan interval if not connected because bd scan should not be run if not connected |
| 7245 | if(!csrIsAllSessionDisconnected(pMac)) |
| 7246 | { |
| 7247 | //If disbaling BG scan here, we need to stop aging as well |
| 7248 | if(pScanReq->scanInterval == 0) |
| 7249 | { |
| 7250 | //Stop aging because no new result is coming in |
| 7251 | csrScanStopResultAgingTimer(pMac); |
| 7252 | } |
| 7253 | |
| 7254 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 7255 | { |
| 7256 | vos_log_scan_pkt_type *pScanLog = NULL; |
| 7257 | |
| 7258 | WLAN_VOS_DIAG_LOG_ALLOC(pScanLog, vos_log_scan_pkt_type, LOG_WLAN_SCAN_C); |
| 7259 | if(pScanLog) |
| 7260 | { |
| 7261 | pScanLog->eventId = WLAN_SCAN_EVENT_HO_SCAN_REQ; |
| 7262 | pScanLog->minChnTime = (v_U8_t)pScanReq->minChnTime; |
| 7263 | pScanLog->maxChnTime = (v_U8_t)pScanReq->maxChnTime; |
| 7264 | pScanLog->timeBetweenBgScan = (v_U8_t)pScanReq->scanInterval; |
| 7265 | pScanLog->numChannel = pScanReq->ChannelInfo.numOfChannels; |
| 7266 | if(pScanLog->numChannel && (pScanLog->numChannel < VOS_LOG_MAX_NUM_CHANNEL)) |
| 7267 | { |
| 7268 | palCopyMemory(pMac->hHdd, pScanLog->channels, pScanReq->ChannelInfo.ChannelList, |
| 7269 | pScanLog->numChannel); |
| 7270 | } |
| 7271 | WLAN_VOS_DIAG_LOG_REPORT(pScanLog); |
| 7272 | } |
| 7273 | } |
| 7274 | #endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 7275 | |
| 7276 | status = ccmCfgSetInt(pMac, WNI_CFG_BACKGROUND_SCAN_PERIOD, pScanReq->scanInterval, NULL, eANI_BOOLEAN_FALSE); |
| 7277 | } |
| 7278 | else |
| 7279 | { |
| 7280 | //No need to stop aging because IDLE scan is still running |
| 7281 | status = ccmCfgSetInt(pMac, WNI_CFG_BACKGROUND_SCAN_PERIOD, 0, NULL, eANI_BOOLEAN_FALSE); |
| 7282 | } |
| 7283 | |
| 7284 | if(pScanReq->SSID.length > WNI_CFG_SSID_LEN) |
| 7285 | { |
| 7286 | pScanReq->SSID.length = WNI_CFG_SSID_LEN; |
| 7287 | } |
| 7288 | |
| 7289 | status = ccmCfgSetStr(pMac, WNI_CFG_BG_SCAN_CHANNEL_LIST, pScanReq->ChannelInfo.ChannelList, dataLen, NULL, eANI_BOOLEAN_FALSE); |
| 7290 | status = ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pScanReq->SSID.ssId, pScanReq->SSID.length, NULL, eANI_BOOLEAN_FALSE); |
| 7291 | |
| 7292 | |
| 7293 | |
| 7294 | return (status); |
| 7295 | } |
| 7296 | |
| 7297 | |
| 7298 | eHalStatus csrScanAbortMacScan(tpAniSirGlobal pMac) |
| 7299 | { |
| 7300 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 7301 | tSirMbMsg *pMsg; |
| 7302 | tANI_U16 msgLen; |
| 7303 | tListElem *pEntry; |
| 7304 | tSmeCmd *pCommand; |
| 7305 | |
| 7306 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 7307 | csrLLLock(&pMac->scan.scanCmdPendingList); |
| 7308 | while( NULL != ( pEntry = csrLLRemoveHead( &pMac->scan.scanCmdPendingList, LL_ACCESS_NOLOCK) ) ) |
| 7309 | { |
| 7310 | |
| 7311 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 7312 | csrAbortCommand( pMac, pCommand, eANI_BOOLEAN_FALSE); |
| 7313 | } |
| 7314 | csrLLUnlock(&pMac->scan.scanCmdPendingList); |
| 7315 | #endif |
| 7316 | |
| 7317 | pMac->scan.fDropScanCmd = eANI_BOOLEAN_TRUE; |
| 7318 | csrRemoveCmdFromPendingList( pMac, &pMac->roam.roamCmdPendingList, eSmeCommandScan); |
| 7319 | csrRemoveCmdFromPendingList( pMac, &pMac->sme.smeCmdPendingList, eSmeCommandScan); |
| 7320 | pMac->scan.fDropScanCmd = eANI_BOOLEAN_FALSE; |
| 7321 | |
| 7322 | //We need to abort scan only if we are scanning |
| 7323 | if(NULL != (pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK))) |
| 7324 | { |
| 7325 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 7326 | if(eSmeCommandScan == pCommand->command) |
| 7327 | { |
| 7328 | msgLen = (tANI_U16)(sizeof( tSirMbMsg )); |
| 7329 | status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen); |
| 7330 | if(HAL_STATUS_SUCCESS(status)) |
| 7331 | { |
| 7332 | palZeroMemory(pMac->hHdd, (void *)pMsg, msgLen); |
| 7333 | pMsg->type = pal_cpu_to_be16((tANI_U16)eWNI_SME_SCAN_ABORT_IND); |
| 7334 | pMsg->msgLen = pal_cpu_to_be16(msgLen); |
| 7335 | status = palSendMBMessage(pMac->hHdd, pMsg); |
| 7336 | } |
| 7337 | } |
| 7338 | } |
| 7339 | |
| 7340 | return( status ); |
| 7341 | } |
| 7342 | |
| 7343 | void csrRemoveCmdFromPendingList(tpAniSirGlobal pMac, tDblLinkList *pList, |
| 7344 | eSmeCommandType commandType ) |
| 7345 | { |
| 7346 | tDblLinkList localList; |
| 7347 | tListElem *pEntry; |
| 7348 | tSmeCmd *pCommand; |
| 7349 | tListElem *pEntryToRemove; |
| 7350 | |
| 7351 | vos_mem_zero(&localList, sizeof(tDblLinkList)); |
| 7352 | if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList))) |
| 7353 | { |
| 7354 | smsLog(pMac, LOGE, FL(" failed to open list")); |
| 7355 | return; |
| 7356 | } |
| 7357 | |
| 7358 | csrLLLock(pList); |
| 7359 | if( !csrLLIsListEmpty( pList, LL_ACCESS_NOLOCK ) ) |
| 7360 | { |
| 7361 | pEntry = csrLLPeekHead( pList, LL_ACCESS_NOLOCK); |
| 7362 | |
| 7363 | // Have to make sure we don't loop back to the head of the list, which will |
| 7364 | // happen if the entry is NOT on the list... |
| 7365 | while( pEntry ) |
| 7366 | { |
| 7367 | pEntryToRemove = pEntry; |
| 7368 | pEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK); |
| 7369 | pCommand = GET_BASE_ADDR( pEntryToRemove, tSmeCmd, Link ); |
| 7370 | if ( pCommand->command == commandType ) |
| 7371 | { |
| 7372 | // Remove that entry only |
| 7373 | if(csrLLRemoveEntry( pList, pEntryToRemove, LL_ACCESS_NOLOCK)) |
| 7374 | { |
| 7375 | csrLLInsertTail(&localList, pEntryToRemove, LL_ACCESS_NOLOCK); |
| 7376 | } |
| 7377 | } |
| 7378 | } |
| 7379 | |
| 7380 | |
| 7381 | } |
| 7382 | csrLLUnlock(pList); |
| 7383 | |
| 7384 | while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) ) |
| 7385 | { |
| 7386 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 7387 | csrAbortCommand( pMac, pCommand, eANI_BOOLEAN_FALSE); |
| 7388 | } |
| 7389 | csrLLClose(&localList); |
| 7390 | |
| 7391 | } |
| 7392 | |
| 7393 | |
| 7394 | eHalStatus csrScanAbortMacScanNotForConnect(tpAniSirGlobal pMac) |
| 7395 | { |
| 7396 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 7397 | |
| 7398 | if( !csrIsScanForRoamCommandActive( pMac ) ) |
| 7399 | { |
| 7400 | //Only abort the scan if it is not used for other roam/connect purpose |
| 7401 | status = csrScanAbortMacScan(pMac); |
| 7402 | } |
| 7403 | |
| 7404 | return (status); |
| 7405 | } |
| 7406 | |
| 7407 | |
| 7408 | eHalStatus csrScanGetScanChannelInfo(tpAniSirGlobal pMac) |
| 7409 | { |
| 7410 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 7411 | tSirMbMsg *pMsg; |
| 7412 | tANI_U16 msgLen; |
| 7413 | |
| 7414 | msgLen = (tANI_U16)(sizeof( tSirMbMsg )); |
| 7415 | status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen); |
| 7416 | if(HAL_STATUS_SUCCESS(status)) |
| 7417 | { |
| 7418 | palZeroMemory(pMac->hHdd, pMsg, msgLen); |
| 7419 | pMsg->type = eWNI_SME_GET_SCANNED_CHANNEL_REQ; |
| 7420 | pMsg->msgLen = msgLen; |
| 7421 | status = palSendMBMessage(pMac->hHdd, pMsg); |
| 7422 | } |
| 7423 | |
| 7424 | return( status ); |
| 7425 | } |
| 7426 | |
| 7427 | tANI_BOOLEAN csrRoamIsValidChannel( tpAniSirGlobal pMac, tANI_U8 channel ) |
| 7428 | { |
| 7429 | tANI_BOOLEAN fValid = FALSE; |
| 7430 | tANI_U32 idxValidChannels; |
| 7431 | tANI_U32 len = pMac->roam.numValidChannels; |
| 7432 | |
| 7433 | for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ ) |
| 7434 | { |
| 7435 | if ( channel == pMac->roam.validChannelList[ idxValidChannels ] ) |
| 7436 | { |
| 7437 | fValid = TRUE; |
| 7438 | break; |
| 7439 | } |
| 7440 | } |
| 7441 | |
| 7442 | return fValid; |
| 7443 | } |
| 7444 | |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 7445 | eHalStatus csrScanSavePreferredNetworkFound(tpAniSirGlobal pMac, |
| 7446 | tSirPrefNetworkFoundInd *pPrefNetworkFoundInd) |
| 7447 | { |
| 7448 | v_U32_t uLen = 0; |
| 7449 | tpSirProbeRespBeacon pParsedFrame; |
| 7450 | tCsrScanResult *pScanResult = NULL; |
| 7451 | tSirBssDescription *pBssDescr = NULL; |
| 7452 | tANI_BOOLEAN fDupBss; |
| 7453 | tDot11fBeaconIEs *pIesLocal = NULL; |
| 7454 | tAniSSID tmpSsid; |
| 7455 | v_TIME_t timer=0; |
| 7456 | tpSirMacMgmtHdr macHeader = (tpSirMacMgmtHdr)pPrefNetworkFoundInd->data; |
| 7457 | |
| 7458 | pParsedFrame = |
| 7459 | (tpSirProbeRespBeacon) vos_mem_malloc(sizeof(tSirProbeRespBeacon)); |
| 7460 | |
| 7461 | if (NULL == pParsedFrame) |
| 7462 | { |
| 7463 | smsLog(pMac, LOGE, FL(" fail to allocate memory for frame")); |
| 7464 | return eHAL_STATUS_RESOURCES; |
| 7465 | } |
| 7466 | |
| 7467 | if ( pPrefNetworkFoundInd->frameLength <= SIR_MAC_HDR_LEN_3A ) |
| 7468 | { |
| 7469 | smsLog(pMac, LOGE, |
| 7470 | FL("Not enough bytes in PNO indication probe resp frame! length=%d"), |
| 7471 | pPrefNetworkFoundInd->frameLength); |
| 7472 | vos_mem_free(pParsedFrame); |
| 7473 | return eHAL_STATUS_FAILURE; |
| 7474 | } |
| 7475 | |
| 7476 | if (sirConvertProbeFrame2Struct(pMac, |
| 7477 | &pPrefNetworkFoundInd->data[SIR_MAC_HDR_LEN_3A], |
| 7478 | pPrefNetworkFoundInd->frameLength - SIR_MAC_HDR_LEN_3A, |
| 7479 | pParsedFrame) != eSIR_SUCCESS || |
| 7480 | !pParsedFrame->ssidPresent) |
| 7481 | { |
| 7482 | smsLog(pMac, LOGE, |
| 7483 | FL("Parse error ProbeResponse, length=%d"), |
| 7484 | pPrefNetworkFoundInd->frameLength); |
| 7485 | vos_mem_free(pParsedFrame); |
| 7486 | return eHAL_STATUS_FAILURE; |
| 7487 | } |
| 7488 | //24 byte MAC header and 12 byte to ssid IE |
| 7489 | if (pPrefNetworkFoundInd->frameLength > |
| 7490 | (SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_SSID_OFFSET)) |
| 7491 | { |
| 7492 | uLen = pPrefNetworkFoundInd->frameLength - |
| 7493 | (SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_SSID_OFFSET); |
| 7494 | } |
| 7495 | |
| 7496 | if ( !HAL_STATUS_SUCCESS(palAllocateMemory( pMac->hHdd, |
| 7497 | (void **)&pScanResult, sizeof(tCsrScanResult) + uLen )) ) |
| 7498 | { |
| 7499 | smsLog(pMac, LOGE, FL(" fail to allocate memory for frame")); |
| 7500 | vos_mem_free(pParsedFrame); |
| 7501 | return eHAL_STATUS_RESOURCES; |
| 7502 | } |
| 7503 | |
| 7504 | palZeroMemory( pMac->hHdd, pScanResult, sizeof(tCsrScanResult) + uLen ); |
| 7505 | pBssDescr = &pScanResult->Result.BssDescriptor; |
| 7506 | /** |
| 7507 | * Length of BSS desription is without length of |
| 7508 | * length itself and length of pointer |
| 7509 | * that holds the next BSS description |
| 7510 | */ |
| 7511 | pBssDescr->length = (tANI_U16)( |
| 7512 | sizeof(tSirBssDescription) - sizeof(tANI_U16) - |
| 7513 | sizeof(tANI_U32) + uLen); |
| 7514 | if (pParsedFrame->dsParamsPresent) |
| 7515 | { |
| 7516 | pBssDescr->channelId = pParsedFrame->channelNumber; |
| 7517 | } |
| 7518 | else if (pParsedFrame->HTInfo.present) |
| 7519 | { |
| 7520 | pBssDescr->channelId = pParsedFrame->HTInfo.primaryChannel; |
| 7521 | } |
| 7522 | else |
| 7523 | { |
| 7524 | pBssDescr->channelId = pParsedFrame->channelNumber; |
| 7525 | } |
| 7526 | |
| 7527 | if ((pBssDescr->channelId > 0) && (pBssDescr->channelId < 15)) |
| 7528 | { |
| 7529 | int i; |
| 7530 | // 11b or 11g packet |
| 7531 | // 11g iff extended Rate IE is present or |
| 7532 | // if there is an A rate in suppRate IE |
| 7533 | for (i = 0; i < pParsedFrame->supportedRates.numRates; i++) |
| 7534 | { |
| 7535 | if (sirIsArate(pParsedFrame->supportedRates.rate[i] & 0x7f)) |
| 7536 | { |
| 7537 | pBssDescr->nwType = eSIR_11G_NW_TYPE; |
| 7538 | break; |
| 7539 | } |
| 7540 | } |
| 7541 | if (pParsedFrame->extendedRatesPresent) |
| 7542 | { |
| 7543 | pBssDescr->nwType = eSIR_11G_NW_TYPE; |
| 7544 | } |
| 7545 | } |
| 7546 | else |
| 7547 | { |
| 7548 | // 11a packet |
| 7549 | pBssDescr->nwType = eSIR_11A_NW_TYPE; |
| 7550 | } |
| 7551 | |
| 7552 | pBssDescr->sinr = 0; |
| 7553 | pBssDescr->rssi = -1 * pPrefNetworkFoundInd->rssi; |
| 7554 | pBssDescr->beaconInterval = pParsedFrame->beaconInterval; |
| 7555 | pBssDescr->timeStamp[0] = pParsedFrame->timeStamp[0]; |
| 7556 | pBssDescr->timeStamp[1] = pParsedFrame->timeStamp[1]; |
| 7557 | pBssDescr->capabilityInfo = *((tANI_U16 *)&pParsedFrame->capabilityInfo); |
| 7558 | palCopyMemory( pMac->hHdd, (tANI_U8 *) &pBssDescr->bssId, |
| 7559 | (tANI_U8 *) macHeader->bssId, |
| 7560 | sizeof(tSirMacAddr)); |
| 7561 | pBssDescr->nReceivedTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd); |
| 7562 | |
| 7563 | smsLog( pMac, LOG2, "(%s):Bssid= %02x-%02x-%02x-%02x-%02x-%02x " |
| 7564 | "chan= %d, rssi = %d", __func__, |
| 7565 | pBssDescr->bssId[ 0 ], pBssDescr->bssId[ 1 ], |
| 7566 | pBssDescr->bssId[ 2 ], pBssDescr->bssId[ 3 ], |
| 7567 | pBssDescr->bssId[ 4 ], pBssDescr->bssId[ 5 ], |
| 7568 | pBssDescr->channelId, |
| 7569 | pBssDescr->rssi ); |
| 7570 | |
| 7571 | //IEs |
| 7572 | if (uLen) |
| 7573 | { |
| 7574 | vos_mem_copy( &pBssDescr->ieFields, |
| 7575 | pPrefNetworkFoundInd->data + |
| 7576 | (SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_SSID_OFFSET), |
| 7577 | uLen); |
| 7578 | } |
| 7579 | |
| 7580 | pIesLocal = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ); |
| 7581 | if ( !pIesLocal && |
| 7582 | (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, |
| 7583 | &pScanResult->Result.BssDescriptor, &pIesLocal))) ) |
| 7584 | { |
| 7585 | smsLog(pMac, LOGE, FL(" Cannot parse IEs")); |
| 7586 | csrFreeScanResultEntry(pMac, pScanResult); |
| 7587 | vos_mem_free(pParsedFrame); |
| 7588 | return eHAL_STATUS_RESOURCES; |
| 7589 | } |
| 7590 | |
| 7591 | fDupBss = csrRemoveDupBssDescription( pMac, |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 7592 | &pScanResult->Result.BssDescriptor, pIesLocal, &tmpSsid, &timer, FALSE); |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 7593 | //Check whether we have reach out limit |
| 7594 | if ( CSR_SCAN_IS_OVER_BSS_LIMIT(pMac) ) |
| 7595 | { |
| 7596 | //Limit reach |
| 7597 | smsLog(pMac, LOGE, FL(" BSS limit reached")); |
| 7598 | //Free the resources |
| 7599 | if( (pScanResult->Result.pvIes == NULL) && pIesLocal ) |
| 7600 | { |
| 7601 | palFreeMemory(pMac->hHdd, pIesLocal); |
| 7602 | } |
| 7603 | csrFreeScanResultEntry(pMac, pScanResult); |
| 7604 | vos_mem_free(pParsedFrame); |
| 7605 | return eHAL_STATUS_RESOURCES; |
| 7606 | } |
| 7607 | //Add to scan cache |
| 7608 | csrScanAddResult(pMac, pScanResult, pIesLocal); |
| 7609 | |
| 7610 | vos_mem_free(pParsedFrame); |
| 7611 | |
| 7612 | return eHAL_STATUS_SUCCESS; |
| 7613 | } |
| 7614 | |
Madan Mohan Koyyalamudi | dd3c966 | 2012-11-09 17:39:30 -0800 | [diff] [blame] | 7615 | #ifdef FEATURE_WLAN_LFR |
| 7616 | void csrInitOccupiedChannelsList(tpAniSirGlobal pMac) |
| 7617 | { |
| 7618 | tListElem *pEntry = NULL; |
| 7619 | tCsrScanResult *pBssDesc = NULL; |
| 7620 | tDot11fBeaconIEs *pIes = NULL; |
Srinivas | 28b5b4e | 2012-12-12 13:07:53 -0800 | [diff] [blame] | 7621 | tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo; |
| 7622 | |
| 7623 | if (0 != pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels) |
| 7624 | { |
| 7625 | 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] | 7626 | " hence NO need to build occupied channel list (numChannels = %d)"), |
Srinivas | 28b5b4e | 2012-12-12 13:07:53 -0800 | [diff] [blame] | 7627 | __func__, pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels); |
| 7628 | return; |
| 7629 | } |
Madan Mohan Koyyalamudi | dd3c966 | 2012-11-09 17:39:30 -0800 | [diff] [blame] | 7630 | |
| 7631 | if (!csrNeighborRoamIsNewConnectedProfile(pMac)) |
| 7632 | { |
| 7633 | 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] | 7634 | " matches previous (numChannels = %d)"), |
Madan Mohan Koyyalamudi | dd3c966 | 2012-11-09 17:39:30 -0800 | [diff] [blame] | 7635 | __func__, pMac->scan.occupiedChannels.numChannels); |
| 7636 | return; |
| 7637 | } |
| 7638 | |
| 7639 | /* Empty occupied channels here */ |
| 7640 | pMac->scan.occupiedChannels.numChannels = 0; |
| 7641 | |
| 7642 | csrLLLock(&pMac->scan.scanResultList); |
| 7643 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK ); |
| 7644 | while( pEntry ) |
| 7645 | { |
| 7646 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 7647 | pIes = (tDot11fBeaconIEs *)( pBssDesc->Result.pvIes ); |
| 7648 | |
| 7649 | //At this time, pBssDescription->Result.pvIes may be NULL |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 7650 | if( !pIes && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, |
Madan Mohan Koyyalamudi | dd3c966 | 2012-11-09 17:39:30 -0800 | [diff] [blame] | 7651 | &pBssDesc->Result.BssDescriptor, &pIes))) ) |
| 7652 | { |
| 7653 | continue; |
| 7654 | } |
| 7655 | |
| 7656 | csrScanAddToOccupiedChannels(pMac, pBssDesc, &pMac->scan.occupiedChannels, pIes); |
| 7657 | |
| 7658 | /* |
| 7659 | * Free the memory allocated for pIes in csrGetParsedBssDescriptionIEs |
| 7660 | */ |
| 7661 | if( (pBssDesc->Result.pvIes == NULL) && pIes ) |
| 7662 | { |
| 7663 | palFreeMemory(pMac->hHdd, pIes); |
| 7664 | } |
| 7665 | |
| 7666 | pEntry = csrLLNext( &pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK ); |
| 7667 | }//while |
| 7668 | csrLLUnlock(&pMac->scan.scanResultList); |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 7669 | |
Madan Mohan Koyyalamudi | dd3c966 | 2012-11-09 17:39:30 -0800 | [diff] [blame] | 7670 | } |
| 7671 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7672 | |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 7673 | eHalStatus csrScanCreateEntryInScanCache(tpAniSirGlobal pMac, tANI_U32 sessionId, |
| 7674 | tCsrBssid bssid, tANI_U8 channel) |
| 7675 | { |
| 7676 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 7677 | tDot11fBeaconIEs *pNewIes = NULL; |
| 7678 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 7679 | tSirBssDescription *pNewBssDescriptor; |
| 7680 | tANI_U32 size = 0; |
| 7681 | |
| 7682 | if(NULL == pSession) |
| 7683 | { |
| 7684 | status = eHAL_STATUS_FAILURE; |
| 7685 | return status; |
| 7686 | } |
| 7687 | smsLog(pMac, LOG2, FL("csrScanCreateEntryInScanCache: Current bssid::" |
| 7688 | "0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x"), |
| 7689 | pSession->pConnectBssDesc->bssId[0], |
| 7690 | pSession->pConnectBssDesc->bssId[1], |
| 7691 | pSession->pConnectBssDesc->bssId[2], |
| 7692 | pSession->pConnectBssDesc->bssId[3], |
| 7693 | pSession->pConnectBssDesc->bssId[4], |
| 7694 | pSession->pConnectBssDesc->bssId[5]); |
| 7695 | smsLog(pMac, LOG2, FL("csrScanCreateEntryInScanCache: My bssid::" |
| 7696 | "0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x channel %d"), |
| 7697 | bssid[0],bssid[1],bssid[2], |
| 7698 | bssid[3],bssid[4],bssid[5],channel); |
| 7699 | |
| 7700 | do |
| 7701 | { |
| 7702 | if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, |
| 7703 | pSession->pConnectBssDesc, &pNewIes))) |
| 7704 | { |
| 7705 | smsLog(pMac, LOGE, FL("%s: Failed to parse IEs"), |
| 7706 | __func__); |
| 7707 | status = eHAL_STATUS_FAILURE; |
| 7708 | break; |
| 7709 | } |
| 7710 | |
| 7711 | size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length); |
| 7712 | if(size) |
| 7713 | { |
| 7714 | status = palAllocateMemory(pMac->hHdd, (void **)&pNewBssDescriptor, size); |
| 7715 | if(HAL_STATUS_SUCCESS(status)) |
| 7716 | { |
| 7717 | palCopyMemory(pMac->hHdd, pNewBssDescriptor, pSession->pConnectBssDesc, size); |
| 7718 | } |
| 7719 | else |
| 7720 | { |
| 7721 | smsLog(pMac, LOGE, FL("%s: memory allocation failed"), |
| 7722 | __func__); |
| 7723 | status = eHAL_STATUS_FAILURE; |
| 7724 | break; |
| 7725 | } |
| 7726 | |
| 7727 | //change the BSSID & channel as passed |
| 7728 | palCopyMemory( pMac->hHdd, pNewBssDescriptor->bssId, bssid, |
| 7729 | sizeof(tSirMacAddr) ); |
| 7730 | pNewBssDescriptor->channelId = channel; |
Tushnim Bhattacharyya | 5128d75 | 2013-06-26 23:23:18 -0700 | [diff] [blame] | 7731 | if(NULL == csrScanAppendBssDescription( pMac, pNewBssDescriptor, pNewIes, TRUE )) |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 7732 | { |
Tushnim Bhattacharyya | 5128d75 | 2013-06-26 23:23:18 -0700 | [diff] [blame] | 7733 | smsLog(pMac, LOGE, FL("%s: csrScanAppendBssDescription failed"), |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 7734 | __func__); |
| 7735 | status = eHAL_STATUS_FAILURE; |
| 7736 | break; |
| 7737 | } |
| 7738 | } |
| 7739 | else |
| 7740 | { |
| 7741 | smsLog(pMac, LOGE, FL("%s: length of bss descriptor is 0"), |
| 7742 | __func__); |
| 7743 | status = eHAL_STATUS_FAILURE; |
| 7744 | break; |
| 7745 | } |
| 7746 | smsLog(pMac, LOGE, FL("%s: entry successfully added in scan cache"), |
| 7747 | __func__); |
| 7748 | }while(0); |
| 7749 | |
| 7750 | if(pNewIes) |
| 7751 | { |
| 7752 | palFreeMemory(pMac->hHdd, pNewIes); |
| 7753 | } |
| 7754 | if(pNewBssDescriptor) |
| 7755 | { |
| 7756 | palFreeMemory(pMac->hHdd, pNewBssDescriptor); |
| 7757 | } |
| 7758 | return status; |
| 7759 | } |