Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Siddharth Bhal | d8a95e8 | 2015-02-12 20:14:52 +0530 | [diff] [blame] | 2 | * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved. |
Kiet Lam | 0fb93dd | 2014-02-19 00:32:59 -0800 | [diff] [blame] | 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
Gopichand Nakkala | 92f07d8 | 2013-01-08 21:16:34 -0800 | [diff] [blame] | 20 | */ |
Kiet Lam | 0fb93dd | 2014-02-19 00:32:59 -0800 | [diff] [blame] | 21 | |
| 22 | /* |
| 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
| 26 | */ |
| 27 | |
Jeff Johnson | 40b59aa | 2013-03-19 14:43:18 -0700 | [diff] [blame] | 28 | /** ------------------------------------------------------------------------- * |
| 29 | ------------------------------------------------------------------------- * |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 30 | |
Jeff Johnson | 40b59aa | 2013-03-19 14:43:18 -0700 | [diff] [blame] | 31 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 32 | \file csrApiScan.c |
Jeff Johnson | 40b59aa | 2013-03-19 14:43:18 -0700 | [diff] [blame] | 33 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 34 | Implementation for the Common Scan interfaces. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 35 | ========================================================================== */ |
| 36 | |
| 37 | #include "aniGlobal.h" |
| 38 | |
| 39 | #include "palApi.h" |
| 40 | #include "csrInsideApi.h" |
| 41 | #include "smeInside.h" |
| 42 | #include "smsDebug.h" |
| 43 | |
| 44 | #include "csrSupport.h" |
| 45 | #include "wlan_qct_tl.h" |
| 46 | |
| 47 | #include "vos_diag_core_log.h" |
| 48 | #include "vos_diag_core_event.h" |
| 49 | |
| 50 | #include "vos_nvitem.h" |
Rajesh Babu Prathipati | 20cdffa | 2014-07-01 22:24:59 +0530 | [diff] [blame] | 51 | #include "vos_memory.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 52 | #include "wlan_qct_wda.h" |
Abhishek Singh | e3fa11f | 2014-05-13 11:11:10 +0530 | [diff] [blame] | 53 | #include "vos_utils.h" |
Jeff Johnson | 40b59aa | 2013-03-19 14:43:18 -0700 | [diff] [blame] | 54 | |
Kiet Lam | d1f3dc8 | 2013-11-05 20:45:04 +0530 | [diff] [blame] | 55 | #define MIN_CHN_TIME_TO_FIND_GO 100 |
| 56 | #define MAX_CHN_TIME_TO_FIND_GO 100 |
| 57 | #define DIRECT_SSID_LEN 7 |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 58 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 59 | |
| 60 | /* Purpose of HIDDEN_TIMER |
| 61 | ** When we remove hidden ssid from the profile i.e., forget the SSID via GUI that SSID shouldn't see in the profile |
| 62 | ** For above requirement we used timer limit, logic is explained below |
| 63 | ** Timer value is initialsed to current time when it receives corresponding probe response of hidden SSID (The probe request is |
| 64 | ** received regularly till SSID in the profile. Once it is removed from profile probe request is not sent.) when we receive probe response |
| 65 | ** for broadcast probe request, during update SSID with saved SSID we will diff current time with saved SSID time if it is greater than 1 min |
| 66 | ** then we are not updating with old one |
| 67 | */ |
| 68 | |
| 69 | #define HIDDEN_TIMER (1*60*1000) |
| 70 | #define CSR_SCAN_RESULT_RSSI_WEIGHT 80 // must be less than 100, represent the persentage of new RSSI |
| 71 | |
| 72 | /*--------------------------------------------------------------------------- |
| 73 | PER filter constant fraction: it is a % |
| 74 | ---------------------------------------------------------------------------*/ |
| 75 | #define CSR_SCAN_PER_FILTER_FRAC 100 |
| 76 | |
| 77 | /*--------------------------------------------------------------------------- |
| 78 | RSSI filter constant fraction: it is a % |
| 79 | ---------------------------------------------------------------------------*/ |
| 80 | #define CSR_SCAN_RSSI_FILTER_FRAC 100 |
| 81 | |
| 82 | /*--------------------------------------------------------------------------- |
| 83 | Convert RSSI into overall score: Since RSSI is in -dBm values, and the |
| 84 | overall needs to be weighted inversely (where greater value means better |
| 85 | system), we convert. |
| 86 | RSSI *cannot* be more than 0xFF or less than 0 for meaningful WLAN operation |
| 87 | ---------------------------------------------------------------------------*/ |
| 88 | #define CSR_SCAN_MAX_SCORE_VAL 0xFF |
| 89 | #define CSR_SCAN_MIN_SCORE_VAL 0x0 |
| 90 | #define CSR_SCAN_HANDOFF_DELTA 10 |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 91 | #define MAX_ACTIVE_SCAN_FOR_ONE_CHANNEL 140 |
| 92 | #define MIN_ACTIVE_SCAN_FOR_ONE_CHANNEL 120 |
Madan Mohan Koyyalamudi | a53c4dc | 2012-11-13 10:35:42 -0800 | [diff] [blame] | 93 | #define CSR_SCAN_OVERALL_SCORE( rssi ) \ |
| 94 | (( rssi < CSR_SCAN_MAX_SCORE_VAL ) \ |
| 95 | ? (CSR_SCAN_MAX_SCORE_VAL-rssi) : CSR_SCAN_MIN_SCORE_VAL) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 96 | |
| 97 | |
| 98 | #define CSR_SCAN_IS_OVER_BSS_LIMIT(pMac) \ |
| 99 | ( (pMac)->scan.nBssLimit <= (csrLLCount(&(pMac)->scan.scanResultList)) ) |
| 100 | |
Sushant Kaushik | f4e085e | 2014-06-17 16:07:33 +0530 | [diff] [blame] | 101 | #define THIRTY_PERCENT(x) (x*30/100); |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 102 | |
krunal soni | 5f112f0 | 2013-11-25 15:00:11 -0800 | [diff] [blame] | 103 | #define MANDATORY_BG_CHANNEL 11 |
| 104 | |
Tushnim Bhattacharyya | 582ac1d | 2013-11-07 23:44:09 -0800 | [diff] [blame] | 105 | #ifndef CONFIG_ENABLE_LINUX_REG |
Sushant Kaushik | f4e085e | 2014-06-17 16:07:33 +0530 | [diff] [blame] | 106 | tCsrIgnoreChannels countryIgnoreList[MAX_COUNTRY_IGNORE] = { |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 107 | { {'U','A'}, { 136, 140}, 2}, |
| 108 | { {'T','W'}, { 36, 40, 44, 48, 52}, 5}, |
Madan Mohan Koyyalamudi | 28dd042 | 2013-08-12 15:06:21 +0530 | [diff] [blame] | 109 | { {'I','D'}, { 165}, 1 }, |
Wilson Yang | e3d2b29 | 2013-10-09 00:35:43 -0700 | [diff] [blame] | 110 | { {'A','U'}, { 120, 124, 128}, 3 }, |
Wilson Yang | ce31eaf | 2013-11-11 14:40:34 -0800 | [diff] [blame] | 111 | { {'A','R'}, { 120, 124, 128}, 3 } |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 112 | }; |
Tushnim Bhattacharyya | 582ac1d | 2013-11-07 23:44:09 -0800 | [diff] [blame] | 113 | #else |
Sushant Kaushik | f4e085e | 2014-06-17 16:07:33 +0530 | [diff] [blame] | 114 | tCsrIgnoreChannels countryIgnoreList[MAX_COUNTRY_IGNORE] = { }; |
Tushnim Bhattacharyya | 582ac1d | 2013-11-07 23:44:09 -0800 | [diff] [blame] | 115 | #endif //CONFIG_ENABLE_LINUX_REG |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 116 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 117 | //*** This is temporary work around. It need to call CCM api to get to CFG later |
| 118 | /// Get string parameter value |
| 119 | extern tSirRetStatus wlan_cfgGetStr(tpAniSirGlobal, tANI_U16, tANI_U8*, tANI_U32*); |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 120 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 121 | void csrScanGetResultTimerHandler(void *); |
Sandeep Puligilla | 2b6dc63 | 2012-12-17 14:44:16 -0800 | [diff] [blame] | 122 | static void csrScanResultCfgAgingTimerHandler(void *pv); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 123 | void csrScanIdleScanTimerHandler(void *); |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 124 | static void csrSetDefaultScanTiming( tpAniSirGlobal pMac, tSirScanType scanType, tCsrScanRequest *pScanRequest); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 125 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 126 | static void csrStaApConcTimerHandler(void *); |
| 127 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 128 | tANI_BOOLEAN csrIsSupportedChannel(tpAniSirGlobal pMac, tANI_U8 channelId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 129 | eHalStatus csrScanChannels( tpAniSirGlobal pMac, tSmeCmd *pCommand ); |
| 130 | void csrSetCfgValidChannelList( tpAniSirGlobal pMac, tANI_U8 *pChannelList, tANI_U8 NumChannels ); |
| 131 | void csrSaveTxPowerToCfg( tpAniSirGlobal pMac, tDblLinkList *pList, tANI_U32 cfgId ); |
| 132 | void csrSetCfgCountryCode( tpAniSirGlobal pMac, tANI_U8 *countryCode ); |
| 133 | void csrPurgeChannelPower( tpAniSirGlobal pMac, tDblLinkList *pChannelList ); |
| 134 | //if bgPeriod is 0, background scan is disabled. It is in millisecond units |
| 135 | eHalStatus csrSetCfgBackgroundScanPeriod(tpAniSirGlobal pMac, tANI_U32 bgPeriod); |
| 136 | eHalStatus csrProcessSetBGScanParam(tpAniSirGlobal pMac, tSmeCmd *pCommand); |
| 137 | void csrReleaseScanCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand, eCsrScanStatus scanStatus); |
| 138 | static tANI_BOOLEAN csrScanValidateScanResult( tpAniSirGlobal pMac, tANI_U8 *pChannels, |
| 139 | tANI_U8 numChn, tSirBssDescription *pBssDesc, |
| 140 | tDot11fBeaconIEs **ppIes ); |
| 141 | eHalStatus csrSetBGScanChannelList( tpAniSirGlobal pMac, tANI_U8 *pAdjustChannels, tANI_U8 NumAdjustChannels); |
| 142 | void csrReleaseCmdSingle(tpAniSirGlobal pMac, tSmeCmd *pCommand); |
| 143 | tANI_BOOLEAN csrRoamIsValidChannel( tpAniSirGlobal pMac, tANI_U8 channel ); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 144 | void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 145 | |
Madan Mohan Koyyalamudi | 783b236 | 2012-10-21 11:54:41 -0700 | [diff] [blame] | 146 | |
Madan Mohan Koyyalamudi | 783b236 | 2012-10-21 11:54:41 -0700 | [diff] [blame] | 147 | |
Madan Mohan Koyyalamudi | 783b236 | 2012-10-21 11:54:41 -0700 | [diff] [blame] | 148 | |
Madan Mohan Koyyalamudi | 923c1e1 | 2012-11-30 17:53:27 -0800 | [diff] [blame] | 149 | static void csrReleaseScanCmdPendingList(tpAniSirGlobal pMac) |
| 150 | { |
| 151 | tListElem *pEntry; |
| 152 | tSmeCmd *pCommand; |
| 153 | |
| 154 | while((pEntry = csrLLRemoveHead( &pMac->scan.scanCmdPendingList, LL_ACCESS_LOCK)) != NULL) |
| 155 | { |
| 156 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 157 | if ( eSmeCsrCommandMask & pCommand->command ) |
| 158 | { |
| 159 | csrAbortCommand( pMac, pCommand, eANI_BOOLEAN_TRUE ); |
| 160 | } |
| 161 | else |
| 162 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 163 | smsLog(pMac, LOGE, FL("Error: Received command : %d"),pCommand->command); |
Madan Mohan Koyyalamudi | 923c1e1 | 2012-11-30 17:53:27 -0800 | [diff] [blame] | 164 | } |
| 165 | } |
| 166 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 167 | //pResult is invalid calling this function. |
| 168 | void csrFreeScanResultEntry( tpAniSirGlobal pMac, tCsrScanResult *pResult ) |
| 169 | { |
| 170 | if( NULL != pResult->Result.pvIes ) |
| 171 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 172 | vos_mem_free(pResult->Result.pvIes); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 173 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 174 | vos_mem_free(pResult); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | |
| 178 | static eHalStatus csrLLScanPurgeResult(tpAniSirGlobal pMac, tDblLinkList *pList) |
| 179 | { |
| 180 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 181 | tListElem *pEntry; |
| 182 | tCsrScanResult *pBssDesc; |
| 183 | |
| 184 | csrLLLock(pList); |
| 185 | |
| 186 | while((pEntry = csrLLRemoveHead(pList, LL_ACCESS_NOLOCK)) != NULL) |
| 187 | { |
| 188 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 189 | csrFreeScanResultEntry( pMac, pBssDesc ); |
| 190 | } |
| 191 | |
| 192 | csrLLUnlock(pList); |
| 193 | |
| 194 | return (status); |
| 195 | } |
| 196 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 197 | eHalStatus csrScanOpen( tpAniSirGlobal pMac ) |
| 198 | { |
| 199 | eHalStatus status; |
| 200 | |
| 201 | do |
| 202 | { |
| 203 | csrLLOpen(pMac->hHdd, &pMac->scan.scanResultList); |
| 204 | csrLLOpen(pMac->hHdd, &pMac->scan.tempScanResults); |
| 205 | csrLLOpen(pMac->hHdd, &pMac->scan.channelPowerInfoList24); |
| 206 | csrLLOpen(pMac->hHdd, &pMac->scan.channelPowerInfoList5G); |
| 207 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 208 | csrLLOpen(pMac->hHdd, &pMac->scan.scanCmdPendingList); |
| 209 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 210 | pMac->scan.fFullScanIssued = eANI_BOOLEAN_FALSE; |
| 211 | pMac->scan.nBssLimit = CSR_MAX_BSS_SUPPORT; |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 212 | status = vos_timer_init(&pMac->scan.hTimerGetResult, VOS_TIMER_TYPE_SW, csrScanGetResultTimerHandler, pMac); |
| 213 | if (!HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 214 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 215 | smsLog(pMac, LOGE, FL("cannot allocate memory for getResult timer")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 216 | break; |
| 217 | } |
| 218 | #ifdef WLAN_AP_STA_CONCURRENCY |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 219 | status = vos_timer_init(&pMac->scan.hTimerStaApConcTimer, VOS_TIMER_TYPE_SW, csrStaApConcTimerHandler, pMac); |
| 220 | if (!HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 221 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 222 | smsLog(pMac, LOGE, FL("cannot allocate memory for hTimerStaApConcTimer timer")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 223 | break; |
| 224 | } |
| 225 | #endif |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 226 | status = vos_timer_init(&pMac->scan.hTimerIdleScan, VOS_TIMER_TYPE_SW, csrScanIdleScanTimerHandler, pMac); |
| 227 | if (!HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 228 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 229 | smsLog(pMac, LOGE, FL("cannot allocate memory for idleScan timer")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 230 | break; |
| 231 | } |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 232 | status = vos_timer_init(&pMac->scan.hTimerResultCfgAging, VOS_TIMER_TYPE_SW, |
| 233 | csrScanResultCfgAgingTimerHandler, pMac); |
| 234 | if (!HAL_STATUS_SUCCESS(status)) |
Sandeep Puligilla | 2b6dc63 | 2012-12-17 14:44:16 -0800 | [diff] [blame] | 235 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 236 | smsLog(pMac, LOGE, FL("cannot allocate memory for CFG ResultAging timer")); |
Sandeep Puligilla | 2b6dc63 | 2012-12-17 14:44:16 -0800 | [diff] [blame] | 237 | break; |
| 238 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 239 | }while(0); |
| 240 | |
| 241 | return (status); |
| 242 | } |
| 243 | |
| 244 | |
| 245 | eHalStatus csrScanClose( tpAniSirGlobal pMac ) |
| 246 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 247 | csrLLScanPurgeResult(pMac, &pMac->scan.tempScanResults); |
| 248 | csrLLScanPurgeResult(pMac, &pMac->scan.scanResultList); |
| 249 | #ifdef WLAN_AP_STA_CONCURRENCY |
Madan Mohan Koyyalamudi | 923c1e1 | 2012-11-30 17:53:27 -0800 | [diff] [blame] | 250 | csrReleaseScanCmdPendingList(pMac); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 251 | #endif |
| 252 | csrLLClose(&pMac->scan.scanResultList); |
| 253 | csrLLClose(&pMac->scan.tempScanResults); |
| 254 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 255 | csrLLClose(&pMac->scan.scanCmdPendingList); |
| 256 | #endif |
| 257 | csrPurgeChannelPower(pMac, &pMac->scan.channelPowerInfoList24); |
| 258 | csrPurgeChannelPower(pMac, &pMac->scan.channelPowerInfoList5G); |
| 259 | csrLLClose(&pMac->scan.channelPowerInfoList24); |
| 260 | csrLLClose(&pMac->scan.channelPowerInfoList5G); |
| 261 | csrScanDisable(pMac); |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 262 | vos_timer_destroy(&pMac->scan.hTimerResultCfgAging); |
| 263 | vos_timer_destroy(&pMac->scan.hTimerGetResult); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 264 | #ifdef WLAN_AP_STA_CONCURRENCY |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 265 | vos_timer_destroy(&pMac->scan.hTimerStaApConcTimer); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 266 | #endif |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 267 | vos_timer_destroy(&pMac->scan.hTimerIdleScan); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 268 | return eHAL_STATUS_SUCCESS; |
| 269 | } |
| 270 | |
| 271 | |
| 272 | eHalStatus csrScanEnable( tpAniSirGlobal pMac ) |
| 273 | { |
| 274 | |
| 275 | pMac->scan.fScanEnable = eANI_BOOLEAN_TRUE; |
| 276 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 277 | |
| 278 | return eHAL_STATUS_SUCCESS; |
| 279 | } |
| 280 | |
| 281 | |
| 282 | eHalStatus csrScanDisable( tpAniSirGlobal pMac ) |
| 283 | { |
| 284 | |
| 285 | csrScanStopTimers(pMac); |
| 286 | pMac->scan.fScanEnable = eANI_BOOLEAN_FALSE; |
| 287 | |
| 288 | return eHAL_STATUS_SUCCESS; |
| 289 | } |
| 290 | |
| 291 | |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 292 | //Set scan timing parameters according to state of other driver sessions |
| 293 | //No validation of the parameters is performed. |
| 294 | static void csrSetDefaultScanTiming( tpAniSirGlobal pMac, tSirScanType scanType, tCsrScanRequest *pScanRequest) |
| 295 | { |
| 296 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 297 | if(csrIsAnySessionConnected(pMac)) |
| 298 | { |
Sushant Kaushik | a6fef4b | 2014-09-24 16:17:08 +0530 | [diff] [blame] | 299 | //Reset passive scan time as per ini parameter. |
Abhishek Singh | 7fb7dc1 | 2014-11-06 17:44:05 +0530 | [diff] [blame] | 300 | ccmCfgSetInt(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, |
Sushant Kaushik | a6fef4b | 2014-09-24 16:17:08 +0530 | [diff] [blame] | 301 | pMac->roam.configParam.nPassiveMaxChnTimeConc, |
| 302 | NULL,eANI_BOOLEAN_FALSE); |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 303 | //If multi-session, use the appropriate default scan times |
| 304 | if(scanType == eSIR_ACTIVE_SCAN) |
| 305 | { |
| 306 | pScanRequest->maxChnTime = pMac->roam.configParam.nActiveMaxChnTimeConc; |
| 307 | pScanRequest->minChnTime = pMac->roam.configParam.nActiveMinChnTimeConc; |
| 308 | } |
| 309 | else |
| 310 | { |
| 311 | pScanRequest->maxChnTime = pMac->roam.configParam.nPassiveMaxChnTimeConc; |
| 312 | pScanRequest->minChnTime = pMac->roam.configParam.nPassiveMinChnTimeConc; |
| 313 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 314 | pScanRequest->maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc; |
| 315 | pScanRequest->minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc; |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 316 | |
| 317 | pScanRequest->restTime = pMac->roam.configParam.nRestTimeConc; |
| 318 | |
| 319 | //Return so that fields set above will not be overwritten. |
| 320 | return; |
| 321 | } |
| 322 | #endif |
| 323 | |
| 324 | //This portion of the code executed if multi-session not supported |
| 325 | //(WLAN_AP_STA_CONCURRENCY not defined) or no multi-session. |
| 326 | //Use the "regular" (non-concurrency) default scan timing. |
Abhishek Singh | 7fb7dc1 | 2014-11-06 17:44:05 +0530 | [diff] [blame] | 327 | ccmCfgSetInt(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, |
Kaushik, Sushant | 49758c1 | 2014-09-26 11:25:38 +0530 | [diff] [blame] | 328 | pMac->roam.configParam.nPassiveMaxChnTime, |
| 329 | NULL,eANI_BOOLEAN_FALSE); |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 330 | if(pScanRequest->scanType == eSIR_ACTIVE_SCAN) |
| 331 | { |
| 332 | pScanRequest->maxChnTime = pMac->roam.configParam.nActiveMaxChnTime; |
| 333 | pScanRequest->minChnTime = pMac->roam.configParam.nActiveMinChnTime; |
| 334 | } |
| 335 | else |
| 336 | { |
| 337 | pScanRequest->maxChnTime = pMac->roam.configParam.nPassiveMaxChnTime; |
| 338 | pScanRequest->minChnTime = pMac->roam.configParam.nPassiveMinChnTime; |
| 339 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 340 | pScanRequest->maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc; |
| 341 | pScanRequest->minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc; |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 342 | |
| 343 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 344 | //No rest time if no sessions are connected. |
| 345 | pScanRequest->restTime = 0; |
| 346 | #endif |
| 347 | } |
| 348 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 349 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 350 | //Return SUCCESS is the command is queued, else returns eHAL_STATUS_FAILURE |
| 351 | eHalStatus csrQueueScanRequest( tpAniSirGlobal pMac, tSmeCmd *pScanCmd ) |
| 352 | { |
| 353 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 354 | |
| 355 | tANI_BOOLEAN fNoCmdPending; |
| 356 | tSmeCmd *pQueueScanCmd=NULL; |
| 357 | tSmeCmd *pSendScanCmd=NULL; |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 358 | tANI_U8 nNumChanCombinedConc = 0; |
Gopichand Nakkala | 114718f | 2013-03-25 19:19:46 -0700 | [diff] [blame] | 359 | if (NULL == pScanCmd) |
| 360 | { |
| 361 | smsLog (pMac, LOGE, FL("Scan Req cmd is NULL")); |
| 362 | return eHAL_STATUS_FAILURE; |
| 363 | } |
Madan Mohan Koyyalamudi | 48081ef | 2012-12-04 16:49:55 -0800 | [diff] [blame] | 364 | /* split scan if any one of the following: |
| 365 | * - STA session is connected and the scan is not a P2P search |
| 366 | * - any P2P session is connected |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 367 | * Do not split scans if no concurrent infra connections are |
| 368 | * active and if the scan is a BG scan triggered by LFR (OR) |
| 369 | * any scan if LFR is in the middle of a BG scan. Splitting |
| 370 | * the scan is delaying the time it takes for LFR to find |
| 371 | * candidates and resulting in disconnects. |
Madan Mohan Koyyalamudi | 48081ef | 2012-12-04 16:49:55 -0800 | [diff] [blame] | 372 | */ |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 373 | |
| 374 | if(csrIsStaSessionConnected(pMac) && |
| 375 | !csrIsP2pSessionConnected(pMac)) |
| 376 | { |
| 377 | nNumChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc; |
| 378 | } |
| 379 | else if(csrIsP2pSessionConnected(pMac)) |
| 380 | { |
| 381 | nNumChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc; |
| 382 | } |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 383 | if ( (csrIsStaSessionConnected(pMac) && |
| 384 | #ifdef FEATURE_WLAN_LFR |
| 385 | (csrIsConcurrentInfraConnected(pMac) || |
| 386 | ((pScanCmd->u.scanCmd.reason != eCsrScanBgScan) && |
| 387 | (pMac->roam.neighborRoamInfo.neighborRoamState != |
| 388 | eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN))) && |
| 389 | #endif |
| 390 | (pScanCmd->u.scanCmd.u.scanRequest.p2pSearch != 1)) || |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 391 | (csrIsP2pSessionConnected(pMac)) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 392 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 393 | tCsrScanRequest scanReq; |
| 394 | tANI_U8 numChn = pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels; |
| 395 | tCsrChannelInfo *pChnInfo = &scanReq.ChannelInfo; |
| 396 | tANI_U8 channelToScan[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 397 | tANI_BOOLEAN bMemAlloc = eANI_BOOLEAN_FALSE; |
| 398 | |
| 399 | if (numChn == 0) |
| 400 | { |
| 401 | |
| 402 | numChn = pMac->scan.baseChannels.numChannels; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 403 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 404 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = vos_mem_malloc(numChn); |
| 405 | if ( NULL == pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 406 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 407 | smsLog( pMac, LOGE, FL(" Failed to get memory for channel list ") ); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 408 | return eHAL_STATUS_FAILURE; |
| 409 | } |
| 410 | bMemAlloc = eANI_BOOLEAN_TRUE; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 411 | vos_mem_copy(pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList, |
| 412 | pMac->scan.baseChannels.channelList, numChn); |
| 413 | status = eHAL_STATUS_SUCCESS; |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 414 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 415 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 416 | vos_mem_free(pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 417 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = NULL; |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 418 | smsLog( pMac, LOGE, FL(" Failed to copy memory to channel list ") ); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 419 | return eHAL_STATUS_FAILURE; |
| 420 | } |
| 421 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = numChn; |
| 422 | } |
Sushant Kaushik | 826de80 | 2014-05-08 18:04:11 +0530 | [diff] [blame] | 423 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, |
| 424 | "%s: Total Number of channels to scan : %d " |
| 425 | "Splitted in group of %d ", __func__, numChn, |
| 426 | nNumChanCombinedConc); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 427 | //Whenever we get a scan request with multiple channels we break it up into 2 requests |
| 428 | //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] | 429 | if ( numChn > nNumChanCombinedConc) |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 430 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 431 | vos_mem_set(&scanReq, sizeof(tCsrScanRequest), 0); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 432 | |
| 433 | pQueueScanCmd = csrGetCommandBuffer(pMac); //optimize this to use 2 command buffer only |
| 434 | if (!pQueueScanCmd) |
| 435 | { |
| 436 | if (bMemAlloc) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 437 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 438 | vos_mem_free(pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 439 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = NULL; |
| 440 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 441 | } |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 442 | smsLog( pMac, LOGE, FL(" Failed to get Queue command buffer") ); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 443 | return eHAL_STATUS_FAILURE; |
| 444 | } |
| 445 | pQueueScanCmd->command = pScanCmd->command; |
| 446 | pQueueScanCmd->sessionId = pScanCmd->sessionId; |
| 447 | pQueueScanCmd->u.scanCmd.callback = pScanCmd->u.scanCmd.callback; |
| 448 | pQueueScanCmd->u.scanCmd.pContext = pScanCmd->u.scanCmd.pContext; |
| 449 | pQueueScanCmd->u.scanCmd.reason = pScanCmd->u.scanCmd.reason; |
| 450 | pQueueScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 451 | |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 452 | /* First copy all the parameters to local variable of scan request */ |
| 453 | csrScanCopyRequest(pMac, &scanReq, &pScanCmd->u.scanCmd.u.scanRequest); |
Madan Mohan Koyyalamudi | af2a8b9 | 2012-10-09 14:58:07 -0700 | [diff] [blame] | 454 | |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 455 | /* Now modify the elements of local var scan request required to be modified for split scan */ |
| 456 | if(scanReq.ChannelInfo.ChannelList != NULL) |
| 457 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 458 | vos_mem_free(scanReq.ChannelInfo.ChannelList); |
Madan Mohan Koyyalamudi | 0c626f3 | 2012-11-30 15:10:25 -0800 | [diff] [blame] | 459 | scanReq.ChannelInfo.ChannelList = NULL; |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 460 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 461 | |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 462 | pChnInfo->numOfChannels = pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels - nNumChanCombinedConc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 463 | |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 464 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN, |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 465 | FL(" &channelToScan %p pScanCmd(%p) pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList(%p)numChn(%d)"), |
| 466 | &channelToScan[0], pScanCmd, |
| 467 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList, numChn); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 468 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 469 | vos_mem_copy(&channelToScan[0], |
| 470 | &pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[ |
| 471 | nNumChanCombinedConc], |
| 472 | pChnInfo->numOfChannels * sizeof(tANI_U8)); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 473 | |
| 474 | pChnInfo->ChannelList = &channelToScan[0]; |
| 475 | |
| 476 | scanReq.BSSType = eCSR_BSS_TYPE_ANY; |
c_hpothu | dbefd3e | 2014-04-28 15:59:47 +0530 | [diff] [blame] | 477 | |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 478 | //Use concurrency values for min/maxChnTime. |
| 479 | //We know csrIsAnySessionConnected(pMac) returns TRUE here |
| 480 | csrSetDefaultScanTiming(pMac, scanReq.scanType, &scanReq); |
| 481 | |
| 482 | status = csrScanCopyRequest(pMac, &pQueueScanCmd->u.scanCmd.u.scanRequest, &scanReq); |
| 483 | |
| 484 | if(!HAL_STATUS_SUCCESS(status)) |
| 485 | { |
| 486 | if (bMemAlloc) |
| 487 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 488 | vos_mem_free(pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 489 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = NULL; |
| 490 | |
| 491 | } |
| 492 | if( scanReq.pIEField != NULL) |
| 493 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 494 | vos_mem_free(scanReq.pIEField); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 495 | scanReq.pIEField = NULL; |
| 496 | } |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 497 | smsLog( pMac, LOGE, FL(" Failed to get copy csrScanRequest = %d"), status ); |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 498 | return eHAL_STATUS_FAILURE; |
| 499 | } |
| 500 | /* Clean the local scan variable */ |
| 501 | scanReq.ChannelInfo.ChannelList = NULL; |
| 502 | scanReq.ChannelInfo.numOfChannels = 0; |
| 503 | csrScanFreeRequest(pMac, &scanReq); |
| 504 | |
| 505 | /* setup the command to scan 2 channels */ |
| 506 | pSendScanCmd = pScanCmd; |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 507 | pSendScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = nNumChanCombinedConc; |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 508 | pSendScanCmd->u.scanCmd.u.scanRequest.BSSType = eCSR_BSS_TYPE_ANY; |
c_hpothu | dbefd3e | 2014-04-28 15:59:47 +0530 | [diff] [blame] | 509 | |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 510 | //Use concurrency values for min/maxChnTime. |
| 511 | //We know csrIsAnySessionConnected(pMac) returns TRUE here |
| 512 | csrSetDefaultScanTiming(pMac, pSendScanCmd->u.scanCmd.u.scanRequest.scanType, &pSendScanCmd->u.scanCmd.u.scanRequest); |
| 513 | pSendScanCmd->u.scanCmd.callback = NULL; |
| 514 | } else { |
| 515 | pSendScanCmd = pScanCmd; |
| 516 | pSendScanCmd->u.scanCmd.u.scanRequest.BSSType = eCSR_BSS_TYPE_ANY; |
c_hpothu | dbefd3e | 2014-04-28 15:59:47 +0530 | [diff] [blame] | 517 | |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 518 | //Use concurrency values for min/maxChnTime. |
| 519 | //We know csrIsAnySessionConnected(pMac) returns TRUE here |
| 520 | csrSetDefaultScanTiming(pMac, pSendScanCmd->u.scanCmd.u.scanRequest.scanType, &pSendScanCmd->u.scanCmd.u.scanRequest); |
| 521 | } |
| 522 | |
| 523 | fNoCmdPending = csrLLIsListEmpty( &pMac->scan.scanCmdPendingList, LL_ACCESS_LOCK ); |
| 524 | |
| 525 | //Logic Below is as follows |
| 526 | // If the scanCmdPendingList is empty then we directly send that command |
| 527 | // to smeCommandQueue else we buffer it in our scanCmdPendingList Queue |
| 528 | if( fNoCmdPending ) |
| 529 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 530 | if (pQueueScanCmd != NULL) |
| 531 | { |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 532 | csrLLInsertTail( &pMac->scan.scanCmdPendingList, &pQueueScanCmd->Link, LL_ACCESS_LOCK ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 533 | } |
| 534 | |
| 535 | if (pSendScanCmd != NULL) |
| 536 | { |
| 537 | return csrQueueSmeCommand(pMac, pSendScanCmd, eANI_BOOLEAN_FALSE); |
| 538 | } |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 539 | } |
| 540 | else |
| 541 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 542 | if (pSendScanCmd != NULL) |
| 543 | { |
| 544 | csrLLInsertTail( &pMac->scan.scanCmdPendingList, &pSendScanCmd->Link, LL_ACCESS_LOCK ); |
| 545 | } |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 546 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 547 | if (pQueueScanCmd != NULL) |
| 548 | { |
| 549 | csrLLInsertTail( &pMac->scan.scanCmdPendingList, &pQueueScanCmd->Link, LL_ACCESS_LOCK ); |
| 550 | } |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 551 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 552 | } |
| 553 | else |
| 554 | { //No concurrency case |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 555 | smsLog( pMac, LOG2, FL("Queuing scan command (reason=%d, roamState=%d" |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 556 | " numOfChannels=%d)"), |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 557 | pScanCmd->u.scanCmd.reason, |
| 558 | pMac->roam.neighborRoamInfo.neighborRoamState, |
| 559 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 560 | return csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_FALSE); |
| 561 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 562 | |
| 563 | return ( status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 564 | } |
| 565 | #endif |
| 566 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 567 | /* --------------------------------------------------------------------------- |
| 568 | \fn csrScan2GOnyRequest |
| 569 | \brief This function will update the scan request with only |
Jeff Johnson | b88db98 | 2012-12-10 13:34:59 -0800 | [diff] [blame] | 570 | 2.4GHz valid channel list. |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 571 | \param pMac |
| 572 | \param pScanCmd |
| 573 | \param pScanRequest |
| 574 | \return None |
| 575 | -------------------------------------------------------------------------------*/ |
| 576 | static void csrScan2GOnyRequest(tpAniSirGlobal pMac,tSmeCmd *pScanCmd, |
| 577 | tCsrScanRequest *pScanRequest) |
| 578 | { |
| 579 | tANI_U8 index, channelId, channelListSize = 0; |
| 580 | tANI_U8 channelList2G[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}; |
| 581 | static tANI_U8 validchannelList[CSR_MAX_2_4_GHZ_SUPPORTED_CHANNELS] = {0}; |
| 582 | |
| 583 | VOS_ASSERT(pScanCmd && pScanRequest); |
Madan Mohan Koyyalamudi | 33ef6a2 | 2012-10-30 17:44:43 -0700 | [diff] [blame] | 584 | /* To silence the KW tool null check is added */ |
| 585 | if((pScanCmd == NULL) || (pScanRequest == NULL)) |
| 586 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 587 | smsLog( pMac, LOGE, FL(" pScanCmd or pScanRequest is NULL ")); |
Madan Mohan Koyyalamudi | 33ef6a2 | 2012-10-30 17:44:43 -0700 | [diff] [blame] | 588 | return; |
| 589 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 590 | |
| 591 | if (pScanCmd->u.scanCmd.scanID || |
| 592 | (eCSR_SCAN_REQUEST_FULL_SCAN != pScanRequest->requestType)) |
| 593 | return; |
| 594 | |
| 595 | //Contsruct valid Supported 2.4 GHz Channel List |
| 596 | for( index = 0; index < ARRAY_SIZE(channelList2G); index++ ) |
| 597 | { |
| 598 | channelId = channelList2G[index]; |
| 599 | if ( csrIsSupportedChannel( pMac, channelId ) ) |
| 600 | { |
| 601 | validchannelList[channelListSize++] = channelId; |
| 602 | } |
| 603 | } |
| 604 | |
| 605 | pScanRequest->ChannelInfo.numOfChannels = channelListSize; |
| 606 | pScanRequest->ChannelInfo.ChannelList = validchannelList; |
| 607 | } |
| 608 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 609 | eHalStatus csrScanRequest(tpAniSirGlobal pMac, tANI_U16 sessionId, |
| 610 | tCsrScanRequest *pScanRequest, tANI_U32 *pScanRequestID, |
| 611 | csrScanCompleteCallback callback, void *pContext) |
| 612 | { |
| 613 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 614 | tSmeCmd *pScanCmd = NULL; |
Madan Mohan Koyyalamudi | cb90bb2 | 2012-10-30 18:24:43 -0700 | [diff] [blame] | 615 | eCsrConnectState ConnectState; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 616 | |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 617 | if(pScanRequest == NULL) |
| 618 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 619 | smsLog( pMac, LOGE, FL(" pScanRequest is NULL")); |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 620 | VOS_ASSERT(0); |
Kaushik, Sushant | 488df38 | 2014-03-05 11:43:47 +0530 | [diff] [blame] | 621 | return eHAL_STATUS_FAILURE ; |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 622 | } |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 623 | |
Kiet Lam | d1f3dc8 | 2013-11-05 20:45:04 +0530 | [diff] [blame] | 624 | /* During group formation, the P2P client scans for GO with the specific SSID. |
| 625 | * There will be chances of GO switching to other channels because of scan or |
| 626 | * to STA channel in case of STA+GO MCC scenario. So to increase the possibility |
| 627 | * of client to find the GO, the dwell time of scan is increased to 100ms. |
| 628 | */ |
| 629 | if(pScanRequest->p2pSearch) |
| 630 | { |
Rashmi Ramanna | 6f7931c | 2013-12-20 09:04:12 +0530 | [diff] [blame] | 631 | if(pScanRequest->SSIDs.numOfSSIDs) |
Kiet Lam | d1f3dc8 | 2013-11-05 20:45:04 +0530 | [diff] [blame] | 632 | { |
Rashmi Ramanna | 6f7931c | 2013-12-20 09:04:12 +0530 | [diff] [blame] | 633 | //If the scan request is for specific SSId the length of SSID will be |
| 634 | //greater than 7 as SSID for p2p search contains "DIRECT-") |
| 635 | if(pScanRequest->SSIDs.SSIDList->SSID.length > DIRECT_SSID_LEN) |
| 636 | { |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 637 | smsLog( pMac, LOG1, FL("P2P: Increasing the min and max Dwell" |
| 638 | " time to %d for specific SSID scan %.*s"), |
| 639 | MAX_CHN_TIME_TO_FIND_GO, |
| 640 | pScanRequest->SSIDs.SSIDList->SSID.length, |
| 641 | pScanRequest->SSIDs.SSIDList->SSID.ssId); |
Rashmi Ramanna | 6f7931c | 2013-12-20 09:04:12 +0530 | [diff] [blame] | 642 | pScanRequest->maxChnTime = MAX_CHN_TIME_TO_FIND_GO; |
| 643 | pScanRequest->minChnTime = MIN_CHN_TIME_TO_FIND_GO; |
| 644 | } |
Kiet Lam | d1f3dc8 | 2013-11-05 20:45:04 +0530 | [diff] [blame] | 645 | } |
| 646 | } |
| 647 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 648 | do |
| 649 | { |
| 650 | if(pMac->scan.fScanEnable) |
| 651 | { |
| 652 | pScanCmd = csrGetCommandBuffer(pMac); |
| 653 | if(pScanCmd) |
| 654 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 655 | vos_mem_set(&pScanCmd->u.scanCmd, sizeof(tScanCmd), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 656 | pScanCmd->command = eSmeCommandScan; |
| 657 | pScanCmd->sessionId = sessionId; |
| 658 | pScanCmd->u.scanCmd.callback = callback; |
| 659 | pScanCmd->u.scanCmd.pContext = pContext; |
| 660 | if(eCSR_SCAN_REQUEST_11D_SCAN == pScanRequest->requestType) |
| 661 | { |
| 662 | pScanCmd->u.scanCmd.reason = eCsrScan11d1; |
| 663 | } |
| 664 | else if((eCSR_SCAN_REQUEST_FULL_SCAN == pScanRequest->requestType) || |
| 665 | (eCSR_SCAN_P2P_DISCOVERY == pScanRequest->requestType) |
| 666 | #ifdef SOFTAP_CHANNEL_RANGE |
| 667 | ||(eCSR_SCAN_SOFTAP_CHANNEL_RANGE == pScanRequest->requestType) |
| 668 | #endif |
| 669 | ) |
| 670 | { |
| 671 | pScanCmd->u.scanCmd.reason = eCsrScanUserRequest; |
| 672 | } |
| 673 | else if(eCSR_SCAN_HO_BG_SCAN == pScanRequest->requestType) |
| 674 | { |
| 675 | pScanCmd->u.scanCmd.reason = eCsrScanBgScan; |
| 676 | } |
| 677 | else if(eCSR_SCAN_HO_PROBE_SCAN == pScanRequest->requestType) |
| 678 | { |
| 679 | pScanCmd->u.scanCmd.reason = eCsrScanProbeBss; |
| 680 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 681 | else if(eCSR_SCAN_P2P_FIND_PEER == pScanRequest->requestType) |
| 682 | { |
| 683 | pScanCmd->u.scanCmd.reason = eCsrScanP2PFindPeer; |
| 684 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 685 | else |
| 686 | { |
| 687 | pScanCmd->u.scanCmd.reason = eCsrScanIdleScan; |
| 688 | } |
| 689 | if(pScanRequest->minChnTime == 0 && pScanRequest->maxChnTime == 0) |
| 690 | { |
| 691 | //The caller doesn't set the time correctly. Set it here |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 692 | csrSetDefaultScanTiming(pMac, pScanRequest->scanType, |
| 693 | pScanRequest); |
| 694 | smsLog(pMac, LOG1, FL("Setting default min %d and max %d" |
| 695 | " ChnTime"), pScanRequest->minChnTime, |
| 696 | pScanRequest->maxChnTime); |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 697 | } |
| 698 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 699 | if(pScanRequest->restTime == 0) |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 700 | { |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 701 | //Need to set restTime only if at least one session is connected |
| 702 | if(csrIsAnySessionConnected(pMac)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 703 | { |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 704 | pScanRequest->restTime = pMac->roam.configParam.nRestTimeConc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 705 | } |
| 706 | } |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 707 | #endif |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 708 | /*For Standalone wlan : channel time will remain the same. |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 709 | 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] | 710 | This has been done to provide a larger scan window for faster connection during btc.Else Scan is seen |
| 711 | to take a long time. |
| 712 | For BTC with A2DP up: Channel time will not be doubled, if station is already associated. |
| 713 | */ |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 714 | status = csrRoamGetConnectState(pMac,sessionId,&ConnectState); |
Srinivas Girigowda | c84c57c | 2013-02-19 17:41:56 -0800 | [diff] [blame] | 715 | if (HAL_STATUS_SUCCESS(status) && |
| 716 | pMac->btc.fA2DPUp && |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 717 | (eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED != ConnectState) && |
| 718 | (eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED != ConnectState)) |
| 719 | { |
| 720 | pScanRequest->maxChnTime = pScanRequest->maxChnTime << 1; |
| 721 | pScanRequest->minChnTime = pScanRequest->minChnTime << 1; |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 722 | smsLog( pMac, LOG1, FL("BTC A2DP up, doubling max and min" |
| 723 | " ChnTime (Max=%d Min=%d)"), |
| 724 | pScanRequest->maxChnTime, |
| 725 | pScanRequest->minChnTime); |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 726 | } |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 727 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 728 | pScanRequest->maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc; |
| 729 | pScanRequest->minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 730 | //Need to make the following atomic |
| 731 | pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around |
| 732 | |
| 733 | if(pScanRequestID) |
| 734 | { |
| 735 | *pScanRequestID = pScanCmd->u.scanCmd.scanID; |
| 736 | } |
| 737 | |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 738 | // 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] | 739 | // If it is not, CSR will save the scan request in the pending cmd queue |
| 740 | // & issue an 11d scan request to PE. |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 741 | if (((0 == pScanCmd->u.scanCmd.scanID) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 742 | && (eCSR_SCAN_REQUEST_11D_SCAN != pScanRequest->requestType)) |
| 743 | #ifdef SOFTAP_CHANNEL_RANGE |
| 744 | && (eCSR_SCAN_SOFTAP_CHANNEL_RANGE != pScanRequest->requestType) |
| 745 | #endif |
| 746 | && (eANI_BOOLEAN_FALSE == pMac->scan.fEnableBypass11d) |
| 747 | ) |
| 748 | { |
| 749 | tSmeCmd *p11dScanCmd; |
| 750 | tCsrScanRequest scanReq; |
| 751 | tCsrChannelInfo *pChnInfo = &scanReq.ChannelInfo; |
| 752 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 753 | vos_mem_set(&scanReq, sizeof(tCsrScanRequest), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 754 | |
| 755 | p11dScanCmd = csrGetCommandBuffer(pMac); |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 756 | if (p11dScanCmd) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 757 | { |
| 758 | tANI_U32 numChn = pMac->scan.baseChannels.numChannels; |
| 759 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 760 | vos_mem_set(&p11dScanCmd->u.scanCmd, sizeof(tScanCmd), 0); |
| 761 | pChnInfo->ChannelList = vos_mem_malloc(numChn); |
| 762 | if ( NULL == pChnInfo->ChannelList ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 763 | { |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 764 | smsLog(pMac, LOGE, FL("Failed to allocate memory")); |
| 765 | status = eHAL_STATUS_FAILURE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 766 | break; |
| 767 | } |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 768 | vos_mem_copy(pChnInfo->ChannelList, |
| 769 | pMac->scan.baseChannels.channelList, |
| 770 | numChn); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 771 | pChnInfo->numOfChannels = (tANI_U8)numChn; |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 772 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 773 | p11dScanCmd->command = eSmeCommandScan; |
Mihir Shete | fc7ff5b | 2014-01-27 11:30:05 +0530 | [diff] [blame] | 774 | p11dScanCmd->u.scanCmd.callback = pMac->scan.callback11dScanDone; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 775 | p11dScanCmd->u.scanCmd.pContext = NULL; |
c_hpothu | 0d5a735 | 2014-03-22 12:30:25 +0530 | [diff] [blame] | 776 | p11dScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 777 | scanReq.BSSType = eCSR_BSS_TYPE_ANY; |
| 778 | |
| 779 | if ( csrIs11dSupported(pMac) ) |
| 780 | { |
c_hpothu | dbefd3e | 2014-04-28 15:59:47 +0530 | [diff] [blame] | 781 | scanReq.scanType = eSIR_PASSIVE_SCAN; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 782 | scanReq.requestType = eCSR_SCAN_REQUEST_11D_SCAN; |
| 783 | p11dScanCmd->u.scanCmd.reason = eCsrScan11d1; |
| 784 | scanReq.maxChnTime = pMac->roam.configParam.nPassiveMaxChnTime; |
| 785 | scanReq.minChnTime = pMac->roam.configParam.nPassiveMinChnTime; |
| 786 | } |
| 787 | else |
| 788 | { |
c_hpothu | dbefd3e | 2014-04-28 15:59:47 +0530 | [diff] [blame] | 789 | scanReq.scanType = pScanRequest->scanType; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 790 | scanReq.requestType = eCSR_SCAN_IDLE_MODE_SCAN; |
| 791 | p11dScanCmd->u.scanCmd.reason = eCsrScanIdleScan; |
| 792 | scanReq.maxChnTime = pMac->roam.configParam.nActiveMaxChnTime; |
| 793 | scanReq.minChnTime = pMac->roam.configParam.nActiveMinChnTime; |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 794 | |
Madan Mohan Koyyalamudi | 04a65f0 | 2013-07-26 13:58:38 +0530 | [diff] [blame] | 795 | scanReq.maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc; |
| 796 | scanReq.minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 797 | } |
c_hpothu | 059edb0 | 2014-03-12 21:44:28 +0530 | [diff] [blame] | 798 | if (pMac->roam.configParam.nInitialDwellTime) |
| 799 | { |
| 800 | scanReq.maxChnTime = |
| 801 | pMac->roam.configParam.nInitialDwellTime; |
| 802 | smsLog(pMac, LOG1, FL("11d scan, updating" |
| 803 | "dwell time for first scan %u"), |
| 804 | scanReq.maxChnTime); |
| 805 | } |
Gupta, Kapil | 01be56b | 2015-12-30 20:36:33 +0530 | [diff] [blame^] | 806 | if (!(pScanRequest->p2pSearch) |
| 807 | &&(pScanRequest->ChannelInfo.numOfChannels |
| 808 | < pMac->roam.configParam. |
| 809 | max_chan_for_dwell_time_cfg)) |
| 810 | { |
| 811 | pScanRequest->maxChnTime = |
| 812 | pScanRequest->maxChnTime << 1; |
| 813 | pScanRequest->minChnTime = |
| 814 | pScanRequest->minChnTime << 1; |
| 815 | smsLog(pMac, LOG1, |
| 816 | FL("Double ChnTime (Max=%d Min=%d) numOfChannels=%d max_chan_for_dwell_time_cfg=%d"), |
| 817 | pScanRequest->maxChnTime, |
| 818 | pScanRequest->minChnTime, |
| 819 | pScanRequest->ChannelInfo.numOfChannels, |
| 820 | pMac->roam.configParam. |
| 821 | max_chan_for_dwell_time_cfg); |
| 822 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 823 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 824 | status = csrScanCopyRequest(pMac, &p11dScanCmd->u.scanCmd.u.scanRequest, &scanReq); |
| 825 | //Free the channel list |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 826 | vos_mem_free(pChnInfo->ChannelList); |
James Zmuda | 9ea1edd | 2013-04-18 18:20:54 -0700 | [diff] [blame] | 827 | pChnInfo->ChannelList = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 828 | |
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 | { |
krunal soni | 5f112f0 | 2013-11-25 15:00:11 -0800 | [diff] [blame] | 831 | pMac->scan.scanProfile.numOfChannels = |
| 832 | p11dScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 833 | //Start process the command |
| 834 | #ifdef WLAN_AP_STA_CONCURRENCY |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 835 | if (!pMac->fScanOffload) |
| 836 | status = csrQueueScanRequest(pMac, p11dScanCmd); |
| 837 | else |
| 838 | status = csrQueueSmeCommand(pMac, p11dScanCmd, |
| 839 | eANI_BOOLEAN_FALSE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 840 | #else |
| 841 | status = csrQueueSmeCommand(pMac, p11dScanCmd, eANI_BOOLEAN_FALSE); |
| 842 | #endif |
| 843 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 844 | { |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 845 | smsLog(pMac, LOGE, FL("Failed to send message" |
| 846 | " status = %d"), status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 847 | break; |
| 848 | } |
| 849 | } |
| 850 | else |
| 851 | { |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 852 | smsLog(pMac, LOGE, FL("csrScanCopyRequest failed")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 853 | break; |
| 854 | } |
| 855 | } |
| 856 | else |
| 857 | { |
| 858 | //error |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 859 | smsLog( pMac, LOGE, FL("p11dScanCmd failed") ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 860 | break; |
| 861 | } |
| 862 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 863 | |
| 864 | //Scan only 2G Channels if set in ini file |
| 865 | //This is mainly to reduce the First Scan duration |
| 866 | //Once we turn on Wifi |
| 867 | if(pMac->scan.fFirstScanOnly2GChnl) |
| 868 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 869 | smsLog( pMac, LOG1, FL("Scanning only 2G Channels during first scan")); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 870 | csrScan2GOnyRequest(pMac, pScanCmd, pScanRequest); |
| 871 | } |
| 872 | |
c_hpothu | 059edb0 | 2014-03-12 21:44:28 +0530 | [diff] [blame] | 873 | if (pMac->roam.configParam.nInitialDwellTime) |
| 874 | { |
| 875 | pScanRequest->maxChnTime = |
| 876 | pMac->roam.configParam.nInitialDwellTime; |
| 877 | pMac->roam.configParam.nInitialDwellTime = 0; |
| 878 | smsLog(pMac, LOG1, |
| 879 | FL("updating dwell time for first scan %u"), |
| 880 | pScanRequest->maxChnTime); |
| 881 | } |
| 882 | |
Gupta, Kapil | 01be56b | 2015-12-30 20:36:33 +0530 | [diff] [blame^] | 883 | if (!(pScanRequest->p2pSearch) |
| 884 | && (pScanRequest->ChannelInfo.numOfChannels |
| 885 | < pMac->roam.configParam.max_chan_for_dwell_time_cfg)) |
| 886 | { |
| 887 | pScanRequest->maxChnTime = pScanRequest->maxChnTime << 1; |
| 888 | pScanRequest->minChnTime = pScanRequest->minChnTime << 1; |
| 889 | smsLog(pMac, LOG1, |
| 890 | FL("Double ChnTime (Max=%d Min=%d) numOfChannels=%d max_chan_for_dwell_time_cfg=%d"), |
| 891 | pScanRequest->maxChnTime, |
| 892 | pScanRequest->minChnTime, |
| 893 | pScanRequest->ChannelInfo.numOfChannels, |
| 894 | pMac->roam.configParam.max_chan_for_dwell_time_cfg); |
| 895 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 896 | status = csrScanCopyRequest(pMac, &pScanCmd->u.scanCmd.u.scanRequest, pScanRequest); |
| 897 | if(HAL_STATUS_SUCCESS(status)) |
| 898 | { |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 899 | tCsrScanRequest *pTempScanReq = |
| 900 | &pScanCmd->u.scanCmd.u.scanRequest; |
krunal soni | 5f112f0 | 2013-11-25 15:00:11 -0800 | [diff] [blame] | 901 | pMac->scan.scanProfile.numOfChannels = |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 902 | pTempScanReq->ChannelInfo.numOfChannels; |
krunal soni | 5f112f0 | 2013-11-25 15:00:11 -0800 | [diff] [blame] | 903 | |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 904 | smsLog( pMac, LOG1, FL(" SId=%d scanId=%d" |
| 905 | " Scan reason=%u numSSIDs=%d" |
| 906 | " numChan=%d P2P search=%d minCT=%d maxCT=%d" |
| 907 | " minCBtc=%d maxCBtx=%d"), |
| 908 | sessionId, pScanCmd->u.scanCmd.scanID, |
| 909 | pScanCmd->u.scanCmd.reason, |
| 910 | pTempScanReq->SSIDs.numOfSSIDs, |
| 911 | pTempScanReq->ChannelInfo.numOfChannels, |
| 912 | pTempScanReq->p2pSearch, |
| 913 | pTempScanReq->minChnTime, |
| 914 | pTempScanReq->maxChnTime, |
| 915 | pTempScanReq->minChnTimeBtc, |
| 916 | pTempScanReq->maxChnTimeBtc ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 917 | //Start process the command |
| 918 | #ifdef WLAN_AP_STA_CONCURRENCY |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 919 | if (!pMac->fScanOffload) |
| 920 | status = csrQueueScanRequest(pMac,pScanCmd); |
| 921 | else |
| 922 | status = csrQueueSmeCommand(pMac, pScanCmd, |
| 923 | eANI_BOOLEAN_FALSE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 924 | #else |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 925 | status = csrQueueSmeCommand(pMac, pScanCmd, |
| 926 | eANI_BOOLEAN_FALSE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 927 | #endif |
| 928 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 929 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 930 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 931 | break; |
| 932 | } |
| 933 | } |
| 934 | else |
| 935 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 936 | smsLog( pMac, LOGE, FL(" fail to copy request status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 937 | break; |
| 938 | } |
| 939 | } |
| 940 | else |
| 941 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 942 | smsLog( pMac, LOGE, FL(" pScanCmd is NULL")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 943 | break; |
| 944 | } |
| 945 | } |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 946 | else |
| 947 | { |
| 948 | smsLog( pMac, LOGE, FL("SId: %d Scanning not enabled" |
| 949 | " Scan type=%u, numOfSSIDs=%d P2P search=%d"), |
| 950 | sessionId, pScanRequest->requestType, |
| 951 | pScanRequest->SSIDs.numOfSSIDs, |
| 952 | pScanRequest->p2pSearch ); |
| 953 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 954 | } while(0); |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 955 | |
| 956 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 957 | if(!HAL_STATUS_SUCCESS(status) && pScanCmd) |
| 958 | { |
| 959 | if( eCsrScanIdleScan == pScanCmd->u.scanCmd.reason ) |
| 960 | { |
| 961 | //Set the flag back for restarting idle scan |
| 962 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 963 | } |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 964 | smsLog( pMac, LOGE, FL(" SId: %d Failed with status=%d" |
| 965 | " Scan reason=%u numOfSSIDs=%d" |
| 966 | " P2P search=%d scanId=%d"), |
| 967 | sessionId, status, pScanCmd->u.scanCmd.reason, |
| 968 | pScanRequest->SSIDs.numOfSSIDs, pScanRequest->p2pSearch, |
| 969 | pScanCmd->u.scanCmd.scanID ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 970 | csrReleaseCommandScan(pMac, pScanCmd); |
| 971 | } |
| 972 | |
| 973 | return (status); |
| 974 | } |
| 975 | |
| 976 | |
| 977 | eHalStatus csrScanRequestResult(tpAniSirGlobal pMac) |
| 978 | { |
| 979 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 980 | tSmeCmd *pScanCmd; |
| 981 | |
| 982 | if(pMac->scan.fScanEnable) |
| 983 | { |
| 984 | pScanCmd = csrGetCommandBuffer(pMac); |
| 985 | if(pScanCmd) |
| 986 | { |
| 987 | pScanCmd->command = eSmeCommandScan; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 988 | vos_mem_set(&pScanCmd->u.scanCmd, sizeof(tScanCmd), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 989 | pScanCmd->u.scanCmd.callback = NULL; |
| 990 | pScanCmd->u.scanCmd.pContext = NULL; |
| 991 | pScanCmd->u.scanCmd.reason = eCsrScanGetResult; |
| 992 | //Need to make the following atomic |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 993 | pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID; //let it wrap around |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 994 | status = csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_FALSE); |
| 995 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 996 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 997 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 998 | csrReleaseCommandScan(pMac, pScanCmd); |
| 999 | } |
| 1000 | } |
| 1001 | else |
| 1002 | { |
| 1003 | //log error |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1004 | smsLog(pMac, LOGE, FL("can not obtain a common buffer")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1005 | status = eHAL_STATUS_RESOURCES; |
| 1006 | } |
| 1007 | } |
| 1008 | |
| 1009 | return (status); |
| 1010 | } |
| 1011 | |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 1012 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 1013 | eHalStatus csrScanRequestLfrResult(tpAniSirGlobal pMac, tANI_U32 sessionId, |
| 1014 | csrScanCompleteCallback callback, void *pContext) |
| 1015 | { |
| 1016 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1017 | tSmeCmd *pScanCmd; |
| 1018 | |
| 1019 | if (pMac->scan.fScanEnable) |
| 1020 | { |
| 1021 | pScanCmd = csrGetCommandBuffer(pMac); |
| 1022 | if (pScanCmd) |
| 1023 | { |
| 1024 | pScanCmd->command = eSmeCommandScan; |
| 1025 | pScanCmd->sessionId = sessionId; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1026 | vos_mem_set(&pScanCmd->u.scanCmd, sizeof(tScanCmd), 0); |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 1027 | pScanCmd->u.scanCmd.callback = callback; |
| 1028 | pScanCmd->u.scanCmd.pContext = pContext; |
| 1029 | pScanCmd->u.scanCmd.reason = eCsrScanGetLfrResult; |
| 1030 | //Need to make the following atomic |
| 1031 | pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID; //let it wrap around |
| 1032 | status = csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_TRUE); |
| 1033 | if ( !HAL_STATUS_SUCCESS( status ) ) |
| 1034 | { |
| 1035 | smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status ); |
| 1036 | csrReleaseCommandScan(pMac, pScanCmd); |
| 1037 | } |
| 1038 | } |
| 1039 | else |
| 1040 | { |
| 1041 | //log error |
| 1042 | smsLog(pMac, LOGE, FL("can not obtain a common buffer\n")); |
| 1043 | status = eHAL_STATUS_RESOURCES; |
| 1044 | } |
| 1045 | } |
| 1046 | |
| 1047 | return (status); |
| 1048 | } |
| 1049 | #endif //WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1050 | |
| 1051 | eHalStatus csrScanAllChannels(tpAniSirGlobal pMac, eCsrRequestType reqType) |
| 1052 | { |
| 1053 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1054 | tANI_U32 scanId; |
| 1055 | tCsrScanRequest scanReq; |
| 1056 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1057 | vos_mem_set(&scanReq, sizeof(tCsrScanRequest), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1058 | scanReq.BSSType = eCSR_BSS_TYPE_ANY; |
| 1059 | scanReq.scanType = eSIR_ACTIVE_SCAN; |
| 1060 | scanReq.requestType = reqType; |
| 1061 | scanReq.maxChnTime = pMac->roam.configParam.nActiveMaxChnTime; |
| 1062 | scanReq.minChnTime = pMac->roam.configParam.nActiveMinChnTime; |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 1063 | scanReq.maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc; |
| 1064 | scanReq.minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1065 | //Scan with invalid sessionId. |
| 1066 | //This results in SME using the first available session to scan. |
| 1067 | status = csrScanRequest(pMac, CSR_SESSION_ID_INVALID, &scanReq, |
| 1068 | &scanId, NULL, NULL); |
| 1069 | |
| 1070 | return (status); |
| 1071 | } |
| 1072 | |
| 1073 | |
| 1074 | |
| 1075 | |
| 1076 | eHalStatus csrIssueRoamAfterLostlinkScan(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamReason reason) |
| 1077 | { |
| 1078 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 1079 | tScanResultHandle hBSSList = NULL; |
| 1080 | tCsrScanResultFilter *pScanFilter = NULL; |
| 1081 | tANI_U32 roamId = 0; |
| 1082 | tCsrRoamProfile *pProfile = NULL; |
| 1083 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 1084 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1085 | if(!pSession) |
| 1086 | { |
| 1087 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 1088 | return eHAL_STATUS_FAILURE; |
| 1089 | } |
| 1090 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1091 | do |
| 1092 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1093 | smsLog(pMac, LOG1, " csrIssueRoamAfterLostlinkScan called"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1094 | if(pSession->fCancelRoaming) |
| 1095 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1096 | smsLog(pMac, LOGW, " lostlink roaming is cancelled"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1097 | csrScanStartIdleScan(pMac); |
| 1098 | status = eHAL_STATUS_SUCCESS; |
| 1099 | break; |
| 1100 | } |
| 1101 | //Here is the profile we need to connect to |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1102 | pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter)); |
| 1103 | if ( NULL == pScanFilter) |
| 1104 | status = eHAL_STATUS_FAILURE; |
| 1105 | else |
| 1106 | status = eHAL_STATUS_SUCCESS; |
| 1107 | if (!HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1108 | break; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1109 | vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1110 | if(NULL == pSession->pCurRoamProfile) |
| 1111 | { |
| 1112 | pScanFilter->EncryptionType.numEntries = 1; |
| 1113 | pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE; |
| 1114 | } |
| 1115 | else |
| 1116 | { |
| 1117 | //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1118 | pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile)); |
| 1119 | if ( NULL == pProfile ) |
| 1120 | status = eHAL_STATUS_FAILURE; |
| 1121 | else |
| 1122 | status = eHAL_STATUS_SUCCESS; |
| 1123 | if (!HAL_STATUS_SUCCESS(status)) |
| 1124 | break; |
| 1125 | vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1126 | status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile); |
| 1127 | if(!HAL_STATUS_SUCCESS(status)) |
| 1128 | break; |
| 1129 | status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter); |
| 1130 | }//We have a profile |
| 1131 | roamId = GET_NEXT_ROAM_ID(&pMac->roam); |
| 1132 | if(HAL_STATUS_SUCCESS(status)) |
| 1133 | { |
| 1134 | status = csrScanGetResult(pMac, pScanFilter, &hBSSList); |
| 1135 | if(HAL_STATUS_SUCCESS(status)) |
| 1136 | { |
| 1137 | if(eCsrLostLink1 == reason) |
| 1138 | { |
| 1139 | //we want to put the last connected BSS to the very beginning, if possible |
| 1140 | csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList); |
| 1141 | } |
| 1142 | status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, reason, |
| 1143 | roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE); |
| 1144 | if(!HAL_STATUS_SUCCESS(status)) |
| 1145 | { |
| 1146 | csrScanResultPurge(pMac, hBSSList); |
| 1147 | } |
| 1148 | }//Have scan result |
| 1149 | } |
| 1150 | }while(0); |
| 1151 | if(pScanFilter) |
| 1152 | { |
| 1153 | //we need to free memory for filter if profile exists |
| 1154 | csrFreeScanFilter(pMac, pScanFilter); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1155 | vos_mem_free(pScanFilter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1156 | } |
| 1157 | if(NULL != pProfile) |
| 1158 | { |
| 1159 | csrReleaseProfile(pMac, pProfile); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1160 | vos_mem_free(pProfile); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1161 | } |
| 1162 | |
| 1163 | return (status); |
| 1164 | } |
| 1165 | |
| 1166 | |
Ratheesh S P | ece1f83 | 2015-07-25 15:50:25 +0530 | [diff] [blame] | 1167 | eHalStatus csrScanGetScanChnInfo(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1168 | { |
| 1169 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1170 | tSmeCmd *pScanCmd; |
| 1171 | |
| 1172 | if(pMac->scan.fScanEnable) |
| 1173 | { |
| 1174 | pScanCmd = csrGetCommandBuffer(pMac); |
| 1175 | if(pScanCmd) |
| 1176 | { |
| 1177 | pScanCmd->command = eSmeCommandScan; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1178 | vos_mem_set(&pScanCmd->u.scanCmd, sizeof(tScanCmd), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1179 | pScanCmd->u.scanCmd.reason = eCsrScanGetScanChnInfo; |
| 1180 | //Need to make the following atomic |
| 1181 | pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around |
Ratheesh S P | ece1f83 | 2015-07-25 15:50:25 +0530 | [diff] [blame] | 1182 | pScanCmd->sessionId = pCommand->sessionId; |
| 1183 | if( pCommand->u.scanCmd.reason == eCsrScanUserRequest) |
| 1184 | { |
| 1185 | pScanCmd->u.scanCmd.callback = NULL; |
| 1186 | pScanCmd->u.scanCmd.pContext = NULL; |
| 1187 | } else { |
| 1188 | pScanCmd->u.scanCmd.callback = pCommand->u.scanCmd.callback; |
| 1189 | pScanCmd->u.scanCmd.pContext = pCommand->u.scanCmd.pContext; |
| 1190 | pScanCmd->u.scanCmd.abortScanIndication = |
| 1191 | pCommand->u.scanCmd.abortScanIndication; |
| 1192 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1193 | status = csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_FALSE); |
| 1194 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 1195 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1196 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1197 | csrReleaseCommandScan(pMac, pScanCmd); |
| 1198 | } |
| 1199 | } |
| 1200 | else |
| 1201 | { |
| 1202 | //log error |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1203 | smsLog(pMac, LOGE, FL("can not obtain a common buffer")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1204 | status = eHAL_STATUS_RESOURCES; |
| 1205 | } |
| 1206 | } |
| 1207 | |
| 1208 | return (status); |
| 1209 | } |
| 1210 | |
| 1211 | |
| 1212 | eHalStatus csrScanHandleFailedLostlink1(tpAniSirGlobal pMac, tANI_U32 sessionId) |
| 1213 | { |
| 1214 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 1215 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 1216 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1217 | if(!pSession) |
| 1218 | { |
| 1219 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 1220 | return eHAL_STATUS_FAILURE; |
| 1221 | } |
| 1222 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1223 | smsLog(pMac, LOGW, " Lostlink scan 1 failed"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1224 | if(pSession->fCancelRoaming) |
| 1225 | { |
| 1226 | csrScanStartIdleScan(pMac); |
| 1227 | } |
| 1228 | else if(pSession->pCurRoamProfile) |
| 1229 | { |
| 1230 | //We fail lostlink1 but there may be other BSS in the cached result fit the profile. Give it a try first |
| 1231 | if(pSession->pCurRoamProfile->SSIDs.numOfSSIDs == 0 || |
| 1232 | pSession->pCurRoamProfile->SSIDs.numOfSSIDs > 1) |
| 1233 | { |
| 1234 | //try lostlink scan2 |
| 1235 | status = csrScanRequestLostLink2(pMac, sessionId); |
| 1236 | } |
| 1237 | else if(!pSession->pCurRoamProfile->ChannelInfo.ChannelList || |
| 1238 | pSession->pCurRoamProfile->ChannelInfo.ChannelList[0] == 0) |
| 1239 | { |
| 1240 | //go straight to lostlink scan3 |
| 1241 | status = csrScanRequestLostLink3(pMac, sessionId); |
| 1242 | } |
| 1243 | else |
| 1244 | { |
| 1245 | //we are done with lostlink |
| 1246 | if(csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_FALSE, eCSR_ROAM_RESULT_FAILURE)) |
| 1247 | { |
| 1248 | csrScanStartIdleScan(pMac); |
| 1249 | } |
| 1250 | status = eHAL_STATUS_SUCCESS; |
| 1251 | } |
| 1252 | } |
| 1253 | else |
| 1254 | { |
| 1255 | status = csrScanRequestLostLink3(pMac, sessionId); |
| 1256 | } |
| 1257 | |
| 1258 | return (status); |
| 1259 | } |
| 1260 | |
| 1261 | |
| 1262 | |
| 1263 | eHalStatus csrScanHandleFailedLostlink2(tpAniSirGlobal pMac, tANI_U32 sessionId) |
| 1264 | { |
| 1265 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 1266 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 1267 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1268 | if(!pSession) |
| 1269 | { |
| 1270 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 1271 | return eHAL_STATUS_FAILURE; |
| 1272 | } |
| 1273 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1274 | smsLog(pMac, LOGW, " Lostlink scan 2 failed"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1275 | if(pSession->fCancelRoaming) |
| 1276 | { |
| 1277 | csrScanStartIdleScan(pMac); |
| 1278 | } |
| 1279 | else if(!pSession->pCurRoamProfile || !pSession->pCurRoamProfile->ChannelInfo.ChannelList || |
| 1280 | pSession->pCurRoamProfile->ChannelInfo.ChannelList[0] == 0) |
| 1281 | { |
| 1282 | //try lostlink scan3 |
| 1283 | status = csrScanRequestLostLink3(pMac, sessionId); |
| 1284 | } |
| 1285 | else |
| 1286 | { |
| 1287 | //we are done with lostlink |
| 1288 | if(csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_FALSE, eCSR_ROAM_RESULT_FAILURE)) |
| 1289 | { |
| 1290 | csrScanStartIdleScan(pMac); |
| 1291 | } |
| 1292 | } |
| 1293 | |
| 1294 | return (status); |
| 1295 | } |
| 1296 | |
| 1297 | |
| 1298 | |
| 1299 | eHalStatus csrScanHandleFailedLostlink3(tpAniSirGlobal pMac, tANI_U32 sessionId) |
| 1300 | { |
| 1301 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1302 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1303 | smsLog(pMac, LOGW, " Lostlink scan 3 failed"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1304 | if(eANI_BOOLEAN_TRUE == csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_FALSE, eCSR_ROAM_RESULT_FAILURE)) |
| 1305 | { |
| 1306 | //we are done with lostlink |
| 1307 | csrScanStartIdleScan(pMac); |
| 1308 | } |
| 1309 | |
| 1310 | return (status); |
| 1311 | } |
| 1312 | |
| 1313 | |
| 1314 | |
| 1315 | |
| 1316 | //Lostlink1 scan is to actively scan the last connected profile's SSID on all matched BSS channels. |
| 1317 | //If no roam profile (it should not), it is like lostlinkscan3 |
| 1318 | eHalStatus csrScanRequestLostLink1( tpAniSirGlobal pMac, tANI_U32 sessionId ) |
| 1319 | { |
| 1320 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1321 | tSmeCmd *pCommand = NULL; |
| 1322 | tANI_U8 bAddr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; |
| 1323 | tCsrScanResultFilter *pScanFilter = NULL; |
| 1324 | tScanResultHandle hBSSList = NULL; |
| 1325 | tCsrScanResultInfo *pScanResult = NULL; |
| 1326 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 1327 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1328 | if(!pSession) |
| 1329 | { |
| 1330 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 1331 | return eHAL_STATUS_FAILURE; |
| 1332 | } |
| 1333 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1334 | smsLog(pMac, LOGW, FL(" called")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1335 | do |
| 1336 | { |
| 1337 | pCommand = csrGetCommandBuffer(pMac); |
| 1338 | if(!pCommand) |
| 1339 | { |
| 1340 | status = eHAL_STATUS_RESOURCES; |
| 1341 | break; |
| 1342 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1343 | vos_mem_set(&pCommand->u.scanCmd, sizeof(tScanCmd), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1344 | pCommand->command = eSmeCommandScan; |
| 1345 | pCommand->sessionId = (tANI_U8)sessionId; |
| 1346 | pCommand->u.scanCmd.reason = eCsrScanLostLink1; |
| 1347 | pCommand->u.scanCmd.callback = NULL; |
| 1348 | pCommand->u.scanCmd.pContext = NULL; |
| 1349 | pCommand->u.scanCmd.u.scanRequest.maxChnTime = pMac->roam.configParam.nActiveMaxChnTime; |
| 1350 | pCommand->u.scanCmd.u.scanRequest.minChnTime = pMac->roam.configParam.nActiveMinChnTime; |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 1351 | pCommand->u.scanCmd.u.scanRequest.maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc; |
| 1352 | pCommand->u.scanCmd.u.scanRequest.minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1353 | pCommand->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 1354 | if(pSession->connectedProfile.SSID.length) |
| 1355 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1356 | pCommand->u.scanCmd.u.scanRequest.SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo)); |
| 1357 | if ( NULL == pCommand->u.scanCmd.u.scanRequest.SSIDs.SSIDList ) |
| 1358 | status = eHAL_STATUS_FAILURE; |
| 1359 | else |
| 1360 | status = eHAL_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1361 | if(!HAL_STATUS_SUCCESS(status)) |
| 1362 | { |
| 1363 | break; |
| 1364 | } |
| 1365 | pCommand->u.scanCmd.u.scanRequest.SSIDs.numOfSSIDs = 1; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1366 | vos_mem_copy(&pCommand->u.scanCmd.u.scanRequest.SSIDs.SSIDList[0].SSID, |
| 1367 | &pSession->connectedProfile.SSID, sizeof(tSirMacSSid)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1368 | } |
| 1369 | else |
| 1370 | { |
| 1371 | pCommand->u.scanCmd.u.scanRequest.SSIDs.numOfSSIDs = 0; |
| 1372 | } |
| 1373 | if(pSession->pCurRoamProfile) |
| 1374 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1375 | pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter)); |
| 1376 | if ( NULL == pScanFilter ) |
| 1377 | status = eHAL_STATUS_FAILURE; |
| 1378 | else |
| 1379 | status = eHAL_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1380 | if(!HAL_STATUS_SUCCESS(status)) |
| 1381 | { |
| 1382 | break; |
| 1383 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1384 | vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1385 | status = csrRoamPrepareFilterFromProfile(pMac, pSession->pCurRoamProfile, pScanFilter); |
| 1386 | if(!HAL_STATUS_SUCCESS(status)) |
| 1387 | { |
| 1388 | break; |
| 1389 | } |
| 1390 | //Don't change variable status here because whether we can get result or not, the command goes to PE. |
| 1391 | //The status is also used to indicate whether the command is queued. Not success meaning not queue |
| 1392 | if(HAL_STATUS_SUCCESS((csrScanGetResult(pMac, pScanFilter, &hBSSList))) && hBSSList) |
| 1393 | { |
| 1394 | tANI_U8 i, nChn = 0; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1395 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = |
| 1396 | vos_mem_malloc(WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 1397 | if ( NULL == pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList ) |
| 1398 | status = eHAL_STATUS_FAILURE; |
| 1399 | else |
| 1400 | status = eHAL_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1401 | if(!HAL_STATUS_SUCCESS(status)) |
| 1402 | { |
| 1403 | break; |
| 1404 | } |
| 1405 | while(((pScanResult = csrScanResultGetNext(pMac, hBSSList)) != NULL) && |
| 1406 | nChn < WNI_CFG_VALID_CHANNEL_LIST_LEN) |
| 1407 | { |
| 1408 | for(i = 0; i < nChn; i++) |
| 1409 | { |
| 1410 | if(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[i] == |
| 1411 | pScanResult->BssDescriptor.channelId) |
| 1412 | { |
| 1413 | break; |
| 1414 | } |
| 1415 | } |
| 1416 | if(i == nChn) |
| 1417 | { |
| 1418 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[nChn++] = pScanResult->BssDescriptor.channelId; |
| 1419 | } |
| 1420 | } |
| 1421 | //Include the last connected BSS' channel |
| 1422 | if(csrRoamIsChannelValid(pMac, pSession->connectedProfile.operationChannel)) |
| 1423 | { |
| 1424 | for(i = 0; i < nChn; i++) |
| 1425 | { |
| 1426 | if(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[i] == |
| 1427 | pSession->connectedProfile.operationChannel) |
| 1428 | { |
| 1429 | break; |
| 1430 | } |
| 1431 | } |
| 1432 | if(i == nChn) |
| 1433 | { |
| 1434 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[nChn++] = pSession->connectedProfile.operationChannel; |
| 1435 | } |
| 1436 | } |
| 1437 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = nChn; |
| 1438 | } |
| 1439 | else |
| 1440 | { |
| 1441 | if(csrRoamIsChannelValid(pMac, pSession->connectedProfile.operationChannel)) |
| 1442 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1443 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = vos_mem_malloc(1); |
| 1444 | if ( NULL == pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList ) |
| 1445 | status = eHAL_STATUS_FAILURE; |
| 1446 | else |
| 1447 | status = eHAL_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1448 | //just try the last connected channel |
| 1449 | if(HAL_STATUS_SUCCESS(status)) |
| 1450 | { |
| 1451 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[0] = pSession->connectedProfile.operationChannel; |
| 1452 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = 1; |
| 1453 | } |
| 1454 | else |
| 1455 | { |
| 1456 | break; |
| 1457 | } |
| 1458 | } |
| 1459 | } |
| 1460 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1461 | vos_mem_copy(&pCommand->u.scanCmd.u.scanRequest.bssid, bAddr, sizeof(tCsrBssid)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1462 | status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE); |
| 1463 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 1464 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1465 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1466 | break; |
| 1467 | } |
| 1468 | } while( 0 ); |
| 1469 | |
| 1470 | if(!HAL_STATUS_SUCCESS(status)) |
| 1471 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1472 | smsLog(pMac, LOGW, " csrScanRequestLostLink1 failed with status %d", status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1473 | if(pCommand) |
| 1474 | { |
| 1475 | csrReleaseCommandScan(pMac, pCommand); |
| 1476 | } |
| 1477 | status = csrScanHandleFailedLostlink1( pMac, sessionId ); |
| 1478 | } |
| 1479 | if(pScanFilter) |
| 1480 | { |
| 1481 | csrFreeScanFilter(pMac, pScanFilter); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1482 | vos_mem_free(pScanFilter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1483 | } |
| 1484 | if(hBSSList) |
| 1485 | { |
| 1486 | csrScanResultPurge(pMac, hBSSList); |
| 1487 | } |
| 1488 | |
| 1489 | return( status ); |
| 1490 | } |
| 1491 | |
| 1492 | |
| 1493 | //Lostlink2 scan is to actively scan the all SSIDs of the last roaming profile's on all matched BSS channels. |
| 1494 | //Since MAC doesn't support multiple SSID, we scan all SSIDs and filter them afterwards |
| 1495 | eHalStatus csrScanRequestLostLink2( tpAniSirGlobal pMac, tANI_U32 sessionId ) |
| 1496 | { |
| 1497 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1498 | tANI_U8 bAddr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; |
| 1499 | tCsrScanResultFilter *pScanFilter = NULL; |
| 1500 | tScanResultHandle hBSSList = NULL; |
| 1501 | tCsrScanResultInfo *pScanResult = NULL; |
| 1502 | tSmeCmd *pCommand = NULL; |
| 1503 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 1504 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1505 | if(!pSession) |
| 1506 | { |
| 1507 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 1508 | return eHAL_STATUS_FAILURE; |
| 1509 | } |
| 1510 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1511 | smsLog(pMac, LOGW, FL(" called")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1512 | do |
| 1513 | { |
| 1514 | pCommand = csrGetCommandBuffer(pMac); |
| 1515 | if(!pCommand) |
| 1516 | { |
| 1517 | status = eHAL_STATUS_RESOURCES; |
| 1518 | break; |
| 1519 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1520 | vos_mem_set(&pCommand->u.scanCmd, sizeof(tScanCmd), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1521 | pCommand->command = eSmeCommandScan; |
| 1522 | pCommand->sessionId = (tANI_U8)sessionId; |
| 1523 | pCommand->u.scanCmd.reason = eCsrScanLostLink2; |
| 1524 | pCommand->u.scanCmd.callback = NULL; |
| 1525 | pCommand->u.scanCmd.pContext = NULL; |
| 1526 | pCommand->u.scanCmd.u.scanRequest.maxChnTime = pMac->roam.configParam.nActiveMaxChnTime; |
| 1527 | pCommand->u.scanCmd.u.scanRequest.minChnTime = pMac->roam.configParam.nActiveMinChnTime; |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 1528 | pCommand->u.scanCmd.u.scanRequest.maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc; |
| 1529 | pCommand->u.scanCmd.u.scanRequest.minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1530 | pCommand->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 1531 | if(pSession->pCurRoamProfile) |
| 1532 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1533 | pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter)); |
| 1534 | if ( NULL == pScanFilter ) |
| 1535 | status = eHAL_STATUS_FAILURE; |
| 1536 | else |
| 1537 | status = eHAL_STATUS_SUCCESS; |
| 1538 | if (!HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1539 | { |
| 1540 | break; |
| 1541 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1542 | vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1543 | status = csrRoamPrepareFilterFromProfile(pMac, pSession->pCurRoamProfile, pScanFilter); |
| 1544 | if(!HAL_STATUS_SUCCESS(status)) |
| 1545 | { |
| 1546 | break; |
| 1547 | } |
| 1548 | status = csrScanGetResult(pMac, pScanFilter, &hBSSList); |
| 1549 | if(!HAL_STATUS_SUCCESS(status)) |
| 1550 | { |
| 1551 | break; |
| 1552 | } |
| 1553 | if(hBSSList) |
| 1554 | { |
| 1555 | tANI_U8 i, nChn = 0; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1556 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = |
| 1557 | vos_mem_malloc(WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 1558 | if ( NULL == pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList ) |
| 1559 | status = eHAL_STATUS_FAILURE; |
| 1560 | else |
| 1561 | status = eHAL_STATUS_SUCCESS; |
| 1562 | if (!HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1563 | { |
| 1564 | break; |
| 1565 | } |
| 1566 | while(((pScanResult = csrScanResultGetNext(pMac, hBSSList)) != NULL) && |
| 1567 | nChn < WNI_CFG_VALID_CHANNEL_LIST_LEN) |
| 1568 | { |
| 1569 | for(i = 0; i < nChn; i++) |
| 1570 | { |
| 1571 | if(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[i] == |
| 1572 | pScanResult->BssDescriptor.channelId) |
| 1573 | { |
| 1574 | break; |
| 1575 | } |
| 1576 | } |
| 1577 | if(i == nChn) |
| 1578 | { |
| 1579 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[nChn++] = pScanResult->BssDescriptor.channelId; |
| 1580 | } |
| 1581 | } |
| 1582 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = nChn; |
| 1583 | } |
| 1584 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1585 | vos_mem_copy(&pCommand->u.scanCmd.u.scanRequest.bssid, bAddr, sizeof(tCsrBssid)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1586 | //Put to the head in pending queue |
| 1587 | status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE); |
| 1588 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 1589 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1590 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1591 | break; |
| 1592 | } |
| 1593 | } while( 0 ); |
| 1594 | |
| 1595 | if(!HAL_STATUS_SUCCESS(status)) |
| 1596 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1597 | smsLog(pMac, LOGW, " csrScanRequestLostLink2 failed with status %d", status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1598 | if(pCommand) |
| 1599 | { |
| 1600 | csrReleaseCommandScan(pMac, pCommand); |
| 1601 | } |
| 1602 | status = csrScanHandleFailedLostlink2( pMac, sessionId ); |
| 1603 | } |
| 1604 | if(pScanFilter) |
| 1605 | { |
| 1606 | csrFreeScanFilter(pMac, pScanFilter); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1607 | vos_mem_free(pScanFilter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1608 | } |
| 1609 | if(hBSSList) |
| 1610 | { |
| 1611 | csrScanResultPurge(pMac, hBSSList); |
| 1612 | } |
| 1613 | |
| 1614 | return( status ); |
| 1615 | } |
| 1616 | |
| 1617 | |
| 1618 | //To actively scan all valid channels |
| 1619 | eHalStatus csrScanRequestLostLink3( tpAniSirGlobal pMac, tANI_U32 sessionId ) |
| 1620 | { |
| 1621 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1622 | tSmeCmd *pCommand; |
| 1623 | tANI_U8 bAddr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; |
| 1624 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1625 | smsLog(pMac, LOGW, FL(" called")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1626 | do |
| 1627 | { |
| 1628 | pCommand = csrGetCommandBuffer(pMac); |
| 1629 | if(!pCommand) |
| 1630 | { |
| 1631 | status = eHAL_STATUS_RESOURCES; |
| 1632 | break; |
| 1633 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1634 | vos_mem_set(&pCommand->u.scanCmd, sizeof(tScanCmd), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1635 | pCommand->command = eSmeCommandScan; |
| 1636 | pCommand->sessionId = (tANI_U8)sessionId; |
| 1637 | pCommand->u.scanCmd.reason = eCsrScanLostLink3; |
| 1638 | pCommand->u.scanCmd.callback = NULL; |
| 1639 | pCommand->u.scanCmd.pContext = NULL; |
| 1640 | pCommand->u.scanCmd.u.scanRequest.maxChnTime = pMac->roam.configParam.nActiveMaxChnTime; |
| 1641 | pCommand->u.scanCmd.u.scanRequest.minChnTime = pMac->roam.configParam.nActiveMinChnTime; |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 1642 | pCommand->u.scanCmd.u.scanRequest.maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc; |
| 1643 | pCommand->u.scanCmd.u.scanRequest.minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1644 | pCommand->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1645 | vos_mem_copy(&pCommand->u.scanCmd.u.scanRequest.bssid, bAddr, sizeof(tCsrBssid)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1646 | //Put to the head of pending queue |
| 1647 | status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE); |
| 1648 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 1649 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1650 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1651 | break; |
| 1652 | } |
| 1653 | } while( 0 ); |
| 1654 | if(!HAL_STATUS_SUCCESS(status)) |
| 1655 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1656 | smsLog(pMac, LOGW, " csrScanRequestLostLink3 failed with status %d", status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1657 | if(csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_FALSE, eCSR_ROAM_RESULT_FAILURE)) |
| 1658 | { |
| 1659 | csrScanStartIdleScan(pMac); |
| 1660 | } |
| 1661 | if(pCommand) |
| 1662 | { |
| 1663 | csrReleaseCommandScan(pMac, pCommand); |
| 1664 | } |
| 1665 | } |
| 1666 | |
| 1667 | return( status ); |
| 1668 | } |
| 1669 | |
| 1670 | |
| 1671 | eHalStatus csrScanHandleSearchForSSID(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
| 1672 | { |
| 1673 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 1674 | tScanResultHandle hBSSList = CSR_INVALID_SCANRESULT_HANDLE; |
| 1675 | tCsrScanResultFilter *pScanFilter = NULL; |
| 1676 | tCsrRoamProfile *pProfile = pCommand->u.scanCmd.pToRoamProfile; |
| 1677 | tANI_U32 sessionId = pCommand->sessionId; |
Abhishek Singh | 7f775f8 | 2015-12-17 15:23:52 +0530 | [diff] [blame] | 1678 | tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId); |
| 1679 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1680 | do |
| 1681 | { |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 1682 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 1683 | //if this scan is for LFR |
| 1684 | if(pMac->roam.neighborRoamInfo.uOsRequestedHandoff) |
| 1685 | { |
| 1686 | //notify LFR state m/c |
| 1687 | if(eHAL_STATUS_SUCCESS != csrNeighborRoamSssidScanDone(pMac, eHAL_STATUS_SUCCESS)) |
| 1688 | { |
Mukul Sharma | 20aa658 | 2014-08-07 21:36:12 +0530 | [diff] [blame] | 1689 | csrNeighborRoamStartLfrScan(pMac, REASON_OS_REQUESTED_ROAMING_NOW); |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 1690 | } |
| 1691 | status = eHAL_STATUS_SUCCESS; |
| 1692 | break; |
| 1693 | } |
| 1694 | #endif |
Abhishek Singh | 7f775f8 | 2015-12-17 15:23:52 +0530 | [diff] [blame] | 1695 | if (!pSession) |
| 1696 | { |
| 1697 | smsLog(pMac, LOGE, FL("session %d not found"), sessionId); |
| 1698 | break; |
| 1699 | } |
| 1700 | /* If Disconnect is already issued from HDD no need to issue connect */ |
| 1701 | if (pSession->abortConnection) |
| 1702 | { |
| 1703 | smsLog(pMac, LOGE, |
| 1704 | FL("Disconnect in progress, no need to issue connect")); |
| 1705 | break; |
| 1706 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1707 | //If there is roam command waiting, ignore this roam because the newer roam command is the one to execute |
| 1708 | if(csrIsRoamCommandWaitingForSession(pMac, sessionId)) |
| 1709 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1710 | smsLog(pMac, LOGW, FL(" aborts because roam command waiting")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1711 | break; |
| 1712 | } |
| 1713 | if(pProfile == NULL) |
| 1714 | break; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1715 | pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter)); |
| 1716 | if ( NULL == pScanFilter ) |
| 1717 | status = eHAL_STATUS_FAILURE; |
| 1718 | else |
| 1719 | status = eHAL_STATUS_SUCCESS; |
| 1720 | if (!HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1721 | break; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1722 | vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1723 | status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter); |
| 1724 | if(!HAL_STATUS_SUCCESS(status)) |
| 1725 | break; |
| 1726 | status = csrScanGetResult(pMac, pScanFilter, &hBSSList); |
| 1727 | if(!HAL_STATUS_SUCCESS(status)) |
| 1728 | break; |
| 1729 | status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued, |
| 1730 | pCommand->u.scanCmd.roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE); |
| 1731 | if(!HAL_STATUS_SUCCESS(status)) |
| 1732 | { |
| 1733 | break; |
| 1734 | } |
| 1735 | }while(0); |
| 1736 | if(!HAL_STATUS_SUCCESS(status)) |
| 1737 | { |
| 1738 | if(CSR_INVALID_SCANRESULT_HANDLE != hBSSList) |
| 1739 | { |
| 1740 | csrScanResultPurge(pMac, hBSSList); |
| 1741 | } |
| 1742 | //We haven't done anything to this profile |
| 1743 | csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.scanCmd.roamId, |
| 1744 | eCSR_ROAM_ASSOCIATION_FAILURE, eCSR_ROAM_RESULT_FAILURE); |
| 1745 | //In case we have nothing else to do, restart idle scan |
| 1746 | if(csrIsConnStateDisconnected(pMac, sessionId) && !csrIsRoamCommandWaiting(pMac)) |
| 1747 | { |
| 1748 | status = csrScanStartIdleScan(pMac); |
| 1749 | } |
| 1750 | #ifdef FEATURE_WLAN_BTAMP_UT_RF |
| 1751 | //In case of WDS station, let it retry. |
| 1752 | if( CSR_IS_WDS_STA(pProfile) ) |
| 1753 | { |
| 1754 | //Save the roma profile so we can retry |
| 1755 | csrFreeRoamProfile( pMac, sessionId ); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1756 | pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile)); |
| 1757 | if ( NULL != pSession->pCurRoamProfile ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1758 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1759 | vos_mem_set(pSession->pCurRoamProfilee, sizeof(tCsrRoamProfile), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1760 | csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile); |
| 1761 | } |
| 1762 | csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD); |
| 1763 | } |
| 1764 | #endif |
| 1765 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1766 | if (pScanFilter) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1767 | { |
| 1768 | csrFreeScanFilter(pMac, pScanFilter); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1769 | vos_mem_free(pScanFilter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1770 | } |
| 1771 | |
| 1772 | return (status); |
| 1773 | } |
| 1774 | |
| 1775 | |
| 1776 | eHalStatus csrScanHandleSearchForSSIDFailure(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
| 1777 | { |
| 1778 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 1779 | tANI_U32 sessionId = pCommand->sessionId; |
| 1780 | tCsrRoamProfile *pProfile = pCommand->u.scanCmd.pToRoamProfile; |
| 1781 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 1782 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 1783 | //if this scan is for LFR |
| 1784 | if(pMac->roam.neighborRoamInfo.uOsRequestedHandoff) |
| 1785 | { |
| 1786 | //notify LFR state m/c |
| 1787 | if(eHAL_STATUS_SUCCESS != csrNeighborRoamSssidScanDone(pMac, eHAL_STATUS_FAILURE)) |
| 1788 | { |
Mukul Sharma | 20aa658 | 2014-08-07 21:36:12 +0530 | [diff] [blame] | 1789 | csrNeighborRoamStartLfrScan(pMac, REASON_OS_REQUESTED_ROAMING_NOW); |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 1790 | } |
| 1791 | return eHAL_STATUS_SUCCESS; |
| 1792 | } |
| 1793 | #endif |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1794 | if(!pSession) |
| 1795 | { |
| 1796 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 1797 | return eHAL_STATUS_FAILURE; |
| 1798 | } |
| 1799 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1800 | #if defined(WLAN_DEBUG) |
| 1801 | if(pCommand->u.scanCmd.u.scanRequest.SSIDs.numOfSSIDs == 1) |
| 1802 | { |
| 1803 | char str[36]; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1804 | vos_mem_copy(str, |
| 1805 | pCommand->u.scanCmd.u.scanRequest.SSIDs.SSIDList[0].SSID.ssId, |
| 1806 | pCommand->u.scanCmd.u.scanRequest.SSIDs.SSIDList[0].SSID.length); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1807 | 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] | 1808 | smsLog(pMac, LOGW, FL(" SSID = %s"), str); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1809 | } |
| 1810 | #endif |
| 1811 | //Check whether it is for start ibss. No need to do anything if it is a JOIN request |
| 1812 | if(pProfile && CSR_IS_START_IBSS(pProfile)) |
| 1813 | { |
| 1814 | status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued, |
| 1815 | pCommand->u.scanCmd.roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE); |
| 1816 | if(!HAL_STATUS_SUCCESS(status)) |
| 1817 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 1818 | 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] | 1819 | csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.scanCmd.roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE); |
| 1820 | } |
| 1821 | } |
| 1822 | else |
| 1823 | { |
| 1824 | eCsrRoamResult roamResult = eCSR_ROAM_RESULT_FAILURE; |
| 1825 | |
| 1826 | if(csrIsConnStateDisconnected(pMac, sessionId) && |
| 1827 | !csrIsRoamCommandWaitingForSession(pMac, sessionId)) |
| 1828 | { |
| 1829 | status = csrScanStartIdleScan(pMac); |
| 1830 | } |
| 1831 | if((NULL == pProfile) || !csrIsBssTypeIBSS(pProfile->BSSType)) |
| 1832 | { |
| 1833 | //Only indicate assoc_completion if we indicate assoc_start. |
| 1834 | if(pSession->bRefAssocStartCnt > 0) |
| 1835 | { |
| 1836 | tCsrRoamInfo *pRoamInfo = NULL, roamInfo; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1837 | vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1838 | pRoamInfo = &roamInfo; |
| 1839 | if(pCommand->u.roamCmd.pRoamBssEntry) |
| 1840 | { |
| 1841 | tCsrScanResult *pScanResult = |
| 1842 | GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, |
| 1843 | tCsrScanResult, Link); |
| 1844 | roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor; |
| 1845 | } |
| 1846 | roamInfo.statusCode = pSession->joinFailStatusCode.statusCode; |
| 1847 | roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode; |
| 1848 | pSession->bRefAssocStartCnt--; |
| 1849 | csrRoamCallCallback(pMac, sessionId, pRoamInfo, |
| 1850 | pCommand->u.scanCmd.roamId, |
| 1851 | eCSR_ROAM_ASSOCIATION_COMPLETION, |
| 1852 | eCSR_ROAM_RESULT_FAILURE); |
| 1853 | } |
Madan Mohan Koyyalamudi | ee255f1 | 2012-09-28 15:41:19 -0700 | [diff] [blame] | 1854 | else |
| 1855 | { |
| 1856 | csrRoamCallCallback(pMac, sessionId, NULL, |
| 1857 | pCommand->u.scanCmd.roamId, |
| 1858 | eCSR_ROAM_ASSOCIATION_FAILURE, |
| 1859 | eCSR_ROAM_RESULT_FAILURE); |
| 1860 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1861 | #ifdef FEATURE_WLAN_BTAMP_UT_RF |
| 1862 | //In case of WDS station, let it retry. |
| 1863 | if( CSR_IS_WDS_STA(pProfile) ) |
| 1864 | { |
| 1865 | //Save the roma profile so we can retry |
| 1866 | csrFreeRoamProfile( pMac, sessionId ); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1867 | pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile)); |
| 1868 | if ( NULL != pSession->pCurRoamProfile ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1869 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1870 | vos_mem_set(pSession->pCurRoamProfile, sizeof(tCsrRoamProfile), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1871 | csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile); |
| 1872 | } |
| 1873 | csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD); |
| 1874 | } |
| 1875 | #endif |
| 1876 | } |
| 1877 | else |
| 1878 | { |
| 1879 | roamResult = eCSR_ROAM_RESULT_IBSS_START_FAILED; |
| 1880 | } |
| 1881 | csrRoamCompletion(pMac, sessionId, NULL, pCommand, roamResult, eANI_BOOLEAN_FALSE); |
| 1882 | } |
| 1883 | |
| 1884 | return (status); |
| 1885 | } |
| 1886 | |
| 1887 | |
| 1888 | //After scan for cap changes, issue a roaming command to either reconnect to the AP or pick another one to connect |
| 1889 | eHalStatus csrScanHandleCapChangeScanComplete(tpAniSirGlobal pMac, tANI_U32 sessionId) |
| 1890 | { |
| 1891 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 1892 | tScanResultHandle hBSSList = NULL; |
| 1893 | tCsrScanResultFilter *pScanFilter = NULL; |
| 1894 | tANI_U32 roamId = 0; |
| 1895 | tCsrRoamProfile *pProfile = NULL; |
| 1896 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 1897 | |
| 1898 | do |
| 1899 | { |
| 1900 | //Here is the profile we need to connect to |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1901 | pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter)); |
| 1902 | if ( NULL == pScanFilter ) |
| 1903 | status = eHAL_STATUS_FAILURE; |
| 1904 | else |
| 1905 | status = eHAL_STATUS_SUCCESS; |
| 1906 | if (!HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1907 | break; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1908 | vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0); |
| 1909 | if (NULL == pSession) break; |
| 1910 | if (NULL == pSession->pCurRoamProfile) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1911 | { |
| 1912 | pScanFilter->EncryptionType.numEntries = 1; |
| 1913 | pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE; |
| 1914 | } |
| 1915 | else |
| 1916 | { |
| 1917 | //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1918 | pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile)); |
| 1919 | if ( NULL == pProfile ) |
| 1920 | status = eHAL_STATUS_FAILURE; |
| 1921 | else |
| 1922 | status = eHAL_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1923 | if(!HAL_STATUS_SUCCESS(status)) |
| 1924 | break; |
| 1925 | status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile); |
| 1926 | if(!HAL_STATUS_SUCCESS(status)) |
| 1927 | break; |
| 1928 | status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter); |
| 1929 | }//We have a profile |
| 1930 | roamId = GET_NEXT_ROAM_ID(&pMac->roam); |
| 1931 | if(HAL_STATUS_SUCCESS(status)) |
| 1932 | { |
| 1933 | status = csrScanGetResult(pMac, pScanFilter, &hBSSList); |
| 1934 | if(HAL_STATUS_SUCCESS(status)) |
| 1935 | { |
| 1936 | //we want to put the last connected BSS to the very beginning, if possible |
| 1937 | csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList); |
| 1938 | status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, |
| 1939 | eCsrCapsChange, 0, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE); |
| 1940 | if(!HAL_STATUS_SUCCESS(status)) |
| 1941 | { |
| 1942 | csrScanResultPurge(pMac, hBSSList); |
| 1943 | } |
| 1944 | }//Have scan result |
| 1945 | else |
| 1946 | { |
Arif Hussain | a7c8e41 | 2013-11-20 11:06:42 -0800 | [diff] [blame] | 1947 | smsLog(pMac, LOGW, FL("cannot find matching BSS of " |
| 1948 | MAC_ADDRESS_STR), |
| 1949 | MAC_ADDR_ARRAY(pSession->connectedProfile.bssid)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1950 | //Disconnect |
| 1951 | csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED); |
| 1952 | } |
| 1953 | } |
| 1954 | }while(0); |
| 1955 | if(pScanFilter) |
| 1956 | { |
| 1957 | csrFreeScanFilter(pMac, pScanFilter); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1958 | vos_mem_free(pScanFilter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1959 | } |
| 1960 | if(NULL != pProfile) |
| 1961 | { |
| 1962 | csrReleaseProfile(pMac, pProfile); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1963 | vos_mem_free(pProfile); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1964 | } |
| 1965 | |
| 1966 | return (status); |
| 1967 | } |
| 1968 | |
| 1969 | |
| 1970 | |
| 1971 | eHalStatus csrScanResultPurge(tpAniSirGlobal pMac, tScanResultHandle hScanList) |
| 1972 | { |
| 1973 | eHalStatus status = eHAL_STATUS_INVALID_PARAMETER; |
| 1974 | tScanResultList *pScanList = (tScanResultList *)hScanList; |
| 1975 | |
| 1976 | if(pScanList) |
| 1977 | { |
| 1978 | status = csrLLScanPurgeResult(pMac, &pScanList->List); |
| 1979 | csrLLClose(&pScanList->List); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 1980 | vos_mem_free(pScanList); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1981 | } |
| 1982 | return (status); |
| 1983 | } |
| 1984 | |
| 1985 | |
| 1986 | static tANI_U32 csrGetBssPreferValue(tpAniSirGlobal pMac, int rssi) |
| 1987 | { |
| 1988 | tANI_U32 ret = 0; |
| 1989 | int i = CSR_NUM_RSSI_CAT - 1; |
| 1990 | |
| 1991 | while(i >= 0) |
| 1992 | { |
| 1993 | if(rssi >= pMac->roam.configParam.RSSICat[i]) |
| 1994 | { |
| 1995 | ret = pMac->roam.configParam.BssPreferValue[i]; |
| 1996 | break; |
| 1997 | } |
| 1998 | i--; |
| 1999 | }; |
| 2000 | |
| 2001 | return (ret); |
| 2002 | } |
| 2003 | |
| 2004 | |
| 2005 | //Return a CapValue base on the capabilities of a BSS |
| 2006 | static tANI_U32 csrGetBssCapValue(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes) |
| 2007 | { |
| 2008 | tANI_U32 ret = CSR_BSS_CAP_VALUE_NONE; |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2009 | #if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR) |
Madan Mohan Koyyalamudi | d502607 | 2012-11-30 14:56:21 -0800 | [diff] [blame] | 2010 | if(CSR_IS_ROAM_PREFER_5GHZ(pMac)) |
| 2011 | { |
| 2012 | if((pBssDesc) && CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId)) |
| 2013 | { |
| 2014 | ret += CSR_BSS_CAP_VALUE_5GHZ; |
| 2015 | } |
| 2016 | } |
| 2017 | #endif |
Srinivas Girigowda | 41c7c5f | 2013-10-21 19:01:38 -0700 | [diff] [blame] | 2018 | /* if strict select 5GHz is non-zero then ignore the capability checking */ |
| 2019 | if (pIes && !CSR_IS_SELECT_5GHZ_MARGIN(pMac)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2020 | { |
| 2021 | //We only care about 11N capability |
| 2022 | if(pIes->HTCaps.present) |
| 2023 | { |
| 2024 | ret += CSR_BSS_CAP_VALUE_HT; |
| 2025 | } |
| 2026 | if(CSR_IS_QOS_BSS(pIes)) |
| 2027 | { |
| 2028 | ret += CSR_BSS_CAP_VALUE_WMM; |
| 2029 | //Give advantage to UAPSD |
| 2030 | if(CSR_IS_UAPSD_BSS(pIes)) |
| 2031 | { |
| 2032 | ret += CSR_BSS_CAP_VALUE_UAPSD; |
| 2033 | } |
| 2034 | } |
| 2035 | } |
| 2036 | |
| 2037 | return (ret); |
| 2038 | } |
| 2039 | |
| 2040 | |
| 2041 | //To check whther pBss1 is better than pBss2 |
| 2042 | static tANI_BOOLEAN csrIsBetterBss(tCsrScanResult *pBss1, tCsrScanResult *pBss2) |
| 2043 | { |
| 2044 | tANI_BOOLEAN ret; |
| 2045 | |
| 2046 | if(CSR_IS_BETTER_PREFER_VALUE(pBss1->preferValue, pBss2->preferValue)) |
| 2047 | { |
| 2048 | ret = eANI_BOOLEAN_TRUE; |
| 2049 | } |
| 2050 | else if(CSR_IS_EQUAL_PREFER_VALUE(pBss1->preferValue, pBss2->preferValue)) |
| 2051 | { |
| 2052 | if(CSR_IS_BETTER_CAP_VALUE(pBss1->capValue, pBss2->capValue)) |
| 2053 | { |
| 2054 | ret = eANI_BOOLEAN_TRUE; |
| 2055 | } |
| 2056 | else |
| 2057 | { |
| 2058 | ret = eANI_BOOLEAN_FALSE; |
| 2059 | } |
| 2060 | } |
| 2061 | else |
| 2062 | { |
| 2063 | ret = eANI_BOOLEAN_FALSE; |
| 2064 | } |
| 2065 | |
| 2066 | return (ret); |
| 2067 | } |
| 2068 | |
| 2069 | |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 2070 | #ifdef FEATURE_WLAN_LFR |
Madan Mohan Koyyalamudi | 470d2cf | 2012-09-28 14:43:44 -0700 | [diff] [blame] | 2071 | //Add the channel to the occupiedChannels array |
| 2072 | static void csrScanAddToOccupiedChannels( |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 2073 | tpAniSirGlobal pMac, |
| 2074 | tCsrScanResult *pResult, |
| 2075 | tCsrChannel *pOccupiedChannels, |
Madan Mohan Koyyalamudi | 470d2cf | 2012-09-28 14:43:44 -0700 | [diff] [blame] | 2076 | tDot11fBeaconIEs *pIes) |
| 2077 | { |
| 2078 | eHalStatus status; |
| 2079 | tANI_U8 channel; |
| 2080 | tANI_U8 numOccupiedChannels = pOccupiedChannels->numChannels; |
| 2081 | tANI_U8 *pOccupiedChannelList = pOccupiedChannels->channelList; |
| 2082 | |
| 2083 | channel = pResult->Result.BssDescriptor.channelId; |
| 2084 | |
| 2085 | if (!csrIsChannelPresentInList(pOccupiedChannelList, numOccupiedChannels, channel) |
Madan Mohan Koyyalamudi | dd3c966 | 2012-11-09 17:39:30 -0800 | [diff] [blame] | 2086 | && csrNeighborRoamConnectedProfileMatch(pMac, pResult, pIes)) |
Madan Mohan Koyyalamudi | 470d2cf | 2012-09-28 14:43:44 -0700 | [diff] [blame] | 2087 | { |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 2088 | status = csrAddToChannelListFront(pOccupiedChannelList, numOccupiedChannels, channel); |
Madan Mohan Koyyalamudi | 470d2cf | 2012-09-28 14:43:44 -0700 | [diff] [blame] | 2089 | if(HAL_STATUS_SUCCESS(status)) |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 2090 | { |
Madan Mohan Koyyalamudi | 470d2cf | 2012-09-28 14:43:44 -0700 | [diff] [blame] | 2091 | pOccupiedChannels->numChannels++; |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 2092 | 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] | 2093 | __func__, channel, pOccupiedChannels->numChannels); |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 2094 | if (pOccupiedChannels->numChannels > CSR_BG_SCAN_OCCUPIED_CHANNEL_LIST_LEN) |
| 2095 | pOccupiedChannels->numChannels = CSR_BG_SCAN_OCCUPIED_CHANNEL_LIST_LEN; |
| 2096 | } |
Madan Mohan Koyyalamudi | 470d2cf | 2012-09-28 14:43:44 -0700 | [diff] [blame] | 2097 | } |
| 2098 | } |
Mukul Sharma | 9e4e0f9 | 2015-02-13 18:45:20 +0530 | [diff] [blame] | 2099 | |
| 2100 | void csrAddChannelToOccupiedChannelList(tpAniSirGlobal pMac, |
| 2101 | tANI_U8 channel) |
| 2102 | { |
| 2103 | eHalStatus status; |
| 2104 | tCsrChannel *pOccupiedChannels = &pMac->scan.occupiedChannels; |
| 2105 | tANI_U8 numOccupiedChannels = pOccupiedChannels->numChannels; |
| 2106 | tANI_U8 *pOccupiedChannelList = pOccupiedChannels->channelList; |
| 2107 | if (!csrIsChannelPresentInList(pOccupiedChannelList, |
| 2108 | numOccupiedChannels, channel)) |
| 2109 | { |
| 2110 | status = csrAddToChannelListFront(pOccupiedChannelList, |
| 2111 | numOccupiedChannels, channel); |
| 2112 | if(HAL_STATUS_SUCCESS(status)) |
| 2113 | { |
| 2114 | pOccupiedChannels->numChannels++; |
| 2115 | smsLog(pMac, LOG2, FL("added channel %d to the list (count=%d)"), |
| 2116 | channel, pOccupiedChannels->numChannels); |
| 2117 | if (pOccupiedChannels->numChannels > |
| 2118 | CSR_BG_SCAN_OCCUPIED_CHANNEL_LIST_LEN) |
| 2119 | { |
| 2120 | pOccupiedChannels->numChannels = |
| 2121 | CSR_BG_SCAN_OCCUPIED_CHANNEL_LIST_LEN; |
| 2122 | smsLog(pMac, LOG2, |
| 2123 | FL("trim no of Channels for Occ channel list")); |
| 2124 | } |
| 2125 | } |
| 2126 | } |
| 2127 | } |
Madan Mohan Koyyalamudi | 470d2cf | 2012-09-28 14:43:44 -0700 | [diff] [blame] | 2128 | #endif |
| 2129 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2130 | //Put the BSS into the scan result list |
| 2131 | //pIes can not be NULL |
| 2132 | static void csrScanAddResult(tpAniSirGlobal pMac, tCsrScanResult *pResult, tDot11fBeaconIEs *pIes) |
| 2133 | { |
Srinivas | 28b5b4e | 2012-12-12 13:07:53 -0800 | [diff] [blame] | 2134 | #ifdef FEATURE_WLAN_LFR |
| 2135 | tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo; |
| 2136 | #endif |
| 2137 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2138 | pResult->preferValue = csrGetBssPreferValue(pMac, (int)pResult->Result.BssDescriptor.rssi); |
| 2139 | pResult->capValue = csrGetBssCapValue(pMac, &pResult->Result.BssDescriptor, pIes); |
| 2140 | csrLLInsertTail( &pMac->scan.scanResultList, &pResult->Link, LL_ACCESS_LOCK ); |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 2141 | #ifdef FEATURE_WLAN_LFR |
Srinivas | 28b5b4e | 2012-12-12 13:07:53 -0800 | [diff] [blame] | 2142 | if(0 == pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels) |
| 2143 | { |
| 2144 | /* Build the occupied channel list, only if "gNeighborScanChannelList" is |
| 2145 | NOT set in the cfg.ini file */ |
| 2146 | csrScanAddToOccupiedChannels(pMac, pResult, &pMac->scan.occupiedChannels, pIes); |
| 2147 | } |
Madan Mohan Koyyalamudi | 470d2cf | 2012-09-28 14:43:44 -0700 | [diff] [blame] | 2148 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2149 | } |
| 2150 | |
| 2151 | |
| 2152 | eHalStatus csrScanGetResult(tpAniSirGlobal pMac, tCsrScanResultFilter *pFilter, tScanResultHandle *phResult) |
| 2153 | { |
| 2154 | eHalStatus status; |
| 2155 | tScanResultList *pRetList; |
| 2156 | tCsrScanResult *pResult, *pBssDesc; |
| 2157 | tANI_U32 count = 0; |
| 2158 | tListElem *pEntry; |
| 2159 | tANI_U32 bssLen, allocLen; |
| 2160 | eCsrEncryptionType uc = eCSR_ENCRYPT_TYPE_NONE, mc = eCSR_ENCRYPT_TYPE_NONE; |
| 2161 | eCsrAuthType auth = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 2162 | tDot11fBeaconIEs *pIes, *pNewIes; |
| 2163 | tANI_BOOLEAN fMatch; |
Srinivas Girigowda | 8e7e105 | 2013-11-13 18:53:14 -0800 | [diff] [blame] | 2164 | tANI_U16 i = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2165 | |
| 2166 | if(phResult) |
| 2167 | { |
| 2168 | *phResult = CSR_INVALID_SCANRESULT_HANDLE; |
| 2169 | } |
Srinivas Girigowda | 41c7c5f | 2013-10-21 19:01:38 -0700 | [diff] [blame] | 2170 | |
| 2171 | if (pMac->roam.configParam.nSelect5GHzMargin) |
| 2172 | { |
| 2173 | pMac->scan.inScanResultBestAPRssi = -128; |
| 2174 | csrLLLock(&pMac->scan.scanResultList); |
| 2175 | |
| 2176 | /* Find out the best AP Rssi going thru the scan results */ |
| 2177 | pEntry = csrLLPeekHead(&pMac->scan.scanResultList, LL_ACCESS_NOLOCK); |
| 2178 | while ( NULL != pEntry) |
| 2179 | { |
| 2180 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
Srinivas Girigowda | 8e7e105 | 2013-11-13 18:53:14 -0800 | [diff] [blame] | 2181 | fMatch = FALSE; |
| 2182 | |
| 2183 | if (pFilter) |
| 2184 | for(i = 0; i < pFilter->SSIDs.numOfSSIDs; i++) |
Srinivas Girigowda | 41c7c5f | 2013-10-21 19:01:38 -0700 | [diff] [blame] | 2185 | { |
Srinivas Girigowda | 8e7e105 | 2013-11-13 18:53:14 -0800 | [diff] [blame] | 2186 | fMatch = csrIsSsidMatch( pMac, pFilter->SSIDs.SSIDList[i].SSID.ssId, pFilter->SSIDs.SSIDList[i].SSID.length, |
| 2187 | pBssDesc->Result.ssId.ssId, |
| 2188 | pBssDesc->Result.ssId.length, eANI_BOOLEAN_TRUE ); |
| 2189 | if (fMatch) |
| 2190 | { |
| 2191 | pIes = (tDot11fBeaconIEs *)( pBssDesc->Result.pvIes ); |
| 2192 | |
| 2193 | //At this time, pBssDescription->Result.pvIes may be NULL |
| 2194 | if( !pIes && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, |
| 2195 | &pBssDesc->Result.BssDescriptor, &pIes))) ) |
| 2196 | { |
| 2197 | continue; |
| 2198 | } |
| 2199 | |
| 2200 | smsLog(pMac, LOG1, FL("SSID Matched")); |
Leela Venkata Kiran Kumar Reddy Chirala | e208a83 | 2014-04-27 22:34:25 -0700 | [diff] [blame] | 2201 | |
Leela Venkata Kiran Kumar Reddy Chirala | f257bef | 2014-04-11 18:48:12 -0700 | [diff] [blame] | 2202 | if ( pFilter->bOSENAssociation ) |
| 2203 | { |
| 2204 | fMatch = TRUE; |
| 2205 | } |
Leela Venkata Kiran Kumar Reddy Chirala | e208a83 | 2014-04-27 22:34:25 -0700 | [diff] [blame] | 2206 | else |
| 2207 | { |
Abhishek Singh | 658d4de | 2014-06-26 10:53:15 +0530 | [diff] [blame] | 2208 | #ifdef WLAN_FEATURE_11W |
Abhishek Singh | 3b56d3a | 2014-06-25 12:37:39 +0530 | [diff] [blame] | 2209 | fMatch = csrIsSecurityMatch(pMac, &pFilter->authType, |
| 2210 | &pFilter->EncryptionType, |
| 2211 | &pFilter->mcEncryptionType, |
| 2212 | &pFilter->MFPEnabled, |
| 2213 | &pFilter->MFPRequired, |
| 2214 | &pFilter->MFPCapable, |
| 2215 | &pBssDesc->Result.BssDescriptor, |
| 2216 | pIes, NULL, NULL, NULL ); |
Abhishek Singh | 658d4de | 2014-06-26 10:53:15 +0530 | [diff] [blame] | 2217 | #else |
| 2218 | fMatch = csrIsSecurityMatch(pMac, &pFilter->authType, |
| 2219 | &pFilter->EncryptionType, |
| 2220 | &pFilter->mcEncryptionType, |
| 2221 | NULL, NULL, NULL, |
| 2222 | &pBssDesc->Result.BssDescriptor, |
| 2223 | pIes, NULL, NULL, NULL ); |
| 2224 | #endif |
Leela Venkata Kiran Kumar Reddy Chirala | e208a83 | 2014-04-27 22:34:25 -0700 | [diff] [blame] | 2225 | } |
| 2226 | if ((pBssDesc->Result.pvIes == NULL) && pIes) |
| 2227 | vos_mem_free(pIes); |
Srinivas Girigowda | 8e7e105 | 2013-11-13 18:53:14 -0800 | [diff] [blame] | 2228 | |
| 2229 | if (fMatch) |
| 2230 | smsLog(pMac, LOG1, FL(" Security Matched")); |
| 2231 | } |
| 2232 | } |
| 2233 | |
| 2234 | if (fMatch && (pBssDesc->Result.BssDescriptor.rssi > pMac->scan.inScanResultBestAPRssi)) |
| 2235 | { |
| 2236 | smsLog(pMac, LOG1, FL("Best AP Rssi changed from %d to %d"), |
| 2237 | pMac->scan.inScanResultBestAPRssi, |
| 2238 | pBssDesc->Result.BssDescriptor.rssi); |
Srinivas Girigowda | 41c7c5f | 2013-10-21 19:01:38 -0700 | [diff] [blame] | 2239 | pMac->scan.inScanResultBestAPRssi = pBssDesc->Result.BssDescriptor.rssi; |
| 2240 | } |
| 2241 | pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK); |
| 2242 | } |
| 2243 | |
Srinivas Girigowda | 8e7e105 | 2013-11-13 18:53:14 -0800 | [diff] [blame] | 2244 | if ( -128 != pMac->scan.inScanResultBestAPRssi) |
Srinivas Girigowda | 41c7c5f | 2013-10-21 19:01:38 -0700 | [diff] [blame] | 2245 | { |
Srinivas Girigowda | 8e7e105 | 2013-11-13 18:53:14 -0800 | [diff] [blame] | 2246 | smsLog(pMac, LOG1, FL("Best AP Rssi is %d"), pMac->scan.inScanResultBestAPRssi); |
| 2247 | /* Modify Rssi category based on best AP Rssi */ |
| 2248 | csrAssignRssiForCategory(pMac, pMac->scan.inScanResultBestAPRssi, pMac->roam.configParam.bCatRssiOffset); |
| 2249 | pEntry = csrLLPeekHead(&pMac->scan.scanResultList, LL_ACCESS_NOLOCK); |
| 2250 | while ( NULL != pEntry) |
| 2251 | { |
| 2252 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
Srinivas Girigowda | 41c7c5f | 2013-10-21 19:01:38 -0700 | [diff] [blame] | 2253 | |
Srinivas Girigowda | 8e7e105 | 2013-11-13 18:53:14 -0800 | [diff] [blame] | 2254 | /* re-assign preference value based on modified rssi bucket */ |
| 2255 | pBssDesc->preferValue = csrGetBssPreferValue(pMac, (int)pBssDesc->Result.BssDescriptor.rssi); |
Srinivas Girigowda | 41c7c5f | 2013-10-21 19:01:38 -0700 | [diff] [blame] | 2256 | |
Arif Hussain | a7c8e41 | 2013-11-20 11:06:42 -0800 | [diff] [blame] | 2257 | smsLog(pMac, LOG2, FL("BSSID("MAC_ADDRESS_STR |
Jeff Johnson | 123ed00 | 2013-11-22 17:39:55 -0800 | [diff] [blame] | 2258 | ") Rssi(%d) Chnl(%d) PrefVal(%u) SSID=%.*s"), |
Arif Hussain | a7c8e41 | 2013-11-20 11:06:42 -0800 | [diff] [blame] | 2259 | MAC_ADDR_ARRAY(pBssDesc->Result.BssDescriptor.bssId), |
| 2260 | pBssDesc->Result.BssDescriptor.rssi, |
| 2261 | pBssDesc->Result.BssDescriptor.channelId, |
| 2262 | pBssDesc->preferValue, |
| 2263 | pBssDesc->Result.ssId.length, pBssDesc->Result.ssId.ssId); |
Srinivas Girigowda | 8e7e105 | 2013-11-13 18:53:14 -0800 | [diff] [blame] | 2264 | |
| 2265 | pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK); |
| 2266 | } |
Srinivas Girigowda | 41c7c5f | 2013-10-21 19:01:38 -0700 | [diff] [blame] | 2267 | } |
| 2268 | |
| 2269 | csrLLUnlock(&pMac->scan.scanResultList); |
| 2270 | } |
| 2271 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2272 | pRetList = vos_mem_malloc(sizeof(tScanResultList)); |
| 2273 | if ( NULL == pRetList ) |
| 2274 | status = eHAL_STATUS_FAILURE; |
| 2275 | else |
| 2276 | status = eHAL_STATUS_SUCCESS; |
Srinivas Girigowda | 41c7c5f | 2013-10-21 19:01:38 -0700 | [diff] [blame] | 2277 | if(HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2278 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2279 | vos_mem_set(pRetList, sizeof(tScanResultList), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2280 | csrLLOpen(pMac->hHdd, &pRetList->List); |
| 2281 | pRetList->pCurEntry = NULL; |
| 2282 | |
| 2283 | csrLLLock(&pMac->scan.scanResultList); |
| 2284 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK ); |
| 2285 | while( pEntry ) |
| 2286 | { |
| 2287 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 2288 | pIes = (tDot11fBeaconIEs *)( pBssDesc->Result.pvIes ); |
| 2289 | //if pBssDesc->Result.pvIes is NULL, we need to free any memory allocated by csrMatchBSS |
| 2290 | //for any error condition, otherwiase, it will be freed later. |
| 2291 | //reset |
| 2292 | fMatch = eANI_BOOLEAN_FALSE; |
| 2293 | pNewIes = NULL; |
| 2294 | |
| 2295 | if(pFilter) |
| 2296 | { |
| 2297 | fMatch = csrMatchBSS(pMac, &pBssDesc->Result.BssDescriptor, pFilter, &auth, &uc, &mc, &pIes); |
| 2298 | if( NULL != pIes ) |
| 2299 | { |
| 2300 | //Only save it when matching |
| 2301 | if(fMatch) |
| 2302 | { |
| 2303 | if( !pBssDesc->Result.pvIes ) |
| 2304 | { |
| 2305 | //csrMatchBSS allocates the memory. Simply pass it and it is freed later |
| 2306 | pNewIes = pIes; |
| 2307 | } |
| 2308 | else |
| 2309 | { |
| 2310 | //The pIes is allocated by someone else. make a copy |
| 2311 | //Only to save parsed IEs if caller provides a filter. Most likely the caller |
| 2312 | //is using to for association, hence save the parsed IEs |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2313 | pNewIes = vos_mem_malloc(sizeof(tDot11fBeaconIEs)); |
| 2314 | if ( NULL == pNewIes ) |
| 2315 | status = eHAL_STATUS_FAILURE; |
| 2316 | else |
| 2317 | status = eHAL_STATUS_SUCCESS; |
| 2318 | if ( HAL_STATUS_SUCCESS( status ) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2319 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2320 | vos_mem_copy(pNewIes, pIes, sizeof( tDot11fBeaconIEs )); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2321 | } |
| 2322 | else |
| 2323 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 2324 | smsLog(pMac, LOGE, FL(" fail to allocate memory for IEs")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2325 | //Need to free memory allocated by csrMatchBSS |
| 2326 | if( !pBssDesc->Result.pvIes ) |
| 2327 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2328 | vos_mem_free(pIes); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2329 | } |
| 2330 | break; |
| 2331 | } |
| 2332 | } |
| 2333 | }//fMatch |
| 2334 | else if( !pBssDesc->Result.pvIes ) |
| 2335 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2336 | vos_mem_free(pIes); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2337 | } |
| 2338 | } |
| 2339 | } |
| 2340 | if(NULL == pFilter || fMatch) |
| 2341 | { |
| 2342 | bssLen = pBssDesc->Result.BssDescriptor.length + sizeof(pBssDesc->Result.BssDescriptor.length); |
| 2343 | allocLen = sizeof( tCsrScanResult ) + bssLen; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2344 | pResult = vos_mem_malloc(allocLen); |
| 2345 | if ( NULL == pResult ) |
| 2346 | status = eHAL_STATUS_FAILURE; |
| 2347 | else |
| 2348 | status = eHAL_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2349 | if(!HAL_STATUS_SUCCESS(status)) |
| 2350 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 2351 | 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] | 2352 | if(pNewIes) |
| 2353 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2354 | vos_mem_free(pNewIes); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2355 | } |
| 2356 | break; |
| 2357 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2358 | vos_mem_set(pResult, allocLen, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2359 | pResult->capValue = pBssDesc->capValue; |
| 2360 | pResult->preferValue = pBssDesc->preferValue; |
| 2361 | pResult->ucEncryptionType = uc; |
| 2362 | pResult->mcEncryptionType = mc; |
| 2363 | pResult->authType = auth; |
| 2364 | pResult->Result.ssId = pBssDesc->Result.ssId; |
| 2365 | pResult->Result.timer = 0; |
| 2366 | //save the pIes for later use |
| 2367 | pResult->Result.pvIes = pNewIes; |
| 2368 | //save bss description |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2369 | vos_mem_copy(&pResult->Result.BssDescriptor, |
| 2370 | &pBssDesc->Result.BssDescriptor, bssLen); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2371 | //No need to lock pRetList because it is locally allocated and no outside can access it at this time |
| 2372 | if(csrLLIsListEmpty(&pRetList->List, LL_ACCESS_NOLOCK)) |
| 2373 | { |
| 2374 | csrLLInsertTail(&pRetList->List, &pResult->Link, LL_ACCESS_NOLOCK); |
| 2375 | } |
| 2376 | else |
| 2377 | { |
| 2378 | //To sort the list |
| 2379 | tListElem *pTmpEntry; |
| 2380 | tCsrScanResult *pTmpResult; |
| 2381 | |
| 2382 | pTmpEntry = csrLLPeekHead(&pRetList->List, LL_ACCESS_NOLOCK); |
| 2383 | while(pTmpEntry) |
| 2384 | { |
| 2385 | pTmpResult = GET_BASE_ADDR( pTmpEntry, tCsrScanResult, Link ); |
| 2386 | if(csrIsBetterBss(pResult, pTmpResult)) |
| 2387 | { |
| 2388 | csrLLInsertEntry(&pRetList->List, pTmpEntry, &pResult->Link, LL_ACCESS_NOLOCK); |
| 2389 | //To indicate we are done |
| 2390 | pResult = NULL; |
| 2391 | break; |
| 2392 | } |
| 2393 | pTmpEntry = csrLLNext(&pRetList->List, pTmpEntry, LL_ACCESS_NOLOCK); |
| 2394 | } |
| 2395 | if(pResult != NULL) |
| 2396 | { |
| 2397 | //This one is not better than any one |
| 2398 | csrLLInsertTail(&pRetList->List, &pResult->Link, LL_ACCESS_NOLOCK); |
| 2399 | } |
| 2400 | } |
| 2401 | count++; |
| 2402 | } |
| 2403 | pEntry = csrLLNext( &pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK ); |
| 2404 | }//while |
| 2405 | csrLLUnlock(&pMac->scan.scanResultList); |
| 2406 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 2407 | smsLog(pMac, LOG2, FL("return %d BSS"), csrLLCount(&pRetList->List)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2408 | |
| 2409 | if( !HAL_STATUS_SUCCESS(status) || (phResult == NULL) ) |
| 2410 | { |
| 2411 | //Fail or No one wants the result. |
| 2412 | csrScanResultPurge(pMac, (tScanResultHandle)pRetList); |
| 2413 | } |
| 2414 | else |
| 2415 | { |
| 2416 | if(0 == count) |
| 2417 | { |
| 2418 | //We are here meaning the there is no match |
| 2419 | csrLLClose(&pRetList->List); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2420 | vos_mem_free(pRetList); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2421 | status = eHAL_STATUS_E_NULL_VALUE; |
| 2422 | } |
| 2423 | else if(phResult) |
| 2424 | { |
| 2425 | *phResult = pRetList; |
| 2426 | } |
| 2427 | } |
| 2428 | }//Allocated pRetList |
| 2429 | |
| 2430 | return (status); |
| 2431 | } |
| 2432 | |
Madan Mohan Koyyalamudi | ab41d0f | 2012-10-31 17:17:10 -0700 | [diff] [blame] | 2433 | /* |
| 2434 | * NOTE: This routine is being added to make |
| 2435 | * sure that scan results are not being flushed |
| 2436 | * while roaming. If the scan results are flushed, |
| 2437 | * we are unable to recover from |
| 2438 | * csrRoamRoamingStateDisassocRspProcessor. |
| 2439 | * If it is needed to remove this routine, |
| 2440 | * first ensure that we recover gracefully from |
| 2441 | * csrRoamRoamingStateDisassocRspProcessor if |
| 2442 | * csrScanGetResult returns with a failure because |
| 2443 | * of not being able to find the roaming BSS. |
| 2444 | */ |
| 2445 | tANI_U8 csrScanFlushDenied(tpAniSirGlobal pMac) |
| 2446 | { |
| 2447 | switch(pMac->roam.neighborRoamInfo.neighborRoamState) { |
| 2448 | case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN: |
| 2449 | case eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING: |
| 2450 | case eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE: |
| 2451 | case eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING: |
| 2452 | return (pMac->roam.neighborRoamInfo.neighborRoamState); |
| 2453 | default: |
| 2454 | return 0; |
| 2455 | } |
| 2456 | } |
| 2457 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2458 | eHalStatus csrScanFlushResult(tpAniSirGlobal pMac) |
| 2459 | { |
Madan Mohan Koyyalamudi | ab41d0f | 2012-10-31 17:17:10 -0700 | [diff] [blame] | 2460 | tANI_U8 isFlushDenied = csrScanFlushDenied(pMac); |
Srinivas, Dasari | 42bf770 | 2014-02-07 11:29:53 +0530 | [diff] [blame] | 2461 | eHalStatus status = eHAL_STATUS_SUCCESS; |
Madan Mohan Koyyalamudi | ab41d0f | 2012-10-31 17:17:10 -0700 | [diff] [blame] | 2462 | if (isFlushDenied) { |
| 2463 | smsLog(pMac, LOGW, "%s: scan flush denied in roam state %d", |
| 2464 | __func__, isFlushDenied); |
| 2465 | return eHAL_STATUS_FAILURE; |
| 2466 | } |
Srinivas, Dasari | 42bf770 | 2014-02-07 11:29:53 +0530 | [diff] [blame] | 2467 | csrLLScanPurgeResult( pMac, &pMac->scan.tempScanResults ); |
| 2468 | csrLLScanPurgeResult( pMac, &pMac->scan.scanResultList ); |
| 2469 | return( status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2470 | } |
| 2471 | |
Mukul Sharma | 20aa658 | 2014-08-07 21:36:12 +0530 | [diff] [blame] | 2472 | eHalStatus csrScanFlushSelectiveResultForBand(tpAniSirGlobal pMac, v_BOOL_t flushP2P, tSirRFBand band) |
| 2473 | { |
| 2474 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2475 | tListElem *pEntry,*pFreeElem; |
| 2476 | tCsrScanResult *pBssDesc; |
| 2477 | tDblLinkList *pList = &pMac->scan.scanResultList; |
| 2478 | |
| 2479 | csrLLLock(pList); |
| 2480 | |
| 2481 | pEntry = csrLLPeekHead( pList, LL_ACCESS_NOLOCK ); |
| 2482 | while( pEntry != NULL) |
| 2483 | { |
| 2484 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 2485 | if( (flushP2P == vos_mem_compare( pBssDesc->Result.ssId.ssId, |
| 2486 | "DIRECT-", 7)) && |
| 2487 | (GetRFBand(pBssDesc->Result.BssDescriptor.channelId) == band) |
| 2488 | ) |
| 2489 | { |
| 2490 | pFreeElem = pEntry; |
| 2491 | pEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK); |
| 2492 | csrLLRemoveEntry(pList, pFreeElem, LL_ACCESS_NOLOCK); |
| 2493 | csrFreeScanResultEntry( pMac, pBssDesc ); |
| 2494 | continue; |
| 2495 | } |
| 2496 | pEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK); |
| 2497 | } |
| 2498 | |
| 2499 | csrLLUnlock(pList); |
| 2500 | |
| 2501 | return (status); |
| 2502 | } |
| 2503 | |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2504 | eHalStatus csrScanFlushSelectiveResult(tpAniSirGlobal pMac, v_BOOL_t flushP2P) |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2505 | { |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2506 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2507 | tListElem *pEntry,*pFreeElem; |
| 2508 | tCsrScanResult *pBssDesc; |
| 2509 | tDblLinkList *pList = &pMac->scan.scanResultList; |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2510 | |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2511 | csrLLLock(pList); |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2512 | |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2513 | pEntry = csrLLPeekHead( pList, LL_ACCESS_NOLOCK ); |
| 2514 | while( pEntry != NULL) |
| 2515 | { |
| 2516 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 2517 | if( flushP2P == vos_mem_compare( pBssDesc->Result.ssId.ssId, |
| 2518 | "DIRECT-", 7) ) |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2519 | { |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2520 | pFreeElem = pEntry; |
| 2521 | pEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK); |
| 2522 | csrLLRemoveEntry(pList, pFreeElem, LL_ACCESS_NOLOCK); |
| 2523 | csrFreeScanResultEntry( pMac, pBssDesc ); |
| 2524 | continue; |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2525 | } |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2526 | pEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK); |
| 2527 | } |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2528 | |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2529 | csrLLUnlock(pList); |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2530 | |
Madan Mohan Koyyalamudi | 5850f31 | 2012-11-27 19:00:25 +0530 | [diff] [blame] | 2531 | return (status); |
Madan Mohan Koyyalamudi | a3fcf14 | 2012-10-18 15:01:20 -0700 | [diff] [blame] | 2532 | } |
| 2533 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2534 | /** |
| 2535 | * csrCheck11dChannel |
| 2536 | * |
| 2537 | *FUNCTION: |
Srinivas, Dasari | 42bf770 | 2014-02-07 11:29:53 +0530 | [diff] [blame] | 2538 | * This function is called from csrScanFilterResults function and |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2539 | * compare channel number with given channel list. |
| 2540 | * |
| 2541 | *LOGIC: |
| 2542 | * Check Scan result channel number with CFG channel list |
| 2543 | * |
| 2544 | *ASSUMPTIONS: |
| 2545 | * |
| 2546 | * |
| 2547 | *NOTE: |
| 2548 | * |
| 2549 | * @param channelId channel number |
| 2550 | * @param pChannelList Pointer to channel list |
| 2551 | * @param numChannels Number of channel in channel list |
| 2552 | * |
| 2553 | * @return Status |
| 2554 | */ |
| 2555 | |
| 2556 | eHalStatus csrCheck11dChannel(tANI_U8 channelId, tANI_U8 *pChannelList, tANI_U32 numChannels) |
| 2557 | { |
| 2558 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 2559 | tANI_U8 i = 0; |
| 2560 | |
| 2561 | for (i = 0; i < numChannels; i++) |
| 2562 | { |
| 2563 | if(pChannelList[ i ] == channelId) |
| 2564 | { |
| 2565 | status = eHAL_STATUS_SUCCESS; |
| 2566 | break; |
| 2567 | } |
| 2568 | } |
| 2569 | return status; |
| 2570 | } |
| 2571 | |
| 2572 | /** |
Srinivas, Dasari | 42bf770 | 2014-02-07 11:29:53 +0530 | [diff] [blame] | 2573 | * csrScanFilterResults |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2574 | * |
| 2575 | *FUNCTION: |
| 2576 | * This function is called from csrApplyCountryInformation function and |
| 2577 | * filter scan result based on valid channel list number. |
| 2578 | * |
| 2579 | *LOGIC: |
| 2580 | * Get scan result from scan list and Check Scan result channel number |
| 2581 | * with 11d channel list if channel number is found in 11d channel list |
| 2582 | * then do not remove scan result entry from scan list |
| 2583 | * |
| 2584 | *ASSUMPTIONS: |
| 2585 | * |
| 2586 | * |
| 2587 | *NOTE: |
| 2588 | * |
| 2589 | * @param pMac Pointer to Global MAC structure |
| 2590 | * |
| 2591 | * @return Status |
| 2592 | */ |
| 2593 | |
Srinivas, Dasari | 42bf770 | 2014-02-07 11:29:53 +0530 | [diff] [blame] | 2594 | eHalStatus csrScanFilterResults(tpAniSirGlobal pMac) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2595 | { |
| 2596 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2597 | tListElem *pEntry,*pTempEntry; |
| 2598 | tCsrScanResult *pBssDesc; |
| 2599 | tANI_U32 len = sizeof(pMac->roam.validChannelList); |
| 2600 | |
| 2601 | /* Get valid channels list from CFG */ |
| 2602 | if (!HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, |
| 2603 | pMac->roam.validChannelList, &len))) |
| 2604 | { |
Agarwal Ashish | e3cca2a | 2013-07-21 03:01:48 +0530 | [diff] [blame] | 2605 | smsLog( pMac, LOGE, "Failed to get Channel list from CFG"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2606 | } |
| 2607 | |
| 2608 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_LOCK ); |
| 2609 | while( pEntry ) |
| 2610 | { |
| 2611 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
Srinivas, Dasari | 42bf770 | 2014-02-07 11:29:53 +0530 | [diff] [blame] | 2612 | pTempEntry = csrLLNext( &pMac->scan.scanResultList, pEntry, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2613 | LL_ACCESS_LOCK ); |
| 2614 | if(csrCheck11dChannel(pBssDesc->Result.BssDescriptor.channelId, |
Srinivas, Dasari | 42bf770 | 2014-02-07 11:29:53 +0530 | [diff] [blame] | 2615 | pMac->roam.validChannelList, len)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2616 | { |
| 2617 | /* Remove Scan result which does not have 11d channel */ |
| 2618 | if( csrLLRemoveEntry( &pMac->scan.scanResultList, pEntry, |
| 2619 | LL_ACCESS_LOCK )) |
| 2620 | { |
| 2621 | csrFreeScanResultEntry( pMac, pBssDesc ); |
| 2622 | } |
| 2623 | } |
Srinivas, Dasari | 42bf770 | 2014-02-07 11:29:53 +0530 | [diff] [blame] | 2624 | pEntry = pTempEntry; |
| 2625 | } |
| 2626 | |
| 2627 | pEntry = csrLLPeekHead( &pMac->scan.tempScanResults, LL_ACCESS_LOCK ); |
| 2628 | while( pEntry ) |
| 2629 | { |
| 2630 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 2631 | pTempEntry = csrLLNext( &pMac->scan.tempScanResults, pEntry, |
| 2632 | LL_ACCESS_LOCK ); |
| 2633 | if(csrCheck11dChannel(pBssDesc->Result.BssDescriptor.channelId, |
| 2634 | pMac->roam.validChannelList, len)) |
| 2635 | { |
| 2636 | /* Remove Scan result which does not have 11d channel */ |
| 2637 | if( csrLLRemoveEntry( &pMac->scan.tempScanResults, pEntry, |
| 2638 | LL_ACCESS_LOCK )) |
| 2639 | { |
| 2640 | csrFreeScanResultEntry( pMac, pBssDesc ); |
| 2641 | } |
| 2642 | } |
| 2643 | else |
| 2644 | { |
| 2645 | smsLog( pMac, LOG1, FL("%d is a Valid channel"), |
| 2646 | pBssDesc->Result.BssDescriptor.channelId); |
| 2647 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2648 | pEntry = pTempEntry; |
| 2649 | } |
| 2650 | return status; |
| 2651 | } |
| 2652 | |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 2653 | /** |
| 2654 | * csrScanFilterDFSResults |
| 2655 | * |
| 2656 | *FUNCTION: |
| 2657 | * This function filter BSSIDs on DFS channels from the scan results. |
| 2658 | * |
| 2659 | *LOGIC: |
| 2660 | * Get scan result from scan list and Check Scan result channel number |
| 2661 | * with 11d channel list if channel number is found in 11d channel list |
| 2662 | * and if fEnableDFSChnlScan is zero and if channel is DFS, then |
| 2663 | * remove scan result entry from scan list |
| 2664 | * |
| 2665 | *ASSUMPTIONS: |
| 2666 | * |
| 2667 | *NOTE: |
| 2668 | * |
| 2669 | * @param pMac Pointer to Global MAC structure |
| 2670 | * |
| 2671 | * @return Status |
| 2672 | */ |
| 2673 | |
| 2674 | eHalStatus csrScanFilterDFSResults(tpAniSirGlobal pMac) |
| 2675 | { |
| 2676 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2677 | tListElem *pEntry,*pTempEntry; |
| 2678 | tCsrScanResult *pBssDesc; |
| 2679 | |
| 2680 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_LOCK ); |
| 2681 | while( pEntry ) |
| 2682 | { |
| 2683 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 2684 | pTempEntry = csrLLNext( &pMac->scan.scanResultList, pEntry, |
| 2685 | LL_ACCESS_LOCK ); |
| 2686 | if((pMac->scan.fEnableDFSChnlScan == DFS_CHNL_SCAN_DISABLED) && |
| 2687 | CSR_IS_CHANNEL_DFS(pBssDesc->Result.BssDescriptor.channelId)) |
| 2688 | { |
| 2689 | smsLog( pMac, LOG1, FL("%d is a DFS ch filtered from scan list"), |
| 2690 | pBssDesc->Result.BssDescriptor.channelId); |
| 2691 | /* Remove Scan result which does not have 11d channel */ |
| 2692 | if( csrLLRemoveEntry( &pMac->scan.scanResultList, pEntry, |
| 2693 | LL_ACCESS_LOCK )) |
| 2694 | { |
| 2695 | csrFreeScanResultEntry( pMac, pBssDesc ); |
| 2696 | } |
| 2697 | } |
| 2698 | else |
| 2699 | { |
| 2700 | smsLog( pMac, LOG1, FL("%d is a Valid channel"), |
| 2701 | pBssDesc->Result.BssDescriptor.channelId); |
| 2702 | } |
| 2703 | pEntry = pTempEntry; |
| 2704 | } |
| 2705 | |
| 2706 | pEntry = csrLLPeekHead( &pMac->scan.tempScanResults, LL_ACCESS_LOCK ); |
| 2707 | while( pEntry ) |
| 2708 | { |
| 2709 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 2710 | pTempEntry = csrLLNext( &pMac->scan.tempScanResults, pEntry, |
| 2711 | LL_ACCESS_LOCK ); |
| 2712 | |
| 2713 | if((pMac->scan.fEnableDFSChnlScan == DFS_CHNL_SCAN_DISABLED) && |
| 2714 | CSR_IS_CHANNEL_DFS(pBssDesc->Result.BssDescriptor.channelId)) |
| 2715 | { |
| 2716 | smsLog( pMac, LOG1, FL("%d is a DFS ch filtered from scan list"), |
| 2717 | pBssDesc->Result.BssDescriptor.channelId); |
| 2718 | /* Remove Scan result which does not have 11d channel */ |
| 2719 | if( csrLLRemoveEntry( &pMac->scan.tempScanResults, pEntry, |
| 2720 | LL_ACCESS_LOCK )) |
| 2721 | { |
| 2722 | csrFreeScanResultEntry( pMac, pBssDesc ); |
| 2723 | } |
| 2724 | } |
| 2725 | else |
| 2726 | { |
| 2727 | smsLog( pMac, LOG1, FL("%d is a Valid channel"), |
| 2728 | pBssDesc->Result.BssDescriptor.channelId); |
| 2729 | } |
| 2730 | pEntry = pTempEntry; |
| 2731 | } |
| 2732 | return status; |
| 2733 | } |
| 2734 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2735 | |
| 2736 | eHalStatus csrScanCopyResultList(tpAniSirGlobal pMac, tScanResultHandle hIn, tScanResultHandle *phResult) |
| 2737 | { |
| 2738 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2739 | tScanResultList *pRetList, *pInList = (tScanResultList *)hIn; |
| 2740 | tCsrScanResult *pResult, *pScanResult; |
| 2741 | tANI_U32 count = 0; |
| 2742 | tListElem *pEntry; |
| 2743 | tANI_U32 bssLen, allocLen; |
| 2744 | |
| 2745 | if(phResult) |
| 2746 | { |
| 2747 | *phResult = CSR_INVALID_SCANRESULT_HANDLE; |
| 2748 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2749 | pRetList = vos_mem_malloc(sizeof(tScanResultList)); |
| 2750 | if ( NULL == pRetList ) |
| 2751 | status = eHAL_STATUS_FAILURE; |
| 2752 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2753 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2754 | vos_mem_set(pRetList, sizeof(tScanResultList), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2755 | csrLLOpen(pMac->hHdd, &pRetList->List); |
| 2756 | pRetList->pCurEntry = NULL; |
| 2757 | csrLLLock(&pMac->scan.scanResultList); |
| 2758 | csrLLLock(&pInList->List); |
| 2759 | |
| 2760 | pEntry = csrLLPeekHead( &pInList->List, LL_ACCESS_NOLOCK ); |
| 2761 | while( pEntry ) |
| 2762 | { |
| 2763 | pScanResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 2764 | bssLen = pScanResult->Result.BssDescriptor.length + sizeof(pScanResult->Result.BssDescriptor.length); |
| 2765 | allocLen = sizeof( tCsrScanResult ) + bssLen; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2766 | pResult = vos_mem_malloc(allocLen); |
| 2767 | if ( NULL == pResult ) |
| 2768 | status = eHAL_STATUS_FAILURE; |
| 2769 | else |
| 2770 | status = eHAL_STATUS_SUCCESS; |
| 2771 | if (!HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2772 | { |
| 2773 | csrScanResultPurge(pMac, (tScanResultHandle *)pRetList); |
| 2774 | count = 0; |
| 2775 | break; |
| 2776 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2777 | vos_mem_set(pResult, allocLen , 0); |
| 2778 | vos_mem_copy(&pResult->Result.BssDescriptor, &pScanResult->Result.BssDescriptor, bssLen); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2779 | if( pScanResult->Result.pvIes ) |
| 2780 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2781 | pResult->Result.pvIes = vos_mem_malloc(sizeof( tDot11fBeaconIEs )); |
| 2782 | if ( NULL == pResult->Result.pvIes ) |
| 2783 | status = eHAL_STATUS_FAILURE; |
| 2784 | else |
| 2785 | status = eHAL_STATUS_SUCCESS; |
| 2786 | if (!HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2787 | { |
| 2788 | //Free the memory we allocate above first |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2789 | vos_mem_free(pResult); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2790 | csrScanResultPurge(pMac, (tScanResultHandle *)pRetList); |
| 2791 | count = 0; |
| 2792 | break; |
| 2793 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2794 | vos_mem_copy(pResult->Result.pvIes, pScanResult->Result.pvIes, |
| 2795 | sizeof( tDot11fBeaconIEs )); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2796 | } |
| 2797 | csrLLInsertTail(&pRetList->List, &pResult->Link, LL_ACCESS_LOCK); |
| 2798 | count++; |
| 2799 | pEntry = csrLLNext( &pInList->List, pEntry, LL_ACCESS_NOLOCK ); |
| 2800 | }//while |
| 2801 | csrLLUnlock(&pInList->List); |
| 2802 | csrLLUnlock(&pMac->scan.scanResultList); |
| 2803 | |
| 2804 | if(HAL_STATUS_SUCCESS(status)) |
| 2805 | { |
| 2806 | if(0 == count) |
| 2807 | { |
| 2808 | csrLLClose(&pRetList->List); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2809 | vos_mem_free(pRetList); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2810 | status = eHAL_STATUS_E_NULL_VALUE; |
| 2811 | } |
| 2812 | else if(phResult) |
| 2813 | { |
| 2814 | *phResult = pRetList; |
| 2815 | } |
| 2816 | } |
| 2817 | }//Allocated pRetList |
| 2818 | |
| 2819 | return (status); |
| 2820 | } |
| 2821 | |
| 2822 | |
| 2823 | |
| 2824 | eHalStatus csrScanningStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf ) |
| 2825 | { |
| 2826 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 2827 | tSirMbMsg *pMsg = (tSirMbMsg *)pMsgBuf; |
Hanumantha Reddy Pothula | 1b6eb2f | 2015-11-30 20:50:23 +0530 | [diff] [blame] | 2828 | tSirSmeDisConDoneInd *pDisConDoneInd; |
| 2829 | tCsrRoamInfo roamInfo = {0}; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2830 | |
Hanumantha Reddy Pothula | 1b6eb2f | 2015-11-30 20:50:23 +0530 | [diff] [blame] | 2831 | if((eWNI_SME_SCAN_RSP == pMsg->type) || |
| 2832 | (eWNI_SME_GET_SCANNED_CHANNEL_RSP == pMsg->type)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2833 | { |
| 2834 | status = csrScanSmeScanResponse( pMac, pMsgBuf ); |
| 2835 | } |
| 2836 | else |
| 2837 | { |
Hanumantha Reddy Pothula | 1b6eb2f | 2015-11-30 20:50:23 +0530 | [diff] [blame] | 2838 | switch (pMsg->type) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2839 | { |
Hanumantha Reddy Pothula | 1b6eb2f | 2015-11-30 20:50:23 +0530 | [diff] [blame] | 2840 | case eWNI_SME_UPPER_LAYER_ASSOC_CNF: |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 2841 | { |
Hanumantha Reddy Pothula | 1b6eb2f | 2015-11-30 20:50:23 +0530 | [diff] [blame] | 2842 | tCsrRoamSession *pSession; |
| 2843 | tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf; |
| 2844 | tCsrRoamInfo *pRoamInfo = NULL; |
| 2845 | tANI_U32 sessionId; |
| 2846 | eHalStatus status; |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 2847 | |
Hanumantha Reddy Pothula | 1b6eb2f | 2015-11-30 20:50:23 +0530 | [diff] [blame] | 2848 | smsLog( pMac, LOG1, |
| 2849 | FL("Scanning : ASSOCIATION confirmation can be given to upper layer ")); |
| 2850 | pRoamInfo = &roamInfo; |
| 2851 | pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf; |
| 2852 | status = csrRoamGetSessionIdFromBSSID( pMac, |
| 2853 | (tCsrBssid *)pUpperLayerAssocCnf->bssId, |
| 2854 | &sessionId ); |
| 2855 | pSession = CSR_GET_SESSION(pMac, sessionId); |
| 2856 | |
| 2857 | if(!pSession) |
| 2858 | { |
| 2859 | smsLog(pMac, LOGE, FL("session %d not found "), sessionId); |
| 2860 | return eHAL_STATUS_FAILURE; |
| 2861 | } |
| 2862 | |
| 2863 | //send the status code as Success |
| 2864 | pRoamInfo->statusCode = eSIR_SME_SUCCESS; |
| 2865 | pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile; |
| 2866 | pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid; |
| 2867 | pRoamInfo->rsnIELen = |
| 2868 | (tANI_U8)pUpperLayerAssocCnf->rsnIE.length; |
| 2869 | pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata; |
| 2870 | pRoamInfo->addIELen = |
| 2871 | (tANI_U8)pUpperLayerAssocCnf->addIE.length; |
| 2872 | pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata; |
| 2873 | vos_mem_copy(pRoamInfo->peerMac, |
| 2874 | pUpperLayerAssocCnf->peerMacAddr, |
| 2875 | sizeof(tSirMacAddr)); |
| 2876 | vos_mem_copy(&pRoamInfo->bssid, |
| 2877 | pUpperLayerAssocCnf->bssId, |
| 2878 | sizeof(tCsrBssid)); |
| 2879 | pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta; |
Hardik Kantilal Patel | 1ba630f | 2014-11-21 04:32:05 +0530 | [diff] [blame] | 2880 | #ifdef WLAN_FEATURE_AP_HT40_24G |
Hanumantha Reddy Pothula | 1b6eb2f | 2015-11-30 20:50:23 +0530 | [diff] [blame] | 2881 | pRoamInfo->HT40MHzIntoEnabledSta = |
| 2882 | pUpperLayerAssocCnf->HT40MHzIntoEnabledSta; |
Hardik Kantilal Patel | 1ba630f | 2014-11-21 04:32:05 +0530 | [diff] [blame] | 2883 | #endif |
Hanumantha Reddy Pothula | 1b6eb2f | 2015-11-30 20:50:23 +0530 | [diff] [blame] | 2884 | if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) ) |
| 2885 | { |
| 2886 | pMac->roam.roamSession[sessionId].connectState = |
| 2887 | eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED; |
| 2888 | pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq; |
| 2889 | status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, |
| 2890 | 0, eCSR_ROAM_INFRA_IND, |
| 2891 | eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF); |
| 2892 | } |
| 2893 | if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile)) |
| 2894 | { |
| 2895 | vos_sleep( 100 ); |
| 2896 | pMac->roam.roamSession[sessionId].connectState = |
| 2897 | eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta |
| 2898 | status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, |
| 2899 | eCSR_ROAM_WDS_IND, |
| 2900 | eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta |
| 2901 | } |
| 2902 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2903 | } |
Hanumantha Reddy Pothula | 1b6eb2f | 2015-11-30 20:50:23 +0530 | [diff] [blame] | 2904 | case eWNI_SME_DISCONNECT_DONE_IND: |
| 2905 | pDisConDoneInd = (tSirSmeDisConDoneInd *)(pMsg); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 2906 | |
Hanumantha Reddy Pothula | 1b6eb2f | 2015-11-30 20:50:23 +0530 | [diff] [blame] | 2907 | smsLog( pMac, LOG1, |
| 2908 | FL("eWNI_SME_DISCONNECT_DONE_IND RC:%d"), |
| 2909 | pDisConDoneInd->reasonCode); |
| 2910 | if( CSR_IS_SESSION_VALID(pMac, pDisConDoneInd->sessionId)) |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 2911 | { |
Hanumantha Reddy Pothula | 1b6eb2f | 2015-11-30 20:50:23 +0530 | [diff] [blame] | 2912 | roamInfo.reasonCode = pDisConDoneInd->reasonCode; |
| 2913 | roamInfo.statusCode = eSIR_SME_STA_DISASSOCIATED; |
| 2914 | vos_mem_copy(roamInfo.peerMac, pDisConDoneInd->peerMacAddr, |
| 2915 | sizeof(tSirMacAddr)); |
| 2916 | status = csrRoamCallCallback(pMac, |
| 2917 | pDisConDoneInd->sessionId, |
| 2918 | &roamInfo, 0, |
| 2919 | eCSR_ROAM_LOSTLINK, |
| 2920 | eCSR_ROAM_RESULT_DISASSOC_IND); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 2921 | } |
| 2922 | else |
| 2923 | { |
Hanumantha Reddy Pothula | 1b6eb2f | 2015-11-30 20:50:23 +0530 | [diff] [blame] | 2924 | smsLog(pMac, LOGE, FL("Inactive session %d"), |
| 2925 | pDisConDoneInd->sessionId); |
| 2926 | status = eHAL_STATUS_FAILURE; |
| 2927 | } |
| 2928 | break; |
| 2929 | |
| 2930 | default : |
| 2931 | if( csrIsAnySessionInConnectState( pMac ) ) |
| 2932 | { |
| 2933 | /*In case of we are connected, we need to check whether connect |
| 2934 | * status changes because scan may also run while connected. |
| 2935 | */ |
| 2936 | csrRoamCheckForLinkStatusChange( pMac, (tSirSmeRsp *)pMsgBuf ); |
| 2937 | } |
| 2938 | else |
| 2939 | { |
| 2940 | smsLog( pMac, LOGW, |
| 2941 | "Message [0x%04x] received in state, when expecting Scan Response", |
| 2942 | pMsg->type ); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 2943 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2944 | } |
| 2945 | } |
| 2946 | |
| 2947 | return (status); |
| 2948 | } |
| 2949 | |
| 2950 | |
| 2951 | |
| 2952 | void csrCheckNSaveWscIe(tpAniSirGlobal pMac, tSirBssDescription *pNewBssDescr, tSirBssDescription *pOldBssDescr) |
| 2953 | { |
| 2954 | int idx, len; |
| 2955 | tANI_U8 *pbIe; |
| 2956 | |
| 2957 | //If failed to remove, assuming someone else got it. |
| 2958 | if((pNewBssDescr->fProbeRsp != pOldBssDescr->fProbeRsp) && |
| 2959 | (0 == pNewBssDescr->WscIeLen)) |
| 2960 | { |
| 2961 | idx = 0; |
| 2962 | len = pOldBssDescr->length - sizeof(tSirBssDescription) + |
| 2963 | sizeof(tANI_U16) + sizeof(tANI_U32) - DOT11F_IE_WSCPROBERES_MIN_LEN - 2; |
| 2964 | pbIe = (tANI_U8 *)pOldBssDescr->ieFields; |
| 2965 | //Save WPS IE if it exists |
| 2966 | pNewBssDescr->WscIeLen = 0; |
| 2967 | while(idx < len) |
| 2968 | { |
| 2969 | if((DOT11F_EID_WSCPROBERES == pbIe[0]) && |
| 2970 | (0x00 == pbIe[2]) && (0x50 == pbIe[3]) && (0xf2 == pbIe[4]) && (0x04 == pbIe[5])) |
| 2971 | { |
| 2972 | //Founrd it |
| 2973 | if((DOT11F_IE_WSCPROBERES_MAX_LEN - 2) >= pbIe[1]) |
| 2974 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 2975 | vos_mem_copy(pNewBssDescr->WscIeProbeRsp, pbIe, pbIe[1] + 2); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2976 | pNewBssDescr->WscIeLen = pbIe[1] + 2; |
| 2977 | } |
| 2978 | break; |
| 2979 | } |
| 2980 | idx += pbIe[1] + 2; |
| 2981 | pbIe += pbIe[1] + 2; |
| 2982 | } |
| 2983 | } |
| 2984 | } |
| 2985 | |
| 2986 | |
| 2987 | |
| 2988 | //pIes may be NULL |
| 2989 | tANI_BOOLEAN csrRemoveDupBssDescription( tpAniSirGlobal pMac, tSirBssDescription *pSirBssDescr, |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 2990 | tDot11fBeaconIEs *pIes, tAniSSID *pSsid, v_TIME_t *timer, tANI_BOOLEAN fForced ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2991 | { |
| 2992 | tListElem *pEntry; |
| 2993 | |
| 2994 | tCsrScanResult *pBssDesc; |
| 2995 | tANI_BOOLEAN fRC = FALSE; |
| 2996 | |
| 2997 | // Walk through all the chained BssDescriptions. If we find a chained BssDescription that |
| 2998 | // matches the BssID of the BssDescription passed in, then these must be duplicate scan |
| 2999 | // results for this Bss. In that case, remove the 'old' Bss description from the linked list. |
| 3000 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_LOCK ); |
| 3001 | |
| 3002 | while( pEntry ) |
| 3003 | { |
| 3004 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 3005 | |
| 3006 | // we have a duplicate scan results only when BSSID, SSID, Channel and NetworkType |
| 3007 | // matches |
| 3008 | if ( csrIsDuplicateBssDescription( pMac, &pBssDesc->Result.BssDescriptor, |
Tushnim Bhattacharyya | 5128d75 | 2013-06-26 23:23:18 -0700 | [diff] [blame] | 3009 | pSirBssDescr, pIes, fForced ) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3010 | { |
| 3011 | pSirBssDescr->rssi = (tANI_S8)( (((tANI_S32)pSirBssDescr->rssi * CSR_SCAN_RESULT_RSSI_WEIGHT ) + |
| 3012 | ((tANI_S32)pBssDesc->Result.BssDescriptor.rssi * (100 - CSR_SCAN_RESULT_RSSI_WEIGHT) )) / 100 ); |
| 3013 | // Remove the 'old' entry from the list.... |
| 3014 | if( csrLLRemoveEntry( &pMac->scan.scanResultList, pEntry, LL_ACCESS_LOCK ) ) |
| 3015 | { |
| 3016 | // !we need to free the memory associated with this node |
| 3017 | //If failed to remove, assuming someone else got it. |
| 3018 | *pSsid = pBssDesc->Result.ssId; |
| 3019 | *timer = pBssDesc->Result.timer; |
| 3020 | csrCheckNSaveWscIe(pMac, pSirBssDescr, &pBssDesc->Result.BssDescriptor); |
| 3021 | |
| 3022 | csrFreeScanResultEntry( pMac, pBssDesc ); |
| 3023 | } |
| 3024 | else |
| 3025 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 3026 | smsLog( pMac, LOGW, FL( " fail to remove entry" ) ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3027 | } |
| 3028 | fRC = TRUE; |
| 3029 | |
| 3030 | // If we found a match, we can stop looking through the list. |
| 3031 | break; |
| 3032 | } |
| 3033 | |
| 3034 | pEntry = csrLLNext( &pMac->scan.scanResultList, pEntry, LL_ACCESS_LOCK ); |
| 3035 | } |
| 3036 | |
| 3037 | return fRC; |
| 3038 | } |
| 3039 | |
| 3040 | |
| 3041 | eHalStatus csrAddPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId, |
| 3042 | tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes ) |
| 3043 | { |
| 3044 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 3045 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 3046 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 3047 | if(!pSession) |
| 3048 | { |
| 3049 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 3050 | return eHAL_STATUS_FAILURE; |
| 3051 | } |
| 3052 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 3053 | smsLog(pMac, LOGW, "csrAddPMKIDCandidateList called pMac->scan.NumPmkidCandidate = %d", pSession->NumPmkidCandidate); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3054 | if( pIes ) |
| 3055 | { |
| 3056 | // check if this is a RSN BSS |
| 3057 | if( pIes->RSN.present ) |
| 3058 | { |
| 3059 | // Check if the BSS is capable of doing pre-authentication |
| 3060 | if( pSession->NumPmkidCandidate < CSR_MAX_PMKID_ALLOWED ) |
| 3061 | { |
| 3062 | |
| 3063 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 3064 | { |
| 3065 | WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3066 | vos_mem_set(&secEvent, sizeof(vos_event_wlan_security_payload_type), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3067 | secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_CANDIDATE_FOUND; |
| 3068 | secEvent.encryptionModeMulticast = |
| 3069 | (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType); |
| 3070 | secEvent.encryptionModeUnicast = |
| 3071 | (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3072 | vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3073 | secEvent.authMode = |
| 3074 | (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType); |
| 3075 | WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY); |
| 3076 | } |
| 3077 | #endif//#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 3078 | |
| 3079 | // if yes, then add to PMKIDCandidateList |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3080 | vos_mem_copy(pSession->PmkidCandidateInfo[pSession->NumPmkidCandidate].BSSID, |
| 3081 | pBssDesc->bssId, WNI_CFG_BSSID_LEN); |
| 3082 | // Bit 0 offirst byte - PreAuthentication Capability |
| 3083 | if ( (pIes->RSN.RSN_Cap[0] >> 0) & 0x1 ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3084 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3085 | pSession->PmkidCandidateInfo[pSession->NumPmkidCandidate].preAuthSupported |
| 3086 | = eANI_BOOLEAN_TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3087 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3088 | else |
| 3089 | { |
| 3090 | pSession->PmkidCandidateInfo[pSession->NumPmkidCandidate].preAuthSupported |
| 3091 | = eANI_BOOLEAN_FALSE; |
| 3092 | } |
| 3093 | pSession->NumPmkidCandidate++; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3094 | } |
| 3095 | else |
| 3096 | { |
| 3097 | status = eHAL_STATUS_FAILURE; |
| 3098 | } |
| 3099 | } |
| 3100 | } |
| 3101 | |
| 3102 | return (status); |
| 3103 | } |
| 3104 | |
| 3105 | //This function checks whether new AP is found for the current connected profile |
| 3106 | //If it is found, it return the sessionId, else it return invalid sessionID |
| 3107 | tANI_U32 csrProcessBSSDescForPMKIDList(tpAniSirGlobal pMac, |
| 3108 | tSirBssDescription *pBssDesc, |
| 3109 | tDot11fBeaconIEs *pIes) |
| 3110 | { |
| 3111 | tANI_U32 i, bRet = CSR_SESSION_ID_INVALID; |
| 3112 | tCsrRoamSession *pSession; |
| 3113 | tDot11fBeaconIEs *pIesLocal = pIes; |
| 3114 | |
| 3115 | if( pIesLocal || HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal)) ) |
| 3116 | { |
| 3117 | for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ ) |
| 3118 | { |
| 3119 | if( CSR_IS_SESSION_VALID( pMac, i ) ) |
| 3120 | { |
| 3121 | pSession = CSR_GET_SESSION( pMac, i ); |
| 3122 | if( csrIsConnStateConnectedInfra( pMac, i ) && |
| 3123 | ( eCSR_AUTH_TYPE_RSN == pSession->connectedProfile.AuthType ) ) |
| 3124 | { |
| 3125 | if(csrMatchBSSToConnectProfile(pMac, &pSession->connectedProfile, pBssDesc, pIesLocal)) |
| 3126 | { |
| 3127 | //this new BSS fits the current profile connected |
| 3128 | if(HAL_STATUS_SUCCESS(csrAddPMKIDCandidateList(pMac, i, pBssDesc, pIesLocal))) |
| 3129 | { |
| 3130 | bRet = i; |
| 3131 | } |
| 3132 | break; |
| 3133 | } |
| 3134 | } |
| 3135 | } |
| 3136 | } |
| 3137 | if( !pIes ) |
| 3138 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3139 | vos_mem_free(pIesLocal); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3140 | } |
| 3141 | } |
| 3142 | |
| 3143 | return (tANI_U8)bRet; |
| 3144 | } |
| 3145 | |
| 3146 | #ifdef FEATURE_WLAN_WAPI |
| 3147 | eHalStatus csrAddBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId, |
| 3148 | tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes ) |
| 3149 | { |
| 3150 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 3151 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 3152 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 3153 | if(!pSession) |
| 3154 | { |
| 3155 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 3156 | return eHAL_STATUS_FAILURE; |
| 3157 | } |
| 3158 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3159 | smsLog(pMac, LOGW, "csrAddBKIDCandidateList called pMac->scan.NumBkidCandidate = %d", |
| 3160 | pSession->NumBkidCandidate); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3161 | if( pIes ) |
| 3162 | { |
| 3163 | // check if this is a WAPI BSS |
| 3164 | if( pIes->WAPI.present ) |
| 3165 | { |
| 3166 | // Check if the BSS is capable of doing pre-authentication |
| 3167 | if( pSession->NumBkidCandidate < CSR_MAX_BKID_ALLOWED ) |
| 3168 | { |
| 3169 | |
| 3170 | // if yes, then add to BKIDCandidateList |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3171 | vos_mem_copy(pSession->BkidCandidateInfo[pSession->NumBkidCandidate].BSSID, |
| 3172 | pBssDesc->bssId, WNI_CFG_BSSID_LEN); |
| 3173 | if ( pIes->WAPI.preauth ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3174 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3175 | pSession->BkidCandidateInfo[pSession->NumBkidCandidate].preAuthSupported |
| 3176 | = eANI_BOOLEAN_TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3177 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3178 | else |
| 3179 | { |
| 3180 | pSession->BkidCandidateInfo[pSession->NumBkidCandidate].preAuthSupported |
| 3181 | = eANI_BOOLEAN_FALSE; |
| 3182 | } |
| 3183 | pSession->NumBkidCandidate++; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3184 | } |
| 3185 | else |
| 3186 | { |
| 3187 | status = eHAL_STATUS_FAILURE; |
| 3188 | } |
| 3189 | } |
| 3190 | } |
| 3191 | |
| 3192 | return (status); |
| 3193 | } |
| 3194 | |
| 3195 | //This function checks whether new AP is found for the current connected profile |
| 3196 | //if so add to BKIDCandidateList |
| 3197 | tANI_BOOLEAN csrProcessBSSDescForBKIDList(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc, |
| 3198 | tDot11fBeaconIEs *pIes) |
| 3199 | { |
| 3200 | tANI_BOOLEAN fRC = FALSE; |
| 3201 | tDot11fBeaconIEs *pIesLocal = pIes; |
| 3202 | tANI_U32 sessionId; |
| 3203 | tCsrRoamSession *pSession; |
| 3204 | |
| 3205 | if( pIesLocal || HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal)) ) |
| 3206 | { |
| 3207 | for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ ) |
| 3208 | { |
| 3209 | if( CSR_IS_SESSION_VALID( pMac, sessionId) ) |
| 3210 | { |
| 3211 | pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 3212 | if( csrIsConnStateConnectedInfra( pMac, sessionId ) && |
| 3213 | eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == pSession->connectedProfile.AuthType) |
| 3214 | { |
| 3215 | if(csrMatchBSSToConnectProfile(pMac, &pSession->connectedProfile,pBssDesc, pIesLocal)) |
| 3216 | { |
| 3217 | //this new BSS fits the current profile connected |
| 3218 | if(HAL_STATUS_SUCCESS(csrAddBKIDCandidateList(pMac, sessionId, pBssDesc, pIesLocal))) |
| 3219 | { |
| 3220 | fRC = TRUE; |
| 3221 | } |
| 3222 | } |
| 3223 | } |
| 3224 | } |
| 3225 | } |
| 3226 | if(!pIes) |
| 3227 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3228 | vos_mem_free(pIesLocal); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3229 | } |
| 3230 | |
| 3231 | } |
| 3232 | return fRC; |
| 3233 | } |
| 3234 | |
| 3235 | #endif |
| 3236 | |
| 3237 | |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 3238 | static void csrMoveTempScanResultsToMainList( tpAniSirGlobal pMac, tANI_U8 reason ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3239 | { |
| 3240 | tListElem *pEntry; |
| 3241 | tCsrScanResult *pBssDescription; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3242 | tANI_BOOLEAN fDupBss; |
| 3243 | #ifdef FEATURE_WLAN_WAPI |
| 3244 | tANI_BOOLEAN fNewWapiBSSForCurConnection = eANI_BOOLEAN_FALSE; |
| 3245 | #endif /* FEATURE_WLAN_WAPI */ |
| 3246 | tDot11fBeaconIEs *pIesLocal = NULL; |
| 3247 | tANI_U32 sessionId = CSR_SESSION_ID_INVALID; |
| 3248 | tAniSSID tmpSsid; |
| 3249 | v_TIME_t timer=0; |
| 3250 | |
| 3251 | tmpSsid.length = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3252 | |
| 3253 | // remove the BSS descriptions from temporary list |
| 3254 | while( ( pEntry = csrLLRemoveTail( &pMac->scan.tempScanResults, LL_ACCESS_LOCK ) ) != NULL) |
| 3255 | { |
| 3256 | pBssDescription = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 3257 | |
Vinay Krishna Eranna | 566365f | 2015-03-09 12:34:13 +0530 | [diff] [blame] | 3258 | smsLog( pMac, LOG2, "...Bssid= "MAC_ADDRESS_STR" chan= %d, rssi = -%d", |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 3259 | MAC_ADDR_ARRAY(pBssDescription->Result.BssDescriptor.bssId), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3260 | pBssDescription->Result.BssDescriptor.channelId, |
| 3261 | pBssDescription->Result.BssDescriptor.rssi * (-1) ); |
| 3262 | |
| 3263 | //At this time, pBssDescription->Result.pvIes may be NULL |
| 3264 | pIesLocal = (tDot11fBeaconIEs *)( pBssDescription->Result.pvIes ); |
| 3265 | if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pBssDescription->Result.BssDescriptor, &pIesLocal))) ) |
| 3266 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 3267 | smsLog(pMac, LOGE, FL(" Cannot pared IEs")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3268 | csrFreeScanResultEntry(pMac, pBssDescription); |
| 3269 | continue; |
| 3270 | } |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 3271 | fDupBss = csrRemoveDupBssDescription( pMac, &pBssDescription->Result.BssDescriptor, pIesLocal, &tmpSsid, &timer, FALSE ); |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 3272 | //Check whether we have reach out limit, but don't lose the LFR candidates came from FW |
| 3273 | if( CSR_SCAN_IS_OVER_BSS_LIMIT(pMac) |
| 3274 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 3275 | && !( eCsrScanGetLfrResult == reason ) |
| 3276 | #endif |
| 3277 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3278 | { |
| 3279 | //Limit reach |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 3280 | smsLog(pMac, LOGW, FL(" BSS limit reached")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3281 | //Free the resources |
| 3282 | if( (pBssDescription->Result.pvIes == NULL) && pIesLocal ) |
| 3283 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3284 | vos_mem_free(pIesLocal); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3285 | } |
| 3286 | csrFreeScanResultEntry(pMac, pBssDescription); |
| 3287 | //Continue because there may be duplicated BSS |
| 3288 | continue; |
| 3289 | } |
| 3290 | // check for duplicate scan results |
| 3291 | if ( !fDupBss ) |
| 3292 | { |
| 3293 | //Found a new BSS |
| 3294 | sessionId = csrProcessBSSDescForPMKIDList(pMac, |
| 3295 | &pBssDescription->Result.BssDescriptor, pIesLocal); |
| 3296 | if( CSR_SESSION_ID_INVALID != sessionId) |
| 3297 | { |
| 3298 | csrRoamCallCallback(pMac, sessionId, NULL, 0, |
| 3299 | eCSR_ROAM_SCAN_FOUND_NEW_BSS, eCSR_ROAM_RESULT_NONE); |
| 3300 | } |
| 3301 | } |
| 3302 | else |
| 3303 | { |
| 3304 | //Check if the new one has SSID it it, if not, use the older SSID if it exists. |
| 3305 | if( (0 == pBssDescription->Result.ssId.length) && tmpSsid.length ) |
| 3306 | { |
| 3307 | //New BSS has a hidden SSID and old one has the SSID. Keep the SSID only |
| 3308 | //if diff of saved SSID time and current time is less than 1 min to avoid |
| 3309 | //side effect of saving SSID with old one is that if AP changes its SSID while remain |
| 3310 | //hidden, we may never see it and also to address the requirement of |
| 3311 | //When we remove hidden ssid from the profile i.e., forget the SSID via |
| 3312 | // GUI that SSID shouldn't see in the profile |
| 3313 | if( (vos_timer_get_system_time() - timer) <= HIDDEN_TIMER) |
| 3314 | { |
| 3315 | pBssDescription->Result.timer = timer; |
| 3316 | pBssDescription->Result.ssId = tmpSsid; |
| 3317 | } |
| 3318 | } |
| 3319 | } |
| 3320 | |
Agarwal Ashish | d9d7260 | 2013-09-13 00:06:17 +0530 | [diff] [blame] | 3321 | //Find a good AP for 11d info |
| 3322 | if ( csrIs11dSupported( pMac ) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3323 | { |
Agrawal Ashish | 0b6984f | 2014-04-05 18:35:45 +0530 | [diff] [blame] | 3324 | // check if country information element is present |
| 3325 | if (pIesLocal->Country.present) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3326 | { |
Agrawal Ashish | 0b6984f | 2014-04-05 18:35:45 +0530 | [diff] [blame] | 3327 | csrAddVoteForCountryInfo(pMac, pIesLocal->Country.country); |
| 3328 | smsLog(pMac, LOGW, FL("11d AP Bssid " MAC_ADDRESS_STR |
| 3329 | " chan= %d, rssi = -%d, countryCode %c%c"), |
| 3330 | MAC_ADDR_ARRAY( pBssDescription->Result.BssDescriptor.bssId), |
| 3331 | pBssDescription->Result.BssDescriptor.channelId, |
| 3332 | pBssDescription->Result.BssDescriptor.rssi * (-1), |
| 3333 | pIesLocal->Country.country[0],pIesLocal->Country.country[1] ); |
| 3334 | } |
Agarwal Ashish | d9d7260 | 2013-09-13 00:06:17 +0530 | [diff] [blame] | 3335 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3336 | } |
Madan Mohan Koyyalamudi | 527935a | 2012-12-04 16:41:16 -0800 | [diff] [blame] | 3337 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3338 | // append to main list |
| 3339 | csrScanAddResult(pMac, pBssDescription, pIesLocal); |
Agarwal Ashish | d9d7260 | 2013-09-13 00:06:17 +0530 | [diff] [blame] | 3340 | if ( (pBssDescription->Result.pvIes == NULL) && pIesLocal ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3341 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3342 | vos_mem_free(pIesLocal); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3343 | } |
| 3344 | } |
| 3345 | |
Sushant Kaushik | 6274de6 | 2015-05-01 16:31:23 +0530 | [diff] [blame] | 3346 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_LOCK ); |
| 3347 | if (pEntry && 0 != pMac->scan.scanResultCfgAgingTime) |
| 3348 | csrScanStartResultCfgAgingTimer(pMac); |
Tushnim Bhattacharyya | ae31777 | 2013-10-23 18:55:38 -0700 | [diff] [blame] | 3349 | //we don't need to update CC while connected to an AP which is advertising CC already |
| 3350 | if (csrIs11dSupported(pMac)) |
| 3351 | { |
| 3352 | tANI_U32 i; |
| 3353 | tCsrRoamSession *pSession; |
| 3354 | |
| 3355 | for (i = 0; i < CSR_ROAM_SESSION_MAX; i++ ) |
| 3356 | { |
| 3357 | if (CSR_IS_SESSION_VALID( pMac, i ) ) |
| 3358 | { |
| 3359 | pSession = CSR_GET_SESSION( pMac, i ); |
| 3360 | if (csrIsConnStateConnected(pMac, i)) |
| 3361 | { |
Agrawal Ashish | 0b6984f | 2014-04-05 18:35:45 +0530 | [diff] [blame] | 3362 | smsLog(pMac, LOGW, FL("No need for updating CC in" |
| 3363 | "connected state")); |
| 3364 | goto end; |
Tushnim Bhattacharyya | ae31777 | 2013-10-23 18:55:38 -0700 | [diff] [blame] | 3365 | } |
| 3366 | } |
| 3367 | } |
Agrawal Ashish | 0b6984f | 2014-04-05 18:35:45 +0530 | [diff] [blame] | 3368 | csrElectedCountryInfo(pMac); |
Chandrasekaran, Manishekar | 90c4932 | 2014-06-24 13:26:14 +0530 | [diff] [blame] | 3369 | csrLearnCountryInformation( pMac, NULL, NULL, eANI_BOOLEAN_TRUE ); |
Agarwal Ashish | d9d7260 | 2013-09-13 00:06:17 +0530 | [diff] [blame] | 3370 | } |
| 3371 | |
Tushnim Bhattacharyya | ae31777 | 2013-10-23 18:55:38 -0700 | [diff] [blame] | 3372 | end: |
| 3373 | //If we can find the current 11d info in any of the scan results, or |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3374 | // a good enough AP with the 11d info from the scan results then no need to |
| 3375 | // get into ambiguous state |
| 3376 | if(pMac->scan.fAmbiguous11dInfoFound) |
| 3377 | { |
Agrawal Ashish | 0b6984f | 2014-04-05 18:35:45 +0530 | [diff] [blame] | 3378 | if((pMac->scan.fCurrent11dInfoMatch)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3379 | { |
| 3380 | pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE; |
| 3381 | } |
| 3382 | } |
| 3383 | |
| 3384 | #ifdef FEATURE_WLAN_WAPI |
| 3385 | if(fNewWapiBSSForCurConnection) |
| 3386 | { |
| 3387 | //remember it first |
| 3388 | csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_SCAN_FOUND_NEW_BSS, eCSR_ROAM_RESULT_NEW_WAPI_BSS); |
| 3389 | } |
| 3390 | #endif /* FEATURE_WLAN_WAPI */ |
| 3391 | |
| 3392 | return; |
| 3393 | } |
| 3394 | |
| 3395 | |
| 3396 | static tCsrScanResult *csrScanSaveBssDescription( tpAniSirGlobal pMac, tSirBssDescription *pBSSDescription, |
| 3397 | tDot11fBeaconIEs *pIes) |
| 3398 | { |
| 3399 | tCsrScanResult *pCsrBssDescription = NULL; |
| 3400 | tANI_U32 cbBSSDesc; |
| 3401 | tANI_U32 cbAllocated; |
Sushant Kaushik | 6274de6 | 2015-05-01 16:31:23 +0530 | [diff] [blame] | 3402 | tListElem *pEntry; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3403 | |
| 3404 | // figure out how big the BSS description is (the BSSDesc->length does NOT |
| 3405 | // include the size of the length field itself). |
| 3406 | cbBSSDesc = pBSSDescription->length + sizeof( pBSSDescription->length ); |
| 3407 | |
| 3408 | cbAllocated = sizeof( tCsrScanResult ) + cbBSSDesc; |
| 3409 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3410 | pCsrBssDescription = vos_mem_malloc(cbAllocated); |
| 3411 | if ( NULL != pCsrBssDescription ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3412 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3413 | vos_mem_set(pCsrBssDescription, cbAllocated, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3414 | pCsrBssDescription->AgingCount = (tANI_S32)pMac->roam.configParam.agingCount; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3415 | vos_mem_copy(&pCsrBssDescription->Result.BssDescriptor, pBSSDescription, cbBSSDesc); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3416 | #if defined(VOSS_ENSBALED) |
| 3417 | VOS_ASSERT( pCsrBssDescription->Result.pvIes == NULL ); |
| 3418 | #endif |
| 3419 | csrScanAddResult(pMac, pCsrBssDescription, pIes); |
Sushant Kaushik | 6274de6 | 2015-05-01 16:31:23 +0530 | [diff] [blame] | 3420 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_LOCK ); |
| 3421 | if (pEntry && 0 != pMac->scan.scanResultCfgAgingTime) |
| 3422 | csrScanStartResultCfgAgingTimer(pMac); |
| 3423 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3424 | } |
| 3425 | |
| 3426 | return( pCsrBssDescription ); |
| 3427 | } |
| 3428 | |
| 3429 | // Append a Bss Description... |
| 3430 | tCsrScanResult *csrScanAppendBssDescription( tpAniSirGlobal pMac, |
| 3431 | tSirBssDescription *pSirBssDescription, |
Tushnim Bhattacharyya | 5128d75 | 2013-06-26 23:23:18 -0700 | [diff] [blame] | 3432 | tDot11fBeaconIEs *pIes, tANI_BOOLEAN fForced ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3433 | { |
| 3434 | tCsrScanResult *pCsrBssDescription = NULL; |
| 3435 | tAniSSID tmpSsid; |
| 3436 | v_TIME_t timer = 0; |
| 3437 | int result; |
| 3438 | |
| 3439 | tmpSsid.length = 0; |
Tushnim Bhattacharyya | 5128d75 | 2013-06-26 23:23:18 -0700 | [diff] [blame] | 3440 | result = csrRemoveDupBssDescription( pMac, pSirBssDescription, pIes, &tmpSsid, &timer, fForced ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3441 | pCsrBssDescription = csrScanSaveBssDescription( pMac, pSirBssDescription, pIes ); |
| 3442 | if (result && (pCsrBssDescription != NULL)) |
| 3443 | { |
| 3444 | //Check if the new one has SSID it it, if not, use the older SSID if it exists. |
| 3445 | if( (0 == pCsrBssDescription->Result.ssId.length) && tmpSsid.length ) |
| 3446 | { |
| 3447 | //New BSS has a hidden SSID and old one has the SSID. Keep the SSID only |
| 3448 | //if diff of saved SSID time and current time is less than 1 min to avoid |
| 3449 | //side effect of saving SSID with old one is that if AP changes its SSID while remain |
| 3450 | //hidden, we may never see it and also to address the requirement of |
| 3451 | //When we remove hidden ssid from the profile i.e., forget the SSID via |
| 3452 | // GUI that SSID shouldn't see in the profile |
| 3453 | if((vos_timer_get_system_time()-timer) <= HIDDEN_TIMER) |
| 3454 | { |
| 3455 | pCsrBssDescription->Result.ssId = tmpSsid; |
| 3456 | pCsrBssDescription->Result.timer = timer; |
| 3457 | } |
| 3458 | } |
| 3459 | } |
| 3460 | |
| 3461 | |
| 3462 | return( pCsrBssDescription ); |
| 3463 | } |
| 3464 | |
| 3465 | |
| 3466 | |
| 3467 | void csrPurgeChannelPower( tpAniSirGlobal pMac, tDblLinkList *pChannelList ) |
| 3468 | { |
| 3469 | tCsrChannelPowerInfo *pChannelSet; |
| 3470 | tListElem *pEntry; |
| 3471 | |
| 3472 | csrLLLock(pChannelList); |
| 3473 | // Remove the channel sets from the learned list and put them in the free list |
| 3474 | while( ( pEntry = csrLLRemoveHead( pChannelList, LL_ACCESS_NOLOCK ) ) != NULL) |
| 3475 | { |
| 3476 | pChannelSet = GET_BASE_ADDR( pEntry, tCsrChannelPowerInfo, link ); |
| 3477 | if( pChannelSet ) |
| 3478 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3479 | vos_mem_free(pChannelSet); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3480 | } |
| 3481 | } |
| 3482 | csrLLUnlock(pChannelList); |
| 3483 | return; |
| 3484 | } |
| 3485 | |
| 3486 | |
| 3487 | /* |
| 3488 | * Save the channelList into the ultimate storage as the final stage of channel |
| 3489 | * Input: pCountryInfo -- the country code (e.g. "USI"), channel list, and power limit are all stored inside this data structure |
| 3490 | */ |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3491 | eHalStatus csrSaveToChannelPower2G_5G( tpAniSirGlobal pMac, tANI_U32 tableSize, tSirMacChanInfo *channelTable ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3492 | { |
| 3493 | tANI_U32 i = tableSize / sizeof( tSirMacChanInfo ); |
| 3494 | tSirMacChanInfo *pChannelInfo; |
| 3495 | tCsrChannelPowerInfo *pChannelSet; |
| 3496 | tANI_BOOLEAN f2GHzInfoFound = FALSE; |
| 3497 | tANI_BOOLEAN f2GListPurged = FALSE, f5GListPurged = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3498 | |
| 3499 | pChannelInfo = channelTable; |
| 3500 | // atleast 3 bytes have to be remaining -- from "countryString" |
| 3501 | while ( i-- ) |
| 3502 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3503 | pChannelSet = vos_mem_malloc(sizeof(tCsrChannelPowerInfo)); |
| 3504 | if ( NULL != pChannelSet ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3505 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3506 | vos_mem_set(pChannelSet, sizeof(tCsrChannelPowerInfo), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3507 | pChannelSet->firstChannel = pChannelInfo->firstChanNum; |
| 3508 | pChannelSet->numChannels = pChannelInfo->numChannels; |
| 3509 | |
| 3510 | // 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] | 3511 | if( (CSR_IS_CHANNEL_24GHZ(pChannelSet->firstChannel)) && |
Madan Mohan Koyyalamudi | 5904d7c | 2012-09-24 13:49:03 -0700 | [diff] [blame] | 3512 | ((pChannelSet->firstChannel + (pChannelSet->numChannels - 1)) <= CSR_MAX_24GHz_CHANNEL_NUMBER) ) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3513 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3514 | { |
| 3515 | pChannelSet->interChannelOffset = 1; |
| 3516 | f2GHzInfoFound = TRUE; |
| 3517 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3518 | else if ( (CSR_IS_CHANNEL_5GHZ(pChannelSet->firstChannel)) && |
Madan Mohan Koyyalamudi | 5904d7c | 2012-09-24 13:49:03 -0700 | [diff] [blame] | 3519 | ((pChannelSet->firstChannel + ((pChannelSet->numChannels - 1) * 4)) <= CSR_MAX_5GHz_CHANNEL_NUMBER) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3520 | { |
| 3521 | pChannelSet->interChannelOffset = 4; |
| 3522 | f2GHzInfoFound = FALSE; |
| 3523 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3524 | else |
| 3525 | { |
Madan Mohan Koyyalamudi | 5904d7c | 2012-09-24 13:49:03 -0700 | [diff] [blame] | 3526 | smsLog( pMac, LOGW, FL("Invalid Channel %d Present in Country IE"), |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3527 | pChannelSet->firstChannel); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3528 | vos_mem_free(pChannelSet); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3529 | return eHAL_STATUS_FAILURE; |
| 3530 | } |
| 3531 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3532 | pChannelSet->txPower = CSR_ROAM_MIN( pChannelInfo->maxTxPower, pMac->roam.configParam.nTxPowerCap ); |
| 3533 | |
| 3534 | if( f2GHzInfoFound ) |
| 3535 | { |
| 3536 | if( !f2GListPurged ) |
| 3537 | { |
| 3538 | // purge previous results if found new |
| 3539 | csrPurgeChannelPower( pMac, &pMac->scan.channelPowerInfoList24 ); |
| 3540 | f2GListPurged = TRUE; |
| 3541 | } |
| 3542 | |
| 3543 | if(CSR_IS_OPERATING_BG_BAND(pMac)) |
| 3544 | { |
| 3545 | // add to the list of 2.4 GHz channel sets |
| 3546 | csrLLInsertTail( &pMac->scan.channelPowerInfoList24, &pChannelSet->link, LL_ACCESS_LOCK ); |
| 3547 | } |
| 3548 | else { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 3549 | 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] | 3550 | pChannelSet->firstChannel); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3551 | vos_mem_free(pChannelSet); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3552 | } |
| 3553 | } |
| 3554 | else |
| 3555 | { |
| 3556 | // 5GHz info found |
| 3557 | if( !f5GListPurged ) |
| 3558 | { |
| 3559 | // purge previous results if found new |
| 3560 | csrPurgeChannelPower( pMac, &pMac->scan.channelPowerInfoList5G ); |
| 3561 | f5GListPurged = TRUE; |
| 3562 | } |
| 3563 | |
| 3564 | if(CSR_IS_OPERATING_A_BAND(pMac)) |
| 3565 | { |
| 3566 | // add to the list of 5GHz channel sets |
| 3567 | csrLLInsertTail( &pMac->scan.channelPowerInfoList5G, &pChannelSet->link, LL_ACCESS_LOCK ); |
| 3568 | } |
| 3569 | else { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 3570 | 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] | 3571 | pChannelSet->firstChannel); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3572 | vos_mem_free(pChannelSet); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3573 | } |
| 3574 | } |
| 3575 | } |
| 3576 | |
| 3577 | pChannelInfo++; // move to next entry |
| 3578 | } |
| 3579 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3580 | return eHAL_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3581 | } |
| 3582 | |
Gopichand Nakkala | c178ac8 | 2013-05-30 19:53:39 +0530 | [diff] [blame] | 3583 | static void csrClearDfsChannelList( tpAniSirGlobal pMac ) |
| 3584 | { |
| 3585 | tSirMbMsg *pMsg; |
| 3586 | tANI_U16 msgLen; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3587 | |
Gopichand Nakkala | c178ac8 | 2013-05-30 19:53:39 +0530 | [diff] [blame] | 3588 | msgLen = (tANI_U16)(sizeof( tSirMbMsg )); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3589 | pMsg = vos_mem_malloc(msgLen); |
| 3590 | if ( NULL != pMsg ) |
Gopichand Nakkala | c178ac8 | 2013-05-30 19:53:39 +0530 | [diff] [blame] | 3591 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3592 | vos_mem_set((void *)pMsg, msgLen, 0); |
Gopichand Nakkala | c178ac8 | 2013-05-30 19:53:39 +0530 | [diff] [blame] | 3593 | pMsg->type = pal_cpu_to_be16((tANI_U16)eWNI_SME_CLEAR_DFS_CHANNEL_LIST); |
| 3594 | pMsg->msgLen = pal_cpu_to_be16(msgLen); |
| 3595 | palSendMBMessage(pMac->hHdd, pMsg); |
| 3596 | } |
| 3597 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3598 | |
| 3599 | void csrApplyPower2Current( tpAniSirGlobal pMac ) |
| 3600 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 3601 | smsLog( pMac, LOG3, FL(" Updating Cfg with power settings")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3602 | csrSaveTxPowerToCfg( pMac, &pMac->scan.channelPowerInfoList24, WNI_CFG_MAX_TX_POWER_2_4 ); |
| 3603 | csrSaveTxPowerToCfg( pMac, &pMac->scan.channelPowerInfoList5G, WNI_CFG_MAX_TX_POWER_5 ); |
| 3604 | } |
| 3605 | |
| 3606 | |
Gopichand Nakkala | b9185f2 | 2012-12-21 08:03:42 -0800 | [diff] [blame] | 3607 | void csrApplyChannelPowerCountryInfo( tpAniSirGlobal pMac, tCsrChannel *pChannelList, tANI_U8 *countryCode, tANI_BOOLEAN updateRiva) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3608 | { |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 3609 | int i, j, count, countryIndex = -1; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3610 | tANI_U8 numChannels = 0; |
| 3611 | tANI_U8 tempNumChannels = 0; |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 3612 | tANI_U8 channelIgnore = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3613 | tCsrChannel ChannelList; |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 3614 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3615 | if( pChannelList->numChannels ) |
| 3616 | { |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 3617 | for(count=0; count < MAX_COUNTRY_IGNORE; count++) |
| 3618 | { |
| 3619 | if(vos_mem_compare(countryCode, countryIgnoreList[count].countryCode, |
| 3620 | VOS_COUNTRY_CODE_LEN)) |
| 3621 | { |
| 3622 | countryIndex = count; |
| 3623 | break; |
| 3624 | } |
| 3625 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3626 | tempNumChannels = CSR_MIN(pChannelList->numChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN); |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 3627 | |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 3628 | for(i=0; i < tempNumChannels; i++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3629 | { |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 3630 | channelIgnore = FALSE; |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 3631 | if( countryIndex != -1 ) |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 3632 | { |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 3633 | for(j=0; j < countryIgnoreList[countryIndex].channelCount; j++) |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 3634 | { |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 3635 | if( pChannelList->channelList[i] == |
| 3636 | countryIgnoreList[countryIndex].channelList[j] ) |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 3637 | { |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 3638 | channelIgnore = TRUE; |
| 3639 | break; |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 3640 | } |
| 3641 | } |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 3642 | } |
| 3643 | if( FALSE == channelIgnore ) |
| 3644 | { |
| 3645 | ChannelList.channelList[numChannels] = pChannelList->channelList[i]; |
| 3646 | numChannels++; |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 3647 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3648 | } |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 3649 | ChannelList.numChannels = numChannels; |
Mahesh A Saptasagar | 1ed5958 | 2014-06-04 18:45:07 +0530 | [diff] [blame] | 3650 | csrApplyPower2Current( pMac ); // Store the channel+power info in the global place: Cfg |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3651 | csrSetCfgValidChannelList(pMac, ChannelList.channelList, ChannelList.numChannels); |
| 3652 | // extend scan capability |
Gopichand Nakkala | 10ba6fc | 2013-04-23 20:30:01 +0530 | [diff] [blame] | 3653 | // build a scan list based on the channel list : channel# + active/passive scan |
| 3654 | csrSetCfgScanControlList(pMac, countryCode, &ChannelList); |
Gopichand Nakkala | c178ac8 | 2013-05-30 19:53:39 +0530 | [diff] [blame] | 3655 | /*Send msg to Lim to clear DFS channel list */ |
| 3656 | csrClearDfsChannelList(pMac); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3657 | #ifdef FEATURE_WLAN_SCAN_PNO |
Gopichand Nakkala | b9185f2 | 2012-12-21 08:03:42 -0800 | [diff] [blame] | 3658 | if (updateRiva) |
| 3659 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 3660 | 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] | 3661 | // Send HAL UpdateScanParams message |
| 3662 | pmcUpdateScanParams(pMac, &(pMac->roam.configParam), &ChannelList, TRUE); |
| 3663 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3664 | #endif // FEATURE_WLAN_SCAN_PNO |
| 3665 | } |
| 3666 | else |
| 3667 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 3668 | smsLog( pMac, LOGE, FL(" 11D channel list is empty")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3669 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3670 | csrSetCfgCountryCode(pMac, countryCode); |
| 3671 | } |
| 3672 | |
Agarwal Ashish | 8bd53ae | 2015-06-12 18:03:45 +0530 | [diff] [blame] | 3673 | void csrUpdateFCCChannelList(tpAniSirGlobal pMac) |
| 3674 | { |
| 3675 | tCsrChannel ChannelList; |
| 3676 | tANI_U8 chnlIndx = 0; |
| 3677 | int i; |
Agarwal Ashish | 8bd53ae | 2015-06-12 18:03:45 +0530 | [diff] [blame] | 3678 | |
| 3679 | for ( i = 0; i < pMac->scan.base20MHzChannels.numChannels; i++ ) |
| 3680 | { |
| 3681 | if (pMac->scan.fcc_constraint && |
| 3682 | ((pMac->scan.base20MHzChannels.channelList[i] == 12) || |
| 3683 | (pMac->scan.base20MHzChannels.channelList[i] == 13))) |
| 3684 | { |
| 3685 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, |
| 3686 | FL("removing channel %d"), |
| 3687 | pMac->scan.base20MHzChannels.channelList[i]); |
| 3688 | continue; |
| 3689 | } |
Abhishek Singh | e7ca7e6 | 2015-10-09 15:02:17 +0530 | [diff] [blame] | 3690 | ChannelList.channelList[chnlIndx] = |
| 3691 | pMac->scan.base20MHzChannels.channelList[i]; |
Agarwal Ashish | 8bd53ae | 2015-06-12 18:03:45 +0530 | [diff] [blame] | 3692 | chnlIndx++; |
| 3693 | } |
| 3694 | csrSetCfgValidChannelList(pMac, ChannelList.channelList, chnlIndx); |
Agrawal Ashish | f92238e | 2015-12-09 17:51:53 +0530 | [diff] [blame] | 3695 | csrScanFilterResults(pMac); |
Agarwal Ashish | 8bd53ae | 2015-06-12 18:03:45 +0530 | [diff] [blame] | 3696 | |
| 3697 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3698 | |
Gopichand Nakkala | b9185f2 | 2012-12-21 08:03:42 -0800 | [diff] [blame] | 3699 | void csrResetCountryInformation( tpAniSirGlobal pMac, tANI_BOOLEAN fForce, tANI_BOOLEAN updateRiva ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3700 | { |
| 3701 | if( fForce || (csrIs11dSupported( pMac ) && (!pMac->scan.f11dInfoReset))) |
| 3702 | { |
| 3703 | |
| 3704 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 3705 | { |
| 3706 | vos_log_802_11d_pkt_type *p11dLog; |
| 3707 | int Index; |
| 3708 | |
| 3709 | WLAN_VOS_DIAG_LOG_ALLOC(p11dLog, vos_log_802_11d_pkt_type, LOG_WLAN_80211D_C); |
| 3710 | if(p11dLog) |
| 3711 | { |
| 3712 | p11dLog->eventId = WLAN_80211D_EVENT_RESET; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3713 | vos_mem_copy(p11dLog->countryCode, pMac->scan.countryCodeCurrent, 3); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3714 | p11dLog->numChannel = pMac->scan.base20MHzChannels.numChannels; |
| 3715 | if(p11dLog->numChannel <= VOS_LOG_MAX_NUM_CHANNEL) |
| 3716 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3717 | vos_mem_copy(p11dLog->Channels, |
| 3718 | pMac->scan.base20MHzChannels.channelList, |
| 3719 | p11dLog->numChannel); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3720 | for (Index=0; Index < pMac->scan.base20MHzChannels.numChannels; Index++) |
| 3721 | { |
| 3722 | p11dLog->TxPwr[Index] = CSR_ROAM_MIN( pMac->scan.defaultPowerTable[Index].pwr, pMac->roam.configParam.nTxPowerCap ); |
| 3723 | } |
| 3724 | } |
| 3725 | if(!pMac->roam.configParam.Is11dSupportEnabled) |
| 3726 | { |
| 3727 | p11dLog->supportMultipleDomain = WLAN_80211D_DISABLED; |
| 3728 | } |
| 3729 | else if(pMac->roam.configParam.fEnforceDefaultDomain) |
| 3730 | { |
| 3731 | p11dLog->supportMultipleDomain = WLAN_80211D_NOT_SUPPORT_MULTI_DOMAIN; |
| 3732 | } |
| 3733 | else |
| 3734 | { |
| 3735 | p11dLog->supportMultipleDomain = WLAN_80211D_SUPPORT_MULTI_DOMAIN; |
| 3736 | } |
| 3737 | WLAN_VOS_DIAG_LOG_REPORT(p11dLog); |
| 3738 | } |
| 3739 | } |
| 3740 | #endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 3741 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3742 | csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels); |
| 3743 | csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels); |
| 3744 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3745 | csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE); |
| 3746 | csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE); |
| 3747 | // ... and apply the channel list, power settings, and the country code. |
Gopichand Nakkala | b9185f2 | 2012-12-21 08:03:42 -0800 | [diff] [blame] | 3748 | csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, updateRiva ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3749 | // clear the 11d channel list |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3750 | vos_mem_set(&pMac->scan.channels11d, sizeof(pMac->scan.channels11d), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3751 | pMac->scan.f11dInfoReset = eANI_BOOLEAN_TRUE; |
| 3752 | pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE; |
| 3753 | } |
| 3754 | |
| 3755 | return; |
| 3756 | } |
| 3757 | |
| 3758 | |
| 3759 | eHalStatus csrResetCountryCodeInformation(tpAniSirGlobal pMac, tANI_BOOLEAN *pfRestartNeeded) |
| 3760 | { |
| 3761 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 3762 | tANI_BOOLEAN fRestart = eANI_BOOLEAN_FALSE; |
| 3763 | |
| 3764 | //Use the Country code and domain from EEPROM |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3765 | vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault, |
| 3766 | WNI_CFG_COUNTRY_CODE_LEN); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3767 | csrSetRegulatoryDomain(pMac, pMac->scan.domainIdCurrent, &fRestart); |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 3768 | if( ((eANI_BOOLEAN_FALSE == fRestart) || (pfRestartNeeded == NULL) ) |
| 3769 | && !csrIsInfraConnected(pMac)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3770 | { |
| 3771 | //Only reset the country info if we don't need to restart |
Gopichand Nakkala | b9185f2 | 2012-12-21 08:03:42 -0800 | [diff] [blame] | 3772 | csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3773 | } |
| 3774 | if(pfRestartNeeded) |
| 3775 | { |
| 3776 | *pfRestartNeeded = fRestart; |
| 3777 | } |
| 3778 | |
| 3779 | return (status); |
| 3780 | } |
| 3781 | |
Agrawal Ashish | 0b6984f | 2014-04-05 18:35:45 +0530 | [diff] [blame] | 3782 | void csrClearVotesForCountryInfo(tpAniSirGlobal pMac) |
| 3783 | { |
| 3784 | pMac->scan.countryCodeCount = 0; |
| 3785 | vos_mem_set(pMac->scan.votes11d, |
| 3786 | sizeof(tCsrVotes11d) * CSR_MAX_NUM_COUNTRY_CODE, 0); |
| 3787 | } |
| 3788 | |
| 3789 | void csrAddVoteForCountryInfo(tpAniSirGlobal pMac, tANI_U8 *pCountryCode) |
| 3790 | { |
| 3791 | tANI_BOOLEAN match = FALSE; |
| 3792 | tANI_U8 i; |
| 3793 | |
| 3794 | /* convert to UPPER here so we are assured |
| 3795 | * the strings are always in upper case. |
| 3796 | */ |
| 3797 | for( i = 0; i < 3; i++ ) |
| 3798 | { |
| 3799 | pCountryCode[ i ] = (tANI_U8)csrToUpper( pCountryCode[ i ] ); |
| 3800 | } |
| 3801 | |
| 3802 | /* Some of the 'old' Cisco 350 series AP's advertise NA as the |
| 3803 | * country code (for North America ??). NA is not a valid country code |
| 3804 | * or domain so let's allow this by changing it to the proper |
| 3805 | * country code (which is US). We've also seen some NETGEAR AP's |
| 3806 | * that have "XX " as the country code with valid 2.4 GHz US channel |
| 3807 | * information. If we cannot find the country code advertised in the |
| 3808 | * 11d information element, let's default to US. |
| 3809 | */ |
| 3810 | |
| 3811 | if ( !HAL_STATUS_SUCCESS(csrGetRegulatoryDomainForCountry( pMac, |
| 3812 | pCountryCode, NULL,COUNTRY_QUERY ) ) ) |
| 3813 | { |
| 3814 | pCountryCode[ 0 ] = '0'; |
| 3815 | pCountryCode[ 1 ] = '0'; |
| 3816 | } |
| 3817 | |
| 3818 | /* We've seen some of the AP's improperly put a 0 for the |
| 3819 | * third character of the country code. spec says valid charcters are |
| 3820 | * 'O' (for outdoor), 'I' for Indoor, or ' ' (space; for either). |
| 3821 | * if we see a 0 in this third character, let's change it to a ' '. |
| 3822 | */ |
| 3823 | if ( 0 == pCountryCode[ 2 ] ) |
| 3824 | { |
| 3825 | pCountryCode[ 2 ] = ' '; |
| 3826 | } |
| 3827 | |
| 3828 | for (i = 0; i < pMac->scan.countryCodeCount; i++) |
| 3829 | { |
| 3830 | match = (vos_mem_compare(pMac->scan.votes11d[i].countryCode, |
| 3831 | pCountryCode, 2)); |
| 3832 | if(match) |
| 3833 | { |
| 3834 | break; |
| 3835 | } |
| 3836 | } |
| 3837 | |
| 3838 | if (match) |
| 3839 | { |
| 3840 | pMac->scan.votes11d[i].votes++; |
| 3841 | } |
| 3842 | else |
| 3843 | { |
| 3844 | vos_mem_copy( pMac->scan.votes11d[pMac->scan.countryCodeCount].countryCode, |
| 3845 | pCountryCode, 3 ); |
| 3846 | pMac->scan.votes11d[pMac->scan.countryCodeCount].votes = 1; |
| 3847 | pMac->scan.countryCodeCount++; |
| 3848 | } |
| 3849 | |
| 3850 | return; |
| 3851 | } |
| 3852 | |
| 3853 | tANI_BOOLEAN csrElectedCountryInfo(tpAniSirGlobal pMac) |
| 3854 | { |
| 3855 | tANI_BOOLEAN fRet = FALSE; |
| 3856 | tANI_U8 maxVotes = 0; |
| 3857 | tANI_U8 i, j=0; |
| 3858 | |
| 3859 | if (!pMac->scan.countryCodeCount) |
| 3860 | { |
| 3861 | return fRet; |
| 3862 | } |
| 3863 | maxVotes = pMac->scan.votes11d[0].votes; |
| 3864 | fRet = TRUE; |
| 3865 | |
| 3866 | for(i = 1; i < pMac->scan.countryCodeCount; i++) |
| 3867 | { |
| 3868 | /* If we have a tie for max votes for 2 different country codes, |
| 3869 | * pick random.we can put some more intelligence - TBD |
| 3870 | */ |
| 3871 | if (maxVotes < pMac->scan.votes11d[i].votes) |
| 3872 | { |
| 3873 | VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, |
| 3874 | " Votes for Country %c%c : %d\n", |
| 3875 | pMac->scan.votes11d[i].countryCode[0], |
| 3876 | pMac->scan.votes11d[i].countryCode[1], |
| 3877 | pMac->scan.votes11d[i].votes); |
| 3878 | |
| 3879 | maxVotes = pMac->scan.votes11d[i].votes; |
| 3880 | j = i; |
| 3881 | fRet = TRUE; |
| 3882 | } |
| 3883 | |
| 3884 | } |
| 3885 | if (fRet) |
| 3886 | { |
Rajesh Babu Prathipati | 20cdffa | 2014-07-01 22:24:59 +0530 | [diff] [blame] | 3887 | vos_mem_copy(pMac->scan.countryCodeElected, |
Agrawal Ashish | 0b6984f | 2014-04-05 18:35:45 +0530 | [diff] [blame] | 3888 | pMac->scan.votes11d[j].countryCode, WNI_CFG_COUNTRY_CODE_LEN); |
Rajesh Babu Prathipati | 20cdffa | 2014-07-01 22:24:59 +0530 | [diff] [blame] | 3889 | vos_mem_copy(pMac->scan.countryCode11d, |
Agarwal Ashish | 852b2c3 | 2014-05-23 17:13:25 +0530 | [diff] [blame] | 3890 | pMac->scan.votes11d[j].countryCode, WNI_CFG_COUNTRY_CODE_LEN); |
Agrawal Ashish | 0b6984f | 2014-04-05 18:35:45 +0530 | [diff] [blame] | 3891 | VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, |
| 3892 | "Selected Country is %c%c With count %d\n", |
| 3893 | pMac->scan.votes11d[j].countryCode[0], |
| 3894 | pMac->scan.votes11d[j].countryCode[1], |
| 3895 | pMac->scan.votes11d[j].votes); |
| 3896 | } |
| 3897 | return fRet; |
| 3898 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3899 | |
| 3900 | eHalStatus csrSetCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry, tANI_BOOLEAN *pfRestartNeeded) |
| 3901 | { |
| 3902 | eHalStatus status = eHAL_STATUS_INVALID_PARAMETER; |
| 3903 | v_REGDOMAIN_t domainId; |
| 3904 | |
| 3905 | if(pCountry) |
| 3906 | { |
Kiet Lam | 6c58333 | 2013-10-14 05:37:09 +0530 | [diff] [blame] | 3907 | status = csrGetRegulatoryDomainForCountry(pMac, pCountry, &domainId, COUNTRY_USER); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3908 | if(HAL_STATUS_SUCCESS(status)) |
| 3909 | { |
| 3910 | status = csrSetRegulatoryDomain(pMac, domainId, pfRestartNeeded); |
| 3911 | if(HAL_STATUS_SUCCESS(status)) |
| 3912 | { |
| 3913 | //We don't need to check the pMac->roam.configParam.fEnforceDefaultDomain flag here, |
| 3914 | //csrSetRegulatoryDomain will fail if the country doesn't fit our domain criteria. |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 3915 | vos_mem_copy(pMac->scan.countryCodeCurrent, pCountry, WNI_CFG_COUNTRY_CODE_LEN); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3916 | if((pfRestartNeeded == NULL) || !(*pfRestartNeeded)) |
| 3917 | { |
| 3918 | //Simply set it to cfg. If we need to restart, restart will apply it to the CFG |
| 3919 | csrSetCfgCountryCode(pMac, pCountry); |
| 3920 | } |
| 3921 | } |
| 3922 | } |
| 3923 | } |
| 3924 | |
| 3925 | return (status); |
| 3926 | } |
| 3927 | |
| 3928 | |
| 3929 | |
| 3930 | //caller allocated memory for pNumChn and pChnPowerInfo |
| 3931 | //As input, *pNumChn has the size of the array of pChnPowerInfo |
| 3932 | //Upon return, *pNumChn has the number of channels assigned. |
| 3933 | void csrGetChannelPowerInfo( tpAniSirGlobal pMac, tDblLinkList *pList, |
| 3934 | tANI_U32 *pNumChn, tChannelListWithPower *pChnPowerInfo) |
| 3935 | { |
| 3936 | tListElem *pEntry; |
| 3937 | tANI_U32 chnIdx = 0, idx; |
| 3938 | tCsrChannelPowerInfo *pChannelSet; |
| 3939 | |
| 3940 | //Get 2.4Ghz first |
| 3941 | pEntry = csrLLPeekHead( pList, LL_ACCESS_LOCK ); |
| 3942 | while( pEntry && (chnIdx < *pNumChn) ) |
| 3943 | { |
| 3944 | pChannelSet = GET_BASE_ADDR( pEntry, tCsrChannelPowerInfo, link ); |
| 3945 | if ( 1 != pChannelSet->interChannelOffset ) |
| 3946 | { |
| 3947 | for( idx = 0; (idx < pChannelSet->numChannels) && (chnIdx < *pNumChn); idx++ ) |
| 3948 | { |
| 3949 | pChnPowerInfo[chnIdx].chanId = (tANI_U8)(pChannelSet->firstChannel + ( idx * pChannelSet->interChannelOffset )); |
| 3950 | pChnPowerInfo[chnIdx++].pwr = pChannelSet->txPower; |
| 3951 | } |
| 3952 | } |
| 3953 | else |
| 3954 | { |
| 3955 | for( idx = 0; (idx < pChannelSet->numChannels) && (chnIdx < *pNumChn); idx++ ) |
| 3956 | { |
| 3957 | pChnPowerInfo[chnIdx].chanId = (tANI_U8)(pChannelSet->firstChannel + idx); |
| 3958 | pChnPowerInfo[chnIdx++].pwr = pChannelSet->txPower; |
| 3959 | } |
| 3960 | } |
| 3961 | |
| 3962 | pEntry = csrLLNext( pList, pEntry, LL_ACCESS_LOCK ); |
| 3963 | } |
| 3964 | *pNumChn = chnIdx; |
| 3965 | |
| 3966 | return ; |
| 3967 | } |
| 3968 | |
| 3969 | |
| 3970 | |
| 3971 | void csrApplyCountryInformation( tpAniSirGlobal pMac, tANI_BOOLEAN fForce ) |
| 3972 | { |
| 3973 | v_REGDOMAIN_t domainId; |
| 3974 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 3975 | |
| 3976 | do |
| 3977 | { |
| 3978 | if( !csrIs11dSupported( pMac ) || 0 == pMac->scan.channelOf11dInfo) break; |
| 3979 | if( pMac->scan.fAmbiguous11dInfoFound ) |
| 3980 | { |
| 3981 | // ambiguous info found |
| 3982 | //Restore te default domain as well |
Kiet Lam | 6c58333 | 2013-10-14 05:37:09 +0530 | [diff] [blame] | 3983 | if(HAL_STATUS_SUCCESS(csrGetRegulatoryDomainForCountry( |
| 3984 | pMac, pMac->scan.countryCodeCurrent, |
| 3985 | &domainId, COUNTRY_QUERY))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3986 | { |
| 3987 | pMac->scan.domainIdCurrent = domainId; |
| 3988 | } |
| 3989 | else |
| 3990 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 3991 | smsLog(pMac, LOGE, FL(" failed to get domain from currentCountryCode %02X%02X"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3992 | pMac->scan.countryCodeCurrent[0], pMac->scan.countryCodeCurrent[1]); |
| 3993 | } |
Gopichand Nakkala | b9185f2 | 2012-12-21 08:03:42 -0800 | [diff] [blame] | 3994 | csrResetCountryInformation( pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_TRUE ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3995 | break; |
| 3996 | } |
| 3997 | if ( pMac->scan.f11dInfoApplied && !fForce ) break; |
Kiet Lam | 6c58333 | 2013-10-14 05:37:09 +0530 | [diff] [blame] | 3998 | if(HAL_STATUS_SUCCESS(csrGetRegulatoryDomainForCountry( |
| 3999 | pMac, pMac->scan.countryCode11d, |
| 4000 | &domainId, COUNTRY_QUERY))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4001 | { |
| 4002 | //Check whether we need to enforce default domain |
| 4003 | if( ( !pMac->roam.configParam.fEnforceDefaultDomain ) || |
| 4004 | (pMac->scan.domainIdCurrent == domainId) ) |
| 4005 | { |
| 4006 | |
| 4007 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 4008 | { |
| 4009 | vos_log_802_11d_pkt_type *p11dLog; |
| 4010 | tChannelListWithPower chnPwrInfo[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 4011 | tANI_U32 nChnInfo = WNI_CFG_VALID_CHANNEL_LIST_LEN, nTmp; |
| 4012 | |
| 4013 | WLAN_VOS_DIAG_LOG_ALLOC(p11dLog, vos_log_802_11d_pkt_type, LOG_WLAN_80211D_C); |
| 4014 | if(p11dLog) |
| 4015 | { |
| 4016 | p11dLog->eventId = WLAN_80211D_EVENT_COUNTRY_SET; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4017 | vos_mem_copy(p11dLog->countryCode, pMac->scan.countryCode11d, 3); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4018 | p11dLog->numChannel = pMac->scan.channels11d.numChannels; |
| 4019 | if(p11dLog->numChannel <= VOS_LOG_MAX_NUM_CHANNEL) |
| 4020 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4021 | vos_mem_copy(p11dLog->Channels, |
| 4022 | pMac->scan.channels11d.channelList, |
| 4023 | p11dLog->numChannel); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4024 | csrGetChannelPowerInfo(pMac, &pMac->scan.channelPowerInfoList24, |
| 4025 | &nChnInfo, chnPwrInfo); |
| 4026 | nTmp = nChnInfo; |
| 4027 | nChnInfo = WNI_CFG_VALID_CHANNEL_LIST_LEN - nTmp; |
| 4028 | csrGetChannelPowerInfo(pMac, &pMac->scan.channelPowerInfoList5G, |
| 4029 | &nChnInfo, &chnPwrInfo[nTmp]); |
| 4030 | for(nTmp = 0; nTmp < p11dLog->numChannel; nTmp++) |
| 4031 | { |
| 4032 | for(nChnInfo = 0; nChnInfo < WNI_CFG_VALID_CHANNEL_LIST_LEN; nChnInfo++) |
| 4033 | { |
| 4034 | if(p11dLog->Channels[nTmp] == chnPwrInfo[nChnInfo].chanId) |
| 4035 | { |
| 4036 | p11dLog->TxPwr[nTmp] = chnPwrInfo[nChnInfo].pwr; |
| 4037 | break; |
| 4038 | } |
| 4039 | } |
| 4040 | } |
| 4041 | } |
| 4042 | if(!pMac->roam.configParam.Is11dSupportEnabled) |
| 4043 | { |
| 4044 | p11dLog->supportMultipleDomain = WLAN_80211D_DISABLED; |
| 4045 | } |
| 4046 | else if(pMac->roam.configParam.fEnforceDefaultDomain) |
| 4047 | { |
| 4048 | p11dLog->supportMultipleDomain = WLAN_80211D_NOT_SUPPORT_MULTI_DOMAIN; |
| 4049 | } |
| 4050 | else |
| 4051 | { |
| 4052 | p11dLog->supportMultipleDomain = WLAN_80211D_SUPPORT_MULTI_DOMAIN; |
| 4053 | } |
| 4054 | WLAN_VOS_DIAG_LOG_REPORT(p11dLog); |
| 4055 | } |
| 4056 | } |
| 4057 | #endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 4058 | if(pMac->scan.domainIdCurrent != domainId) |
| 4059 | { |
Sushant Kaushik | e0d2cce | 2014-04-10 14:36:07 +0530 | [diff] [blame] | 4060 | smsLog(pMac, LOGW, FL("Domain Changed Old %s (%d), new %s"), |
| 4061 | voss_DomainIdtoString(pMac->scan.domainIdCurrent), |
| 4062 | pMac->scan.domainIdCurrent, |
| 4063 | voss_DomainIdtoString(domainId)); |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 4064 | status = WDA_SetRegDomain(pMac, domainId, eSIR_TRUE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4065 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4066 | if (status != eHAL_STATUS_SUCCESS) |
| 4067 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 4068 | smsLog( pMac, LOGE, FL(" fail to set regId %d"), domainId ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4069 | } |
| 4070 | pMac->scan.domainIdCurrent = domainId; |
Kiet Lam | 6c58333 | 2013-10-14 05:37:09 +0530 | [diff] [blame] | 4071 | #ifndef CONFIG_ENABLE_LINUX_REG |
Kiet Lam | bb14e95 | 2013-11-19 14:58:29 +0530 | [diff] [blame] | 4072 | csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, |
| 4073 | pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE ); |
Kiet Lam | 6c58333 | 2013-10-14 05:37:09 +0530 | [diff] [blame] | 4074 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4075 | // switch to active scans using this new channel list |
| 4076 | pMac->scan.curScanType = eSIR_ACTIVE_SCAN; |
| 4077 | pMac->scan.f11dInfoApplied = eANI_BOOLEAN_TRUE; |
| 4078 | pMac->scan.f11dInfoReset = eANI_BOOLEAN_FALSE; |
| 4079 | } |
| 4080 | } |
| 4081 | |
| 4082 | } while( 0 ); |
| 4083 | |
| 4084 | return; |
| 4085 | } |
| 4086 | |
| 4087 | |
| 4088 | |
| 4089 | tANI_BOOLEAN csrSave11dCountryString( tpAniSirGlobal pMac, tANI_U8 *pCountryCode, |
| 4090 | tANI_BOOLEAN fForce) |
| 4091 | { |
| 4092 | tANI_BOOLEAN fCountryStringChanged = FALSE, fUnknownCountryCode = FALSE; |
| 4093 | tANI_U32 i; |
Kiet Lam | 6c58333 | 2013-10-14 05:37:09 +0530 | [diff] [blame] | 4094 | v_REGDOMAIN_t regd; |
Tushnim Bhattacharyya | 582ac1d | 2013-11-07 23:44:09 -0800 | [diff] [blame] | 4095 | tANI_BOOLEAN fCountryNotPresentInDriver = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4096 | |
| 4097 | // convert to UPPER here so we are assured the strings are always in upper case. |
| 4098 | for( i = 0; i < 3; i++ ) |
| 4099 | { |
| 4100 | pCountryCode[ i ] = (tANI_U8)csrToUpper( pCountryCode[ i ] ); |
| 4101 | } |
| 4102 | |
| 4103 | // Some of the 'old' Cisco 350 series AP's advertise NA as the country code (for North America ??). |
| 4104 | // NA is not a valid country code or domain so let's allow this by changing it to the proper |
| 4105 | // country code (which is US). We've also seen some NETGEAR AP's that have "XX " as the country code |
| 4106 | // with valid 2.4 GHz US channel information. If we cannot find the country code advertised in the |
| 4107 | // 11d information element, let's default to US. |
Kiet Lam | 6c58333 | 2013-10-14 05:37:09 +0530 | [diff] [blame] | 4108 | if ( !HAL_STATUS_SUCCESS(csrGetRegulatoryDomainForCountry(pMac, |
| 4109 | pCountryCode, |
| 4110 | ®d, |
| 4111 | COUNTRY_QUERY) ) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4112 | { |
| 4113 | // Check the enforcement first |
| 4114 | if( pMac->roam.configParam.fEnforceDefaultDomain || pMac->roam.configParam.fEnforceCountryCodeMatch ) |
| 4115 | { |
| 4116 | fUnknownCountryCode = TRUE; |
| 4117 | } |
| 4118 | else |
| 4119 | { |
Tushnim Bhattacharyya | 582ac1d | 2013-11-07 23:44:09 -0800 | [diff] [blame] | 4120 | fCountryNotPresentInDriver = TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4121 | } |
| 4122 | } |
Tushnim Bhattacharyya | c3c1e8e | 2013-10-29 17:27:43 -0700 | [diff] [blame] | 4123 | //right now, even if we don't find the CC in driver we set to world. Making |
| 4124 | //sure countryCode11d doesn't get updated with the invalid CC, instead |
| 4125 | //reflect the world CC |
| 4126 | else if (REGDOMAIN_WORLD == regd) |
| 4127 | { |
Tushnim Bhattacharyya | 582ac1d | 2013-11-07 23:44:09 -0800 | [diff] [blame] | 4128 | fCountryNotPresentInDriver = TRUE; |
Tushnim Bhattacharyya | c3c1e8e | 2013-10-29 17:27:43 -0700 | [diff] [blame] | 4129 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4130 | |
| 4131 | // We've seen some of the AP's improperly put a 0 for the third character of the country code. |
| 4132 | // spec says valid charcters are 'O' (for outdoor), 'I' for Indoor, or ' ' (space; for either). |
| 4133 | // if we see a 0 in this third character, let's change it to a ' '. |
| 4134 | if ( 0 == pCountryCode[ 2 ] ) |
| 4135 | { |
| 4136 | pCountryCode[ 2 ] = ' '; |
| 4137 | } |
| 4138 | |
| 4139 | if( !fUnknownCountryCode ) |
| 4140 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4141 | fCountryStringChanged = (!vos_mem_compare(pMac->scan.countryCode11d, pCountryCode, 2)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4142 | |
| 4143 | |
| 4144 | if(( 0 == pMac->scan.countryCode11d[ 0 ] && 0 == pMac->scan.countryCode11d[ 1 ] ) |
| 4145 | || (fForce)) |
| 4146 | { |
Tushnim Bhattacharyya | 582ac1d | 2013-11-07 23:44:09 -0800 | [diff] [blame] | 4147 | if (!fCountryNotPresentInDriver) |
| 4148 | { |
| 4149 | // this is the first .11d information |
| 4150 | vos_mem_copy(pMac->scan.countryCode11d, pCountryCode, |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4151 | sizeof( pMac->scan.countryCode11d )); |
Tushnim Bhattacharyya | 582ac1d | 2013-11-07 23:44:09 -0800 | [diff] [blame] | 4152 | |
| 4153 | } |
| 4154 | else |
| 4155 | { |
| 4156 | pMac->scan.countryCode11d[0] = '0'; |
| 4157 | pMac->scan.countryCode11d[1] = '0'; |
| 4158 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4159 | } |
| 4160 | } |
| 4161 | |
| 4162 | return( fCountryStringChanged ); |
| 4163 | } |
| 4164 | |
| 4165 | |
| 4166 | void csrSaveChannelPowerForBand( tpAniSirGlobal pMac, tANI_BOOLEAN fPopulate5GBand ) |
| 4167 | { |
| 4168 | tANI_U32 Index, count=0; |
| 4169 | tSirMacChanInfo *pChanInfo; |
| 4170 | tSirMacChanInfo *pChanInfoStart; |
Leela V Kiran Kumar Reddy Chirala | 6a45875 | 2013-02-16 15:41:27 -0800 | [diff] [blame] | 4171 | tANI_S32 maxChannelIndex; |
| 4172 | |
| 4173 | maxChannelIndex = ( pMac->scan.base20MHzChannels.numChannels < WNI_CFG_VALID_CHANNEL_LIST_LEN ) ? |
| 4174 | pMac->scan.base20MHzChannels.numChannels : WNI_CFG_VALID_CHANNEL_LIST_LEN ; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4175 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4176 | pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 4177 | if ( NULL != pChanInfo ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4178 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4179 | vos_mem_set(pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4180 | pChanInfoStart = pChanInfo; |
Leela V Kiran Kumar Reddy Chirala | 6a45875 | 2013-02-16 15:41:27 -0800 | [diff] [blame] | 4181 | for (Index=0; Index < maxChannelIndex; Index++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4182 | { |
| 4183 | if ((fPopulate5GBand && (CSR_IS_CHANNEL_5GHZ(pMac->scan.defaultPowerTable[Index].chanId))) || |
| 4184 | (!fPopulate5GBand && (CSR_IS_CHANNEL_24GHZ(pMac->scan.defaultPowerTable[Index].chanId))) ) |
| 4185 | { |
Leela V Kiran Kumar Reddy Chirala | 6a45875 | 2013-02-16 15:41:27 -0800 | [diff] [blame] | 4186 | if(count >= WNI_CFG_VALID_CHANNEL_LIST_LEN) |
| 4187 | { |
| 4188 | smsLog( pMac, LOGW, FL(" csrSaveChannelPowerForBand, count exceeded, count = %d"), count); |
| 4189 | break; |
| 4190 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4191 | pChanInfo->firstChanNum = pMac->scan.defaultPowerTable[Index].chanId; |
| 4192 | pChanInfo->numChannels = 1; |
| 4193 | pChanInfo->maxTxPower = CSR_ROAM_MIN( pMac->scan.defaultPowerTable[Index].pwr, pMac->roam.configParam.nTxPowerCap ); |
| 4194 | pChanInfo++; |
| 4195 | count++; |
| 4196 | } |
| 4197 | } |
| 4198 | if(count) |
| 4199 | { |
| 4200 | csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart ); |
| 4201 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4202 | vos_mem_free(pChanInfoStart); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4203 | } |
| 4204 | } |
| 4205 | |
| 4206 | |
| 4207 | void csrSetOppositeBandChannelInfo( tpAniSirGlobal pMac ) |
| 4208 | { |
| 4209 | tANI_BOOLEAN fPopulate5GBand = FALSE; |
| 4210 | |
| 4211 | do |
| 4212 | { |
| 4213 | // if this is not a dual band product, then we don't need to set the opposite |
| 4214 | // band info. We only work in one band so no need to look in the other band. |
| 4215 | if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) ) break; |
| 4216 | // if we found channel info on the 5.0 band and... |
| 4217 | if ( CSR_IS_CHANNEL_5GHZ( pMac->scan.channelOf11dInfo ) ) |
| 4218 | { |
| 4219 | // and the 2.4 band is empty, then populate the 2.4 channel info |
Kiet Lam | 8d985a0 | 2013-10-11 03:39:41 +0530 | [diff] [blame] | 4220 | if ( !csrLLIsListEmpty( &pMac->scan.channelPowerInfoList24, LL_ACCESS_LOCK ) ) break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4221 | fPopulate5GBand = FALSE; |
| 4222 | } |
| 4223 | else |
| 4224 | { |
| 4225 | // else, we found channel info in the 2.4 GHz band. If the 5.0 band is empty |
| 4226 | // set the 5.0 band info from the 2.4 country code. |
Kiet Lam | 8d985a0 | 2013-10-11 03:39:41 +0530 | [diff] [blame] | 4227 | if ( !csrLLIsListEmpty( &pMac->scan.channelPowerInfoList5G, LL_ACCESS_LOCK ) ) break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4228 | fPopulate5GBand = TRUE; |
| 4229 | } |
| 4230 | csrSaveChannelPowerForBand( pMac, fPopulate5GBand ); |
| 4231 | |
| 4232 | } while( 0 ); |
| 4233 | } |
| 4234 | |
| 4235 | |
| 4236 | tANI_BOOLEAN csrIsSupportedChannel(tpAniSirGlobal pMac, tANI_U8 channelId) |
| 4237 | { |
| 4238 | tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE; |
| 4239 | tANI_U32 i; |
| 4240 | |
| 4241 | //Make sure it is a channel that is in our supported list. |
| 4242 | for ( i = 0; i < pMac->scan.baseChannels.numChannels; i++ ) |
| 4243 | { |
| 4244 | if ( channelId == pMac->scan.baseChannels.channelList[i] ) |
| 4245 | { |
| 4246 | fRet = eANI_BOOLEAN_TRUE; |
| 4247 | break; |
| 4248 | } |
| 4249 | } |
| 4250 | |
| 4251 | //If it is configured to limit a set of the channels |
| 4252 | if( fRet && pMac->roam.configParam.fEnforce11dChannels ) |
| 4253 | { |
| 4254 | fRet = eANI_BOOLEAN_FALSE; |
| 4255 | for ( i = 0; i < pMac->scan.base20MHzChannels.numChannels; i++ ) |
| 4256 | { |
| 4257 | if ( channelId == pMac->scan.base20MHzChannels.channelList[i] ) |
| 4258 | { |
| 4259 | fRet = eANI_BOOLEAN_TRUE; |
| 4260 | break; |
| 4261 | } |
| 4262 | } |
| 4263 | } |
| 4264 | |
| 4265 | return (fRet); |
| 4266 | } |
| 4267 | |
| 4268 | |
| 4269 | |
| 4270 | //bSize specify the buffer size of pChannelList |
| 4271 | tANI_U8 csrGetChannelListFromChannelSet( tpAniSirGlobal pMac, tANI_U8 *pChannelList, tANI_U8 bSize, tCsrChannelPowerInfo *pChannelSet ) |
| 4272 | { |
| 4273 | tANI_U8 i, j = 0, chnId; |
| 4274 | |
| 4275 | bSize = CSR_MIN(bSize, pChannelSet->numChannels); |
| 4276 | for( i = 0; i < bSize; i++ ) |
| 4277 | { |
| 4278 | chnId = (tANI_U8)(pChannelSet->firstChannel + ( i * pChannelSet->interChannelOffset )); |
| 4279 | if ( csrIsSupportedChannel( pMac, chnId ) ) |
| 4280 | { |
| 4281 | pChannelList[j++] = chnId; |
| 4282 | } |
| 4283 | } |
| 4284 | |
| 4285 | return (j); |
| 4286 | } |
| 4287 | |
| 4288 | |
| 4289 | |
| 4290 | //bSize -- specify the buffer size of pChannelList |
| 4291 | void csrConstructCurrentValidChannelList( tpAniSirGlobal pMac, tDblLinkList *pChannelSetList, |
| 4292 | tANI_U8 *pChannelList, tANI_U8 bSize, tANI_U8 *pNumChannels ) |
| 4293 | { |
| 4294 | tListElem *pEntry; |
| 4295 | tCsrChannelPowerInfo *pChannelSet; |
| 4296 | tANI_U8 numChannels; |
| 4297 | tANI_U8 *pChannels; |
| 4298 | |
| 4299 | if( pChannelSetList && pChannelList && pNumChannels ) |
| 4300 | { |
| 4301 | pChannels = pChannelList; |
| 4302 | *pNumChannels = 0; |
| 4303 | pEntry = csrLLPeekHead( pChannelSetList, LL_ACCESS_LOCK ); |
| 4304 | while( pEntry ) |
| 4305 | { |
| 4306 | pChannelSet = GET_BASE_ADDR( pEntry, tCsrChannelPowerInfo, link ); |
| 4307 | numChannels = csrGetChannelListFromChannelSet( pMac, pChannels, bSize, pChannelSet ); |
| 4308 | pChannels += numChannels; |
| 4309 | *pNumChannels += numChannels; |
| 4310 | pEntry = csrLLNext( pChannelSetList, pEntry, LL_ACCESS_LOCK ); |
| 4311 | } |
| 4312 | } |
| 4313 | } |
| 4314 | |
| 4315 | |
| 4316 | /* |
| 4317 | * 802.11D only: Gather 11d IE via beacon or Probe response and store them in pAdapter->channels11d |
| 4318 | */ |
Chandrasekaran, Manishekar | 90c4932 | 2014-06-24 13:26:14 +0530 | [diff] [blame] | 4319 | tANI_BOOLEAN csrLearnCountryInformation( tpAniSirGlobal pMac, tSirBssDescription *pSirBssDesc, |
| 4320 | tDot11fBeaconIEs *pIes, tANI_BOOLEAN fForce) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4321 | { |
Agarwal Ashish | 60a37ee | 2014-05-28 17:20:20 +0530 | [diff] [blame] | 4322 | eHalStatus status; |
Chandrasekaran, Manishekar | 90c4932 | 2014-06-24 13:26:14 +0530 | [diff] [blame] | 4323 | tANI_U8 *pCountryCodeSelected; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4324 | tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE; |
| 4325 | v_REGDOMAIN_t domainId; |
Chandrasekaran, Manishekar | 90c4932 | 2014-06-24 13:26:14 +0530 | [diff] [blame] | 4326 | tDot11fBeaconIEs *pIesLocal = pIes; |
| 4327 | tANI_BOOLEAN useVoting = eANI_BOOLEAN_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4328 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4329 | if (VOS_STA_SAP_MODE == vos_get_conparam ()) |
| 4330 | return eHAL_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4331 | |
Chandrasekaran, Manishekar | 90c4932 | 2014-06-24 13:26:14 +0530 | [diff] [blame] | 4332 | if ((NULL == pSirBssDesc) && (NULL == pIes)) |
| 4333 | useVoting = eANI_BOOLEAN_TRUE; |
| 4334 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4335 | do |
| 4336 | { |
| 4337 | // check if .11d support is enabled |
| 4338 | if( !csrIs11dSupported( pMac ) ) break; |
Agarwal Ashish | 60a37ee | 2014-05-28 17:20:20 +0530 | [diff] [blame] | 4339 | |
Chandrasekaran, Manishekar | 90c4932 | 2014-06-24 13:26:14 +0530 | [diff] [blame] | 4340 | if (eANI_BOOLEAN_FALSE == useVoting) |
| 4341 | { |
| 4342 | if( !pIesLocal && |
| 4343 | (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, |
| 4344 | pSirBssDesc, &pIesLocal)))) |
| 4345 | { |
| 4346 | break; |
| 4347 | } |
| 4348 | // check if country information element is present |
| 4349 | if(!pIesLocal->Country.present) |
| 4350 | { |
| 4351 | //No country info |
| 4352 | break; |
| 4353 | } |
| 4354 | |
| 4355 | if( HAL_STATUS_SUCCESS(csrGetRegulatoryDomainForCountry |
| 4356 | (pMac, pIesLocal->Country.country, &domainId, |
| 4357 | COUNTRY_QUERY)) && |
| 4358 | ( domainId == REGDOMAIN_WORLD)) |
| 4359 | { |
| 4360 | break; |
| 4361 | } |
| 4362 | } //useVoting == eANI_BOOLEAN_FALSE |
| 4363 | |
| 4364 | if (eANI_BOOLEAN_FALSE == useVoting) |
| 4365 | pCountryCodeSelected = pIesLocal->Country.country; |
| 4366 | else |
| 4367 | pCountryCodeSelected = pMac->scan.countryCodeElected; |
| 4368 | |
Kiet Lam | 8d985a0 | 2013-10-11 03:39:41 +0530 | [diff] [blame] | 4369 | status = csrGetRegulatoryDomainForCountry(pMac, |
Chandrasekaran, Manishekar | 90c4932 | 2014-06-24 13:26:14 +0530 | [diff] [blame] | 4370 | pCountryCodeSelected, &domainId, COUNTRY_IE); |
Kiet Lam | 8d985a0 | 2013-10-11 03:39:41 +0530 | [diff] [blame] | 4371 | if ( status != eHAL_STATUS_SUCCESS ) |
| 4372 | { |
| 4373 | smsLog( pMac, LOGE, FL(" fail to get regId %d"), domainId ); |
| 4374 | fRet = eANI_BOOLEAN_FALSE; |
| 4375 | break; |
| 4376 | } |
Agarwal Ashish | 7693f2d | 2014-07-18 18:03:58 +0530 | [diff] [blame] | 4377 | |
| 4378 | /* updating 11d Country Code with Country code selected. */ |
| 4379 | |
| 4380 | vos_mem_copy(pMac->scan.countryCode11d, |
| 4381 | pCountryCodeSelected, |
| 4382 | WNI_CFG_COUNTRY_CODE_LEN); |
| 4383 | |
Agarwal Ashish | 60a37ee | 2014-05-28 17:20:20 +0530 | [diff] [blame] | 4384 | #ifndef CONFIG_ENABLE_LINUX_REG |
Venkata Prathyusha Kuntupalli | 316247e | 2013-03-15 17:45:25 -0700 | [diff] [blame] | 4385 | // Checking for Domain Id change |
| 4386 | if ( domainId != pMac->scan.domainIdCurrent ) |
| 4387 | { |
Kiet Lam | 8d985a0 | 2013-10-11 03:39:41 +0530 | [diff] [blame] | 4388 | vos_mem_copy(pMac->scan.countryCode11d, |
Chandrasekaran, Manishekar | 90c4932 | 2014-06-24 13:26:14 +0530 | [diff] [blame] | 4389 | pCountryCodeSelected, |
Kiet Lam | 8d985a0 | 2013-10-11 03:39:41 +0530 | [diff] [blame] | 4390 | sizeof( pMac->scan.countryCode11d ) ); |
| 4391 | /* Set Current Country code and Current Regulatory domain */ |
| 4392 | status = csrSetRegulatoryDomain(pMac, domainId, NULL); |
| 4393 | if (eHAL_STATUS_SUCCESS != status) |
| 4394 | { |
| 4395 | smsLog(pMac, LOGE, "Set Reg Domain Fail %d", status); |
| 4396 | fRet = eANI_BOOLEAN_FALSE; |
| 4397 | return fRet; |
| 4398 | } |
| 4399 | //csrSetRegulatoryDomain will fail if the country doesn't fit our domain criteria. |
| 4400 | vos_mem_copy(pMac->scan.countryCodeCurrent, |
Chandrasekaran, Manishekar | 90c4932 | 2014-06-24 13:26:14 +0530 | [diff] [blame] | 4401 | pCountryCodeSelected, WNI_CFG_COUNTRY_CODE_LEN); |
Kiet Lam | 8d985a0 | 2013-10-11 03:39:41 +0530 | [diff] [blame] | 4402 | //Simply set it to cfg. |
Chandrasekaran, Manishekar | 90c4932 | 2014-06-24 13:26:14 +0530 | [diff] [blame] | 4403 | csrSetCfgCountryCode(pMac, pCountryCodeSelected); |
Kiet Lam | 8d985a0 | 2013-10-11 03:39:41 +0530 | [diff] [blame] | 4404 | |
| 4405 | /* overwrite the defualt country code */ |
| 4406 | vos_mem_copy(pMac->scan.countryCodeDefault, |
| 4407 | pMac->scan.countryCodeCurrent, |
| 4408 | WNI_CFG_COUNTRY_CODE_LEN); |
| 4409 | /* Set Current RegDomain */ |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 4410 | status = WDA_SetRegDomain(pMac, domainId, eSIR_TRUE); |
Kiet Lam | 8d985a0 | 2013-10-11 03:39:41 +0530 | [diff] [blame] | 4411 | if ( status != eHAL_STATUS_SUCCESS ) |
| 4412 | { |
| 4413 | smsLog( pMac, LOGE, FL(" fail to Set regId %d"), domainId ); |
| 4414 | fRet = eANI_BOOLEAN_FALSE; |
| 4415 | return fRet; |
| 4416 | } |
| 4417 | /* set to default domain ID */ |
Madan Mohan Koyyalamudi | 0e5922d | 2013-09-10 15:45:24 +0530 | [diff] [blame] | 4418 | pMac->scan.domainIdCurrent = domainId; |
Kiet Lam | 8d985a0 | 2013-10-11 03:39:41 +0530 | [diff] [blame] | 4419 | /* get the channels based on new cc */ |
| 4420 | status = csrInitGetChannels( pMac ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4421 | |
Kiet Lam | 8d985a0 | 2013-10-11 03:39:41 +0530 | [diff] [blame] | 4422 | if ( status != eHAL_STATUS_SUCCESS ) |
| 4423 | { |
| 4424 | smsLog( pMac, LOGE, FL(" fail to get Channels ")); |
| 4425 | fRet = eANI_BOOLEAN_FALSE; |
| 4426 | return fRet; |
| 4427 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4428 | |
Kiet Lam | 8d985a0 | 2013-10-11 03:39:41 +0530 | [diff] [blame] | 4429 | /* reset info based on new cc, and we are done */ |
| 4430 | csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE); |
Agarwal Ashish | faef669 | 2014-01-29 19:40:30 +0530 | [diff] [blame] | 4431 | /* Regulatory Domain Changed, Purge Only scan result |
| 4432 | * which does not have channel number belong to 11d |
| 4433 | * channel list |
| 4434 | */ |
Srinivas, Dasari | 42bf770 | 2014-02-07 11:29:53 +0530 | [diff] [blame] | 4435 | csrScanFilterResults(pMac); |
Kiet Lam | 8d985a0 | 2013-10-11 03:39:41 +0530 | [diff] [blame] | 4436 | } |
Kiet Lam | 6c58333 | 2013-10-14 05:37:09 +0530 | [diff] [blame] | 4437 | #endif |
| 4438 | fRet = eANI_BOOLEAN_TRUE; |
| 4439 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4440 | } while( 0 ); |
Chandrasekaran, Manishekar | 90c4932 | 2014-06-24 13:26:14 +0530 | [diff] [blame] | 4441 | |
| 4442 | if( !pIes && pIesLocal ) |
| 4443 | { |
| 4444 | //locally allocated |
| 4445 | vos_mem_free(pIesLocal); |
| 4446 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4447 | |
| 4448 | return( fRet ); |
| 4449 | } |
| 4450 | |
| 4451 | |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 4452 | static void csrSaveScanResults( tpAniSirGlobal pMac, tANI_U8 reason ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4453 | { |
| 4454 | // initialize this to FALSE. profMoveInterimScanResultsToMainList() routine |
| 4455 | // will set this to the channel where an .11d beacon is seen |
| 4456 | pMac->scan.channelOf11dInfo = 0; |
| 4457 | // if we get any ambiguous .11d information then this will be set to TRUE |
| 4458 | pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE; |
| 4459 | //Tush |
| 4460 | // if we get any ambiguous .11d information, then this will be set to TRUE |
| 4461 | // only if the applied 11d info could be found in one of the scan results |
| 4462 | pMac->scan.fCurrent11dInfoMatch = eANI_BOOLEAN_FALSE; |
| 4463 | // 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] | 4464 | csrMoveTempScanResultsToMainList( pMac, reason ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4465 | } |
| 4466 | |
| 4467 | |
| 4468 | void csrReinitScanCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
| 4469 | { |
| 4470 | switch (pCommand->u.scanCmd.reason) |
| 4471 | { |
| 4472 | case eCsrScanSetBGScanParam: |
| 4473 | case eCsrScanAbortBgScan: |
| 4474 | if(pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList) |
| 4475 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4476 | vos_mem_free(pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4477 | pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList = NULL; |
| 4478 | } |
| 4479 | break; |
| 4480 | case eCsrScanBGScanAbort: |
| 4481 | case eCsrScanBGScanEnable: |
| 4482 | case eCsrScanGetScanChnInfo: |
| 4483 | break; |
| 4484 | case eCsrScanAbortNormalScan: |
| 4485 | default: |
| 4486 | csrScanFreeRequest(pMac, &pCommand->u.scanCmd.u.scanRequest); |
| 4487 | break; |
| 4488 | } |
| 4489 | if(pCommand->u.scanCmd.pToRoamProfile) |
| 4490 | { |
| 4491 | csrReleaseProfile(pMac, pCommand->u.scanCmd.pToRoamProfile); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4492 | vos_mem_free(pCommand->u.scanCmd.pToRoamProfile); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4493 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4494 | vos_mem_set(&pCommand->u.scanCmd, sizeof(tScanCmd), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4495 | } |
| 4496 | |
| 4497 | |
| 4498 | tANI_BOOLEAN csrGetRemainingChannelsFor11dScan( tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U8 *pcChannels ) |
| 4499 | { |
| 4500 | tANI_U32 index11dChannels, index; |
| 4501 | tANI_U32 indexCurrentChannels; |
| 4502 | tANI_BOOLEAN fChannelAlreadyScanned; |
| 4503 | tANI_U32 len = sizeof(pMac->roam.validChannelList); |
| 4504 | |
| 4505 | *pcChannels = 0; |
| 4506 | if ( CSR_IS_11D_INFO_FOUND(pMac) && csrRoamIsChannelValid(pMac, pMac->scan.channelOf11dInfo) ) |
| 4507 | { |
| 4508 | if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len))) |
| 4509 | { |
| 4510 | //Find the channel index where we found the 11d info |
| 4511 | for(index = 0; index < len; index++) |
| 4512 | { |
| 4513 | if(pMac->scan.channelOf11dInfo == pMac->roam.validChannelList[index]) |
| 4514 | break; |
| 4515 | } |
| 4516 | //check whether we found the channel index |
| 4517 | if(index < len) |
| 4518 | { |
| 4519 | // Now, look through the 11d channel list and create a list of all channels in the 11d list that are |
| 4520 | // NOT in the current channel list. This gives us a list of the new channels that have not been |
| 4521 | // scanned. We'll scan this new list so we have a complete set of scan results on all of the domain channels |
| 4522 | // initially. |
| 4523 | for ( index11dChannels = 0; index11dChannels < pMac->scan.channels11d.numChannels; index11dChannels++ ) |
| 4524 | { |
| 4525 | fChannelAlreadyScanned = eANI_BOOLEAN_FALSE; |
| 4526 | |
| 4527 | for( indexCurrentChannels = 0; indexCurrentChannels < index; indexCurrentChannels++ ) |
| 4528 | { |
| 4529 | if ( pMac->roam.validChannelList[ indexCurrentChannels ] == pMac->scan.channels11d.channelList[ index11dChannels ] ) |
| 4530 | { |
| 4531 | fChannelAlreadyScanned = eANI_BOOLEAN_TRUE; |
| 4532 | break; |
| 4533 | } |
| 4534 | } |
| 4535 | |
| 4536 | if ( !fChannelAlreadyScanned ) |
| 4537 | { |
| 4538 | pChannels[ *pcChannels ] = pMac->scan.channels11d.channelList[ index11dChannels ]; |
| 4539 | ( *pcChannels )++; |
| 4540 | } |
| 4541 | } |
| 4542 | } |
| 4543 | }//GetCFG |
| 4544 | } |
| 4545 | return( *pcChannels ); |
| 4546 | } |
| 4547 | |
| 4548 | |
| 4549 | eCsrScanCompleteNextCommand csrScanGetNextCommandState( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fSuccess ) |
| 4550 | { |
| 4551 | eCsrScanCompleteNextCommand NextCommand = eCsrNextScanNothing; |
| 4552 | |
| 4553 | switch( pCommand->u.scanCmd.reason ) |
| 4554 | { |
| 4555 | case eCsrScan11d1: |
| 4556 | NextCommand = (fSuccess) ? eCsrNext11dScan1Success : eCsrNext11dScan1Failure; |
| 4557 | break; |
| 4558 | case eCsrScan11d2: |
| 4559 | NextCommand = (fSuccess) ? eCsrNext11dScan2Success : eCsrNext11dScan2Failure; |
| 4560 | break; |
| 4561 | case eCsrScan11dDone: |
| 4562 | NextCommand = eCsrNext11dScanComplete; |
| 4563 | break; |
| 4564 | case eCsrScanLostLink1: |
| 4565 | NextCommand = (fSuccess) ? eCsrNextLostLinkScan1Success : eCsrNextLostLinkScan1Failed; |
| 4566 | break; |
| 4567 | case eCsrScanLostLink2: |
| 4568 | NextCommand = (fSuccess) ? eCsrNextLostLinkScan2Success : eCsrNextLostLinkScan2Failed; |
| 4569 | break; |
| 4570 | case eCsrScanLostLink3: |
| 4571 | NextCommand = (fSuccess) ? eCsrNextLostLinkScan3Success : eCsrNextLostLinkScan3Failed; |
| 4572 | break; |
| 4573 | case eCsrScanForSsid: |
| 4574 | NextCommand = (fSuccess) ? eCsrNexteScanForSsidSuccess : eCsrNexteScanForSsidFailure; |
| 4575 | break; |
| 4576 | case eCsrScanForCapsChange: |
| 4577 | NextCommand = eCsrNextCapChangeScanComplete; //don't care success or not |
| 4578 | break; |
| 4579 | case eCsrScanIdleScan: |
| 4580 | NextCommand = eCsrNextIdleScanComplete; |
| 4581 | break; |
| 4582 | default: |
| 4583 | NextCommand = eCsrNextScanNothing; |
| 4584 | break; |
| 4585 | } |
| 4586 | return( NextCommand ); |
| 4587 | } |
| 4588 | |
| 4589 | |
| 4590 | //Return whether the pCommand is finished. |
| 4591 | tANI_BOOLEAN csrHandleScan11d1Failure(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
| 4592 | { |
| 4593 | tANI_BOOLEAN fRet = eANI_BOOLEAN_TRUE; |
| 4594 | |
| 4595 | //Apply back the default setting and passively scan one more time. |
Gopichand Nakkala | b9185f2 | 2012-12-21 08:03:42 -0800 | [diff] [blame] | 4596 | csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_TRUE); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4597 | pCommand->u.scanCmd.reason = eCsrScan11d2; |
| 4598 | if(HAL_STATUS_SUCCESS(csrScanChannels(pMac, pCommand))) |
| 4599 | { |
| 4600 | fRet = eANI_BOOLEAN_FALSE; |
| 4601 | } |
| 4602 | |
| 4603 | return (fRet); |
| 4604 | } |
| 4605 | |
| 4606 | |
| 4607 | tANI_BOOLEAN csrHandleScan11dSuccess(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
| 4608 | { |
| 4609 | tANI_BOOLEAN fRet = eANI_BOOLEAN_TRUE; |
| 4610 | tANI_U8 *pChannels; |
| 4611 | tANI_U8 cChannels; |
| 4612 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4613 | pChannels = vos_mem_malloc(WNI_CFG_VALID_CHANNEL_LIST_LEN); |
| 4614 | if ( NULL != pChannels ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4615 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4616 | vos_mem_set(pChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4617 | if ( csrGetRemainingChannelsFor11dScan( pMac, pChannels, &cChannels ) ) |
| 4618 | { |
| 4619 | pCommand->u.scanCmd.reason = eCsrScan11dDone; |
| 4620 | if(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList) |
| 4621 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4622 | vos_mem_free(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList); |
James Zmuda | 9ea1edd | 2013-04-18 18:20:54 -0700 | [diff] [blame] | 4623 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4624 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4625 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = vos_mem_malloc(cChannels); |
| 4626 | if ( NULL != pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4627 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4628 | vos_mem_copy(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList, |
| 4629 | pChannels, cChannels); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4630 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = cChannels; |
| 4631 | pCommand->u.scanCmd.u.scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN; |
| 4632 | pCommand->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 4633 | if(HAL_STATUS_SUCCESS(csrScanChannels(pMac, pCommand))) |
| 4634 | { |
| 4635 | //Reuse the same command buffer |
| 4636 | fRet = eANI_BOOLEAN_FALSE; |
| 4637 | } |
| 4638 | } |
| 4639 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4640 | vos_mem_free(pChannels); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4641 | } |
| 4642 | |
| 4643 | return (fRet); |
| 4644 | } |
| 4645 | |
| 4646 | //Return whether the command should be removed |
| 4647 | tANI_BOOLEAN csrScanComplete( tpAniSirGlobal pMac, tSirSmeScanRsp *pScanRsp ) |
| 4648 | { |
| 4649 | eCsrScanCompleteNextCommand NextCommand = eCsrNextScanNothing; |
| 4650 | tListElem *pEntry; |
| 4651 | tSmeCmd *pCommand; |
| 4652 | tANI_BOOLEAN fRemoveCommand = eANI_BOOLEAN_TRUE; |
| 4653 | tANI_BOOLEAN fSuccess; |
| 4654 | |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 4655 | if (pMac->fScanOffload) |
| 4656 | pEntry = csrLLPeekHead(&pMac->sme.smeScanCmdActiveList, LL_ACCESS_LOCK); |
| 4657 | else |
| 4658 | pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4659 | |
| 4660 | if ( pEntry ) |
| 4661 | { |
| 4662 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 4663 | |
| 4664 | // If the head of the queue is Active and it is a SCAN command, remove |
| 4665 | // and put this on the Free queue. |
| 4666 | if ( eSmeCommandScan == pCommand->command ) |
| 4667 | { |
| 4668 | tANI_U32 sessionId = pCommand->sessionId; |
| 4669 | |
| 4670 | if(eSIR_SME_SUCCESS != pScanRsp->statusCode) |
| 4671 | { |
| 4672 | fSuccess = eANI_BOOLEAN_FALSE; |
| 4673 | } |
| 4674 | else |
| 4675 | { |
| 4676 | //pMac->scan.tempScanResults is not empty meaning the scan found something |
| 4677 | //This check only valid here because csrSaveScanresults is not yet called |
| 4678 | fSuccess = (!csrLLIsListEmpty(&pMac->scan.tempScanResults, LL_ACCESS_LOCK)); |
| 4679 | } |
Ratheesh S P | ece1f83 | 2015-07-25 15:50:25 +0530 | [diff] [blame] | 4680 | if (pCommand->u.scanCmd.abortScanIndication & |
| 4681 | eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE) |
Srinivas, Dasari | 187ca4e | 2014-02-07 12:40:09 +0530 | [diff] [blame] | 4682 | { |
| 4683 | /* |
| 4684 | * Scan aborted due to band change |
| 4685 | * The scan results need to be flushed |
| 4686 | */ |
| 4687 | if (pCommand->u.scanCmd.callback |
| 4688 | != pMac->scan.callback11dScanDone) |
| 4689 | { |
| 4690 | smsLog(pMac, LOG1, FL("Filtering the scan results as the " |
| 4691 | "results may belong to wrong band")); |
| 4692 | csrScanFilterResults(pMac); |
| 4693 | } |
| 4694 | else |
| 4695 | { |
| 4696 | smsLog(pMac, LOG1, FL("11d_scan_done will flush the scan" |
| 4697 | " results")); |
| 4698 | } |
Srinivas, Dasari | 187ca4e | 2014-02-07 12:40:09 +0530 | [diff] [blame] | 4699 | } |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 4700 | csrSaveScanResults(pMac, pCommand->u.scanCmd.reason); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4701 | |
Agrawal Ashish | f92238e | 2015-12-09 17:51:53 +0530 | [diff] [blame] | 4702 | /* filter scan result based on valid channel list number */ |
| 4703 | if (pMac->scan.fcc_constraint) |
| 4704 | { |
| 4705 | smsLog(pMac, LOG1, FL("Clear BSS from invalid channels")); |
| 4706 | csrScanFilterResults(pMac); |
| 4707 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4708 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 4709 | { |
| 4710 | vos_log_scan_pkt_type *pScanLog = NULL; |
| 4711 | tScanResultHandle hScanResult; |
| 4712 | tCsrScanResultInfo *pScanResult; |
| 4713 | tDot11fBeaconIEs *pIes; |
| 4714 | int n = 0, c = 0; |
| 4715 | |
| 4716 | WLAN_VOS_DIAG_LOG_ALLOC(pScanLog, vos_log_scan_pkt_type, LOG_WLAN_SCAN_C); |
| 4717 | if(pScanLog) |
| 4718 | { |
| 4719 | if(eCsrScanBgScan == pCommand->u.scanCmd.reason || |
| 4720 | eCsrScanProbeBss == pCommand->u.scanCmd.reason || |
| 4721 | eCsrScanSetBGScanParam == pCommand->u.scanCmd.reason) |
| 4722 | { |
| 4723 | pScanLog->eventId = WLAN_SCAN_EVENT_HO_SCAN_RSP; |
| 4724 | } |
| 4725 | else |
| 4726 | { |
| 4727 | if( eSIR_PASSIVE_SCAN != pMac->scan.curScanType ) |
| 4728 | { |
| 4729 | pScanLog->eventId = WLAN_SCAN_EVENT_ACTIVE_SCAN_RSP; |
| 4730 | } |
| 4731 | else |
| 4732 | { |
| 4733 | pScanLog->eventId = WLAN_SCAN_EVENT_PASSIVE_SCAN_RSP; |
| 4734 | } |
| 4735 | } |
| 4736 | if(eSIR_SME_SUCCESS == pScanRsp->statusCode) |
| 4737 | { |
| 4738 | if(HAL_STATUS_SUCCESS(csrScanGetResult(pMac, NULL, &hScanResult))) |
| 4739 | { |
| 4740 | while(((pScanResult = csrScanResultGetNext(pMac, hScanResult)) != NULL)) |
| 4741 | { |
| 4742 | if( n < VOS_LOG_MAX_NUM_BSSID ) |
| 4743 | { |
| 4744 | if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->BssDescriptor, &pIes))) |
| 4745 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 4746 | smsLog(pMac, LOGE, FL(" fail to parse IEs")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4747 | break; |
| 4748 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4749 | vos_mem_copy(pScanLog->bssid[n], |
| 4750 | pScanResult->BssDescriptor.bssId, 6); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4751 | if(pIes && pIes->SSID.present && VOS_LOG_MAX_SSID_SIZE >= pIes->SSID.num_ssid) |
| 4752 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4753 | vos_mem_copy(pScanLog->ssid[n], |
| 4754 | pIes->SSID.ssid, pIes->SSID.num_ssid); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4755 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4756 | vos_mem_free(pIes); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4757 | n++; |
| 4758 | } |
| 4759 | c++; |
| 4760 | } |
| 4761 | pScanLog->numSsid = (v_U8_t)n; |
| 4762 | pScanLog->totalSsid = (v_U8_t)c; |
| 4763 | csrScanResultPurge(pMac, hScanResult); |
| 4764 | } |
| 4765 | } |
| 4766 | else |
| 4767 | { |
| 4768 | pScanLog->status = WLAN_SCAN_STATUS_FAILURE; |
| 4769 | } |
| 4770 | WLAN_VOS_DIAG_LOG_REPORT(pScanLog); |
| 4771 | } |
| 4772 | } |
| 4773 | #endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 4774 | |
| 4775 | NextCommand = csrScanGetNextCommandState(pMac, pCommand, fSuccess); |
| 4776 | //We reuse the command here instead reissue a new command |
| 4777 | switch(NextCommand) |
| 4778 | { |
| 4779 | case eCsrNext11dScan1Success: |
| 4780 | case eCsrNext11dScan2Success: |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 4781 | smsLog( pMac, LOG2, FL("11dScan1/3 produced results. Reissue Active scan...")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4782 | // if we found country information, no need to continue scanning further, bail out |
| 4783 | fRemoveCommand = eANI_BOOLEAN_TRUE; |
| 4784 | NextCommand = eCsrNext11dScanComplete; |
| 4785 | break; |
| 4786 | case eCsrNext11dScan1Failure: |
| 4787 | //We are not done yet. 11d scan fail once. We will try to reset anything and do it over again |
| 4788 | //The only meaningful thing for this retry is that we cannot find 11d information after a reset so |
| 4789 | //we clear the "old" 11d info and give it once more chance |
| 4790 | fRemoveCommand = csrHandleScan11d1Failure(pMac, pCommand); |
| 4791 | if(fRemoveCommand) |
| 4792 | { |
| 4793 | NextCommand = eCsrNext11dScanComplete; |
| 4794 | } |
| 4795 | break; |
| 4796 | case eCsrNextLostLinkScan1Success: |
| 4797 | if(!HAL_STATUS_SUCCESS(csrIssueRoamAfterLostlinkScan(pMac, sessionId, eCsrLostLink1))) |
| 4798 | { |
| 4799 | csrScanHandleFailedLostlink1(pMac, sessionId); |
| 4800 | } |
| 4801 | break; |
| 4802 | case eCsrNextLostLinkScan2Success: |
| 4803 | if(!HAL_STATUS_SUCCESS(csrIssueRoamAfterLostlinkScan(pMac, sessionId, eCsrLostLink2))) |
| 4804 | { |
| 4805 | csrScanHandleFailedLostlink2(pMac, sessionId); |
| 4806 | } |
| 4807 | break; |
| 4808 | case eCsrNextLostLinkScan3Success: |
| 4809 | if(!HAL_STATUS_SUCCESS(csrIssueRoamAfterLostlinkScan(pMac, sessionId, eCsrLostLink3))) |
| 4810 | { |
| 4811 | csrScanHandleFailedLostlink3(pMac, sessionId); |
| 4812 | } |
| 4813 | break; |
| 4814 | case eCsrNextLostLinkScan1Failed: |
| 4815 | csrScanHandleFailedLostlink1(pMac, sessionId); |
| 4816 | break; |
| 4817 | case eCsrNextLostLinkScan2Failed: |
| 4818 | csrScanHandleFailedLostlink2(pMac, sessionId); |
| 4819 | break; |
| 4820 | case eCsrNextLostLinkScan3Failed: |
| 4821 | csrScanHandleFailedLostlink3(pMac, sessionId); |
| 4822 | break; |
| 4823 | case eCsrNexteScanForSsidSuccess: |
| 4824 | csrScanHandleSearchForSSID(pMac, pCommand); |
| 4825 | break; |
| 4826 | case eCsrNexteScanForSsidFailure: |
| 4827 | csrScanHandleSearchForSSIDFailure(pMac, pCommand); |
| 4828 | break; |
| 4829 | case eCsrNextIdleScanComplete: |
| 4830 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 4831 | break; |
| 4832 | case eCsrNextCapChangeScanComplete: |
| 4833 | csrScanHandleCapChangeScanComplete(pMac, sessionId); |
| 4834 | break; |
| 4835 | default: |
| 4836 | |
| 4837 | break; |
| 4838 | } |
| 4839 | } |
| 4840 | else |
| 4841 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 4842 | 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] | 4843 | fRemoveCommand = eANI_BOOLEAN_FALSE; |
| 4844 | } |
| 4845 | } |
| 4846 | else |
| 4847 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 4848 | smsLog( pMac, LOGW, FL("Scan Completion called but NO commands are ACTIVE ...")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4849 | fRemoveCommand = eANI_BOOLEAN_FALSE; |
| 4850 | } |
| 4851 | |
| 4852 | return( fRemoveCommand ); |
| 4853 | } |
| 4854 | |
| 4855 | |
| 4856 | |
| 4857 | static void csrScanRemoveDupBssDescriptionFromInterimList( tpAniSirGlobal pMac, |
| 4858 | tSirBssDescription *pSirBssDescr, |
| 4859 | tDot11fBeaconIEs *pIes) |
| 4860 | { |
| 4861 | tListElem *pEntry; |
| 4862 | tCsrScanResult *pCsrBssDescription; |
| 4863 | |
| 4864 | // Walk through all the chained BssDescriptions. If we find a chained BssDescription that |
| 4865 | // matches the BssID of the BssDescription passed in, then these must be duplicate scan |
| 4866 | // results for this Bss. In that case, remove the 'old' Bss description from the linked list. |
| 4867 | pEntry = csrLLPeekHead( &pMac->scan.tempScanResults, LL_ACCESS_LOCK ); |
| 4868 | while( pEntry ) |
| 4869 | { |
| 4870 | pCsrBssDescription = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 4871 | |
| 4872 | // we have a duplicate scan results only when BSSID, SSID, Channel and NetworkType |
| 4873 | // matches |
| 4874 | |
| 4875 | if ( csrIsDuplicateBssDescription( pMac, &pCsrBssDescription->Result.BssDescriptor, |
Tushnim Bhattacharyya | 5128d75 | 2013-06-26 23:23:18 -0700 | [diff] [blame] | 4876 | pSirBssDescr, pIes, FALSE ) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4877 | { |
| 4878 | pSirBssDescr->rssi = (tANI_S8)( (((tANI_S32)pSirBssDescr->rssi * CSR_SCAN_RESULT_RSSI_WEIGHT ) + |
| 4879 | ((tANI_S32)pCsrBssDescription->Result.BssDescriptor.rssi * (100 - CSR_SCAN_RESULT_RSSI_WEIGHT) )) / 100 ); |
| 4880 | |
| 4881 | // Remove the 'old' entry from the list.... |
| 4882 | if( csrLLRemoveEntry( &pMac->scan.tempScanResults, pEntry, LL_ACCESS_LOCK ) ) |
| 4883 | { |
| 4884 | csrCheckNSaveWscIe(pMac, pSirBssDescr, &pCsrBssDescription->Result.BssDescriptor); |
| 4885 | // we need to free the memory associated with this node |
| 4886 | csrFreeScanResultEntry( pMac, pCsrBssDescription ); |
| 4887 | } |
| 4888 | |
| 4889 | // If we found a match, we can stop looking through the list. |
| 4890 | break; |
| 4891 | } |
| 4892 | |
| 4893 | pEntry = csrLLNext( &pMac->scan.tempScanResults, pEntry, LL_ACCESS_LOCK ); |
| 4894 | } |
| 4895 | } |
| 4896 | |
| 4897 | |
| 4898 | |
| 4899 | //Caller allocated memory pfNewBssForConn to return whether new candidate for |
| 4900 | //current connection is found. Cannot be NULL |
| 4901 | tCsrScanResult *csrScanSaveBssDescriptionToInterimList( tpAniSirGlobal pMac, |
| 4902 | tSirBssDescription *pBSSDescription, |
| 4903 | tDot11fBeaconIEs *pIes) |
| 4904 | { |
| 4905 | tCsrScanResult *pCsrBssDescription = NULL; |
| 4906 | tANI_U32 cbBSSDesc; |
| 4907 | tANI_U32 cbAllocated; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4908 | |
| 4909 | // figure out how big the BSS description is (the BSSDesc->length does NOT |
| 4910 | // include the size of the length field itself). |
| 4911 | cbBSSDesc = pBSSDescription->length + sizeof( pBSSDescription->length ); |
| 4912 | |
| 4913 | cbAllocated = sizeof( tCsrScanResult ) + cbBSSDesc; |
| 4914 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4915 | pCsrBssDescription = vos_mem_malloc(cbAllocated); |
| 4916 | if ( NULL != pCsrBssDescription ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4917 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4918 | vos_mem_set(pCsrBssDescription, cbAllocated, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4919 | pCsrBssDescription->AgingCount = (tANI_S32)pMac->roam.configParam.agingCount; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4920 | vos_mem_copy(&pCsrBssDescription->Result.BssDescriptor, pBSSDescription, cbBSSDesc ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4921 | //Save SSID separately for later use |
| 4922 | if( pIes->SSID.present && !csrIsNULLSSID(pIes->SSID.ssid, pIes->SSID.num_ssid) ) |
| 4923 | { |
| 4924 | //SSID not hidden |
Madan Mohan Koyyalamudi | 4e31b13 | 2012-11-02 13:13:52 -0700 | [diff] [blame] | 4925 | tANI_U32 len = pIes->SSID.num_ssid; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4926 | if (len > SIR_MAC_MAX_SSID_LENGTH) |
| 4927 | { |
| 4928 | // truncate to fit in our struct |
| 4929 | len = SIR_MAC_MAX_SSID_LENGTH; |
| 4930 | } |
| 4931 | pCsrBssDescription->Result.ssId.length = len; |
| 4932 | pCsrBssDescription->Result.timer = vos_timer_get_system_time(); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 4933 | vos_mem_copy(pCsrBssDescription->Result.ssId.ssId, pIes->SSID.ssid, len); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4934 | } |
| 4935 | csrLLInsertTail( &pMac->scan.tempScanResults, &pCsrBssDescription->Link, LL_ACCESS_LOCK ); |
| 4936 | } |
| 4937 | |
| 4938 | return( pCsrBssDescription ); |
| 4939 | } |
| 4940 | |
| 4941 | |
| 4942 | |
| 4943 | |
| 4944 | tANI_BOOLEAN csrIsDuplicateBssDescription( tpAniSirGlobal pMac, tSirBssDescription *pSirBssDesc1, |
Tushnim Bhattacharyya | 5128d75 | 2013-06-26 23:23:18 -0700 | [diff] [blame] | 4945 | tSirBssDescription *pSirBssDesc2, tDot11fBeaconIEs *pIes2, tANI_BOOLEAN fForced ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4946 | { |
| 4947 | tANI_BOOLEAN fMatch = FALSE; |
| 4948 | tSirMacCapabilityInfo *pCap1, *pCap2; |
| 4949 | tDot11fBeaconIEs *pIes1 = NULL; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4950 | tDot11fBeaconIEs *pIesTemp = pIes2; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4951 | |
| 4952 | pCap1 = (tSirMacCapabilityInfo *)&pSirBssDesc1->capabilityInfo; |
| 4953 | pCap2 = (tSirMacCapabilityInfo *)&pSirBssDesc2->capabilityInfo; |
| 4954 | if(pCap1->ess == pCap2->ess) |
| 4955 | { |
| 4956 | if (pCap1->ess && |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4957 | csrIsMacAddressEqual( pMac, (tCsrBssid *)pSirBssDesc1->bssId, (tCsrBssid *)pSirBssDesc2->bssId)&& |
Abhishek Singh | e3fa11f | 2014-05-13 11:11:10 +0530 | [diff] [blame] | 4958 | (fForced || (vos_chan_to_band(pSirBssDesc1->channelId) == vos_chan_to_band((pSirBssDesc2->channelId))))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4959 | { |
| 4960 | fMatch = TRUE; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4961 | // Check for SSID match, if exists |
| 4962 | do |
| 4963 | { |
| 4964 | if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc1, &pIes1))) |
| 4965 | { |
| 4966 | break; |
| 4967 | } |
| 4968 | if( NULL == pIesTemp ) |
| 4969 | { |
| 4970 | if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc2, &pIesTemp))) |
| 4971 | { |
| 4972 | break; |
| 4973 | } |
| 4974 | } |
| 4975 | if(pIes1->SSID.present && pIesTemp->SSID.present) |
| 4976 | { |
| 4977 | fMatch = csrIsSsidMatch(pMac, pIes1->SSID.ssid, pIes1->SSID.num_ssid, |
| 4978 | pIesTemp->SSID.ssid, pIesTemp->SSID.num_ssid, eANI_BOOLEAN_TRUE); |
| 4979 | } |
| 4980 | }while(0); |
| 4981 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4982 | } |
| 4983 | else if (pCap1->ibss && (pSirBssDesc1->channelId == pSirBssDesc2->channelId)) |
| 4984 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4985 | |
| 4986 | do |
| 4987 | { |
| 4988 | if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc1, &pIes1))) |
| 4989 | { |
| 4990 | break; |
| 4991 | } |
| 4992 | if( NULL == pIesTemp ) |
| 4993 | { |
| 4994 | if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc2, &pIesTemp))) |
| 4995 | { |
| 4996 | break; |
| 4997 | } |
| 4998 | } |
| 4999 | //Same channel cannot have same SSID for different IBSS |
| 5000 | if(pIes1->SSID.present && pIesTemp->SSID.present) |
| 5001 | { |
| 5002 | fMatch = csrIsSsidMatch(pMac, pIes1->SSID.ssid, pIes1->SSID.num_ssid, |
| 5003 | pIesTemp->SSID.ssid, pIesTemp->SSID.num_ssid, eANI_BOOLEAN_TRUE); |
| 5004 | } |
| 5005 | }while(0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5006 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5007 | /* In case of P2P devices, ess and ibss will be set to zero */ |
| 5008 | else if (!pCap1->ess && |
| 5009 | csrIsMacAddressEqual( pMac, (tCsrBssid *)pSirBssDesc1->bssId, (tCsrBssid *)pSirBssDesc2->bssId)) |
| 5010 | { |
| 5011 | fMatch = TRUE; |
| 5012 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5013 | } |
| 5014 | |
| 5015 | if(pIes1) |
| 5016 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5017 | vos_mem_free(pIes1); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5018 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5019 | |
| 5020 | if( (NULL == pIes2) && pIesTemp ) |
| 5021 | { |
| 5022 | //locally allocated |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5023 | vos_mem_free(pIesTemp); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5024 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5025 | |
| 5026 | return( fMatch ); |
| 5027 | } |
| 5028 | |
| 5029 | |
| 5030 | tANI_BOOLEAN csrIsNetworkTypeEqual( tSirBssDescription *pSirBssDesc1, tSirBssDescription *pSirBssDesc2 ) |
| 5031 | { |
| 5032 | return( pSirBssDesc1->nwType == pSirBssDesc2->nwType ); |
| 5033 | } |
| 5034 | |
| 5035 | |
| 5036 | //to check whether the BSS matches the dot11Mode |
| 5037 | static tANI_BOOLEAN csrScanIsBssAllowed(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc, |
| 5038 | tDot11fBeaconIEs *pIes) |
| 5039 | { |
| 5040 | tANI_BOOLEAN fAllowed = eANI_BOOLEAN_FALSE; |
| 5041 | eCsrPhyMode phyMode; |
| 5042 | |
| 5043 | if(HAL_STATUS_SUCCESS(csrGetPhyModeFromBss(pMac, pBssDesc, &phyMode, pIes))) |
| 5044 | { |
| 5045 | switch(pMac->roam.configParam.phyMode) |
| 5046 | { |
| 5047 | case eCSR_DOT11_MODE_11b: |
| 5048 | fAllowed = (tANI_BOOLEAN)(eCSR_DOT11_MODE_11a != phyMode); |
| 5049 | break; |
| 5050 | case eCSR_DOT11_MODE_11g: |
| 5051 | fAllowed = (tANI_BOOLEAN)(eCSR_DOT11_MODE_11a != phyMode); |
| 5052 | break; |
| 5053 | case eCSR_DOT11_MODE_11g_ONLY: |
| 5054 | fAllowed = (tANI_BOOLEAN)(eCSR_DOT11_MODE_11g == phyMode); |
| 5055 | break; |
| 5056 | case eCSR_DOT11_MODE_11a: |
| 5057 | fAllowed = (tANI_BOOLEAN)((eCSR_DOT11_MODE_11b != phyMode) && (eCSR_DOT11_MODE_11g != phyMode)); |
| 5058 | break; |
| 5059 | case eCSR_DOT11_MODE_11n_ONLY: |
| 5060 | fAllowed = (tANI_BOOLEAN)((eCSR_DOT11_MODE_11n == phyMode) || (eCSR_DOT11_MODE_TAURUS == phyMode)); |
| 5061 | break; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5062 | |
| 5063 | #ifdef WLAN_FEATURE_11AC |
| 5064 | case eCSR_DOT11_MODE_11ac_ONLY: |
| 5065 | fAllowed = (tANI_BOOLEAN)((eCSR_DOT11_MODE_11ac == phyMode) || (eCSR_DOT11_MODE_TAURUS == phyMode)); |
| 5066 | break; |
| 5067 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5068 | case eCSR_DOT11_MODE_11b_ONLY: |
| 5069 | fAllowed = (tANI_BOOLEAN)(eCSR_DOT11_MODE_11b == phyMode); |
| 5070 | break; |
| 5071 | case eCSR_DOT11_MODE_11a_ONLY: |
| 5072 | fAllowed = (tANI_BOOLEAN)(eCSR_DOT11_MODE_11a == phyMode); |
| 5073 | break; |
| 5074 | case eCSR_DOT11_MODE_11n: |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5075 | #ifdef WLAN_FEATURE_11AC |
| 5076 | case eCSR_DOT11_MODE_11ac: |
| 5077 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5078 | case eCSR_DOT11_MODE_TAURUS: |
| 5079 | default: |
| 5080 | fAllowed = eANI_BOOLEAN_TRUE; |
| 5081 | break; |
| 5082 | } |
| 5083 | } |
| 5084 | |
| 5085 | return (fAllowed); |
| 5086 | } |
| 5087 | |
| 5088 | |
| 5089 | |
| 5090 | //Return pIes to caller for future use when returning TRUE. |
| 5091 | static tANI_BOOLEAN csrScanValidateScanResult( tpAniSirGlobal pMac, tANI_U8 *pChannels, |
| 5092 | tANI_U8 numChn, tSirBssDescription *pBssDesc, |
| 5093 | tDot11fBeaconIEs **ppIes ) |
| 5094 | { |
| 5095 | tANI_BOOLEAN fValidChannel = FALSE; |
| 5096 | tDot11fBeaconIEs *pIes = NULL; |
| 5097 | tANI_U8 index; |
| 5098 | |
| 5099 | for( index = 0; index < numChn; index++ ) |
| 5100 | { |
| 5101 | // This check relies on the fact that a single BSS description is returned in each |
| 5102 | // ScanRsp call, which is the way LIM implemented the scan req/rsp funtions. We changed |
| 5103 | // to this model when we ran with a large number of APs. If this were to change, then |
| 5104 | // this check would have to mess with removing the bssDescription from somewhere in an |
| 5105 | // arbitrary index in the bssDescription array. |
| 5106 | if ( pChannels[ index ] == pBssDesc->channelId ) |
| 5107 | { |
| 5108 | fValidChannel = TRUE; |
| 5109 | break; |
| 5110 | } |
| 5111 | } |
| 5112 | *ppIes = NULL; |
| 5113 | if(fValidChannel) |
| 5114 | { |
| 5115 | if( HAL_STATUS_SUCCESS( csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes) ) ) |
| 5116 | { |
| 5117 | fValidChannel = csrScanIsBssAllowed(pMac, pBssDesc, pIes); |
| 5118 | if( fValidChannel ) |
| 5119 | { |
| 5120 | *ppIes = pIes; |
| 5121 | } |
| 5122 | else |
| 5123 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5124 | vos_mem_free(pIes); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5125 | } |
| 5126 | } |
| 5127 | else |
| 5128 | { |
| 5129 | fValidChannel = FALSE; |
| 5130 | } |
| 5131 | } |
| 5132 | |
| 5133 | return( fValidChannel ); |
| 5134 | } |
| 5135 | |
| 5136 | |
| 5137 | //Return whether last scan result is received |
| 5138 | static tANI_BOOLEAN csrScanProcessScanResults( tpAniSirGlobal pMac, tSmeCmd *pCommand, |
| 5139 | tSirSmeScanRsp *pScanRsp, tANI_BOOLEAN *pfRemoveCommand ) |
| 5140 | { |
| 5141 | tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE, fRemoveCommand = eANI_BOOLEAN_FALSE; |
| 5142 | tDot11fBeaconIEs *pIes = NULL; |
| 5143 | tANI_U32 cbParsed; |
| 5144 | tSirBssDescription *pSirBssDescription; |
| 5145 | tANI_U32 cbBssDesc; |
| 5146 | tANI_U32 cbScanResult = GET_FIELD_OFFSET( tSirSmeScanRsp, bssDescription ) |
| 5147 | + sizeof(tSirBssDescription); //We need at least one CB |
| 5148 | |
| 5149 | // don't consider the scan rsp to be valid if the status code is Scan Failure. Scan Failure |
| 5150 | // is returned when the scan could not find anything. so if we get scan failure return that |
| 5151 | // the scan response is invalid. Also check the lenght in the scan result for valid scan |
| 5152 | // BssDescriptions.... |
| 5153 | do |
| 5154 | { |
| 5155 | if ( ( cbScanResult <= pScanRsp->length ) && |
| 5156 | (( eSIR_SME_SUCCESS == pScanRsp->statusCode ) || |
| 5157 | ( eSIR_SME_MORE_SCAN_RESULTS_FOLLOW == pScanRsp->statusCode ) ) ) |
| 5158 | { |
| 5159 | tANI_U8 *pChannelList = NULL; |
| 5160 | tANI_U8 cChannels = 0; |
| 5161 | |
| 5162 | //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] | 5163 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 5164 | if( eCsrScanGetLfrResult == pCommand->u.scanCmd.reason ) |
| 5165 | { |
| 5166 | pChannelList = NULL; |
| 5167 | cChannels = 0; |
| 5168 | } |
| 5169 | else |
| 5170 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5171 | if( eCsrScanSetBGScanParam == pCommand->u.scanCmd.reason ) |
| 5172 | { |
| 5173 | //eCsrScanSetBGScanParam uses different structure |
| 5174 | tCsrBGScanRequest *pBgScanReq = &pCommand->u.scanCmd.u.bgScanRequest; |
| 5175 | |
| 5176 | cChannels = pBgScanReq->ChannelInfo.numOfChannels; |
| 5177 | pChannelList = pBgScanReq->ChannelInfo.ChannelList; |
| 5178 | } |
| 5179 | else |
| 5180 | { |
| 5181 | //the rest use generic scan request |
| 5182 | cChannels = pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels; |
| 5183 | pChannelList = pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList; |
| 5184 | } |
| 5185 | |
| 5186 | // if the scan result is not on one of the channels in the Valid channel list, then it |
| 5187 | // must have come from an AP on an overlapping channel (in the 2.4GHz band). In this case, |
| 5188 | // let's drop the scan result. |
| 5189 | // |
| 5190 | // The other situation is where the scan request is for a scan on a particular channel set |
| 5191 | // and the scan result is from a |
| 5192 | |
| 5193 | // if the NumChannels is 0, then we are supposed to be scanning all channels. Use the full channel |
| 5194 | // list as the 'valid' channel list. Otherwise, use the specific channel list in the scan parms |
| 5195 | // as the valid channels. |
| 5196 | if ( 0 == cChannels ) |
| 5197 | { |
| 5198 | tANI_U32 len = sizeof(pMac->roam.validChannelList); |
| 5199 | |
| 5200 | if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len))) |
| 5201 | { |
| 5202 | pChannelList = pMac->roam.validChannelList; |
| 5203 | cChannels = (tANI_U8)len; |
| 5204 | } |
| 5205 | else |
| 5206 | { |
| 5207 | //Cannot continue |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5208 | smsLog( pMac, LOGE, "CSR: Processing internal SCAN results...csrGetCfgValidChannels failed" ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5209 | break; |
| 5210 | } |
| 5211 | } |
| 5212 | |
| 5213 | smsLog( pMac, LOG2, "CSR: Processing internal SCAN results..." ); |
| 5214 | cbParsed = GET_FIELD_OFFSET( tSirSmeScanRsp, bssDescription ); |
| 5215 | pSirBssDescription = pScanRsp->bssDescription; |
| 5216 | while( cbParsed < pScanRsp->length ) |
| 5217 | { |
| 5218 | if ( csrScanValidateScanResult( pMac, pChannelList, cChannels, pSirBssDescription, &pIes ) ) |
| 5219 | { |
| 5220 | csrScanRemoveDupBssDescriptionFromInterimList(pMac, pSirBssDescription, pIes); |
| 5221 | csrScanSaveBssDescriptionToInterimList( pMac, pSirBssDescription, pIes ); |
| 5222 | if( eSIR_PASSIVE_SCAN == pMac->scan.curScanType ) |
| 5223 | { |
| 5224 | if( csrIs11dSupported( pMac) ) |
| 5225 | { |
| 5226 | //Check whether the BSS is acceptable base on 11d info and our configs. |
| 5227 | if( csrMatchCountryCode( pMac, NULL, pIes ) ) |
| 5228 | { |
| 5229 | //Double check whether the channel is acceptable by us. |
| 5230 | if( csrIsSupportedChannel( pMac, pSirBssDescription->channelId ) ) |
| 5231 | { |
| 5232 | pMac->scan.curScanType = eSIR_ACTIVE_SCAN; |
| 5233 | } |
| 5234 | } |
| 5235 | } |
| 5236 | else |
| 5237 | { |
| 5238 | pMac->scan.curScanType = eSIR_ACTIVE_SCAN; |
| 5239 | } |
| 5240 | } |
| 5241 | //Free the resource |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5242 | vos_mem_free(pIes); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5243 | } |
| 5244 | // skip over the BSS description to the next one... |
| 5245 | cbBssDesc = pSirBssDescription->length + sizeof( pSirBssDescription->length ); |
| 5246 | |
| 5247 | cbParsed += cbBssDesc; |
| 5248 | pSirBssDescription = (tSirBssDescription *)((tANI_U8 *)pSirBssDescription + cbBssDesc ); |
| 5249 | |
| 5250 | } //while |
| 5251 | } |
| 5252 | else |
| 5253 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5254 | smsLog( pMac, LOGW, " Scanrsp fail (0x%08X), length = %d (expected %d)", |
Madan Mohan Koyyalamudi | dd3c966 | 2012-11-09 17:39:30 -0800 | [diff] [blame] | 5255 | pScanRsp->statusCode, pScanRsp->length, cbScanResult); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5256 | //HO bg scan/probe failed no need to try autonomously |
| 5257 | if(eCsrScanBgScan == pCommand->u.scanCmd.reason || |
| 5258 | eCsrScanProbeBss == pCommand->u.scanCmd.reason || |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 5259 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 5260 | eCsrScanGetLfrResult == pCommand->u.scanCmd.reason || |
| 5261 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5262 | eCsrScanSetBGScanParam == pCommand->u.scanCmd.reason) |
| 5263 | { |
| 5264 | fRemoveCommand = eANI_BOOLEAN_TRUE; |
| 5265 | } |
| 5266 | } |
| 5267 | }while(0); |
| 5268 | if ( eSIR_SME_MORE_SCAN_RESULTS_FOLLOW != pScanRsp->statusCode ) |
| 5269 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5270 | 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] | 5271 | fRemoveCommand = csrScanComplete( pMac, pScanRsp ); |
| 5272 | fRet = eANI_BOOLEAN_TRUE; |
| 5273 | }//if ( eSIR_SME_MORE_SCAN_RESULTS_FOLLOW != pScanRsp->statusCode ) |
| 5274 | if(pfRemoveCommand) |
| 5275 | { |
| 5276 | *pfRemoveCommand = fRemoveCommand; |
| 5277 | } |
| 5278 | |
| 5279 | #ifdef WLAN_AP_STA_CONCURRENCY |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 5280 | if (pMac->fScanOffload) |
| 5281 | return fRet; |
| 5282 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5283 | if (!csrLLIsListEmpty( &pMac->scan.scanCmdPendingList, LL_ACCESS_LOCK )) |
| 5284 | { |
Madan Mohan Koyyalamudi | 48081ef | 2012-12-04 16:49:55 -0800 | [diff] [blame] | 5285 | /* Pending scan commands in the list because the previous scan command |
| 5286 | * was split into a scan command on one channel + a scan command for all |
| 5287 | * remaining channels. |
| 5288 | * |
| 5289 | * Start timer to trigger processing of the next scan command. |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 5290 | * NOTE for LFR: |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 5291 | * Do not split scans if no concurrent infra connections are |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 5292 | * active and if the scan is a BG scan triggered by LFR (OR) |
| 5293 | * any scan if LFR is in the middle of a BG scan. Splitting |
| 5294 | * the scan is delaying the time it takes for LFR to find |
| 5295 | * candidates and resulting in disconnects. |
Madan Mohan Koyyalamudi | 48081ef | 2012-12-04 16:49:55 -0800 | [diff] [blame] | 5296 | */ |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 5297 | if ( (csrIsStaSessionConnected(pMac) && |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 5298 | #ifdef FEATURE_WLAN_LFR |
| 5299 | (csrIsConcurrentInfraConnected(pMac) || |
| 5300 | ((pCommand->u.scanCmd.reason != eCsrScanBgScan) && |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 5301 | (pMac->roam.neighborRoamInfo.neighborRoamState != |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 5302 | eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN))) && |
| 5303 | #endif |
| 5304 | (pCommand->u.scanCmd.u.scanRequest.p2pSearch != 1)) || |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 5305 | (csrIsP2pSessionConnected(pMac)) ) |
Madan Mohan Koyyalamudi | 48081ef | 2012-12-04 16:49:55 -0800 | [diff] [blame] | 5306 | { |
Madan Mohan Koyyalamudi | d671358 | 2012-11-09 16:56:56 -0800 | [diff] [blame] | 5307 | /* if active connected sessions present then continue to split scan |
| 5308 | * with specified interval between consecutive scans */ |
| 5309 | 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] | 5310 | vos_timer_start(&pMac->scan.hTimerStaApConcTimer, |
| 5311 | pCommand->u.scanCmd.u.scanRequest.restTime); |
Madan Mohan Koyyalamudi | d671358 | 2012-11-09 16:56:56 -0800 | [diff] [blame] | 5312 | } else { |
| 5313 | /* if no connected sessions present then initiate next scan command immediately */ |
| 5314 | /* minimum timer granularity is 10ms */ |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 5315 | vos_timer_start(&pMac->scan.hTimerStaApConcTimer, 10); |
Madan Mohan Koyyalamudi | d671358 | 2012-11-09 16:56:56 -0800 | [diff] [blame] | 5316 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5317 | } |
| 5318 | #endif |
| 5319 | return (fRet); |
| 5320 | } |
| 5321 | |
| 5322 | |
| 5323 | tANI_BOOLEAN csrScanIsWildCardScan( tpAniSirGlobal pMac, tSmeCmd *pCommand ) |
| 5324 | { |
| 5325 | tANI_U8 bssid[WNI_CFG_BSSID_LEN] = {0, 0, 0, 0, 0, 0}; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5326 | tANI_BOOLEAN f = vos_mem_compare(pCommand->u.scanCmd.u.scanRequest.bssid, |
| 5327 | bssid, sizeof(tCsrBssid)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5328 | |
| 5329 | //It is not a wild card scan if the bssid is not broadcast and the number of SSID is 1. |
| 5330 | return ((tANI_BOOLEAN)( (f || (0xff == pCommand->u.scanCmd.u.scanRequest.bssid[0])) && |
| 5331 | (pCommand->u.scanCmd.u.scanRequest.SSIDs.numOfSSIDs != 1) )); |
| 5332 | } |
| 5333 | |
| 5334 | |
| 5335 | eHalStatus csrScanSmeScanResponse( tpAniSirGlobal pMac, void *pMsgBuf ) |
| 5336 | { |
| 5337 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 5338 | tListElem *pEntry; |
| 5339 | tSmeCmd *pCommand; |
| 5340 | eCsrScanStatus scanStatus; |
| 5341 | tSirSmeScanRsp *pScanRsp = (tSirSmeScanRsp *)pMsgBuf; |
| 5342 | tSmeGetScanChnRsp *pScanChnInfo; |
| 5343 | tANI_BOOLEAN fRemoveCommand = eANI_BOOLEAN_TRUE; |
| 5344 | eCsrScanReason reason = eCsrScanOther; |
| 5345 | |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 5346 | if (pMac->fScanOffload) |
| 5347 | pEntry = csrLLPeekHead(&pMac->sme.smeScanCmdActiveList, |
| 5348 | LL_ACCESS_LOCK); |
| 5349 | else |
| 5350 | pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5351 | |
| 5352 | if ( pEntry ) |
| 5353 | { |
| 5354 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 5355 | if ( eSmeCommandScan == pCommand->command ) |
| 5356 | { |
| 5357 | scanStatus = (eSIR_SME_SUCCESS == pScanRsp->statusCode) ? eCSR_SCAN_SUCCESS : eCSR_SCAN_FAILURE; |
| 5358 | reason = pCommand->u.scanCmd.reason; |
| 5359 | switch(pCommand->u.scanCmd.reason) |
| 5360 | { |
| 5361 | case eCsrScanAbortBgScan: |
| 5362 | case eCsrScanAbortNormalScan: |
| 5363 | case eCsrScanBGScanAbort: |
| 5364 | case eCsrScanBGScanEnable: |
| 5365 | break; |
| 5366 | case eCsrScanGetScanChnInfo: |
| 5367 | pScanChnInfo = (tSmeGetScanChnRsp *)pMsgBuf; |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5368 | /* |
| 5369 | * status code not available in tSmeGetScanChnRsp, so |
| 5370 | * by default considereing it to be success |
| 5371 | */ |
| 5372 | scanStatus = eSIR_SME_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5373 | csrScanAgeResults(pMac, pScanChnInfo); |
| 5374 | break; |
| 5375 | case eCsrScanForCapsChange: |
| 5376 | csrScanProcessScanResults( pMac, pCommand, pScanRsp, &fRemoveCommand ); |
| 5377 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5378 | case eCsrScanP2PFindPeer: |
| 5379 | scanStatus = ((eSIR_SME_SUCCESS == pScanRsp->statusCode) && (pScanRsp->length > 50)) ? eCSR_SCAN_FOUND_PEER : eCSR_SCAN_FAILURE; |
| 5380 | csrScanProcessScanResults( pMac, pCommand, pScanRsp, NULL ); |
| 5381 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5382 | case eCsrScanSetBGScanParam: |
| 5383 | default: |
| 5384 | if(csrScanProcessScanResults( pMac, pCommand, pScanRsp, &fRemoveCommand )) |
| 5385 | { |
| 5386 | //Not to get channel info if the scan is not a wildcard scan because |
| 5387 | //it may cause scan results got aged out incorrectly. |
Ratheesh S P | ece1f83 | 2015-07-25 15:50:25 +0530 | [diff] [blame] | 5388 | if(csrScanIsWildCardScan( pMac, pCommand ) && |
| 5389 | (!pCommand->u.scanCmd.u.scanRequest.p2pSearch) |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 5390 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 5391 | && (pCommand->u.scanCmd.reason != eCsrScanGetLfrResult) |
| 5392 | #endif |
| 5393 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5394 | { |
Ratheesh S P | ece1f83 | 2015-07-25 15:50:25 +0530 | [diff] [blame] | 5395 | csrScanGetScanChnInfo(pMac, pCommand); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5396 | } |
| 5397 | } |
| 5398 | break; |
| 5399 | }//switch |
| 5400 | if(fRemoveCommand) |
| 5401 | { |
| 5402 | |
| 5403 | csrReleaseScanCommand(pMac, pCommand, scanStatus); |
| 5404 | |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 5405 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5406 | smeProcessPendingQueue( pMac ); |
| 5407 | } |
| 5408 | else |
| 5409 | { |
| 5410 | smsLog( pMac, LOGW, "CSR: Scan Completion called but SCAN command is not ACTIVE ..." ); |
| 5411 | status = eHAL_STATUS_FAILURE; |
| 5412 | } |
| 5413 | } |
| 5414 | else |
| 5415 | { |
| 5416 | smsLog( pMac, LOGW, "CSR: Scan Completion called but NO commands are ACTIVE ..." ); |
| 5417 | status = eHAL_STATUS_FAILURE; |
| 5418 | } |
| 5419 | |
| 5420 | return (status); |
| 5421 | } |
| 5422 | |
| 5423 | |
| 5424 | |
| 5425 | |
| 5426 | tCsrScanResultInfo *csrScanResultGetFirst(tpAniSirGlobal pMac, tScanResultHandle hScanResult) |
| 5427 | { |
| 5428 | tListElem *pEntry; |
| 5429 | tCsrScanResult *pResult; |
| 5430 | tCsrScanResultInfo *pRet = NULL; |
| 5431 | tScanResultList *pResultList = (tScanResultList *)hScanResult; |
| 5432 | |
| 5433 | if(pResultList) |
| 5434 | { |
| 5435 | csrLLLock(&pResultList->List); |
| 5436 | pEntry = csrLLPeekHead(&pResultList->List, LL_ACCESS_NOLOCK); |
| 5437 | if(pEntry) |
| 5438 | { |
| 5439 | pResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link); |
| 5440 | pRet = &pResult->Result; |
| 5441 | } |
| 5442 | pResultList->pCurEntry = pEntry; |
| 5443 | csrLLUnlock(&pResultList->List); |
| 5444 | } |
| 5445 | |
| 5446 | return pRet; |
| 5447 | } |
| 5448 | |
| 5449 | |
| 5450 | tCsrScanResultInfo *csrScanResultGetNext(tpAniSirGlobal pMac, tScanResultHandle hScanResult) |
| 5451 | { |
| 5452 | tListElem *pEntry = NULL; |
| 5453 | tCsrScanResult *pResult = NULL; |
| 5454 | tCsrScanResultInfo *pRet = NULL; |
| 5455 | tScanResultList *pResultList = (tScanResultList *)hScanResult; |
| 5456 | |
| 5457 | if(pResultList) |
| 5458 | { |
| 5459 | csrLLLock(&pResultList->List); |
| 5460 | if(NULL == pResultList->pCurEntry) |
| 5461 | { |
| 5462 | pEntry = csrLLPeekHead(&pResultList->List, LL_ACCESS_NOLOCK); |
| 5463 | } |
| 5464 | else |
| 5465 | { |
| 5466 | pEntry = csrLLNext(&pResultList->List, pResultList->pCurEntry, LL_ACCESS_NOLOCK); |
| 5467 | } |
| 5468 | if(pEntry) |
| 5469 | { |
| 5470 | pResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link); |
| 5471 | pRet = &pResult->Result; |
| 5472 | } |
| 5473 | pResultList->pCurEntry = pEntry; |
| 5474 | csrLLUnlock(&pResultList->List); |
| 5475 | } |
| 5476 | |
| 5477 | return pRet; |
| 5478 | } |
| 5479 | |
| 5480 | |
| 5481 | //This function moves the first BSS that matches the bssid to the head of the result |
| 5482 | eHalStatus csrMoveBssToHeadFromBSSID(tpAniSirGlobal pMac, tCsrBssid *bssid, tScanResultHandle hScanResult) |
| 5483 | { |
| 5484 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 5485 | tScanResultList *pResultList = (tScanResultList *)hScanResult; |
| 5486 | tCsrScanResult *pResult = NULL; |
| 5487 | tListElem *pEntry = NULL; |
| 5488 | |
| 5489 | if(pResultList && bssid) |
| 5490 | { |
| 5491 | csrLLLock(&pResultList->List); |
| 5492 | pEntry = csrLLPeekHead(&pResultList->List, LL_ACCESS_NOLOCK); |
| 5493 | while(pEntry) |
| 5494 | { |
| 5495 | pResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5496 | if (vos_mem_compare(bssid, pResult->Result.BssDescriptor.bssId, sizeof(tCsrBssid))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5497 | { |
| 5498 | status = eHAL_STATUS_SUCCESS; |
| 5499 | csrLLRemoveEntry(&pResultList->List, pEntry, LL_ACCESS_NOLOCK); |
| 5500 | csrLLInsertHead(&pResultList->List, pEntry, LL_ACCESS_NOLOCK); |
| 5501 | break; |
| 5502 | } |
| 5503 | pEntry = csrLLNext(&pResultList->List, pResultList->pCurEntry, LL_ACCESS_NOLOCK); |
| 5504 | } |
| 5505 | csrLLUnlock(&pResultList->List); |
| 5506 | } |
| 5507 | |
| 5508 | return (status); |
| 5509 | } |
| 5510 | |
| 5511 | |
| 5512 | //Remove the BSS if possible. |
| 5513 | //Return -- TRUE == the BSS is remove. False == Fail to remove it |
| 5514 | //This function is called when list lock is held. Be caution what functions it can call. |
| 5515 | tANI_BOOLEAN csrScanAgeOutBss(tpAniSirGlobal pMac, tCsrScanResult *pResult) |
| 5516 | { |
| 5517 | tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE; |
| 5518 | tANI_U32 i; |
| 5519 | tCsrRoamSession *pSession; |
Padma, Santhosh Kumar | 748b978 | 2014-07-02 12:24:23 +0530 | [diff] [blame] | 5520 | tANI_BOOLEAN isConnBssfound = eANI_BOOLEAN_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5521 | |
| 5522 | for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ ) |
| 5523 | { |
| 5524 | if( CSR_IS_SESSION_VALID( pMac, i ) ) |
| 5525 | { |
| 5526 | pSession = CSR_GET_SESSION( pMac, i ); |
| 5527 | //Not to remove the BSS we are connected to. |
Padma, Santhosh Kumar | 748b978 | 2014-07-02 12:24:23 +0530 | [diff] [blame] | 5528 | if(csrIsConnStateConnectedInfra(pMac, i) && (NULL != pSession->pConnectBssDesc) && |
| 5529 | (csrIsDuplicateBssDescription(pMac, &pResult->Result.BssDescriptor, |
Tushnim Bhattacharyya | 5128d75 | 2013-06-26 23:23:18 -0700 | [diff] [blame] | 5530 | pSession->pConnectBssDesc, NULL, FALSE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5531 | ) |
Padma, Santhosh Kumar | 748b978 | 2014-07-02 12:24:23 +0530 | [diff] [blame] | 5532 | { |
| 5533 | isConnBssfound = eANI_BOOLEAN_TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5534 | break; |
Padma, Santhosh Kumar | 748b978 | 2014-07-02 12:24:23 +0530 | [diff] [blame] | 5535 | } |
| 5536 | } |
| 5537 | } |
| 5538 | |
| 5539 | if( isConnBssfound ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5540 | { |
Padma, Santhosh Kumar | 748b978 | 2014-07-02 12:24:23 +0530 | [diff] [blame] | 5541 | //Reset the counter so that aging out of connected BSS won't hapeen too soon |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5542 | pResult->AgingCount = (tANI_S32)pMac->roam.configParam.agingCount; |
| 5543 | pResult->Result.BssDescriptor.nReceivedTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd); |
Padma, Santhosh Kumar | 748b978 | 2014-07-02 12:24:23 +0530 | [diff] [blame] | 5544 | |
| 5545 | return (fRet); |
| 5546 | } |
| 5547 | else |
| 5548 | { |
| 5549 | smsLog(pMac, LOGW, "Aging out BSS "MAC_ADDRESS_STR" Channel %d", |
| 5550 | MAC_ADDR_ARRAY(pResult->Result.BssDescriptor.bssId), |
| 5551 | pResult->Result.BssDescriptor.channelId); |
| 5552 | //No need to hold the spin lock because caller should hold the lock for pMac->scan.scanResultList |
| 5553 | if( csrLLRemoveEntry(&pMac->scan.scanResultList, &pResult->Link, LL_ACCESS_NOLOCK) ) |
| 5554 | { |
| 5555 | if (csrIsMacAddressEqual(pMac, |
| 5556 | (tCsrBssid *) pResult->Result.BssDescriptor.bssId, |
| 5557 | (tCsrBssid *) pMac->scan.currentCountryBssid)) |
| 5558 | { |
| 5559 | smsLog(pMac, LOGW, "Aging out 11d BSS "MAC_ADDRESS_STR, |
| 5560 | MAC_ADDR_ARRAY(pResult->Result.BssDescriptor.bssId)); |
| 5561 | pMac->scan.currentCountryRSSI = -128; |
| 5562 | } |
| 5563 | csrFreeScanResultEntry(pMac, pResult); |
| 5564 | fRet = eANI_BOOLEAN_TRUE; |
| 5565 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5566 | } |
| 5567 | |
| 5568 | return (fRet); |
| 5569 | } |
| 5570 | |
| 5571 | |
| 5572 | eHalStatus csrScanAgeResults(tpAniSirGlobal pMac, tSmeGetScanChnRsp *pScanChnInfo) |
| 5573 | { |
| 5574 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 5575 | tListElem *pEntry, *tmpEntry; |
| 5576 | tCsrScanResult *pResult; |
| 5577 | tLimScanChn *pChnInfo; |
| 5578 | tANI_U8 i; |
| 5579 | |
| 5580 | csrLLLock(&pMac->scan.scanResultList); |
| 5581 | for(i = 0; i < pScanChnInfo->numChn; i++) |
| 5582 | { |
| 5583 | pChnInfo = &pScanChnInfo->scanChn[i]; |
| 5584 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK ); |
| 5585 | while( pEntry ) |
| 5586 | { |
| 5587 | tmpEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK); |
| 5588 | pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 5589 | if(pResult->Result.BssDescriptor.channelId == pChnInfo->channelId) |
| 5590 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5591 | if(pResult->AgingCount <= 0) |
| 5592 | { |
| 5593 | smsLog(pMac, LOGW, " age out due to ref count"); |
| 5594 | csrScanAgeOutBss(pMac, pResult); |
| 5595 | } |
Madan Mohan Koyyalamudi | b9d3dcc | 2012-09-28 16:47:50 -0700 | [diff] [blame] | 5596 | else |
| 5597 | { |
| 5598 | pResult->AgingCount--; |
| 5599 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5600 | } |
| 5601 | pEntry = tmpEntry; |
| 5602 | } |
| 5603 | } |
| 5604 | csrLLUnlock(&pMac->scan.scanResultList); |
| 5605 | |
| 5606 | return (status); |
| 5607 | } |
| 5608 | |
Abhishek Singh | c640dbb | 2015-06-08 10:54:17 +0530 | [diff] [blame] | 5609 | eHalStatus csrIbssAgeBss(tpAniSirGlobal pMac) |
| 5610 | { |
| 5611 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 5612 | tListElem *pEntry, *tmpEntry; |
| 5613 | tCsrScanResult *pResult; |
| 5614 | |
| 5615 | csrLLLock(&pMac->scan.scanResultList); |
| 5616 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK ); |
| 5617 | while( pEntry ) |
| 5618 | { |
| 5619 | tmpEntry = csrLLNext(&pMac->scan.scanResultList, |
| 5620 | pEntry, LL_ACCESS_NOLOCK); |
| 5621 | pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 5622 | |
| 5623 | smsLog(pMac, LOGW, FL(" age out due Forced IBSS leave")); |
| 5624 | csrScanAgeOutBss(pMac, pResult); |
| 5625 | pEntry = tmpEntry; |
| 5626 | } |
| 5627 | csrLLUnlock(&pMac->scan.scanResultList); |
| 5628 | |
| 5629 | return (status); |
| 5630 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5631 | |
| 5632 | eHalStatus csrSendMBScanReq( tpAniSirGlobal pMac, tANI_U16 sessionId, |
| 5633 | tCsrScanRequest *pScanReq, tScanReqParam *pScanReqParam ) |
| 5634 | { |
| 5635 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 5636 | tSirSmeScanReq *pMsg; |
| 5637 | tANI_U16 msgLen; |
| 5638 | tANI_U8 bssid[WNI_CFG_BSSID_LEN] = {0, 0, 0, 0, 0, 0}; |
| 5639 | tSirScanType scanType = pScanReq->scanType; |
| 5640 | tANI_U32 minChnTime; //in units of milliseconds |
| 5641 | tANI_U32 maxChnTime; //in units of milliseconds |
| 5642 | tANI_U32 i; |
| 5643 | tANI_U8 selfMacAddr[WNI_CFG_BSSID_LEN]; |
| 5644 | tANI_U8 *pSelfMac = NULL; |
| 5645 | |
| 5646 | msgLen = (tANI_U16)(sizeof( tSirSmeScanReq ) - sizeof( pMsg->channelList.channelNumber ) + |
| 5647 | ( sizeof( pMsg->channelList.channelNumber ) * pScanReq->ChannelInfo.numOfChannels )) + |
| 5648 | ( pScanReq->uIEFieldLen ) ; |
| 5649 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5650 | pMsg = vos_mem_malloc(msgLen); |
| 5651 | if ( NULL == pMsg ) |
| 5652 | status = eHAL_STATUS_FAILURE; |
| 5653 | else |
| 5654 | status = eHAL_STATUS_SUCCESS; |
| 5655 | if (HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5656 | { |
| 5657 | do |
| 5658 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5659 | vos_mem_set(pMsg, msgLen, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5660 | pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SCAN_REQ); |
| 5661 | pMsg->length = pal_cpu_to_be16(msgLen); |
| 5662 | //ToDO: Fill in session info when we need to do scan base on session. |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 5663 | if ((pMac->fScanOffload) && (sessionId != CSR_SESSION_ID_INVALID)) |
| 5664 | { |
| 5665 | pMsg->sessionId = sessionId; |
| 5666 | } |
| 5667 | else |
| 5668 | { |
| 5669 | /* if sessionId == CSR_SESSION_ID_INVALID, then send the scan |
| 5670 | request on first available session */ |
| 5671 | pMsg->sessionId = 0; |
| 5672 | } |
| 5673 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5674 | pMsg->transactionId = 0; |
| 5675 | pMsg->dot11mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac, csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode )); |
| 5676 | pMsg->bssType = pal_cpu_to_be32(csrTranslateBsstypeToMacType(pScanReq->BSSType)); |
| 5677 | |
| 5678 | if ( CSR_IS_SESSION_VALID( pMac, sessionId ) ) |
| 5679 | { |
| 5680 | pSelfMac = (tANI_U8 *)&pMac->roam.roamSession[sessionId].selfMacAddr; |
| 5681 | } |
| 5682 | else |
| 5683 | { |
| 5684 | // Since we don't have session for the scanning, we find a valid session. In case we fail to |
| 5685 | // do so, get the WNI_CFG_STA_ID |
| 5686 | for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ ) |
| 5687 | { |
| 5688 | if( CSR_IS_SESSION_VALID( pMac, i ) ) |
| 5689 | { |
| 5690 | pSelfMac = (tANI_U8 *)&pMac->roam.roamSession[i].selfMacAddr; |
| 5691 | break; |
| 5692 | } |
| 5693 | } |
| 5694 | if( CSR_ROAM_SESSION_MAX == i ) |
| 5695 | { |
| 5696 | tANI_U32 len = WNI_CFG_BSSID_LEN; |
| 5697 | pSelfMac = selfMacAddr; |
| 5698 | status = ccmCfgGetStr( pMac, WNI_CFG_STA_ID, pSelfMac, &len ); |
| 5699 | if( !HAL_STATUS_SUCCESS( status ) || |
| 5700 | ( len < WNI_CFG_BSSID_LEN ) ) |
| 5701 | { |
| 5702 | smsLog( pMac, LOGE, FL(" Can not get self MAC address from CFG status = %d"), status ); |
| 5703 | //Force failed status |
| 5704 | status = eHAL_STATUS_FAILURE; |
| 5705 | break; |
| 5706 | } |
| 5707 | } |
| 5708 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5709 | vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, pSelfMac, sizeof(tSirMacAddr)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5710 | |
| 5711 | //sirCopyMacAddr |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5712 | vos_mem_copy((tANI_U8 *)pMsg->bssId, (tANI_U8 *)&pScanReq->bssid, sizeof(tSirMacAddr)); |
| 5713 | if ( vos_mem_compare(pScanReq->bssid, bssid, sizeof(tCsrBssid))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5714 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5715 | vos_mem_set(pMsg->bssId, sizeof(tSirMacAddr), 0xff); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5716 | } |
| 5717 | else |
| 5718 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5719 | vos_mem_copy(pMsg->bssId, pScanReq->bssid, WNI_CFG_BSSID_LEN); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5720 | } |
| 5721 | minChnTime = pScanReq->minChnTime; |
| 5722 | maxChnTime = pScanReq->maxChnTime; |
| 5723 | |
| 5724 | //Verify the scan type first, if the scan is active scan, we need to make sure we |
| 5725 | //are allowed to do so. |
| 5726 | /* if 11d is enabled & we don't see any beacon around, scan type falls |
| 5727 | back to passive. But in BT AMP STA mode we need to send out a |
| 5728 | directed probe*/ |
| 5729 | if( (eSIR_PASSIVE_SCAN != scanType) && (eCSR_SCAN_P2P_DISCOVERY != pScanReq->requestType) |
| 5730 | && (eCSR_BSS_TYPE_WDS_STA != pScanReq->BSSType) |
| 5731 | && (eANI_BOOLEAN_FALSE == pMac->scan.fEnableBypass11d)) |
| 5732 | { |
| 5733 | scanType = pMac->scan.curScanType; |
| 5734 | if(eSIR_PASSIVE_SCAN == pMac->scan.curScanType) |
| 5735 | { |
| 5736 | if(minChnTime < pMac->roam.configParam.nPassiveMinChnTime) |
| 5737 | { |
| 5738 | minChnTime = pMac->roam.configParam.nPassiveMinChnTime; |
| 5739 | } |
| 5740 | if(maxChnTime < pMac->roam.configParam.nPassiveMaxChnTime) |
| 5741 | { |
| 5742 | maxChnTime = pMac->roam.configParam.nPassiveMaxChnTime; |
| 5743 | } |
| 5744 | } |
| 5745 | } |
| 5746 | pMsg->scanType = pal_cpu_to_be32(scanType); |
| 5747 | |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 5748 | pMsg->numSsid = |
| 5749 | (pScanReq->SSIDs.numOfSSIDs < SIR_SCAN_MAX_NUM_SSID) ? |
| 5750 | pScanReq->SSIDs.numOfSSIDs : SIR_SCAN_MAX_NUM_SSID; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5751 | if((pScanReq->SSIDs.numOfSSIDs != 0) && ( eSIR_PASSIVE_SCAN != scanType )) |
| 5752 | { |
Jeff Johnson | 40b59aa | 2013-03-19 14:43:18 -0700 | [diff] [blame] | 5753 | for (i = 0; i < pMsg->numSsid; i++) |
| 5754 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5755 | vos_mem_copy(&pMsg->ssId[i], |
| 5756 | &pScanReq->SSIDs.SSIDList[i].SSID, sizeof(tSirMacSSid)); |
Jeff Johnson | 40b59aa | 2013-03-19 14:43:18 -0700 | [diff] [blame] | 5757 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5758 | } |
| 5759 | else |
| 5760 | { |
| 5761 | //Otherwise we scan all SSID and let the result filter later |
Jeff Johnson | 40b59aa | 2013-03-19 14:43:18 -0700 | [diff] [blame] | 5762 | for (i = 0; i < SIR_SCAN_MAX_NUM_SSID; i++) |
| 5763 | { |
| 5764 | pMsg->ssId[i].length = 0; |
| 5765 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5766 | } |
| 5767 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5768 | pMsg->minChannelTime = pal_cpu_to_be32(minChnTime); |
| 5769 | pMsg->maxChannelTime = pal_cpu_to_be32(maxChnTime); |
Kiran Kumar Lokere | 3527f0c | 2013-02-24 22:21:28 -0800 | [diff] [blame] | 5770 | pMsg->minChannelTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc; |
| 5771 | pMsg->maxChannelTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5772 | //hidden SSID option |
| 5773 | pMsg->hiddenSsid = pScanReqParam->hiddenSsid; |
| 5774 | //rest time |
| 5775 | //pMsg->restTime = pScanReq->restTime; |
| 5776 | pMsg->returnAfterFirstMatch = pScanReqParam->bReturnAfter1stMatch; |
| 5777 | // All the scan results caching will be done by Roaming |
| 5778 | // We do not want LIM to do any caching of scan results, |
| 5779 | // so delete the LIM cache on all scan requests |
| 5780 | pMsg->returnFreshResults = pScanReqParam->freshScan; |
| 5781 | //Always ask for unique result |
| 5782 | pMsg->returnUniqueResults = pScanReqParam->fUniqueResult; |
| 5783 | pMsg->channelList.numChannels = (tANI_U8)pScanReq->ChannelInfo.numOfChannels; |
| 5784 | if(pScanReq->ChannelInfo.numOfChannels) |
| 5785 | { |
| 5786 | //Assuming the channelNumber is tANI_U8 (1 byte) |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5787 | vos_mem_copy(pMsg->channelList.channelNumber, |
| 5788 | pScanReq->ChannelInfo.ChannelList, |
| 5789 | pScanReq->ChannelInfo.numOfChannels); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5790 | } |
| 5791 | |
| 5792 | pMsg->uIEFieldLen = (tANI_U16) pScanReq->uIEFieldLen; |
| 5793 | pMsg->uIEFieldOffset = (tANI_U16)(sizeof( tSirSmeScanReq ) - sizeof( pMsg->channelList.channelNumber ) + |
| 5794 | ( sizeof( pMsg->channelList.channelNumber ) * pScanReq->ChannelInfo.numOfChannels )) ; |
| 5795 | if(pScanReq->uIEFieldLen != 0) |
| 5796 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5797 | vos_mem_copy((tANI_U8 *)pMsg+pMsg->uIEFieldOffset, pScanReq->pIEField, |
| 5798 | pScanReq->uIEFieldLen); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5799 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5800 | pMsg->p2pSearch = pScanReq->p2pSearch; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5801 | |
Madan Mohan Koyyalamudi | 9b87678 | 2012-10-11 16:22:51 -0700 | [diff] [blame] | 5802 | if (pScanReq->requestType == eCSR_SCAN_HO_BG_SCAN) |
| 5803 | { |
| 5804 | pMsg->backgroundScanMode = eSIR_ROAMING_SCAN; |
| 5805 | } |
| 5806 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5807 | }while(0); |
Sushant Kaushik | e0d2cce | 2014-04-10 14:36:07 +0530 | [diff] [blame] | 5808 | smsLog(pMac, LOG1, FL("domainIdCurrent %s (%d) scanType %s (%d)" |
| 5809 | "bssType %s (%d), requestType %s(%d)" |
| 5810 | "numChannels %d"), |
| 5811 | voss_DomainIdtoString(pMac->scan.domainIdCurrent), |
| 5812 | pMac->scan.domainIdCurrent, |
| 5813 | lim_ScanTypetoString(pMsg->scanType), pMsg->scanType, |
| 5814 | lim_BssTypetoString(pMsg->bssType), pMsg->bssType, |
| 5815 | sme_requestTypetoString(pScanReq->requestType), |
| 5816 | pScanReq->requestType, |
| 5817 | pMsg->channelList.numChannels); |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 5818 | |
| 5819 | for(i = 0; i < pMsg->channelList.numChannels; i++) |
| 5820 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5821 | smsLog(pMac, LOG3, FL("channelNumber[%d]= %d"), i, pMsg->channelList.channelNumber[i]); |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 5822 | } |
| 5823 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5824 | if(HAL_STATUS_SUCCESS(status)) |
| 5825 | { |
| 5826 | status = palSendMBMessage(pMac->hHdd, pMsg); |
| 5827 | } |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 5828 | else |
| 5829 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5830 | smsLog( pMac, LOGE, FL(" failed to send down scan req with status = %d"), status ); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5831 | vos_mem_free(pMsg); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5832 | } |
| 5833 | }//Success allocated memory |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 5834 | else |
| 5835 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 5836 | smsLog( pMac, LOGE, FL(" memory allocation failure")); |
Gopichand Nakkala | 9b89a73 | 2012-12-31 16:31:46 -0800 | [diff] [blame] | 5837 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5838 | |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 5839 | if(!HAL_STATUS_SUCCESS(status)) |
| 5840 | { |
| 5841 | smsLog( pMac, LOG1, FL("Failed: SId: %d FirstMatch = %d" |
| 5842 | " UniqueResult = %d freshScan = %d hiddenSsid = %d"), |
| 5843 | sessionId, pScanReqParam->bReturnAfter1stMatch, |
| 5844 | pScanReqParam->fUniqueResult, pScanReqParam->freshScan, |
| 5845 | pScanReqParam->hiddenSsid ); |
Sushant Kaushik | e0d2cce | 2014-04-10 14:36:07 +0530 | [diff] [blame] | 5846 | smsLog( pMac, LOG1, FL("scanType = %s (%d) BSSType = %s (%d) " |
| 5847 | "numOfSSIDs = %d numOfChannels = %d requestType = %s (%d)" |
| 5848 | " p2pSearch = %d\n"), |
| 5849 | lim_ScanTypetoString(pScanReq->scanType), |
| 5850 | pScanReq->scanType, |
| 5851 | lim_BssTypetoString(pScanReq->BSSType), |
| 5852 | pScanReq->BSSType, |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 5853 | pScanReq->SSIDs.numOfSSIDs, |
Sushant Kaushik | e0d2cce | 2014-04-10 14:36:07 +0530 | [diff] [blame] | 5854 | pScanReq->ChannelInfo.numOfChannels, |
| 5855 | sme_requestTypetoString(pScanReq->requestType), |
| 5856 | pScanReq->requestType, |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 5857 | pScanReq->p2pSearch ); |
| 5858 | |
| 5859 | } |
| 5860 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5861 | return( status ); |
| 5862 | } |
| 5863 | |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 5864 | eHalStatus csrSendMBScanResultReq( tpAniSirGlobal pMac, tANI_U32 sessionId, tScanReqParam *pScanReqParam ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5865 | { |
| 5866 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 5867 | tSirSmeScanReq *pMsg; |
| 5868 | tANI_U16 msgLen; |
| 5869 | |
| 5870 | msgLen = (tANI_U16)(sizeof( tSirSmeScanReq )); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5871 | pMsg = vos_mem_malloc(msgLen); |
| 5872 | if ( NULL == pMsg ) |
| 5873 | status = eHAL_STATUS_FAILURE; |
| 5874 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5875 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5876 | vos_mem_set(pMsg, msgLen, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5877 | pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SCAN_REQ); |
| 5878 | pMsg->length = pal_cpu_to_be16(msgLen); |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 5879 | pMsg->sessionId = sessionId; |
| 5880 | pMsg->transactionId = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5881 | pMsg->returnFreshResults = pScanReqParam->freshScan; |
| 5882 | //Always ask for unique result |
| 5883 | pMsg->returnUniqueResults = pScanReqParam->fUniqueResult; |
| 5884 | pMsg->returnAfterFirstMatch = pScanReqParam->bReturnAfter1stMatch; |
| 5885 | status = palSendMBMessage(pMac->hHdd, pMsg); |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 5886 | if (!HAL_STATUS_SUCCESS(status)) |
| 5887 | { |
| 5888 | smsLog( pMac, LOGE, FL(" failed to send down scan req with status = %d\n"), status ); |
| 5889 | } |
| 5890 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5891 | } |
| 5892 | |
| 5893 | return( status ); |
| 5894 | } |
| 5895 | |
| 5896 | |
| 5897 | |
| 5898 | eHalStatus csrScanChannels( tpAniSirGlobal pMac, tSmeCmd *pCommand ) |
| 5899 | { |
| 5900 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 5901 | tScanReqParam scanReq; |
| 5902 | |
| 5903 | do |
| 5904 | { |
| 5905 | scanReq.freshScan = CSR_SME_SCAN_FLAGS_DELETE_CACHE | TRUE; |
| 5906 | scanReq.fUniqueResult = TRUE; |
| 5907 | scanReq.hiddenSsid = SIR_SCAN_NO_HIDDEN_SSID; |
| 5908 | if(eCsrScanForSsid == pCommand->u.scanCmd.reason) |
| 5909 | { |
| 5910 | scanReq.bReturnAfter1stMatch = CSR_SCAN_RETURN_AFTER_FIRST_MATCH; |
| 5911 | } |
| 5912 | else |
| 5913 | { |
| 5914 | // Basically do scan on all channels even for 11D 1st scan case. |
| 5915 | scanReq.bReturnAfter1stMatch = CSR_SCAN_RETURN_AFTER_ALL_CHANNELS; |
| 5916 | } |
| 5917 | if((eCsrScanBgScan == pCommand->u.scanCmd.reason)|| |
| 5918 | (eCsrScanProbeBss == pCommand->u.scanCmd.reason)) |
| 5919 | { |
| 5920 | scanReq.hiddenSsid = SIR_SCAN_HIDDEN_SSID_PE_DECISION; |
| 5921 | } |
| 5922 | |
| 5923 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 5924 | { |
| 5925 | vos_log_scan_pkt_type *pScanLog = NULL; |
| 5926 | |
| 5927 | WLAN_VOS_DIAG_LOG_ALLOC(pScanLog, vos_log_scan_pkt_type, LOG_WLAN_SCAN_C); |
| 5928 | if(pScanLog) |
| 5929 | { |
| 5930 | if(eCsrScanBgScan == pCommand->u.scanCmd.reason || |
| 5931 | eCsrScanProbeBss == pCommand->u.scanCmd.reason) |
| 5932 | { |
| 5933 | pScanLog->eventId = WLAN_SCAN_EVENT_HO_SCAN_REQ; |
| 5934 | } |
| 5935 | else |
| 5936 | { |
| 5937 | if( (eSIR_PASSIVE_SCAN != pCommand->u.scanCmd.u.scanRequest.scanType) && |
| 5938 | (eSIR_PASSIVE_SCAN != pMac->scan.curScanType) ) |
| 5939 | { |
| 5940 | pScanLog->eventId = WLAN_SCAN_EVENT_ACTIVE_SCAN_REQ; |
| 5941 | } |
| 5942 | else |
| 5943 | { |
| 5944 | pScanLog->eventId = WLAN_SCAN_EVENT_PASSIVE_SCAN_REQ; |
| 5945 | } |
| 5946 | } |
| 5947 | pScanLog->minChnTime = (v_U8_t)pCommand->u.scanCmd.u.scanRequest.minChnTime; |
| 5948 | pScanLog->maxChnTime = (v_U8_t)pCommand->u.scanCmd.u.scanRequest.maxChnTime; |
| 5949 | pScanLog->numChannel = (v_U8_t)pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels; |
| 5950 | if(pScanLog->numChannel && (pScanLog->numChannel < VOS_LOG_MAX_NUM_CHANNEL)) |
| 5951 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 5952 | vos_mem_copy(pScanLog->channels, |
| 5953 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList, |
| 5954 | pScanLog->numChannel); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5955 | } |
| 5956 | WLAN_VOS_DIAG_LOG_REPORT(pScanLog); |
| 5957 | } |
| 5958 | } |
| 5959 | #endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 5960 | |
Agrawal Ashish | 0b6984f | 2014-04-05 18:35:45 +0530 | [diff] [blame] | 5961 | csrClearVotesForCountryInfo(pMac); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5962 | status = csrSendMBScanReq(pMac, pCommand->sessionId, |
| 5963 | &pCommand->u.scanCmd.u.scanRequest, &scanReq); |
| 5964 | }while(0); |
| 5965 | |
| 5966 | return( status ); |
| 5967 | } |
| 5968 | |
| 5969 | |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 5970 | eHalStatus csrScanRetrieveResult(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5971 | { |
| 5972 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 5973 | tScanReqParam scanReq; |
| 5974 | |
| 5975 | do |
| 5976 | { |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 5977 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 5978 | if (eCsrScanGetLfrResult == pCommand->u.scanCmd.reason) |
| 5979 | { |
| 5980 | //to get the LFR candidates from PE cache |
| 5981 | scanReq.freshScan = SIR_BG_SCAN_RETURN_LFR_CACHED_RESULTS|SIR_BG_SCAN_PURGE_LFR_RESULTS; |
| 5982 | scanReq.fUniqueResult = TRUE; |
| 5983 | scanReq.bReturnAfter1stMatch = CSR_SCAN_RETURN_AFTER_ALL_CHANNELS; |
| 5984 | } |
| 5985 | else |
| 5986 | #endif |
| 5987 | { |
| 5988 | //not a fresh scan |
| 5989 | scanReq.freshScan = CSR_SME_SCAN_FLAGS_DELETE_CACHE; |
| 5990 | scanReq.fUniqueResult = TRUE; |
| 5991 | scanReq.bReturnAfter1stMatch = CSR_SCAN_RETURN_AFTER_ALL_CHANNELS; |
| 5992 | } |
| 5993 | status = csrSendMBScanResultReq(pMac, pCommand->sessionId, &scanReq); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5994 | }while(0); |
| 5995 | |
| 5996 | return (status); |
| 5997 | } |
| 5998 | |
Siddharth Bhal | d8a95e8 | 2015-02-12 20:14:52 +0530 | [diff] [blame] | 5999 | eHalStatus csrProcessMacAddrSpoofCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand ) |
| 6000 | { |
| 6001 | tSirSpoofMacAddrReq *pMsg; |
| 6002 | tANI_U16 msgLen; |
| 6003 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 6004 | do { |
| 6005 | msgLen = sizeof(tSirSpoofMacAddrReq); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6006 | |
Siddharth Bhal | d8a95e8 | 2015-02-12 20:14:52 +0530 | [diff] [blame] | 6007 | pMsg = vos_mem_malloc(msgLen); |
| 6008 | if ( NULL == pMsg ) |
| 6009 | return eHAL_STATUS_FAILURE; |
| 6010 | pMsg->messageType= pal_cpu_to_be16((tANI_U16)eWNI_SME_MAC_SPOOF_ADDR_IND); |
| 6011 | pMsg->length= pal_cpu_to_be16(msgLen); |
| 6012 | // spoof mac address |
| 6013 | vos_mem_copy((tANI_U8 *)pMsg->macAddr, |
| 6014 | (tANI_U8 *)pCommand->u.macAddrSpoofCmd.macAddr, sizeof(tSirMacAddr)); |
| 6015 | status = palSendMBMessage(pMac->hHdd, pMsg); |
| 6016 | } while( 0 ); |
| 6017 | return( status ); |
| 6018 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6019 | |
| 6020 | eHalStatus csrProcessScanCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand ) |
| 6021 | { |
| 6022 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 6023 | tCsrChannelInfo newChannelInfo = {0, NULL}; |
| 6024 | int i, j; |
| 6025 | tANI_U8 *pChannel = NULL; |
| 6026 | tANI_U32 len = 0; |
| 6027 | |
| 6028 | // Transition to Scanning state... |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 6029 | if (!pMac->fScanOffload) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6030 | { |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 6031 | for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ ) |
| 6032 | { |
| 6033 | pCommand->u.scanCmd.lastRoamState[i] = |
| 6034 | csrRoamStateChange( pMac, eCSR_ROAMING_STATE_SCANNING, i); |
| 6035 | smsLog( pMac, LOG3, "starting SCAN command from %d state...." |
| 6036 | " reason is %d", pCommand->u.scanCmd.lastRoamState[i], |
| 6037 | pCommand->u.scanCmd.reason ); |
| 6038 | } |
| 6039 | } |
| 6040 | else |
| 6041 | { |
| 6042 | pCommand->u.scanCmd.lastRoamState[pCommand->sessionId] = |
| 6043 | csrRoamStateChange(pMac, eCSR_ROAMING_STATE_SCANNING, |
| 6044 | pCommand->sessionId); |
| 6045 | smsLog( pMac, LOG3, |
| 6046 | "starting SCAN command from %d state.... reason is %d", |
| 6047 | pCommand->u.scanCmd.lastRoamState[pCommand->sessionId], |
| 6048 | pCommand->u.scanCmd.reason ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6049 | } |
| 6050 | |
| 6051 | switch(pCommand->u.scanCmd.reason) |
| 6052 | { |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 6053 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 6054 | case eCsrScanGetLfrResult: |
| 6055 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6056 | case eCsrScanGetResult: |
| 6057 | case eCsrScanForCapsChange: //For cap change, LIM already save BSS description |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 6058 | status = csrScanRetrieveResult(pMac, pCommand); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6059 | break; |
| 6060 | case eCsrScanSetBGScanParam: |
| 6061 | status = csrProcessSetBGScanParam(pMac, pCommand); |
| 6062 | break; |
| 6063 | case eCsrScanBGScanAbort: |
| 6064 | status = csrSetCfgBackgroundScanPeriod(pMac, 0); |
| 6065 | break; |
| 6066 | case eCsrScanBGScanEnable: |
| 6067 | status = csrSetCfgBackgroundScanPeriod(pMac, pMac->roam.configParam.bgScanInterval); |
| 6068 | break; |
| 6069 | case eCsrScanGetScanChnInfo: |
Madan Mohan Koyyalamudi | de1b5bc | 2013-07-12 00:56:04 +0530 | [diff] [blame] | 6070 | status = csrScanGetScanChannelInfo(pMac, pCommand->sessionId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6071 | break; |
| 6072 | case eCsrScanUserRequest: |
| 6073 | if(pMac->roam.configParam.fScanTwice) |
| 6074 | { |
| 6075 | //We scan 2.4 channel twice |
| 6076 | if(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels && |
| 6077 | (NULL != pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList)) |
| 6078 | { |
| 6079 | len = pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels; |
| 6080 | //allocate twice the channel |
Mukul Sharma | a631e89 | 2014-08-28 15:38:51 +0530 | [diff] [blame] | 6081 | newChannelInfo.ChannelList = (tANI_U8 *)vos_mem_malloc(len * 2); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6082 | pChannel = pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList; |
| 6083 | } |
| 6084 | else |
| 6085 | { |
| 6086 | //get the valid channel list to scan all. |
| 6087 | len = sizeof(pMac->roam.validChannelList); |
| 6088 | |
| 6089 | if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len))) |
| 6090 | { |
| 6091 | //allocate twice the channel |
| 6092 | newChannelInfo.ChannelList = (tANI_U8 *)vos_mem_malloc(len * 2); |
| 6093 | pChannel = pMac->roam.validChannelList; |
| 6094 | } |
| 6095 | } |
| 6096 | if(NULL == newChannelInfo.ChannelList) |
| 6097 | { |
| 6098 | newChannelInfo.numOfChannels = 0; |
| 6099 | } |
| 6100 | else |
| 6101 | { |
| 6102 | j = 0; |
| 6103 | for(i = 0; i < len; i++) |
| 6104 | { |
| 6105 | newChannelInfo.ChannelList[j++] = pChannel[i]; |
| 6106 | if(CSR_MAX_24GHz_CHANNEL_NUMBER >= pChannel[i]) |
| 6107 | { |
| 6108 | newChannelInfo.ChannelList[j++] = pChannel[i]; |
| 6109 | } |
| 6110 | } |
| 6111 | if(NULL != pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList) |
| 6112 | { |
| 6113 | //pChannel points to the channellist from the command, free it. |
| 6114 | vos_mem_free(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList); |
James Zmuda | 9ea1edd | 2013-04-18 18:20:54 -0700 | [diff] [blame] | 6115 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6116 | } |
| 6117 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = j; |
| 6118 | pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = newChannelInfo.ChannelList; |
| 6119 | } |
| 6120 | } //if(pMac->roam.configParam.fScanTwice) |
| 6121 | |
| 6122 | status = csrScanChannels(pMac, pCommand); |
| 6123 | |
| 6124 | break; |
| 6125 | default: |
| 6126 | status = csrScanChannels(pMac, pCommand); |
| 6127 | break; |
| 6128 | } |
| 6129 | |
| 6130 | if(!HAL_STATUS_SUCCESS(status)) |
| 6131 | { |
| 6132 | csrReleaseScanCommand(pMac, pCommand, eCSR_SCAN_FAILURE); |
| 6133 | } |
| 6134 | |
| 6135 | return (status); |
| 6136 | } |
| 6137 | |
| 6138 | |
| 6139 | eHalStatus csrScanSetBGScanparams(tpAniSirGlobal pMac, tCsrBGScanRequest *pScanReq) |
| 6140 | { |
| 6141 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 6142 | tSmeCmd *pCommand = NULL; |
| 6143 | |
| 6144 | if(pScanReq) |
| 6145 | { |
| 6146 | do |
| 6147 | { |
| 6148 | pCommand = csrGetCommandBuffer(pMac); |
| 6149 | if(!pCommand) |
| 6150 | { |
| 6151 | status = eHAL_STATUS_RESOURCES; |
| 6152 | break; |
| 6153 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6154 | vos_mem_set(&pCommand->u.scanCmd, sizeof(tScanCmd), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6155 | pCommand->command = eSmeCommandScan; |
| 6156 | pCommand->u.scanCmd.reason = eCsrScanSetBGScanParam; |
| 6157 | pCommand->u.scanCmd.callback = NULL; |
| 6158 | pCommand->u.scanCmd.pContext = NULL; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6159 | vos_mem_copy(&pCommand->u.scanCmd.u.bgScanRequest, pScanReq, sizeof(tCsrBGScanRequest)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6160 | //we have to do the follow |
| 6161 | if(pScanReq->ChannelInfo.numOfChannels == 0) |
| 6162 | { |
| 6163 | pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList = NULL; |
| 6164 | } |
| 6165 | else |
| 6166 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6167 | pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList |
| 6168 | = vos_mem_malloc(pScanReq->ChannelInfo.numOfChannels); |
| 6169 | if ( NULL != pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6170 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6171 | vos_mem_copy(pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList, |
| 6172 | pScanReq->ChannelInfo.ChannelList, |
| 6173 | pScanReq->ChannelInfo.numOfChannels); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6174 | } |
| 6175 | else |
| 6176 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6177 | smsLog(pMac, LOGE, FL("ran out of memory")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6178 | csrReleaseCommandScan(pMac, pCommand); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6179 | return eHAL_STATUS_FAILURE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6180 | } |
| 6181 | } |
| 6182 | |
| 6183 | //scan req for SSID |
| 6184 | if(pScanReq->SSID.length) |
| 6185 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6186 | vos_mem_copy(pCommand->u.scanCmd.u.bgScanRequest.SSID.ssId, |
| 6187 | pScanReq->SSID.ssId, pScanReq->SSID.length); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6188 | pCommand->u.scanCmd.u.bgScanRequest.SSID.length = pScanReq->SSID.length; |
| 6189 | |
| 6190 | } |
| 6191 | pCommand->u.scanCmd.u.bgScanRequest.maxChnTime= pScanReq->maxChnTime; |
| 6192 | pCommand->u.scanCmd.u.bgScanRequest.minChnTime = pScanReq->minChnTime; |
| 6193 | pCommand->u.scanCmd.u.bgScanRequest.scanInterval = pScanReq->scanInterval; |
| 6194 | |
| 6195 | |
| 6196 | status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE); |
| 6197 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 6198 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6199 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6200 | csrReleaseCommandScan( pMac, pCommand ); |
| 6201 | break; |
| 6202 | } |
| 6203 | }while(0); |
| 6204 | } |
| 6205 | |
| 6206 | return (status); |
| 6207 | } |
| 6208 | |
| 6209 | eHalStatus csrScanBGScanAbort( tpAniSirGlobal pMac ) |
| 6210 | { |
| 6211 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 6212 | tSmeCmd *pCommand = NULL; |
| 6213 | |
| 6214 | do |
| 6215 | { |
| 6216 | pCommand = csrGetCommandBuffer(pMac); |
| 6217 | if(!pCommand) |
| 6218 | { |
| 6219 | status = eHAL_STATUS_RESOURCES; |
| 6220 | break; |
| 6221 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6222 | vos_mem_set(&pCommand->u.scanCmd, sizeof(tScanCmd), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6223 | pCommand->command = eSmeCommandScan; |
| 6224 | pCommand->u.scanCmd.reason = eCsrScanBGScanAbort; |
| 6225 | pCommand->u.scanCmd.callback = NULL; |
| 6226 | pCommand->u.scanCmd.pContext = NULL; |
| 6227 | status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE); |
| 6228 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 6229 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6230 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6231 | csrReleaseCommandScan( pMac, pCommand ); |
| 6232 | break; |
| 6233 | } |
| 6234 | }while(0); |
| 6235 | |
| 6236 | return (status); |
| 6237 | } |
| 6238 | |
| 6239 | |
| 6240 | //This will enable the background scan with the non-zero interval |
| 6241 | eHalStatus csrScanBGScanEnable(tpAniSirGlobal pMac) |
| 6242 | { |
| 6243 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 6244 | tSmeCmd *pCommand = NULL; |
| 6245 | |
| 6246 | if(pMac->roam.configParam.bgScanInterval) |
| 6247 | { |
| 6248 | do |
| 6249 | { |
| 6250 | pCommand = csrGetCommandBuffer(pMac); |
| 6251 | if(!pCommand) |
| 6252 | { |
| 6253 | status = eHAL_STATUS_RESOURCES; |
| 6254 | break; |
| 6255 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6256 | vos_mem_set(&pCommand->u.scanCmd, sizeof(tScanCmd), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6257 | pCommand->command = eSmeCommandScan; |
| 6258 | pCommand->u.scanCmd.reason = eCsrScanBGScanEnable; |
| 6259 | pCommand->u.scanCmd.callback = NULL; |
| 6260 | pCommand->u.scanCmd.pContext = NULL; |
| 6261 | status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE); |
| 6262 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 6263 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6264 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6265 | csrReleaseCommandScan( pMac, pCommand ); |
| 6266 | break; |
| 6267 | } |
| 6268 | }while(0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6269 | } |
| 6270 | else |
| 6271 | { |
Sushant Kaushik | b8dbb3f | 2015-04-29 17:03:37 +0530 | [diff] [blame] | 6272 | smsLog(pMac, LOGE, FL("cannot continue because the bgscan interval is 0")); |
| 6273 | status = eHAL_STATUS_INVALID_PARAMETER; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6274 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6275 | return (status); |
| 6276 | } |
| 6277 | |
| 6278 | |
| 6279 | eHalStatus csrScanCopyRequest(tpAniSirGlobal pMac, tCsrScanRequest *pDstReq, tCsrScanRequest *pSrcReq) |
| 6280 | { |
| 6281 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 6282 | tANI_U32 len = sizeof(pMac->roam.validChannelList); |
| 6283 | tANI_U32 index = 0; |
| 6284 | tANI_U32 new_index = 0; |
Manjunathappa Prakash | de7b2a5 | 2014-02-28 16:59:03 -0800 | [diff] [blame] | 6285 | eNVChannelEnabledType NVchannel_state; |
Arif Hussain | 6af3862 | 2014-03-12 12:39:57 -0700 | [diff] [blame] | 6286 | tANI_U8 ch144_support = 0; |
| 6287 | |
| 6288 | ch144_support = WDA_getFwWlanFeatCaps(WLAN_CH144); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6289 | |
| 6290 | do |
| 6291 | { |
| 6292 | status = csrScanFreeRequest(pMac, pDstReq); |
| 6293 | if(HAL_STATUS_SUCCESS(status)) |
| 6294 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6295 | vos_mem_copy(pDstReq, pSrcReq, sizeof(tCsrScanRequest)); |
Gopichand Nakkala | c7b1d3e | 2012-12-31 14:07:19 -0800 | [diff] [blame] | 6296 | /* Re-initialize the pointers to NULL since we did a copy */ |
| 6297 | pDstReq->pIEField = NULL; |
| 6298 | pDstReq->ChannelInfo.ChannelList = NULL; |
| 6299 | pDstReq->SSIDs.SSIDList = NULL; |
| 6300 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6301 | if(pSrcReq->uIEFieldLen == 0) |
| 6302 | { |
| 6303 | pDstReq->pIEField = NULL; |
| 6304 | } |
| 6305 | else |
| 6306 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6307 | pDstReq->pIEField = vos_mem_malloc(pSrcReq->uIEFieldLen); |
| 6308 | if ( NULL == pDstReq->pIEField ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6309 | { |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 6310 | status = eHAL_STATUS_FAILURE; |
| 6311 | smsLog(pMac, LOGE, FL("No memory for scanning IE fields")); |
| 6312 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6313 | } |
| 6314 | else |
| 6315 | { |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 6316 | status = eHAL_STATUS_SUCCESS; |
| 6317 | vos_mem_copy(pDstReq->pIEField, pSrcReq->pIEField, |
| 6318 | pSrcReq->uIEFieldLen); |
| 6319 | pDstReq->uIEFieldLen = pSrcReq->uIEFieldLen; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6320 | } |
| 6321 | }//Allocate memory for IE field |
| 6322 | { |
| 6323 | if(pSrcReq->ChannelInfo.numOfChannels == 0) |
| 6324 | { |
| 6325 | pDstReq->ChannelInfo.ChannelList = NULL; |
| 6326 | pDstReq->ChannelInfo.numOfChannels = 0; |
| 6327 | } |
| 6328 | else |
| 6329 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6330 | pDstReq->ChannelInfo.ChannelList = vos_mem_malloc( |
| 6331 | pSrcReq->ChannelInfo.numOfChannels |
| 6332 | * sizeof(*pDstReq->ChannelInfo.ChannelList)); |
| 6333 | if ( NULL == pDstReq->ChannelInfo.ChannelList ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6334 | { |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 6335 | status = eHAL_STATUS_FAILURE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6336 | pDstReq->ChannelInfo.numOfChannels = 0; |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 6337 | smsLog(pMac, LOGE, FL("No memory for scanning Channel" |
| 6338 | " List")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6339 | break; |
| 6340 | } |
| 6341 | |
| 6342 | if((pSrcReq->scanType == eSIR_PASSIVE_SCAN) && (pSrcReq->requestType == eCSR_SCAN_REQUEST_11D_SCAN)) |
| 6343 | { |
| 6344 | for ( index = 0; index < pSrcReq->ChannelInfo.numOfChannels ; index++ ) |
| 6345 | { |
Arif Hussain | 6af3862 | 2014-03-12 12:39:57 -0700 | [diff] [blame] | 6346 | /* Skip CH 144 if firmware support not present */ |
| 6347 | if (pSrcReq->ChannelInfo.ChannelList[index] == 144 && !ch144_support) |
| 6348 | continue; |
Agarwal Ashish | 8bd53ae | 2015-06-12 18:03:45 +0530 | [diff] [blame] | 6349 | /* Skip channel 12 and 13 when FCC constraint is true */ |
| 6350 | if ((pMac->scan.fcc_constraint) && |
| 6351 | ((pSrcReq->ChannelInfo.ChannelList[index] ==12) || |
| 6352 | (pSrcReq->ChannelInfo.ChannelList[index] ==13))) |
| 6353 | { |
| 6354 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, |
| 6355 | FL("Ignoring channel : %d "), |
| 6356 | pSrcReq->ChannelInfo.ChannelList[index]); |
| 6357 | continue; |
| 6358 | } |
Arif Hussain | 6af3862 | 2014-03-12 12:39:57 -0700 | [diff] [blame] | 6359 | |
Manjunathappa Prakash | de7b2a5 | 2014-02-28 16:59:03 -0800 | [diff] [blame] | 6360 | NVchannel_state = vos_nv_getChannelEnabledState( |
| 6361 | pSrcReq->ChannelInfo.ChannelList[index]); |
| 6362 | if ((NV_CHANNEL_ENABLE == NVchannel_state) || |
| 6363 | (NV_CHANNEL_DFS == NVchannel_state)) |
| 6364 | { |
| 6365 | pDstReq->ChannelInfo.ChannelList[new_index] = |
| 6366 | pSrcReq->ChannelInfo.ChannelList[index]; |
| 6367 | new_index++; |
| 6368 | } |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 6369 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6370 | pDstReq->ChannelInfo.numOfChannels = new_index; |
| 6371 | } |
| 6372 | else if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len))) |
| 6373 | { |
| 6374 | new_index = 0; |
| 6375 | pMac->roam.numValidChannels = len; |
c_hpothu | 0d5a735 | 2014-03-22 12:30:25 +0530 | [diff] [blame] | 6376 | |
| 6377 | /* Since in CsrScanRequest,value of pMac->scan.nextScanID |
| 6378 | * is incremented before calling CsrScanCopyRequest, as a |
| 6379 | * result pMac->scan.nextScanID is equal to ONE for the |
| 6380 | * first scan. |
| 6381 | */ |
Ganesh Kondabattini | 8f6e3b3 | 2014-08-25 16:07:54 +0530 | [diff] [blame] | 6382 | if ((pMac->roam.configParam.initialScanSkipDFSCh && |
| 6383 | 1 == pMac->scan.nextScanID) ||(pMac->miracast_mode)) |
c_hpothu | 0d5a735 | 2014-03-22 12:30:25 +0530 | [diff] [blame] | 6384 | { |
| 6385 | smsLog(pMac, LOG1, |
| 6386 | FL("Initial scan, scan only non-DFS channels")); |
| 6387 | |
| 6388 | for (index = 0; index < pSrcReq->ChannelInfo. |
| 6389 | numOfChannels ; index++ ) |
| 6390 | { |
| 6391 | if((csrRoamIsValidChannel(pMac, pSrcReq->ChannelInfo. |
| 6392 | ChannelList[index]))) |
| 6393 | { |
| 6394 | /*Skiipping DFS Channels for 1st scan */ |
| 6395 | if(NV_CHANNEL_DFS == |
| 6396 | vos_nv_getChannelEnabledState(pSrcReq->ChannelInfo. |
| 6397 | ChannelList[index])) |
| 6398 | continue ; |
| 6399 | |
| 6400 | pDstReq->ChannelInfo.ChannelList[new_index] = |
| 6401 | pSrcReq->ChannelInfo.ChannelList[index]; |
| 6402 | new_index++; |
| 6403 | |
| 6404 | } |
| 6405 | } |
| 6406 | pMac->roam.configParam.initialScanSkipDFSCh = 0; |
| 6407 | } |
| 6408 | else |
| 6409 | { |
| 6410 | for ( index = 0; index < pSrcReq->ChannelInfo. |
| 6411 | numOfChannels ; index++ ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6412 | { |
Arif Hussain | 6af3862 | 2014-03-12 12:39:57 -0700 | [diff] [blame] | 6413 | /* Skip CH 144 if firmware support not present */ |
| 6414 | if (pSrcReq->ChannelInfo.ChannelList[index] == 144 && !ch144_support) |
| 6415 | continue; |
| 6416 | |
Madan Mohan Koyyalamudi | 783b236 | 2012-10-21 11:54:41 -0700 | [diff] [blame] | 6417 | /* Allow scan on valid channels only. |
Madan Mohan Koyyalamudi | 783b236 | 2012-10-21 11:54:41 -0700 | [diff] [blame] | 6418 | */ |
Abhishek Singh | 2ec36ab | 2014-08-07 16:14:25 +0530 | [diff] [blame] | 6419 | if ( ( csrRoamIsValidChannel(pMac, pSrcReq->ChannelInfo.ChannelList[index]) ) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6420 | { |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 6421 | if( ((pSrcReq->skipDfsChnlInP2pSearch || |
| 6422 | (pMac->scan.fEnableDFSChnlScan == |
| 6423 | DFS_CHNL_SCAN_DISABLED)) && |
Madan Mohan Koyyalamudi | c5992c9 | 2012-11-15 16:40:57 -0800 | [diff] [blame] | 6424 | (NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(pSrcReq->ChannelInfo.ChannelList[index])) ) |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 6425 | #ifdef FEATURE_WLAN_LFR |
| 6426 | /* |
| 6427 | * If LFR is requesting a contiguous scan |
| 6428 | * (i.e. numOfChannels > 1), then ignore |
| 6429 | * DFS channels. |
| 6430 | * TODO: vos_nv_getChannelEnabledState is returning |
| 6431 | * 120, 124 and 128 as non-DFS channels. Hence, the |
| 6432 | * use of direct check for channels below. |
| 6433 | */ |
| 6434 | || ((eCSR_SCAN_HO_BG_SCAN == pSrcReq->requestType) && |
| 6435 | (pSrcReq->ChannelInfo.numOfChannels > 1) && |
Santhosh Kumar Padma | 9ccaaff | 2014-07-09 19:58:12 +0530 | [diff] [blame] | 6436 | (CSR_IS_CHANNEL_DFS(pSrcReq->ChannelInfo.ChannelList[index])) && |
| 6437 | !pMac->roam.configParam.allowDFSChannelRoam) |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 6438 | #endif |
| 6439 | ) |
| 6440 | { |
| 6441 | #ifdef FEATURE_WLAN_LFR |
Sushant Kaushik | e0d2cce | 2014-04-10 14:36:07 +0530 | [diff] [blame] | 6442 | smsLog(pMac, LOG2, |
| 6443 | FL(" reqType=%s (%d), numOfChannels=%d," |
| 6444 | " ignoring DFS channel %d"), |
| 6445 | sme_requestTypetoString(pSrcReq->requestType), |
| 6446 | pSrcReq->requestType, |
| 6447 | pSrcReq->ChannelInfo.numOfChannels, |
| 6448 | pSrcReq->ChannelInfo.ChannelList[index]); |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 6449 | #endif |
Sushant Kaushik | e0d2cce | 2014-04-10 14:36:07 +0530 | [diff] [blame] | 6450 | continue; |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 6451 | } |
Madan Mohan Koyyalamudi | c5992c9 | 2012-11-15 16:40:57 -0800 | [diff] [blame] | 6452 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6453 | pDstReq->ChannelInfo.ChannelList[new_index] = |
| 6454 | pSrcReq->ChannelInfo.ChannelList[index]; |
| 6455 | new_index++; |
| 6456 | } |
| 6457 | } |
c_hpothu | 0d5a735 | 2014-03-22 12:30:25 +0530 | [diff] [blame] | 6458 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6459 | pDstReq->ChannelInfo.numOfChannels = new_index; |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 6460 | #ifdef FEATURE_WLAN_LFR |
Abhishek Singh | 2ec36ab | 2014-08-07 16:14:25 +0530 | [diff] [blame] | 6461 | if ( ( ( eCSR_SCAN_HO_BG_SCAN == pSrcReq->requestType ) || |
| 6462 | ( eCSR_SCAN_P2P_DISCOVERY == pSrcReq->requestType ) ) && |
| 6463 | ( 0 == pDstReq->ChannelInfo.numOfChannels ) ) |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 6464 | { |
| 6465 | /* |
| 6466 | * No valid channels found in the request. |
| 6467 | * Only perform scan on the channels passed |
Abhishek Singh | 2ec36ab | 2014-08-07 16:14:25 +0530 | [diff] [blame] | 6468 | * pSrcReq if it is a eCSR_SCAN_HO_BG_SCAN or |
| 6469 | * eCSR_SCAN_P2P_DISCOVERY. |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 6470 | * Passing 0 to LIM will trigger a scan on |
| 6471 | * all valid channels which is not desirable. |
| 6472 | */ |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 6473 | smsLog(pMac, LOGE, FL(" no valid channels found" |
| 6474 | " (request=%d)"), pSrcReq->requestType); |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 6475 | for ( index = 0; index < pSrcReq->ChannelInfo.numOfChannels ; index++ ) |
| 6476 | { |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 6477 | smsLog(pMac, LOGE, FL("pSrcReq index=%d" |
| 6478 | " channel=%d"), index, |
| 6479 | pSrcReq->ChannelInfo.ChannelList[index]); |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 6480 | } |
| 6481 | status = eHAL_STATUS_FAILURE; |
| 6482 | break; |
| 6483 | } |
| 6484 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6485 | } |
| 6486 | else |
| 6487 | { |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 6488 | smsLog(pMac, LOGE, FL("Couldn't get the valid Channel" |
| 6489 | " List, keeping requester's list")); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6490 | vos_mem_copy(pDstReq->ChannelInfo.ChannelList, |
| 6491 | pSrcReq->ChannelInfo.ChannelList, |
| 6492 | pSrcReq->ChannelInfo.numOfChannels |
| 6493 | * sizeof(*pDstReq->ChannelInfo.ChannelList)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6494 | pDstReq->ChannelInfo.numOfChannels = pSrcReq->ChannelInfo.numOfChannels; |
| 6495 | } |
| 6496 | }//Allocate memory for Channel List |
| 6497 | } |
| 6498 | if(pSrcReq->SSIDs.numOfSSIDs == 0) |
| 6499 | { |
| 6500 | pDstReq->SSIDs.numOfSSIDs = 0; |
| 6501 | pDstReq->SSIDs.SSIDList = NULL; |
| 6502 | } |
| 6503 | else |
| 6504 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6505 | pDstReq->SSIDs.SSIDList = vos_mem_malloc( |
| 6506 | pSrcReq->SSIDs.numOfSSIDs * sizeof(*pDstReq->SSIDs.SSIDList)); |
| 6507 | if ( NULL == pDstReq->SSIDs.SSIDList ) |
| 6508 | status = eHAL_STATUS_FAILURE; |
| 6509 | else |
| 6510 | status = eHAL_STATUS_SUCCESS; |
| 6511 | if (HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6512 | { |
| 6513 | pDstReq->SSIDs.numOfSSIDs = pSrcReq->SSIDs.numOfSSIDs; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6514 | vos_mem_copy(pDstReq->SSIDs.SSIDList, |
| 6515 | pSrcReq->SSIDs.SSIDList, |
| 6516 | pSrcReq->SSIDs.numOfSSIDs * sizeof(*pDstReq->SSIDs.SSIDList)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6517 | } |
| 6518 | else |
| 6519 | { |
| 6520 | pDstReq->SSIDs.numOfSSIDs = 0; |
Vinay Krishna Eranna | 636b7bc | 2013-12-18 20:49:08 +0530 | [diff] [blame] | 6521 | smsLog(pMac, LOGE, FL("No memory for scanning SSID List")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6522 | break; |
| 6523 | } |
| 6524 | }//Allocate memory for SSID List |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6525 | pDstReq->p2pSearch = pSrcReq->p2pSearch; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 6526 | pDstReq->skipDfsChnlInP2pSearch = pSrcReq->skipDfsChnlInP2pSearch; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6527 | |
| 6528 | } |
| 6529 | }while(0); |
| 6530 | |
| 6531 | if(!HAL_STATUS_SUCCESS(status)) |
| 6532 | { |
| 6533 | csrScanFreeRequest(pMac, pDstReq); |
| 6534 | } |
| 6535 | |
| 6536 | return (status); |
| 6537 | } |
| 6538 | |
| 6539 | |
| 6540 | eHalStatus csrScanFreeRequest(tpAniSirGlobal pMac, tCsrScanRequest *pReq) |
| 6541 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6542 | |
| 6543 | if(pReq->ChannelInfo.ChannelList) |
| 6544 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6545 | vos_mem_free(pReq->ChannelInfo.ChannelList); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6546 | pReq->ChannelInfo.ChannelList = NULL; |
| 6547 | } |
| 6548 | pReq->ChannelInfo.numOfChannels = 0; |
| 6549 | if(pReq->pIEField) |
| 6550 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6551 | vos_mem_free(pReq->pIEField); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6552 | pReq->pIEField = NULL; |
| 6553 | } |
| 6554 | pReq->uIEFieldLen = 0; |
| 6555 | if(pReq->SSIDs.SSIDList) |
| 6556 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6557 | vos_mem_free(pReq->SSIDs.SSIDList); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6558 | pReq->SSIDs.SSIDList = NULL; |
| 6559 | } |
| 6560 | pReq->SSIDs.numOfSSIDs = 0; |
| 6561 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6562 | return eHAL_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6563 | } |
| 6564 | |
| 6565 | |
| 6566 | void csrScanCallCallback(tpAniSirGlobal pMac, tSmeCmd *pCommand, eCsrScanStatus scanStatus) |
| 6567 | { |
| 6568 | if(pCommand->u.scanCmd.callback) |
| 6569 | { |
Ratheesh S P | ece1f83 | 2015-07-25 15:50:25 +0530 | [diff] [blame] | 6570 | if (pCommand->u.scanCmd.abortScanIndication){ |
| 6571 | smsLog( pMac, LOG1, FL("scanDone due to abort")); |
| 6572 | scanStatus = eCSR_SCAN_ABORT; |
| 6573 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6574 | // sme_ReleaseGlobalLock( &pMac->sme ); |
| 6575 | pCommand->u.scanCmd.callback(pMac, pCommand->u.scanCmd.pContext, pCommand->u.scanCmd.scanID, scanStatus); |
| 6576 | // sme_AcquireGlobalLock( &pMac->sme ); |
| 6577 | } else { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6578 | smsLog( pMac, LOG2, "%s:%d - Callback NULL!!!", __func__, __LINE__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6579 | } |
| 6580 | } |
| 6581 | |
| 6582 | |
| 6583 | void csrScanStopTimers(tpAniSirGlobal pMac) |
| 6584 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6585 | csrScanStopIdleScanTimer(pMac); |
| 6586 | csrScanStopGetResultTimer(pMac); |
Sandeep Puligilla | 2b6dc63 | 2012-12-17 14:44:16 -0800 | [diff] [blame] | 6587 | if(0 != pMac->scan.scanResultCfgAgingTime ) |
| 6588 | { |
| 6589 | csrScanStopResultCfgAgingTimer(pMac); |
| 6590 | } |
| 6591 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6592 | } |
| 6593 | |
| 6594 | |
| 6595 | eHalStatus csrScanStartGetResultTimer(tpAniSirGlobal pMac) |
| 6596 | { |
| 6597 | eHalStatus status; |
| 6598 | |
| 6599 | if(pMac->scan.fScanEnable) |
| 6600 | { |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 6601 | 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] | 6602 | } |
| 6603 | else |
| 6604 | { |
| 6605 | status = eHAL_STATUS_FAILURE; |
| 6606 | } |
| 6607 | |
| 6608 | return (status); |
| 6609 | } |
| 6610 | |
| 6611 | |
| 6612 | eHalStatus csrScanStopGetResultTimer(tpAniSirGlobal pMac) |
| 6613 | { |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 6614 | return (vos_timer_stop(&pMac->scan.hTimerGetResult)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6615 | } |
| 6616 | |
| 6617 | |
| 6618 | void csrScanGetResultTimerHandler(void *pv) |
| 6619 | { |
| 6620 | tpAniSirGlobal pMac = PMAC_STRUCT( pv ); |
| 6621 | |
| 6622 | csrScanRequestResult(pMac); |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 6623 | |
| 6624 | 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] | 6625 | } |
| 6626 | |
| 6627 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 6628 | static void csrStaApConcTimerHandler(void *pv) |
| 6629 | { |
| 6630 | tpAniSirGlobal pMac = PMAC_STRUCT( pv ); |
| 6631 | tListElem *pEntry; |
| 6632 | tSmeCmd *pScanCmd; |
| 6633 | |
| 6634 | csrLLLock(&pMac->scan.scanCmdPendingList); |
| 6635 | |
| 6636 | if ( NULL != ( pEntry = csrLLPeekHead( &pMac->scan.scanCmdPendingList, LL_ACCESS_NOLOCK) ) ) |
| 6637 | { |
| 6638 | tCsrScanRequest scanReq; |
| 6639 | tSmeCmd *pSendScanCmd = NULL; |
| 6640 | tANI_U8 numChn = 0; |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 6641 | tANI_U8 nNumChanCombinedConc = 0; |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 6642 | tANI_U8 i, j; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6643 | tCsrChannelInfo *pChnInfo = &scanReq.ChannelInfo; |
| 6644 | tANI_U8 channelToScan[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 6645 | eHalStatus status; |
| 6646 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6647 | pScanCmd = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 6648 | numChn = pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels; |
Madan Mohan Koyyalamudi | d671358 | 2012-11-09 16:56:56 -0800 | [diff] [blame] | 6649 | |
| 6650 | /* if any session is connected and the number of channels to scan is |
| 6651 | * greater than 1 then split the scan into multiple scan operations |
| 6652 | * on each individual channel else continue to perform scan on all |
| 6653 | * specified channels */ |
Madan Mohan Koyyalamudi | 48081ef | 2012-12-04 16:49:55 -0800 | [diff] [blame] | 6654 | |
| 6655 | /* split scan if number of channels to scan is greater than 1 and |
| 6656 | * any one of the following: |
| 6657 | * - STA session is connected and the scan is not a P2P search |
| 6658 | * - any P2P session is connected |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 6659 | * Do not split scans if no concurrent infra connections are |
| 6660 | * active and if the scan is a BG scan triggered by LFR (OR) |
| 6661 | * any scan if LFR is in the middle of a BG scan. Splitting |
| 6662 | * the scan is delaying the time it takes for LFR to find |
| 6663 | * candidates and resulting in disconnects. |
Madan Mohan Koyyalamudi | 48081ef | 2012-12-04 16:49:55 -0800 | [diff] [blame] | 6664 | */ |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 6665 | |
| 6666 | if((csrIsStaSessionConnected(pMac) && |
| 6667 | !csrIsP2pSessionConnected(pMac))) |
| 6668 | { |
| 6669 | nNumChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc; |
| 6670 | } |
| 6671 | else if(csrIsP2pSessionConnected(pMac)) |
| 6672 | { |
| 6673 | nNumChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc; |
| 6674 | } |
| 6675 | |
| 6676 | if ( (numChn > nNumChanCombinedConc) && |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 6677 | ((csrIsStaSessionConnected(pMac) && |
| 6678 | #ifdef FEATURE_WLAN_LFR |
| 6679 | (csrIsConcurrentInfraConnected(pMac) || |
| 6680 | ((pScanCmd->u.scanCmd.reason != eCsrScanBgScan) && |
| 6681 | (pMac->roam.neighborRoamInfo.neighborRoamState != |
| 6682 | eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN))) && |
| 6683 | #endif |
| 6684 | (pScanCmd->u.scanCmd.u.scanRequest.p2pSearch != 1)) || |
Madan Mohan Koyyalamudi | 48081ef | 2012-12-04 16:49:55 -0800 | [diff] [blame] | 6685 | (csrIsP2pSessionConnected(pMac)))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6686 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6687 | vos_mem_set(&scanReq, sizeof(tCsrScanRequest), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6688 | |
| 6689 | pSendScanCmd = csrGetCommandBuffer(pMac); //optimize this to use 2 command buffer only |
| 6690 | if (!pSendScanCmd) |
| 6691 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6692 | smsLog( pMac, LOGE, FL(" Failed to get Queue command buffer") ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6693 | csrLLUnlock(&pMac->scan.scanCmdPendingList); |
| 6694 | return; |
| 6695 | } |
| 6696 | pSendScanCmd->command = pScanCmd->command; |
| 6697 | pSendScanCmd->sessionId = pScanCmd->sessionId; |
| 6698 | pSendScanCmd->u.scanCmd.callback = NULL; |
| 6699 | pSendScanCmd->u.scanCmd.pContext = pScanCmd->u.scanCmd.pContext; |
| 6700 | pSendScanCmd->u.scanCmd.reason = pScanCmd->u.scanCmd.reason; |
| 6701 | pSendScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around |
| 6702 | |
Madan Mohan Koyyalamudi | af2a8b9 | 2012-10-09 14:58:07 -0700 | [diff] [blame] | 6703 | /* First copy all the parameters to local variable of scan request */ |
| 6704 | csrScanCopyRequest(pMac, &scanReq, &pScanCmd->u.scanCmd.u.scanRequest); |
| 6705 | |
| 6706 | /* 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] | 6707 | if(scanReq.ChannelInfo.ChannelList != NULL) |
| 6708 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6709 | vos_mem_free(scanReq.ChannelInfo.ChannelList); |
Madan Mohan Koyyalamudi | 0c626f3 | 2012-11-30 15:10:25 -0800 | [diff] [blame] | 6710 | scanReq.ChannelInfo.ChannelList = NULL; |
| 6711 | } |
| 6712 | |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 6713 | pChnInfo->numOfChannels = nNumChanCombinedConc; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 6714 | vos_mem_copy(&channelToScan[0], |
| 6715 | &pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[0], |
| 6716 | pChnInfo->numOfChannels * sizeof(tANI_U8));//just send one channel |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6717 | pChnInfo->ChannelList = &channelToScan[0]; |
| 6718 | |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 6719 | for (i = 0, j = nNumChanCombinedConc; i < (numChn-nNumChanCombinedConc); i++, j++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6720 | { |
| 6721 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[i] = |
Vinay Malekal | 05fdc81 | 2012-12-17 13:04:30 -0800 | [diff] [blame] | 6722 | 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] | 6723 | } |
| 6724 | |
Sudhir Sattayappa Kohalli | eb97d50 | 2013-05-22 23:16:42 -0700 | [diff] [blame] | 6725 | 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] | 6726 | |
| 6727 | scanReq.BSSType = eCSR_BSS_TYPE_ANY; |
c_hpothu | dbefd3e | 2014-04-28 15:59:47 +0530 | [diff] [blame] | 6728 | |
Madan Mohan Koyyalamudi | 4ff9cd6 | 2012-10-30 17:48:57 -0700 | [diff] [blame] | 6729 | //Use concurrency values for min/maxChnTime. |
| 6730 | //We know csrIsAnySessionConnected(pMac) returns TRUE here |
| 6731 | csrSetDefaultScanTiming(pMac, scanReq.scanType, &scanReq); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6732 | |
| 6733 | status = csrScanCopyRequest(pMac, &pSendScanCmd->u.scanCmd.u.scanRequest, &scanReq); |
| 6734 | if(!HAL_STATUS_SUCCESS(status)) |
| 6735 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6736 | smsLog( pMac, LOGE, FL(" Failed to get copy csrScanRequest = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6737 | csrLLUnlock(&pMac->scan.scanCmdPendingList); |
| 6738 | return; |
Madan Mohan Koyyalamudi | 0c626f3 | 2012-11-30 15:10:25 -0800 | [diff] [blame] | 6739 | } |
| 6740 | /* Clean the local scan variable */ |
| 6741 | scanReq.ChannelInfo.ChannelList = NULL; |
| 6742 | scanReq.ChannelInfo.numOfChannels = 0; |
| 6743 | csrScanFreeRequest(pMac, &scanReq); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6744 | } |
| 6745 | else |
Madan Mohan Koyyalamudi | d671358 | 2012-11-09 16:56:56 -0800 | [diff] [blame] | 6746 | { |
| 6747 | /* no active connected session present or numChn == 1 |
| 6748 | * scan all remaining channels */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6749 | pSendScanCmd = pScanCmd; |
| 6750 | //remove this command from pending list |
| 6751 | if (csrLLRemoveHead( &pMac->scan.scanCmdPendingList, LL_ACCESS_NOLOCK) == NULL) |
| 6752 | { //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] | 6753 | smsLog( pMac, LOGE, FL(" Failed to remove entry from scanCmdPendingList")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6754 | } |
| 6755 | |
| 6756 | } |
| 6757 | csrQueueSmeCommand(pMac, pSendScanCmd, eANI_BOOLEAN_FALSE); |
| 6758 | |
| 6759 | } |
| 6760 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6761 | csrLLUnlock(&pMac->scan.scanCmdPendingList); |
| 6762 | |
| 6763 | } |
| 6764 | #endif |
| 6765 | |
Sandeep Puligilla | 2b6dc63 | 2012-12-17 14:44:16 -0800 | [diff] [blame] | 6766 | eHalStatus csrScanStartResultCfgAgingTimer(tpAniSirGlobal pMac) |
| 6767 | { |
| 6768 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 6769 | |
| 6770 | if(pMac->scan.fScanEnable) |
| 6771 | { |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 6772 | 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] | 6773 | } |
| 6774 | return (status); |
| 6775 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6776 | |
Sandeep Puligilla | 2b6dc63 | 2012-12-17 14:44:16 -0800 | [diff] [blame] | 6777 | eHalStatus csrScanStopResultCfgAgingTimer(tpAniSirGlobal pMac) |
| 6778 | { |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 6779 | return (vos_timer_stop(&pMac->scan.hTimerResultCfgAging)); |
Sandeep Puligilla | 2b6dc63 | 2012-12-17 14:44:16 -0800 | [diff] [blame] | 6780 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6781 | |
| 6782 | //This function returns the maximum time a BSS is allowed in the scan result. |
| 6783 | //The time varies base on connection and power saving factors. |
| 6784 | //Not connected, No PS |
| 6785 | //Not connected, with PS |
| 6786 | //Connected w/o traffic, No PS |
| 6787 | //Connected w/o traffic, with PS |
| 6788 | //Connected w/ traffic, no PS -- Not supported |
| 6789 | //Connected w/ traffic, with PS -- Not supported |
| 6790 | //the return unit is in seconds. |
| 6791 | tANI_U32 csrScanGetAgeOutTime(tpAniSirGlobal pMac) |
| 6792 | { |
| 6793 | tANI_U32 nRet; |
| 6794 | |
| 6795 | if(pMac->scan.nAgingCountDown) |
| 6796 | { |
| 6797 | //Calculate what should be the timeout value for this |
| 6798 | nRet = pMac->scan.nLastAgeTimeOut * pMac->scan.nAgingCountDown; |
| 6799 | pMac->scan.nAgingCountDown--; |
| 6800 | } |
| 6801 | else |
| 6802 | { |
| 6803 | if( csrIsAllSessionDisconnected( pMac ) ) |
| 6804 | { |
| 6805 | if(pmcIsPowerSaveEnabled(pMac, ePMC_IDLE_MODE_POWER_SAVE)) |
| 6806 | { |
| 6807 | nRet = pMac->roam.configParam.scanAgeTimeNCPS; |
| 6808 | } |
| 6809 | else |
| 6810 | { |
| 6811 | nRet = pMac->roam.configParam.scanAgeTimeNCNPS; |
| 6812 | } |
| 6813 | } |
| 6814 | else |
| 6815 | { |
| 6816 | if(pmcIsPowerSaveEnabled(pMac, ePMC_BEACON_MODE_POWER_SAVE)) |
| 6817 | { |
| 6818 | nRet = pMac->roam.configParam.scanAgeTimeCPS; |
| 6819 | } |
| 6820 | else |
| 6821 | { |
| 6822 | nRet = pMac->roam.configParam.scanAgeTimeCNPS; |
| 6823 | } |
| 6824 | } |
| 6825 | //If state-change causing aging time out change, we want to delay it somewhat to avoid |
| 6826 | //unnecessary removal of BSS. This is mostly due to transition from connect to disconnect. |
| 6827 | if(pMac->scan.nLastAgeTimeOut > nRet) |
| 6828 | { |
| 6829 | if(nRet) |
| 6830 | { |
| 6831 | pMac->scan.nAgingCountDown = (pMac->scan.nLastAgeTimeOut / nRet); |
| 6832 | } |
| 6833 | pMac->scan.nLastAgeTimeOut = nRet; |
| 6834 | nRet *= pMac->scan.nAgingCountDown; |
| 6835 | } |
| 6836 | else |
| 6837 | { |
| 6838 | pMac->scan.nLastAgeTimeOut = nRet; |
| 6839 | } |
| 6840 | } |
| 6841 | |
| 6842 | return (nRet); |
| 6843 | } |
| 6844 | |
Sandeep Puligilla | 2b6dc63 | 2012-12-17 14:44:16 -0800 | [diff] [blame] | 6845 | static void csrScanResultCfgAgingTimerHandler(void *pv) |
| 6846 | { |
| 6847 | tpAniSirGlobal pMac = PMAC_STRUCT( pv ); |
| 6848 | tListElem *pEntry, *tmpEntry; |
| 6849 | tCsrScanResult *pResult; |
| 6850 | tANI_TIMESTAMP ageOutTime = pMac->scan.scanResultCfgAgingTime * PAL_TICKS_PER_SECOND; |
| 6851 | tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd); |
| 6852 | |
| 6853 | csrLLLock(&pMac->scan.scanResultList); |
| 6854 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK ); |
| 6855 | while( pEntry ) |
| 6856 | { |
| 6857 | tmpEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK); |
| 6858 | pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 6859 | if((curTime - pResult->Result.BssDescriptor.nReceivedTime) > ageOutTime) |
| 6860 | { |
| 6861 | smsLog(pMac, LOGW, " age out due to time out"); |
| 6862 | csrScanAgeOutBss(pMac, pResult); |
| 6863 | } |
| 6864 | pEntry = tmpEntry; |
| 6865 | } |
| 6866 | csrLLUnlock(&pMac->scan.scanResultList); |
Sushant Kaushik | 6274de6 | 2015-05-01 16:31:23 +0530 | [diff] [blame] | 6867 | if (pEntry) |
| 6868 | 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] | 6869 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6870 | |
| 6871 | eHalStatus csrScanStartIdleScanTimer(tpAniSirGlobal pMac, tANI_U32 interval) |
| 6872 | { |
| 6873 | eHalStatus status; |
| 6874 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6875 | smsLog(pMac, LOG1, " csrScanStartIdleScanTimer"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6876 | if((pMac->scan.fScanEnable) && (eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan) && interval) |
| 6877 | { |
| 6878 | pMac->scan.nIdleScanTimeGap += interval; |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 6879 | vos_timer_stop(&pMac->scan.hTimerIdleScan); |
| 6880 | 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] | 6881 | if( !HAL_STATUS_SUCCESS(status) ) |
| 6882 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6883 | 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] | 6884 | //This should not happen but set the flag to restart when ready |
| 6885 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 6886 | } |
| 6887 | } |
| 6888 | else |
| 6889 | { |
| 6890 | if( pMac->scan.fScanEnable && (eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan) ) |
| 6891 | { |
| 6892 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 6893 | } |
| 6894 | status = eHAL_STATUS_FAILURE; |
| 6895 | } |
| 6896 | |
| 6897 | return (status); |
| 6898 | } |
| 6899 | |
| 6900 | |
| 6901 | eHalStatus csrScanStopIdleScanTimer(tpAniSirGlobal pMac) |
| 6902 | { |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 6903 | return (vos_timer_stop(&pMac->scan.hTimerIdleScan)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6904 | } |
| 6905 | |
| 6906 | |
| 6907 | //Stop CSR from asking for IMPS, This function doesn't disable IMPS from CSR |
| 6908 | void csrScanSuspendIMPS( tpAniSirGlobal pMac ) |
| 6909 | { |
| 6910 | csrScanCancelIdleScan(pMac); |
| 6911 | } |
| 6912 | |
| 6913 | |
| 6914 | //Start CSR from asking for IMPS. This function doesn't trigger CSR to request entering IMPS |
| 6915 | //because IMPS maybe disabled. |
| 6916 | void csrScanResumeIMPS( tpAniSirGlobal pMac ) |
| 6917 | { |
| 6918 | csrScanStartIdleScan( pMac ); |
| 6919 | } |
| 6920 | |
| 6921 | |
| 6922 | void csrScanIMPSCallback(void *callbackContext, eHalStatus status) |
| 6923 | { |
| 6924 | tpAniSirGlobal pMac = PMAC_STRUCT( callbackContext ); |
| 6925 | |
| 6926 | if(eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan) |
| 6927 | { |
| 6928 | if(pMac->roam.configParam.IsIdleScanEnabled) |
| 6929 | { |
| 6930 | if(HAL_STATUS_SUCCESS(status)) |
| 6931 | { |
| 6932 | if(csrIsAllSessionDisconnected(pMac) && !csrIsRoamCommandWaiting(pMac)) |
| 6933 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6934 | smsLog(pMac, LOGW, FL("starts idle mode full scan")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6935 | csrScanAllChannels(pMac, eCSR_SCAN_IDLE_MODE_SCAN); |
| 6936 | } |
| 6937 | else |
| 6938 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6939 | smsLog(pMac, LOGW, FL("cannot start idle mode full scan")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6940 | //even though we are in timer handle, calling stop timer will make sure the timer |
| 6941 | //doesn't get to restart. |
| 6942 | csrScanStopIdleScanTimer(pMac); |
| 6943 | } |
| 6944 | } |
| 6945 | else |
| 6946 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6947 | smsLog(pMac, LOGE, FL("sees not success status (%d)"), status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6948 | } |
| 6949 | } |
| 6950 | else |
| 6951 | {//we might need another flag to check if CSR needs to request imps at all |
| 6952 | |
| 6953 | tANI_U32 nTime = 0; |
| 6954 | |
| 6955 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE; |
| 6956 | if(!HAL_STATUS_SUCCESS(csrScanTriggerIdleScan(pMac, &nTime))) |
| 6957 | { |
| 6958 | csrScanStartIdleScanTimer(pMac, nTime); |
| 6959 | } |
| 6960 | } |
| 6961 | } |
| 6962 | } |
| 6963 | |
| 6964 | |
Rashmi Ramanna | 68b309c | 2014-05-20 11:52:22 +0530 | [diff] [blame] | 6965 | //Param: pTimeInterval -- Caller allocated memory in return, if failed, to specify the nxt time interval for |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6966 | //idle scan timer interval |
| 6967 | //Return: Not success -- meaning it cannot start IMPS, caller needs to start a timer for idle scan |
| 6968 | eHalStatus csrScanTriggerIdleScan(tpAniSirGlobal pMac, tANI_U32 *pTimeInterval) |
| 6969 | { |
| 6970 | eHalStatus status = eHAL_STATUS_CSR_WRONG_STATE; |
| 6971 | |
| 6972 | //Do not trigger IMPS in case of concurrency |
Agarwal Ashish | 5974ed3 | 2014-06-16 16:59:54 +0530 | [diff] [blame] | 6973 | if (vos_concurrent_open_sessions_running() && |
| 6974 | csrIsAnySessionInConnectState(pMac)) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6975 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6976 | smsLog( pMac, LOG1, FL("Cannot request IMPS because Concurrent Sessions Running") ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6977 | return (status); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6978 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6979 | |
| 6980 | if(pTimeInterval) |
| 6981 | { |
| 6982 | *pTimeInterval = 0; |
| 6983 | } |
| 6984 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6985 | smsLog(pMac, LOG3, FL("called")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6986 | if( smeCommandPending( pMac ) ) |
| 6987 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 6988 | smsLog( pMac, LOG1, FL(" Cannot request IMPS because command pending") ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6989 | //Not to enter IMPS because more work to do |
| 6990 | if(pTimeInterval) |
| 6991 | { |
| 6992 | *pTimeInterval = 0; |
| 6993 | } |
| 6994 | //restart when ready |
| 6995 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 6996 | |
| 6997 | return (status); |
| 6998 | } |
Kiran Kumar Lokere | f8c3992 | 2013-03-18 11:08:11 -0700 | [diff] [blame] | 6999 | if (IsPmcImpsReqFailed (pMac)) |
| 7000 | { |
| 7001 | if(pTimeInterval) |
| 7002 | { |
| 7003 | *pTimeInterval = 1000000; //usec |
| 7004 | } |
| 7005 | //restart when ready |
| 7006 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7007 | |
Kiran Kumar Lokere | f8c3992 | 2013-03-18 11:08:11 -0700 | [diff] [blame] | 7008 | return status; |
| 7009 | } |
Rashmi Ramanna | 68b309c | 2014-05-20 11:52:22 +0530 | [diff] [blame] | 7010 | |
| 7011 | if ( !pMac->deferImps && pMac->fDeferIMPSTime ) |
| 7012 | { |
| 7013 | smsLog( pMac, LOG1, FL("Defer IMPS for %dms as command processed"), |
| 7014 | pMac->fDeferIMPSTime); |
Girish Gowli | 4f3775a | 2014-05-30 17:17:08 +0530 | [diff] [blame] | 7015 | if(pTimeInterval) |
| 7016 | { |
| 7017 | *pTimeInterval = pMac->fDeferIMPSTime * 1000; //usec |
| 7018 | } |
Rashmi Ramanna | 68b309c | 2014-05-20 11:52:22 +0530 | [diff] [blame] | 7019 | pMac->deferImps = eANI_BOOLEAN_TRUE; |
| 7020 | return status; |
| 7021 | } |
| 7022 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7023 | if((pMac->scan.fScanEnable) && (eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan) |
| 7024 | /*&& pMac->roam.configParam.impsSleepTime*/) |
| 7025 | { |
| 7026 | //Stop get result timer because idle scan gets scan result out of PE |
| 7027 | csrScanStopGetResultTimer(pMac); |
| 7028 | if(pTimeInterval) |
| 7029 | { |
| 7030 | *pTimeInterval = pMac->roam.configParam.impsSleepTime; |
| 7031 | } |
| 7032 | //pmcRequestImps take a period in millisecond unit. |
| 7033 | status = pmcRequestImps(pMac, pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_MS_UNIT, csrScanIMPSCallback, pMac); |
| 7034 | if(!HAL_STATUS_SUCCESS(status)) |
| 7035 | { |
| 7036 | if(eHAL_STATUS_PMC_ALREADY_IN_IMPS != status) |
| 7037 | { |
| 7038 | //Do restart the timer if CSR thinks it cannot do IMPS |
| 7039 | if( !csrCheckPSReady( pMac ) ) |
| 7040 | { |
| 7041 | if(pTimeInterval) |
| 7042 | { |
| 7043 | *pTimeInterval = 0; |
| 7044 | } |
| 7045 | //Set the restart flag to true because that idle scan |
| 7046 | //can be restarted even though the timer will not be running |
| 7047 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 7048 | } |
| 7049 | else |
| 7050 | { |
| 7051 | //For not now, we do a quicker retry |
| 7052 | if(pTimeInterval) |
| 7053 | { |
| 7054 | *pTimeInterval = CSR_IDLE_SCAN_WAIT_TIME; |
| 7055 | } |
| 7056 | } |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7057 | 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] | 7058 | } |
| 7059 | else |
| 7060 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7061 | smsLog(pMac, LOGW, FL("already in IMPS")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7062 | //Since CSR is the only module to request for IMPS. If it is already in IMPS, CSR assumes |
| 7063 | //the callback will be called in the future. Should not happen though. |
| 7064 | status = eHAL_STATUS_SUCCESS; |
| 7065 | pMac->scan.nIdleScanTimeGap = 0; |
| 7066 | } |
| 7067 | } |
| 7068 | else |
| 7069 | { |
| 7070 | //requested so let's reset the value |
| 7071 | pMac->scan.nIdleScanTimeGap = 0; |
| 7072 | } |
| 7073 | } |
| 7074 | |
| 7075 | return (status); |
| 7076 | } |
| 7077 | |
| 7078 | |
| 7079 | eHalStatus csrScanStartIdleScan(tpAniSirGlobal pMac) |
| 7080 | { |
| 7081 | eHalStatus status = eHAL_STATUS_CSR_WRONG_STATE; |
| 7082 | tANI_U32 nTime = 0; |
| 7083 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7084 | smsLog(pMac, LOGW, FL("called")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7085 | if(pMac->roam.configParam.IsIdleScanEnabled) |
| 7086 | { |
| 7087 | //stop bg scan first |
| 7088 | csrScanBGScanAbort(pMac); |
| 7089 | //Stop get result timer because idle scan gets scan result out of PE |
| 7090 | csrScanStopGetResultTimer(pMac); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7091 | } |
| 7092 | pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE; |
| 7093 | status = csrScanTriggerIdleScan(pMac, &nTime); |
| 7094 | if(!HAL_STATUS_SUCCESS(status)) |
| 7095 | { |
| 7096 | csrScanStartIdleScanTimer(pMac, nTime); |
| 7097 | } |
| 7098 | |
| 7099 | return (status); |
| 7100 | } |
| 7101 | |
| 7102 | |
| 7103 | void csrScanCancelIdleScan(tpAniSirGlobal pMac) |
| 7104 | { |
| 7105 | if(eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan) |
| 7106 | { |
Agarwal Ashish | 5974ed3 | 2014-06-16 16:59:54 +0530 | [diff] [blame] | 7107 | if (vos_concurrent_open_sessions_running()) { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7108 | return; |
| 7109 | } |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7110 | smsLog(pMac, LOG1, " csrScanCancelIdleScan"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7111 | pMac->scan.fCancelIdleScan = eANI_BOOLEAN_TRUE; |
| 7112 | //Set the restart flag in case later on it is uncancelled |
| 7113 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 7114 | csrScanStopIdleScanTimer(pMac); |
| 7115 | csrScanRemoveNotRoamingScanCommand(pMac); |
| 7116 | } |
| 7117 | } |
| 7118 | |
| 7119 | |
| 7120 | void csrScanIdleScanTimerHandler(void *pv) |
| 7121 | { |
| 7122 | tpAniSirGlobal pMac = PMAC_STRUCT( pv ); |
| 7123 | eHalStatus status; |
| 7124 | tANI_U32 nTime = 0; |
| 7125 | |
| 7126 | smsLog(pMac, LOGW, " csrScanIdleScanTimerHandler called "); |
Kiran Kumar Lokere | f8c3992 | 2013-03-18 11:08:11 -0700 | [diff] [blame] | 7127 | pmcResetImpsFailStatus (pMac); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7128 | status = csrScanTriggerIdleScan(pMac, &nTime); |
| 7129 | if(!HAL_STATUS_SUCCESS(status) && (eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan)) |
| 7130 | { |
| 7131 | //Check whether it is time to actually do an idle scan |
| 7132 | if(pMac->scan.nIdleScanTimeGap >= pMac->roam.configParam.impsSleepTime) |
| 7133 | { |
| 7134 | pMac->scan.nIdleScanTimeGap = 0; |
| 7135 | csrScanIMPSCallback(pMac, eHAL_STATUS_SUCCESS); |
| 7136 | } |
| 7137 | else |
| 7138 | { |
| 7139 | csrScanStartIdleScanTimer(pMac, nTime); |
| 7140 | } |
| 7141 | } |
Rashmi Ramanna | 68b309c | 2014-05-20 11:52:22 +0530 | [diff] [blame] | 7142 | if(pMac->deferImps) |
| 7143 | { |
| 7144 | pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE; |
| 7145 | pMac->deferImps = eANI_BOOLEAN_FALSE; |
| 7146 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7147 | } |
| 7148 | |
| 7149 | |
| 7150 | |
| 7151 | |
| 7152 | tANI_BOOLEAN csrScanRemoveNotRoamingScanCommand(tpAniSirGlobal pMac) |
| 7153 | { |
| 7154 | tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE; |
| 7155 | tListElem *pEntry, *pEntryTmp; |
| 7156 | tSmeCmd *pCommand; |
| 7157 | tDblLinkList localList; |
Madan Mohan Koyyalamudi | 2125599 | 2013-08-01 18:00:25 +0530 | [diff] [blame] | 7158 | tDblLinkList *pCmdList; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7159 | |
| 7160 | vos_mem_zero(&localList, sizeof(tDblLinkList)); |
| 7161 | if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList))) |
| 7162 | { |
| 7163 | smsLog(pMac, LOGE, FL(" failed to open list")); |
| 7164 | return fRet; |
| 7165 | } |
Madan Mohan Koyyalamudi | 2125599 | 2013-08-01 18:00:25 +0530 | [diff] [blame] | 7166 | if (!pMac->fScanOffload) |
| 7167 | pCmdList = &pMac->sme.smeCmdPendingList; |
| 7168 | else |
| 7169 | pCmdList = &pMac->sme.smeScanCmdPendingList; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7170 | |
Madan Mohan Koyyalamudi | 2125599 | 2013-08-01 18:00:25 +0530 | [diff] [blame] | 7171 | csrLLLock(pCmdList); |
| 7172 | pEntry = csrLLPeekHead(pCmdList, LL_ACCESS_NOLOCK); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7173 | while(pEntry) |
| 7174 | { |
Madan Mohan Koyyalamudi | 2125599 | 2013-08-01 18:00:25 +0530 | [diff] [blame] | 7175 | pEntryTmp = csrLLNext(pCmdList, pEntry, LL_ACCESS_NOLOCK); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7176 | pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link); |
| 7177 | if( eSmeCommandScan == pCommand->command ) |
| 7178 | { |
| 7179 | switch( pCommand->u.scanCmd.reason ) |
| 7180 | { |
| 7181 | case eCsrScanIdleScan: |
Madan Mohan Koyyalamudi | 2125599 | 2013-08-01 18:00:25 +0530 | [diff] [blame] | 7182 | if( csrLLRemoveEntry(pCmdList, pEntry, LL_ACCESS_NOLOCK) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7183 | { |
| 7184 | csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK); |
| 7185 | } |
| 7186 | fRet = eANI_BOOLEAN_TRUE; |
| 7187 | break; |
| 7188 | |
| 7189 | default: |
| 7190 | break; |
| 7191 | } //switch |
| 7192 | } |
| 7193 | pEntry = pEntryTmp; |
| 7194 | } |
| 7195 | |
Madan Mohan Koyyalamudi | 2125599 | 2013-08-01 18:00:25 +0530 | [diff] [blame] | 7196 | csrLLUnlock(pCmdList); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7197 | |
| 7198 | while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) ) |
| 7199 | { |
| 7200 | pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link); |
| 7201 | csrReleaseCommandScan( pMac, pCommand ); |
| 7202 | } |
| 7203 | |
| 7204 | csrLLClose(&localList); |
| 7205 | |
| 7206 | return (fRet); |
| 7207 | } |
| 7208 | |
| 7209 | |
| 7210 | tANI_BOOLEAN csrScanRemoveFreshScanCommand(tpAniSirGlobal pMac, tANI_U8 sessionId) |
| 7211 | { |
| 7212 | tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE; |
| 7213 | tListElem *pEntry, *pEntryTmp; |
| 7214 | tSmeCmd *pCommand; |
| 7215 | tDblLinkList localList; |
Madan Mohan Koyyalamudi | 2125599 | 2013-08-01 18:00:25 +0530 | [diff] [blame] | 7216 | tDblLinkList *pCmdList; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7217 | |
| 7218 | vos_mem_zero(&localList, sizeof(tDblLinkList)); |
| 7219 | if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList))) |
| 7220 | { |
| 7221 | smsLog(pMac, LOGE, FL(" failed to open list")); |
| 7222 | return fRet; |
| 7223 | } |
| 7224 | |
Madan Mohan Koyyalamudi | 2125599 | 2013-08-01 18:00:25 +0530 | [diff] [blame] | 7225 | if (!pMac->fScanOffload) |
| 7226 | pCmdList = &pMac->sme.smeCmdPendingList; |
| 7227 | else |
| 7228 | pCmdList = &pMac->sme.smeScanCmdPendingList; |
| 7229 | |
| 7230 | csrLLLock(pCmdList); |
| 7231 | pEntry = csrLLPeekHead(pCmdList, LL_ACCESS_NOLOCK); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7232 | while(pEntry) |
| 7233 | { |
Madan Mohan Koyyalamudi | 2125599 | 2013-08-01 18:00:25 +0530 | [diff] [blame] | 7234 | pEntryTmp = csrLLNext(pCmdList, pEntry, LL_ACCESS_NOLOCK); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7235 | pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link); |
| 7236 | if( (eSmeCommandScan == pCommand->command) && (sessionId == pCommand->sessionId) ) |
| 7237 | { |
| 7238 | switch(pCommand->u.scanCmd.reason) |
| 7239 | { |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 7240 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 7241 | case eCsrScanGetLfrResult: |
| 7242 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7243 | case eCsrScanGetResult: |
| 7244 | case eCsrScanSetBGScanParam: |
| 7245 | case eCsrScanBGScanAbort: |
| 7246 | case eCsrScanBGScanEnable: |
| 7247 | case eCsrScanGetScanChnInfo: |
| 7248 | break; |
| 7249 | default: |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7250 | smsLog (pMac, LOGW, "%s: -------- abort scan command reason = %d", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7251 | __func__, pCommand->u.scanCmd.reason); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7252 | //The rest are fresh scan requests |
Madan Mohan Koyyalamudi | 2125599 | 2013-08-01 18:00:25 +0530 | [diff] [blame] | 7253 | if( csrLLRemoveEntry(pCmdList, pEntry, LL_ACCESS_NOLOCK) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7254 | { |
| 7255 | csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK); |
| 7256 | } |
| 7257 | fRet = eANI_BOOLEAN_TRUE; |
| 7258 | break; |
| 7259 | } |
| 7260 | } |
| 7261 | pEntry = pEntryTmp; |
| 7262 | } |
| 7263 | |
Madan Mohan Koyyalamudi | 2125599 | 2013-08-01 18:00:25 +0530 | [diff] [blame] | 7264 | csrLLUnlock(pCmdList); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7265 | |
| 7266 | while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) ) |
| 7267 | { |
| 7268 | pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link); |
| 7269 | if (pCommand->u.scanCmd.callback) |
| 7270 | { |
| 7271 | /* User scan request is pending, |
| 7272 | * send response with status eCSR_SCAN_ABORT*/ |
| 7273 | pCommand->u.scanCmd.callback(pMac, |
| 7274 | pCommand->u.scanCmd.pContext, |
| 7275 | pCommand->u.scanCmd.scanID, |
| 7276 | eCSR_SCAN_ABORT); |
| 7277 | } |
| 7278 | csrReleaseCommandScan( pMac, pCommand ); |
| 7279 | } |
| 7280 | csrLLClose(&localList); |
| 7281 | |
| 7282 | return (fRet); |
| 7283 | } |
| 7284 | |
| 7285 | |
| 7286 | void csrReleaseScanCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand, eCsrScanStatus scanStatus) |
| 7287 | { |
| 7288 | eCsrScanReason reason = pCommand->u.scanCmd.reason; |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 7289 | tANI_BOOLEAN status; |
| 7290 | |
| 7291 | if (!pMac->fScanOffload) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7292 | { |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 7293 | tANI_U32 i; |
| 7294 | for(i = 0; i < CSR_ROAM_SESSION_MAX; i++) |
| 7295 | csrRoamStateChange(pMac, pCommand->u.scanCmd.lastRoamState[i], i); |
| 7296 | } |
| 7297 | else |
| 7298 | { |
| 7299 | csrRoamStateChange(pMac, |
| 7300 | pCommand->u.scanCmd.lastRoamState[pCommand->sessionId], |
| 7301 | pCommand->sessionId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7302 | } |
| 7303 | |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 7304 | csrScanCallCallback(pMac, pCommand, scanStatus); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7305 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7306 | smsLog(pMac, LOG3, " Remove Scan command reason = %d", reason); |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 7307 | if (pMac->fScanOffload) |
| 7308 | { |
| 7309 | status = csrLLRemoveEntry(&pMac->sme.smeScanCmdActiveList, |
| 7310 | &pCommand->Link, LL_ACCESS_LOCK); |
| 7311 | } |
| 7312 | else |
| 7313 | { |
| 7314 | status = csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, |
| 7315 | &pCommand->Link, LL_ACCESS_LOCK); |
| 7316 | } |
| 7317 | |
| 7318 | if(status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7319 | { |
| 7320 | csrReleaseCommandScan( pMac, pCommand ); |
| 7321 | } |
| 7322 | else |
| 7323 | { |
Madan Mohan Koyyalamudi | e1a64b4 | 2013-06-19 16:34:44 +0530 | [diff] [blame] | 7324 | smsLog(pMac, LOGE, |
| 7325 | " ********csrReleaseScanCommand cannot release command reason %d", |
| 7326 | pCommand->u.scanCmd.reason ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7327 | } |
| 7328 | } |
| 7329 | |
| 7330 | |
| 7331 | eHalStatus csrScanGetPMKIDCandidateList(tpAniSirGlobal pMac, tANI_U32 sessionId, |
| 7332 | tPmkidCandidateInfo *pPmkidList, tANI_U32 *pNumItems ) |
| 7333 | { |
| 7334 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 7335 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 7336 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 7337 | if(!pSession) |
| 7338 | { |
| 7339 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 7340 | return eHAL_STATUS_FAILURE; |
| 7341 | } |
| 7342 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7343 | smsLog(pMac, LOGW, " pMac->scan.NumPmkidCandidate = %d", pSession->NumPmkidCandidate); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7344 | csrResetPMKIDCandidateList(pMac, sessionId); |
| 7345 | if(csrIsConnStateConnected(pMac, sessionId) && pSession->pCurRoamProfile) |
| 7346 | { |
| 7347 | tCsrScanResultFilter *pScanFilter; |
| 7348 | tCsrScanResultInfo *pScanResult; |
| 7349 | tScanResultHandle hBSSList; |
| 7350 | tANI_U32 nItems = *pNumItems; |
| 7351 | |
| 7352 | *pNumItems = 0; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7353 | pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter)); |
| 7354 | if ( NULL == pScanFilter ) |
| 7355 | status = eHAL_STATUS_FAILURE; |
| 7356 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7357 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7358 | vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7359 | //Here is the profile we need to connect to |
| 7360 | status = csrRoamPrepareFilterFromProfile(pMac, pSession->pCurRoamProfile, pScanFilter); |
| 7361 | if(HAL_STATUS_SUCCESS(status)) |
| 7362 | { |
| 7363 | status = csrScanGetResult(pMac, pScanFilter, &hBSSList); |
| 7364 | if(HAL_STATUS_SUCCESS(status)) |
| 7365 | { |
| 7366 | while(((pScanResult = csrScanResultGetNext(pMac, hBSSList)) != NULL) && ( pSession->NumPmkidCandidate < nItems)) |
| 7367 | { |
| 7368 | //NumPmkidCandidate adds up here |
| 7369 | csrProcessBSSDescForPMKIDList(pMac, &pScanResult->BssDescriptor, |
| 7370 | (tDot11fBeaconIEs *)( pScanResult->pvIes )); |
| 7371 | } |
| 7372 | if(pSession->NumPmkidCandidate) |
| 7373 | { |
| 7374 | *pNumItems = pSession->NumPmkidCandidate; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7375 | vos_mem_copy(pPmkidList, pSession->PmkidCandidateInfo, |
| 7376 | pSession->NumPmkidCandidate * sizeof(tPmkidCandidateInfo)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7377 | } |
| 7378 | csrScanResultPurge(pMac, hBSSList); |
| 7379 | }//Have scan result |
| 7380 | csrFreeScanFilter(pMac, pScanFilter); |
| 7381 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7382 | vos_mem_free(pScanFilter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7383 | } |
| 7384 | } |
| 7385 | |
| 7386 | return (status); |
| 7387 | } |
| 7388 | |
| 7389 | |
| 7390 | |
| 7391 | #ifdef FEATURE_WLAN_WAPI |
| 7392 | eHalStatus csrScanGetBKIDCandidateList(tpAniSirGlobal pMac, tANI_U32 sessionId, |
| 7393 | tBkidCandidateInfo *pBkidList, tANI_U32 *pNumItems ) |
| 7394 | { |
| 7395 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 7396 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
| 7397 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 7398 | if(!pSession) |
| 7399 | { |
| 7400 | smsLog(pMac, LOGE, FL(" session %d not found "), sessionId); |
| 7401 | return eHAL_STATUS_FAILURE; |
| 7402 | } |
| 7403 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7404 | smsLog(pMac, LOGW, " pMac->scan.NumBkidCandidate = %d", pSession->NumBkidCandidate); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7405 | csrResetBKIDCandidateList(pMac, sessionId); |
| 7406 | if(csrIsConnStateConnected(pMac, sessionId) && pSession->pCurRoamProfile) |
| 7407 | { |
| 7408 | tCsrScanResultFilter *pScanFilter; |
| 7409 | tCsrScanResultInfo *pScanResult; |
| 7410 | tScanResultHandle hBSSList; |
| 7411 | tANI_U32 nItems = *pNumItems; |
| 7412 | *pNumItems = 0; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7413 | pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter)); |
| 7414 | if ( NULL == pScanFilter ) |
| 7415 | status = eHAL_STATUS_FAILURE; |
| 7416 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7417 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7418 | vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7419 | //Here is the profile we need to connect to |
| 7420 | status = csrRoamPrepareFilterFromProfile(pMac, pSession->pCurRoamProfile, pScanFilter); |
| 7421 | if(HAL_STATUS_SUCCESS(status)) |
| 7422 | { |
| 7423 | status = csrScanGetResult(pMac, pScanFilter, &hBSSList); |
| 7424 | if(HAL_STATUS_SUCCESS(status)) |
| 7425 | { |
| 7426 | while(((pScanResult = csrScanResultGetNext(pMac, hBSSList)) != NULL) && ( pSession->NumBkidCandidate < nItems)) |
| 7427 | { |
| 7428 | //pMac->scan.NumBkidCandidate adds up here |
| 7429 | csrProcessBSSDescForBKIDList(pMac, &pScanResult->BssDescriptor, |
| 7430 | (tDot11fBeaconIEs *)( pScanResult->pvIes )); |
| 7431 | |
| 7432 | } |
| 7433 | if(pSession->NumBkidCandidate) |
| 7434 | { |
| 7435 | *pNumItems = pSession->NumBkidCandidate; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7436 | vos_mem_copy(pBkidList, pSession->BkidCandidateInfo, pSession->NumBkidCandidate * sizeof(tBkidCandidateInfo)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7437 | } |
| 7438 | csrScanResultPurge(pMac, hBSSList); |
| 7439 | }//Have scan result |
| 7440 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7441 | vos_mem_free(pScanFilter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7442 | } |
| 7443 | } |
| 7444 | |
| 7445 | return (status); |
| 7446 | } |
| 7447 | #endif /* FEATURE_WLAN_WAPI */ |
| 7448 | |
| 7449 | |
| 7450 | |
| 7451 | //This function is usually used for BSSs that suppresses SSID so the profile |
| 7452 | //shall have one and only one SSID |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 7453 | 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] | 7454 | { |
| 7455 | eHalStatus status = eHAL_STATUS_INVALID_PARAMETER; |
| 7456 | tSmeCmd *pScanCmd = NULL; |
| 7457 | tANI_U8 bAddr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; |
| 7458 | tANI_U8 index = 0; |
| 7459 | tANI_U32 numSsid = pProfile->SSIDs.numOfSSIDs; |
| 7460 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7461 | smsLog(pMac, LOG2, FL("called")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7462 | //For WDS, we use the index 0. There must be at least one in there |
| 7463 | if( CSR_IS_WDS_STA( pProfile ) && numSsid ) |
| 7464 | { |
| 7465 | numSsid = 1; |
| 7466 | } |
| 7467 | if(pMac->scan.fScanEnable && ( numSsid == 1 ) ) |
| 7468 | { |
| 7469 | do |
| 7470 | { |
| 7471 | pScanCmd = csrGetCommandBuffer(pMac); |
| 7472 | if(!pScanCmd) |
| 7473 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7474 | smsLog(pMac, LOGE, FL("failed to allocate command buffer")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7475 | break; |
| 7476 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7477 | vos_mem_set(&pScanCmd->u.scanCmd, sizeof(tScanCmd), 0); |
| 7478 | pScanCmd->u.scanCmd.pToRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile)); |
| 7479 | if ( NULL == pScanCmd->u.scanCmd.pToRoamProfile ) |
krunal soni | 587bf01 | 2014-02-04 12:35:11 -0800 | [diff] [blame] | 7480 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7481 | status = eHAL_STATUS_FAILURE; |
krunal soni | 587bf01 | 2014-02-04 12:35:11 -0800 | [diff] [blame] | 7482 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7483 | else |
krunal soni | 587bf01 | 2014-02-04 12:35:11 -0800 | [diff] [blame] | 7484 | { |
| 7485 | status = csrRoamCopyProfile(pMac, pScanCmd->u.scanCmd.pToRoamProfile, pProfile); |
| 7486 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7487 | if(!HAL_STATUS_SUCCESS(status)) |
| 7488 | break; |
| 7489 | pScanCmd->u.scanCmd.roamId = roamId; |
| 7490 | pScanCmd->command = eSmeCommandScan; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7491 | pScanCmd->sessionId = (tANI_U8)sessionId; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7492 | pScanCmd->u.scanCmd.callback = NULL; |
| 7493 | pScanCmd->u.scanCmd.pContext = NULL; |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 7494 | 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] | 7495 | pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7496 | vos_mem_set(&pScanCmd->u.scanCmd.u.scanRequest, sizeof(tCsrScanRequest), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7497 | pScanCmd->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7498 | pScanCmd->u.scanCmd.u.scanRequest.BSSType = pProfile->BSSType; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7499 | // To avoid 11b rate in probe request Set p2pSearch flag as 1 for P2P Client Mode |
| 7500 | if(VOS_P2P_CLIENT_MODE == pProfile->csrPersona) |
| 7501 | { |
| 7502 | pScanCmd->u.scanCmd.u.scanRequest.p2pSearch = 1; |
| 7503 | } |
Agarwal Ashish | 4f61613 | 2013-12-30 23:32:50 +0530 | [diff] [blame] | 7504 | if(pProfile->nAddIEScanLength) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7505 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7506 | pScanCmd->u.scanCmd.u.scanRequest.pIEField = vos_mem_malloc( |
| 7507 | pProfile->nAddIEScanLength); |
| 7508 | if ( NULL == pScanCmd->u.scanCmd.u.scanRequest.pIEField ) |
| 7509 | status = eHAL_STATUS_FAILURE; |
| 7510 | else |
| 7511 | status = eHAL_STATUS_SUCCESS; |
| 7512 | vos_mem_set(pScanCmd->u.scanCmd.u.scanRequest.pIEField, |
| 7513 | pProfile->nAddIEScanLength, 0); |
| 7514 | if (HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7515 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7516 | vos_mem_copy(pScanCmd->u.scanCmd.u.scanRequest.pIEField, |
Agarwal Ashish | 4f61613 | 2013-12-30 23:32:50 +0530 | [diff] [blame] | 7517 | pProfile->addIEScan, pProfile->nAddIEScanLength); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7518 | pScanCmd->u.scanCmd.u.scanRequest.uIEFieldLen = pProfile->nAddIEScanLength; |
| 7519 | } |
| 7520 | else |
| 7521 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7522 | smsLog(pMac, LOGE, "No memory for scanning IE fields"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7523 | } |
| 7524 | } //Allocate memory for IE field |
| 7525 | else |
| 7526 | { |
| 7527 | pScanCmd->u.scanCmd.u.scanRequest.uIEFieldLen = 0; |
| 7528 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 7529 | /* For one channel be good enpugh time to receive beacon atleast */ |
| 7530 | if( 1 == pProfile->ChannelInfo.numOfChannels ) |
| 7531 | { |
| 7532 | pScanCmd->u.scanCmd.u.scanRequest.maxChnTime = MAX_ACTIVE_SCAN_FOR_ONE_CHANNEL; |
| 7533 | pScanCmd->u.scanCmd.u.scanRequest.minChnTime = MIN_ACTIVE_SCAN_FOR_ONE_CHANNEL; |
| 7534 | } |
| 7535 | else |
| 7536 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7537 | pScanCmd->u.scanCmd.u.scanRequest.maxChnTime = |
| 7538 | pMac->roam.configParam.nActiveMaxChnTime; |
| 7539 | pScanCmd->u.scanCmd.u.scanRequest.minChnTime = |
| 7540 | pMac->roam.configParam.nActiveMinChnTime; |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 7541 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7542 | pScanCmd->u.scanCmd.u.scanRequest.maxChnTimeBtc = |
| 7543 | pMac->roam.configParam.nActiveMaxChnTimeBtc; |
| 7544 | pScanCmd->u.scanCmd.u.scanRequest.minChnTimeBtc = |
| 7545 | pMac->roam.configParam.nActiveMinChnTimeBtc; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7546 | if(pProfile->BSSIDs.numOfBSSIDs == 1) |
| 7547 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7548 | vos_mem_copy(pScanCmd->u.scanCmd.u.scanRequest.bssid, |
| 7549 | pProfile->BSSIDs.bssid, sizeof(tCsrBssid)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7550 | } |
| 7551 | else |
| 7552 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7553 | vos_mem_copy(pScanCmd->u.scanCmd.u.scanRequest.bssid, bAddr, 6); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7554 | } |
| 7555 | if(pProfile->ChannelInfo.numOfChannels) |
| 7556 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7557 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = vos_mem_malloc( |
| 7558 | sizeof(*pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList) |
| 7559 | * pProfile->ChannelInfo.numOfChannels); |
| 7560 | if ( NULL == pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList ) |
| 7561 | status = eHAL_STATUS_FAILURE; |
| 7562 | else |
| 7563 | status = eHAL_STATUS_SUCCESS; |
| 7564 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = 0; |
| 7565 | if(HAL_STATUS_SUCCESS(status)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7566 | { |
| 7567 | csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[0]); |
| 7568 | for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++) |
| 7569 | { |
| 7570 | if(csrRoamIsValidChannel(pMac, pProfile->ChannelInfo.ChannelList[index])) |
| 7571 | { |
| 7572 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels] |
| 7573 | = pProfile->ChannelInfo.ChannelList[index]; |
| 7574 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels++; |
| 7575 | } |
| 7576 | else |
| 7577 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7578 | 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] | 7579 | } |
| 7580 | |
| 7581 | } |
| 7582 | } |
| 7583 | else |
| 7584 | { |
| 7585 | break; |
| 7586 | } |
| 7587 | |
| 7588 | } |
| 7589 | else |
| 7590 | { |
| 7591 | pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = 0; |
| 7592 | } |
| 7593 | if(pProfile->SSIDs.numOfSSIDs) |
| 7594 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7595 | pScanCmd->u.scanCmd.u.scanRequest.SSIDs.SSIDList = vos_mem_malloc( |
| 7596 | pProfile->SSIDs.numOfSSIDs * sizeof(tCsrSSIDInfo)); |
| 7597 | if ( NULL == pScanCmd->u.scanCmd.u.scanRequest.SSIDs.SSIDList ) |
| 7598 | status = eHAL_STATUS_FAILURE; |
| 7599 | else |
| 7600 | status = eHAL_STATUS_SUCCESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7601 | if(!HAL_STATUS_SUCCESS(status)) |
| 7602 | { |
| 7603 | break; |
| 7604 | } |
| 7605 | pScanCmd->u.scanCmd.u.scanRequest.SSIDs.numOfSSIDs = 1; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7606 | vos_mem_copy(pScanCmd->u.scanCmd.u.scanRequest.SSIDs.SSIDList, |
| 7607 | pProfile->SSIDs.SSIDList, sizeof(tCsrSSIDInfo)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7608 | } |
| 7609 | //Start process the command |
| 7610 | status = csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_FALSE); |
| 7611 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 7612 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7613 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7614 | break; |
| 7615 | } |
| 7616 | }while(0); |
| 7617 | if(!HAL_STATUS_SUCCESS(status)) |
| 7618 | { |
| 7619 | if(pScanCmd) |
| 7620 | { |
| 7621 | csrReleaseCommandScan(pMac, pScanCmd); |
| 7622 | //TODO:free the memory that is allocated in this function |
| 7623 | } |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 7624 | if(notify) |
| 7625 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7626 | csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE); |
| 7627 | } |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 7628 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7629 | }//valid |
| 7630 | else |
| 7631 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7632 | 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] | 7633 | pMac->scan.fScanEnable, pProfile->SSIDs.numOfSSIDs); |
| 7634 | } |
| 7635 | |
| 7636 | return (status); |
| 7637 | } |
| 7638 | |
| 7639 | |
| 7640 | //Issue a scan base on the new capability infomation |
| 7641 | //This should only happen when the associated AP changes its capability. |
| 7642 | //After this scan is done, CSR reroams base on the new scan results |
| 7643 | eHalStatus csrScanForCapabilityChange(tpAniSirGlobal pMac, tSirSmeApNewCaps *pNewCaps) |
| 7644 | { |
| 7645 | eHalStatus status = eHAL_STATUS_INVALID_PARAMETER; |
| 7646 | tSmeCmd *pScanCmd = NULL; |
| 7647 | |
| 7648 | if(pNewCaps) |
| 7649 | { |
| 7650 | do |
| 7651 | { |
| 7652 | pScanCmd = csrGetCommandBuffer(pMac); |
| 7653 | if(!pScanCmd) |
| 7654 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7655 | smsLog(pMac, LOGE, FL("failed to allocate command buffer")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7656 | status = eHAL_STATUS_RESOURCES; |
| 7657 | break; |
| 7658 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7659 | vos_mem_set(&pScanCmd->u.scanCmd, sizeof(tScanCmd), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7660 | status = eHAL_STATUS_SUCCESS; |
| 7661 | pScanCmd->u.scanCmd.roamId = 0; |
| 7662 | pScanCmd->command = eSmeCommandScan; |
| 7663 | pScanCmd->u.scanCmd.callback = NULL; |
| 7664 | pScanCmd->u.scanCmd.pContext = NULL; |
| 7665 | pScanCmd->u.scanCmd.reason = eCsrScanForCapsChange; |
| 7666 | pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around |
| 7667 | status = csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_FALSE); |
| 7668 | if( !HAL_STATUS_SUCCESS( status ) ) |
| 7669 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7670 | smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7671 | break; |
| 7672 | } |
| 7673 | }while(0); |
| 7674 | if(!HAL_STATUS_SUCCESS(status)) |
| 7675 | { |
| 7676 | if(pScanCmd) |
| 7677 | { |
| 7678 | csrReleaseCommandScan(pMac, pScanCmd); |
| 7679 | } |
| 7680 | } |
| 7681 | } |
| 7682 | |
| 7683 | return (status); |
| 7684 | } |
| 7685 | |
| 7686 | |
| 7687 | |
| 7688 | void csrInitBGScanChannelList(tpAniSirGlobal pMac) |
| 7689 | { |
| 7690 | tANI_U32 len = CSR_MIN(sizeof(pMac->roam.validChannelList), sizeof(pMac->scan.bgScanChannelList)); |
| 7691 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7692 | vos_mem_set(pMac->scan.bgScanChannelList, len, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7693 | pMac->scan.numBGScanChannel = 0; |
| 7694 | |
| 7695 | if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len))) |
| 7696 | { |
| 7697 | pMac->roam.numValidChannels = len; |
| 7698 | pMac->scan.numBGScanChannel = (tANI_U8)CSR_MIN(len, WNI_CFG_BG_SCAN_CHANNEL_LIST_LEN); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7699 | vos_mem_copy(pMac->scan.bgScanChannelList, pMac->roam.validChannelList, |
| 7700 | pMac->scan.numBGScanChannel); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7701 | csrSetBGScanChannelList(pMac, pMac->scan.bgScanChannelList, pMac->scan.numBGScanChannel); |
| 7702 | } |
| 7703 | } |
| 7704 | |
| 7705 | |
| 7706 | //This function return TRUE if background scan channel list is adjusted. |
| 7707 | //this function will only shrink the background scan channel list |
| 7708 | tANI_BOOLEAN csrAdjustBGScanChannelList(tpAniSirGlobal pMac, tANI_U8 *pChannelList, tANI_U8 NumChannels, |
| 7709 | tANI_U8 *pAdjustChannels, tANI_U8 *pNumAdjustChannels) |
| 7710 | { |
| 7711 | tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE; |
| 7712 | tANI_U8 i, j, count = *pNumAdjustChannels; |
| 7713 | |
| 7714 | i = 0; |
| 7715 | while(i < count) |
| 7716 | { |
| 7717 | for(j = 0; j < NumChannels; j++) |
| 7718 | { |
| 7719 | if(pChannelList[j] == pAdjustChannels[i]) |
| 7720 | break; |
| 7721 | } |
| 7722 | if(j == NumChannels) |
| 7723 | { |
| 7724 | //This channel is not in the list, remove it |
| 7725 | fRet = eANI_BOOLEAN_TRUE; |
| 7726 | count--; |
| 7727 | if(count - i) |
| 7728 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7729 | vos_mem_copy(&pAdjustChannels[i], &pAdjustChannels[i+1], count - i); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7730 | } |
| 7731 | else |
| 7732 | { |
| 7733 | //already remove the last one. Done. |
| 7734 | break; |
| 7735 | } |
| 7736 | } |
| 7737 | else |
| 7738 | { |
| 7739 | i++; |
| 7740 | } |
| 7741 | }//while(i<count) |
| 7742 | *pNumAdjustChannels = count; |
| 7743 | |
| 7744 | return (fRet); |
| 7745 | } |
| 7746 | |
| 7747 | |
| 7748 | //Get the list of the base channels to scan for passively 11d info |
| 7749 | eHalStatus csrScanGetSupportedChannels( tpAniSirGlobal pMac ) |
| 7750 | { |
| 7751 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 7752 | int n = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 7753 | |
| 7754 | status = vos_nv_getSupportedChannels( pMac->scan.baseChannels.channelList, &n, NULL, NULL ); |
| 7755 | if( HAL_STATUS_SUCCESS(status) ) |
| 7756 | { |
| 7757 | pMac->scan.baseChannels.numChannels = (tANI_U8)n; |
| 7758 | } |
| 7759 | else |
| 7760 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7761 | smsLog( pMac, LOGE, FL(" failed") ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7762 | pMac->scan.baseChannels.numChannels = 0; |
| 7763 | } |
| 7764 | |
| 7765 | return ( status ); |
| 7766 | } |
| 7767 | |
| 7768 | //This function use the input pChannelList to validate the current saved channel list |
| 7769 | eHalStatus csrSetBGScanChannelList( tpAniSirGlobal pMac, tANI_U8 *pAdjustChannels, tANI_U8 NumAdjustChannels) |
| 7770 | { |
| 7771 | tANI_U32 dataLen = sizeof( tANI_U8 ) * NumAdjustChannels; |
| 7772 | |
| 7773 | return (ccmCfgSetStr(pMac, WNI_CFG_BG_SCAN_CHANNEL_LIST, pAdjustChannels, dataLen, NULL, eANI_BOOLEAN_FALSE)); |
| 7774 | } |
| 7775 | |
| 7776 | |
| 7777 | void csrSetCfgValidChannelList( tpAniSirGlobal pMac, tANI_U8 *pChannelList, tANI_U8 NumChannels ) |
| 7778 | { |
| 7779 | tANI_U32 dataLen = sizeof( tANI_U8 ) * NumChannels; |
Gopichand Nakkala | f72a387 | 2013-06-11 17:51:13 +0530 | [diff] [blame] | 7780 | eHalStatus status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7781 | |
Mihir Shete | 31c435d | 2014-02-12 13:13:34 +0530 | [diff] [blame] | 7782 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, |
| 7783 | "%s: dump valid channel list(NumChannels(%d))", |
| 7784 | __func__,NumChannels); |
| 7785 | VOS_TRACE_HEX_DUMP(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, |
| 7786 | pChannelList, NumChannels); |
| 7787 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7788 | ccmCfgSetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST, pChannelList, dataLen, NULL, eANI_BOOLEAN_FALSE); |
Leela Venkata Kiran Kumar Reddy Chirala | c6663f7 | 2014-02-03 21:04:58 -0800 | [diff] [blame] | 7789 | #ifdef QCA_WIFI_2_0 |
Gopichand Nakkala | f72a387 | 2013-06-11 17:51:13 +0530 | [diff] [blame] | 7790 | if (pMac->fScanOffload) |
| 7791 | { |
| 7792 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, |
| 7793 | "Scan offload is enabled, update default chan list"); |
Leela Venkata Kiran Kumar Reddy Chirala | c6663f7 | 2014-02-03 21:04:58 -0800 | [diff] [blame] | 7794 | status = csrUpdateChannelList(pMac); |
| 7795 | } |
| 7796 | #else |
| 7797 | status = csrUpdateChannelList(pMac); |
| 7798 | #endif |
| 7799 | |
| 7800 | if (eHAL_STATUS_SUCCESS != status) |
| 7801 | { |
| 7802 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, |
| 7803 | "failed to update the supported channel list"); |
Gopichand Nakkala | f72a387 | 2013-06-11 17:51:13 +0530 | [diff] [blame] | 7804 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7805 | return; |
| 7806 | } |
| 7807 | |
| 7808 | |
| 7809 | |
| 7810 | /* |
| 7811 | * The Tx power limits are saved in the cfg for future usage. |
| 7812 | */ |
| 7813 | void csrSaveTxPowerToCfg( tpAniSirGlobal pMac, tDblLinkList *pList, tANI_U32 cfgId ) |
| 7814 | { |
| 7815 | tListElem *pEntry; |
| 7816 | tANI_U32 cbLen = 0, dataLen; |
| 7817 | tCsrChannelPowerInfo *pChannelSet; |
| 7818 | tANI_U32 idx; |
| 7819 | tSirMacChanInfo *pChannelPowerSet; |
| 7820 | tANI_U8 *pBuf = NULL; |
| 7821 | |
| 7822 | //allocate maximum space for all channels |
| 7823 | dataLen = WNI_CFG_VALID_CHANNEL_LIST_LEN * sizeof(tSirMacChanInfo); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7824 | if ( (pBuf = vos_mem_malloc(dataLen)) != NULL ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7825 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7826 | vos_mem_set(pBuf, dataLen, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7827 | pChannelPowerSet = (tSirMacChanInfo *)(pBuf); |
| 7828 | |
| 7829 | pEntry = csrLLPeekHead( pList, LL_ACCESS_LOCK ); |
| 7830 | // write the tuples (startChan, numChan, txPower) for each channel found in the channel power list. |
| 7831 | while( pEntry ) |
| 7832 | { |
| 7833 | pChannelSet = GET_BASE_ADDR( pEntry, tCsrChannelPowerInfo, link ); |
| 7834 | if ( 1 != pChannelSet->interChannelOffset ) |
| 7835 | { |
| 7836 | // we keep the 5G channel sets internally with an interchannel offset of 4. Expand these |
| 7837 | // to the right format... (inter channel offset of 1 is the only option for the triplets |
| 7838 | // that 11d advertises. |
| 7839 | if ((cbLen + (pChannelSet->numChannels * sizeof(tSirMacChanInfo))) >= dataLen) |
| 7840 | { |
| 7841 | // expanding this entry will overflow our allocation |
| 7842 | smsLog(pMac, LOGE, |
| 7843 | "%s: Buffer overflow, start %d, num %d, offset %d", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7844 | __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7845 | pChannelSet->firstChannel, |
| 7846 | pChannelSet->numChannels, |
| 7847 | pChannelSet->interChannelOffset); |
| 7848 | break; |
| 7849 | } |
| 7850 | |
| 7851 | for( idx = 0; idx < pChannelSet->numChannels; idx++ ) |
| 7852 | { |
| 7853 | pChannelPowerSet->firstChanNum = (tSirMacChanNum)(pChannelSet->firstChannel + ( idx * pChannelSet->interChannelOffset )); |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7854 | smsLog(pMac, LOG3, " Setting Channel Number %d", pChannelPowerSet->firstChanNum); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7855 | pChannelPowerSet->numChannels = 1; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7856 | pChannelPowerSet->maxTxPower = CSR_ROAM_MIN( pChannelSet->txPower, pMac->roam.configParam.nTxPowerCap ); |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7857 | smsLog(pMac, LOG3, " Setting Max Transmit Power %d", pChannelPowerSet->maxTxPower); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7858 | cbLen += sizeof( tSirMacChanInfo ); |
| 7859 | pChannelPowerSet++; |
| 7860 | } |
| 7861 | } |
| 7862 | else |
| 7863 | { |
| 7864 | if (cbLen >= dataLen) |
| 7865 | { |
| 7866 | // this entry will overflow our allocation |
| 7867 | smsLog(pMac, LOGE, |
| 7868 | "%s: Buffer overflow, start %d, num %d, offset %d", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7869 | __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7870 | pChannelSet->firstChannel, |
| 7871 | pChannelSet->numChannels, |
| 7872 | pChannelSet->interChannelOffset); |
| 7873 | break; |
| 7874 | } |
| 7875 | pChannelPowerSet->firstChanNum = pChannelSet->firstChannel; |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7876 | smsLog(pMac, LOG3, " Setting Channel Number %d", pChannelPowerSet->firstChanNum); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7877 | pChannelPowerSet->numChannels = pChannelSet->numChannels; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7878 | pChannelPowerSet->maxTxPower = CSR_ROAM_MIN( pChannelSet->txPower, pMac->roam.configParam.nTxPowerCap ); |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7879 | 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] | 7880 | |
| 7881 | |
| 7882 | cbLen += sizeof( tSirMacChanInfo ); |
| 7883 | pChannelPowerSet++; |
| 7884 | } |
| 7885 | |
| 7886 | pEntry = csrLLNext( pList, pEntry, LL_ACCESS_LOCK ); |
| 7887 | } |
| 7888 | |
| 7889 | if(cbLen) |
| 7890 | { |
| 7891 | ccmCfgSetStr(pMac, cfgId, (tANI_U8 *)pBuf, cbLen, NULL, eANI_BOOLEAN_FALSE); |
| 7892 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7893 | vos_mem_free(pBuf); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7894 | }//Allocate memory |
| 7895 | } |
| 7896 | |
| 7897 | |
| 7898 | void csrSetCfgCountryCode( tpAniSirGlobal pMac, tANI_U8 *countryCode ) |
| 7899 | { |
| 7900 | tANI_U8 cc[WNI_CFG_COUNTRY_CODE_LEN]; |
| 7901 | ///v_REGDOMAIN_t DomainId; |
| 7902 | |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 7903 | smsLog( pMac, LOG3, "Setting Country Code in Cfg from csrSetCfgCountryCode %s",countryCode ); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7904 | vos_mem_copy(cc, countryCode, WNI_CFG_COUNTRY_CODE_LEN); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7905 | |
| 7906 | // don't program the bogus country codes that we created for Korea in the MAC. if we see |
| 7907 | // the bogus country codes, program the MAC with the right country code. |
| 7908 | if ( ( 'K' == countryCode[ 0 ] && '1' == countryCode[ 1 ] ) || |
| 7909 | ( 'K' == countryCode[ 0 ] && '2' == countryCode[ 1 ] ) || |
| 7910 | ( 'K' == countryCode[ 0 ] && '3' == countryCode[ 1 ] ) || |
| 7911 | ( 'K' == countryCode[ 0 ] && '4' == countryCode[ 1 ] ) ) |
| 7912 | { |
| 7913 | // replace the alternate Korea country codes, 'K1', 'K2', .. with 'KR' for Korea |
| 7914 | cc[ 1 ] = 'R'; |
| 7915 | } |
| 7916 | ccmCfgSetStr(pMac, WNI_CFG_COUNTRY_CODE, cc, WNI_CFG_COUNTRY_CODE_LEN, NULL, eANI_BOOLEAN_FALSE); |
| 7917 | |
| 7918 | //Need to let HALPHY know about the current domain so it can apply some |
| 7919 | //domain-specific settings (TX filter...) |
| 7920 | /*if(HAL_STATUS_SUCCESS(csrGetRegulatoryDomainForCountry(pMac, cc, &DomainId))) |
| 7921 | { |
| 7922 | halPhySetRegDomain(pMac, DomainId); |
| 7923 | }*/ |
| 7924 | } |
| 7925 | |
| 7926 | |
| 7927 | |
| 7928 | eHalStatus csrGetCountryCode(tpAniSirGlobal pMac, tANI_U8 *pBuf, tANI_U8 *pbLen) |
| 7929 | { |
| 7930 | eHalStatus status = eHAL_STATUS_INVALID_PARAMETER; |
| 7931 | tANI_U32 len; |
| 7932 | |
| 7933 | if(pBuf && pbLen && (*pbLen >= WNI_CFG_COUNTRY_CODE_LEN)) |
| 7934 | { |
| 7935 | len = *pbLen; |
| 7936 | status = ccmCfgGetStr(pMac, WNI_CFG_COUNTRY_CODE, pBuf, &len); |
| 7937 | if(HAL_STATUS_SUCCESS(status)) |
| 7938 | { |
| 7939 | *pbLen = (tANI_U8)len; |
| 7940 | } |
| 7941 | } |
| 7942 | |
| 7943 | return (status); |
| 7944 | } |
| 7945 | |
| 7946 | |
| 7947 | void csrSetCfgScanControlList( tpAniSirGlobal pMac, tANI_U8 *countryCode, tCsrChannel *pChannelList ) |
| 7948 | { |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 7949 | tANI_U8 i, j, k; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7950 | tANI_BOOLEAN found=FALSE; |
| 7951 | tANI_U8 *pControlList = NULL; |
| 7952 | tANI_U32 len = WNI_CFG_SCAN_CONTROL_LIST_LEN; |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 7953 | tANI_U8 cfgActiveDFSChannels = 0; |
| 7954 | tANI_U8 *cfgActiveDFSChannelLIst = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7955 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7956 | if ( (pControlList = vos_mem_malloc(WNI_CFG_SCAN_CONTROL_LIST_LEN)) != NULL ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7957 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 7958 | vos_mem_set((void *)pControlList, WNI_CFG_SCAN_CONTROL_LIST_LEN, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7959 | if(HAL_STATUS_SUCCESS(ccmCfgGetStr(pMac, WNI_CFG_SCAN_CONTROL_LIST, pControlList, &len))) |
| 7960 | { |
| 7961 | for (i = 0; i < pChannelList->numChannels; i++) |
| 7962 | { |
| 7963 | for (j = 0; j < len; j += 2) |
| 7964 | { |
| 7965 | if (pControlList[j] == pChannelList->channelList[i]) |
| 7966 | { |
| 7967 | found = TRUE; |
| 7968 | break; |
| 7969 | } |
| 7970 | } |
| 7971 | |
| 7972 | if (found) // insert a pair(channel#, flag) |
| 7973 | { |
Gopichand Nakkala | 392cbc1 | 2013-05-28 16:15:00 +0530 | [diff] [blame] | 7974 | pControlList[j+1] = csrGetScanType(pMac, pControlList[j]); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7975 | found = FALSE; // reset the flag |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7976 | |
Padma, Santhosh Kumar | 778d838 | 2015-03-04 17:41:22 +0530 | [diff] [blame] | 7977 | // When DFS mode is 2, mark static channels as active |
| 7978 | if (pMac->scan.fEnableDFSChnlScan == |
| 7979 | DFS_CHNL_SCAN_ENABLED_ACTIVE) |
| 7980 | { |
| 7981 | cfgActiveDFSChannels = |
| 7982 | pMac->roam.neighborRoamInfo.cfgParams. |
| 7983 | channelInfo.numOfChannels; |
| 7984 | cfgActiveDFSChannelLIst = |
| 7985 | pMac->roam.neighborRoamInfo.cfgParams. |
| 7986 | channelInfo.ChannelList; |
| 7987 | if (cfgActiveDFSChannelLIst) |
| 7988 | { |
| 7989 | for (k=0; k < cfgActiveDFSChannels; k++) |
| 7990 | { |
| 7991 | if(CSR_IS_CHANNEL_DFS(cfgActiveDFSChannelLIst[k]) |
| 7992 | && (pControlList[j] == |
| 7993 | cfgActiveDFSChannelLIst[k])) |
| 7994 | { |
| 7995 | pControlList[j+1] = eSIR_ACTIVE_SCAN; |
| 7996 | smsLog(pMac, LOG1, FL("Marked DFS ch %d" |
| 7997 | " as active"), |
| 7998 | cfgActiveDFSChannelLIst[k]); |
| 7999 | } |
| 8000 | } |
| 8001 | } |
| 8002 | } |
| 8003 | } |
| 8004 | } |
| 8005 | |
| 8006 | smsLog(pMac, LOG1, FL("fEnableDFSChnlScan %d"), |
| 8007 | pMac->scan.fEnableDFSChnlScan); |
Mihir Shete | 31c435d | 2014-02-12 13:13:34 +0530 | [diff] [blame] | 8008 | VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, |
| 8009 | "%s: dump scan control list",__func__); |
| 8010 | VOS_TRACE_HEX_DUMP(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, |
| 8011 | pControlList, len); |
| 8012 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8013 | ccmCfgSetStr(pMac, WNI_CFG_SCAN_CONTROL_LIST, pControlList, len, NULL, eANI_BOOLEAN_FALSE); |
| 8014 | }//Successfully getting scan control list |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8015 | vos_mem_free(pControlList); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8016 | }//AllocateMemory |
| 8017 | } |
| 8018 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8019 | //if bgPeriod is 0, background scan is disabled. It is in millisecond units |
| 8020 | eHalStatus csrSetCfgBackgroundScanPeriod(tpAniSirGlobal pMac, tANI_U32 bgPeriod) |
| 8021 | { |
| 8022 | return (ccmCfgSetInt(pMac, WNI_CFG_BACKGROUND_SCAN_PERIOD, bgPeriod, (tCcmCfgSetCallback) csrScanCcmCfgSetCallback, eANI_BOOLEAN_FALSE)); |
| 8023 | } |
| 8024 | |
| 8025 | |
| 8026 | void csrScanCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result) |
| 8027 | { |
| 8028 | tListElem *pEntry = NULL; |
| 8029 | tSmeCmd *pCommand = NULL; |
| 8030 | tpAniSirGlobal pMac = PMAC_STRUCT( hHal ); |
Madan Mohan Koyyalamudi | 2125599 | 2013-08-01 18:00:25 +0530 | [diff] [blame] | 8031 | tDblLinkList *pCmdList ; |
| 8032 | |
| 8033 | if (!pMac->fScanOffload) |
| 8034 | pCmdList = &pMac->sme.smeCmdActiveList; |
| 8035 | else |
| 8036 | pCmdList = &pMac->sme.smeScanCmdActiveList; |
| 8037 | |
| 8038 | pEntry = csrLLPeekHead( pCmdList, LL_ACCESS_LOCK ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8039 | if ( pEntry ) |
| 8040 | { |
| 8041 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 8042 | if ( eSmeCommandScan == pCommand->command ) |
| 8043 | { |
| 8044 | eCsrScanStatus scanStatus = (CCM_IS_RESULT_SUCCESS(result)) ? eCSR_SCAN_SUCCESS : eCSR_SCAN_FAILURE; |
| 8045 | csrReleaseScanCommand(pMac, pCommand, scanStatus); |
| 8046 | } |
| 8047 | else |
| 8048 | { |
Kiran Kumar Lokere | 3334fbb | 2013-03-07 12:36:05 -0800 | [diff] [blame] | 8049 | 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] | 8050 | } |
| 8051 | } |
| 8052 | smeProcessPendingQueue( pMac ); |
| 8053 | } |
| 8054 | |
| 8055 | eHalStatus csrProcessSetBGScanParam(tpAniSirGlobal pMac, tSmeCmd *pCommand) |
| 8056 | { |
| 8057 | eHalStatus status; |
| 8058 | tCsrBGScanRequest *pScanReq = &pCommand->u.scanCmd.u.bgScanRequest; |
| 8059 | tANI_U32 dataLen = sizeof( tANI_U8 ) * pScanReq->ChannelInfo.numOfChannels; |
| 8060 | |
| 8061 | //***setcfg for background scan channel list |
| 8062 | status = ccmCfgSetInt(pMac, WNI_CFG_ACTIVE_MINIMUM_CHANNEL_TIME, pScanReq->minChnTime, NULL, eANI_BOOLEAN_FALSE); |
| 8063 | status = ccmCfgSetInt(pMac, WNI_CFG_ACTIVE_MAXIMUM_CHANNEL_TIME, pScanReq->maxChnTime, NULL, eANI_BOOLEAN_FALSE); |
| 8064 | //Not set the background scan interval if not connected because bd scan should not be run if not connected |
| 8065 | if(!csrIsAllSessionDisconnected(pMac)) |
| 8066 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8067 | |
| 8068 | #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 8069 | { |
| 8070 | vos_log_scan_pkt_type *pScanLog = NULL; |
| 8071 | |
| 8072 | WLAN_VOS_DIAG_LOG_ALLOC(pScanLog, vos_log_scan_pkt_type, LOG_WLAN_SCAN_C); |
| 8073 | if(pScanLog) |
| 8074 | { |
| 8075 | pScanLog->eventId = WLAN_SCAN_EVENT_HO_SCAN_REQ; |
| 8076 | pScanLog->minChnTime = (v_U8_t)pScanReq->minChnTime; |
| 8077 | pScanLog->maxChnTime = (v_U8_t)pScanReq->maxChnTime; |
| 8078 | pScanLog->timeBetweenBgScan = (v_U8_t)pScanReq->scanInterval; |
| 8079 | pScanLog->numChannel = pScanReq->ChannelInfo.numOfChannels; |
| 8080 | if(pScanLog->numChannel && (pScanLog->numChannel < VOS_LOG_MAX_NUM_CHANNEL)) |
| 8081 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8082 | vos_mem_copy(pScanLog->channels, |
| 8083 | pScanReq->ChannelInfo.ChannelList, |
| 8084 | pScanLog->numChannel); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8085 | } |
| 8086 | WLAN_VOS_DIAG_LOG_REPORT(pScanLog); |
| 8087 | } |
| 8088 | } |
| 8089 | #endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR |
| 8090 | |
| 8091 | status = ccmCfgSetInt(pMac, WNI_CFG_BACKGROUND_SCAN_PERIOD, pScanReq->scanInterval, NULL, eANI_BOOLEAN_FALSE); |
| 8092 | } |
| 8093 | else |
| 8094 | { |
| 8095 | //No need to stop aging because IDLE scan is still running |
| 8096 | status = ccmCfgSetInt(pMac, WNI_CFG_BACKGROUND_SCAN_PERIOD, 0, NULL, eANI_BOOLEAN_FALSE); |
| 8097 | } |
| 8098 | |
| 8099 | if(pScanReq->SSID.length > WNI_CFG_SSID_LEN) |
| 8100 | { |
| 8101 | pScanReq->SSID.length = WNI_CFG_SSID_LEN; |
| 8102 | } |
| 8103 | |
| 8104 | status = ccmCfgSetStr(pMac, WNI_CFG_BG_SCAN_CHANNEL_LIST, pScanReq->ChannelInfo.ChannelList, dataLen, NULL, eANI_BOOLEAN_FALSE); |
| 8105 | status = ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pScanReq->SSID.ssId, pScanReq->SSID.length, NULL, eANI_BOOLEAN_FALSE); |
| 8106 | |
| 8107 | |
| 8108 | |
| 8109 | return (status); |
| 8110 | } |
| 8111 | |
| 8112 | |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 8113 | tSirAbortScanStatus csrScanAbortMacScan(tpAniSirGlobal pMac, |
| 8114 | tANI_U8 sessionId, |
| 8115 | eCsrAbortReason reason) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8116 | { |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 8117 | tSirAbortScanStatus abortScanStatus = eSIR_ABORT_ACTIVE_SCAN_LIST_EMPTY; |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 8118 | tSirSmeScanAbortReq *pMsg; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8119 | tANI_U16 msgLen; |
| 8120 | tListElem *pEntry; |
| 8121 | tSmeCmd *pCommand; |
| 8122 | |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 8123 | if (!pMac->fScanOffload) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8124 | { |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 8125 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 8126 | csrLLLock(&pMac->scan.scanCmdPendingList); |
| 8127 | while(NULL != |
| 8128 | (pEntry = csrLLRemoveHead(&pMac->scan.scanCmdPendingList, |
| 8129 | LL_ACCESS_NOLOCK))) |
| 8130 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8131 | |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 8132 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 8133 | csrAbortCommand( pMac, pCommand, eANI_BOOLEAN_FALSE); |
| 8134 | } |
| 8135 | csrLLUnlock(&pMac->scan.scanCmdPendingList); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8136 | #endif |
| 8137 | |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 8138 | pMac->scan.fDropScanCmd = eANI_BOOLEAN_TRUE; |
| 8139 | csrRemoveCmdFromPendingList( pMac, &pMac->roam.roamCmdPendingList, eSmeCommandScan); |
| 8140 | csrRemoveCmdFromPendingList( pMac, &pMac->sme.smeCmdPendingList, eSmeCommandScan); |
| 8141 | pMac->scan.fDropScanCmd = eANI_BOOLEAN_FALSE; |
| 8142 | |
| 8143 | pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK); |
| 8144 | } |
| 8145 | else |
| 8146 | { |
| 8147 | pMac->scan.fDropScanCmd = eANI_BOOLEAN_TRUE; |
| 8148 | csrRemoveCmdWithSessionIdFromPendingList(pMac, |
| 8149 | sessionId, |
| 8150 | &pMac->sme.smeScanCmdPendingList, |
| 8151 | eSmeCommandScan); |
| 8152 | pMac->scan.fDropScanCmd = eANI_BOOLEAN_FALSE; |
| 8153 | |
| 8154 | pEntry = csrLLPeekHead(&pMac->sme.smeScanCmdActiveList, LL_ACCESS_LOCK); |
| 8155 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8156 | |
| 8157 | //We need to abort scan only if we are scanning |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 8158 | if(NULL != pEntry) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8159 | { |
| 8160 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 8161 | if(eSmeCommandScan == pCommand->command && |
| 8162 | pCommand->sessionId == sessionId) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8163 | { |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 8164 | msgLen = (tANI_U16)(sizeof(tSirSmeScanAbortReq)); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8165 | pMsg = vos_mem_malloc(msgLen); |
| 8166 | if ( NULL == pMsg ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8167 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8168 | smsLog(pMac, LOGE, FL("Failed to allocate memory for SmeScanAbortReq")); |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 8169 | abortScanStatus = eSIR_ABORT_SCAN_FAILURE; |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8170 | } |
| 8171 | else |
| 8172 | { |
Ratheesh S P | ece1f83 | 2015-07-25 15:50:25 +0530 | [diff] [blame] | 8173 | pCommand->u.scanCmd.abortScanIndication = eCSR_SCAN_ABORT_DEFAULT; |
Srinivas, Dasari | 187ca4e | 2014-02-07 12:40:09 +0530 | [diff] [blame] | 8174 | if(reason == eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE) |
| 8175 | { |
Ratheesh S P | ece1f83 | 2015-07-25 15:50:25 +0530 | [diff] [blame] | 8176 | pCommand->u.scanCmd.abortScanIndication |
| 8177 | = eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE; |
Srinivas, Dasari | 187ca4e | 2014-02-07 12:40:09 +0530 | [diff] [blame] | 8178 | } |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8179 | vos_mem_set((void *)pMsg, msgLen, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8180 | pMsg->type = pal_cpu_to_be16((tANI_U16)eWNI_SME_SCAN_ABORT_IND); |
| 8181 | pMsg->msgLen = pal_cpu_to_be16(msgLen); |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 8182 | pMsg->sessionId = sessionId; |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 8183 | if (eHAL_STATUS_SUCCESS != palSendMBMessage(pMac->hHdd, pMsg)) |
| 8184 | { |
| 8185 | smsLog(pMac, LOGE, |
| 8186 | FL("Failed to post eWNI_SME_SCAN_ABORT_IND")); |
| 8187 | abortScanStatus = eSIR_ABORT_SCAN_FAILURE; |
Ratheesh S P | ece1f83 | 2015-07-25 15:50:25 +0530 | [diff] [blame] | 8188 | pCommand->u.scanCmd.abortScanIndication = 0; |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 8189 | } |
| 8190 | else |
| 8191 | { |
| 8192 | abortScanStatus = eSIR_ABORT_ACTIVE_SCAN_LIST_NOT_EMPTY; |
| 8193 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8194 | } |
| 8195 | } |
| 8196 | } |
| 8197 | |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 8198 | return(abortScanStatus); |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 8199 | } |
| 8200 | |
| 8201 | void csrRemoveCmdWithSessionIdFromPendingList(tpAniSirGlobal pMac, |
| 8202 | tANI_U8 sessionId, |
| 8203 | tDblLinkList *pList, |
| 8204 | eSmeCommandType commandType) |
| 8205 | { |
| 8206 | tDblLinkList localList; |
| 8207 | tListElem *pEntry; |
| 8208 | tSmeCmd *pCommand; |
| 8209 | tListElem *pEntryToRemove; |
| 8210 | |
| 8211 | vos_mem_zero(&localList, sizeof(tDblLinkList)); |
| 8212 | if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList))) |
| 8213 | { |
| 8214 | smsLog(pMac, LOGE, FL(" failed to open list")); |
| 8215 | return; |
| 8216 | } |
| 8217 | |
| 8218 | csrLLLock(pList); |
| 8219 | if ((pEntry = csrLLPeekHead( pList, LL_ACCESS_NOLOCK))) |
| 8220 | { |
| 8221 | |
| 8222 | /* Have to make sure we don't loop back to the head of the list, |
| 8223 | * which will happen if the entry is NOT on the list */ |
| 8224 | while (pEntry) |
| 8225 | { |
| 8226 | pEntryToRemove = pEntry; |
| 8227 | pEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK); |
| 8228 | pCommand = GET_BASE_ADDR( pEntryToRemove, tSmeCmd, Link ); |
| 8229 | if ((pCommand->command == commandType) && |
| 8230 | (pCommand->sessionId == sessionId)) |
| 8231 | { |
| 8232 | /* Remove that entry only */ |
| 8233 | if (csrLLRemoveEntry( pList, pEntryToRemove, LL_ACCESS_NOLOCK)) |
| 8234 | { |
| 8235 | csrLLInsertTail(&localList, pEntryToRemove, |
| 8236 | LL_ACCESS_NOLOCK); |
| 8237 | } |
| 8238 | } |
| 8239 | } |
| 8240 | } |
| 8241 | csrLLUnlock(pList); |
| 8242 | |
| 8243 | while ((pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK))) |
| 8244 | { |
| 8245 | pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link); |
| 8246 | csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_FALSE); |
| 8247 | } |
| 8248 | |
| 8249 | csrLLClose(&localList); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8250 | } |
| 8251 | |
| 8252 | void csrRemoveCmdFromPendingList(tpAniSirGlobal pMac, tDblLinkList *pList, |
| 8253 | eSmeCommandType commandType ) |
| 8254 | { |
| 8255 | tDblLinkList localList; |
| 8256 | tListElem *pEntry; |
| 8257 | tSmeCmd *pCommand; |
| 8258 | tListElem *pEntryToRemove; |
| 8259 | |
| 8260 | vos_mem_zero(&localList, sizeof(tDblLinkList)); |
| 8261 | if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList))) |
| 8262 | { |
| 8263 | smsLog(pMac, LOGE, FL(" failed to open list")); |
| 8264 | return; |
| 8265 | } |
| 8266 | |
| 8267 | csrLLLock(pList); |
| 8268 | if( !csrLLIsListEmpty( pList, LL_ACCESS_NOLOCK ) ) |
| 8269 | { |
| 8270 | pEntry = csrLLPeekHead( pList, LL_ACCESS_NOLOCK); |
| 8271 | |
| 8272 | // Have to make sure we don't loop back to the head of the list, which will |
| 8273 | // happen if the entry is NOT on the list... |
| 8274 | while( pEntry ) |
| 8275 | { |
| 8276 | pEntryToRemove = pEntry; |
| 8277 | pEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK); |
| 8278 | pCommand = GET_BASE_ADDR( pEntryToRemove, tSmeCmd, Link ); |
| 8279 | if ( pCommand->command == commandType ) |
| 8280 | { |
| 8281 | // Remove that entry only |
| 8282 | if(csrLLRemoveEntry( pList, pEntryToRemove, LL_ACCESS_NOLOCK)) |
| 8283 | { |
| 8284 | csrLLInsertTail(&localList, pEntryToRemove, LL_ACCESS_NOLOCK); |
| 8285 | } |
| 8286 | } |
| 8287 | } |
| 8288 | |
| 8289 | |
| 8290 | } |
| 8291 | csrLLUnlock(pList); |
| 8292 | |
| 8293 | while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) ) |
| 8294 | { |
| 8295 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 8296 | csrAbortCommand( pMac, pCommand, eANI_BOOLEAN_FALSE); |
| 8297 | } |
| 8298 | csrLLClose(&localList); |
| 8299 | |
| 8300 | } |
| 8301 | |
Abhishek Singh | dc2bfd4 | 2014-06-19 17:59:05 +0530 | [diff] [blame] | 8302 | eHalStatus csrScanAbortScanForSSID(tpAniSirGlobal pMac, tANI_U32 sessionId) |
| 8303 | { |
| 8304 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 8305 | tSirSmeScanAbortReq *pMsg; |
| 8306 | tANI_U16 msgLen; |
| 8307 | tListElem *pEntry; |
| 8308 | tSmeCmd *pCommand; |
| 8309 | |
| 8310 | if (!pMac->fScanOffload) |
| 8311 | { |
| 8312 | pMac->scan.fDropScanCmd = eANI_BOOLEAN_TRUE; |
| 8313 | #ifdef WLAN_AP_STA_CONCURRENCY |
| 8314 | csrRemoveScanForSSIDFromPendingList( pMac, &pMac->scan.scanCmdPendingList, sessionId); |
| 8315 | #endif |
| 8316 | csrRemoveScanForSSIDFromPendingList( pMac, &pMac->roam.roamCmdPendingList, sessionId); |
| 8317 | csrRemoveScanForSSIDFromPendingList( pMac, &pMac->sme.smeCmdPendingList, sessionId); |
| 8318 | pMac->scan.fDropScanCmd = eANI_BOOLEAN_FALSE; |
| 8319 | pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK); |
| 8320 | } |
| 8321 | else |
| 8322 | { |
| 8323 | pMac->scan.fDropScanCmd = eANI_BOOLEAN_TRUE; |
| 8324 | csrRemoveScanForSSIDFromPendingList( pMac, &pMac->sme.smeScanCmdPendingList, sessionId); |
| 8325 | pMac->scan.fDropScanCmd = eANI_BOOLEAN_FALSE; |
| 8326 | pEntry = csrLLPeekHead(&pMac->sme.smeScanCmdActiveList, LL_ACCESS_LOCK); |
| 8327 | } |
| 8328 | |
| 8329 | if(NULL != pEntry) |
| 8330 | { |
| 8331 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 8332 | |
| 8333 | if ( (eSmeCommandScan == pCommand->command ) && |
| 8334 | (sessionId == pCommand->sessionId)) |
| 8335 | { |
| 8336 | if ( eCsrScanForSsid == pCommand->u.scanCmd.reason) |
| 8337 | { |
| 8338 | msgLen = (tANI_U16)(sizeof( tSirSmeScanAbortReq )); |
| 8339 | pMsg = vos_mem_malloc(msgLen); |
| 8340 | if ( NULL == pMsg ) |
| 8341 | { |
| 8342 | status = eHAL_STATUS_FAILURE; |
| 8343 | smsLog(pMac, LOGE, FL("Failed to allocate memory for SmeScanAbortReq")); |
| 8344 | } |
| 8345 | else |
| 8346 | { |
| 8347 | vos_mem_zero((void *)pMsg, msgLen); |
| 8348 | pMsg->type = pal_cpu_to_be16((tANI_U16)eWNI_SME_SCAN_ABORT_IND); |
| 8349 | pMsg->msgLen = pal_cpu_to_be16(msgLen); |
| 8350 | pMsg->sessionId = sessionId; |
| 8351 | status = palSendMBMessage(pMac->hHdd, pMsg); |
| 8352 | } |
| 8353 | } |
| 8354 | } |
| 8355 | } |
| 8356 | return( status ); |
| 8357 | } |
| 8358 | |
| 8359 | void csrRemoveScanForSSIDFromPendingList(tpAniSirGlobal pMac, tDblLinkList *pList, tANI_U32 sessionId) |
| 8360 | { |
| 8361 | tDblLinkList localList; |
| 8362 | tListElem *pEntry; |
| 8363 | tSmeCmd *pCommand; |
| 8364 | tListElem *pEntryToRemove; |
| 8365 | |
| 8366 | vos_mem_zero(&localList, sizeof(tDblLinkList)); |
| 8367 | if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList))) |
| 8368 | { |
| 8369 | smsLog(pMac, LOGE, FL(" failed to open list")); |
| 8370 | return; |
| 8371 | } |
| 8372 | |
| 8373 | csrLLLock(pList); |
| 8374 | if( !csrLLIsListEmpty( pList, LL_ACCESS_NOLOCK ) ) |
| 8375 | { |
| 8376 | pEntry = csrLLPeekHead( pList, LL_ACCESS_NOLOCK); |
| 8377 | |
| 8378 | // Have to make sure we don't loop back to the head of the list, which will |
| 8379 | // happen if the entry is NOT on the list... |
| 8380 | while( pEntry ) |
| 8381 | { |
| 8382 | pEntryToRemove = pEntry; |
| 8383 | pEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK); |
| 8384 | pCommand = GET_BASE_ADDR( pEntryToRemove, tSmeCmd, Link ); |
| 8385 | if ( (eSmeCommandScan == pCommand->command ) && |
| 8386 | (sessionId == pCommand->sessionId) ) |
| 8387 | { |
| 8388 | if ( eCsrScanForSsid == pCommand->u.scanCmd.reason) |
| 8389 | { |
| 8390 | // Remove that entry only |
| 8391 | if ( csrLLRemoveEntry( pList, pEntryToRemove, LL_ACCESS_NOLOCK)) |
| 8392 | { |
| 8393 | csrLLInsertTail(&localList, pEntryToRemove, LL_ACCESS_NOLOCK); |
| 8394 | } |
| 8395 | } |
| 8396 | } |
| 8397 | } |
| 8398 | } |
| 8399 | csrLLUnlock(pList); |
| 8400 | |
| 8401 | while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) ) |
| 8402 | { |
| 8403 | pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link ); |
| 8404 | csrAbortCommand( pMac, pCommand, eANI_BOOLEAN_FALSE); |
| 8405 | } |
| 8406 | csrLLClose(&localList); |
| 8407 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8408 | |
Madan Mohan Koyyalamudi | ff3a715 | 2013-06-13 14:47:55 +0530 | [diff] [blame] | 8409 | eHalStatus csrScanAbortMacScanNotForConnect(tpAniSirGlobal pMac, |
| 8410 | tANI_U8 sessionId) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8411 | { |
| 8412 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 8413 | |
| 8414 | if( !csrIsScanForRoamCommandActive( pMac ) ) |
| 8415 | { |
| 8416 | //Only abort the scan if it is not used for other roam/connect purpose |
c_hpothu | a3d45d5 | 2015-01-05 14:11:17 +0530 | [diff] [blame] | 8417 | if (eSIR_ABORT_SCAN_FAILURE == |
| 8418 | csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT)) |
| 8419 | { |
| 8420 | smsLog(pMac, LOGE, FL("fail to abort scan")); |
| 8421 | status = eHAL_STATUS_FAILURE; |
| 8422 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8423 | } |
| 8424 | |
| 8425 | return (status); |
| 8426 | } |
| 8427 | |
| 8428 | |
Madan Mohan Koyyalamudi | de1b5bc | 2013-07-12 00:56:04 +0530 | [diff] [blame] | 8429 | eHalStatus csrScanGetScanChannelInfo(tpAniSirGlobal pMac, tANI_U8 sessionId) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8430 | { |
| 8431 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 8432 | tSirMbMsg *pMsg; |
| 8433 | tANI_U16 msgLen; |
| 8434 | |
Madan Mohan Koyyalamudi | de1b5bc | 2013-07-12 00:56:04 +0530 | [diff] [blame] | 8435 | if (pMac->fScanOffload) |
| 8436 | msgLen = (tANI_U16)(sizeof(tSirSmeGetScanChanReq)); |
| 8437 | else |
| 8438 | msgLen = (tANI_U16)(sizeof(tSirMbMsg)); |
| 8439 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8440 | pMsg = vos_mem_malloc(msgLen); |
| 8441 | if ( NULL == pMsg ) |
| 8442 | status = eHAL_STATUS_FAILURE; |
| 8443 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8444 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8445 | vos_mem_set(pMsg, msgLen, 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8446 | pMsg->type = eWNI_SME_GET_SCANNED_CHANNEL_REQ; |
| 8447 | pMsg->msgLen = msgLen; |
Madan Mohan Koyyalamudi | de1b5bc | 2013-07-12 00:56:04 +0530 | [diff] [blame] | 8448 | if (pMac->fScanOffload) |
| 8449 | ((tSirSmeGetScanChanReq *)pMsg)->sessionId = sessionId; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8450 | status = palSendMBMessage(pMac->hHdd, pMsg); |
| 8451 | } |
| 8452 | |
| 8453 | return( status ); |
| 8454 | } |
| 8455 | |
| 8456 | tANI_BOOLEAN csrRoamIsValidChannel( tpAniSirGlobal pMac, tANI_U8 channel ) |
| 8457 | { |
| 8458 | tANI_BOOLEAN fValid = FALSE; |
| 8459 | tANI_U32 idxValidChannels; |
| 8460 | tANI_U32 len = pMac->roam.numValidChannels; |
| 8461 | |
| 8462 | for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ ) |
| 8463 | { |
| 8464 | if ( channel == pMac->roam.validChannelList[ idxValidChannels ] ) |
| 8465 | { |
| 8466 | fValid = TRUE; |
| 8467 | break; |
| 8468 | } |
| 8469 | } |
| 8470 | |
| 8471 | return fValid; |
| 8472 | } |
| 8473 | |
Manjunathappa Prakash | 4f1d5a5 | 2013-11-11 16:22:19 -0800 | [diff] [blame] | 8474 | #ifdef FEATURE_WLAN_SCAN_PNO |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 8475 | eHalStatus csrScanSavePreferredNetworkFound(tpAniSirGlobal pMac, |
| 8476 | tSirPrefNetworkFoundInd *pPrefNetworkFoundInd) |
| 8477 | { |
| 8478 | v_U32_t uLen = 0; |
| 8479 | tpSirProbeRespBeacon pParsedFrame; |
| 8480 | tCsrScanResult *pScanResult = NULL; |
| 8481 | tSirBssDescription *pBssDescr = NULL; |
| 8482 | tANI_BOOLEAN fDupBss; |
| 8483 | tDot11fBeaconIEs *pIesLocal = NULL; |
| 8484 | tAniSSID tmpSsid; |
| 8485 | v_TIME_t timer=0; |
| 8486 | tpSirMacMgmtHdr macHeader = (tpSirMacMgmtHdr)pPrefNetworkFoundInd->data; |
Abhishek Singh | d3d4e02 | 2014-11-11 13:02:40 +0530 | [diff] [blame] | 8487 | boolean bFoundonAppliedChannel = FALSE; |
| 8488 | v_U32_t indx; |
| 8489 | u8 channelsAllowed[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 8490 | v_U32_t numChannelsAllowed = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
Sushant Kaushik | 6274de6 | 2015-05-01 16:31:23 +0530 | [diff] [blame] | 8491 | tListElem *pEntry; |
Abhishek Singh | d3d4e02 | 2014-11-11 13:02:40 +0530 | [diff] [blame] | 8492 | |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 8493 | |
| 8494 | pParsedFrame = |
Abhishek Singh | c75726d | 2015-04-13 14:44:14 +0530 | [diff] [blame] | 8495 | (tpSirProbeRespBeacon)vos_mem_vmalloc(sizeof(tSirProbeRespBeacon)); |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 8496 | |
| 8497 | if (NULL == pParsedFrame) |
| 8498 | { |
| 8499 | smsLog(pMac, LOGE, FL(" fail to allocate memory for frame")); |
| 8500 | return eHAL_STATUS_RESOURCES; |
| 8501 | } |
| 8502 | |
| 8503 | if ( pPrefNetworkFoundInd->frameLength <= SIR_MAC_HDR_LEN_3A ) |
| 8504 | { |
| 8505 | smsLog(pMac, LOGE, |
| 8506 | FL("Not enough bytes in PNO indication probe resp frame! length=%d"), |
| 8507 | pPrefNetworkFoundInd->frameLength); |
Abhishek Singh | c75726d | 2015-04-13 14:44:14 +0530 | [diff] [blame] | 8508 | vos_mem_vfree(pParsedFrame); |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 8509 | return eHAL_STATUS_FAILURE; |
| 8510 | } |
| 8511 | |
| 8512 | if (sirConvertProbeFrame2Struct(pMac, |
| 8513 | &pPrefNetworkFoundInd->data[SIR_MAC_HDR_LEN_3A], |
| 8514 | pPrefNetworkFoundInd->frameLength - SIR_MAC_HDR_LEN_3A, |
| 8515 | pParsedFrame) != eSIR_SUCCESS || |
| 8516 | !pParsedFrame->ssidPresent) |
| 8517 | { |
| 8518 | smsLog(pMac, LOGE, |
| 8519 | FL("Parse error ProbeResponse, length=%d"), |
| 8520 | pPrefNetworkFoundInd->frameLength); |
Abhishek Singh | c75726d | 2015-04-13 14:44:14 +0530 | [diff] [blame] | 8521 | vos_mem_vfree(pParsedFrame); |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 8522 | return eHAL_STATUS_FAILURE; |
| 8523 | } |
| 8524 | //24 byte MAC header and 12 byte to ssid IE |
| 8525 | if (pPrefNetworkFoundInd->frameLength > |
| 8526 | (SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_SSID_OFFSET)) |
| 8527 | { |
| 8528 | uLen = pPrefNetworkFoundInd->frameLength - |
| 8529 | (SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_SSID_OFFSET); |
| 8530 | } |
| 8531 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8532 | pScanResult = vos_mem_malloc(sizeof(tCsrScanResult) + uLen); |
| 8533 | if ( NULL == pScanResult ) |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 8534 | { |
| 8535 | smsLog(pMac, LOGE, FL(" fail to allocate memory for frame")); |
| 8536 | vos_mem_free(pParsedFrame); |
| 8537 | return eHAL_STATUS_RESOURCES; |
| 8538 | } |
| 8539 | |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8540 | vos_mem_set(pScanResult, sizeof(tCsrScanResult) + uLen, 0); |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 8541 | pBssDescr = &pScanResult->Result.BssDescriptor; |
| 8542 | /** |
| 8543 | * Length of BSS desription is without length of |
| 8544 | * length itself and length of pointer |
| 8545 | * that holds the next BSS description |
| 8546 | */ |
| 8547 | pBssDescr->length = (tANI_U16)( |
| 8548 | sizeof(tSirBssDescription) - sizeof(tANI_U16) - |
| 8549 | sizeof(tANI_U32) + uLen); |
| 8550 | if (pParsedFrame->dsParamsPresent) |
| 8551 | { |
| 8552 | pBssDescr->channelId = pParsedFrame->channelNumber; |
| 8553 | } |
| 8554 | else if (pParsedFrame->HTInfo.present) |
| 8555 | { |
| 8556 | pBssDescr->channelId = pParsedFrame->HTInfo.primaryChannel; |
| 8557 | } |
| 8558 | else |
| 8559 | { |
Mahesh A Saptasagar | add9979 | 2014-03-26 16:04:20 +0530 | [diff] [blame] | 8560 | /** |
| 8561 | * If Probe Responce received in PNO indication does not |
| 8562 | * contain DSParam IE or HT Info IE then add dummy channel |
| 8563 | * to the received BSS info so that Scan result received as |
| 8564 | * a part of PNO is updated to the supplicant. Specially |
| 8565 | * applicable in case of AP configured in 11A only mode. |
| 8566 | */ |
| 8567 | if ((pMac->roam.configParam.bandCapability == eCSR_BAND_ALL) || |
| 8568 | (pMac->roam.configParam.bandCapability == eCSR_BAND_24)) |
| 8569 | { |
| 8570 | pBssDescr->channelId = 1; |
| 8571 | } |
| 8572 | else if(pMac->roam.configParam.bandCapability == eCSR_BAND_5G) |
| 8573 | { |
| 8574 | pBssDescr->channelId = 36; |
| 8575 | } |
Abhishek Singh | d3d4e02 | 2014-11-11 13:02:40 +0530 | [diff] [blame] | 8576 | /* Restrict the logic to ignore the pno indication for invalid channel |
| 8577 | * only if valid channel info is present in beacon/probe resp. |
| 8578 | * If no channel info is present in beacon/probe resp, always process |
| 8579 | * the pno indication. |
| 8580 | */ |
| 8581 | bFoundonAppliedChannel = TRUE; |
| 8582 | } |
| 8583 | |
| 8584 | if (0 != sme_GetCfgValidChannels(pMac, channelsAllowed, &numChannelsAllowed)) |
| 8585 | { |
| 8586 | smsLog(pMac, LOGE, FL(" sme_GetCfgValidChannels failed ")); |
| 8587 | csrFreeScanResultEntry(pMac, pScanResult); |
Abhishek Singh | c75726d | 2015-04-13 14:44:14 +0530 | [diff] [blame] | 8588 | vos_mem_vfree(pParsedFrame); |
Abhishek Singh | d3d4e02 | 2014-11-11 13:02:40 +0530 | [diff] [blame] | 8589 | return eHAL_STATUS_FAILURE; |
| 8590 | } |
| 8591 | /* Checking chhanelId with allowed channel list */ |
| 8592 | for (indx = 0; indx < numChannelsAllowed; indx++) |
| 8593 | { |
| 8594 | if (pBssDescr->channelId == channelsAllowed[indx]) |
| 8595 | { |
| 8596 | bFoundonAppliedChannel = TRUE; |
| 8597 | smsLog(pMac, LOG1, FL(" pno ind found on applied channel =%d\n "), |
| 8598 | pBssDescr->channelId); |
| 8599 | break; |
| 8600 | } |
| 8601 | } |
| 8602 | /* Ignore PNO indication if AP is on Invalid channel. |
| 8603 | */ |
| 8604 | if(FALSE == bFoundonAppliedChannel) |
| 8605 | { |
| 8606 | smsLog(pMac, LOGW, FL(" prefered network found on invalid channel = %d"), |
| 8607 | pBssDescr->channelId); |
| 8608 | csrFreeScanResultEntry(pMac, pScanResult); |
Abhishek Singh | c75726d | 2015-04-13 14:44:14 +0530 | [diff] [blame] | 8609 | vos_mem_vfree(pParsedFrame); |
Abhishek Singh | d3d4e02 | 2014-11-11 13:02:40 +0530 | [diff] [blame] | 8610 | return eHAL_STATUS_FAILURE; |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 8611 | } |
| 8612 | |
| 8613 | if ((pBssDescr->channelId > 0) && (pBssDescr->channelId < 15)) |
| 8614 | { |
| 8615 | int i; |
| 8616 | // 11b or 11g packet |
| 8617 | // 11g iff extended Rate IE is present or |
| 8618 | // if there is an A rate in suppRate IE |
| 8619 | for (i = 0; i < pParsedFrame->supportedRates.numRates; i++) |
| 8620 | { |
| 8621 | if (sirIsArate(pParsedFrame->supportedRates.rate[i] & 0x7f)) |
| 8622 | { |
| 8623 | pBssDescr->nwType = eSIR_11G_NW_TYPE; |
| 8624 | break; |
| 8625 | } |
| 8626 | } |
| 8627 | if (pParsedFrame->extendedRatesPresent) |
| 8628 | { |
| 8629 | pBssDescr->nwType = eSIR_11G_NW_TYPE; |
| 8630 | } |
| 8631 | } |
| 8632 | else |
| 8633 | { |
| 8634 | // 11a packet |
| 8635 | pBssDescr->nwType = eSIR_11A_NW_TYPE; |
| 8636 | } |
| 8637 | |
| 8638 | pBssDescr->sinr = 0; |
| 8639 | pBssDescr->rssi = -1 * pPrefNetworkFoundInd->rssi; |
| 8640 | pBssDescr->beaconInterval = pParsedFrame->beaconInterval; |
AnjaneeDevi Kapparapu | 4b04391 | 2014-02-18 13:22:35 +0530 | [diff] [blame] | 8641 | if (!pBssDescr->beaconInterval) |
| 8642 | { |
| 8643 | smsLog(pMac, LOGW, |
| 8644 | FL("Bcn Interval is Zero , default to 100" MAC_ADDRESS_STR), |
| 8645 | MAC_ADDR_ARRAY(pBssDescr->bssId) ); |
| 8646 | pBssDescr->beaconInterval = 100; |
| 8647 | } |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 8648 | pBssDescr->timeStamp[0] = pParsedFrame->timeStamp[0]; |
| 8649 | pBssDescr->timeStamp[1] = pParsedFrame->timeStamp[1]; |
| 8650 | pBssDescr->capabilityInfo = *((tANI_U16 *)&pParsedFrame->capabilityInfo); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8651 | vos_mem_copy((tANI_U8 *) &pBssDescr->bssId, (tANI_U8 *) macHeader->bssId, sizeof(tSirMacAddr)); |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 8652 | pBssDescr->nReceivedTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd); |
| 8653 | |
Abhishek Singh | 195c03e | 2014-05-14 17:21:30 +0530 | [diff] [blame] | 8654 | smsLog( pMac, LOG1, FL("Bssid= "MAC_ADDRESS_STR |
| 8655 | " chan= %d, rssi = %d "), |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 8656 | MAC_ADDR_ARRAY(pBssDescr->bssId), |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 8657 | pBssDescr->channelId, |
Abhishek Singh | 195c03e | 2014-05-14 17:21:30 +0530 | [diff] [blame] | 8658 | pBssDescr->rssi); |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 8659 | |
| 8660 | //IEs |
| 8661 | if (uLen) |
| 8662 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8663 | vos_mem_copy(&pBssDescr->ieFields, |
| 8664 | pPrefNetworkFoundInd->data + (SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_SSID_OFFSET), |
| 8665 | uLen); |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 8666 | } |
| 8667 | |
| 8668 | pIesLocal = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ); |
| 8669 | if ( !pIesLocal && |
| 8670 | (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, |
| 8671 | &pScanResult->Result.BssDescriptor, &pIesLocal))) ) |
| 8672 | { |
| 8673 | smsLog(pMac, LOGE, FL(" Cannot parse IEs")); |
| 8674 | csrFreeScanResultEntry(pMac, pScanResult); |
Abhishek Singh | c75726d | 2015-04-13 14:44:14 +0530 | [diff] [blame] | 8675 | vos_mem_vfree(pParsedFrame); |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 8676 | return eHAL_STATUS_RESOURCES; |
| 8677 | } |
| 8678 | |
| 8679 | fDupBss = csrRemoveDupBssDescription( pMac, |
Madan Mohan Koyyalamudi | a48c681 | 2013-07-11 12:01:37 +0530 | [diff] [blame] | 8680 | &pScanResult->Result.BssDescriptor, pIesLocal, &tmpSsid, &timer, FALSE); |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 8681 | //Check whether we have reach out limit |
| 8682 | if ( CSR_SCAN_IS_OVER_BSS_LIMIT(pMac) ) |
| 8683 | { |
| 8684 | //Limit reach |
| 8685 | smsLog(pMac, LOGE, FL(" BSS limit reached")); |
| 8686 | //Free the resources |
| 8687 | if( (pScanResult->Result.pvIes == NULL) && pIesLocal ) |
| 8688 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8689 | vos_mem_free(pIesLocal); |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 8690 | } |
| 8691 | csrFreeScanResultEntry(pMac, pScanResult); |
| 8692 | vos_mem_free(pParsedFrame); |
| 8693 | return eHAL_STATUS_RESOURCES; |
| 8694 | } |
Nalla Kartheek | 7194642 | 2015-09-15 14:41:22 +0530 | [diff] [blame] | 8695 | |
| 8696 | if ((macHeader->fc.type == SIR_MAC_MGMT_FRAME) && |
| 8697 | (macHeader->fc.subType == SIR_MAC_MGMT_PROBE_RSP)) |
| 8698 | { |
| 8699 | pScanResult->Result.BssDescriptor.fProbeRsp = 1; |
| 8700 | } |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 8701 | //Add to scan cache |
| 8702 | csrScanAddResult(pMac, pScanResult, pIesLocal); |
Sushant Kaushik | 6274de6 | 2015-05-01 16:31:23 +0530 | [diff] [blame] | 8703 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_LOCK ); |
| 8704 | if (pEntry && 0 != pMac->scan.scanResultCfgAgingTime) |
| 8705 | csrScanStartResultCfgAgingTimer(pMac); |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 8706 | |
Kiet Lam | b537cfb | 2013-11-07 12:56:49 +0530 | [diff] [blame] | 8707 | if( (pScanResult->Result.pvIes == NULL) && pIesLocal ) |
| 8708 | { |
| 8709 | vos_mem_free(pIesLocal); |
| 8710 | } |
| 8711 | |
Abhishek Singh | c75726d | 2015-04-13 14:44:14 +0530 | [diff] [blame] | 8712 | vos_mem_vfree(pParsedFrame); |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 8713 | |
| 8714 | return eHAL_STATUS_SUCCESS; |
| 8715 | } |
Manjunathappa Prakash | 4f1d5a5 | 2013-11-11 16:22:19 -0800 | [diff] [blame] | 8716 | #endif //FEATURE_WLAN_SCAN_PNO |
Srikant Kuppa | 066904f | 2013-05-07 13:56:02 -0700 | [diff] [blame] | 8717 | |
Madan Mohan Koyyalamudi | dd3c966 | 2012-11-09 17:39:30 -0800 | [diff] [blame] | 8718 | #ifdef FEATURE_WLAN_LFR |
| 8719 | void csrInitOccupiedChannelsList(tpAniSirGlobal pMac) |
| 8720 | { |
| 8721 | tListElem *pEntry = NULL; |
| 8722 | tCsrScanResult *pBssDesc = NULL; |
| 8723 | tDot11fBeaconIEs *pIes = NULL; |
Srinivas | 28b5b4e | 2012-12-12 13:07:53 -0800 | [diff] [blame] | 8724 | tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo; |
| 8725 | |
| 8726 | if (0 != pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels) |
| 8727 | { |
| 8728 | 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] | 8729 | " hence NO need to build occupied channel list (numChannels = %d)"), |
Srinivas | 28b5b4e | 2012-12-12 13:07:53 -0800 | [diff] [blame] | 8730 | __func__, pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels); |
| 8731 | return; |
| 8732 | } |
Madan Mohan Koyyalamudi | dd3c966 | 2012-11-09 17:39:30 -0800 | [diff] [blame] | 8733 | |
| 8734 | if (!csrNeighborRoamIsNewConnectedProfile(pMac)) |
| 8735 | { |
| 8736 | 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] | 8737 | " matches previous (numChannels = %d)"), |
Madan Mohan Koyyalamudi | dd3c966 | 2012-11-09 17:39:30 -0800 | [diff] [blame] | 8738 | __func__, pMac->scan.occupiedChannels.numChannels); |
| 8739 | return; |
| 8740 | } |
| 8741 | |
| 8742 | /* Empty occupied channels here */ |
| 8743 | pMac->scan.occupiedChannels.numChannels = 0; |
| 8744 | |
| 8745 | csrLLLock(&pMac->scan.scanResultList); |
| 8746 | pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK ); |
| 8747 | while( pEntry ) |
| 8748 | { |
| 8749 | pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link ); |
| 8750 | pIes = (tDot11fBeaconIEs *)( pBssDesc->Result.pvIes ); |
| 8751 | |
| 8752 | //At this time, pBssDescription->Result.pvIes may be NULL |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 8753 | if( !pIes && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, |
Madan Mohan Koyyalamudi | dd3c966 | 2012-11-09 17:39:30 -0800 | [diff] [blame] | 8754 | &pBssDesc->Result.BssDescriptor, &pIes))) ) |
| 8755 | { |
| 8756 | continue; |
| 8757 | } |
| 8758 | |
| 8759 | csrScanAddToOccupiedChannels(pMac, pBssDesc, &pMac->scan.occupiedChannels, pIes); |
| 8760 | |
| 8761 | /* |
| 8762 | * Free the memory allocated for pIes in csrGetParsedBssDescriptionIEs |
| 8763 | */ |
| 8764 | if( (pBssDesc->Result.pvIes == NULL) && pIes ) |
| 8765 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8766 | vos_mem_free(pIes); |
Madan Mohan Koyyalamudi | dd3c966 | 2012-11-09 17:39:30 -0800 | [diff] [blame] | 8767 | } |
| 8768 | |
| 8769 | pEntry = csrLLNext( &pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK ); |
| 8770 | }//while |
| 8771 | csrLLUnlock(&pMac->scan.scanResultList); |
Srikant Kuppa | 866893f | 2012-12-27 17:28:14 -0800 | [diff] [blame] | 8772 | |
Madan Mohan Koyyalamudi | dd3c966 | 2012-11-09 17:39:30 -0800 | [diff] [blame] | 8773 | } |
| 8774 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 8775 | |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 8776 | eHalStatus csrScanCreateEntryInScanCache(tpAniSirGlobal pMac, tANI_U32 sessionId, |
| 8777 | tCsrBssid bssid, tANI_U8 channel) |
| 8778 | { |
| 8779 | eHalStatus status = eHAL_STATUS_SUCCESS; |
| 8780 | tDot11fBeaconIEs *pNewIes = NULL; |
| 8781 | tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId ); |
Praveen Kumar Sirisilla | 8bdfac4 | 2013-10-10 17:20:48 -0700 | [diff] [blame] | 8782 | tSirBssDescription *pNewBssDescriptor = NULL; |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 8783 | tANI_U32 size = 0; |
| 8784 | |
| 8785 | if(NULL == pSession) |
| 8786 | { |
| 8787 | status = eHAL_STATUS_FAILURE; |
| 8788 | return status; |
| 8789 | } |
| 8790 | smsLog(pMac, LOG2, FL("csrScanCreateEntryInScanCache: Current bssid::" |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 8791 | MAC_ADDRESS_STR), |
| 8792 | MAC_ADDR_ARRAY(pSession->pConnectBssDesc->bssId)); |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 8793 | smsLog(pMac, LOG2, FL("csrScanCreateEntryInScanCache: My bssid::" |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 8794 | MAC_ADDRESS_STR" channel %d"), |
| 8795 | MAC_ADDR_ARRAY(bssid), channel); |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 8796 | |
| 8797 | do |
| 8798 | { |
| 8799 | if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, |
| 8800 | pSession->pConnectBssDesc, &pNewIes))) |
| 8801 | { |
| 8802 | smsLog(pMac, LOGE, FL("%s: Failed to parse IEs"), |
| 8803 | __func__); |
| 8804 | status = eHAL_STATUS_FAILURE; |
| 8805 | break; |
| 8806 | } |
| 8807 | |
| 8808 | size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length); |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8809 | if (size) |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 8810 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8811 | pNewBssDescriptor = vos_mem_malloc(size); |
| 8812 | if ( NULL == pNewBssDescriptor ) |
| 8813 | status = eHAL_STATUS_FAILURE; |
| 8814 | else |
| 8815 | status = eHAL_STATUS_SUCCESS; |
| 8816 | if (HAL_STATUS_SUCCESS(status)) |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 8817 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8818 | vos_mem_copy(pNewBssDescriptor, pSession->pConnectBssDesc, size); |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 8819 | } |
| 8820 | else |
| 8821 | { |
| 8822 | smsLog(pMac, LOGE, FL("%s: memory allocation failed"), |
| 8823 | __func__); |
| 8824 | status = eHAL_STATUS_FAILURE; |
| 8825 | break; |
| 8826 | } |
| 8827 | |
| 8828 | //change the BSSID & channel as passed |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8829 | vos_mem_copy(pNewBssDescriptor->bssId, bssid, sizeof(tSirMacAddr)); |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 8830 | pNewBssDescriptor->channelId = channel; |
Tushnim Bhattacharyya | 5128d75 | 2013-06-26 23:23:18 -0700 | [diff] [blame] | 8831 | if(NULL == csrScanAppendBssDescription( pMac, pNewBssDescriptor, pNewIes, TRUE )) |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 8832 | { |
Tushnim Bhattacharyya | 5128d75 | 2013-06-26 23:23:18 -0700 | [diff] [blame] | 8833 | smsLog(pMac, LOGE, FL("%s: csrScanAppendBssDescription failed"), |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 8834 | __func__); |
| 8835 | status = eHAL_STATUS_FAILURE; |
| 8836 | break; |
| 8837 | } |
| 8838 | } |
| 8839 | else |
| 8840 | { |
| 8841 | smsLog(pMac, LOGE, FL("%s: length of bss descriptor is 0"), |
| 8842 | __func__); |
| 8843 | status = eHAL_STATUS_FAILURE; |
| 8844 | break; |
| 8845 | } |
| 8846 | smsLog(pMac, LOGE, FL("%s: entry successfully added in scan cache"), |
| 8847 | __func__); |
| 8848 | }while(0); |
| 8849 | |
| 8850 | if(pNewIes) |
| 8851 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8852 | vos_mem_free(pNewIes); |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 8853 | } |
| 8854 | if(pNewBssDescriptor) |
| 8855 | { |
Kiet Lam | 64c1b49 | 2013-07-12 13:56:44 +0530 | [diff] [blame] | 8856 | vos_mem_free(pNewBssDescriptor); |
Varun Reddy Yeturu | cc661d2 | 2013-05-20 11:47:10 -0700 | [diff] [blame] | 8857 | } |
| 8858 | return status; |
| 8859 | } |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 8860 | |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 8861 | #ifdef FEATURE_WLAN_ESE |
Srinivas Girigowda | 5cecb20 | 2013-10-08 09:13:25 -0700 | [diff] [blame] | 8862 | // Update the TSF with the difference in system time |
| 8863 | void UpdateCCKMTSF(tANI_U32 *timeStamp0, tANI_U32 *timeStamp1, tANI_U32 *incr) |
| 8864 | { |
| 8865 | tANI_U64 timeStamp64 = ((tANI_U64)*timeStamp1 << 32) | (*timeStamp0); |
| 8866 | |
| 8867 | timeStamp64 = (tANI_U64)(timeStamp64 + (tANI_U64)*incr); |
| 8868 | *timeStamp0 = (tANI_U32)(timeStamp64 & 0xffffffff); |
| 8869 | *timeStamp1 = (tANI_U32)((timeStamp64 >> 32) & 0xffffffff); |
| 8870 | } |
| 8871 | #endif |