blob: 44922ebb17e7de7af5f51f127f4bdfcfe577a70c [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
Jeff Johnson40b59aa2013-03-19 14:43:18 -070042/** ------------------------------------------------------------------------- *
43 ------------------------------------------------------------------------- *
Jeff Johnson295189b2012-06-20 16:38:30 -070044
Jeff Johnson40b59aa2013-03-19 14:43:18 -070045
Jeff Johnson295189b2012-06-20 16:38:30 -070046 \file csrApiScan.c
Jeff Johnson40b59aa2013-03-19 14:43:18 -070047
Jeff Johnson295189b2012-06-20 16:38:30 -070048 Implementation for the Common Scan interfaces.
Jeff Johnson40b59aa2013-03-19 14:43:18 -070049
50 Copyright (C) 2006 Airgo Networks, Incorporated
Jeff Johnson295189b2012-06-20 16:38:30 -070051 ========================================================================== */
52
53#include "aniGlobal.h"
54
55#include "palApi.h"
56#include "csrInsideApi.h"
57#include "smeInside.h"
58#include "smsDebug.h"
59
60#include "csrSupport.h"
61#include "wlan_qct_tl.h"
62
63#include "vos_diag_core_log.h"
64#include "vos_diag_core_event.h"
65
66#include "vos_nvitem.h"
67#include "wlan_qct_wda.h"
Jeff Johnson40b59aa2013-03-19 14:43:18 -070068
Jeff Johnson295189b2012-06-20 16:38:30 -070069#define CSR_VALIDATE_LIST //This portion of code need to be removed once the issue is resolved.
70
71#ifdef CSR_VALIDATE_LIST
72tDblLinkList *g_pchannelPowerInfoList24 = NULL, * g_pchannelPowerInfoList5 = NULL;
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -070073tpAniSirGlobal g_pMac;
Jeff Johnson295189b2012-06-20 16:38:30 -070074#endif
75
76/* Purpose of HIDDEN_TIMER
77** When we remove hidden ssid from the profile i.e., forget the SSID via GUI that SSID shouldn't see in the profile
78** For above requirement we used timer limit, logic is explained below
79** Timer value is initialsed to current time when it receives corresponding probe response of hidden SSID (The probe request is
80** received regularly till SSID in the profile. Once it is removed from profile probe request is not sent.) when we receive probe response
81** for broadcast probe request, during update SSID with saved SSID we will diff current time with saved SSID time if it is greater than 1 min
82** then we are not updating with old one
83*/
84
85#define HIDDEN_TIMER (1*60*1000)
86#define CSR_SCAN_RESULT_RSSI_WEIGHT 80 // must be less than 100, represent the persentage of new RSSI
87
88/*---------------------------------------------------------------------------
89 PER filter constant fraction: it is a %
90---------------------------------------------------------------------------*/
91#define CSR_SCAN_PER_FILTER_FRAC 100
92
93/*---------------------------------------------------------------------------
94 RSSI filter constant fraction: it is a %
95---------------------------------------------------------------------------*/
96#define CSR_SCAN_RSSI_FILTER_FRAC 100
97
98/*---------------------------------------------------------------------------
99Convert RSSI into overall score: Since RSSI is in -dBm values, and the
100overall needs to be weighted inversely (where greater value means better
101system), we convert.
102RSSI *cannot* be more than 0xFF or less than 0 for meaningful WLAN operation
103---------------------------------------------------------------------------*/
104#define CSR_SCAN_MAX_SCORE_VAL 0xFF
105#define CSR_SCAN_MIN_SCORE_VAL 0x0
106#define CSR_SCAN_HANDOFF_DELTA 10
Jeff Johnson32d95a32012-09-10 13:15:23 -0700107#define MAX_ACTIVE_SCAN_FOR_ONE_CHANNEL 140
108#define MIN_ACTIVE_SCAN_FOR_ONE_CHANNEL 120
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -0800109#define CSR_SCAN_OVERALL_SCORE( rssi ) \
110 (( rssi < CSR_SCAN_MAX_SCORE_VAL ) \
111 ? (CSR_SCAN_MAX_SCORE_VAL-rssi) : CSR_SCAN_MIN_SCORE_VAL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700112
113
114#define CSR_SCAN_IS_OVER_BSS_LIMIT(pMac) \
115 ( (pMac)->scan.nBssLimit <= (csrLLCount(&(pMac)->scan.scanResultList)) )
116
Gopichand Nakkala10ba6fc2013-04-23 20:30:01 +0530117/* Maximum number of channels per country can be ignored */
118#define MAX_CHANNELS_IGNORE 10
119
Madan Mohan Koyyalamudi28dd0422013-08-12 15:06:21 +0530120#define MAX_COUNTRY_IGNORE 4
Gopichand Nakkala10ba6fc2013-04-23 20:30:01 +0530121
Agarwal Ashishd9d72602013-09-13 00:06:17 +0530122#define THIRTY_PERCENT(x) (x*30/100);
123
Gopichand Nakkala10ba6fc2013-04-23 20:30:01 +0530124/*struct to hold the ignored channel list based on country */
125typedef struct sCsrIgnoreChannels
126{
127 tANI_U8 countryCode[NV_FIELD_COUNTRY_CODE_SIZE];
128 tANI_U16 channelList[MAX_CHANNELS_IGNORE];
129 tANI_U16 channelCount;
130}tCsrIgnoreChannels;
131
132static tCsrIgnoreChannels countryIgnoreList[MAX_COUNTRY_IGNORE] = {
133 { {'U','A'}, { 136, 140}, 2},
134 { {'T','W'}, { 36, 40, 44, 48, 52}, 5},
Madan Mohan Koyyalamudi28dd0422013-08-12 15:06:21 +0530135 { {'I','D'}, { 165}, 1 },
136 { {'A','U'}, { 120, 124, 128}, 3 }
Gopichand Nakkala10ba6fc2013-04-23 20:30:01 +0530137 };
138
Jeff Johnson295189b2012-06-20 16:38:30 -0700139//*** This is temporary work around. It need to call CCM api to get to CFG later
140/// Get string parameter value
141extern tSirRetStatus wlan_cfgGetStr(tpAniSirGlobal, tANI_U16, tANI_U8*, tANI_U32*);
Gopichand Nakkala10ba6fc2013-04-23 20:30:01 +0530142
Jeff Johnson295189b2012-06-20 16:38:30 -0700143void csrScanGetResultTimerHandler(void *);
144void csrScanResultAgingTimerHandler(void *pv);
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -0800145static void csrScanResultCfgAgingTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700146void csrScanIdleScanTimerHandler(void *);
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700147static void csrSetDefaultScanTiming( tpAniSirGlobal pMac, tSirScanType scanType, tCsrScanRequest *pScanRequest);
Jeff Johnson295189b2012-06-20 16:38:30 -0700148#ifdef WLAN_AP_STA_CONCURRENCY
149static void csrStaApConcTimerHandler(void *);
150#endif
Jeff Johnsone7245742012-09-05 17:12:55 -0700151tANI_BOOLEAN csrIsSupportedChannel(tpAniSirGlobal pMac, tANI_U8 channelId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700152eHalStatus csrScanChannels( tpAniSirGlobal pMac, tSmeCmd *pCommand );
153void csrSetCfgValidChannelList( tpAniSirGlobal pMac, tANI_U8 *pChannelList, tANI_U8 NumChannels );
154void csrSaveTxPowerToCfg( tpAniSirGlobal pMac, tDblLinkList *pList, tANI_U32 cfgId );
155void csrSetCfgCountryCode( tpAniSirGlobal pMac, tANI_U8 *countryCode );
156void csrPurgeChannelPower( tpAniSirGlobal pMac, tDblLinkList *pChannelList );
157//if bgPeriod is 0, background scan is disabled. It is in millisecond units
158eHalStatus csrSetCfgBackgroundScanPeriod(tpAniSirGlobal pMac, tANI_U32 bgPeriod);
159eHalStatus csrProcessSetBGScanParam(tpAniSirGlobal pMac, tSmeCmd *pCommand);
160void csrReleaseScanCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand, eCsrScanStatus scanStatus);
161static tANI_BOOLEAN csrScanValidateScanResult( tpAniSirGlobal pMac, tANI_U8 *pChannels,
162 tANI_U8 numChn, tSirBssDescription *pBssDesc,
163 tDot11fBeaconIEs **ppIes );
164eHalStatus csrSetBGScanChannelList( tpAniSirGlobal pMac, tANI_U8 *pAdjustChannels, tANI_U8 NumAdjustChannels);
165void csrReleaseCmdSingle(tpAniSirGlobal pMac, tSmeCmd *pCommand);
166tANI_BOOLEAN csrRoamIsValidChannel( tpAniSirGlobal pMac, tANI_U8 channel );
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700167void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList );
Jeff Johnson295189b2012-06-20 16:38:30 -0700168
Madan Mohan Koyyalamudi783b2362012-10-21 11:54:41 -0700169#define CSR_IS_SOCIAL_CHANNEL(channel) (((channel) == 1) || ((channel) == 6) || ((channel) == 11) )
170
Madan Mohan Koyyalamudi783b2362012-10-21 11:54:41 -0700171
Madan Mohan Koyyalamudi783b2362012-10-21 11:54:41 -0700172
Madan Mohan Koyyalamudi923c1e12012-11-30 17:53:27 -0800173static void csrReleaseScanCmdPendingList(tpAniSirGlobal pMac)
174{
175 tListElem *pEntry;
176 tSmeCmd *pCommand;
177
178 while((pEntry = csrLLRemoveHead( &pMac->scan.scanCmdPendingList, LL_ACCESS_LOCK)) != NULL)
179 {
180 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
181 if ( eSmeCsrCommandMask & pCommand->command )
182 {
183 csrAbortCommand( pMac, pCommand, eANI_BOOLEAN_TRUE );
184 }
185 else
186 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800187 smsLog(pMac, LOGE, FL("Error: Received command : %d"),pCommand->command);
Madan Mohan Koyyalamudi923c1e12012-11-30 17:53:27 -0800188 }
189 }
190}
Jeff Johnson295189b2012-06-20 16:38:30 -0700191//pResult is invalid calling this function.
192void csrFreeScanResultEntry( tpAniSirGlobal pMac, tCsrScanResult *pResult )
193{
194 if( NULL != pResult->Result.pvIes )
195 {
196 palFreeMemory( pMac->hHdd, pResult->Result.pvIes );
197 }
198 palFreeMemory(pMac->hHdd, pResult);
199}
200
201
202static eHalStatus csrLLScanPurgeResult(tpAniSirGlobal pMac, tDblLinkList *pList)
203{
204 eHalStatus status = eHAL_STATUS_SUCCESS;
205 tListElem *pEntry;
206 tCsrScanResult *pBssDesc;
207
208 csrLLLock(pList);
209
210 while((pEntry = csrLLRemoveHead(pList, LL_ACCESS_NOLOCK)) != NULL)
211 {
212 pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
213 csrFreeScanResultEntry( pMac, pBssDesc );
214 }
215
216 csrLLUnlock(pList);
217
218 return (status);
219}
220
221
222int csrCheckValidateLists(void * dest, const void *src, v_SIZE_t num, int idx)
223{
224#ifdef CSR_VALIDATE_LIST
225
226 int ii = 1;
227
228 if( (NULL == g_pMac) || (!g_pMac->scan.fValidateList ) )
229 {
230 return ii;
231 }
232 if(g_pchannelPowerInfoList24)
233 {
234 //check 2.4 list
235 tListElem *pElem, *pHead;
236 int count;
237
238 count = (int)(g_pchannelPowerInfoList24->Count);
239 pHead = &g_pchannelPowerInfoList24->ListHead;
240 pElem = pHead->next;
241 if((tANI_U32)(pHead->next) > 0x00010000) //Assuming kernel address is not that low.
242 {
243 //this loop crashes if the pointer is not right
244 while(pElem->next != pHead)
245 {
246 if((tANI_U32)(pElem->next) > 0x00010000)
247 {
248 pElem = pElem->next;
249 VOS_ASSERT(count > 0);
250 count--;
251 }
252 else
253 {
254 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
255 " %d Detect 1 list(0x%X) error Head(0x%X) next(0x%X) Count %d, dest(0x%X) src(0x%X) numBytes(%d)",
256 idx, (unsigned int)g_pchannelPowerInfoList24, (unsigned int)pHead,
257 (unsigned int)(pHead->next), (int)g_pchannelPowerInfoList24->Count,
258 (unsigned int)dest, (unsigned int)src, (int)num);
259 VOS_ASSERT(0);
260 ii = 0;
261 break;
262 }
263 }
264 }
265 else
266 {
267 //Bad list
268 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL, " %d Detect list(0x%X) error Head(0x%X) next(0x%X) Count %d, dest(0x%X) src(0x%X) numBytes(%d)",
269 idx, (unsigned int)g_pchannelPowerInfoList24, (unsigned int)pHead,
270 (unsigned int)(pHead->next), (int)g_pchannelPowerInfoList24->Count,
271 (unsigned int)dest, (unsigned int)src, (int)num);
272 VOS_ASSERT(0);
273 ii = 0;
274 }
275 }
276 else
277 {
278 //list ok
279 ii = 1;
280 }
281
282
283 return ii;
284
285#else
286 return 1;
287#endif //#ifdef CSR_VALIDATE_LIST
288}
289
290
291eHalStatus csrScanOpen( tpAniSirGlobal pMac )
292{
293 eHalStatus status;
294
295 do
296 {
297 csrLLOpen(pMac->hHdd, &pMac->scan.scanResultList);
298 csrLLOpen(pMac->hHdd, &pMac->scan.tempScanResults);
299 csrLLOpen(pMac->hHdd, &pMac->scan.channelPowerInfoList24);
300 csrLLOpen(pMac->hHdd, &pMac->scan.channelPowerInfoList5G);
301#ifdef WLAN_AP_STA_CONCURRENCY
302 csrLLOpen(pMac->hHdd, &pMac->scan.scanCmdPendingList);
303#endif
304#ifdef CSR_VALIDATE_LIST
305 g_pchannelPowerInfoList5 = &pMac->scan.channelPowerInfoList5G;
306 g_pMac = pMac;
307 g_pchannelPowerInfoList24 = &pMac->scan.channelPowerInfoList24;
308#endif
309 pMac->scan.fFullScanIssued = eANI_BOOLEAN_FALSE;
310 pMac->scan.nBssLimit = CSR_MAX_BSS_SUPPORT;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530311 status = vos_timer_init(&pMac->scan.hTimerGetResult, VOS_TIMER_TYPE_SW, csrScanGetResultTimerHandler, pMac);
312 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700313 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800314 smsLog(pMac, LOGE, FL("cannot allocate memory for getResult timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700315 break;
316 }
317#ifdef WLAN_AP_STA_CONCURRENCY
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530318 status = vos_timer_init(&pMac->scan.hTimerStaApConcTimer, VOS_TIMER_TYPE_SW, csrStaApConcTimerHandler, pMac);
319 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700320 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800321 smsLog(pMac, LOGE, FL("cannot allocate memory for hTimerStaApConcTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700322 break;
323 }
324#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530325 status = vos_timer_init(&pMac->scan.hTimerIdleScan, VOS_TIMER_TYPE_SW, csrScanIdleScanTimerHandler, pMac);
326 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700327 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800328 smsLog(pMac, LOGE, FL("cannot allocate memory for idleScan timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700329 break;
330 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530331 status = vos_timer_init(&pMac->scan.hTimerResultAging, VOS_TIMER_TYPE_SW, csrScanResultAgingTimerHandler, pMac);
332 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700333 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800334 smsLog(pMac, LOGE, FL("cannot allocate memory for ResultAging timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700335 break;
336 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530337 status = vos_timer_init(&pMac->scan.hTimerResultCfgAging, VOS_TIMER_TYPE_SW,
338 csrScanResultCfgAgingTimerHandler, pMac);
339 if (!HAL_STATUS_SUCCESS(status))
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -0800340 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800341 smsLog(pMac, LOGE, FL("cannot allocate memory for CFG ResultAging timer"));
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -0800342 break;
343 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700344 }while(0);
345
346 return (status);
347}
348
349
350eHalStatus csrScanClose( tpAniSirGlobal pMac )
351{
352#ifdef CSR_VALIDATE_LIST
353 g_pchannelPowerInfoList24 = NULL;
354 g_pchannelPowerInfoList5 = NULL;
355 g_pMac = NULL;
356#endif
357 csrLLScanPurgeResult(pMac, &pMac->scan.tempScanResults);
358 csrLLScanPurgeResult(pMac, &pMac->scan.scanResultList);
359#ifdef WLAN_AP_STA_CONCURRENCY
Madan Mohan Koyyalamudi923c1e12012-11-30 17:53:27 -0800360 csrReleaseScanCmdPendingList(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700361#endif
362 csrLLClose(&pMac->scan.scanResultList);
363 csrLLClose(&pMac->scan.tempScanResults);
364#ifdef WLAN_AP_STA_CONCURRENCY
365 csrLLClose(&pMac->scan.scanCmdPendingList);
366#endif
367 csrPurgeChannelPower(pMac, &pMac->scan.channelPowerInfoList24);
368 csrPurgeChannelPower(pMac, &pMac->scan.channelPowerInfoList5G);
369 csrLLClose(&pMac->scan.channelPowerInfoList24);
370 csrLLClose(&pMac->scan.channelPowerInfoList5G);
371 csrScanDisable(pMac);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530372 vos_timer_destroy(&pMac->scan.hTimerResultAging);
373 vos_timer_destroy(&pMac->scan.hTimerResultCfgAging);
374 vos_timer_destroy(&pMac->scan.hTimerGetResult);
Jeff Johnson295189b2012-06-20 16:38:30 -0700375#ifdef WLAN_AP_STA_CONCURRENCY
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530376 vos_timer_destroy(&pMac->scan.hTimerStaApConcTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700377#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530378 vos_timer_destroy(&pMac->scan.hTimerIdleScan);
Jeff Johnson295189b2012-06-20 16:38:30 -0700379 return eHAL_STATUS_SUCCESS;
380}
381
382
383eHalStatus csrScanEnable( tpAniSirGlobal pMac )
384{
385
386 pMac->scan.fScanEnable = eANI_BOOLEAN_TRUE;
387 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE;
388
389 return eHAL_STATUS_SUCCESS;
390}
391
392
393eHalStatus csrScanDisable( tpAniSirGlobal pMac )
394{
395
396 csrScanStopTimers(pMac);
397 pMac->scan.fScanEnable = eANI_BOOLEAN_FALSE;
398
399 return eHAL_STATUS_SUCCESS;
400}
401
402
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700403//Set scan timing parameters according to state of other driver sessions
404//No validation of the parameters is performed.
405static void csrSetDefaultScanTiming( tpAniSirGlobal pMac, tSirScanType scanType, tCsrScanRequest *pScanRequest)
406{
407#ifdef WLAN_AP_STA_CONCURRENCY
408 if(csrIsAnySessionConnected(pMac))
409 {
410 //If multi-session, use the appropriate default scan times
411 if(scanType == eSIR_ACTIVE_SCAN)
412 {
413 pScanRequest->maxChnTime = pMac->roam.configParam.nActiveMaxChnTimeConc;
414 pScanRequest->minChnTime = pMac->roam.configParam.nActiveMinChnTimeConc;
415 }
416 else
417 {
418 pScanRequest->maxChnTime = pMac->roam.configParam.nPassiveMaxChnTimeConc;
419 pScanRequest->minChnTime = pMac->roam.configParam.nPassiveMinChnTimeConc;
420 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -0800421 pScanRequest->maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
422 pScanRequest->minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700423
424 pScanRequest->restTime = pMac->roam.configParam.nRestTimeConc;
425
426 //Return so that fields set above will not be overwritten.
427 return;
428 }
429#endif
430
431 //This portion of the code executed if multi-session not supported
432 //(WLAN_AP_STA_CONCURRENCY not defined) or no multi-session.
433 //Use the "regular" (non-concurrency) default scan timing.
434 if(pScanRequest->scanType == eSIR_ACTIVE_SCAN)
435 {
436 pScanRequest->maxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
437 pScanRequest->minChnTime = pMac->roam.configParam.nActiveMinChnTime;
438 }
439 else
440 {
441 pScanRequest->maxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
442 pScanRequest->minChnTime = pMac->roam.configParam.nPassiveMinChnTime;
443 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -0800444 pScanRequest->maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
445 pScanRequest->minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700446
447#ifdef WLAN_AP_STA_CONCURRENCY
448 //No rest time if no sessions are connected.
449 pScanRequest->restTime = 0;
450#endif
451}
452
Jeff Johnson295189b2012-06-20 16:38:30 -0700453#ifdef WLAN_AP_STA_CONCURRENCY
454//Return SUCCESS is the command is queued, else returns eHAL_STATUS_FAILURE
455eHalStatus csrQueueScanRequest( tpAniSirGlobal pMac, tSmeCmd *pScanCmd )
456{
457 eHalStatus status = eHAL_STATUS_SUCCESS;
458
459 tANI_BOOLEAN fNoCmdPending;
460 tSmeCmd *pQueueScanCmd=NULL;
461 tSmeCmd *pSendScanCmd=NULL;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -0700462 tANI_U8 nNumChanCombinedConc = 0;
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700463 if (NULL == pScanCmd)
464 {
465 smsLog (pMac, LOGE, FL("Scan Req cmd is NULL"));
466 return eHAL_STATUS_FAILURE;
467 }
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -0800468 /* split scan if any one of the following:
469 * - STA session is connected and the scan is not a P2P search
470 * - any P2P session is connected
Srikant Kuppa866893f2012-12-27 17:28:14 -0800471 * Do not split scans if no concurrent infra connections are
472 * active and if the scan is a BG scan triggered by LFR (OR)
473 * any scan if LFR is in the middle of a BG scan. Splitting
474 * the scan is delaying the time it takes for LFR to find
475 * candidates and resulting in disconnects.
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -0800476 */
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -0700477
478 if(csrIsStaSessionConnected(pMac) &&
479 !csrIsP2pSessionConnected(pMac))
480 {
481 nNumChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
482 }
483 else if(csrIsP2pSessionConnected(pMac))
484 {
485 nNumChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
486 }
Srikant Kuppa866893f2012-12-27 17:28:14 -0800487 if ( (csrIsStaSessionConnected(pMac) &&
488#ifdef FEATURE_WLAN_LFR
489 (csrIsConcurrentInfraConnected(pMac) ||
490 ((pScanCmd->u.scanCmd.reason != eCsrScanBgScan) &&
491 (pMac->roam.neighborRoamInfo.neighborRoamState !=
492 eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN))) &&
493#endif
494 (pScanCmd->u.scanCmd.u.scanRequest.p2pSearch != 1)) ||
Vinay Malekal05fdc812012-12-17 13:04:30 -0800495 (csrIsP2pSessionConnected(pMac)) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700496 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700497 tCsrScanRequest scanReq;
498 tANI_U8 numChn = pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels;
499 tCsrChannelInfo *pChnInfo = &scanReq.ChannelInfo;
500 tANI_U8 channelToScan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -0700501 tANI_BOOLEAN bMemAlloc = eANI_BOOLEAN_FALSE;
502
503 if (numChn == 0)
504 {
505
506 numChn = pMac->scan.baseChannels.numChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -0700507
Vinay Malekal05fdc812012-12-17 13:04:30 -0800508 status = palAllocateMemory( pMac->hHdd, (void **)&pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList, numChn );
509 if( !HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700510 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800511 smsLog( pMac, LOGE, FL(" Failed to get memory for channel list ") );
Vinay Malekal05fdc812012-12-17 13:04:30 -0800512 return eHAL_STATUS_FAILURE;
513 }
514 bMemAlloc = eANI_BOOLEAN_TRUE;
515 status = palCopyMemory( pMac->hHdd, pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList,
516 pMac->scan.baseChannels.channelList, numChn );
517 if( !HAL_STATUS_SUCCESS( status ) )
518 {
519 palFreeMemory( pMac->hHdd, pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList );
520 pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = NULL;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800521 smsLog( pMac, LOGE, FL(" Failed to copy memory to channel list ") );
Vinay Malekal05fdc812012-12-17 13:04:30 -0800522 return eHAL_STATUS_FAILURE;
523 }
524 pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = numChn;
525 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700526
Vinay Malekal05fdc812012-12-17 13:04:30 -0800527 //Whenever we get a scan request with multiple channels we break it up into 2 requests
528 //First request for first channel to scan and second request to scan remaining channels
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -0700529 if ( numChn > nNumChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -0800530 {
531 palZeroMemory(pMac->hHdd, &scanReq, sizeof(tCsrScanRequest));
532
533 pQueueScanCmd = csrGetCommandBuffer(pMac); //optimize this to use 2 command buffer only
534 if (!pQueueScanCmd)
535 {
536 if (bMemAlloc)
Jeff Johnson295189b2012-06-20 16:38:30 -0700537 {
Vinay Malekal05fdc812012-12-17 13:04:30 -0800538 palFreeMemory( pMac->hHdd, pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList );
539 pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = NULL;
540
Jeff Johnson295189b2012-06-20 16:38:30 -0700541 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800542 smsLog( pMac, LOGE, FL(" Failed to get Queue command buffer") );
Vinay Malekal05fdc812012-12-17 13:04:30 -0800543 return eHAL_STATUS_FAILURE;
544 }
545 pQueueScanCmd->command = pScanCmd->command;
546 pQueueScanCmd->sessionId = pScanCmd->sessionId;
547 pQueueScanCmd->u.scanCmd.callback = pScanCmd->u.scanCmd.callback;
548 pQueueScanCmd->u.scanCmd.pContext = pScanCmd->u.scanCmd.pContext;
549 pQueueScanCmd->u.scanCmd.reason = pScanCmd->u.scanCmd.reason;
550 pQueueScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around
Jeff Johnson295189b2012-06-20 16:38:30 -0700551
Vinay Malekal05fdc812012-12-17 13:04:30 -0800552 /* First copy all the parameters to local variable of scan request */
553 csrScanCopyRequest(pMac, &scanReq, &pScanCmd->u.scanCmd.u.scanRequest);
Madan Mohan Koyyalamudiaf2a8b92012-10-09 14:58:07 -0700554
Vinay Malekal05fdc812012-12-17 13:04:30 -0800555 /* Now modify the elements of local var scan request required to be modified for split scan */
556 if(scanReq.ChannelInfo.ChannelList != NULL)
557 {
558 palFreeMemory(pMac->hHdd, scanReq.ChannelInfo.ChannelList);
Madan Mohan Koyyalamudi0c626f32012-11-30 15:10:25 -0800559 scanReq.ChannelInfo.ChannelList = NULL;
Vinay Malekal05fdc812012-12-17 13:04:30 -0800560 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700561
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -0700562 pChnInfo->numOfChannels = pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels - nNumChanCombinedConc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700563
Vinay Malekal05fdc812012-12-17 13:04:30 -0800564 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +0530565 FL(" &channelToScan %p pScanCmd(%p) pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList(%p)numChn(%d)"),
566 &channelToScan[0], pScanCmd,
567 pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList, numChn);
Jeff Johnson295189b2012-06-20 16:38:30 -0700568
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -0700569 palCopyMemory(pMac->hHdd, &channelToScan[0], &pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[nNumChanCombinedConc],
Vinay Malekal05fdc812012-12-17 13:04:30 -0800570 pChnInfo->numOfChannels * sizeof(tANI_U8));
571
572 pChnInfo->ChannelList = &channelToScan[0];
573
574 scanReq.BSSType = eCSR_BSS_TYPE_ANY;
575 //Modify callers parameters in case of concurrency
Madan Mohan Koyyalamudi04a65f02013-07-26 13:58:38 +0530576 if (!pScanCmd->u.scanCmd.u.scanRequest.bcnRptReqScan)
577 scanReq.scanType = eSIR_ACTIVE_SCAN;
Vinay Malekal05fdc812012-12-17 13:04:30 -0800578 //Use concurrency values for min/maxChnTime.
579 //We know csrIsAnySessionConnected(pMac) returns TRUE here
580 csrSetDefaultScanTiming(pMac, scanReq.scanType, &scanReq);
581
582 status = csrScanCopyRequest(pMac, &pQueueScanCmd->u.scanCmd.u.scanRequest, &scanReq);
583
584 if(!HAL_STATUS_SUCCESS(status))
585 {
586 if (bMemAlloc)
587 {
588 palFreeMemory( pMac->hHdd, pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList );
589 pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = NULL;
590
591 }
592 if( scanReq.pIEField != NULL)
593 {
594 palFreeMemory(pMac->hHdd, scanReq.pIEField);
595 scanReq.pIEField = NULL;
596 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800597 smsLog( pMac, LOGE, FL(" Failed to get copy csrScanRequest = %d"), status );
Vinay Malekal05fdc812012-12-17 13:04:30 -0800598 return eHAL_STATUS_FAILURE;
599 }
600 /* Clean the local scan variable */
601 scanReq.ChannelInfo.ChannelList = NULL;
602 scanReq.ChannelInfo.numOfChannels = 0;
603 csrScanFreeRequest(pMac, &scanReq);
604
605 /* setup the command to scan 2 channels */
606 pSendScanCmd = pScanCmd;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -0700607 pSendScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = nNumChanCombinedConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -0800608 pSendScanCmd->u.scanCmd.u.scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
Madan Mohan Koyyalamudi04a65f02013-07-26 13:58:38 +0530609 if (!pSendScanCmd->u.scanCmd.u.scanRequest.bcnRptReqScan)
610 pSendScanCmd->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN;
Vinay Malekal05fdc812012-12-17 13:04:30 -0800611 //Use concurrency values for min/maxChnTime.
612 //We know csrIsAnySessionConnected(pMac) returns TRUE here
613 csrSetDefaultScanTiming(pMac, pSendScanCmd->u.scanCmd.u.scanRequest.scanType, &pSendScanCmd->u.scanCmd.u.scanRequest);
614 pSendScanCmd->u.scanCmd.callback = NULL;
615 } else {
616 pSendScanCmd = pScanCmd;
617 pSendScanCmd->u.scanCmd.u.scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
Madan Mohan Koyyalamudi04a65f02013-07-26 13:58:38 +0530618 if (!pSendScanCmd->u.scanCmd.u.scanRequest.bcnRptReqScan)
619 pSendScanCmd->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN;
Vinay Malekal05fdc812012-12-17 13:04:30 -0800620 //Use concurrency values for min/maxChnTime.
621 //We know csrIsAnySessionConnected(pMac) returns TRUE here
622 csrSetDefaultScanTiming(pMac, pSendScanCmd->u.scanCmd.u.scanRequest.scanType, &pSendScanCmd->u.scanCmd.u.scanRequest);
623 }
624
625 fNoCmdPending = csrLLIsListEmpty( &pMac->scan.scanCmdPendingList, LL_ACCESS_LOCK );
626
627 //Logic Below is as follows
628 // If the scanCmdPendingList is empty then we directly send that command
629 // to smeCommandQueue else we buffer it in our scanCmdPendingList Queue
630 if( fNoCmdPending )
631 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700632 if (pQueueScanCmd != NULL)
633 {
Vinay Malekal05fdc812012-12-17 13:04:30 -0800634 csrLLInsertTail( &pMac->scan.scanCmdPendingList, &pQueueScanCmd->Link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -0700635 }
636
637 if (pSendScanCmd != NULL)
638 {
639 return csrQueueSmeCommand(pMac, pSendScanCmd, eANI_BOOLEAN_FALSE);
640 }
Vinay Malekal05fdc812012-12-17 13:04:30 -0800641 }
642 else
643 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700644 if (pSendScanCmd != NULL)
645 {
646 csrLLInsertTail( &pMac->scan.scanCmdPendingList, &pSendScanCmd->Link, LL_ACCESS_LOCK );
647 }
Vinay Malekal05fdc812012-12-17 13:04:30 -0800648
Jeff Johnson295189b2012-06-20 16:38:30 -0700649 if (pQueueScanCmd != NULL)
650 {
651 csrLLInsertTail( &pMac->scan.scanCmdPendingList, &pQueueScanCmd->Link, LL_ACCESS_LOCK );
652 }
Vinay Malekal05fdc812012-12-17 13:04:30 -0800653 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700654 }
655 else
656 { //No concurrency case
Srikant Kuppa866893f2012-12-27 17:28:14 -0800657 smsLog( pMac, LOG2, FL("Queuing scan command (reason=%d, roamState=%d"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800658 " numOfChannels=%d)"),
Srikant Kuppa866893f2012-12-27 17:28:14 -0800659 pScanCmd->u.scanCmd.reason,
660 pMac->roam.neighborRoamInfo.neighborRoamState,
661 pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -0700662 return csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_FALSE);
663 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700664
665 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -0700666}
667#endif
668
Jeff Johnsone7245742012-09-05 17:12:55 -0700669/* ---------------------------------------------------------------------------
670 \fn csrScan2GOnyRequest
671 \brief This function will update the scan request with only
Jeff Johnsonb88db982012-12-10 13:34:59 -0800672 2.4GHz valid channel list.
Jeff Johnsone7245742012-09-05 17:12:55 -0700673 \param pMac
674 \param pScanCmd
675 \param pScanRequest
676 \return None
677 -------------------------------------------------------------------------------*/
678static void csrScan2GOnyRequest(tpAniSirGlobal pMac,tSmeCmd *pScanCmd,
679 tCsrScanRequest *pScanRequest)
680{
681 tANI_U8 index, channelId, channelListSize = 0;
682 tANI_U8 channelList2G[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14};
683 static tANI_U8 validchannelList[CSR_MAX_2_4_GHZ_SUPPORTED_CHANNELS] = {0};
684
685 VOS_ASSERT(pScanCmd && pScanRequest);
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -0700686 /* To silence the KW tool null check is added */
687 if((pScanCmd == NULL) || (pScanRequest == NULL))
688 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800689 smsLog( pMac, LOGE, FL(" pScanCmd or pScanRequest is NULL "));
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -0700690 return;
691 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700692
693 if (pScanCmd->u.scanCmd.scanID ||
694 (eCSR_SCAN_REQUEST_FULL_SCAN != pScanRequest->requestType))
695 return;
696
697 //Contsruct valid Supported 2.4 GHz Channel List
698 for( index = 0; index < ARRAY_SIZE(channelList2G); index++ )
699 {
700 channelId = channelList2G[index];
701 if ( csrIsSupportedChannel( pMac, channelId ) )
702 {
703 validchannelList[channelListSize++] = channelId;
704 }
705 }
706
707 pScanRequest->ChannelInfo.numOfChannels = channelListSize;
708 pScanRequest->ChannelInfo.ChannelList = validchannelList;
709}
710
Jeff Johnson295189b2012-06-20 16:38:30 -0700711eHalStatus csrScanRequest(tpAniSirGlobal pMac, tANI_U16 sessionId,
712 tCsrScanRequest *pScanRequest, tANI_U32 *pScanRequestID,
713 csrScanCompleteCallback callback, void *pContext)
714{
715 eHalStatus status = eHAL_STATUS_FAILURE;
716 tSmeCmd *pScanCmd = NULL;
Madan Mohan Koyyalamudicb90bb22012-10-30 18:24:43 -0700717 eCsrConnectState ConnectState;
Jeff Johnson295189b2012-06-20 16:38:30 -0700718
Gopichand Nakkala9b89a732012-12-31 16:31:46 -0800719 if(pScanRequest == NULL)
720 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800721 smsLog( pMac, LOGE, FL(" pScanRequest is NULL"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -0800722 VOS_ASSERT(0);
723 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700724
Jeff Johnson295189b2012-06-20 16:38:30 -0700725 do
726 {
727 if(pMac->scan.fScanEnable)
728 {
729 pScanCmd = csrGetCommandBuffer(pMac);
730 if(pScanCmd)
731 {
732 palZeroMemory(pMac->hHdd, &pScanCmd->u.scanCmd, sizeof(tScanCmd));
733 pScanCmd->command = eSmeCommandScan;
734 pScanCmd->sessionId = sessionId;
735 pScanCmd->u.scanCmd.callback = callback;
736 pScanCmd->u.scanCmd.pContext = pContext;
737 if(eCSR_SCAN_REQUEST_11D_SCAN == pScanRequest->requestType)
738 {
739 pScanCmd->u.scanCmd.reason = eCsrScan11d1;
740 }
741 else if((eCSR_SCAN_REQUEST_FULL_SCAN == pScanRequest->requestType) ||
742 (eCSR_SCAN_P2P_DISCOVERY == pScanRequest->requestType)
743#ifdef SOFTAP_CHANNEL_RANGE
744 ||(eCSR_SCAN_SOFTAP_CHANNEL_RANGE == pScanRequest->requestType)
745#endif
746 )
747 {
748 pScanCmd->u.scanCmd.reason = eCsrScanUserRequest;
749 }
750 else if(eCSR_SCAN_HO_BG_SCAN == pScanRequest->requestType)
751 {
752 pScanCmd->u.scanCmd.reason = eCsrScanBgScan;
753 }
754 else if(eCSR_SCAN_HO_PROBE_SCAN == pScanRequest->requestType)
755 {
756 pScanCmd->u.scanCmd.reason = eCsrScanProbeBss;
757 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700758 else if(eCSR_SCAN_P2P_FIND_PEER == pScanRequest->requestType)
759 {
760 pScanCmd->u.scanCmd.reason = eCsrScanP2PFindPeer;
761 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700762 else
763 {
764 pScanCmd->u.scanCmd.reason = eCsrScanIdleScan;
765 }
766 if(pScanRequest->minChnTime == 0 && pScanRequest->maxChnTime == 0)
767 {
768 //The caller doesn't set the time correctly. Set it here
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700769 csrSetDefaultScanTiming(pMac, pScanRequest->scanType, pScanRequest);
770 }
771#ifdef WLAN_AP_STA_CONCURRENCY
772 if(pScanRequest->restTime == 0)
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -0800773 {
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700774 //Need to set restTime only if at least one session is connected
775 if(csrIsAnySessionConnected(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -0700776 {
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700777 pScanRequest->restTime = pMac->roam.configParam.nRestTimeConc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700778 }
779 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700780#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -0700781 /*For Standalone wlan : channel time will remain the same.
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530782 For BTC with A2DP up: Channel time = Channel time * 2, if station is not already associated.
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -0800783 This has been done to provide a larger scan window for faster connection during btc.Else Scan is seen
784 to take a long time.
785 For BTC with A2DP up: Channel time will not be doubled, if station is already associated.
786 */
Jeff Johnson32d95a32012-09-10 13:15:23 -0700787 status = csrRoamGetConnectState(pMac,sessionId,&ConnectState);
Srinivas Girigowdac84c57c2013-02-19 17:41:56 -0800788 if (HAL_STATUS_SUCCESS(status) &&
789 pMac->btc.fA2DPUp &&
Jeff Johnson32d95a32012-09-10 13:15:23 -0700790 (eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED != ConnectState) &&
791 (eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED != ConnectState))
792 {
793 pScanRequest->maxChnTime = pScanRequest->maxChnTime << 1;
794 pScanRequest->minChnTime = pScanRequest->minChnTime << 1;
795 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -0800796
797 pScanRequest->maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
798 pScanRequest->minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700799 //Need to make the following atomic
800 pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around
801
802 if(pScanRequestID)
803 {
804 *pScanRequestID = pScanCmd->u.scanCmd.scanID;
805 }
806
Gopichand Nakkala9b89a732012-12-31 16:31:46 -0800807 // If it is the first scan request from HDD, CSR checks if it is for 11d.
Jeff Johnson295189b2012-06-20 16:38:30 -0700808 // If it is not, CSR will save the scan request in the pending cmd queue
809 // & issue an 11d scan request to PE.
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -0800810 if (((0 == pScanCmd->u.scanCmd.scanID)
Jeff Johnson295189b2012-06-20 16:38:30 -0700811 && (eCSR_SCAN_REQUEST_11D_SCAN != pScanRequest->requestType))
812#ifdef SOFTAP_CHANNEL_RANGE
813 && (eCSR_SCAN_SOFTAP_CHANNEL_RANGE != pScanRequest->requestType)
814#endif
815 && (eANI_BOOLEAN_FALSE == pMac->scan.fEnableBypass11d)
816 )
817 {
818 tSmeCmd *p11dScanCmd;
819 tCsrScanRequest scanReq;
820 tCsrChannelInfo *pChnInfo = &scanReq.ChannelInfo;
821
822 palZeroMemory(pMac->hHdd, &scanReq, sizeof(tCsrScanRequest));
823
824 p11dScanCmd = csrGetCommandBuffer(pMac);
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -0800825 if (p11dScanCmd)
Jeff Johnson295189b2012-06-20 16:38:30 -0700826 {
827 tANI_U32 numChn = pMac->scan.baseChannels.numChannels;
828
829 palZeroMemory(pMac->hHdd, &p11dScanCmd->u.scanCmd, sizeof(tScanCmd));
830 status = palAllocateMemory( pMac->hHdd, (void **)&pChnInfo->ChannelList, numChn );
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -0800831 if ( !HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700832 {
833 break;
834 }
835 status = palCopyMemory( pMac->hHdd, pChnInfo->ChannelList,
836 pMac->scan.baseChannels.channelList, numChn );
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -0800837 if ( !HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700838 {
839 palFreeMemory( pMac->hHdd, pChnInfo->ChannelList );
840 pChnInfo->ChannelList = NULL;
841 break;
842 }
843 pChnInfo->numOfChannels = (tANI_U8)numChn;
844 p11dScanCmd->command = eSmeCommandScan;
845 p11dScanCmd->u.scanCmd.callback = NULL;
846 p11dScanCmd->u.scanCmd.pContext = NULL;
847 p11dScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++;
848 scanReq.BSSType = eCSR_BSS_TYPE_ANY;
849
850 if ( csrIs11dSupported(pMac) )
851 {
Madan Mohan Koyyalamudi04a65f02013-07-26 13:58:38 +0530852 scanReq.bcnRptReqScan = pScanRequest->bcnRptReqScan;
853 if (pScanRequest->bcnRptReqScan)
854 scanReq.scanType = pScanRequest->scanType ?
855 eSIR_PASSIVE_SCAN :
856 pScanRequest->scanType;
857 else
858 scanReq.scanType = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700859 scanReq.requestType = eCSR_SCAN_REQUEST_11D_SCAN;
860 p11dScanCmd->u.scanCmd.reason = eCsrScan11d1;
861 scanReq.maxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
862 scanReq.minChnTime = pMac->roam.configParam.nPassiveMinChnTime;
863 }
864 else
865 {
Madan Mohan Koyyalamudi04a65f02013-07-26 13:58:38 +0530866 scanReq.bcnRptReqScan = pScanRequest->bcnRptReqScan;
867 if (pScanRequest->bcnRptReqScan)
868 scanReq.scanType = pScanRequest->scanType;
869 else
870 scanReq.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700871 scanReq.requestType = eCSR_SCAN_IDLE_MODE_SCAN;
872 p11dScanCmd->u.scanCmd.reason = eCsrScanIdleScan;
873 scanReq.maxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
874 scanReq.minChnTime = pMac->roam.configParam.nActiveMinChnTime;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -0800875
Madan Mohan Koyyalamudi04a65f02013-07-26 13:58:38 +0530876 scanReq.maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
877 scanReq.minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700878 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700879
Jeff Johnson295189b2012-06-20 16:38:30 -0700880 status = csrScanCopyRequest(pMac, &p11dScanCmd->u.scanCmd.u.scanRequest, &scanReq);
881 //Free the channel list
882 palFreeMemory( pMac->hHdd, pChnInfo->ChannelList );
James Zmuda9ea1edd2013-04-18 18:20:54 -0700883 pChnInfo->ChannelList = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700884
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -0800885 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700886 {
887 //Start process the command
888#ifdef WLAN_AP_STA_CONCURRENCY
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530889 if (!pMac->fScanOffload)
890 status = csrQueueScanRequest(pMac, p11dScanCmd);
891 else
892 status = csrQueueSmeCommand(pMac, p11dScanCmd,
893 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700894#else
895 status = csrQueueSmeCommand(pMac, p11dScanCmd, eANI_BOOLEAN_FALSE);
896#endif
897 if( !HAL_STATUS_SUCCESS( status ) )
898 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800899 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -0700900 break;
901 }
902 }
903 else
904 {
905 break;
906 }
907 }
908 else
909 {
910 //error
911 break;
912 }
913 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700914
915 //Scan only 2G Channels if set in ini file
916 //This is mainly to reduce the First Scan duration
917 //Once we turn on Wifi
918 if(pMac->scan.fFirstScanOnly2GChnl)
919 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800920 smsLog( pMac, LOG1, FL("Scanning only 2G Channels during first scan"));
Jeff Johnsone7245742012-09-05 17:12:55 -0700921 csrScan2GOnyRequest(pMac, pScanCmd, pScanRequest);
922 }
923
Jeff Johnson295189b2012-06-20 16:38:30 -0700924 status = csrScanCopyRequest(pMac, &pScanCmd->u.scanCmd.u.scanRequest, pScanRequest);
925 if(HAL_STATUS_SUCCESS(status))
926 {
927 //Start process the command
928#ifdef WLAN_AP_STA_CONCURRENCY
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530929 if (!pMac->fScanOffload)
930 status = csrQueueScanRequest(pMac,pScanCmd);
931 else
932 status = csrQueueSmeCommand(pMac, pScanCmd,
933 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700934#else
935 status = csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_FALSE);
936#endif
937 if( !HAL_STATUS_SUCCESS( status ) )
938 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800939 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -0700940 break;
941 }
942 }
943 else
944 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800945 smsLog( pMac, LOGE, FL(" fail to copy request status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -0700946 break;
947 }
948 }
949 else
950 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800951 smsLog( pMac, LOGE, FL(" pScanCmd is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700952 break;
953 }
954 }
955 } while(0);
956 if(!HAL_STATUS_SUCCESS(status) && pScanCmd)
957 {
958 if( eCsrScanIdleScan == pScanCmd->u.scanCmd.reason )
959 {
960 //Set the flag back for restarting idle scan
961 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE;
962 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800963 smsLog( pMac, LOGE, FL(" failed with status = %d, releasing scan cmd"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -0700964 csrReleaseCommandScan(pMac, pScanCmd);
965 }
966
967 return (status);
968}
969
970
971eHalStatus csrScanRequestResult(tpAniSirGlobal pMac)
972{
973 eHalStatus status = eHAL_STATUS_SUCCESS;
974 tSmeCmd *pScanCmd;
975
976 if(pMac->scan.fScanEnable)
977 {
978 pScanCmd = csrGetCommandBuffer(pMac);
979 if(pScanCmd)
980 {
981 pScanCmd->command = eSmeCommandScan;
982 palZeroMemory(pMac->hHdd, &pScanCmd->u.scanCmd, sizeof(tScanCmd));
983 pScanCmd->u.scanCmd.callback = NULL;
984 pScanCmd->u.scanCmd.pContext = NULL;
985 pScanCmd->u.scanCmd.reason = eCsrScanGetResult;
986 //Need to make the following atomic
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -0700987 pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID; //let it wrap around
Jeff Johnson295189b2012-06-20 16:38:30 -0700988 status = csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_FALSE);
989 if( !HAL_STATUS_SUCCESS( status ) )
990 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800991 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -0700992 csrReleaseCommandScan(pMac, pScanCmd);
993 }
994 }
995 else
996 {
997 //log error
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800998 smsLog(pMac, LOGE, FL("can not obtain a common buffer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700999 status = eHAL_STATUS_RESOURCES;
1000 }
1001 }
1002
1003 return (status);
1004}
1005
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001006#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1007eHalStatus csrScanRequestLfrResult(tpAniSirGlobal pMac, tANI_U32 sessionId,
1008 csrScanCompleteCallback callback, void *pContext)
1009{
1010 eHalStatus status = eHAL_STATUS_SUCCESS;
1011 tSmeCmd *pScanCmd;
1012
1013 if (pMac->scan.fScanEnable)
1014 {
1015 pScanCmd = csrGetCommandBuffer(pMac);
1016 if (pScanCmd)
1017 {
1018 pScanCmd->command = eSmeCommandScan;
1019 pScanCmd->sessionId = sessionId;
1020 palZeroMemory(pMac->hHdd, &pScanCmd->u.scanCmd, sizeof(tScanCmd));
1021 pScanCmd->u.scanCmd.callback = callback;
1022 pScanCmd->u.scanCmd.pContext = pContext;
1023 pScanCmd->u.scanCmd.reason = eCsrScanGetLfrResult;
1024 //Need to make the following atomic
1025 pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID; //let it wrap around
1026 status = csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_TRUE);
1027 if ( !HAL_STATUS_SUCCESS( status ) )
1028 {
1029 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
1030 csrReleaseCommandScan(pMac, pScanCmd);
1031 }
1032 }
1033 else
1034 {
1035 //log error
1036 smsLog(pMac, LOGE, FL("can not obtain a common buffer\n"));
1037 status = eHAL_STATUS_RESOURCES;
1038 }
1039 }
1040
1041 return (status);
1042}
1043#endif //WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Jeff Johnson295189b2012-06-20 16:38:30 -07001044
1045eHalStatus csrScanAllChannels(tpAniSirGlobal pMac, eCsrRequestType reqType)
1046{
1047 eHalStatus status = eHAL_STATUS_SUCCESS;
1048 tANI_U32 scanId;
1049 tCsrScanRequest scanReq;
1050
1051 palZeroMemory(pMac->hHdd, &scanReq, sizeof(tCsrScanRequest));
1052 scanReq.BSSType = eCSR_BSS_TYPE_ANY;
1053 scanReq.scanType = eSIR_ACTIVE_SCAN;
1054 scanReq.requestType = reqType;
1055 scanReq.maxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1056 scanReq.minChnTime = pMac->roam.configParam.nActiveMinChnTime;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001057 scanReq.maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
1058 scanReq.minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001059 //Scan with invalid sessionId.
1060 //This results in SME using the first available session to scan.
1061 status = csrScanRequest(pMac, CSR_SESSION_ID_INVALID, &scanReq,
1062 &scanId, NULL, NULL);
1063
1064 return (status);
1065}
1066
1067
1068
1069
1070eHalStatus csrIssueRoamAfterLostlinkScan(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamReason reason)
1071{
1072 eHalStatus status = eHAL_STATUS_FAILURE;
1073 tScanResultHandle hBSSList = NULL;
1074 tCsrScanResultFilter *pScanFilter = NULL;
1075 tANI_U32 roamId = 0;
1076 tCsrRoamProfile *pProfile = NULL;
1077 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
1078
Jeff Johnson32d95a32012-09-10 13:15:23 -07001079 if(!pSession)
1080 {
1081 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
1082 return eHAL_STATUS_FAILURE;
1083 }
1084
Jeff Johnson295189b2012-06-20 16:38:30 -07001085 do
1086 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001087 smsLog(pMac, LOG1, " csrIssueRoamAfterLostlinkScan called");
Jeff Johnson295189b2012-06-20 16:38:30 -07001088 if(pSession->fCancelRoaming)
1089 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001090 smsLog(pMac, LOGW, " lostlink roaming is cancelled");
Jeff Johnson295189b2012-06-20 16:38:30 -07001091 csrScanStartIdleScan(pMac);
1092 status = eHAL_STATUS_SUCCESS;
1093 break;
1094 }
1095 //Here is the profile we need to connect to
1096 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
1097 if(!HAL_STATUS_SUCCESS(status))
1098 break;
1099 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
1100 if(NULL == pSession->pCurRoamProfile)
1101 {
1102 pScanFilter->EncryptionType.numEntries = 1;
1103 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
1104 }
1105 else
1106 {
1107 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
1108 status = palAllocateMemory(pMac->hHdd, (void **)&pProfile, sizeof(tCsrRoamProfile));
1109 if(!HAL_STATUS_SUCCESS(status))
1110 break;
1111 palZeroMemory(pMac->hHdd, pProfile, sizeof(tCsrRoamProfile));
1112 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
1113 if(!HAL_STATUS_SUCCESS(status))
1114 break;
1115 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
1116 }//We have a profile
1117 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
1118 if(HAL_STATUS_SUCCESS(status))
1119 {
1120 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
1121 if(HAL_STATUS_SUCCESS(status))
1122 {
1123 if(eCsrLostLink1 == reason)
1124 {
1125 //we want to put the last connected BSS to the very beginning, if possible
1126 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
1127 }
1128 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, reason,
1129 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE);
1130 if(!HAL_STATUS_SUCCESS(status))
1131 {
1132 csrScanResultPurge(pMac, hBSSList);
1133 }
1134 }//Have scan result
1135 }
1136 }while(0);
1137 if(pScanFilter)
1138 {
1139 //we need to free memory for filter if profile exists
1140 csrFreeScanFilter(pMac, pScanFilter);
1141 palFreeMemory(pMac->hHdd, pScanFilter);
1142 }
1143 if(NULL != pProfile)
1144 {
1145 csrReleaseProfile(pMac, pProfile);
1146 palFreeMemory(pMac->hHdd, (void *)pProfile);
1147 }
1148
1149 return (status);
1150}
1151
1152
Madan Mohan Koyyalamudide1b5bc2013-07-12 00:56:04 +05301153eHalStatus csrScanGetScanChnInfo(tpAniSirGlobal pMac, tANI_U8 sessionId,
1154 void *pContext, void *callback)
Jeff Johnson295189b2012-06-20 16:38:30 -07001155{
1156 eHalStatus status = eHAL_STATUS_SUCCESS;
1157 tSmeCmd *pScanCmd;
1158
1159 if(pMac->scan.fScanEnable)
1160 {
1161 pScanCmd = csrGetCommandBuffer(pMac);
1162 if(pScanCmd)
1163 {
1164 pScanCmd->command = eSmeCommandScan;
1165 palZeroMemory(pMac->hHdd, &pScanCmd->u.scanCmd, sizeof(tScanCmd));
Jeff Johnson32d95a32012-09-10 13:15:23 -07001166 pScanCmd->u.scanCmd.callback = callback;
1167 pScanCmd->u.scanCmd.pContext = pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001168 pScanCmd->u.scanCmd.reason = eCsrScanGetScanChnInfo;
1169 //Need to make the following atomic
1170 pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around
Madan Mohan Koyyalamudide1b5bc2013-07-12 00:56:04 +05301171 pScanCmd->sessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07001172 status = csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_FALSE);
1173 if( !HAL_STATUS_SUCCESS( status ) )
1174 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001175 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07001176 csrReleaseCommandScan(pMac, pScanCmd);
1177 }
1178 }
1179 else
1180 {
1181 //log error
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001182 smsLog(pMac, LOGE, FL("can not obtain a common buffer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001183 status = eHAL_STATUS_RESOURCES;
1184 }
1185 }
1186
1187 return (status);
1188}
1189
1190
1191eHalStatus csrScanHandleFailedLostlink1(tpAniSirGlobal pMac, tANI_U32 sessionId)
1192{
1193 eHalStatus status = eHAL_STATUS_FAILURE;
1194 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
1195
Jeff Johnson32d95a32012-09-10 13:15:23 -07001196 if(!pSession)
1197 {
1198 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
1199 return eHAL_STATUS_FAILURE;
1200 }
1201
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001202 smsLog(pMac, LOGW, " Lostlink scan 1 failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07001203 if(pSession->fCancelRoaming)
1204 {
1205 csrScanStartIdleScan(pMac);
1206 }
1207 else if(pSession->pCurRoamProfile)
1208 {
1209 //We fail lostlink1 but there may be other BSS in the cached result fit the profile. Give it a try first
1210 if(pSession->pCurRoamProfile->SSIDs.numOfSSIDs == 0 ||
1211 pSession->pCurRoamProfile->SSIDs.numOfSSIDs > 1)
1212 {
1213 //try lostlink scan2
1214 status = csrScanRequestLostLink2(pMac, sessionId);
1215 }
1216 else if(!pSession->pCurRoamProfile->ChannelInfo.ChannelList ||
1217 pSession->pCurRoamProfile->ChannelInfo.ChannelList[0] == 0)
1218 {
1219 //go straight to lostlink scan3
1220 status = csrScanRequestLostLink3(pMac, sessionId);
1221 }
1222 else
1223 {
1224 //we are done with lostlink
1225 if(csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_FALSE, eCSR_ROAM_RESULT_FAILURE))
1226 {
1227 csrScanStartIdleScan(pMac);
1228 }
1229 status = eHAL_STATUS_SUCCESS;
1230 }
1231 }
1232 else
1233 {
1234 status = csrScanRequestLostLink3(pMac, sessionId);
1235 }
1236
1237 return (status);
1238}
1239
1240
1241
1242eHalStatus csrScanHandleFailedLostlink2(tpAniSirGlobal pMac, tANI_U32 sessionId)
1243{
1244 eHalStatus status = eHAL_STATUS_FAILURE;
1245 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
1246
Jeff Johnson32d95a32012-09-10 13:15:23 -07001247 if(!pSession)
1248 {
1249 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
1250 return eHAL_STATUS_FAILURE;
1251 }
1252
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001253 smsLog(pMac, LOGW, " Lostlink scan 2 failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07001254 if(pSession->fCancelRoaming)
1255 {
1256 csrScanStartIdleScan(pMac);
1257 }
1258 else if(!pSession->pCurRoamProfile || !pSession->pCurRoamProfile->ChannelInfo.ChannelList ||
1259 pSession->pCurRoamProfile->ChannelInfo.ChannelList[0] == 0)
1260 {
1261 //try lostlink scan3
1262 status = csrScanRequestLostLink3(pMac, sessionId);
1263 }
1264 else
1265 {
1266 //we are done with lostlink
1267 if(csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_FALSE, eCSR_ROAM_RESULT_FAILURE))
1268 {
1269 csrScanStartIdleScan(pMac);
1270 }
1271 }
1272
1273 return (status);
1274}
1275
1276
1277
1278eHalStatus csrScanHandleFailedLostlink3(tpAniSirGlobal pMac, tANI_U32 sessionId)
1279{
1280 eHalStatus status = eHAL_STATUS_SUCCESS;
1281
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001282 smsLog(pMac, LOGW, " Lostlink scan 3 failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07001283 if(eANI_BOOLEAN_TRUE == csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_FALSE, eCSR_ROAM_RESULT_FAILURE))
1284 {
1285 //we are done with lostlink
1286 csrScanStartIdleScan(pMac);
1287 }
1288
1289 return (status);
1290}
1291
1292
1293
1294
1295//Lostlink1 scan is to actively scan the last connected profile's SSID on all matched BSS channels.
1296//If no roam profile (it should not), it is like lostlinkscan3
1297eHalStatus csrScanRequestLostLink1( tpAniSirGlobal pMac, tANI_U32 sessionId )
1298{
1299 eHalStatus status = eHAL_STATUS_SUCCESS;
1300 tSmeCmd *pCommand = NULL;
1301 tANI_U8 bAddr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
1302 tCsrScanResultFilter *pScanFilter = NULL;
1303 tScanResultHandle hBSSList = NULL;
1304 tCsrScanResultInfo *pScanResult = NULL;
1305 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
1306
Jeff Johnson32d95a32012-09-10 13:15:23 -07001307 if(!pSession)
1308 {
1309 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
1310 return eHAL_STATUS_FAILURE;
1311 }
1312
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001313 smsLog(pMac, LOGW, FL(" called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001314 do
1315 {
1316 pCommand = csrGetCommandBuffer(pMac);
1317 if(!pCommand)
1318 {
1319 status = eHAL_STATUS_RESOURCES;
1320 break;
1321 }
1322 palZeroMemory(pMac->hHdd, &pCommand->u.scanCmd, sizeof(tScanCmd));
1323 pCommand->command = eSmeCommandScan;
1324 pCommand->sessionId = (tANI_U8)sessionId;
1325 pCommand->u.scanCmd.reason = eCsrScanLostLink1;
1326 pCommand->u.scanCmd.callback = NULL;
1327 pCommand->u.scanCmd.pContext = NULL;
1328 pCommand->u.scanCmd.u.scanRequest.maxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1329 pCommand->u.scanCmd.u.scanRequest.minChnTime = pMac->roam.configParam.nActiveMinChnTime;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001330 pCommand->u.scanCmd.u.scanRequest.maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
1331 pCommand->u.scanCmd.u.scanRequest.minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001332 pCommand->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN;
1333 if(pSession->connectedProfile.SSID.length)
1334 {
1335 status = palAllocateMemory(pMac->hHdd, (void **)&pCommand->u.scanCmd.u.scanRequest.SSIDs.SSIDList, sizeof(tCsrSSIDInfo));
1336 if(!HAL_STATUS_SUCCESS(status))
1337 {
1338 break;
1339 }
1340 pCommand->u.scanCmd.u.scanRequest.SSIDs.numOfSSIDs = 1;
1341 palCopyMemory(pMac->hHdd, &pCommand->u.scanCmd.u.scanRequest.SSIDs.SSIDList[0].SSID,
1342 &pSession->connectedProfile.SSID, sizeof(tSirMacSSid));
1343 }
1344 else
1345 {
1346 pCommand->u.scanCmd.u.scanRequest.SSIDs.numOfSSIDs = 0;
1347 }
1348 if(pSession->pCurRoamProfile)
1349 {
1350 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
1351 if(!HAL_STATUS_SUCCESS(status))
1352 {
1353 break;
1354 }
1355 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
1356 status = csrRoamPrepareFilterFromProfile(pMac, pSession->pCurRoamProfile, pScanFilter);
1357 if(!HAL_STATUS_SUCCESS(status))
1358 {
1359 break;
1360 }
1361 //Don't change variable status here because whether we can get result or not, the command goes to PE.
1362 //The status is also used to indicate whether the command is queued. Not success meaning not queue
1363 if(HAL_STATUS_SUCCESS((csrScanGetResult(pMac, pScanFilter, &hBSSList))) && hBSSList)
1364 {
1365 tANI_U8 i, nChn = 0;
1366 status = palAllocateMemory(pMac->hHdd, (void **)&pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList,
1367 WNI_CFG_VALID_CHANNEL_LIST_LEN);
1368 if(!HAL_STATUS_SUCCESS(status))
1369 {
1370 break;
1371 }
1372 while(((pScanResult = csrScanResultGetNext(pMac, hBSSList)) != NULL) &&
1373 nChn < WNI_CFG_VALID_CHANNEL_LIST_LEN)
1374 {
1375 for(i = 0; i < nChn; i++)
1376 {
1377 if(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[i] ==
1378 pScanResult->BssDescriptor.channelId)
1379 {
1380 break;
1381 }
1382 }
1383 if(i == nChn)
1384 {
1385 pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[nChn++] = pScanResult->BssDescriptor.channelId;
1386 }
1387 }
1388 //Include the last connected BSS' channel
1389 if(csrRoamIsChannelValid(pMac, pSession->connectedProfile.operationChannel))
1390 {
1391 for(i = 0; i < nChn; i++)
1392 {
1393 if(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[i] ==
1394 pSession->connectedProfile.operationChannel)
1395 {
1396 break;
1397 }
1398 }
1399 if(i == nChn)
1400 {
1401 pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[nChn++] = pSession->connectedProfile.operationChannel;
1402 }
1403 }
1404 pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = nChn;
1405 }
1406 else
1407 {
1408 if(csrRoamIsChannelValid(pMac, pSession->connectedProfile.operationChannel))
1409 {
1410 status = palAllocateMemory(pMac->hHdd, (void **)&pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList,
1411 1);
1412 //just try the last connected channel
1413 if(HAL_STATUS_SUCCESS(status))
1414 {
1415 pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[0] = pSession->connectedProfile.operationChannel;
1416 pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = 1;
1417 }
1418 else
1419 {
1420 break;
1421 }
1422 }
1423 }
1424 }
1425 palCopyMemory(pMac->hHdd, &pCommand->u.scanCmd.u.scanRequest.bssid, bAddr, sizeof(tCsrBssid));
1426 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
1427 if( !HAL_STATUS_SUCCESS( status ) )
1428 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001429 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07001430 break;
1431 }
1432 } while( 0 );
1433
1434 if(!HAL_STATUS_SUCCESS(status))
1435 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001436 smsLog(pMac, LOGW, " csrScanRequestLostLink1 failed with status %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001437 if(pCommand)
1438 {
1439 csrReleaseCommandScan(pMac, pCommand);
1440 }
1441 status = csrScanHandleFailedLostlink1( pMac, sessionId );
1442 }
1443 if(pScanFilter)
1444 {
1445 csrFreeScanFilter(pMac, pScanFilter);
1446 palFreeMemory(pMac->hHdd, pScanFilter);
1447 }
1448 if(hBSSList)
1449 {
1450 csrScanResultPurge(pMac, hBSSList);
1451 }
1452
1453 return( status );
1454}
1455
1456
1457//Lostlink2 scan is to actively scan the all SSIDs of the last roaming profile's on all matched BSS channels.
1458//Since MAC doesn't support multiple SSID, we scan all SSIDs and filter them afterwards
1459eHalStatus csrScanRequestLostLink2( tpAniSirGlobal pMac, tANI_U32 sessionId )
1460{
1461 eHalStatus status = eHAL_STATUS_SUCCESS;
1462 tANI_U8 bAddr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
1463 tCsrScanResultFilter *pScanFilter = NULL;
1464 tScanResultHandle hBSSList = NULL;
1465 tCsrScanResultInfo *pScanResult = NULL;
1466 tSmeCmd *pCommand = NULL;
1467 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
1468
Jeff Johnson32d95a32012-09-10 13:15:23 -07001469 if(!pSession)
1470 {
1471 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
1472 return eHAL_STATUS_FAILURE;
1473 }
1474
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001475 smsLog(pMac, LOGW, FL(" called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001476 do
1477 {
1478 pCommand = csrGetCommandBuffer(pMac);
1479 if(!pCommand)
1480 {
1481 status = eHAL_STATUS_RESOURCES;
1482 break;
1483 }
1484 palZeroMemory(pMac->hHdd, &pCommand->u.scanCmd, sizeof(tScanCmd));
1485 pCommand->command = eSmeCommandScan;
1486 pCommand->sessionId = (tANI_U8)sessionId;
1487 pCommand->u.scanCmd.reason = eCsrScanLostLink2;
1488 pCommand->u.scanCmd.callback = NULL;
1489 pCommand->u.scanCmd.pContext = NULL;
1490 pCommand->u.scanCmd.u.scanRequest.maxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1491 pCommand->u.scanCmd.u.scanRequest.minChnTime = pMac->roam.configParam.nActiveMinChnTime;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001492 pCommand->u.scanCmd.u.scanRequest.maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
1493 pCommand->u.scanCmd.u.scanRequest.minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001494 pCommand->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN;
1495 if(pSession->pCurRoamProfile)
1496 {
1497 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
1498 if(!HAL_STATUS_SUCCESS(status))
1499 {
1500 break;
1501 }
1502 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
1503 status = csrRoamPrepareFilterFromProfile(pMac, pSession->pCurRoamProfile, pScanFilter);
1504 if(!HAL_STATUS_SUCCESS(status))
1505 {
1506 break;
1507 }
1508 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
1509 if(!HAL_STATUS_SUCCESS(status))
1510 {
1511 break;
1512 }
1513 if(hBSSList)
1514 {
1515 tANI_U8 i, nChn = 0;
1516 status = palAllocateMemory(pMac->hHdd, (void **)&pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList,
1517 WNI_CFG_VALID_CHANNEL_LIST_LEN);
1518 if(!HAL_STATUS_SUCCESS(status))
1519 {
1520 break;
1521 }
1522 while(((pScanResult = csrScanResultGetNext(pMac, hBSSList)) != NULL) &&
1523 nChn < WNI_CFG_VALID_CHANNEL_LIST_LEN)
1524 {
1525 for(i = 0; i < nChn; i++)
1526 {
1527 if(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[i] ==
1528 pScanResult->BssDescriptor.channelId)
1529 {
1530 break;
1531 }
1532 }
1533 if(i == nChn)
1534 {
1535 pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[nChn++] = pScanResult->BssDescriptor.channelId;
1536 }
1537 }
1538 pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = nChn;
1539 }
1540 }
1541 palCopyMemory(pMac->hHdd, &pCommand->u.scanCmd.u.scanRequest.bssid, bAddr, sizeof(tCsrBssid));
1542 //Put to the head in pending queue
1543 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
1544 if( !HAL_STATUS_SUCCESS( status ) )
1545 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001546 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07001547 break;
1548 }
1549 } while( 0 );
1550
1551 if(!HAL_STATUS_SUCCESS(status))
1552 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001553 smsLog(pMac, LOGW, " csrScanRequestLostLink2 failed with status %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001554 if(pCommand)
1555 {
1556 csrReleaseCommandScan(pMac, pCommand);
1557 }
1558 status = csrScanHandleFailedLostlink2( pMac, sessionId );
1559 }
1560 if(pScanFilter)
1561 {
1562 csrFreeScanFilter(pMac, pScanFilter);
1563 palFreeMemory(pMac->hHdd, pScanFilter);
1564 }
1565 if(hBSSList)
1566 {
1567 csrScanResultPurge(pMac, hBSSList);
1568 }
1569
1570 return( status );
1571}
1572
1573
1574//To actively scan all valid channels
1575eHalStatus csrScanRequestLostLink3( tpAniSirGlobal pMac, tANI_U32 sessionId )
1576{
1577 eHalStatus status = eHAL_STATUS_SUCCESS;
1578 tSmeCmd *pCommand;
1579 tANI_U8 bAddr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
1580
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001581 smsLog(pMac, LOGW, FL(" called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001582 do
1583 {
1584 pCommand = csrGetCommandBuffer(pMac);
1585 if(!pCommand)
1586 {
1587 status = eHAL_STATUS_RESOURCES;
1588 break;
1589 }
1590 palZeroMemory(pMac->hHdd, &pCommand->u.scanCmd, sizeof(tScanCmd));
1591 pCommand->command = eSmeCommandScan;
1592 pCommand->sessionId = (tANI_U8)sessionId;
1593 pCommand->u.scanCmd.reason = eCsrScanLostLink3;
1594 pCommand->u.scanCmd.callback = NULL;
1595 pCommand->u.scanCmd.pContext = NULL;
1596 pCommand->u.scanCmd.u.scanRequest.maxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1597 pCommand->u.scanCmd.u.scanRequest.minChnTime = pMac->roam.configParam.nActiveMinChnTime;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001598 pCommand->u.scanCmd.u.scanRequest.maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
1599 pCommand->u.scanCmd.u.scanRequest.minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001600 pCommand->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN;
1601 palCopyMemory(pMac->hHdd, &pCommand->u.scanCmd.u.scanRequest.bssid, bAddr, sizeof(tCsrBssid));
1602 //Put to the head of pending queue
1603 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
1604 if( !HAL_STATUS_SUCCESS( status ) )
1605 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001606 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07001607 break;
1608 }
1609 } while( 0 );
1610 if(!HAL_STATUS_SUCCESS(status))
1611 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001612 smsLog(pMac, LOGW, " csrScanRequestLostLink3 failed with status %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001613 if(csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_FALSE, eCSR_ROAM_RESULT_FAILURE))
1614 {
1615 csrScanStartIdleScan(pMac);
1616 }
1617 if(pCommand)
1618 {
1619 csrReleaseCommandScan(pMac, pCommand);
1620 }
1621 }
1622
1623 return( status );
1624}
1625
1626
1627eHalStatus csrScanHandleSearchForSSID(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1628{
1629 eHalStatus status = eHAL_STATUS_FAILURE;
1630 tScanResultHandle hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
1631 tCsrScanResultFilter *pScanFilter = NULL;
1632 tCsrRoamProfile *pProfile = pCommand->u.scanCmd.pToRoamProfile;
1633 tANI_U32 sessionId = pCommand->sessionId;
1634#ifdef FEATURE_WLAN_BTAMP_UT_RF
1635 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
1636#endif
1637 do
1638 {
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07001639#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1640 //if this scan is for LFR
1641 if(pMac->roam.neighborRoamInfo.uOsRequestedHandoff)
1642 {
1643 //notify LFR state m/c
1644 if(eHAL_STATUS_SUCCESS != csrNeighborRoamSssidScanDone(pMac, eHAL_STATUS_SUCCESS))
1645 {
Varun Reddy Yeturue3af4282013-06-07 00:56:52 -07001646 csrNeighborRoamStartLfrScan(pMac);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07001647 }
1648 status = eHAL_STATUS_SUCCESS;
1649 break;
1650 }
1651#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001652 //If there is roam command waiting, ignore this roam because the newer roam command is the one to execute
1653 if(csrIsRoamCommandWaitingForSession(pMac, sessionId))
1654 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001655 smsLog(pMac, LOGW, FL(" aborts because roam command waiting"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001656 break;
1657 }
1658 if(pProfile == NULL)
1659 break;
1660 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
1661 if(!HAL_STATUS_SUCCESS(status))
1662 break;
1663 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
1664 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
1665 if(!HAL_STATUS_SUCCESS(status))
1666 break;
1667 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
1668 if(!HAL_STATUS_SUCCESS(status))
1669 break;
1670 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
1671 pCommand->u.scanCmd.roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE);
1672 if(!HAL_STATUS_SUCCESS(status))
1673 {
1674 break;
1675 }
1676 }while(0);
1677 if(!HAL_STATUS_SUCCESS(status))
1678 {
1679 if(CSR_INVALID_SCANRESULT_HANDLE != hBSSList)
1680 {
1681 csrScanResultPurge(pMac, hBSSList);
1682 }
1683 //We haven't done anything to this profile
1684 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.scanCmd.roamId,
1685 eCSR_ROAM_ASSOCIATION_FAILURE, eCSR_ROAM_RESULT_FAILURE);
1686 //In case we have nothing else to do, restart idle scan
1687 if(csrIsConnStateDisconnected(pMac, sessionId) && !csrIsRoamCommandWaiting(pMac))
1688 {
1689 status = csrScanStartIdleScan(pMac);
1690 }
1691#ifdef FEATURE_WLAN_BTAMP_UT_RF
1692 //In case of WDS station, let it retry.
1693 if( CSR_IS_WDS_STA(pProfile) )
1694 {
1695 //Save the roma profile so we can retry
1696 csrFreeRoamProfile( pMac, sessionId );
1697 if (HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
1698 (void **)&pSession->pCurRoamProfile,
1699 sizeof(tCsrRoamProfile))))
1700 {
1701 palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile));
1702 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
1703 }
1704 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
1705 }
1706#endif
1707 }
1708 if(pScanFilter)
1709 {
1710 csrFreeScanFilter(pMac, pScanFilter);
1711 palFreeMemory(pMac->hHdd, pScanFilter);
1712 }
1713
1714 return (status);
1715}
1716
1717
1718eHalStatus csrScanHandleSearchForSSIDFailure(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1719{
1720 eHalStatus status = eHAL_STATUS_SUCCESS;
1721 tANI_U32 sessionId = pCommand->sessionId;
1722 tCsrRoamProfile *pProfile = pCommand->u.scanCmd.pToRoamProfile;
1723 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07001724#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1725 //if this scan is for LFR
1726 if(pMac->roam.neighborRoamInfo.uOsRequestedHandoff)
1727 {
1728 //notify LFR state m/c
1729 if(eHAL_STATUS_SUCCESS != csrNeighborRoamSssidScanDone(pMac, eHAL_STATUS_FAILURE))
1730 {
Varun Reddy Yeturue3af4282013-06-07 00:56:52 -07001731 csrNeighborRoamStartLfrScan(pMac);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07001732 }
1733 return eHAL_STATUS_SUCCESS;
1734 }
1735#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07001736 if(!pSession)
1737 {
1738 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
1739 return eHAL_STATUS_FAILURE;
1740 }
1741
Jeff Johnson295189b2012-06-20 16:38:30 -07001742#if defined(WLAN_DEBUG)
1743 if(pCommand->u.scanCmd.u.scanRequest.SSIDs.numOfSSIDs == 1)
1744 {
1745 char str[36];
1746 palCopyMemory(pMac->hHdd, str, pCommand->u.scanCmd.u.scanRequest.SSIDs.SSIDList[0].SSID.ssId,
1747 pCommand->u.scanCmd.u.scanRequest.SSIDs.SSIDList[0].SSID.length);
1748 str[pCommand->u.scanCmd.u.scanRequest.SSIDs.SSIDList[0].SSID.length] = 0;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001749 smsLog(pMac, LOGW, FL(" SSID = %s"), str);
Jeff Johnson295189b2012-06-20 16:38:30 -07001750 }
1751#endif
1752 //Check whether it is for start ibss. No need to do anything if it is a JOIN request
1753 if(pProfile && CSR_IS_START_IBSS(pProfile))
1754 {
1755 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
1756 pCommand->u.scanCmd.roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE);
1757 if(!HAL_STATUS_SUCCESS(status))
1758 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001759 smsLog(pMac, LOGE, FL("failed to issue startIBSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001760 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.scanCmd.roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
1761 }
1762 }
1763 else
1764 {
1765 eCsrRoamResult roamResult = eCSR_ROAM_RESULT_FAILURE;
1766
1767 if(csrIsConnStateDisconnected(pMac, sessionId) &&
1768 !csrIsRoamCommandWaitingForSession(pMac, sessionId))
1769 {
1770 status = csrScanStartIdleScan(pMac);
1771 }
1772 if((NULL == pProfile) || !csrIsBssTypeIBSS(pProfile->BSSType))
1773 {
1774 //Only indicate assoc_completion if we indicate assoc_start.
1775 if(pSession->bRefAssocStartCnt > 0)
1776 {
1777 tCsrRoamInfo *pRoamInfo = NULL, roamInfo;
1778 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
1779 pRoamInfo = &roamInfo;
1780 if(pCommand->u.roamCmd.pRoamBssEntry)
1781 {
1782 tCsrScanResult *pScanResult =
1783 GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry,
1784 tCsrScanResult, Link);
1785 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
1786 }
1787 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
1788 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
1789 pSession->bRefAssocStartCnt--;
1790 csrRoamCallCallback(pMac, sessionId, pRoamInfo,
1791 pCommand->u.scanCmd.roamId,
1792 eCSR_ROAM_ASSOCIATION_COMPLETION,
1793 eCSR_ROAM_RESULT_FAILURE);
1794 }
Madan Mohan Koyyalamudiee255f12012-09-28 15:41:19 -07001795 else
1796 {
1797 csrRoamCallCallback(pMac, sessionId, NULL,
1798 pCommand->u.scanCmd.roamId,
1799 eCSR_ROAM_ASSOCIATION_FAILURE,
1800 eCSR_ROAM_RESULT_FAILURE);
1801 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001802#ifdef FEATURE_WLAN_BTAMP_UT_RF
1803 //In case of WDS station, let it retry.
1804 if( CSR_IS_WDS_STA(pProfile) )
1805 {
1806 //Save the roma profile so we can retry
1807 csrFreeRoamProfile( pMac, sessionId );
1808 if (HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
1809 (void **)&pSession->pCurRoamProfile,
1810 sizeof(tCsrRoamProfile))))
1811 {
1812 palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile));
1813 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
1814 }
1815 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
1816 }
1817#endif
1818 }
1819 else
1820 {
1821 roamResult = eCSR_ROAM_RESULT_IBSS_START_FAILED;
1822 }
1823 csrRoamCompletion(pMac, sessionId, NULL, pCommand, roamResult, eANI_BOOLEAN_FALSE);
1824 }
1825
1826 return (status);
1827}
1828
1829
1830//After scan for cap changes, issue a roaming command to either reconnect to the AP or pick another one to connect
1831eHalStatus csrScanHandleCapChangeScanComplete(tpAniSirGlobal pMac, tANI_U32 sessionId)
1832{
1833 eHalStatus status = eHAL_STATUS_FAILURE;
1834 tScanResultHandle hBSSList = NULL;
1835 tCsrScanResultFilter *pScanFilter = NULL;
1836 tANI_U32 roamId = 0;
1837 tCsrRoamProfile *pProfile = NULL;
1838 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
1839
1840 do
1841 {
1842 //Here is the profile we need to connect to
1843 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
1844 if(!HAL_STATUS_SUCCESS(status))
1845 break;
1846 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
1847 if(NULL == pSession) break;
1848 if(NULL == pSession->pCurRoamProfile)
1849 {
1850 pScanFilter->EncryptionType.numEntries = 1;
1851 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
1852 }
1853 else
1854 {
1855 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
1856 status = palAllocateMemory(pMac->hHdd, (void **)&pProfile, sizeof(tCsrRoamProfile));
1857 if(!HAL_STATUS_SUCCESS(status))
1858 break;
1859 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
1860 if(!HAL_STATUS_SUCCESS(status))
1861 break;
1862 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
1863 }//We have a profile
1864 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
1865 if(HAL_STATUS_SUCCESS(status))
1866 {
1867 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
1868 if(HAL_STATUS_SUCCESS(status))
1869 {
1870 //we want to put the last connected BSS to the very beginning, if possible
1871 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
1872 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList,
1873 eCsrCapsChange, 0, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE);
1874 if(!HAL_STATUS_SUCCESS(status))
1875 {
1876 csrScanResultPurge(pMac, hBSSList);
1877 }
1878 }//Have scan result
1879 else
1880 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001881 smsLog(pMac, LOGW, FL("cannot find matching BSS of %02X-%02X-%02X-%02X-%02X-%02X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001882 pSession->connectedProfile.bssid[0],
1883 pSession->connectedProfile.bssid[1],
1884 pSession->connectedProfile.bssid[2],
1885 pSession->connectedProfile.bssid[3],
1886 pSession->connectedProfile.bssid[4],
1887 pSession->connectedProfile.bssid[5]);
1888 //Disconnect
1889 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1890 }
1891 }
1892 }while(0);
1893 if(pScanFilter)
1894 {
1895 csrFreeScanFilter(pMac, pScanFilter);
1896 palFreeMemory(pMac->hHdd, pScanFilter);
1897 }
1898 if(NULL != pProfile)
1899 {
1900 csrReleaseProfile(pMac, pProfile);
1901 palFreeMemory(pMac->hHdd, pProfile);
1902 }
1903
1904 return (status);
1905}
1906
1907
1908
1909eHalStatus csrScanResultPurge(tpAniSirGlobal pMac, tScanResultHandle hScanList)
1910{
1911 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
1912 tScanResultList *pScanList = (tScanResultList *)hScanList;
1913
1914 if(pScanList)
1915 {
1916 status = csrLLScanPurgeResult(pMac, &pScanList->List);
1917 csrLLClose(&pScanList->List);
1918 palFreeMemory(pMac->hHdd, pScanList);
1919 }
1920 return (status);
1921}
1922
1923
1924static tANI_U32 csrGetBssPreferValue(tpAniSirGlobal pMac, int rssi)
1925{
1926 tANI_U32 ret = 0;
1927 int i = CSR_NUM_RSSI_CAT - 1;
1928
1929 while(i >= 0)
1930 {
1931 if(rssi >= pMac->roam.configParam.RSSICat[i])
1932 {
1933 ret = pMac->roam.configParam.BssPreferValue[i];
1934 break;
1935 }
1936 i--;
1937 };
1938
1939 return (ret);
1940}
1941
1942
1943//Return a CapValue base on the capabilities of a BSS
1944static tANI_U32 csrGetBssCapValue(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
1945{
1946 tANI_U32 ret = CSR_BSS_CAP_VALUE_NONE;
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001947#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1948 if(CSR_IS_ROAM_PREFER_5GHZ(pMac))
1949 {
1950 if((pBssDesc) && CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
1951 {
1952 ret += CSR_BSS_CAP_VALUE_5GHZ;
1953 }
1954 }
1955#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001956 if( pIes )
1957 {
1958 //We only care about 11N capability
1959 if(pIes->HTCaps.present)
1960 {
1961 ret += CSR_BSS_CAP_VALUE_HT;
1962 }
1963 if(CSR_IS_QOS_BSS(pIes))
1964 {
1965 ret += CSR_BSS_CAP_VALUE_WMM;
1966 //Give advantage to UAPSD
1967 if(CSR_IS_UAPSD_BSS(pIes))
1968 {
1969 ret += CSR_BSS_CAP_VALUE_UAPSD;
1970 }
1971 }
1972 }
1973
1974 return (ret);
1975}
1976
1977
1978//To check whther pBss1 is better than pBss2
1979static tANI_BOOLEAN csrIsBetterBss(tCsrScanResult *pBss1, tCsrScanResult *pBss2)
1980{
1981 tANI_BOOLEAN ret;
1982
1983 if(CSR_IS_BETTER_PREFER_VALUE(pBss1->preferValue, pBss2->preferValue))
1984 {
1985 ret = eANI_BOOLEAN_TRUE;
1986 }
1987 else if(CSR_IS_EQUAL_PREFER_VALUE(pBss1->preferValue, pBss2->preferValue))
1988 {
1989 if(CSR_IS_BETTER_CAP_VALUE(pBss1->capValue, pBss2->capValue))
1990 {
1991 ret = eANI_BOOLEAN_TRUE;
1992 }
1993 else
1994 {
1995 ret = eANI_BOOLEAN_FALSE;
1996 }
1997 }
1998 else
1999 {
2000 ret = eANI_BOOLEAN_FALSE;
2001 }
2002
2003 return (ret);
2004}
2005
2006
Srikant Kuppa866893f2012-12-27 17:28:14 -08002007#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002008//Add the channel to the occupiedChannels array
2009static void csrScanAddToOccupiedChannels(
Srikant Kuppa866893f2012-12-27 17:28:14 -08002010 tpAniSirGlobal pMac,
2011 tCsrScanResult *pResult,
2012 tCsrChannel *pOccupiedChannels,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002013 tDot11fBeaconIEs *pIes)
2014{
2015 eHalStatus status;
2016 tANI_U8 channel;
2017 tANI_U8 numOccupiedChannels = pOccupiedChannels->numChannels;
2018 tANI_U8 *pOccupiedChannelList = pOccupiedChannels->channelList;
2019
2020 channel = pResult->Result.BssDescriptor.channelId;
2021
2022 if (!csrIsChannelPresentInList(pOccupiedChannelList, numOccupiedChannels, channel)
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002023 && csrNeighborRoamConnectedProfileMatch(pMac, pResult, pIes))
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002024 {
Srikant Kuppa866893f2012-12-27 17:28:14 -08002025 status = csrAddToChannelListFront(pOccupiedChannelList, numOccupiedChannels, channel);
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002026 if(HAL_STATUS_SUCCESS(status))
Srikant Kuppa866893f2012-12-27 17:28:14 -08002027 {
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002028 pOccupiedChannels->numChannels++;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002029 smsLog(pMac, LOG2, FL("%s: added channel %d to the list (count=%d)"),
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002030 __func__, channel, pOccupiedChannels->numChannels);
Srikant Kuppa866893f2012-12-27 17:28:14 -08002031 if (pOccupiedChannels->numChannels > CSR_BG_SCAN_OCCUPIED_CHANNEL_LIST_LEN)
2032 pOccupiedChannels->numChannels = CSR_BG_SCAN_OCCUPIED_CHANNEL_LIST_LEN;
2033 }
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002034 }
2035}
2036#endif
2037
Jeff Johnson295189b2012-06-20 16:38:30 -07002038//Put the BSS into the scan result list
2039//pIes can not be NULL
2040static void csrScanAddResult(tpAniSirGlobal pMac, tCsrScanResult *pResult, tDot11fBeaconIEs *pIes)
2041{
Srinivas28b5b4e2012-12-12 13:07:53 -08002042#ifdef FEATURE_WLAN_LFR
2043 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2044#endif
2045
Jeff Johnson295189b2012-06-20 16:38:30 -07002046 pResult->preferValue = csrGetBssPreferValue(pMac, (int)pResult->Result.BssDescriptor.rssi);
2047 pResult->capValue = csrGetBssCapValue(pMac, &pResult->Result.BssDescriptor, pIes);
2048 csrLLInsertTail( &pMac->scan.scanResultList, &pResult->Link, LL_ACCESS_LOCK );
Srikant Kuppa866893f2012-12-27 17:28:14 -08002049#ifdef FEATURE_WLAN_LFR
Srinivas28b5b4e2012-12-12 13:07:53 -08002050 if(0 == pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
2051 {
2052 /* Build the occupied channel list, only if "gNeighborScanChannelList" is
2053 NOT set in the cfg.ini file */
2054 csrScanAddToOccupiedChannels(pMac, pResult, &pMac->scan.occupiedChannels, pIes);
2055 }
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002056#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002057}
2058
2059
2060eHalStatus csrScanGetResult(tpAniSirGlobal pMac, tCsrScanResultFilter *pFilter, tScanResultHandle *phResult)
2061{
2062 eHalStatus status;
2063 tScanResultList *pRetList;
2064 tCsrScanResult *pResult, *pBssDesc;
2065 tANI_U32 count = 0;
2066 tListElem *pEntry;
2067 tANI_U32 bssLen, allocLen;
2068 eCsrEncryptionType uc = eCSR_ENCRYPT_TYPE_NONE, mc = eCSR_ENCRYPT_TYPE_NONE;
2069 eCsrAuthType auth = eCSR_AUTH_TYPE_OPEN_SYSTEM;
2070 tDot11fBeaconIEs *pIes, *pNewIes;
2071 tANI_BOOLEAN fMatch;
2072
2073 if(phResult)
2074 {
2075 *phResult = CSR_INVALID_SCANRESULT_HANDLE;
2076 }
2077 status = palAllocateMemory(pMac->hHdd, (void **)&pRetList, sizeof(tScanResultList));
2078 if(HAL_STATUS_SUCCESS(status))
2079 {
2080 palZeroMemory(pMac->hHdd, pRetList, sizeof(tScanResultList));
2081 csrLLOpen(pMac->hHdd, &pRetList->List);
2082 pRetList->pCurEntry = NULL;
2083
2084 csrLLLock(&pMac->scan.scanResultList);
2085 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
2086 while( pEntry )
2087 {
2088 pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
2089 pIes = (tDot11fBeaconIEs *)( pBssDesc->Result.pvIes );
2090 //if pBssDesc->Result.pvIes is NULL, we need to free any memory allocated by csrMatchBSS
2091 //for any error condition, otherwiase, it will be freed later.
2092 //reset
2093 fMatch = eANI_BOOLEAN_FALSE;
2094 pNewIes = NULL;
2095
2096 if(pFilter)
2097 {
2098 fMatch = csrMatchBSS(pMac, &pBssDesc->Result.BssDescriptor, pFilter, &auth, &uc, &mc, &pIes);
2099 if( NULL != pIes )
2100 {
2101 //Only save it when matching
2102 if(fMatch)
2103 {
2104 if( !pBssDesc->Result.pvIes )
2105 {
2106 //csrMatchBSS allocates the memory. Simply pass it and it is freed later
2107 pNewIes = pIes;
2108 }
2109 else
2110 {
2111 //The pIes is allocated by someone else. make a copy
2112 //Only to save parsed IEs if caller provides a filter. Most likely the caller
2113 //is using to for association, hence save the parsed IEs
2114 status = palAllocateMemory(pMac->hHdd, (void **)&pNewIes, sizeof(tDot11fBeaconIEs));
2115 if( HAL_STATUS_SUCCESS( status ) )
2116 {
2117 palCopyMemory( pMac->hHdd, pNewIes, pIes, sizeof( tDot11fBeaconIEs ) );
2118 }
2119 else
2120 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002121 smsLog(pMac, LOGE, FL(" fail to allocate memory for IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002122 //Need to free memory allocated by csrMatchBSS
2123 if( !pBssDesc->Result.pvIes )
2124 {
2125 palFreeMemory(pMac->hHdd, pIes);
2126 }
2127 break;
2128 }
2129 }
2130 }//fMatch
2131 else if( !pBssDesc->Result.pvIes )
2132 {
2133 palFreeMemory(pMac->hHdd, pIes);
2134 }
2135 }
2136 }
2137 if(NULL == pFilter || fMatch)
2138 {
2139 bssLen = pBssDesc->Result.BssDescriptor.length + sizeof(pBssDesc->Result.BssDescriptor.length);
2140 allocLen = sizeof( tCsrScanResult ) + bssLen;
2141 status = palAllocateMemory(pMac->hHdd, (void **)&pResult, allocLen);
2142 if(!HAL_STATUS_SUCCESS(status))
2143 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002144 smsLog(pMac, LOGE, FL(" fail to allocate memory for scan result, len=%d"), allocLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07002145 if(pNewIes)
2146 {
2147 palFreeMemory(pMac->hHdd, pNewIes);
2148 }
2149 break;
2150 }
2151 palZeroMemory(pMac->hHdd, pResult, allocLen);
2152 pResult->capValue = pBssDesc->capValue;
2153 pResult->preferValue = pBssDesc->preferValue;
2154 pResult->ucEncryptionType = uc;
2155 pResult->mcEncryptionType = mc;
2156 pResult->authType = auth;
2157 pResult->Result.ssId = pBssDesc->Result.ssId;
2158 pResult->Result.timer = 0;
2159 //save the pIes for later use
2160 pResult->Result.pvIes = pNewIes;
2161 //save bss description
2162 status = palCopyMemory(pMac->hHdd, &pResult->Result.BssDescriptor, &pBssDesc->Result.BssDescriptor, bssLen);
2163 if(!HAL_STATUS_SUCCESS(status))
2164 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002165 smsLog(pMac, LOGE, FL(" fail to copy memory for scan result"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002166 palFreeMemory(pMac->hHdd, pResult);
2167 if(pNewIes)
2168 {
2169 palFreeMemory(pMac->hHdd, pNewIes);
2170 }
2171 break;
2172 }
2173 //No need to lock pRetList because it is locally allocated and no outside can access it at this time
2174 if(csrLLIsListEmpty(&pRetList->List, LL_ACCESS_NOLOCK))
2175 {
2176 csrLLInsertTail(&pRetList->List, &pResult->Link, LL_ACCESS_NOLOCK);
2177 }
2178 else
2179 {
2180 //To sort the list
2181 tListElem *pTmpEntry;
2182 tCsrScanResult *pTmpResult;
2183
2184 pTmpEntry = csrLLPeekHead(&pRetList->List, LL_ACCESS_NOLOCK);
2185 while(pTmpEntry)
2186 {
2187 pTmpResult = GET_BASE_ADDR( pTmpEntry, tCsrScanResult, Link );
2188 if(csrIsBetterBss(pResult, pTmpResult))
2189 {
2190 csrLLInsertEntry(&pRetList->List, pTmpEntry, &pResult->Link, LL_ACCESS_NOLOCK);
2191 //To indicate we are done
2192 pResult = NULL;
2193 break;
2194 }
2195 pTmpEntry = csrLLNext(&pRetList->List, pTmpEntry, LL_ACCESS_NOLOCK);
2196 }
2197 if(pResult != NULL)
2198 {
2199 //This one is not better than any one
2200 csrLLInsertTail(&pRetList->List, &pResult->Link, LL_ACCESS_NOLOCK);
2201 }
2202 }
2203 count++;
2204 }
2205 pEntry = csrLLNext( &pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK );
2206 }//while
2207 csrLLUnlock(&pMac->scan.scanResultList);
2208
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002209 smsLog(pMac, LOG2, FL("return %d BSS"), csrLLCount(&pRetList->List));
Jeff Johnson295189b2012-06-20 16:38:30 -07002210
2211 if( !HAL_STATUS_SUCCESS(status) || (phResult == NULL) )
2212 {
2213 //Fail or No one wants the result.
2214 csrScanResultPurge(pMac, (tScanResultHandle)pRetList);
2215 }
2216 else
2217 {
2218 if(0 == count)
2219 {
2220 //We are here meaning the there is no match
2221 csrLLClose(&pRetList->List);
2222 palFreeMemory(pMac->hHdd, pRetList);
2223 status = eHAL_STATUS_E_NULL_VALUE;
2224 }
2225 else if(phResult)
2226 {
2227 *phResult = pRetList;
2228 }
2229 }
2230 }//Allocated pRetList
2231
2232 return (status);
2233}
2234
Madan Mohan Koyyalamudiab41d0f2012-10-31 17:17:10 -07002235/*
2236 * NOTE: This routine is being added to make
2237 * sure that scan results are not being flushed
2238 * while roaming. If the scan results are flushed,
2239 * we are unable to recover from
2240 * csrRoamRoamingStateDisassocRspProcessor.
2241 * If it is needed to remove this routine,
2242 * first ensure that we recover gracefully from
2243 * csrRoamRoamingStateDisassocRspProcessor if
2244 * csrScanGetResult returns with a failure because
2245 * of not being able to find the roaming BSS.
2246 */
2247tANI_U8 csrScanFlushDenied(tpAniSirGlobal pMac)
2248{
2249 switch(pMac->roam.neighborRoamInfo.neighborRoamState) {
2250 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN:
2251 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING:
2252 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE:
2253 case eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING:
2254 return (pMac->roam.neighborRoamInfo.neighborRoamState);
2255 default:
2256 return 0;
2257 }
2258}
2259
Jeff Johnson295189b2012-06-20 16:38:30 -07002260eHalStatus csrScanFlushResult(tpAniSirGlobal pMac)
2261{
Madan Mohan Koyyalamudiab41d0f2012-10-31 17:17:10 -07002262 tANI_U8 isFlushDenied = csrScanFlushDenied(pMac);
2263 if (isFlushDenied) {
2264 smsLog(pMac, LOGW, "%s: scan flush denied in roam state %d",
2265 __func__, isFlushDenied);
2266 return eHAL_STATUS_FAILURE;
2267 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002268 return ( csrLLScanPurgeResult(pMac, &pMac->scan.scanResultList) );
2269}
2270
Madan Mohan Koyyalamudi5850f312012-11-27 19:00:25 +05302271eHalStatus csrScanFlushSelectiveResult(tpAniSirGlobal pMac, v_BOOL_t flushP2P)
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07002272{
Madan Mohan Koyyalamudi5850f312012-11-27 19:00:25 +05302273 eHalStatus status = eHAL_STATUS_SUCCESS;
2274 tListElem *pEntry,*pFreeElem;
2275 tCsrScanResult *pBssDesc;
2276 tDblLinkList *pList = &pMac->scan.scanResultList;
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07002277
Madan Mohan Koyyalamudi5850f312012-11-27 19:00:25 +05302278 csrLLLock(pList);
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07002279
Madan Mohan Koyyalamudi5850f312012-11-27 19:00:25 +05302280 pEntry = csrLLPeekHead( pList, LL_ACCESS_NOLOCK );
2281 while( pEntry != NULL)
2282 {
2283 pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
2284 if( flushP2P == vos_mem_compare( pBssDesc->Result.ssId.ssId,
2285 "DIRECT-", 7) )
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07002286 {
Madan Mohan Koyyalamudi5850f312012-11-27 19:00:25 +05302287 pFreeElem = pEntry;
2288 pEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
2289 csrLLRemoveEntry(pList, pFreeElem, LL_ACCESS_NOLOCK);
2290 csrFreeScanResultEntry( pMac, pBssDesc );
2291 continue;
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07002292 }
Madan Mohan Koyyalamudi5850f312012-11-27 19:00:25 +05302293 pEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
2294 }
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07002295
Madan Mohan Koyyalamudi5850f312012-11-27 19:00:25 +05302296 csrLLUnlock(pList);
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07002297
Madan Mohan Koyyalamudi5850f312012-11-27 19:00:25 +05302298 return (status);
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07002299}
2300
Jeff Johnson295189b2012-06-20 16:38:30 -07002301/**
2302 * csrCheck11dChannel
2303 *
2304 *FUNCTION:
2305 * This function is called from csrScanFilter11dResult function and
2306 * compare channel number with given channel list.
2307 *
2308 *LOGIC:
2309 * Check Scan result channel number with CFG channel list
2310 *
2311 *ASSUMPTIONS:
2312 *
2313 *
2314 *NOTE:
2315 *
2316 * @param channelId channel number
2317 * @param pChannelList Pointer to channel list
2318 * @param numChannels Number of channel in channel list
2319 *
2320 * @return Status
2321 */
2322
2323eHalStatus csrCheck11dChannel(tANI_U8 channelId, tANI_U8 *pChannelList, tANI_U32 numChannels)
2324{
2325 eHalStatus status = eHAL_STATUS_FAILURE;
2326 tANI_U8 i = 0;
2327
2328 for (i = 0; i < numChannels; i++)
2329 {
2330 if(pChannelList[ i ] == channelId)
2331 {
2332 status = eHAL_STATUS_SUCCESS;
2333 break;
2334 }
2335 }
2336 return status;
2337}
2338
2339/**
2340 * csrScanFilter11dResult
2341 *
2342 *FUNCTION:
2343 * This function is called from csrApplyCountryInformation function and
2344 * filter scan result based on valid channel list number.
2345 *
2346 *LOGIC:
2347 * Get scan result from scan list and Check Scan result channel number
2348 * with 11d channel list if channel number is found in 11d channel list
2349 * then do not remove scan result entry from scan list
2350 *
2351 *ASSUMPTIONS:
2352 *
2353 *
2354 *NOTE:
2355 *
2356 * @param pMac Pointer to Global MAC structure
2357 *
2358 * @return Status
2359 */
2360
2361eHalStatus csrScanFilter11dResult(tpAniSirGlobal pMac)
2362{
2363 eHalStatus status = eHAL_STATUS_SUCCESS;
2364 tListElem *pEntry,*pTempEntry;
2365 tCsrScanResult *pBssDesc;
2366 tANI_U32 len = sizeof(pMac->roam.validChannelList);
2367
2368 /* Get valid channels list from CFG */
2369 if (!HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac,
2370 pMac->roam.validChannelList, &len)))
2371 {
2372 smsLog( pMac, LOG1, "Failed to get Channel list from CFG");
2373 }
2374
2375 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_LOCK );
2376 while( pEntry )
2377 {
2378 pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
2379 pTempEntry = csrLLNext( &pMac->scan.scanResultList, pEntry,
2380 LL_ACCESS_LOCK );
2381 if(csrCheck11dChannel(pBssDesc->Result.BssDescriptor.channelId,
2382 pMac->roam.validChannelList, len))
2383 {
2384 /* Remove Scan result which does not have 11d channel */
2385 if( csrLLRemoveEntry( &pMac->scan.scanResultList, pEntry,
2386 LL_ACCESS_LOCK ))
2387 {
2388 csrFreeScanResultEntry( pMac, pBssDesc );
2389 }
2390 }
2391 pEntry = pTempEntry;
2392 }
2393 return status;
2394}
2395
2396
2397eHalStatus csrScanCopyResultList(tpAniSirGlobal pMac, tScanResultHandle hIn, tScanResultHandle *phResult)
2398{
2399 eHalStatus status = eHAL_STATUS_SUCCESS;
2400 tScanResultList *pRetList, *pInList = (tScanResultList *)hIn;
2401 tCsrScanResult *pResult, *pScanResult;
2402 tANI_U32 count = 0;
2403 tListElem *pEntry;
2404 tANI_U32 bssLen, allocLen;
2405
2406 if(phResult)
2407 {
2408 *phResult = CSR_INVALID_SCANRESULT_HANDLE;
2409 }
2410 status = palAllocateMemory(pMac->hHdd, (void **)&pRetList, sizeof(tScanResultList));
2411 if(HAL_STATUS_SUCCESS(status))
2412 {
2413 palZeroMemory(pMac->hHdd, pRetList, sizeof(tScanResultList));
2414 csrLLOpen(pMac->hHdd, &pRetList->List);
2415 pRetList->pCurEntry = NULL;
2416 csrLLLock(&pMac->scan.scanResultList);
2417 csrLLLock(&pInList->List);
2418
2419 pEntry = csrLLPeekHead( &pInList->List, LL_ACCESS_NOLOCK );
2420 while( pEntry )
2421 {
2422 pScanResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
2423 bssLen = pScanResult->Result.BssDescriptor.length + sizeof(pScanResult->Result.BssDescriptor.length);
2424 allocLen = sizeof( tCsrScanResult ) + bssLen;
2425 status = palAllocateMemory(pMac->hHdd, (void **)&pResult, allocLen);
2426 if(!HAL_STATUS_SUCCESS(status))
2427 {
2428 csrScanResultPurge(pMac, (tScanResultHandle *)pRetList);
2429 count = 0;
2430 break;
2431 }
2432 palZeroMemory(pMac->hHdd, pResult, allocLen);
2433 status = palCopyMemory(pMac->hHdd, &pResult->Result.BssDescriptor, &pScanResult->Result.BssDescriptor, bssLen);
2434 if(!HAL_STATUS_SUCCESS(status))
2435 {
2436 csrScanResultPurge(pMac, (tScanResultHandle *)pRetList);
2437 count = 0;
2438 break;
2439 }
2440 if( pScanResult->Result.pvIes )
2441 {
2442 status = palAllocateMemory(pMac->hHdd, (void **)&pResult->Result.pvIes, sizeof( tDot11fBeaconIEs ));
2443 if(!HAL_STATUS_SUCCESS(status))
2444 {
2445 //Free the memory we allocate above first
2446 palFreeMemory( pMac->hHdd, pResult );
2447 csrScanResultPurge(pMac, (tScanResultHandle *)pRetList);
2448 count = 0;
2449 break;
2450 }
2451 status = palCopyMemory(pMac->hHdd, pResult->Result.pvIes,
2452 pScanResult->Result.pvIes, sizeof( tDot11fBeaconIEs ));
2453 if(!HAL_STATUS_SUCCESS(status))
2454 {
2455 //Free the memory we allocate above first
2456 palFreeMemory( pMac->hHdd, pResult );
2457 csrScanResultPurge(pMac, (tScanResultHandle *)pRetList);
2458 count = 0;
2459 break;
2460 }
2461 }
2462 csrLLInsertTail(&pRetList->List, &pResult->Link, LL_ACCESS_LOCK);
2463 count++;
2464 pEntry = csrLLNext( &pInList->List, pEntry, LL_ACCESS_NOLOCK );
2465 }//while
2466 csrLLUnlock(&pInList->List);
2467 csrLLUnlock(&pMac->scan.scanResultList);
2468
2469 if(HAL_STATUS_SUCCESS(status))
2470 {
2471 if(0 == count)
2472 {
2473 csrLLClose(&pRetList->List);
2474 palFreeMemory(pMac->hHdd, pRetList);
2475 status = eHAL_STATUS_E_NULL_VALUE;
2476 }
2477 else if(phResult)
2478 {
2479 *phResult = pRetList;
2480 }
2481 }
2482 }//Allocated pRetList
2483
2484 return (status);
2485}
2486
2487
2488
2489eHalStatus csrScanningStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
2490{
2491 eHalStatus status = eHAL_STATUS_SUCCESS;
2492 tSirMbMsg *pMsg = (tSirMbMsg *)pMsgBuf;
2493
2494 if((eWNI_SME_SCAN_RSP == pMsg->type) || (eWNI_SME_GET_SCANNED_CHANNEL_RSP == pMsg->type))
2495 {
2496 status = csrScanSmeScanResponse( pMac, pMsgBuf );
2497 }
2498 else
2499 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002500 if(pMsg->type == eWNI_SME_UPPER_LAYER_ASSOC_CNF)
Jeff Johnson295189b2012-06-20 16:38:30 -07002501 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002502 tCsrRoamSession *pSession;
2503 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
2504 tCsrRoamInfo roamInfo;
2505 tCsrRoamInfo *pRoamInfo = NULL;
2506 tANI_U32 sessionId;
2507 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002508 smsLog( pMac, LOG1, FL("Scanning : ASSOCIATION confirmation can be given to upper layer "));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002509 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
2510 pRoamInfo = &roamInfo;
2511 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
2512 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
2513 pSession = CSR_GET_SESSION(pMac, sessionId);
2514
2515 if(!pSession)
2516 {
2517 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2518 return eHAL_STATUS_FAILURE;
2519 }
2520
2521 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
2522 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
2523 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
2524 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
2525 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
2526 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
2527 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
2528 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr, sizeof(tSirMacAddr));
2529 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pUpperLayerAssocCnf->bssId, sizeof(tCsrBssid));
2530 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
2531 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
2532 {
2533 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
2534 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
2535 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
2536 }
2537 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
2538 {
2539 vos_sleep( 100 );
2540 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
2541 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
2542 }
2543
Jeff Johnson295189b2012-06-20 16:38:30 -07002544 }
2545 else
2546 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002547
2548 if( csrIsAnySessionInConnectState( pMac ) )
2549 {
2550 //In case of we are connected, we need to check whether connect status changes
2551 //because scan may also run while connected.
2552 csrRoamCheckForLinkStatusChange( pMac, ( tSirSmeRsp * )pMsgBuf );
2553 }
2554 else
2555 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002556 smsLog( pMac, LOGW, "Message [0x%04x] received in state, when expecting Scan Response", pMsg->type );
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002557 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002558 }
2559 }
2560
2561 return (status);
2562}
2563
2564
2565
2566void csrCheckNSaveWscIe(tpAniSirGlobal pMac, tSirBssDescription *pNewBssDescr, tSirBssDescription *pOldBssDescr)
2567{
2568 int idx, len;
2569 tANI_U8 *pbIe;
2570
2571 //If failed to remove, assuming someone else got it.
2572 if((pNewBssDescr->fProbeRsp != pOldBssDescr->fProbeRsp) &&
2573 (0 == pNewBssDescr->WscIeLen))
2574 {
2575 idx = 0;
2576 len = pOldBssDescr->length - sizeof(tSirBssDescription) +
2577 sizeof(tANI_U16) + sizeof(tANI_U32) - DOT11F_IE_WSCPROBERES_MIN_LEN - 2;
2578 pbIe = (tANI_U8 *)pOldBssDescr->ieFields;
2579 //Save WPS IE if it exists
2580 pNewBssDescr->WscIeLen = 0;
2581 while(idx < len)
2582 {
2583 if((DOT11F_EID_WSCPROBERES == pbIe[0]) &&
2584 (0x00 == pbIe[2]) && (0x50 == pbIe[3]) && (0xf2 == pbIe[4]) && (0x04 == pbIe[5]))
2585 {
2586 //Founrd it
2587 if((DOT11F_IE_WSCPROBERES_MAX_LEN - 2) >= pbIe[1])
2588 {
2589 palCopyMemory(pMac->hHdd, pNewBssDescr->WscIeProbeRsp,
2590 pbIe, pbIe[1] + 2);
2591 pNewBssDescr->WscIeLen = pbIe[1] + 2;
2592 }
2593 break;
2594 }
2595 idx += pbIe[1] + 2;
2596 pbIe += pbIe[1] + 2;
2597 }
2598 }
2599}
2600
2601
2602
2603//pIes may be NULL
2604tANI_BOOLEAN csrRemoveDupBssDescription( tpAniSirGlobal pMac, tSirBssDescription *pSirBssDescr,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302605 tDot11fBeaconIEs *pIes, tAniSSID *pSsid, v_TIME_t *timer, tANI_BOOLEAN fForced )
Jeff Johnson295189b2012-06-20 16:38:30 -07002606{
2607 tListElem *pEntry;
2608
2609 tCsrScanResult *pBssDesc;
2610 tANI_BOOLEAN fRC = FALSE;
2611
2612 // Walk through all the chained BssDescriptions. If we find a chained BssDescription that
2613 // matches the BssID of the BssDescription passed in, then these must be duplicate scan
2614 // results for this Bss. In that case, remove the 'old' Bss description from the linked list.
2615 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_LOCK );
2616
2617 while( pEntry )
2618 {
2619 pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
2620
2621 // we have a duplicate scan results only when BSSID, SSID, Channel and NetworkType
2622 // matches
2623 if ( csrIsDuplicateBssDescription( pMac, &pBssDesc->Result.BssDescriptor,
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07002624 pSirBssDescr, pIes, fForced ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002625 {
2626 pSirBssDescr->rssi = (tANI_S8)( (((tANI_S32)pSirBssDescr->rssi * CSR_SCAN_RESULT_RSSI_WEIGHT ) +
2627 ((tANI_S32)pBssDesc->Result.BssDescriptor.rssi * (100 - CSR_SCAN_RESULT_RSSI_WEIGHT) )) / 100 );
2628 // Remove the 'old' entry from the list....
2629 if( csrLLRemoveEntry( &pMac->scan.scanResultList, pEntry, LL_ACCESS_LOCK ) )
2630 {
2631 // !we need to free the memory associated with this node
2632 //If failed to remove, assuming someone else got it.
2633 *pSsid = pBssDesc->Result.ssId;
2634 *timer = pBssDesc->Result.timer;
2635 csrCheckNSaveWscIe(pMac, pSirBssDescr, &pBssDesc->Result.BssDescriptor);
2636
2637 csrFreeScanResultEntry( pMac, pBssDesc );
2638 }
2639 else
2640 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002641 smsLog( pMac, LOGW, FL( " fail to remove entry" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -07002642 }
2643 fRC = TRUE;
2644
2645 // If we found a match, we can stop looking through the list.
2646 break;
2647 }
2648
2649 pEntry = csrLLNext( &pMac->scan.scanResultList, pEntry, LL_ACCESS_LOCK );
2650 }
2651
2652 return fRC;
2653}
2654
2655
2656eHalStatus csrAddPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId,
2657 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes )
2658{
2659 eHalStatus status = eHAL_STATUS_FAILURE;
2660 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2661
Jeff Johnson32d95a32012-09-10 13:15:23 -07002662 if(!pSession)
2663 {
2664 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2665 return eHAL_STATUS_FAILURE;
2666 }
2667
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002668 smsLog(pMac, LOGW, "csrAddPMKIDCandidateList called pMac->scan.NumPmkidCandidate = %d", pSession->NumPmkidCandidate);
Jeff Johnson295189b2012-06-20 16:38:30 -07002669 if( pIes )
2670 {
2671 // check if this is a RSN BSS
2672 if( pIes->RSN.present )
2673 {
2674 // Check if the BSS is capable of doing pre-authentication
2675 if( pSession->NumPmkidCandidate < CSR_MAX_PMKID_ALLOWED )
2676 {
2677
2678#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2679 {
2680 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
2681 palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type));
2682 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_CANDIDATE_FOUND;
2683 secEvent.encryptionModeMulticast =
2684 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
2685 secEvent.encryptionModeUnicast =
2686 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
2687 palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 );
2688 secEvent.authMode =
2689 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
2690 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
2691 }
2692#endif//#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2693
2694 // if yes, then add to PMKIDCandidateList
2695 status = palCopyMemory(pMac->hHdd, pSession->PmkidCandidateInfo[pSession->NumPmkidCandidate].BSSID,
2696 pBssDesc->bssId, WNI_CFG_BSSID_LEN);
2697
2698 if( HAL_STATUS_SUCCESS( status ) )
2699 {
Venkata Prathyusha Kuntupalliea7098e2013-01-31 16:08:13 -08002700 if ( (pIes->RSN.RSN_Cap[0] >> 0) & 0x1 ) // Bit 0 offirst byte - PreAuthentication Capability
Jeff Johnson295189b2012-06-20 16:38:30 -07002701 {
2702 pSession->PmkidCandidateInfo[pSession->NumPmkidCandidate].preAuthSupported = eANI_BOOLEAN_TRUE;
2703 }
2704 else
2705 {
2706 pSession->PmkidCandidateInfo[pSession->NumPmkidCandidate].preAuthSupported = eANI_BOOLEAN_FALSE;
2707 }
2708 pSession->NumPmkidCandidate++;
2709 }
2710 }
2711 else
2712 {
2713 status = eHAL_STATUS_FAILURE;
2714 }
2715 }
2716 }
2717
2718 return (status);
2719}
2720
2721//This function checks whether new AP is found for the current connected profile
2722//If it is found, it return the sessionId, else it return invalid sessionID
2723tANI_U32 csrProcessBSSDescForPMKIDList(tpAniSirGlobal pMac,
2724 tSirBssDescription *pBssDesc,
2725 tDot11fBeaconIEs *pIes)
2726{
2727 tANI_U32 i, bRet = CSR_SESSION_ID_INVALID;
2728 tCsrRoamSession *pSession;
2729 tDot11fBeaconIEs *pIesLocal = pIes;
2730
2731 if( pIesLocal || HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal)) )
2732 {
2733 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
2734 {
2735 if( CSR_IS_SESSION_VALID( pMac, i ) )
2736 {
2737 pSession = CSR_GET_SESSION( pMac, i );
2738 if( csrIsConnStateConnectedInfra( pMac, i ) &&
2739 ( eCSR_AUTH_TYPE_RSN == pSession->connectedProfile.AuthType ) )
2740 {
2741 if(csrMatchBSSToConnectProfile(pMac, &pSession->connectedProfile, pBssDesc, pIesLocal))
2742 {
2743 //this new BSS fits the current profile connected
2744 if(HAL_STATUS_SUCCESS(csrAddPMKIDCandidateList(pMac, i, pBssDesc, pIesLocal)))
2745 {
2746 bRet = i;
2747 }
2748 break;
2749 }
2750 }
2751 }
2752 }
2753 if( !pIes )
2754 {
2755 palFreeMemory(pMac->hHdd, pIesLocal);
2756 }
2757 }
2758
2759 return (tANI_U8)bRet;
2760}
2761
2762#ifdef FEATURE_WLAN_WAPI
2763eHalStatus csrAddBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId,
2764 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes )
2765{
2766 eHalStatus status = eHAL_STATUS_FAILURE;
2767 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2768
Jeff Johnson32d95a32012-09-10 13:15:23 -07002769 if(!pSession)
2770 {
2771 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2772 return eHAL_STATUS_FAILURE;
2773 }
2774
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002775 smsLog(pMac, LOGW, "csrAddBKIDCandidateList called pMac->scan.NumBkidCandidate = %d", pSession->NumBkidCandidate);
Jeff Johnson295189b2012-06-20 16:38:30 -07002776 if( pIes )
2777 {
2778 // check if this is a WAPI BSS
2779 if( pIes->WAPI.present )
2780 {
2781 // Check if the BSS is capable of doing pre-authentication
2782 if( pSession->NumBkidCandidate < CSR_MAX_BKID_ALLOWED )
2783 {
2784
2785 // if yes, then add to BKIDCandidateList
2786 status = palCopyMemory(pMac->hHdd, pSession->BkidCandidateInfo[pSession->NumBkidCandidate].BSSID,
2787 pBssDesc->bssId, WNI_CFG_BSSID_LEN);
2788
2789 if( HAL_STATUS_SUCCESS( status ) )
2790 {
2791 if ( pIes->WAPI.preauth )
2792 {
2793 pSession->BkidCandidateInfo[pSession->NumBkidCandidate].preAuthSupported = eANI_BOOLEAN_TRUE;
2794 }
2795 else
2796 {
2797 pSession->BkidCandidateInfo[pSession->NumBkidCandidate].preAuthSupported = eANI_BOOLEAN_FALSE;
2798 }
2799 pSession->NumBkidCandidate++;
2800 }
2801 }
2802 else
2803 {
2804 status = eHAL_STATUS_FAILURE;
2805 }
2806 }
2807 }
2808
2809 return (status);
2810}
2811
2812//This function checks whether new AP is found for the current connected profile
2813//if so add to BKIDCandidateList
2814tANI_BOOLEAN csrProcessBSSDescForBKIDList(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
2815 tDot11fBeaconIEs *pIes)
2816{
2817 tANI_BOOLEAN fRC = FALSE;
2818 tDot11fBeaconIEs *pIesLocal = pIes;
2819 tANI_U32 sessionId;
2820 tCsrRoamSession *pSession;
2821
2822 if( pIesLocal || HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal)) )
2823 {
2824 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
2825 {
2826 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2827 {
2828 pSession = CSR_GET_SESSION( pMac, sessionId );
2829 if( csrIsConnStateConnectedInfra( pMac, sessionId ) &&
2830 eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == pSession->connectedProfile.AuthType)
2831 {
2832 if(csrMatchBSSToConnectProfile(pMac, &pSession->connectedProfile,pBssDesc, pIesLocal))
2833 {
2834 //this new BSS fits the current profile connected
2835 if(HAL_STATUS_SUCCESS(csrAddBKIDCandidateList(pMac, sessionId, pBssDesc, pIesLocal)))
2836 {
2837 fRC = TRUE;
2838 }
2839 }
2840 }
2841 }
2842 }
2843 if(!pIes)
2844 {
2845 palFreeMemory(pMac->hHdd, pIesLocal);
2846 }
2847
2848 }
2849 return fRC;
2850}
2851
2852#endif
2853
2854
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07002855static void csrMoveTempScanResultsToMainList( tpAniSirGlobal pMac, tANI_U8 reason )
Jeff Johnson295189b2012-06-20 16:38:30 -07002856{
2857 tListElem *pEntry;
Agarwal Ashishd9d72602013-09-13 00:06:17 +05302858 tListElem *pEntryTemp;
2859 tListElem *pNext;
Jeff Johnson295189b2012-06-20 16:38:30 -07002860 tCsrScanResult *pBssDescription;
2861 tANI_S8 cand_Bss_rssi;
Agarwal Ashishd9d72602013-09-13 00:06:17 +05302862 tANI_S8 rssi_of_current_country;
Jeff Johnson295189b2012-06-20 16:38:30 -07002863 tANI_BOOLEAN fDupBss;
2864#ifdef FEATURE_WLAN_WAPI
2865 tANI_BOOLEAN fNewWapiBSSForCurConnection = eANI_BOOLEAN_FALSE;
2866#endif /* FEATURE_WLAN_WAPI */
2867 tDot11fBeaconIEs *pIesLocal = NULL;
2868 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
2869 tAniSSID tmpSsid;
2870 v_TIME_t timer=0;
Agarwal Ashishd9d72602013-09-13 00:06:17 +05302871 tCsrBssid bssid_temp = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
Jeff Johnson295189b2012-06-20 16:38:30 -07002872
2873 tmpSsid.length = 0;
2874 cand_Bss_rssi = -128; // RSSI coming from PE is -ve
Agarwal Ashishd9d72602013-09-13 00:06:17 +05302875 rssi_of_current_country = -128;
Jeff Johnson295189b2012-06-20 16:38:30 -07002876
2877 // remove the BSS descriptions from temporary list
2878 while( ( pEntry = csrLLRemoveTail( &pMac->scan.tempScanResults, LL_ACCESS_LOCK ) ) != NULL)
2879 {
2880 pBssDescription = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
2881
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002882 smsLog( pMac, LOGW, "...Bssid= %02x-%02x-%02x-%02x-%02x-%02x chan= %d, rssi = -%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002883 pBssDescription->Result.BssDescriptor.bssId[ 0 ], pBssDescription->Result.BssDescriptor.bssId[ 1 ],
2884 pBssDescription->Result.BssDescriptor.bssId[ 2 ], pBssDescription->Result.BssDescriptor.bssId[ 3 ],
2885 pBssDescription->Result.BssDescriptor.bssId[ 4 ], pBssDescription->Result.BssDescriptor.bssId[ 5 ],
2886 pBssDescription->Result.BssDescriptor.channelId,
2887 pBssDescription->Result.BssDescriptor.rssi * (-1) );
2888
2889 //At this time, pBssDescription->Result.pvIes may be NULL
2890 pIesLocal = (tDot11fBeaconIEs *)( pBssDescription->Result.pvIes );
2891 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pBssDescription->Result.BssDescriptor, &pIesLocal))) )
2892 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002893 smsLog(pMac, LOGE, FL(" Cannot pared IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002894 csrFreeScanResultEntry(pMac, pBssDescription);
2895 continue;
2896 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302897 fDupBss = csrRemoveDupBssDescription( pMac, &pBssDescription->Result.BssDescriptor, pIesLocal, &tmpSsid, &timer, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07002898 //Check whether we have reach out limit, but don't lose the LFR candidates came from FW
2899 if( CSR_SCAN_IS_OVER_BSS_LIMIT(pMac)
2900#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2901 && !( eCsrScanGetLfrResult == reason )
2902#endif
2903 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002904 {
2905 //Limit reach
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002906 smsLog(pMac, LOGW, FL(" BSS limit reached"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002907 //Free the resources
2908 if( (pBssDescription->Result.pvIes == NULL) && pIesLocal )
2909 {
2910 palFreeMemory(pMac->hHdd, pIesLocal);
2911 }
2912 csrFreeScanResultEntry(pMac, pBssDescription);
2913 //Continue because there may be duplicated BSS
2914 continue;
2915 }
2916 // check for duplicate scan results
2917 if ( !fDupBss )
2918 {
2919 //Found a new BSS
2920 sessionId = csrProcessBSSDescForPMKIDList(pMac,
2921 &pBssDescription->Result.BssDescriptor, pIesLocal);
2922 if( CSR_SESSION_ID_INVALID != sessionId)
2923 {
2924 csrRoamCallCallback(pMac, sessionId, NULL, 0,
2925 eCSR_ROAM_SCAN_FOUND_NEW_BSS, eCSR_ROAM_RESULT_NONE);
2926 }
2927 }
2928 else
2929 {
2930 //Check if the new one has SSID it it, if not, use the older SSID if it exists.
2931 if( (0 == pBssDescription->Result.ssId.length) && tmpSsid.length )
2932 {
2933 //New BSS has a hidden SSID and old one has the SSID. Keep the SSID only
2934 //if diff of saved SSID time and current time is less than 1 min to avoid
2935 //side effect of saving SSID with old one is that if AP changes its SSID while remain
2936 //hidden, we may never see it and also to address the requirement of
2937 //When we remove hidden ssid from the profile i.e., forget the SSID via
2938 // GUI that SSID shouldn't see in the profile
2939 if( (vos_timer_get_system_time() - timer) <= HIDDEN_TIMER)
2940 {
2941 pBssDescription->Result.timer = timer;
2942 pBssDescription->Result.ssId = tmpSsid;
2943 }
2944 }
2945 }
2946
Agarwal Ashishd9d72602013-09-13 00:06:17 +05302947 //Find a good AP for 11d info
2948 if ( csrIs11dSupported( pMac ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002949 {
Agarwal Ashishd9d72602013-09-13 00:06:17 +05302950 if (cand_Bss_rssi < pBssDescription->Result.BssDescriptor.rssi)
Jeff Johnson295189b2012-06-20 16:38:30 -07002951 {
2952 // check if country information element is present
Agarwal Ashishd9d72602013-09-13 00:06:17 +05302953 if (pIesLocal->Country.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07002954 {
2955 cand_Bss_rssi = pBssDescription->Result.BssDescriptor.rssi;
Agarwal Ashishd9d72602013-09-13 00:06:17 +05302956 smsLog(pMac, LOGW, FL("11d AP Bssid " MAC_ADDRESS_STR
2957 " chan= %d, rssi = -%d, countryCode %c%c"),
2958 MAC_ADDR_ARRAY( pBssDescription->Result.BssDescriptor.bssId),
2959 pBssDescription->Result.BssDescriptor.channelId,
2960 pBssDescription->Result.BssDescriptor.rssi * (-1),
2961 pIesLocal->Country.country[0],pIesLocal->Country.country[1] );
2962 //Getting BSSID for best AP in scan result.
2963 palCopyMemory(pMac->hHdd, bssid_temp,
2964 pBssDescription->Result.BssDescriptor.bssId, sizeof(tSirMacAddr));
2965
Jeff Johnson295189b2012-06-20 16:38:30 -07002966 }
2967
2968 }
2969 }
Agarwal Ashishd9d72602013-09-13 00:06:17 +05302970 //get current rssi for BSS from which country code is acquired.
2971 if ( csrIs11dSupported(pMac) && (csrIsMacAddressEqual(pMac,
2972 &pMac->scan.currentCountryBssid,
2973 &pBssDescription->Result.BssDescriptor.bssId) ))
2974 {
2975 smsLog(pMac, LOGW, FL("Information about current country Bssid "
2976 MAC_ADDRESS_STR
2977 " chan= %d, rssi = -%d, countryCode %c%c"),
2978 MAC_ADDR_ARRAY( pBssDescription->Result.BssDescriptor.bssId),
2979 pBssDescription->Result.BssDescriptor.channelId,
2980 pBssDescription->Result.BssDescriptor.rssi * (-1),
2981 pIesLocal->Country.country[0],pIesLocal->Country.country[1] );
2982 rssi_of_current_country = pBssDescription->Result.BssDescriptor.rssi ;
2983 }
2984
Jeff Johnson295189b2012-06-20 16:38:30 -07002985
Madan Mohan Koyyalamudi527935a2012-12-04 16:41:16 -08002986
Jeff Johnson295189b2012-06-20 16:38:30 -07002987 // append to main list
2988 csrScanAddResult(pMac, pBssDescription, pIesLocal);
Agarwal Ashishd9d72602013-09-13 00:06:17 +05302989 if ( (pBssDescription->Result.pvIes == NULL) && pIesLocal )
Jeff Johnson295189b2012-06-20 16:38:30 -07002990 {
2991 palFreeMemory(pMac->hHdd, pIesLocal);
2992 }
2993 }
2994
Agarwal Ashishd9d72602013-09-13 00:06:17 +05302995 // Calculating 30% of current rssi is an idea for not to change
2996 // country code so freq.
2997 if (rssi_of_current_country != -128)
2998 {
2999 rssi_of_current_country = rssi_of_current_country
3000 - THIRTY_PERCENT(rssi_of_current_country);
3001 }
3002
3003 if ((rssi_of_current_country <= cand_Bss_rssi ) || rssi_of_current_country == -128)
3004 {
3005 csrLLLock(&pMac->scan.scanResultList);
3006 pEntryTemp = csrLLPeekHead(&pMac->scan.scanResultList, LL_ACCESS_NOLOCK);
3007 while ( NULL != pEntryTemp)
3008 {
3009 pNext = csrLLNext(&pMac->scan.scanResultList, pEntryTemp,
3010 LL_ACCESS_NOLOCK);
3011 pBssDescription = GET_BASE_ADDR( pEntryTemp, tCsrScanResult, Link );
3012 pIesLocal = (tDot11fBeaconIEs *)( pBssDescription->Result.pvIes );
3013 // Need to traverse whole scan list to get description for best 11d AP.
3014 if (csrIsMacAddressEqual(pMac, (tCsrBssid *)&bssid_temp,
3015 (tCsrBssid *) pBssDescription->Result.BssDescriptor.bssId))
3016 {
3017 palCopyMemory(pMac->hHdd, pMac->scan.currentCountryBssid,
3018 bssid_temp, sizeof(tSirMacAddr));
3019 // Best AP should be passed to update reg domain.
3020 csrLearnCountryInformation( pMac, &pBssDescription->Result.BssDescriptor,
3021 pIesLocal, eANI_BOOLEAN_FALSE );
3022 break;
3023 }
3024 pEntryTemp = pNext;
3025 }
3026 csrLLUnlock(&pMac->scan.scanResultList);
3027 }
3028
3029
Jeff Johnson295189b2012-06-20 16:38:30 -07003030 //Tush: If we can find the current 11d info in any of the scan results, or
3031 // a good enough AP with the 11d info from the scan results then no need to
3032 // get into ambiguous state
3033 if(pMac->scan.fAmbiguous11dInfoFound)
3034 {
3035 if((pMac->scan.fCurrent11dInfoMatch) || (cand_Bss_rssi != -128))
3036 {
3037 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
3038 }
3039 }
3040
3041#ifdef FEATURE_WLAN_WAPI
3042 if(fNewWapiBSSForCurConnection)
3043 {
3044 //remember it first
3045 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_SCAN_FOUND_NEW_BSS, eCSR_ROAM_RESULT_NEW_WAPI_BSS);
3046 }
3047#endif /* FEATURE_WLAN_WAPI */
3048
3049 return;
3050}
3051
3052
3053static tCsrScanResult *csrScanSaveBssDescription( tpAniSirGlobal pMac, tSirBssDescription *pBSSDescription,
3054 tDot11fBeaconIEs *pIes)
3055{
3056 tCsrScanResult *pCsrBssDescription = NULL;
3057 tANI_U32 cbBSSDesc;
3058 tANI_U32 cbAllocated;
3059 eHalStatus halStatus;
3060
3061 // figure out how big the BSS description is (the BSSDesc->length does NOT
3062 // include the size of the length field itself).
3063 cbBSSDesc = pBSSDescription->length + sizeof( pBSSDescription->length );
3064
3065 cbAllocated = sizeof( tCsrScanResult ) + cbBSSDesc;
3066
3067 halStatus = palAllocateMemory( pMac->hHdd, (void **)&pCsrBssDescription, cbAllocated );
3068 if ( HAL_STATUS_SUCCESS(halStatus) )
3069 {
3070 palZeroMemory( pMac->hHdd, pCsrBssDescription, cbAllocated );
3071 pCsrBssDescription->AgingCount = (tANI_S32)pMac->roam.configParam.agingCount;
3072 palCopyMemory(pMac->hHdd, &pCsrBssDescription->Result.BssDescriptor, pBSSDescription, cbBSSDesc );
3073#if defined(VOSS_ENSBALED)
3074 VOS_ASSERT( pCsrBssDescription->Result.pvIes == NULL );
3075#endif
3076 csrScanAddResult(pMac, pCsrBssDescription, pIes);
3077 }
3078
3079 return( pCsrBssDescription );
3080}
3081
3082// Append a Bss Description...
3083tCsrScanResult *csrScanAppendBssDescription( tpAniSirGlobal pMac,
3084 tSirBssDescription *pSirBssDescription,
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07003085 tDot11fBeaconIEs *pIes, tANI_BOOLEAN fForced )
Jeff Johnson295189b2012-06-20 16:38:30 -07003086{
3087 tCsrScanResult *pCsrBssDescription = NULL;
3088 tAniSSID tmpSsid;
3089 v_TIME_t timer = 0;
3090 int result;
3091
3092 tmpSsid.length = 0;
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07003093 result = csrRemoveDupBssDescription( pMac, pSirBssDescription, pIes, &tmpSsid, &timer, fForced );
Jeff Johnson295189b2012-06-20 16:38:30 -07003094 pCsrBssDescription = csrScanSaveBssDescription( pMac, pSirBssDescription, pIes );
3095 if (result && (pCsrBssDescription != NULL))
3096 {
3097 //Check if the new one has SSID it it, if not, use the older SSID if it exists.
3098 if( (0 == pCsrBssDescription->Result.ssId.length) && tmpSsid.length )
3099 {
3100 //New BSS has a hidden SSID and old one has the SSID. Keep the SSID only
3101 //if diff of saved SSID time and current time is less than 1 min to avoid
3102 //side effect of saving SSID with old one is that if AP changes its SSID while remain
3103 //hidden, we may never see it and also to address the requirement of
3104 //When we remove hidden ssid from the profile i.e., forget the SSID via
3105 // GUI that SSID shouldn't see in the profile
3106 if((vos_timer_get_system_time()-timer) <= HIDDEN_TIMER)
3107 {
3108 pCsrBssDescription->Result.ssId = tmpSsid;
3109 pCsrBssDescription->Result.timer = timer;
3110 }
3111 }
3112 }
3113
3114
3115 return( pCsrBssDescription );
3116}
3117
3118
3119
3120void csrPurgeChannelPower( tpAniSirGlobal pMac, tDblLinkList *pChannelList )
3121{
3122 tCsrChannelPowerInfo *pChannelSet;
3123 tListElem *pEntry;
3124
3125 csrLLLock(pChannelList);
3126 // Remove the channel sets from the learned list and put them in the free list
3127 while( ( pEntry = csrLLRemoveHead( pChannelList, LL_ACCESS_NOLOCK ) ) != NULL)
3128 {
3129 pChannelSet = GET_BASE_ADDR( pEntry, tCsrChannelPowerInfo, link );
3130 if( pChannelSet )
3131 {
3132 palFreeMemory( pMac->hHdd, pChannelSet );
3133 }
3134 }
3135 csrLLUnlock(pChannelList);
3136 return;
3137}
3138
3139
3140/*
3141 * Save the channelList into the ultimate storage as the final stage of channel
3142 * Input: pCountryInfo -- the country code (e.g. "USI"), channel list, and power limit are all stored inside this data structure
3143 */
Jeff Johnsone7245742012-09-05 17:12:55 -07003144eHalStatus csrSaveToChannelPower2G_5G( tpAniSirGlobal pMac, tANI_U32 tableSize, tSirMacChanInfo *channelTable )
Jeff Johnson295189b2012-06-20 16:38:30 -07003145{
3146 tANI_U32 i = tableSize / sizeof( tSirMacChanInfo );
3147 tSirMacChanInfo *pChannelInfo;
3148 tCsrChannelPowerInfo *pChannelSet;
3149 tANI_BOOLEAN f2GHzInfoFound = FALSE;
3150 tANI_BOOLEAN f2GListPurged = FALSE, f5GListPurged = FALSE;
3151 eHalStatus halStatus;
3152
3153 pChannelInfo = channelTable;
3154 // atleast 3 bytes have to be remaining -- from "countryString"
3155 while ( i-- )
3156 {
3157 halStatus = palAllocateMemory( pMac->hHdd, (void **)&pChannelSet, sizeof(tCsrChannelPowerInfo) );
3158 if ( eHAL_STATUS_SUCCESS == halStatus )
3159 {
3160 palZeroMemory(pMac->hHdd, pChannelSet, sizeof(tCsrChannelPowerInfo));
3161 pChannelSet->firstChannel = pChannelInfo->firstChanNum;
3162 pChannelSet->numChannels = pChannelInfo->numChannels;
3163
3164 // Now set the inter-channel offset based on the frequency band the channel set lies in
Jeff Johnsone7245742012-09-05 17:12:55 -07003165 if( (CSR_IS_CHANNEL_24GHZ(pChannelSet->firstChannel)) &&
Madan Mohan Koyyalamudi5904d7c2012-09-24 13:49:03 -07003166 ((pChannelSet->firstChannel + (pChannelSet->numChannels - 1)) <= CSR_MAX_24GHz_CHANNEL_NUMBER) )
Jeff Johnsone7245742012-09-05 17:12:55 -07003167
Jeff Johnson295189b2012-06-20 16:38:30 -07003168 {
3169 pChannelSet->interChannelOffset = 1;
3170 f2GHzInfoFound = TRUE;
3171 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003172 else if ( (CSR_IS_CHANNEL_5GHZ(pChannelSet->firstChannel)) &&
Madan Mohan Koyyalamudi5904d7c2012-09-24 13:49:03 -07003173 ((pChannelSet->firstChannel + ((pChannelSet->numChannels - 1) * 4)) <= CSR_MAX_5GHz_CHANNEL_NUMBER) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003174 {
3175 pChannelSet->interChannelOffset = 4;
3176 f2GHzInfoFound = FALSE;
3177 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003178 else
3179 {
Madan Mohan Koyyalamudi5904d7c2012-09-24 13:49:03 -07003180 smsLog( pMac, LOGW, FL("Invalid Channel %d Present in Country IE"),
Jeff Johnsone7245742012-09-05 17:12:55 -07003181 pChannelSet->firstChannel);
3182 palFreeMemory(pMac->hHdd, pChannelSet);
3183 return eHAL_STATUS_FAILURE;
3184 }
3185
Jeff Johnson295189b2012-06-20 16:38:30 -07003186 pChannelSet->txPower = CSR_ROAM_MIN( pChannelInfo->maxTxPower, pMac->roam.configParam.nTxPowerCap );
3187
3188 if( f2GHzInfoFound )
3189 {
3190 if( !f2GListPurged )
3191 {
3192 // purge previous results if found new
3193 csrPurgeChannelPower( pMac, &pMac->scan.channelPowerInfoList24 );
3194 f2GListPurged = TRUE;
3195 }
3196
3197 if(CSR_IS_OPERATING_BG_BAND(pMac))
3198 {
3199 // add to the list of 2.4 GHz channel sets
3200 csrLLInsertTail( &pMac->scan.channelPowerInfoList24, &pChannelSet->link, LL_ACCESS_LOCK );
3201 }
3202 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003203 smsLog( pMac, LOGW, FL("Adding 11B/G channels in 11A mode -- First Channel is %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003204 pChannelSet->firstChannel);
3205 palFreeMemory(pMac->hHdd, pChannelSet);
3206 }
3207 }
3208 else
3209 {
3210 // 5GHz info found
3211 if( !f5GListPurged )
3212 {
3213 // purge previous results if found new
3214 csrPurgeChannelPower( pMac, &pMac->scan.channelPowerInfoList5G );
3215 f5GListPurged = TRUE;
3216 }
3217
3218 if(CSR_IS_OPERATING_A_BAND(pMac))
3219 {
3220 // add to the list of 5GHz channel sets
3221 csrLLInsertTail( &pMac->scan.channelPowerInfoList5G, &pChannelSet->link, LL_ACCESS_LOCK );
3222 }
3223 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003224 smsLog( pMac, LOGW, FL("Adding 11A channels in B/G mode -- First Channel is %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003225 pChannelSet->firstChannel);
3226 palFreeMemory(pMac->hHdd, pChannelSet);
3227 }
3228 }
3229 }
3230
3231 pChannelInfo++; // move to next entry
3232 }
3233
Jeff Johnsone7245742012-09-05 17:12:55 -07003234 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003235}
3236
Gopichand Nakkalac178ac82013-05-30 19:53:39 +05303237static void csrClearDfsChannelList( tpAniSirGlobal pMac )
3238{
3239 tSirMbMsg *pMsg;
3240 tANI_U16 msgLen;
3241 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003242
Gopichand Nakkalac178ac82013-05-30 19:53:39 +05303243 msgLen = (tANI_U16)(sizeof( tSirMbMsg ));
3244 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
3245 if(HAL_STATUS_SUCCESS(status))
3246 {
3247 palZeroMemory(pMac->hHdd, (void *)pMsg, msgLen);
3248 pMsg->type = pal_cpu_to_be16((tANI_U16)eWNI_SME_CLEAR_DFS_CHANNEL_LIST);
3249 pMsg->msgLen = pal_cpu_to_be16(msgLen);
3250 palSendMBMessage(pMac->hHdd, pMsg);
3251 }
3252}
Jeff Johnson295189b2012-06-20 16:38:30 -07003253
3254void csrApplyPower2Current( tpAniSirGlobal pMac )
3255{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003256 smsLog( pMac, LOG3, FL(" Updating Cfg with power settings"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003257 csrSaveTxPowerToCfg( pMac, &pMac->scan.channelPowerInfoList24, WNI_CFG_MAX_TX_POWER_2_4 );
3258 csrSaveTxPowerToCfg( pMac, &pMac->scan.channelPowerInfoList5G, WNI_CFG_MAX_TX_POWER_5 );
3259}
3260
3261
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08003262void csrApplyChannelPowerCountryInfo( tpAniSirGlobal pMac, tCsrChannel *pChannelList, tANI_U8 *countryCode, tANI_BOOLEAN updateRiva)
Jeff Johnson295189b2012-06-20 16:38:30 -07003263{
Gopichand Nakkala10ba6fc2013-04-23 20:30:01 +05303264 int i, j, count, countryIndex = -1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003265 eNVChannelEnabledType channelEnabledType;
3266 tANI_U8 numChannels = 0;
3267 tANI_U8 tempNumChannels = 0;
Gopichand Nakkala10ba6fc2013-04-23 20:30:01 +05303268 tANI_U8 channelIgnore = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003269 tCsrChannel ChannelList;
Gopichand Nakkala10ba6fc2013-04-23 20:30:01 +05303270
Jeff Johnson295189b2012-06-20 16:38:30 -07003271 if( pChannelList->numChannels )
3272 {
Gopichand Nakkala10ba6fc2013-04-23 20:30:01 +05303273 for(count=0; count < MAX_COUNTRY_IGNORE; count++)
3274 {
3275 if(vos_mem_compare(countryCode, countryIgnoreList[count].countryCode,
3276 VOS_COUNTRY_CODE_LEN))
3277 {
3278 countryIndex = count;
3279 break;
3280 }
3281 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003282 tempNumChannels = CSR_MIN(pChannelList->numChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN);
3283 /* If user doesn't want to scan the DFS channels lets trim them from
3284 the valid channel list*/
Gopichand Nakkala10ba6fc2013-04-23 20:30:01 +05303285 for(i=0; i < tempNumChannels; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07003286 {
Gopichand Nakkala10ba6fc2013-04-23 20:30:01 +05303287 channelIgnore = FALSE;
3288 if( FALSE == pMac->scan.fEnableDFSChnlScan )
3289 {
3290 channelEnabledType =
3291 vos_nv_getChannelEnabledState(pChannelList->channelList[i]);
3292 }
3293 else
3294 {
Madan Mohan Koyyalamudi3f65e312012-11-06 15:31:12 -08003295 channelEnabledType = NV_CHANNEL_ENABLE;
Gopichand Nakkala10ba6fc2013-04-23 20:30:01 +05303296 }
3297 if( NV_CHANNEL_ENABLE == channelEnabledType )
3298 {
3299 if( countryIndex != -1 )
3300 {
3301 for(j=0; j < countryIgnoreList[countryIndex].channelCount; j++)
3302 {
3303 if( pChannelList->channelList[i] ==
3304 countryIgnoreList[countryIndex].channelList[j] )
3305 {
3306 channelIgnore = TRUE;
3307 break;
3308 }
3309 }
3310 }
3311 if( FALSE == channelIgnore )
3312 {
3313 ChannelList.channelList[numChannels] = pChannelList->channelList[i];
3314 numChannels++;
3315 }
3316 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003317 }
Gopichand Nakkala10ba6fc2013-04-23 20:30:01 +05303318 ChannelList.numChannels = numChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07003319 csrSetCfgValidChannelList(pMac, ChannelList.channelList, ChannelList.numChannels);
3320 // extend scan capability
Gopichand Nakkala10ba6fc2013-04-23 20:30:01 +05303321 // build a scan list based on the channel list : channel# + active/passive scan
3322 csrSetCfgScanControlList(pMac, countryCode, &ChannelList);
Gopichand Nakkalac178ac82013-05-30 19:53:39 +05303323 /*Send msg to Lim to clear DFS channel list */
3324 csrClearDfsChannelList(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07003325#ifdef FEATURE_WLAN_SCAN_PNO
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08003326 if (updateRiva)
3327 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003328 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, FL(" Sending 11d PNO info to Riva"));
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08003329 // Send HAL UpdateScanParams message
3330 pmcUpdateScanParams(pMac, &(pMac->roam.configParam), &ChannelList, TRUE);
3331 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003332#endif // FEATURE_WLAN_SCAN_PNO
3333 }
3334 else
3335 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003336 smsLog( pMac, LOGE, FL(" 11D channel list is empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003337 }
3338 csrApplyPower2Current( pMac ); // Store the channel+power info in the global place: Cfg
3339 csrSetCfgCountryCode(pMac, countryCode);
3340}
3341
3342
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08003343void csrResetCountryInformation( tpAniSirGlobal pMac, tANI_BOOLEAN fForce, tANI_BOOLEAN updateRiva )
Jeff Johnson295189b2012-06-20 16:38:30 -07003344{
3345 if( fForce || (csrIs11dSupported( pMac ) && (!pMac->scan.f11dInfoReset)))
3346 {
3347
3348#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
3349 {
3350 vos_log_802_11d_pkt_type *p11dLog;
3351 int Index;
3352
3353 WLAN_VOS_DIAG_LOG_ALLOC(p11dLog, vos_log_802_11d_pkt_type, LOG_WLAN_80211D_C);
3354 if(p11dLog)
3355 {
3356 p11dLog->eventId = WLAN_80211D_EVENT_RESET;
3357 palCopyMemory(pMac->hHdd, p11dLog->countryCode, pMac->scan.countryCodeCurrent, 3);
3358 p11dLog->numChannel = pMac->scan.base20MHzChannels.numChannels;
3359 if(p11dLog->numChannel <= VOS_LOG_MAX_NUM_CHANNEL)
3360 {
3361 palCopyMemory(pMac->hHdd, p11dLog->Channels, pMac->scan.base20MHzChannels.channelList,
3362 p11dLog->numChannel);
3363 for (Index=0; Index < pMac->scan.base20MHzChannels.numChannels; Index++)
3364 {
3365 p11dLog->TxPwr[Index] = CSR_ROAM_MIN( pMac->scan.defaultPowerTable[Index].pwr, pMac->roam.configParam.nTxPowerCap );
3366 }
3367 }
3368 if(!pMac->roam.configParam.Is11dSupportEnabled)
3369 {
3370 p11dLog->supportMultipleDomain = WLAN_80211D_DISABLED;
3371 }
3372 else if(pMac->roam.configParam.fEnforceDefaultDomain)
3373 {
3374 p11dLog->supportMultipleDomain = WLAN_80211D_NOT_SUPPORT_MULTI_DOMAIN;
3375 }
3376 else
3377 {
3378 p11dLog->supportMultipleDomain = WLAN_80211D_SUPPORT_MULTI_DOMAIN;
3379 }
3380 WLAN_VOS_DIAG_LOG_REPORT(p11dLog);
3381 }
3382 }
3383#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
3384
3385 // switch to passive scans only when 11d is enabled
3386 if( csrIs11dSupported( pMac ) )
3387 {
3388 pMac->scan.curScanType = eSIR_PASSIVE_SCAN;
3389 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003390
3391 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
3392 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
3393
Jeff Johnson295189b2012-06-20 16:38:30 -07003394 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
3395 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
3396 // ... and apply the channel list, power settings, and the country code.
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08003397 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, updateRiva );
Jeff Johnson295189b2012-06-20 16:38:30 -07003398 // clear the 11d channel list
3399 palZeroMemory( pMac->hHdd, &pMac->scan.channels11d, sizeof(pMac->scan.channels11d) );
3400 pMac->scan.f11dInfoReset = eANI_BOOLEAN_TRUE;
3401 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE;
3402 }
3403
3404 return;
3405}
3406
3407
3408eHalStatus csrResetCountryCodeInformation(tpAniSirGlobal pMac, tANI_BOOLEAN *pfRestartNeeded)
3409{
3410 eHalStatus status = eHAL_STATUS_SUCCESS;
3411 tANI_BOOLEAN fRestart = eANI_BOOLEAN_FALSE;
3412
3413 //Use the Country code and domain from EEPROM
3414 palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN);
3415 csrSetRegulatoryDomain(pMac, pMac->scan.domainIdCurrent, &fRestart);
Jeff Johnson43971f52012-07-17 12:26:56 -07003416 if( ((eANI_BOOLEAN_FALSE == fRestart) || (pfRestartNeeded == NULL) )
3417 && !csrIsInfraConnected(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07003418 {
3419 //Only reset the country info if we don't need to restart
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08003420 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003421 }
3422 if(pfRestartNeeded)
3423 {
3424 *pfRestartNeeded = fRestart;
3425 }
3426
3427 return (status);
3428}
3429
3430
3431eHalStatus csrSetCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry, tANI_BOOLEAN *pfRestartNeeded)
3432{
3433 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
3434 v_REGDOMAIN_t domainId;
3435
3436 if(pCountry)
3437 {
3438 status = csrGetRegulatoryDomainForCountry(pMac, pCountry, &domainId);
3439 if(HAL_STATUS_SUCCESS(status))
3440 {
3441 status = csrSetRegulatoryDomain(pMac, domainId, pfRestartNeeded);
3442 if(HAL_STATUS_SUCCESS(status))
3443 {
3444 //We don't need to check the pMac->roam.configParam.fEnforceDefaultDomain flag here,
3445 //csrSetRegulatoryDomain will fail if the country doesn't fit our domain criteria.
3446 palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent, pCountry, WNI_CFG_COUNTRY_CODE_LEN);
3447 if((pfRestartNeeded == NULL) || !(*pfRestartNeeded))
3448 {
3449 //Simply set it to cfg. If we need to restart, restart will apply it to the CFG
3450 csrSetCfgCountryCode(pMac, pCountry);
3451 }
3452 }
3453 }
3454 }
3455
3456 return (status);
3457}
3458
3459
3460
3461//caller allocated memory for pNumChn and pChnPowerInfo
3462//As input, *pNumChn has the size of the array of pChnPowerInfo
3463//Upon return, *pNumChn has the number of channels assigned.
3464void csrGetChannelPowerInfo( tpAniSirGlobal pMac, tDblLinkList *pList,
3465 tANI_U32 *pNumChn, tChannelListWithPower *pChnPowerInfo)
3466{
3467 tListElem *pEntry;
3468 tANI_U32 chnIdx = 0, idx;
3469 tCsrChannelPowerInfo *pChannelSet;
3470
3471 //Get 2.4Ghz first
3472 pEntry = csrLLPeekHead( pList, LL_ACCESS_LOCK );
3473 while( pEntry && (chnIdx < *pNumChn) )
3474 {
3475 pChannelSet = GET_BASE_ADDR( pEntry, tCsrChannelPowerInfo, link );
3476 if ( 1 != pChannelSet->interChannelOffset )
3477 {
3478 for( idx = 0; (idx < pChannelSet->numChannels) && (chnIdx < *pNumChn); idx++ )
3479 {
3480 pChnPowerInfo[chnIdx].chanId = (tANI_U8)(pChannelSet->firstChannel + ( idx * pChannelSet->interChannelOffset ));
3481 pChnPowerInfo[chnIdx++].pwr = pChannelSet->txPower;
3482 }
3483 }
3484 else
3485 {
3486 for( idx = 0; (idx < pChannelSet->numChannels) && (chnIdx < *pNumChn); idx++ )
3487 {
3488 pChnPowerInfo[chnIdx].chanId = (tANI_U8)(pChannelSet->firstChannel + idx);
3489 pChnPowerInfo[chnIdx++].pwr = pChannelSet->txPower;
3490 }
3491 }
3492
3493 pEntry = csrLLNext( pList, pEntry, LL_ACCESS_LOCK );
3494 }
3495 *pNumChn = chnIdx;
3496
3497 return ;
3498}
3499
3500
3501
3502void csrApplyCountryInformation( tpAniSirGlobal pMac, tANI_BOOLEAN fForce )
3503{
3504 v_REGDOMAIN_t domainId;
3505 eHalStatus status = eHAL_STATUS_SUCCESS;
3506
3507 do
3508 {
3509 if( !csrIs11dSupported( pMac ) || 0 == pMac->scan.channelOf11dInfo) break;
3510 if( pMac->scan.fAmbiguous11dInfoFound )
3511 {
3512 // ambiguous info found
3513 //Restore te default domain as well
3514 if(HAL_STATUS_SUCCESS(csrGetRegulatoryDomainForCountry( pMac, pMac->scan.countryCodeCurrent, &domainId )))
3515 {
3516 pMac->scan.domainIdCurrent = domainId;
3517 }
3518 else
3519 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003520 smsLog(pMac, LOGE, FL(" failed to get domain from currentCountryCode %02X%02X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003521 pMac->scan.countryCodeCurrent[0], pMac->scan.countryCodeCurrent[1]);
3522 }
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08003523 csrResetCountryInformation( pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07003524 break;
3525 }
3526 if ( pMac->scan.f11dInfoApplied && !fForce ) break;
3527 if(HAL_STATUS_SUCCESS(csrGetRegulatoryDomainForCountry( pMac, pMac->scan.countryCode11d, &domainId )))
3528 {
3529 //Check whether we need to enforce default domain
3530 if( ( !pMac->roam.configParam.fEnforceDefaultDomain ) ||
3531 (pMac->scan.domainIdCurrent == domainId) )
3532 {
3533
3534#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
3535 {
3536 vos_log_802_11d_pkt_type *p11dLog;
3537 tChannelListWithPower chnPwrInfo[WNI_CFG_VALID_CHANNEL_LIST_LEN];
3538 tANI_U32 nChnInfo = WNI_CFG_VALID_CHANNEL_LIST_LEN, nTmp;
3539
3540 WLAN_VOS_DIAG_LOG_ALLOC(p11dLog, vos_log_802_11d_pkt_type, LOG_WLAN_80211D_C);
3541 if(p11dLog)
3542 {
3543 p11dLog->eventId = WLAN_80211D_EVENT_COUNTRY_SET;
3544 palCopyMemory(pMac->hHdd, p11dLog->countryCode, pMac->scan.countryCode11d, 3);
3545 p11dLog->numChannel = pMac->scan.channels11d.numChannels;
3546 if(p11dLog->numChannel <= VOS_LOG_MAX_NUM_CHANNEL)
3547 {
3548 palCopyMemory(pMac->hHdd, p11dLog->Channels, pMac->scan.channels11d.channelList,
3549 p11dLog->numChannel);
3550 csrGetChannelPowerInfo(pMac, &pMac->scan.channelPowerInfoList24,
3551 &nChnInfo, chnPwrInfo);
3552 nTmp = nChnInfo;
3553 nChnInfo = WNI_CFG_VALID_CHANNEL_LIST_LEN - nTmp;
3554 csrGetChannelPowerInfo(pMac, &pMac->scan.channelPowerInfoList5G,
3555 &nChnInfo, &chnPwrInfo[nTmp]);
3556 for(nTmp = 0; nTmp < p11dLog->numChannel; nTmp++)
3557 {
3558 for(nChnInfo = 0; nChnInfo < WNI_CFG_VALID_CHANNEL_LIST_LEN; nChnInfo++)
3559 {
3560 if(p11dLog->Channels[nTmp] == chnPwrInfo[nChnInfo].chanId)
3561 {
3562 p11dLog->TxPwr[nTmp] = chnPwrInfo[nChnInfo].pwr;
3563 break;
3564 }
3565 }
3566 }
3567 }
3568 if(!pMac->roam.configParam.Is11dSupportEnabled)
3569 {
3570 p11dLog->supportMultipleDomain = WLAN_80211D_DISABLED;
3571 }
3572 else if(pMac->roam.configParam.fEnforceDefaultDomain)
3573 {
3574 p11dLog->supportMultipleDomain = WLAN_80211D_NOT_SUPPORT_MULTI_DOMAIN;
3575 }
3576 else
3577 {
3578 p11dLog->supportMultipleDomain = WLAN_80211D_SUPPORT_MULTI_DOMAIN;
3579 }
3580 WLAN_VOS_DIAG_LOG_REPORT(p11dLog);
3581 }
3582 }
3583#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
3584 if(pMac->scan.domainIdCurrent != domainId)
3585 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003586 smsLog(pMac, LOGW, FL("Domain Changed Old %d, new %d"),
3587 pMac->scan.domainIdCurrent, domainId);
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05303588 status = WDA_SetRegDomain(pMac, domainId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003589 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003590 if (status != eHAL_STATUS_SUCCESS)
3591 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003592 smsLog( pMac, LOGE, FL(" fail to set regId %d"), domainId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003593 }
3594 pMac->scan.domainIdCurrent = domainId;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08003595 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.channels11d, pMac->scan.countryCode11d, eANI_BOOLEAN_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07003596 // switch to active scans using this new channel list
3597 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
3598 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_TRUE;
3599 pMac->scan.f11dInfoReset = eANI_BOOLEAN_FALSE;
3600 }
3601 }
3602
3603 } while( 0 );
3604
3605 return;
3606}
3607
3608
3609
3610tANI_BOOLEAN csrSave11dCountryString( tpAniSirGlobal pMac, tANI_U8 *pCountryCode,
3611 tANI_BOOLEAN fForce)
3612{
3613 tANI_BOOLEAN fCountryStringChanged = FALSE, fUnknownCountryCode = FALSE;
3614 tANI_U32 i;
3615
3616 // convert to UPPER here so we are assured the strings are always in upper case.
3617 for( i = 0; i < 3; i++ )
3618 {
3619 pCountryCode[ i ] = (tANI_U8)csrToUpper( pCountryCode[ i ] );
3620 }
3621
3622 // Some of the 'old' Cisco 350 series AP's advertise NA as the country code (for North America ??).
3623 // NA is not a valid country code or domain so let's allow this by changing it to the proper
3624 // country code (which is US). We've also seen some NETGEAR AP's that have "XX " as the country code
3625 // with valid 2.4 GHz US channel information. If we cannot find the country code advertised in the
3626 // 11d information element, let's default to US.
3627 if ( !HAL_STATUS_SUCCESS(csrGetRegulatoryDomainForCountry( pMac, pCountryCode, NULL ) ) )
3628 {
3629 // Check the enforcement first
3630 if( pMac->roam.configParam.fEnforceDefaultDomain || pMac->roam.configParam.fEnforceCountryCodeMatch )
3631 {
3632 fUnknownCountryCode = TRUE;
3633 }
3634 else
3635 {
3636 pCountryCode[ 0 ] = 'U';
3637 pCountryCode[ 1 ] = 'S';
3638 }
3639 }
3640
3641 // We've seen some of the AP's improperly put a 0 for the third character of the country code.
3642 // spec says valid charcters are 'O' (for outdoor), 'I' for Indoor, or ' ' (space; for either).
3643 // if we see a 0 in this third character, let's change it to a ' '.
3644 if ( 0 == pCountryCode[ 2 ] )
3645 {
3646 pCountryCode[ 2 ] = ' ';
3647 }
3648
3649 if( !fUnknownCountryCode )
3650 {
3651 fCountryStringChanged = (!palEqualMemory( pMac->hHdd,
3652 pMac->scan.countryCode11d, pCountryCode, 2));
3653
3654
3655 if(( 0 == pMac->scan.countryCode11d[ 0 ] && 0 == pMac->scan.countryCode11d[ 1 ] )
3656 || (fForce))
3657 {
3658 // this is the first .11d information
3659 palCopyMemory( pMac->hHdd, pMac->scan.countryCode11d, pCountryCode, sizeof( pMac->scan.countryCode11d ) );
3660 }
3661 }
3662
3663 return( fCountryStringChanged );
3664}
3665
3666
3667void csrSaveChannelPowerForBand( tpAniSirGlobal pMac, tANI_BOOLEAN fPopulate5GBand )
3668{
3669 tANI_U32 Index, count=0;
3670 tSirMacChanInfo *pChanInfo;
3671 tSirMacChanInfo *pChanInfoStart;
Leela V Kiran Kumar Reddy Chirala6a458752013-02-16 15:41:27 -08003672 tANI_S32 maxChannelIndex;
3673
3674 maxChannelIndex = ( pMac->scan.base20MHzChannels.numChannels < WNI_CFG_VALID_CHANNEL_LIST_LEN ) ?
3675 pMac->scan.base20MHzChannels.numChannels : WNI_CFG_VALID_CHANNEL_LIST_LEN ;
Jeff Johnson295189b2012-06-20 16:38:30 -07003676
3677 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN)))
3678 {
3679 palZeroMemory(pMac->hHdd, pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
3680 pChanInfoStart = pChanInfo;
Leela V Kiran Kumar Reddy Chirala6a458752013-02-16 15:41:27 -08003681 for (Index=0; Index < maxChannelIndex; Index++)
Jeff Johnson295189b2012-06-20 16:38:30 -07003682 {
3683 if ((fPopulate5GBand && (CSR_IS_CHANNEL_5GHZ(pMac->scan.defaultPowerTable[Index].chanId))) ||
3684 (!fPopulate5GBand && (CSR_IS_CHANNEL_24GHZ(pMac->scan.defaultPowerTable[Index].chanId))) )
3685 {
Leela V Kiran Kumar Reddy Chirala6a458752013-02-16 15:41:27 -08003686 if(count >= WNI_CFG_VALID_CHANNEL_LIST_LEN)
3687 {
3688 smsLog( pMac, LOGW, FL(" csrSaveChannelPowerForBand, count exceeded, count = %d"), count);
3689 break;
3690 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003691 pChanInfo->firstChanNum = pMac->scan.defaultPowerTable[Index].chanId;
3692 pChanInfo->numChannels = 1;
3693 pChanInfo->maxTxPower = CSR_ROAM_MIN( pMac->scan.defaultPowerTable[Index].pwr, pMac->roam.configParam.nTxPowerCap );
3694 pChanInfo++;
3695 count++;
3696 }
3697 }
3698 if(count)
3699 {
3700 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
3701 }
3702 palFreeMemory(pMac->hHdd, pChanInfoStart);
3703 }
3704}
3705
3706
3707void csrSetOppositeBandChannelInfo( tpAniSirGlobal pMac )
3708{
3709 tANI_BOOLEAN fPopulate5GBand = FALSE;
3710
3711 do
3712 {
3713 // if this is not a dual band product, then we don't need to set the opposite
3714 // band info. We only work in one band so no need to look in the other band.
3715 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) ) break;
3716 // if we found channel info on the 5.0 band and...
3717 if ( CSR_IS_CHANNEL_5GHZ( pMac->scan.channelOf11dInfo ) )
3718 {
3719 // and the 2.4 band is empty, then populate the 2.4 channel info
Jeff Johnson295189b2012-06-20 16:38:30 -07003720 fPopulate5GBand = FALSE;
3721 }
3722 else
3723 {
3724 // else, we found channel info in the 2.4 GHz band. If the 5.0 band is empty
3725 // set the 5.0 band info from the 2.4 country code.
Jeff Johnson295189b2012-06-20 16:38:30 -07003726 fPopulate5GBand = TRUE;
3727 }
3728 csrSaveChannelPowerForBand( pMac, fPopulate5GBand );
3729
3730 } while( 0 );
3731}
3732
3733
3734tANI_BOOLEAN csrIsSupportedChannel(tpAniSirGlobal pMac, tANI_U8 channelId)
3735{
3736 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
3737 tANI_U32 i;
3738
3739 //Make sure it is a channel that is in our supported list.
3740 for ( i = 0; i < pMac->scan.baseChannels.numChannels; i++ )
3741 {
3742 if ( channelId == pMac->scan.baseChannels.channelList[i] )
3743 {
3744 fRet = eANI_BOOLEAN_TRUE;
3745 break;
3746 }
3747 }
3748
3749 //If it is configured to limit a set of the channels
3750 if( fRet && pMac->roam.configParam.fEnforce11dChannels )
3751 {
3752 fRet = eANI_BOOLEAN_FALSE;
3753 for ( i = 0; i < pMac->scan.base20MHzChannels.numChannels; i++ )
3754 {
3755 if ( channelId == pMac->scan.base20MHzChannels.channelList[i] )
3756 {
3757 fRet = eANI_BOOLEAN_TRUE;
3758 break;
3759 }
3760 }
3761 }
3762
3763 return (fRet);
3764}
3765
3766
3767
3768//bSize specify the buffer size of pChannelList
3769tANI_U8 csrGetChannelListFromChannelSet( tpAniSirGlobal pMac, tANI_U8 *pChannelList, tANI_U8 bSize, tCsrChannelPowerInfo *pChannelSet )
3770{
3771 tANI_U8 i, j = 0, chnId;
3772
3773 bSize = CSR_MIN(bSize, pChannelSet->numChannels);
3774 for( i = 0; i < bSize; i++ )
3775 {
3776 chnId = (tANI_U8)(pChannelSet->firstChannel + ( i * pChannelSet->interChannelOffset ));
3777 if ( csrIsSupportedChannel( pMac, chnId ) )
3778 {
3779 pChannelList[j++] = chnId;
3780 }
3781 }
3782
3783 return (j);
3784}
3785
3786
3787
3788//bSize -- specify the buffer size of pChannelList
3789void csrConstructCurrentValidChannelList( tpAniSirGlobal pMac, tDblLinkList *pChannelSetList,
3790 tANI_U8 *pChannelList, tANI_U8 bSize, tANI_U8 *pNumChannels )
3791{
3792 tListElem *pEntry;
3793 tCsrChannelPowerInfo *pChannelSet;
3794 tANI_U8 numChannels;
3795 tANI_U8 *pChannels;
3796
3797 if( pChannelSetList && pChannelList && pNumChannels )
3798 {
3799 pChannels = pChannelList;
3800 *pNumChannels = 0;
3801 pEntry = csrLLPeekHead( pChannelSetList, LL_ACCESS_LOCK );
3802 while( pEntry )
3803 {
3804 pChannelSet = GET_BASE_ADDR( pEntry, tCsrChannelPowerInfo, link );
3805 numChannels = csrGetChannelListFromChannelSet( pMac, pChannels, bSize, pChannelSet );
3806 pChannels += numChannels;
3807 *pNumChannels += numChannels;
3808 pEntry = csrLLNext( pChannelSetList, pEntry, LL_ACCESS_LOCK );
3809 }
3810 }
3811}
3812
3813
3814/*
3815 * 802.11D only: Gather 11d IE via beacon or Probe response and store them in pAdapter->channels11d
3816*/
3817tANI_BOOLEAN csrLearnCountryInformation( tpAniSirGlobal pMac, tSirBssDescription *pSirBssDesc,
3818 tDot11fBeaconIEs *pIes, tANI_BOOLEAN fForce)
3819{
3820 tANI_U8 Num2GChannels, bMaxNumChn;
3821 eHalStatus status;
3822 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
3823 v_REGDOMAIN_t domainId;
3824 tDot11fBeaconIEs *pIesLocal = pIes;
3825
Jeff Johnson295189b2012-06-20 16:38:30 -07003826 if (VOS_STA_SAP_MODE == vos_get_conparam ())
3827 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003828
3829 do
3830 {
3831 // check if .11d support is enabled
3832 if( !csrIs11dSupported( pMac ) ) break;
3833 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
3834 {
3835 break;
3836 }
3837 // check if country information element is present
3838 if(!pIesLocal->Country.present)
3839 {
3840 //No country info
3841 break;
3842 }
3843
3844 if( csrSave11dCountryString( pMac, pIesLocal->Country.country, fForce ) )
3845 {
3846 // country string changed, this should not happen
3847 //Need to check whether we care about this BSS' domain info
3848 //If it doesn't match of the connected profile or roaming profile, let's ignore it
3849 tANI_U32 i;
3850 tCsrRoamSession *pSession;
3851
3852 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
3853 {
3854 if( CSR_IS_SESSION_VALID( pMac, i ) )
3855 {
3856 pSession = CSR_GET_SESSION( pMac, i );
3857 if(pSession->pCurRoamProfile)
3858 {
3859 tCsrScanResultFilter filter;
3860
3861 palZeroMemory(pMac->hHdd, &filter, sizeof(tCsrScanResultFilter));
3862 status = csrRoamPrepareFilterFromProfile(pMac, pSession->pCurRoamProfile, &filter);
3863 if(HAL_STATUS_SUCCESS(status))
3864 {
3865 tANI_BOOLEAN fMatch = csrMatchBSS(pMac, pSirBssDesc, &filter, NULL, NULL, NULL, NULL);
3866 //Free the resource first
3867 csrFreeScanFilter( pMac, &filter );
3868 if(fMatch)
3869 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003870 smsLog(pMac, LOGW, " Matching roam profile BSSID %02X-%02X-%02X-%02X-%02X-%02X causing ambiguous domain info",
Jeff Johnson295189b2012-06-20 16:38:30 -07003871 pSirBssDesc->bssId[0], pSirBssDesc->bssId[1], pSirBssDesc->bssId[2],
3872 pSirBssDesc->bssId[3], pSirBssDesc->bssId[4], pSirBssDesc->bssId[5]);
3873 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_TRUE;
3874 break;
3875 }
3876 }
3877 }
3878 else if( csrIsConnStateConnected(pMac, i))
3879 {
3880 //Reach here only when the currention is base on no profile.
3881 //User doesn't give profile and just connect to anything.
3882 if(csrMatchBSSToConnectProfile(pMac, &pSession->connectedProfile, pSirBssDesc, pIesLocal))
3883 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003884 smsLog(pMac, LOGW, " Matching connect profile BSSID %02X-%02X-%02X-%02X-%02X-%02X causing ambiguous domain info",
Jeff Johnson295189b2012-06-20 16:38:30 -07003885 pSirBssDesc->bssId[0], pSirBssDesc->bssId[1], pSirBssDesc->bssId[2],
3886 pSirBssDesc->bssId[3], pSirBssDesc->bssId[4], pSirBssDesc->bssId[5]);
3887 //Tush
3888 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_TRUE;
3889 if(csrIsBssidMatch(pMac, (tCsrBssid *)&pSirBssDesc->bssId,
3890 &pSession->connectedProfile.bssid))
3891 {
3892 //AP changed the 11d info on the fly, modify cfg
3893 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
3894 fRet = eANI_BOOLEAN_TRUE;
3895 }
3896 break;
3897 }
3898 }
3899 } //valid session
3900 } //for
3901 if ( i == CSR_ROAM_SESSION_MAX )
3902 {
3903 //Check whether we can use this country's 11d information
3904 if( !pMac->roam.configParam.fEnforceDefaultDomain )
3905 {
3906 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_TRUE;
3907 }
3908 else
3909 {
3910 VOS_ASSERT( pMac->scan.domainIdCurrent == pMac->scan.domainIdDefault );
3911 if( HAL_STATUS_SUCCESS(csrGetRegulatoryDomainForCountry(
3912 pMac, pIesLocal->Country.country, &domainId )) &&
3913 ( domainId == pMac->scan.domainIdCurrent ) )
3914 {
3915 //Two countries in the same domain
3916 }
3917 }
3918 }
3919 }
3920 else //Tush
3921 {
3922 pMac->scan.fCurrent11dInfoMatch = eANI_BOOLEAN_TRUE;
3923 }
3924
3925 //In case that some channels in 5GHz have the same channel number as 2.4GHz (<= 14)
3926 if(CSR_IS_CHANNEL_5GHZ(pSirBssDesc->channelId))
3927 {
3928 tANI_U8 iC;
3929 tSirMacChanInfo* pMacChnSet = (tSirMacChanInfo *)(&pIesLocal->Country.triplets[0]);
3930
3931 for(iC = 0; iC < pIesLocal->Country.num_triplets; iC++)
3932 {
3933 if(CSR_IS_CHANNEL_24GHZ(pMacChnSet[iC].firstChanNum))
3934 {
3935 pMacChnSet[iC].firstChanNum += 200; //*** Where is this 200 defined?
3936 }
3937 }
3938 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003939 smsLog(pMac, LOG3, FL(" %d sets each one is %d"), pIesLocal->Country.num_triplets, sizeof(tSirMacChanInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07003940 // save the channel/power information from the Channel IE.
3941 //sizeof(tSirMacChanInfo) has to be 3
Jeff Johnsone7245742012-09-05 17:12:55 -07003942 if (eHAL_STATUS_SUCCESS != csrSaveToChannelPower2G_5G( pMac, pIesLocal->Country.num_triplets * sizeof(tSirMacChanInfo),
3943 (tSirMacChanInfo *)(&pIesLocal->Country.triplets[0]) ))
3944 {
3945 fRet = eANI_BOOLEAN_FALSE;
3946 return fRet;
3947 }
3948
Jeff Johnson295189b2012-06-20 16:38:30 -07003949 // set the indicator of the channel where the country IE was found...
3950 pMac->scan.channelOf11dInfo = pSirBssDesc->channelId;
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07003951 csrGetRegulatoryDomainForCountry(pMac, pIesLocal->Country.country, &domainId );
3952 // Checking for Domain Id change
3953 if ( domainId != pMac->scan.domainIdCurrent )
3954 {
3955 tSirMacChanInfo* pMacChnSet = (tSirMacChanInfo *)(&pIesLocal->Country.triplets[0]);
Madan Mohan Koyyalamudi0e5922d2013-09-10 15:45:24 +05303956 palCopyMemory( pMac->hHdd, pMac->scan.countryCode11d, pIesLocal->Country.country,
3957 sizeof( pMac->scan.countryCode11d ) );
3958 csrSetCfgCountryCode(pMac, pIesLocal->Country.country);
3959 WDA_SetRegDomain(pMac, domainId);
3960 pMac->scan.domainIdCurrent = domainId;
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05303961 // Check whether AP provided the 2.4GHZ list or 5GHZ list
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07003962 if(CSR_IS_CHANNEL_24GHZ(pMacChnSet[0].firstChanNum))
3963 {
3964 // AP Provided the 2.4 Channels, Update the 5GHz channels from nv.bin
3965 csrGet5GChannels(pMac );
3966 }
3967 else
3968 {
3969 // AP Provided the 5G Channels, Update the 2.4GHZ channel list from nv.bin
3970 csrGet24GChannels(pMac );
3971 }
3972 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003973 // Populate both band channel lists based on what we found in the country information...
3974 csrSetOppositeBandChannelInfo( pMac );
3975 bMaxNumChn = WNI_CFG_VALID_CHANNEL_LIST_LEN;
3976 // construct 2GHz channel list first
3977 csrConstructCurrentValidChannelList( pMac, &pMac->scan.channelPowerInfoList24, pMac->scan.channels11d.channelList,
3978 bMaxNumChn, &Num2GChannels );
3979 // construct 5GHz channel list now
3980 if(bMaxNumChn > Num2GChannels)
3981 {
3982 csrConstructCurrentValidChannelList( pMac, &pMac->scan.channelPowerInfoList5G, pMac->scan.channels11d.channelList + Num2GChannels,
3983 bMaxNumChn - Num2GChannels,
3984 &pMac->scan.channels11d.numChannels );
3985 }
3986
3987 pMac->scan.channels11d.numChannels += Num2GChannels;
3988 fRet = eANI_BOOLEAN_TRUE;
3989
3990 } while( 0 );
3991
3992 if( !pIes && pIesLocal )
3993 {
3994 //locally allocated
3995 palFreeMemory(pMac->hHdd, pIesLocal);
3996 }
3997
3998 return( fRet );
3999}
4000
4001
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004002static void csrSaveScanResults( tpAniSirGlobal pMac, tANI_U8 reason )
Jeff Johnson295189b2012-06-20 16:38:30 -07004003{
4004 // initialize this to FALSE. profMoveInterimScanResultsToMainList() routine
4005 // will set this to the channel where an .11d beacon is seen
4006 pMac->scan.channelOf11dInfo = 0;
4007 // if we get any ambiguous .11d information then this will be set to TRUE
4008 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
4009 //Tush
4010 // if we get any ambiguous .11d information, then this will be set to TRUE
4011 // only if the applied 11d info could be found in one of the scan results
4012 pMac->scan.fCurrent11dInfoMatch = eANI_BOOLEAN_FALSE;
4013 // move the scan results from interim list to the main scan list
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004014 csrMoveTempScanResultsToMainList( pMac, reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004015
4016 // Now check if we gathered any domain/country specific information
4017 // If so, we should update channel list and apply Tx power settings
Jeff Johnsone7245742012-09-05 17:12:55 -07004018 if( csrIs11dSupported(pMac) )
4019 {
4020 csrApplyCountryInformation( pMac, FALSE );
4021 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004022}
4023
4024
4025void csrReinitScanCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4026{
4027 switch (pCommand->u.scanCmd.reason)
4028 {
4029 case eCsrScanSetBGScanParam:
4030 case eCsrScanAbortBgScan:
4031 if(pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList)
4032 {
4033 palFreeMemory(pMac->hHdd, pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList);
4034 pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList = NULL;
4035 }
4036 break;
4037 case eCsrScanBGScanAbort:
4038 case eCsrScanBGScanEnable:
4039 case eCsrScanGetScanChnInfo:
4040 break;
4041 case eCsrScanAbortNormalScan:
4042 default:
4043 csrScanFreeRequest(pMac, &pCommand->u.scanCmd.u.scanRequest);
4044 break;
4045 }
4046 if(pCommand->u.scanCmd.pToRoamProfile)
4047 {
4048 csrReleaseProfile(pMac, pCommand->u.scanCmd.pToRoamProfile);
4049 palFreeMemory(pMac->hHdd, pCommand->u.scanCmd.pToRoamProfile);
4050 }
4051 palZeroMemory(pMac->hHdd, &pCommand->u.scanCmd, sizeof(tScanCmd));
4052}
4053
4054
4055tANI_BOOLEAN csrGetRemainingChannelsFor11dScan( tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U8 *pcChannels )
4056{
4057 tANI_U32 index11dChannels, index;
4058 tANI_U32 indexCurrentChannels;
4059 tANI_BOOLEAN fChannelAlreadyScanned;
4060 tANI_U32 len = sizeof(pMac->roam.validChannelList);
4061
4062 *pcChannels = 0;
4063 if ( CSR_IS_11D_INFO_FOUND(pMac) && csrRoamIsChannelValid(pMac, pMac->scan.channelOf11dInfo) )
4064 {
4065 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
4066 {
4067 //Find the channel index where we found the 11d info
4068 for(index = 0; index < len; index++)
4069 {
4070 if(pMac->scan.channelOf11dInfo == pMac->roam.validChannelList[index])
4071 break;
4072 }
4073 //check whether we found the channel index
4074 if(index < len)
4075 {
4076 // Now, look through the 11d channel list and create a list of all channels in the 11d list that are
4077 // NOT in the current channel list. This gives us a list of the new channels that have not been
4078 // scanned. We'll scan this new list so we have a complete set of scan results on all of the domain channels
4079 // initially.
4080 for ( index11dChannels = 0; index11dChannels < pMac->scan.channels11d.numChannels; index11dChannels++ )
4081 {
4082 fChannelAlreadyScanned = eANI_BOOLEAN_FALSE;
4083
4084 for( indexCurrentChannels = 0; indexCurrentChannels < index; indexCurrentChannels++ )
4085 {
4086 if ( pMac->roam.validChannelList[ indexCurrentChannels ] == pMac->scan.channels11d.channelList[ index11dChannels ] )
4087 {
4088 fChannelAlreadyScanned = eANI_BOOLEAN_TRUE;
4089 break;
4090 }
4091 }
4092
4093 if ( !fChannelAlreadyScanned )
4094 {
4095 pChannels[ *pcChannels ] = pMac->scan.channels11d.channelList[ index11dChannels ];
4096 ( *pcChannels )++;
4097 }
4098 }
4099 }
4100 }//GetCFG
4101 }
4102 return( *pcChannels );
4103}
4104
4105
4106eCsrScanCompleteNextCommand csrScanGetNextCommandState( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fSuccess )
4107{
4108 eCsrScanCompleteNextCommand NextCommand = eCsrNextScanNothing;
4109
4110 switch( pCommand->u.scanCmd.reason )
4111 {
4112 case eCsrScan11d1:
4113 NextCommand = (fSuccess) ? eCsrNext11dScan1Success : eCsrNext11dScan1Failure;
4114 break;
4115 case eCsrScan11d2:
4116 NextCommand = (fSuccess) ? eCsrNext11dScan2Success : eCsrNext11dScan2Failure;
4117 break;
4118 case eCsrScan11dDone:
4119 NextCommand = eCsrNext11dScanComplete;
4120 break;
4121 case eCsrScanLostLink1:
4122 NextCommand = (fSuccess) ? eCsrNextLostLinkScan1Success : eCsrNextLostLinkScan1Failed;
4123 break;
4124 case eCsrScanLostLink2:
4125 NextCommand = (fSuccess) ? eCsrNextLostLinkScan2Success : eCsrNextLostLinkScan2Failed;
4126 break;
4127 case eCsrScanLostLink3:
4128 NextCommand = (fSuccess) ? eCsrNextLostLinkScan3Success : eCsrNextLostLinkScan3Failed;
4129 break;
4130 case eCsrScanForSsid:
4131 NextCommand = (fSuccess) ? eCsrNexteScanForSsidSuccess : eCsrNexteScanForSsidFailure;
4132 break;
4133 case eCsrScanForCapsChange:
4134 NextCommand = eCsrNextCapChangeScanComplete; //don't care success or not
4135 break;
4136 case eCsrScanIdleScan:
4137 NextCommand = eCsrNextIdleScanComplete;
4138 break;
4139 default:
4140 NextCommand = eCsrNextScanNothing;
4141 break;
4142 }
4143 return( NextCommand );
4144}
4145
4146
4147//Return whether the pCommand is finished.
4148tANI_BOOLEAN csrHandleScan11d1Failure(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4149{
4150 tANI_BOOLEAN fRet = eANI_BOOLEAN_TRUE;
4151
4152 //Apply back the default setting and passively scan one more time.
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08004153 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004154 pCommand->u.scanCmd.reason = eCsrScan11d2;
4155 if(HAL_STATUS_SUCCESS(csrScanChannels(pMac, pCommand)))
4156 {
4157 fRet = eANI_BOOLEAN_FALSE;
4158 }
4159
4160 return (fRet);
4161}
4162
4163
4164tANI_BOOLEAN csrHandleScan11dSuccess(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4165{
4166 tANI_BOOLEAN fRet = eANI_BOOLEAN_TRUE;
4167 tANI_U8 *pChannels;
4168 tANI_U8 cChannels;
4169
4170 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN)))
4171 {
4172 palZeroMemory(pMac->hHdd, pChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN);
4173 if ( csrGetRemainingChannelsFor11dScan( pMac, pChannels, &cChannels ) )
4174 {
4175 pCommand->u.scanCmd.reason = eCsrScan11dDone;
4176 if(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList)
4177 {
4178 palFreeMemory(pMac->hHdd, pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList);
James Zmuda9ea1edd2013-04-18 18:20:54 -07004179 pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004180 }
4181 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList, cChannels)))
4182 {
4183 palCopyMemory(pMac->hHdd, pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList, pChannels, cChannels);
4184 pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = cChannels;
4185 pCommand->u.scanCmd.u.scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
4186 pCommand->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN;
4187 if(HAL_STATUS_SUCCESS(csrScanChannels(pMac, pCommand)))
4188 {
4189 //Reuse the same command buffer
4190 fRet = eANI_BOOLEAN_FALSE;
4191 }
4192 }
4193 }
4194 palFreeMemory(pMac->hHdd, pChannels);
4195 }
4196
4197 return (fRet);
4198}
4199
4200//Return whether the command should be removed
4201tANI_BOOLEAN csrScanComplete( tpAniSirGlobal pMac, tSirSmeScanRsp *pScanRsp )
4202{
4203 eCsrScanCompleteNextCommand NextCommand = eCsrNextScanNothing;
4204 tListElem *pEntry;
4205 tSmeCmd *pCommand;
4206 tANI_BOOLEAN fRemoveCommand = eANI_BOOLEAN_TRUE;
4207 tANI_BOOLEAN fSuccess;
4208
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +05304209 if (pMac->fScanOffload)
4210 pEntry = csrLLPeekHead(&pMac->sme.smeScanCmdActiveList, LL_ACCESS_LOCK);
4211 else
4212 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
Jeff Johnson295189b2012-06-20 16:38:30 -07004213
4214 if ( pEntry )
4215 {
4216 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
4217
4218 // If the head of the queue is Active and it is a SCAN command, remove
4219 // and put this on the Free queue.
4220 if ( eSmeCommandScan == pCommand->command )
4221 {
4222 tANI_U32 sessionId = pCommand->sessionId;
4223
4224 if(eSIR_SME_SUCCESS != pScanRsp->statusCode)
4225 {
4226 fSuccess = eANI_BOOLEAN_FALSE;
4227 }
4228 else
4229 {
4230 //pMac->scan.tempScanResults is not empty meaning the scan found something
4231 //This check only valid here because csrSaveScanresults is not yet called
4232 fSuccess = (!csrLLIsListEmpty(&pMac->scan.tempScanResults, LL_ACCESS_LOCK));
4233 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004234 csrSaveScanResults(pMac, pCommand->u.scanCmd.reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07004235
4236#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
4237 {
4238 vos_log_scan_pkt_type *pScanLog = NULL;
4239 tScanResultHandle hScanResult;
4240 tCsrScanResultInfo *pScanResult;
4241 tDot11fBeaconIEs *pIes;
4242 int n = 0, c = 0;
4243
4244 WLAN_VOS_DIAG_LOG_ALLOC(pScanLog, vos_log_scan_pkt_type, LOG_WLAN_SCAN_C);
4245 if(pScanLog)
4246 {
4247 if(eCsrScanBgScan == pCommand->u.scanCmd.reason ||
4248 eCsrScanProbeBss == pCommand->u.scanCmd.reason ||
4249 eCsrScanSetBGScanParam == pCommand->u.scanCmd.reason)
4250 {
4251 pScanLog->eventId = WLAN_SCAN_EVENT_HO_SCAN_RSP;
4252 }
4253 else
4254 {
4255 if( eSIR_PASSIVE_SCAN != pMac->scan.curScanType )
4256 {
4257 pScanLog->eventId = WLAN_SCAN_EVENT_ACTIVE_SCAN_RSP;
4258 }
4259 else
4260 {
4261 pScanLog->eventId = WLAN_SCAN_EVENT_PASSIVE_SCAN_RSP;
4262 }
4263 }
4264 if(eSIR_SME_SUCCESS == pScanRsp->statusCode)
4265 {
4266 if(HAL_STATUS_SUCCESS(csrScanGetResult(pMac, NULL, &hScanResult)))
4267 {
4268 while(((pScanResult = csrScanResultGetNext(pMac, hScanResult)) != NULL))
4269 {
4270 if( n < VOS_LOG_MAX_NUM_BSSID )
4271 {
4272 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->BssDescriptor, &pIes)))
4273 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004274 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004275 break;
4276 }
4277 palCopyMemory(pMac->hHdd, pScanLog->bssid[n], pScanResult->BssDescriptor.bssId, 6);
4278 if(pIes && pIes->SSID.present && VOS_LOG_MAX_SSID_SIZE >= pIes->SSID.num_ssid)
4279 {
4280 palCopyMemory(pMac->hHdd, pScanLog->ssid[n],
4281 pIes->SSID.ssid, pIes->SSID.num_ssid);
4282 }
4283 palFreeMemory(pMac->hHdd, pIes);
4284 n++;
4285 }
4286 c++;
4287 }
4288 pScanLog->numSsid = (v_U8_t)n;
4289 pScanLog->totalSsid = (v_U8_t)c;
4290 csrScanResultPurge(pMac, hScanResult);
4291 }
4292 }
4293 else
4294 {
4295 pScanLog->status = WLAN_SCAN_STATUS_FAILURE;
4296 }
4297 WLAN_VOS_DIAG_LOG_REPORT(pScanLog);
4298 }
4299 }
4300#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
4301
4302 NextCommand = csrScanGetNextCommandState(pMac, pCommand, fSuccess);
4303 //We reuse the command here instead reissue a new command
4304 switch(NextCommand)
4305 {
4306 case eCsrNext11dScan1Success:
4307 case eCsrNext11dScan2Success:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004308 smsLog( pMac, LOG2, FL("11dScan1/3 produced results. Reissue Active scan..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07004309 // if we found country information, no need to continue scanning further, bail out
4310 fRemoveCommand = eANI_BOOLEAN_TRUE;
4311 NextCommand = eCsrNext11dScanComplete;
4312 break;
4313 case eCsrNext11dScan1Failure:
4314 //We are not done yet. 11d scan fail once. We will try to reset anything and do it over again
4315 //The only meaningful thing for this retry is that we cannot find 11d information after a reset so
4316 //we clear the "old" 11d info and give it once more chance
4317 fRemoveCommand = csrHandleScan11d1Failure(pMac, pCommand);
4318 if(fRemoveCommand)
4319 {
4320 NextCommand = eCsrNext11dScanComplete;
4321 }
4322 break;
4323 case eCsrNextLostLinkScan1Success:
4324 if(!HAL_STATUS_SUCCESS(csrIssueRoamAfterLostlinkScan(pMac, sessionId, eCsrLostLink1)))
4325 {
4326 csrScanHandleFailedLostlink1(pMac, sessionId);
4327 }
4328 break;
4329 case eCsrNextLostLinkScan2Success:
4330 if(!HAL_STATUS_SUCCESS(csrIssueRoamAfterLostlinkScan(pMac, sessionId, eCsrLostLink2)))
4331 {
4332 csrScanHandleFailedLostlink2(pMac, sessionId);
4333 }
4334 break;
4335 case eCsrNextLostLinkScan3Success:
4336 if(!HAL_STATUS_SUCCESS(csrIssueRoamAfterLostlinkScan(pMac, sessionId, eCsrLostLink3)))
4337 {
4338 csrScanHandleFailedLostlink3(pMac, sessionId);
4339 }
4340 break;
4341 case eCsrNextLostLinkScan1Failed:
4342 csrScanHandleFailedLostlink1(pMac, sessionId);
4343 break;
4344 case eCsrNextLostLinkScan2Failed:
4345 csrScanHandleFailedLostlink2(pMac, sessionId);
4346 break;
4347 case eCsrNextLostLinkScan3Failed:
4348 csrScanHandleFailedLostlink3(pMac, sessionId);
4349 break;
4350 case eCsrNexteScanForSsidSuccess:
4351 csrScanHandleSearchForSSID(pMac, pCommand);
4352 break;
4353 case eCsrNexteScanForSsidFailure:
4354 csrScanHandleSearchForSSIDFailure(pMac, pCommand);
4355 break;
4356 case eCsrNextIdleScanComplete:
4357 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE;
4358 break;
4359 case eCsrNextCapChangeScanComplete:
4360 csrScanHandleCapChangeScanComplete(pMac, sessionId);
4361 break;
4362 default:
4363
4364 break;
4365 }
4366 }
4367 else
4368 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004369 smsLog( pMac, LOGW, FL("Scan Completion called but SCAN command is not ACTIVE ..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07004370 fRemoveCommand = eANI_BOOLEAN_FALSE;
4371 }
4372 }
4373 else
4374 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004375 smsLog( pMac, LOGW, FL("Scan Completion called but NO commands are ACTIVE ..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07004376 fRemoveCommand = eANI_BOOLEAN_FALSE;
4377 }
4378
4379 return( fRemoveCommand );
4380}
4381
4382
4383
4384static void csrScanRemoveDupBssDescriptionFromInterimList( tpAniSirGlobal pMac,
4385 tSirBssDescription *pSirBssDescr,
4386 tDot11fBeaconIEs *pIes)
4387{
4388 tListElem *pEntry;
4389 tCsrScanResult *pCsrBssDescription;
4390
4391 // Walk through all the chained BssDescriptions. If we find a chained BssDescription that
4392 // matches the BssID of the BssDescription passed in, then these must be duplicate scan
4393 // results for this Bss. In that case, remove the 'old' Bss description from the linked list.
4394 pEntry = csrLLPeekHead( &pMac->scan.tempScanResults, LL_ACCESS_LOCK );
4395 while( pEntry )
4396 {
4397 pCsrBssDescription = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
4398
4399 // we have a duplicate scan results only when BSSID, SSID, Channel and NetworkType
4400 // matches
4401
4402 if ( csrIsDuplicateBssDescription( pMac, &pCsrBssDescription->Result.BssDescriptor,
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07004403 pSirBssDescr, pIes, FALSE ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004404 {
4405 pSirBssDescr->rssi = (tANI_S8)( (((tANI_S32)pSirBssDescr->rssi * CSR_SCAN_RESULT_RSSI_WEIGHT ) +
4406 ((tANI_S32)pCsrBssDescription->Result.BssDescriptor.rssi * (100 - CSR_SCAN_RESULT_RSSI_WEIGHT) )) / 100 );
4407
4408 // Remove the 'old' entry from the list....
4409 if( csrLLRemoveEntry( &pMac->scan.tempScanResults, pEntry, LL_ACCESS_LOCK ) )
4410 {
4411 csrCheckNSaveWscIe(pMac, pSirBssDescr, &pCsrBssDescription->Result.BssDescriptor);
4412 // we need to free the memory associated with this node
4413 csrFreeScanResultEntry( pMac, pCsrBssDescription );
4414 }
4415
4416 // If we found a match, we can stop looking through the list.
4417 break;
4418 }
4419
4420 pEntry = csrLLNext( &pMac->scan.tempScanResults, pEntry, LL_ACCESS_LOCK );
4421 }
4422}
4423
4424
4425
4426//Caller allocated memory pfNewBssForConn to return whether new candidate for
4427//current connection is found. Cannot be NULL
4428tCsrScanResult *csrScanSaveBssDescriptionToInterimList( tpAniSirGlobal pMac,
4429 tSirBssDescription *pBSSDescription,
4430 tDot11fBeaconIEs *pIes)
4431{
4432 tCsrScanResult *pCsrBssDescription = NULL;
4433 tANI_U32 cbBSSDesc;
4434 tANI_U32 cbAllocated;
4435 eHalStatus halStatus;
4436
4437 // figure out how big the BSS description is (the BSSDesc->length does NOT
4438 // include the size of the length field itself).
4439 cbBSSDesc = pBSSDescription->length + sizeof( pBSSDescription->length );
4440
4441 cbAllocated = sizeof( tCsrScanResult ) + cbBSSDesc;
4442
4443 halStatus = palAllocateMemory( pMac->hHdd, (void **)&pCsrBssDescription, cbAllocated );
4444 if ( HAL_STATUS_SUCCESS(halStatus) )
4445 {
4446 palZeroMemory(pMac->hHdd, pCsrBssDescription, cbAllocated);
4447 pCsrBssDescription->AgingCount = (tANI_S32)pMac->roam.configParam.agingCount;
4448 palCopyMemory(pMac->hHdd, &pCsrBssDescription->Result.BssDescriptor, pBSSDescription, cbBSSDesc );
4449 //Save SSID separately for later use
4450 if( pIes->SSID.present && !csrIsNULLSSID(pIes->SSID.ssid, pIes->SSID.num_ssid) )
4451 {
4452 //SSID not hidden
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07004453 tANI_U32 len = pIes->SSID.num_ssid;
Jeff Johnson295189b2012-06-20 16:38:30 -07004454 if (len > SIR_MAC_MAX_SSID_LENGTH)
4455 {
4456 // truncate to fit in our struct
4457 len = SIR_MAC_MAX_SSID_LENGTH;
4458 }
4459 pCsrBssDescription->Result.ssId.length = len;
4460 pCsrBssDescription->Result.timer = vos_timer_get_system_time();
4461 palCopyMemory(pMac->hHdd, pCsrBssDescription->Result.ssId.ssId,
4462 pIes->SSID.ssid, len );
4463 }
4464 csrLLInsertTail( &pMac->scan.tempScanResults, &pCsrBssDescription->Link, LL_ACCESS_LOCK );
4465 }
4466
4467 return( pCsrBssDescription );
4468}
4469
4470
4471
4472
4473tANI_BOOLEAN csrIsDuplicateBssDescription( tpAniSirGlobal pMac, tSirBssDescription *pSirBssDesc1,
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07004474 tSirBssDescription *pSirBssDesc2, tDot11fBeaconIEs *pIes2, tANI_BOOLEAN fForced )
Jeff Johnson295189b2012-06-20 16:38:30 -07004475{
4476 tANI_BOOLEAN fMatch = FALSE;
4477 tSirMacCapabilityInfo *pCap1, *pCap2;
4478 tDot11fBeaconIEs *pIes1 = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07004479 tDot11fBeaconIEs *pIesTemp = pIes2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004480
4481 pCap1 = (tSirMacCapabilityInfo *)&pSirBssDesc1->capabilityInfo;
4482 pCap2 = (tSirMacCapabilityInfo *)&pSirBssDesc2->capabilityInfo;
4483 if(pCap1->ess == pCap2->ess)
4484 {
4485 if (pCap1->ess &&
Jeff Johnsone7245742012-09-05 17:12:55 -07004486 csrIsMacAddressEqual( pMac, (tCsrBssid *)pSirBssDesc1->bssId, (tCsrBssid *)pSirBssDesc2->bssId)&&
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07004487 (fForced || (pSirBssDesc1->channelId == pSirBssDesc2->channelId)))
Jeff Johnson295189b2012-06-20 16:38:30 -07004488 {
4489 fMatch = TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004490 // Check for SSID match, if exists
4491 do
4492 {
4493 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc1, &pIes1)))
4494 {
4495 break;
4496 }
4497 if( NULL == pIesTemp )
4498 {
4499 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc2, &pIesTemp)))
4500 {
4501 break;
4502 }
4503 }
4504 if(pIes1->SSID.present && pIesTemp->SSID.present)
4505 {
4506 fMatch = csrIsSsidMatch(pMac, pIes1->SSID.ssid, pIes1->SSID.num_ssid,
4507 pIesTemp->SSID.ssid, pIesTemp->SSID.num_ssid, eANI_BOOLEAN_TRUE);
4508 }
4509 }while(0);
4510
Jeff Johnson295189b2012-06-20 16:38:30 -07004511 }
4512 else if (pCap1->ibss && (pSirBssDesc1->channelId == pSirBssDesc2->channelId))
4513 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004514
4515 do
4516 {
4517 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc1, &pIes1)))
4518 {
4519 break;
4520 }
4521 if( NULL == pIesTemp )
4522 {
4523 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc2, &pIesTemp)))
4524 {
4525 break;
4526 }
4527 }
4528 //Same channel cannot have same SSID for different IBSS
4529 if(pIes1->SSID.present && pIesTemp->SSID.present)
4530 {
4531 fMatch = csrIsSsidMatch(pMac, pIes1->SSID.ssid, pIes1->SSID.num_ssid,
4532 pIesTemp->SSID.ssid, pIesTemp->SSID.num_ssid, eANI_BOOLEAN_TRUE);
4533 }
4534 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004535 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004536 /* In case of P2P devices, ess and ibss will be set to zero */
4537 else if (!pCap1->ess &&
4538 csrIsMacAddressEqual( pMac, (tCsrBssid *)pSirBssDesc1->bssId, (tCsrBssid *)pSirBssDesc2->bssId))
4539 {
4540 fMatch = TRUE;
4541 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004542 }
4543
4544 if(pIes1)
4545 {
4546 palFreeMemory(pMac->hHdd, pIes1);
4547 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004548
4549 if( (NULL == pIes2) && pIesTemp )
4550 {
4551 //locally allocated
4552 palFreeMemory(pMac->hHdd, pIesTemp);
4553 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004554
4555 return( fMatch );
4556}
4557
4558
4559tANI_BOOLEAN csrIsNetworkTypeEqual( tSirBssDescription *pSirBssDesc1, tSirBssDescription *pSirBssDesc2 )
4560{
4561 return( pSirBssDesc1->nwType == pSirBssDesc2->nwType );
4562}
4563
4564
4565//to check whether the BSS matches the dot11Mode
4566static tANI_BOOLEAN csrScanIsBssAllowed(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
4567 tDot11fBeaconIEs *pIes)
4568{
4569 tANI_BOOLEAN fAllowed = eANI_BOOLEAN_FALSE;
4570 eCsrPhyMode phyMode;
4571
4572 if(HAL_STATUS_SUCCESS(csrGetPhyModeFromBss(pMac, pBssDesc, &phyMode, pIes)))
4573 {
4574 switch(pMac->roam.configParam.phyMode)
4575 {
4576 case eCSR_DOT11_MODE_11b:
4577 fAllowed = (tANI_BOOLEAN)(eCSR_DOT11_MODE_11a != phyMode);
4578 break;
4579 case eCSR_DOT11_MODE_11g:
4580 fAllowed = (tANI_BOOLEAN)(eCSR_DOT11_MODE_11a != phyMode);
4581 break;
4582 case eCSR_DOT11_MODE_11g_ONLY:
4583 fAllowed = (tANI_BOOLEAN)(eCSR_DOT11_MODE_11g == phyMode);
4584 break;
4585 case eCSR_DOT11_MODE_11a:
4586 fAllowed = (tANI_BOOLEAN)((eCSR_DOT11_MODE_11b != phyMode) && (eCSR_DOT11_MODE_11g != phyMode));
4587 break;
4588 case eCSR_DOT11_MODE_11n_ONLY:
4589 fAllowed = (tANI_BOOLEAN)((eCSR_DOT11_MODE_11n == phyMode) || (eCSR_DOT11_MODE_TAURUS == phyMode));
4590 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004591
4592#ifdef WLAN_FEATURE_11AC
4593 case eCSR_DOT11_MODE_11ac_ONLY:
4594 fAllowed = (tANI_BOOLEAN)((eCSR_DOT11_MODE_11ac == phyMode) || (eCSR_DOT11_MODE_TAURUS == phyMode));
4595 break;
4596#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004597 case eCSR_DOT11_MODE_11b_ONLY:
4598 fAllowed = (tANI_BOOLEAN)(eCSR_DOT11_MODE_11b == phyMode);
4599 break;
4600 case eCSR_DOT11_MODE_11a_ONLY:
4601 fAllowed = (tANI_BOOLEAN)(eCSR_DOT11_MODE_11a == phyMode);
4602 break;
4603 case eCSR_DOT11_MODE_11n:
Jeff Johnsone7245742012-09-05 17:12:55 -07004604#ifdef WLAN_FEATURE_11AC
4605 case eCSR_DOT11_MODE_11ac:
4606#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004607 case eCSR_DOT11_MODE_TAURUS:
4608 default:
4609 fAllowed = eANI_BOOLEAN_TRUE;
4610 break;
4611 }
4612 }
4613
4614 return (fAllowed);
4615}
4616
4617
4618
4619//Return pIes to caller for future use when returning TRUE.
4620static tANI_BOOLEAN csrScanValidateScanResult( tpAniSirGlobal pMac, tANI_U8 *pChannels,
4621 tANI_U8 numChn, tSirBssDescription *pBssDesc,
4622 tDot11fBeaconIEs **ppIes )
4623{
4624 tANI_BOOLEAN fValidChannel = FALSE;
4625 tDot11fBeaconIEs *pIes = NULL;
4626 tANI_U8 index;
4627
4628 for( index = 0; index < numChn; index++ )
4629 {
4630 // This check relies on the fact that a single BSS description is returned in each
4631 // ScanRsp call, which is the way LIM implemented the scan req/rsp funtions. We changed
4632 // to this model when we ran with a large number of APs. If this were to change, then
4633 // this check would have to mess with removing the bssDescription from somewhere in an
4634 // arbitrary index in the bssDescription array.
4635 if ( pChannels[ index ] == pBssDesc->channelId )
4636 {
4637 fValidChannel = TRUE;
4638 break;
4639 }
4640 }
4641 *ppIes = NULL;
4642 if(fValidChannel)
4643 {
4644 if( HAL_STATUS_SUCCESS( csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes) ) )
4645 {
4646 fValidChannel = csrScanIsBssAllowed(pMac, pBssDesc, pIes);
4647 if( fValidChannel )
4648 {
4649 *ppIes = pIes;
4650 }
4651 else
4652 {
4653 palFreeMemory( pMac->hHdd, pIes );
4654 }
4655 }
4656 else
4657 {
4658 fValidChannel = FALSE;
4659 }
4660 }
4661
4662 return( fValidChannel );
4663}
4664
4665
4666//Return whether last scan result is received
4667static tANI_BOOLEAN csrScanProcessScanResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
4668 tSirSmeScanRsp *pScanRsp, tANI_BOOLEAN *pfRemoveCommand )
4669{
4670 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE, fRemoveCommand = eANI_BOOLEAN_FALSE;
4671 tDot11fBeaconIEs *pIes = NULL;
4672 tANI_U32 cbParsed;
4673 tSirBssDescription *pSirBssDescription;
4674 tANI_U32 cbBssDesc;
4675 tANI_U32 cbScanResult = GET_FIELD_OFFSET( tSirSmeScanRsp, bssDescription )
4676 + sizeof(tSirBssDescription); //We need at least one CB
4677
4678 // don't consider the scan rsp to be valid if the status code is Scan Failure. Scan Failure
4679 // is returned when the scan could not find anything. so if we get scan failure return that
4680 // the scan response is invalid. Also check the lenght in the scan result for valid scan
4681 // BssDescriptions....
4682 do
4683 {
4684 if ( ( cbScanResult <= pScanRsp->length ) &&
4685 (( eSIR_SME_SUCCESS == pScanRsp->statusCode ) ||
4686 ( eSIR_SME_MORE_SCAN_RESULTS_FOLLOW == pScanRsp->statusCode ) ) )
4687 {
4688 tANI_U8 *pChannelList = NULL;
4689 tANI_U8 cChannels = 0;
4690
4691 //Different scan type can reach this point, we need to distinguish it
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004692#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
4693 if( eCsrScanGetLfrResult == pCommand->u.scanCmd.reason )
4694 {
4695 pChannelList = NULL;
4696 cChannels = 0;
4697 }
4698 else
4699#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004700 if( eCsrScanSetBGScanParam == pCommand->u.scanCmd.reason )
4701 {
4702 //eCsrScanSetBGScanParam uses different structure
4703 tCsrBGScanRequest *pBgScanReq = &pCommand->u.scanCmd.u.bgScanRequest;
4704
4705 cChannels = pBgScanReq->ChannelInfo.numOfChannels;
4706 pChannelList = pBgScanReq->ChannelInfo.ChannelList;
4707 }
4708 else
4709 {
4710 //the rest use generic scan request
4711 cChannels = pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels;
4712 pChannelList = pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList;
4713 }
4714
4715 // if the scan result is not on one of the channels in the Valid channel list, then it
4716 // must have come from an AP on an overlapping channel (in the 2.4GHz band). In this case,
4717 // let's drop the scan result.
4718 //
4719 // The other situation is where the scan request is for a scan on a particular channel set
4720 // and the scan result is from a
4721
4722 // if the NumChannels is 0, then we are supposed to be scanning all channels. Use the full channel
4723 // list as the 'valid' channel list. Otherwise, use the specific channel list in the scan parms
4724 // as the valid channels.
4725 if ( 0 == cChannels )
4726 {
4727 tANI_U32 len = sizeof(pMac->roam.validChannelList);
4728
4729 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
4730 {
4731 pChannelList = pMac->roam.validChannelList;
4732 cChannels = (tANI_U8)len;
4733 }
4734 else
4735 {
4736 //Cannot continue
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004737 smsLog( pMac, LOGE, "CSR: Processing internal SCAN results...csrGetCfgValidChannels failed" );
Jeff Johnson295189b2012-06-20 16:38:30 -07004738 break;
4739 }
4740 }
4741
4742 smsLog( pMac, LOG2, "CSR: Processing internal SCAN results..." );
4743 cbParsed = GET_FIELD_OFFSET( tSirSmeScanRsp, bssDescription );
4744 pSirBssDescription = pScanRsp->bssDescription;
4745 while( cbParsed < pScanRsp->length )
4746 {
4747 if ( csrScanValidateScanResult( pMac, pChannelList, cChannels, pSirBssDescription, &pIes ) )
4748 {
4749 csrScanRemoveDupBssDescriptionFromInterimList(pMac, pSirBssDescription, pIes);
4750 csrScanSaveBssDescriptionToInterimList( pMac, pSirBssDescription, pIes );
4751 if( eSIR_PASSIVE_SCAN == pMac->scan.curScanType )
4752 {
4753 if( csrIs11dSupported( pMac) )
4754 {
4755 //Check whether the BSS is acceptable base on 11d info and our configs.
4756 if( csrMatchCountryCode( pMac, NULL, pIes ) )
4757 {
4758 //Double check whether the channel is acceptable by us.
4759 if( csrIsSupportedChannel( pMac, pSirBssDescription->channelId ) )
4760 {
4761 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
4762 }
4763 }
4764 }
4765 else
4766 {
4767 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
4768 }
4769 }
4770 //Free the resource
4771 palFreeMemory( pMac->hHdd, pIes );
4772 }
4773 // skip over the BSS description to the next one...
4774 cbBssDesc = pSirBssDescription->length + sizeof( pSirBssDescription->length );
4775
4776 cbParsed += cbBssDesc;
4777 pSirBssDescription = (tSirBssDescription *)((tANI_U8 *)pSirBssDescription + cbBssDesc );
4778
4779 } //while
4780 }
4781 else
4782 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004783 smsLog( pMac, LOGW, " Scanrsp fail (0x%08X), length = %d (expected %d)",
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08004784 pScanRsp->statusCode, pScanRsp->length, cbScanResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07004785 //HO bg scan/probe failed no need to try autonomously
4786 if(eCsrScanBgScan == pCommand->u.scanCmd.reason ||
4787 eCsrScanProbeBss == pCommand->u.scanCmd.reason ||
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004788#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
4789 eCsrScanGetLfrResult == pCommand->u.scanCmd.reason ||
4790#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004791 eCsrScanSetBGScanParam == pCommand->u.scanCmd.reason)
4792 {
4793 fRemoveCommand = eANI_BOOLEAN_TRUE;
4794 }
4795 }
4796 }while(0);
4797 if ( eSIR_SME_MORE_SCAN_RESULTS_FOLLOW != pScanRsp->statusCode )
4798 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004799 smsLog(pMac, LOG1, " Scan received %d unique BSS scan reason is %d", csrLLCount(&pMac->scan.tempScanResults), pCommand->u.scanCmd.reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07004800 fRemoveCommand = csrScanComplete( pMac, pScanRsp );
4801 fRet = eANI_BOOLEAN_TRUE;
4802 }//if ( eSIR_SME_MORE_SCAN_RESULTS_FOLLOW != pScanRsp->statusCode )
4803 if(pfRemoveCommand)
4804 {
4805 *pfRemoveCommand = fRemoveCommand;
4806 }
4807
4808#ifdef WLAN_AP_STA_CONCURRENCY
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +05304809 if (pMac->fScanOffload)
4810 return fRet;
4811
Jeff Johnson295189b2012-06-20 16:38:30 -07004812 if (!csrLLIsListEmpty( &pMac->scan.scanCmdPendingList, LL_ACCESS_LOCK ))
4813 {
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08004814 /* Pending scan commands in the list because the previous scan command
4815 * was split into a scan command on one channel + a scan command for all
4816 * remaining channels.
4817 *
4818 * Start timer to trigger processing of the next scan command.
Srikant Kuppa866893f2012-12-27 17:28:14 -08004819 * NOTE for LFR:
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +05304820 * Do not split scans if no concurrent infra connections are
Srikant Kuppa866893f2012-12-27 17:28:14 -08004821 * active and if the scan is a BG scan triggered by LFR (OR)
4822 * any scan if LFR is in the middle of a BG scan. Splitting
4823 * the scan is delaying the time it takes for LFR to find
4824 * candidates and resulting in disconnects.
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08004825 */
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +05304826 if ( (csrIsStaSessionConnected(pMac) &&
Srikant Kuppa866893f2012-12-27 17:28:14 -08004827#ifdef FEATURE_WLAN_LFR
4828 (csrIsConcurrentInfraConnected(pMac) ||
4829 ((pCommand->u.scanCmd.reason != eCsrScanBgScan) &&
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +05304830 (pMac->roam.neighborRoamInfo.neighborRoamState !=
Srikant Kuppa866893f2012-12-27 17:28:14 -08004831 eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN))) &&
4832#endif
4833 (pCommand->u.scanCmd.u.scanRequest.p2pSearch != 1)) ||
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +05304834 (csrIsP2pSessionConnected(pMac)) )
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08004835 {
Madan Mohan Koyyalamudid6713582012-11-09 16:56:56 -08004836 /* if active connected sessions present then continue to split scan
4837 * with specified interval between consecutive scans */
4838 csrSetDefaultScanTiming(pMac, pCommand->u.scanCmd.u.scanRequest.scanType, &(pCommand->u.scanCmd.u.scanRequest));
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05304839 vos_timer_start(&pMac->scan.hTimerStaApConcTimer,
4840 pCommand->u.scanCmd.u.scanRequest.restTime);
Madan Mohan Koyyalamudid6713582012-11-09 16:56:56 -08004841 } else {
4842 /* if no connected sessions present then initiate next scan command immediately */
4843 /* minimum timer granularity is 10ms */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05304844 vos_timer_start(&pMac->scan.hTimerStaApConcTimer, 10);
Madan Mohan Koyyalamudid6713582012-11-09 16:56:56 -08004845 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004846 }
4847#endif
4848 return (fRet);
4849}
4850
4851
4852tANI_BOOLEAN csrScanIsWildCardScan( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4853{
4854 tANI_U8 bssid[WNI_CFG_BSSID_LEN] = {0, 0, 0, 0, 0, 0};
4855 tANI_BOOLEAN f = palEqualMemory( pMac->hHdd, pCommand->u.scanCmd.u.scanRequest.bssid,
4856 bssid, sizeof(tCsrBssid) );
4857
4858 //It is not a wild card scan if the bssid is not broadcast and the number of SSID is 1.
4859 return ((tANI_BOOLEAN)( (f || (0xff == pCommand->u.scanCmd.u.scanRequest.bssid[0])) &&
4860 (pCommand->u.scanCmd.u.scanRequest.SSIDs.numOfSSIDs != 1) ));
4861}
4862
4863
4864eHalStatus csrScanSmeScanResponse( tpAniSirGlobal pMac, void *pMsgBuf )
4865{
4866 eHalStatus status = eHAL_STATUS_SUCCESS;
4867 tListElem *pEntry;
4868 tSmeCmd *pCommand;
4869 eCsrScanStatus scanStatus;
4870 tSirSmeScanRsp *pScanRsp = (tSirSmeScanRsp *)pMsgBuf;
4871 tSmeGetScanChnRsp *pScanChnInfo;
4872 tANI_BOOLEAN fRemoveCommand = eANI_BOOLEAN_TRUE;
4873 eCsrScanReason reason = eCsrScanOther;
4874
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +05304875 if (pMac->fScanOffload)
4876 pEntry = csrLLPeekHead(&pMac->sme.smeScanCmdActiveList,
4877 LL_ACCESS_LOCK);
4878 else
4879 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
Jeff Johnson295189b2012-06-20 16:38:30 -07004880
4881 if ( pEntry )
4882 {
4883 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
4884 if ( eSmeCommandScan == pCommand->command )
4885 {
4886 scanStatus = (eSIR_SME_SUCCESS == pScanRsp->statusCode) ? eCSR_SCAN_SUCCESS : eCSR_SCAN_FAILURE;
4887 reason = pCommand->u.scanCmd.reason;
4888 switch(pCommand->u.scanCmd.reason)
4889 {
4890 case eCsrScanAbortBgScan:
4891 case eCsrScanAbortNormalScan:
4892 case eCsrScanBGScanAbort:
4893 case eCsrScanBGScanEnable:
4894 break;
4895 case eCsrScanGetScanChnInfo:
4896 pScanChnInfo = (tSmeGetScanChnRsp *)pMsgBuf;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07004897 /*
4898 * status code not available in tSmeGetScanChnRsp, so
4899 * by default considereing it to be success
4900 */
4901 scanStatus = eSIR_SME_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004902 csrScanAgeResults(pMac, pScanChnInfo);
4903 break;
4904 case eCsrScanForCapsChange:
4905 csrScanProcessScanResults( pMac, pCommand, pScanRsp, &fRemoveCommand );
4906 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004907 case eCsrScanP2PFindPeer:
4908 scanStatus = ((eSIR_SME_SUCCESS == pScanRsp->statusCode) && (pScanRsp->length > 50)) ? eCSR_SCAN_FOUND_PEER : eCSR_SCAN_FAILURE;
4909 csrScanProcessScanResults( pMac, pCommand, pScanRsp, NULL );
4910 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004911 case eCsrScanSetBGScanParam:
4912 default:
4913 if(csrScanProcessScanResults( pMac, pCommand, pScanRsp, &fRemoveCommand ))
4914 {
4915 //Not to get channel info if the scan is not a wildcard scan because
4916 //it may cause scan results got aged out incorrectly.
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004917 if( csrScanIsWildCardScan( pMac, pCommand ) && (!pCommand->u.scanCmd.u.scanRequest.p2pSearch)
4918#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
4919 && (pCommand->u.scanCmd.reason != eCsrScanGetLfrResult)
4920#endif
4921 )
Jeff Johnson295189b2012-06-20 16:38:30 -07004922 {
4923 //Get the list of channels scanned
Jeff Johnson32d95a32012-09-10 13:15:23 -07004924 if( pCommand->u.scanCmd.reason != eCsrScanUserRequest)
4925 {
Madan Mohan Koyyalamudide1b5bc2013-07-12 00:56:04 +05304926 csrScanGetScanChnInfo(pMac, pCommand->sessionId,
4927 NULL, NULL);
Jeff Johnson32d95a32012-09-10 13:15:23 -07004928 }
4929 else
4930 {
Madan Mohan Koyyalamudide1b5bc2013-07-12 00:56:04 +05304931 csrScanGetScanChnInfo(pMac,
4932 pCommand->sessionId,
4933 pCommand->u.scanCmd.pContext,
4934 pCommand->u.scanCmd.callback);
Jeff Johnson32d95a32012-09-10 13:15:23 -07004935 pCommand->u.scanCmd.callback = NULL;
4936 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004937 }
4938 }
4939 break;
4940 }//switch
4941 if(fRemoveCommand)
4942 {
4943
4944 csrReleaseScanCommand(pMac, pCommand, scanStatus);
4945
Srikant Kuppa866893f2012-12-27 17:28:14 -08004946 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004947 smeProcessPendingQueue( pMac );
4948 }
4949 else
4950 {
4951 smsLog( pMac, LOGW, "CSR: Scan Completion called but SCAN command is not ACTIVE ..." );
4952 status = eHAL_STATUS_FAILURE;
4953 }
4954 }
4955 else
4956 {
4957 smsLog( pMac, LOGW, "CSR: Scan Completion called but NO commands are ACTIVE ..." );
4958 status = eHAL_STATUS_FAILURE;
4959 }
4960
4961 return (status);
4962}
4963
4964
4965
4966
4967tCsrScanResultInfo *csrScanResultGetFirst(tpAniSirGlobal pMac, tScanResultHandle hScanResult)
4968{
4969 tListElem *pEntry;
4970 tCsrScanResult *pResult;
4971 tCsrScanResultInfo *pRet = NULL;
4972 tScanResultList *pResultList = (tScanResultList *)hScanResult;
4973
4974 if(pResultList)
4975 {
4976 csrLLLock(&pResultList->List);
4977 pEntry = csrLLPeekHead(&pResultList->List, LL_ACCESS_NOLOCK);
4978 if(pEntry)
4979 {
4980 pResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
4981 pRet = &pResult->Result;
4982 }
4983 pResultList->pCurEntry = pEntry;
4984 csrLLUnlock(&pResultList->List);
4985 }
4986
4987 return pRet;
4988}
4989
4990
4991tCsrScanResultInfo *csrScanResultGetNext(tpAniSirGlobal pMac, tScanResultHandle hScanResult)
4992{
4993 tListElem *pEntry = NULL;
4994 tCsrScanResult *pResult = NULL;
4995 tCsrScanResultInfo *pRet = NULL;
4996 tScanResultList *pResultList = (tScanResultList *)hScanResult;
4997
4998 if(pResultList)
4999 {
5000 csrLLLock(&pResultList->List);
5001 if(NULL == pResultList->pCurEntry)
5002 {
5003 pEntry = csrLLPeekHead(&pResultList->List, LL_ACCESS_NOLOCK);
5004 }
5005 else
5006 {
5007 pEntry = csrLLNext(&pResultList->List, pResultList->pCurEntry, LL_ACCESS_NOLOCK);
5008 }
5009 if(pEntry)
5010 {
5011 pResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
5012 pRet = &pResult->Result;
5013 }
5014 pResultList->pCurEntry = pEntry;
5015 csrLLUnlock(&pResultList->List);
5016 }
5017
5018 return pRet;
5019}
5020
5021
5022//This function moves the first BSS that matches the bssid to the head of the result
5023eHalStatus csrMoveBssToHeadFromBSSID(tpAniSirGlobal pMac, tCsrBssid *bssid, tScanResultHandle hScanResult)
5024{
5025 eHalStatus status = eHAL_STATUS_FAILURE;
5026 tScanResultList *pResultList = (tScanResultList *)hScanResult;
5027 tCsrScanResult *pResult = NULL;
5028 tListElem *pEntry = NULL;
5029
5030 if(pResultList && bssid)
5031 {
5032 csrLLLock(&pResultList->List);
5033 pEntry = csrLLPeekHead(&pResultList->List, LL_ACCESS_NOLOCK);
5034 while(pEntry)
5035 {
5036 pResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
5037 if(palEqualMemory(pMac->hHdd, bssid, pResult->Result.BssDescriptor.bssId, sizeof(tCsrBssid)))
5038 {
5039 status = eHAL_STATUS_SUCCESS;
5040 csrLLRemoveEntry(&pResultList->List, pEntry, LL_ACCESS_NOLOCK);
5041 csrLLInsertHead(&pResultList->List, pEntry, LL_ACCESS_NOLOCK);
5042 break;
5043 }
5044 pEntry = csrLLNext(&pResultList->List, pResultList->pCurEntry, LL_ACCESS_NOLOCK);
5045 }
5046 csrLLUnlock(&pResultList->List);
5047 }
5048
5049 return (status);
5050}
5051
5052
5053//Remove the BSS if possible.
5054//Return -- TRUE == the BSS is remove. False == Fail to remove it
5055//This function is called when list lock is held. Be caution what functions it can call.
5056tANI_BOOLEAN csrScanAgeOutBss(tpAniSirGlobal pMac, tCsrScanResult *pResult)
5057{
5058 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
5059 tANI_U32 i;
5060 tCsrRoamSession *pSession;
5061
5062 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
5063 {
5064 if( CSR_IS_SESSION_VALID( pMac, i ) )
5065 {
5066 pSession = CSR_GET_SESSION( pMac, i );
5067 //Not to remove the BSS we are connected to.
5068 if(csrIsConnStateDisconnected(pMac, i) || (NULL == pSession->pConnectBssDesc) ||
5069 (!csrIsDuplicateBssDescription(pMac, &pResult->Result.BssDescriptor,
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07005070 pSession->pConnectBssDesc, NULL, FALSE))
Jeff Johnson295189b2012-06-20 16:38:30 -07005071 )
5072 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005073 smsLog(pMac, LOGW, "Aging out BSS %02X-%02X-%02X-%02X-%02X-%02X Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005074 pResult->Result.BssDescriptor.bssId[0],
5075 pResult->Result.BssDescriptor.bssId[1],
5076 pResult->Result.BssDescriptor.bssId[2],
5077 pResult->Result.BssDescriptor.bssId[3],
5078 pResult->Result.BssDescriptor.bssId[4],
5079 pResult->Result.BssDescriptor.bssId[5],
5080 pResult->Result.BssDescriptor.channelId);
5081 //No need to hold the spin lock because caller should hold the lock for pMac->scan.scanResultList
5082 if( csrLLRemoveEntry(&pMac->scan.scanResultList, &pResult->Link, LL_ACCESS_NOLOCK) )
5083 {
5084 csrFreeScanResultEntry(pMac, pResult);
Madan Mohan Koyyalamudi2e068bc2012-10-22 14:58:47 -07005085 fRet = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005086 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005087 break;
5088 }
5089 } //valid session
5090 } //for
Madan Mohan Koyyalamudi2e068bc2012-10-22 14:58:47 -07005091 if( CSR_ROAM_SESSION_MAX == i && fRet != eANI_BOOLEAN_TRUE )
Jeff Johnson295189b2012-06-20 16:38:30 -07005092 {
5093 //reset the counter so this won't hapeen too soon
5094 pResult->AgingCount = (tANI_S32)pMac->roam.configParam.agingCount;
5095 pResult->Result.BssDescriptor.nReceivedTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
5096 }
5097
5098 return (fRet);
5099}
5100
5101
5102eHalStatus csrScanAgeResults(tpAniSirGlobal pMac, tSmeGetScanChnRsp *pScanChnInfo)
5103{
5104 eHalStatus status = eHAL_STATUS_SUCCESS;
5105 tListElem *pEntry, *tmpEntry;
5106 tCsrScanResult *pResult;
5107 tLimScanChn *pChnInfo;
5108 tANI_U8 i;
5109
5110 csrLLLock(&pMac->scan.scanResultList);
5111 for(i = 0; i < pScanChnInfo->numChn; i++)
5112 {
5113 pChnInfo = &pScanChnInfo->scanChn[i];
5114 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
5115 while( pEntry )
5116 {
5117 tmpEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
5118 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
5119 if(pResult->Result.BssDescriptor.channelId == pChnInfo->channelId)
5120 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005121 if(pResult->AgingCount <= 0)
5122 {
5123 smsLog(pMac, LOGW, " age out due to ref count");
5124 csrScanAgeOutBss(pMac, pResult);
5125 }
Madan Mohan Koyyalamudib9d3dcc2012-09-28 16:47:50 -07005126 else
5127 {
5128 pResult->AgingCount--;
5129 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005130 }
5131 pEntry = tmpEntry;
5132 }
5133 }
5134 csrLLUnlock(&pMac->scan.scanResultList);
5135
5136 return (status);
5137}
5138
5139
5140eHalStatus csrSendMBScanReq( tpAniSirGlobal pMac, tANI_U16 sessionId,
5141 tCsrScanRequest *pScanReq, tScanReqParam *pScanReqParam )
5142{
5143 eHalStatus status = eHAL_STATUS_SUCCESS;
5144 tSirSmeScanReq *pMsg;
5145 tANI_U16 msgLen;
5146 tANI_U8 bssid[WNI_CFG_BSSID_LEN] = {0, 0, 0, 0, 0, 0};
5147 tSirScanType scanType = pScanReq->scanType;
5148 tANI_U32 minChnTime; //in units of milliseconds
5149 tANI_U32 maxChnTime; //in units of milliseconds
5150 tANI_U32 i;
5151 tANI_U8 selfMacAddr[WNI_CFG_BSSID_LEN];
5152 tANI_U8 *pSelfMac = NULL;
5153
5154 msgLen = (tANI_U16)(sizeof( tSirSmeScanReq ) - sizeof( pMsg->channelList.channelNumber ) +
5155 ( sizeof( pMsg->channelList.channelNumber ) * pScanReq->ChannelInfo.numOfChannels )) +
5156 ( pScanReq->uIEFieldLen ) ;
5157
5158 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
5159 if(HAL_STATUS_SUCCESS(status))
5160 {
5161 do
5162 {
5163 palZeroMemory(pMac->hHdd, pMsg, msgLen);
5164 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SCAN_REQ);
5165 pMsg->length = pal_cpu_to_be16(msgLen);
5166 //ToDO: Fill in session info when we need to do scan base on session.
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05305167 if ((pMac->fScanOffload) && (sessionId != CSR_SESSION_ID_INVALID))
5168 {
5169 pMsg->sessionId = sessionId;
5170 }
5171 else
5172 {
5173 /* if sessionId == CSR_SESSION_ID_INVALID, then send the scan
5174 request on first available session */
5175 pMsg->sessionId = 0;
5176 }
5177
Jeff Johnson295189b2012-06-20 16:38:30 -07005178 pMsg->transactionId = 0;
5179 pMsg->dot11mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac, csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
5180 pMsg->bssType = pal_cpu_to_be32(csrTranslateBsstypeToMacType(pScanReq->BSSType));
5181
5182 if ( CSR_IS_SESSION_VALID( pMac, sessionId ) )
5183 {
5184 pSelfMac = (tANI_U8 *)&pMac->roam.roamSession[sessionId].selfMacAddr;
5185 }
5186 else
5187 {
5188 // Since we don't have session for the scanning, we find a valid session. In case we fail to
5189 // do so, get the WNI_CFG_STA_ID
5190 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
5191 {
5192 if( CSR_IS_SESSION_VALID( pMac, i ) )
5193 {
5194 pSelfMac = (tANI_U8 *)&pMac->roam.roamSession[i].selfMacAddr;
5195 break;
5196 }
5197 }
5198 if( CSR_ROAM_SESSION_MAX == i )
5199 {
5200 tANI_U32 len = WNI_CFG_BSSID_LEN;
5201 pSelfMac = selfMacAddr;
5202 status = ccmCfgGetStr( pMac, WNI_CFG_STA_ID, pSelfMac, &len );
5203 if( !HAL_STATUS_SUCCESS( status ) ||
5204 ( len < WNI_CFG_BSSID_LEN ) )
5205 {
5206 smsLog( pMac, LOGE, FL(" Can not get self MAC address from CFG status = %d"), status );
5207 //Force failed status
5208 status = eHAL_STATUS_FAILURE;
5209 break;
5210 }
5211 }
5212 }
5213 palCopyMemory( pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr, pSelfMac, sizeof(tSirMacAddr) );
5214
5215 //sirCopyMacAddr
5216 palCopyMemory( pMac->hHdd, (tANI_U8 *)pMsg->bssId, (tANI_U8 *)&pScanReq->bssid, sizeof(tSirMacAddr) );
5217 if( palEqualMemory( pMac->hHdd, pScanReq->bssid, bssid, sizeof(tCsrBssid) ) )
5218 {
5219 palFillMemory( pMac->hHdd, pMsg->bssId, sizeof(tSirMacAddr), 0xff );
5220 }
5221 else
5222 {
5223 palCopyMemory(pMac->hHdd, pMsg->bssId, pScanReq->bssid, WNI_CFG_BSSID_LEN);
5224 }
5225 minChnTime = pScanReq->minChnTime;
5226 maxChnTime = pScanReq->maxChnTime;
5227
5228 //Verify the scan type first, if the scan is active scan, we need to make sure we
5229 //are allowed to do so.
5230 /* if 11d is enabled & we don't see any beacon around, scan type falls
5231 back to passive. But in BT AMP STA mode we need to send out a
5232 directed probe*/
5233 if( (eSIR_PASSIVE_SCAN != scanType) && (eCSR_SCAN_P2P_DISCOVERY != pScanReq->requestType)
5234 && (eCSR_BSS_TYPE_WDS_STA != pScanReq->BSSType)
5235 && (eANI_BOOLEAN_FALSE == pMac->scan.fEnableBypass11d))
5236 {
5237 scanType = pMac->scan.curScanType;
5238 if(eSIR_PASSIVE_SCAN == pMac->scan.curScanType)
5239 {
5240 if(minChnTime < pMac->roam.configParam.nPassiveMinChnTime)
5241 {
5242 minChnTime = pMac->roam.configParam.nPassiveMinChnTime;
5243 }
5244 if(maxChnTime < pMac->roam.configParam.nPassiveMaxChnTime)
5245 {
5246 maxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
5247 }
5248 }
5249 }
5250 pMsg->scanType = pal_cpu_to_be32(scanType);
5251
5252 pMsg->numSsid = (pScanReq->SSIDs.numOfSSIDs < SIR_SCAN_MAX_NUM_SSID) ? pScanReq->SSIDs.numOfSSIDs :
5253 SIR_SCAN_MAX_NUM_SSID;
5254 if((pScanReq->SSIDs.numOfSSIDs != 0) && ( eSIR_PASSIVE_SCAN != scanType ))
5255 {
Jeff Johnson40b59aa2013-03-19 14:43:18 -07005256 for (i = 0; i < pMsg->numSsid; i++)
5257 {
5258 palCopyMemory(pMac->hHdd, &pMsg->ssId[i], &pScanReq->SSIDs.SSIDList[i].SSID, sizeof(tSirMacSSid));
5259 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005260 }
5261 else
5262 {
5263 //Otherwise we scan all SSID and let the result filter later
Jeff Johnson40b59aa2013-03-19 14:43:18 -07005264 for (i = 0; i < SIR_SCAN_MAX_NUM_SSID; i++)
5265 {
5266 pMsg->ssId[i].length = 0;
5267 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005268 }
5269
Jeff Johnson295189b2012-06-20 16:38:30 -07005270 pMsg->minChannelTime = pal_cpu_to_be32(minChnTime);
5271 pMsg->maxChannelTime = pal_cpu_to_be32(maxChnTime);
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08005272 pMsg->minChannelTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
5273 pMsg->maxChannelTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005274 //hidden SSID option
5275 pMsg->hiddenSsid = pScanReqParam->hiddenSsid;
5276 //rest time
5277 //pMsg->restTime = pScanReq->restTime;
5278 pMsg->returnAfterFirstMatch = pScanReqParam->bReturnAfter1stMatch;
5279 // All the scan results caching will be done by Roaming
5280 // We do not want LIM to do any caching of scan results,
5281 // so delete the LIM cache on all scan requests
5282 pMsg->returnFreshResults = pScanReqParam->freshScan;
5283 //Always ask for unique result
5284 pMsg->returnUniqueResults = pScanReqParam->fUniqueResult;
5285 pMsg->channelList.numChannels = (tANI_U8)pScanReq->ChannelInfo.numOfChannels;
5286 if(pScanReq->ChannelInfo.numOfChannels)
5287 {
5288 //Assuming the channelNumber is tANI_U8 (1 byte)
5289 status = palCopyMemory(pMac->hHdd, pMsg->channelList.channelNumber, pScanReq->ChannelInfo.ChannelList,
5290 pScanReq->ChannelInfo.numOfChannels);
5291 }
5292
5293 pMsg->uIEFieldLen = (tANI_U16) pScanReq->uIEFieldLen;
5294 pMsg->uIEFieldOffset = (tANI_U16)(sizeof( tSirSmeScanReq ) - sizeof( pMsg->channelList.channelNumber ) +
5295 ( sizeof( pMsg->channelList.channelNumber ) * pScanReq->ChannelInfo.numOfChannels )) ;
5296 if(pScanReq->uIEFieldLen != 0)
5297 {
5298 palCopyMemory(pMac->hHdd, (tANI_U8 *)pMsg+pMsg->uIEFieldOffset,
5299 pScanReq->pIEField, pScanReq->uIEFieldLen );
5300 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005301 pMsg->p2pSearch = pScanReq->p2pSearch;
Jeff Johnson295189b2012-06-20 16:38:30 -07005302
Madan Mohan Koyyalamudi9b876782012-10-11 16:22:51 -07005303 if (pScanReq->requestType == eCSR_SCAN_HO_BG_SCAN)
5304 {
5305 pMsg->backgroundScanMode = eSIR_ROAMING_SCAN;
5306 }
5307
Jeff Johnson295189b2012-06-20 16:38:30 -07005308 }while(0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005309 smsLog(pMac, LOG1, FL("domainIdCurrent %d scanType %d bssType %d requestType %d numChannels %d "),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005310 pMac->scan.domainIdCurrent, pMsg->scanType, pMsg->bssType,
5311 pScanReq->requestType, pMsg->channelList.numChannels);
5312
5313 for(i = 0; i < pMsg->channelList.numChannels; i++)
5314 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005315 smsLog(pMac, LOG3, FL("channelNumber[%d]= %d"), i, pMsg->channelList.channelNumber[i]);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005316 }
5317
Jeff Johnson295189b2012-06-20 16:38:30 -07005318 if(HAL_STATUS_SUCCESS(status))
5319 {
5320 status = palSendMBMessage(pMac->hHdd, pMsg);
5321 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005322 else
5323 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005324 smsLog( pMac, LOGE, FL(" failed to send down scan req with status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005325 palFreeMemory(pMac->hHdd, pMsg);
5326 }
5327 }//Success allocated memory
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005328 else
5329 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005330 smsLog( pMac, LOGE, FL(" memory allocation failure"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005331 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005332
5333 return( status );
5334}
5335
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005336eHalStatus csrSendMBScanResultReq( tpAniSirGlobal pMac, tANI_U32 sessionId, tScanReqParam *pScanReqParam )
Jeff Johnson295189b2012-06-20 16:38:30 -07005337{
5338 eHalStatus status = eHAL_STATUS_SUCCESS;
5339 tSirSmeScanReq *pMsg;
5340 tANI_U16 msgLen;
5341
5342 msgLen = (tANI_U16)(sizeof( tSirSmeScanReq ));
5343 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
5344 if(HAL_STATUS_SUCCESS(status))
5345 {
5346 palZeroMemory(pMac->hHdd, pMsg, msgLen);
5347 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SCAN_REQ);
5348 pMsg->length = pal_cpu_to_be16(msgLen);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005349 pMsg->sessionId = sessionId;
5350 pMsg->transactionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005351 pMsg->returnFreshResults = pScanReqParam->freshScan;
5352 //Always ask for unique result
5353 pMsg->returnUniqueResults = pScanReqParam->fUniqueResult;
5354 pMsg->returnAfterFirstMatch = pScanReqParam->bReturnAfter1stMatch;
5355 status = palSendMBMessage(pMac->hHdd, pMsg);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005356 if (!HAL_STATUS_SUCCESS(status))
5357 {
5358 smsLog( pMac, LOGE, FL(" failed to send down scan req with status = %d\n"), status );
5359 }
5360
Jeff Johnson295189b2012-06-20 16:38:30 -07005361 }
5362
5363 return( status );
5364}
5365
5366
5367
5368eHalStatus csrScanChannels( tpAniSirGlobal pMac, tSmeCmd *pCommand )
5369{
5370 eHalStatus status = eHAL_STATUS_FAILURE;
5371 tScanReqParam scanReq;
5372
5373 do
5374 {
5375 scanReq.freshScan = CSR_SME_SCAN_FLAGS_DELETE_CACHE | TRUE;
5376 scanReq.fUniqueResult = TRUE;
5377 scanReq.hiddenSsid = SIR_SCAN_NO_HIDDEN_SSID;
5378 if(eCsrScanForSsid == pCommand->u.scanCmd.reason)
5379 {
5380 scanReq.bReturnAfter1stMatch = CSR_SCAN_RETURN_AFTER_FIRST_MATCH;
5381 }
5382 else
5383 {
5384 // Basically do scan on all channels even for 11D 1st scan case.
5385 scanReq.bReturnAfter1stMatch = CSR_SCAN_RETURN_AFTER_ALL_CHANNELS;
5386 }
5387 if((eCsrScanBgScan == pCommand->u.scanCmd.reason)||
5388 (eCsrScanProbeBss == pCommand->u.scanCmd.reason))
5389 {
5390 scanReq.hiddenSsid = SIR_SCAN_HIDDEN_SSID_PE_DECISION;
5391 }
5392
5393#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5394 {
5395 vos_log_scan_pkt_type *pScanLog = NULL;
5396
5397 WLAN_VOS_DIAG_LOG_ALLOC(pScanLog, vos_log_scan_pkt_type, LOG_WLAN_SCAN_C);
5398 if(pScanLog)
5399 {
5400 if(eCsrScanBgScan == pCommand->u.scanCmd.reason ||
5401 eCsrScanProbeBss == pCommand->u.scanCmd.reason)
5402 {
5403 pScanLog->eventId = WLAN_SCAN_EVENT_HO_SCAN_REQ;
5404 }
5405 else
5406 {
5407 if( (eSIR_PASSIVE_SCAN != pCommand->u.scanCmd.u.scanRequest.scanType) &&
5408 (eSIR_PASSIVE_SCAN != pMac->scan.curScanType) )
5409 {
5410 pScanLog->eventId = WLAN_SCAN_EVENT_ACTIVE_SCAN_REQ;
5411 }
5412 else
5413 {
5414 pScanLog->eventId = WLAN_SCAN_EVENT_PASSIVE_SCAN_REQ;
5415 }
5416 }
5417 pScanLog->minChnTime = (v_U8_t)pCommand->u.scanCmd.u.scanRequest.minChnTime;
5418 pScanLog->maxChnTime = (v_U8_t)pCommand->u.scanCmd.u.scanRequest.maxChnTime;
5419 pScanLog->numChannel = (v_U8_t)pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels;
5420 if(pScanLog->numChannel && (pScanLog->numChannel < VOS_LOG_MAX_NUM_CHANNEL))
5421 {
5422 palCopyMemory(pMac->hHdd, pScanLog->channels,
5423 pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList,
5424 pScanLog->numChannel);
5425 }
5426 WLAN_VOS_DIAG_LOG_REPORT(pScanLog);
5427 }
5428 }
5429#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5430
5431
5432 status = csrSendMBScanReq(pMac, pCommand->sessionId,
5433 &pCommand->u.scanCmd.u.scanRequest, &scanReq);
5434 }while(0);
5435
5436 return( status );
5437}
5438
5439
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005440eHalStatus csrScanRetrieveResult(tpAniSirGlobal pMac, tSmeCmd *pCommand)
Jeff Johnson295189b2012-06-20 16:38:30 -07005441{
5442 eHalStatus status = eHAL_STATUS_FAILURE;
5443 tScanReqParam scanReq;
5444
5445 do
5446 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005447#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5448 if (eCsrScanGetLfrResult == pCommand->u.scanCmd.reason)
5449 {
5450 //to get the LFR candidates from PE cache
5451 scanReq.freshScan = SIR_BG_SCAN_RETURN_LFR_CACHED_RESULTS|SIR_BG_SCAN_PURGE_LFR_RESULTS;
5452 scanReq.fUniqueResult = TRUE;
5453 scanReq.bReturnAfter1stMatch = CSR_SCAN_RETURN_AFTER_ALL_CHANNELS;
5454 }
5455 else
5456#endif
5457 {
5458 //not a fresh scan
5459 scanReq.freshScan = CSR_SME_SCAN_FLAGS_DELETE_CACHE;
5460 scanReq.fUniqueResult = TRUE;
5461 scanReq.bReturnAfter1stMatch = CSR_SCAN_RETURN_AFTER_ALL_CHANNELS;
5462 }
5463 status = csrSendMBScanResultReq(pMac, pCommand->sessionId, &scanReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07005464 }while(0);
5465
5466 return (status);
5467}
5468
5469
5470
5471eHalStatus csrProcessScanCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
5472{
5473 eHalStatus status = eHAL_STATUS_SUCCESS;
5474 tCsrChannelInfo newChannelInfo = {0, NULL};
5475 int i, j;
5476 tANI_U8 *pChannel = NULL;
5477 tANI_U32 len = 0;
5478
5479 // Transition to Scanning state...
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +05305480 if (!pMac->fScanOffload)
Jeff Johnson295189b2012-06-20 16:38:30 -07005481 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +05305482 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
5483 {
5484 pCommand->u.scanCmd.lastRoamState[i] =
5485 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_SCANNING, i);
5486 smsLog( pMac, LOG3, "starting SCAN command from %d state...."
5487 " reason is %d", pCommand->u.scanCmd.lastRoamState[i],
5488 pCommand->u.scanCmd.reason );
5489 }
5490 }
5491 else
5492 {
5493 pCommand->u.scanCmd.lastRoamState[pCommand->sessionId] =
5494 csrRoamStateChange(pMac, eCSR_ROAMING_STATE_SCANNING,
5495 pCommand->sessionId);
5496 smsLog( pMac, LOG3,
5497 "starting SCAN command from %d state.... reason is %d",
5498 pCommand->u.scanCmd.lastRoamState[pCommand->sessionId],
5499 pCommand->u.scanCmd.reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07005500 }
5501
5502 switch(pCommand->u.scanCmd.reason)
5503 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005504#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5505 case eCsrScanGetLfrResult:
5506#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005507 case eCsrScanGetResult:
5508 case eCsrScanForCapsChange: //For cap change, LIM already save BSS description
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005509 status = csrScanRetrieveResult(pMac, pCommand);
Jeff Johnson295189b2012-06-20 16:38:30 -07005510 break;
5511 case eCsrScanSetBGScanParam:
5512 status = csrProcessSetBGScanParam(pMac, pCommand);
5513 break;
5514 case eCsrScanBGScanAbort:
5515 status = csrSetCfgBackgroundScanPeriod(pMac, 0);
5516 break;
5517 case eCsrScanBGScanEnable:
5518 status = csrSetCfgBackgroundScanPeriod(pMac, pMac->roam.configParam.bgScanInterval);
5519 break;
5520 case eCsrScanGetScanChnInfo:
Madan Mohan Koyyalamudide1b5bc2013-07-12 00:56:04 +05305521 status = csrScanGetScanChannelInfo(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005522 break;
5523 case eCsrScanUserRequest:
5524 if(pMac->roam.configParam.fScanTwice)
5525 {
5526 //We scan 2.4 channel twice
5527 if(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels &&
5528 (NULL != pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList))
5529 {
5530 len = pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels;
5531 //allocate twice the channel
5532 newChannelInfo.ChannelList = (tANI_U8 *)vos_mem_malloc(newChannelInfo.numOfChannels * 2);
5533 pChannel = pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList;
5534 }
5535 else
5536 {
5537 //get the valid channel list to scan all.
5538 len = sizeof(pMac->roam.validChannelList);
5539
5540 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
5541 {
5542 //allocate twice the channel
5543 newChannelInfo.ChannelList = (tANI_U8 *)vos_mem_malloc(len * 2);
5544 pChannel = pMac->roam.validChannelList;
5545 }
5546 }
5547 if(NULL == newChannelInfo.ChannelList)
5548 {
5549 newChannelInfo.numOfChannels = 0;
5550 }
5551 else
5552 {
5553 j = 0;
5554 for(i = 0; i < len; i++)
5555 {
5556 newChannelInfo.ChannelList[j++] = pChannel[i];
5557 if(CSR_MAX_24GHz_CHANNEL_NUMBER >= pChannel[i])
5558 {
5559 newChannelInfo.ChannelList[j++] = pChannel[i];
5560 }
5561 }
5562 if(NULL != pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList)
5563 {
5564 //pChannel points to the channellist from the command, free it.
5565 vos_mem_free(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList);
James Zmuda9ea1edd2013-04-18 18:20:54 -07005566 pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005567 }
5568 pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = j;
5569 pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = newChannelInfo.ChannelList;
5570 }
5571 } //if(pMac->roam.configParam.fScanTwice)
5572
5573 status = csrScanChannels(pMac, pCommand);
5574
5575 break;
5576 default:
5577 status = csrScanChannels(pMac, pCommand);
5578 break;
5579 }
5580
5581 if(!HAL_STATUS_SUCCESS(status))
5582 {
5583 csrReleaseScanCommand(pMac, pCommand, eCSR_SCAN_FAILURE);
5584 }
5585
5586 return (status);
5587}
5588
5589
5590eHalStatus csrScanSetBGScanparams(tpAniSirGlobal pMac, tCsrBGScanRequest *pScanReq)
5591{
5592 eHalStatus status = eHAL_STATUS_SUCCESS;
5593 tSmeCmd *pCommand = NULL;
5594
5595 if(pScanReq)
5596 {
5597 do
5598 {
5599 pCommand = csrGetCommandBuffer(pMac);
5600 if(!pCommand)
5601 {
5602 status = eHAL_STATUS_RESOURCES;
5603 break;
5604 }
5605 palZeroMemory(pMac->hHdd, &pCommand->u.scanCmd, sizeof(tScanCmd));
5606 pCommand->command = eSmeCommandScan;
5607 pCommand->u.scanCmd.reason = eCsrScanSetBGScanParam;
5608 pCommand->u.scanCmd.callback = NULL;
5609 pCommand->u.scanCmd.pContext = NULL;
5610 palCopyMemory(pMac->hHdd, &pCommand->u.scanCmd.u.bgScanRequest, pScanReq, sizeof(tCsrBGScanRequest));
5611 //we have to do the follow
5612 if(pScanReq->ChannelInfo.numOfChannels == 0)
5613 {
5614 pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList = NULL;
5615 }
5616 else
5617 {
5618 status = palAllocateMemory(pMac->hHdd, (void **)&pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList,
5619 pScanReq->ChannelInfo.numOfChannels);
5620 if(HAL_STATUS_SUCCESS(status))
5621 {
5622 palCopyMemory(pMac->hHdd, pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList,
5623 pScanReq->ChannelInfo.ChannelList, pScanReq->ChannelInfo.numOfChannels);
5624 }
5625 else
5626 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005627 smsLog(pMac, LOGE, FL("ran out of memory"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005628 csrReleaseCommandScan(pMac, pCommand);
5629 break;
5630 }
5631 }
5632
5633 //scan req for SSID
5634 if(pScanReq->SSID.length)
5635 {
5636 palCopyMemory(pMac->hHdd,
5637 pCommand->u.scanCmd.u.bgScanRequest.SSID.ssId,
5638 pScanReq->SSID.ssId,
5639 pScanReq->SSID.length);
5640 pCommand->u.scanCmd.u.bgScanRequest.SSID.length = pScanReq->SSID.length;
5641
5642 }
5643 pCommand->u.scanCmd.u.bgScanRequest.maxChnTime= pScanReq->maxChnTime;
5644 pCommand->u.scanCmd.u.bgScanRequest.minChnTime = pScanReq->minChnTime;
5645 pCommand->u.scanCmd.u.bgScanRequest.scanInterval = pScanReq->scanInterval;
5646
5647
5648 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
5649 if( !HAL_STATUS_SUCCESS( status ) )
5650 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005651 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005652 csrReleaseCommandScan( pMac, pCommand );
5653 break;
5654 }
5655 }while(0);
5656 }
5657
5658 return (status);
5659}
5660
5661eHalStatus csrScanBGScanAbort( tpAniSirGlobal pMac )
5662{
5663 eHalStatus status = eHAL_STATUS_SUCCESS;
5664 tSmeCmd *pCommand = NULL;
5665
5666 do
5667 {
5668 pCommand = csrGetCommandBuffer(pMac);
5669 if(!pCommand)
5670 {
5671 status = eHAL_STATUS_RESOURCES;
5672 break;
5673 }
5674 palZeroMemory(pMac->hHdd, &pCommand->u.scanCmd, sizeof(tScanCmd));
5675 pCommand->command = eSmeCommandScan;
5676 pCommand->u.scanCmd.reason = eCsrScanBGScanAbort;
5677 pCommand->u.scanCmd.callback = NULL;
5678 pCommand->u.scanCmd.pContext = NULL;
5679 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
5680 if( !HAL_STATUS_SUCCESS( status ) )
5681 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005682 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005683 csrReleaseCommandScan( pMac, pCommand );
5684 break;
5685 }
5686 }while(0);
5687
5688 return (status);
5689}
5690
5691
5692//This will enable the background scan with the non-zero interval
5693eHalStatus csrScanBGScanEnable(tpAniSirGlobal pMac)
5694{
5695 eHalStatus status = eHAL_STATUS_SUCCESS;
5696 tSmeCmd *pCommand = NULL;
5697
5698 if(pMac->roam.configParam.bgScanInterval)
5699 {
5700 do
5701 {
5702 pCommand = csrGetCommandBuffer(pMac);
5703 if(!pCommand)
5704 {
5705 status = eHAL_STATUS_RESOURCES;
5706 break;
5707 }
5708 palZeroMemory(pMac->hHdd, &pCommand->u.scanCmd, sizeof(tScanCmd));
5709 pCommand->command = eSmeCommandScan;
5710 pCommand->u.scanCmd.reason = eCsrScanBGScanEnable;
5711 pCommand->u.scanCmd.callback = NULL;
5712 pCommand->u.scanCmd.pContext = NULL;
5713 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
5714 if( !HAL_STATUS_SUCCESS( status ) )
5715 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005716 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005717 csrReleaseCommandScan( pMac, pCommand );
5718 break;
5719 }
5720 }while(0);
5721 //BG scan results are reported automatically by PE to SME once the scan is done.
5722 //No need to fetch the results explicitly.
5723 //csrScanStartGetResultTimer(pMac);
5724 csrScanStartResultAgingTimer(pMac);
5725 }
5726 else
5727 {
5728 //We don't have BG scan so stop the aging timer
5729 csrScanStopResultAgingTimer(pMac);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005730 smsLog(pMac, LOGE, FL("cannot continue because the bgscan interval is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005731 status = eHAL_STATUS_INVALID_PARAMETER;
5732 }
5733
5734 return (status);
5735}
5736
5737
5738eHalStatus csrScanCopyRequest(tpAniSirGlobal pMac, tCsrScanRequest *pDstReq, tCsrScanRequest *pSrcReq)
5739{
5740 eHalStatus status = eHAL_STATUS_SUCCESS;
5741 tANI_U32 len = sizeof(pMac->roam.validChannelList);
5742 tANI_U32 index = 0;
5743 tANI_U32 new_index = 0;
5744
5745 do
5746 {
5747 status = csrScanFreeRequest(pMac, pDstReq);
5748 if(HAL_STATUS_SUCCESS(status))
5749 {
5750 status = palCopyMemory(pMac->hHdd, pDstReq, pSrcReq, sizeof(tCsrScanRequest));
Gopichand Nakkalac7b1d3e2012-12-31 14:07:19 -08005751 /* Re-initialize the pointers to NULL since we did a copy */
5752 pDstReq->pIEField = NULL;
5753 pDstReq->ChannelInfo.ChannelList = NULL;
5754 pDstReq->SSIDs.SSIDList = NULL;
5755
Jeff Johnson295189b2012-06-20 16:38:30 -07005756 if(pSrcReq->uIEFieldLen == 0)
5757 {
5758 pDstReq->pIEField = NULL;
5759 }
5760 else
5761 {
5762 status = palAllocateMemory(pMac->hHdd, (void **)&pDstReq->pIEField, pSrcReq->uIEFieldLen);
5763 if(HAL_STATUS_SUCCESS(status))
5764 {
5765 palCopyMemory(pMac->hHdd, pDstReq->pIEField, pSrcReq->pIEField, pSrcReq->uIEFieldLen);
5766 pDstReq->uIEFieldLen = pSrcReq->uIEFieldLen;
5767 }
5768 else
5769 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005770 smsLog(pMac, LOGE, "No memory for scanning IE fields");
Jeff Johnson295189b2012-06-20 16:38:30 -07005771 break;
5772 }
5773 }//Allocate memory for IE field
5774 {
5775 if(pSrcReq->ChannelInfo.numOfChannels == 0)
5776 {
5777 pDstReq->ChannelInfo.ChannelList = NULL;
5778 pDstReq->ChannelInfo.numOfChannels = 0;
5779 }
5780 else
5781 {
5782 status = palAllocateMemory(pMac->hHdd, (void **)&pDstReq->ChannelInfo.ChannelList,
5783 pSrcReq->ChannelInfo.numOfChannels * sizeof(*pDstReq->ChannelInfo.ChannelList));
5784 if(!HAL_STATUS_SUCCESS(status))
5785 {
5786 pDstReq->ChannelInfo.numOfChannels = 0;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005787 smsLog(pMac, LOGE, "No memory for scanning Channel List");
Jeff Johnson295189b2012-06-20 16:38:30 -07005788 break;
5789 }
5790
5791 if((pSrcReq->scanType == eSIR_PASSIVE_SCAN) && (pSrcReq->requestType == eCSR_SCAN_REQUEST_11D_SCAN))
5792 {
5793 for ( index = 0; index < pSrcReq->ChannelInfo.numOfChannels ; index++ )
5794 {
5795 pDstReq->ChannelInfo.ChannelList[new_index] =
5796 pSrcReq->ChannelInfo.ChannelList[index];
5797 new_index++;
5798 }
5799 pDstReq->ChannelInfo.numOfChannels = new_index;
5800 }
5801 else if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
5802 {
5803 new_index = 0;
5804 pMac->roam.numValidChannels = len;
5805 for ( index = 0; index < pSrcReq->ChannelInfo.numOfChannels ; index++ )
5806 {
Madan Mohan Koyyalamudi783b2362012-10-21 11:54:41 -07005807 /* Allow scan on valid channels only.
5808 * If it is p2p scan and valid channel list doesnt contain
5809 * social channels, enforce scan on social channels because
5810 * that is the only way to find p2p peers.
5811 * This can happen only if band is set to 5Ghz mode.
5812 */
Madan Mohan Koyyalamudic5992c92012-11-15 16:40:57 -08005813 if((csrRoamIsValidChannel(pMac, pSrcReq->ChannelInfo.ChannelList[index])) ||
5814 ((eCSR_SCAN_P2P_DISCOVERY == pSrcReq->requestType) &&
Madan Mohan Koyyalamudi783b2362012-10-21 11:54:41 -07005815 CSR_IS_SOCIAL_CHANNEL(pSrcReq->ChannelInfo.ChannelList[index])))
Jeff Johnson295189b2012-06-20 16:38:30 -07005816 {
Srikant Kuppa866893f2012-12-27 17:28:14 -08005817 if( (pSrcReq->skipDfsChnlInP2pSearch &&
Madan Mohan Koyyalamudic5992c92012-11-15 16:40:57 -08005818 (NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(pSrcReq->ChannelInfo.ChannelList[index])) )
Srikant Kuppa866893f2012-12-27 17:28:14 -08005819#ifdef FEATURE_WLAN_LFR
5820 /*
5821 * If LFR is requesting a contiguous scan
5822 * (i.e. numOfChannels > 1), then ignore
5823 * DFS channels.
5824 * TODO: vos_nv_getChannelEnabledState is returning
5825 * 120, 124 and 128 as non-DFS channels. Hence, the
5826 * use of direct check for channels below.
5827 */
5828 || ((eCSR_SCAN_HO_BG_SCAN == pSrcReq->requestType) &&
5829 (pSrcReq->ChannelInfo.numOfChannels > 1) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08005830 (CSR_IS_CHANNEL_DFS(pSrcReq->ChannelInfo.ChannelList[index])))
Srikant Kuppa866893f2012-12-27 17:28:14 -08005831#endif
5832 )
5833 {
5834#ifdef FEATURE_WLAN_LFR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005835 smsLog(pMac, LOG2,
Srikant Kuppa866893f2012-12-27 17:28:14 -08005836 "%s: reqType=%d, numOfChannels=%d,"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005837 " ignoring DFS channel %d",
Srikant Kuppa866893f2012-12-27 17:28:14 -08005838 __func__, pSrcReq->requestType,
5839 pSrcReq->ChannelInfo.numOfChannels,
5840 pSrcReq->ChannelInfo.ChannelList[index]);
5841#endif
Madan Mohan Koyyalamudic5992c92012-11-15 16:40:57 -08005842 continue;
Srikant Kuppa866893f2012-12-27 17:28:14 -08005843 }
Madan Mohan Koyyalamudic5992c92012-11-15 16:40:57 -08005844
Jeff Johnson295189b2012-06-20 16:38:30 -07005845 pDstReq->ChannelInfo.ChannelList[new_index] =
5846 pSrcReq->ChannelInfo.ChannelList[index];
5847 new_index++;
5848 }
5849 }
5850 pDstReq->ChannelInfo.numOfChannels = new_index;
Srikant Kuppa866893f2012-12-27 17:28:14 -08005851#ifdef FEATURE_WLAN_LFR
5852 if ((eCSR_SCAN_HO_BG_SCAN == pSrcReq->requestType) &&
5853 (0 == pDstReq->ChannelInfo.numOfChannels))
5854 {
5855 /*
5856 * No valid channels found in the request.
5857 * Only perform scan on the channels passed
5858 * pSrcReq if it is a eCSR_SCAN_HO_BG_SCAN.
5859 * Passing 0 to LIM will trigger a scan on
5860 * all valid channels which is not desirable.
5861 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005862 smsLog(pMac, LOGE, "%s: no valid channels found (request=%d)",
Srikant Kuppa866893f2012-12-27 17:28:14 -08005863 __func__, pSrcReq->requestType);
5864 for ( index = 0; index < pSrcReq->ChannelInfo.numOfChannels ; index++ )
5865 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005866 smsLog(pMac, LOGE, "pSrcReq index=%d channel=%d",
Srikant Kuppa866893f2012-12-27 17:28:14 -08005867 index, pSrcReq->ChannelInfo.ChannelList[index]);
5868 }
5869 status = eHAL_STATUS_FAILURE;
5870 break;
5871 }
5872#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005873 }
5874 else
5875 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005876 smsLog(pMac, LOGE, "Couldn't get the valid Channel List, keeping requester's list");
Jeff Johnson295189b2012-06-20 16:38:30 -07005877 palCopyMemory(pMac->hHdd, pDstReq->ChannelInfo.ChannelList, pSrcReq->ChannelInfo.ChannelList,
5878 pSrcReq->ChannelInfo.numOfChannels * sizeof(*pDstReq->ChannelInfo.ChannelList));
5879 pDstReq->ChannelInfo.numOfChannels = pSrcReq->ChannelInfo.numOfChannels;
5880 }
5881 }//Allocate memory for Channel List
5882 }
5883 if(pSrcReq->SSIDs.numOfSSIDs == 0)
5884 {
5885 pDstReq->SSIDs.numOfSSIDs = 0;
5886 pDstReq->SSIDs.SSIDList = NULL;
5887 }
5888 else
5889 {
5890 status = palAllocateMemory(pMac->hHdd, (void **)&pDstReq->SSIDs.SSIDList,
5891 pSrcReq->SSIDs.numOfSSIDs * sizeof(*pDstReq->SSIDs.SSIDList));
5892 if(HAL_STATUS_SUCCESS(status))
5893 {
5894 pDstReq->SSIDs.numOfSSIDs = pSrcReq->SSIDs.numOfSSIDs;
5895 palCopyMemory(pMac->hHdd, pDstReq->SSIDs.SSIDList, pSrcReq->SSIDs.SSIDList,
5896 pSrcReq->SSIDs.numOfSSIDs * sizeof(*pDstReq->SSIDs.SSIDList));
5897 }
5898 else
5899 {
5900 pDstReq->SSIDs.numOfSSIDs = 0;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005901 smsLog(pMac, LOGE, "No memory for scanning SSID List");
Jeff Johnson295189b2012-06-20 16:38:30 -07005902 break;
5903 }
5904 }//Allocate memory for SSID List
Jeff Johnson295189b2012-06-20 16:38:30 -07005905 pDstReq->p2pSearch = pSrcReq->p2pSearch;
Jeff Johnsone7245742012-09-05 17:12:55 -07005906 pDstReq->skipDfsChnlInP2pSearch = pSrcReq->skipDfsChnlInP2pSearch;
Jeff Johnson295189b2012-06-20 16:38:30 -07005907
5908 }
5909 }while(0);
5910
5911 if(!HAL_STATUS_SUCCESS(status))
5912 {
5913 csrScanFreeRequest(pMac, pDstReq);
5914 }
5915
5916 return (status);
5917}
5918
5919
5920eHalStatus csrScanFreeRequest(tpAniSirGlobal pMac, tCsrScanRequest *pReq)
5921{
5922 eHalStatus status = eHAL_STATUS_SUCCESS;
5923
5924 if(pReq->ChannelInfo.ChannelList)
5925 {
5926 status = palFreeMemory(pMac->hHdd, pReq->ChannelInfo.ChannelList);
5927 pReq->ChannelInfo.ChannelList = NULL;
5928 }
5929 pReq->ChannelInfo.numOfChannels = 0;
5930 if(pReq->pIEField)
5931 {
5932 status = palFreeMemory(pMac->hHdd, pReq->pIEField);
5933 pReq->pIEField = NULL;
5934 }
5935 pReq->uIEFieldLen = 0;
5936 if(pReq->SSIDs.SSIDList)
5937 {
5938 palFreeMemory(pMac->hHdd, pReq->SSIDs.SSIDList);
5939 pReq->SSIDs.SSIDList = NULL;
5940 }
5941 pReq->SSIDs.numOfSSIDs = 0;
5942
5943 return (status);
5944}
5945
5946
5947void csrScanCallCallback(tpAniSirGlobal pMac, tSmeCmd *pCommand, eCsrScanStatus scanStatus)
5948{
5949 if(pCommand->u.scanCmd.callback)
5950 {
5951// sme_ReleaseGlobalLock( &pMac->sme );
5952 pCommand->u.scanCmd.callback(pMac, pCommand->u.scanCmd.pContext, pCommand->u.scanCmd.scanID, scanStatus);
5953// sme_AcquireGlobalLock( &pMac->sme );
5954 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005955 smsLog( pMac, LOG2, "%s:%d - Callback NULL!!!", __func__, __LINE__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005956 }
5957}
5958
5959
5960void csrScanStopTimers(tpAniSirGlobal pMac)
5961{
5962 csrScanStopResultAgingTimer(pMac);
5963 csrScanStopIdleScanTimer(pMac);
5964 csrScanStopGetResultTimer(pMac);
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08005965 if(0 != pMac->scan.scanResultCfgAgingTime )
5966 {
5967 csrScanStopResultCfgAgingTimer(pMac);
5968 }
5969
Jeff Johnson295189b2012-06-20 16:38:30 -07005970}
5971
5972
5973eHalStatus csrScanStartGetResultTimer(tpAniSirGlobal pMac)
5974{
5975 eHalStatus status;
5976
5977 if(pMac->scan.fScanEnable)
5978 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05305979 status = vos_timer_start(&pMac->scan.hTimerGetResult, CSR_SCAN_GET_RESULT_INTERVAL/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -07005980 }
5981 else
5982 {
5983 status = eHAL_STATUS_FAILURE;
5984 }
5985
5986 return (status);
5987}
5988
5989
5990eHalStatus csrScanStopGetResultTimer(tpAniSirGlobal pMac)
5991{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05305992 return (vos_timer_stop(&pMac->scan.hTimerGetResult));
Jeff Johnson295189b2012-06-20 16:38:30 -07005993}
5994
5995
5996void csrScanGetResultTimerHandler(void *pv)
5997{
5998 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
5999
6000 csrScanRequestResult(pMac);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306001
6002 vos_timer_start(&pMac->scan.hTimerGetResult, CSR_SCAN_GET_RESULT_INTERVAL/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -07006003}
6004
6005#ifdef WLAN_AP_STA_CONCURRENCY
6006static void csrStaApConcTimerHandler(void *pv)
6007{
6008 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
6009 tListElem *pEntry;
6010 tSmeCmd *pScanCmd;
6011
6012 csrLLLock(&pMac->scan.scanCmdPendingList);
6013
6014 if ( NULL != ( pEntry = csrLLPeekHead( &pMac->scan.scanCmdPendingList, LL_ACCESS_NOLOCK) ) )
6015 {
6016 tCsrScanRequest scanReq;
6017 tSmeCmd *pSendScanCmd = NULL;
6018 tANI_U8 numChn = 0;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07006019 tANI_U8 nNumChanCombinedConc = 0;
Vinay Malekal05fdc812012-12-17 13:04:30 -08006020 tANI_U8 i, j;
Jeff Johnson295189b2012-06-20 16:38:30 -07006021 tCsrChannelInfo *pChnInfo = &scanReq.ChannelInfo;
6022 tANI_U8 channelToScan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
6023 eHalStatus status;
6024
Jeff Johnson295189b2012-06-20 16:38:30 -07006025 pScanCmd = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6026 numChn = pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels;
Madan Mohan Koyyalamudid6713582012-11-09 16:56:56 -08006027
6028 /* if any session is connected and the number of channels to scan is
6029 * greater than 1 then split the scan into multiple scan operations
6030 * on each individual channel else continue to perform scan on all
6031 * specified channels */
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08006032
6033 /* split scan if number of channels to scan is greater than 1 and
6034 * any one of the following:
6035 * - STA session is connected and the scan is not a P2P search
6036 * - any P2P session is connected
Srikant Kuppa866893f2012-12-27 17:28:14 -08006037 * Do not split scans if no concurrent infra connections are
6038 * active and if the scan is a BG scan triggered by LFR (OR)
6039 * any scan if LFR is in the middle of a BG scan. Splitting
6040 * the scan is delaying the time it takes for LFR to find
6041 * candidates and resulting in disconnects.
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08006042 */
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07006043
6044 if((csrIsStaSessionConnected(pMac) &&
6045 !csrIsP2pSessionConnected(pMac)))
6046 {
6047 nNumChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
6048 }
6049 else if(csrIsP2pSessionConnected(pMac))
6050 {
6051 nNumChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
6052 }
6053
6054 if ( (numChn > nNumChanCombinedConc) &&
Srikant Kuppa866893f2012-12-27 17:28:14 -08006055 ((csrIsStaSessionConnected(pMac) &&
6056#ifdef FEATURE_WLAN_LFR
6057 (csrIsConcurrentInfraConnected(pMac) ||
6058 ((pScanCmd->u.scanCmd.reason != eCsrScanBgScan) &&
6059 (pMac->roam.neighborRoamInfo.neighborRoamState !=
6060 eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN))) &&
6061#endif
6062 (pScanCmd->u.scanCmd.u.scanRequest.p2pSearch != 1)) ||
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08006063 (csrIsP2pSessionConnected(pMac))))
Jeff Johnson295189b2012-06-20 16:38:30 -07006064 {
6065 palZeroMemory(pMac->hHdd, &scanReq, sizeof(tCsrScanRequest));
6066
6067 pSendScanCmd = csrGetCommandBuffer(pMac); //optimize this to use 2 command buffer only
6068 if (!pSendScanCmd)
6069 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006070 smsLog( pMac, LOGE, FL(" Failed to get Queue command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006071 csrLLUnlock(&pMac->scan.scanCmdPendingList);
6072 return;
6073 }
6074 pSendScanCmd->command = pScanCmd->command;
6075 pSendScanCmd->sessionId = pScanCmd->sessionId;
6076 pSendScanCmd->u.scanCmd.callback = NULL;
6077 pSendScanCmd->u.scanCmd.pContext = pScanCmd->u.scanCmd.pContext;
6078 pSendScanCmd->u.scanCmd.reason = pScanCmd->u.scanCmd.reason;
6079 pSendScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around
6080
Madan Mohan Koyyalamudiaf2a8b92012-10-09 14:58:07 -07006081 /* First copy all the parameters to local variable of scan request */
6082 csrScanCopyRequest(pMac, &scanReq, &pScanCmd->u.scanCmd.u.scanRequest);
6083
6084 /* Now modify the elements of local var scan request required to be modified for split scan */
Madan Mohan Koyyalamudi0c626f32012-11-30 15:10:25 -08006085 if(scanReq.ChannelInfo.ChannelList != NULL)
6086 {
6087 palFreeMemory(pMac->hHdd,scanReq.ChannelInfo.ChannelList);
6088 scanReq.ChannelInfo.ChannelList = NULL;
6089 }
6090
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07006091 pChnInfo->numOfChannels = nNumChanCombinedConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08006092 palCopyMemory(pMac->hHdd, &channelToScan[0], &pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[0],
6093 pChnInfo->numOfChannels * sizeof(tANI_U8)); //just send one channel
Jeff Johnson295189b2012-06-20 16:38:30 -07006094 pChnInfo->ChannelList = &channelToScan[0];
6095
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07006096 for (i = 0, j = nNumChanCombinedConc; i < (numChn-nNumChanCombinedConc); i++, j++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006097 {
6098 pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[i] =
Vinay Malekal05fdc812012-12-17 13:04:30 -08006099 pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[j]; //Move all the channels one step
Jeff Johnson295189b2012-06-20 16:38:30 -07006100 }
6101
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07006102 pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = numChn - nNumChanCombinedConc; //reduce outstanding # of channels to be scanned
Jeff Johnson295189b2012-06-20 16:38:30 -07006103
6104 scanReq.BSSType = eCSR_BSS_TYPE_ANY;
6105 //Modify callers parameters in case of concurrency
6106 scanReq.scanType = eSIR_ACTIVE_SCAN;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07006107 //Use concurrency values for min/maxChnTime.
6108 //We know csrIsAnySessionConnected(pMac) returns TRUE here
6109 csrSetDefaultScanTiming(pMac, scanReq.scanType, &scanReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07006110
6111 status = csrScanCopyRequest(pMac, &pSendScanCmd->u.scanCmd.u.scanRequest, &scanReq);
6112 if(!HAL_STATUS_SUCCESS(status))
6113 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006114 smsLog( pMac, LOGE, FL(" Failed to get copy csrScanRequest = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006115 csrLLUnlock(&pMac->scan.scanCmdPendingList);
6116 return;
Madan Mohan Koyyalamudi0c626f32012-11-30 15:10:25 -08006117 }
6118 /* Clean the local scan variable */
6119 scanReq.ChannelInfo.ChannelList = NULL;
6120 scanReq.ChannelInfo.numOfChannels = 0;
6121 csrScanFreeRequest(pMac, &scanReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07006122 }
6123 else
Madan Mohan Koyyalamudid6713582012-11-09 16:56:56 -08006124 {
6125 /* no active connected session present or numChn == 1
6126 * scan all remaining channels */
Jeff Johnson295189b2012-06-20 16:38:30 -07006127 pSendScanCmd = pScanCmd;
6128 //remove this command from pending list
6129 if (csrLLRemoveHead( &pMac->scan.scanCmdPendingList, LL_ACCESS_NOLOCK) == NULL)
6130 { //In case between PeekHead and here, the entry got removed by another thread.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006131 smsLog( pMac, LOGE, FL(" Failed to remove entry from scanCmdPendingList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006132 }
6133
6134 }
6135 csrQueueSmeCommand(pMac, pSendScanCmd, eANI_BOOLEAN_FALSE);
6136
6137 }
6138
Jeff Johnson295189b2012-06-20 16:38:30 -07006139 csrLLUnlock(&pMac->scan.scanCmdPendingList);
6140
6141}
6142#endif
6143
6144eHalStatus csrScanStartResultAgingTimer(tpAniSirGlobal pMac)
6145{
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08006146 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006147
6148 if(pMac->scan.fScanEnable)
6149 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306150 status = vos_timer_start(&pMac->scan.hTimerResultAging, CSR_SCAN_RESULT_AGING_INTERVAL/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -07006151 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006152 return (status);
6153}
6154
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08006155eHalStatus csrScanStartResultCfgAgingTimer(tpAniSirGlobal pMac)
6156{
6157 eHalStatus status = eHAL_STATUS_FAILURE;
6158
6159 if(pMac->scan.fScanEnable)
6160 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306161 status = vos_timer_start(&pMac->scan.hTimerResultCfgAging, CSR_SCAN_RESULT_CFG_AGING_INTERVAL/PAL_TIMER_TO_MS_UNIT);
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08006162 }
6163 return (status);
6164}
Jeff Johnson295189b2012-06-20 16:38:30 -07006165
6166eHalStatus csrScanStopResultAgingTimer(tpAniSirGlobal pMac)
6167{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306168 return (vos_timer_stop(&pMac->scan.hTimerResultAging));
Jeff Johnson295189b2012-06-20 16:38:30 -07006169}
6170
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08006171eHalStatus csrScanStopResultCfgAgingTimer(tpAniSirGlobal pMac)
6172{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306173 return (vos_timer_stop(&pMac->scan.hTimerResultCfgAging));
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08006174}
Jeff Johnson295189b2012-06-20 16:38:30 -07006175
6176//This function returns the maximum time a BSS is allowed in the scan result.
6177//The time varies base on connection and power saving factors.
6178//Not connected, No PS
6179//Not connected, with PS
6180//Connected w/o traffic, No PS
6181//Connected w/o traffic, with PS
6182//Connected w/ traffic, no PS -- Not supported
6183//Connected w/ traffic, with PS -- Not supported
6184//the return unit is in seconds.
6185tANI_U32 csrScanGetAgeOutTime(tpAniSirGlobal pMac)
6186{
6187 tANI_U32 nRet;
6188
6189 if(pMac->scan.nAgingCountDown)
6190 {
6191 //Calculate what should be the timeout value for this
6192 nRet = pMac->scan.nLastAgeTimeOut * pMac->scan.nAgingCountDown;
6193 pMac->scan.nAgingCountDown--;
6194 }
6195 else
6196 {
6197 if( csrIsAllSessionDisconnected( pMac ) )
6198 {
6199 if(pmcIsPowerSaveEnabled(pMac, ePMC_IDLE_MODE_POWER_SAVE))
6200 {
6201 nRet = pMac->roam.configParam.scanAgeTimeNCPS;
6202 }
6203 else
6204 {
6205 nRet = pMac->roam.configParam.scanAgeTimeNCNPS;
6206 }
6207 }
6208 else
6209 {
6210 if(pmcIsPowerSaveEnabled(pMac, ePMC_BEACON_MODE_POWER_SAVE))
6211 {
6212 nRet = pMac->roam.configParam.scanAgeTimeCPS;
6213 }
6214 else
6215 {
6216 nRet = pMac->roam.configParam.scanAgeTimeCNPS;
6217 }
6218 }
6219 //If state-change causing aging time out change, we want to delay it somewhat to avoid
6220 //unnecessary removal of BSS. This is mostly due to transition from connect to disconnect.
6221 if(pMac->scan.nLastAgeTimeOut > nRet)
6222 {
6223 if(nRet)
6224 {
6225 pMac->scan.nAgingCountDown = (pMac->scan.nLastAgeTimeOut / nRet);
6226 }
6227 pMac->scan.nLastAgeTimeOut = nRet;
6228 nRet *= pMac->scan.nAgingCountDown;
6229 }
6230 else
6231 {
6232 pMac->scan.nLastAgeTimeOut = nRet;
6233 }
6234 }
6235
6236 return (nRet);
6237}
6238
6239
6240void csrScanResultAgingTimerHandler(void *pv)
6241{
6242 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
6243 tANI_BOOLEAN fDisconnected = csrIsAllSessionDisconnected(pMac);
6244
6245 //no scan, no aging
6246 if(pMac->scan.fScanEnable &&
6247 (((eANI_BOOLEAN_FALSE == fDisconnected) && pMac->roam.configParam.bgScanInterval)
6248 || (fDisconnected && (pMac->scan.fCancelIdleScan == eANI_BOOLEAN_FALSE)))
6249 )
6250 {
6251 tListElem *pEntry, *tmpEntry;
6252 tCsrScanResult *pResult;
6253 tANI_TIMESTAMP ageOutTime = (tANI_TIMESTAMP)(csrScanGetAgeOutTime(pMac) * PAL_TICKS_PER_SECOND); //turn it into 10ms units
6254 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
6255
6256 csrLLLock(&pMac->scan.scanResultList);
6257 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
6258 while( pEntry )
6259 {
6260 tmpEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
6261 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
6262 if((curTime - pResult->Result.BssDescriptor.nReceivedTime) > ageOutTime)
6263 {
6264 smsLog(pMac, LOGW, " age out due to time out");
6265 csrScanAgeOutBss(pMac, pResult);
6266 }
6267 pEntry = tmpEntry;
6268 }
6269 csrLLUnlock(&pMac->scan.scanResultList);
6270 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306271 vos_timer_start(&pMac->scan.hTimerResultAging, CSR_SCAN_RESULT_AGING_INTERVAL/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -07006272}
6273
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08006274static void csrScanResultCfgAgingTimerHandler(void *pv)
6275{
6276 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
6277 tListElem *pEntry, *tmpEntry;
6278 tCsrScanResult *pResult;
6279 tANI_TIMESTAMP ageOutTime = pMac->scan.scanResultCfgAgingTime * PAL_TICKS_PER_SECOND;
6280 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
6281
6282 csrLLLock(&pMac->scan.scanResultList);
6283 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
6284 while( pEntry )
6285 {
6286 tmpEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
6287 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
6288 if((curTime - pResult->Result.BssDescriptor.nReceivedTime) > ageOutTime)
6289 {
6290 smsLog(pMac, LOGW, " age out due to time out");
6291 csrScanAgeOutBss(pMac, pResult);
6292 }
6293 pEntry = tmpEntry;
6294 }
6295 csrLLUnlock(&pMac->scan.scanResultList);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306296 vos_timer_start(&pMac->scan.hTimerResultCfgAging, CSR_SCAN_RESULT_CFG_AGING_INTERVAL/PAL_TIMER_TO_MS_UNIT);
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08006297}
Jeff Johnson295189b2012-06-20 16:38:30 -07006298
6299eHalStatus csrScanStartIdleScanTimer(tpAniSirGlobal pMac, tANI_U32 interval)
6300{
6301 eHalStatus status;
6302
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006303 smsLog(pMac, LOG1, " csrScanStartIdleScanTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -07006304 if((pMac->scan.fScanEnable) && (eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan) && interval)
6305 {
6306 pMac->scan.nIdleScanTimeGap += interval;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306307 vos_timer_stop(&pMac->scan.hTimerIdleScan);
6308 status = vos_timer_start(&pMac->scan.hTimerIdleScan, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -07006309 if( !HAL_STATUS_SUCCESS(status) )
6310 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006311 smsLog(pMac, LOGE, " Fail to start Idle scan timer. status = %d interval = %d", status, interval);
Jeff Johnson295189b2012-06-20 16:38:30 -07006312 //This should not happen but set the flag to restart when ready
6313 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE;
6314 }
6315 }
6316 else
6317 {
6318 if( pMac->scan.fScanEnable && (eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan) )
6319 {
6320 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE;
6321 }
6322 status = eHAL_STATUS_FAILURE;
6323 }
6324
6325 return (status);
6326}
6327
6328
6329eHalStatus csrScanStopIdleScanTimer(tpAniSirGlobal pMac)
6330{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306331 return (vos_timer_stop(&pMac->scan.hTimerIdleScan));
Jeff Johnson295189b2012-06-20 16:38:30 -07006332}
6333
6334
6335//Stop CSR from asking for IMPS, This function doesn't disable IMPS from CSR
6336void csrScanSuspendIMPS( tpAniSirGlobal pMac )
6337{
6338 csrScanCancelIdleScan(pMac);
6339}
6340
6341
6342//Start CSR from asking for IMPS. This function doesn't trigger CSR to request entering IMPS
6343//because IMPS maybe disabled.
6344void csrScanResumeIMPS( tpAniSirGlobal pMac )
6345{
6346 csrScanStartIdleScan( pMac );
6347}
6348
6349
6350void csrScanIMPSCallback(void *callbackContext, eHalStatus status)
6351{
6352 tpAniSirGlobal pMac = PMAC_STRUCT( callbackContext );
6353
6354 if(eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan)
6355 {
6356 if(pMac->roam.configParam.IsIdleScanEnabled)
6357 {
6358 if(HAL_STATUS_SUCCESS(status))
6359 {
6360 if(csrIsAllSessionDisconnected(pMac) && !csrIsRoamCommandWaiting(pMac))
6361 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006362 smsLog(pMac, LOGW, FL("starts idle mode full scan"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006363 csrScanAllChannels(pMac, eCSR_SCAN_IDLE_MODE_SCAN);
6364 }
6365 else
6366 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006367 smsLog(pMac, LOGW, FL("cannot start idle mode full scan"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006368 //even though we are in timer handle, calling stop timer will make sure the timer
6369 //doesn't get to restart.
6370 csrScanStopIdleScanTimer(pMac);
6371 }
6372 }
6373 else
6374 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006375 smsLog(pMac, LOGE, FL("sees not success status (%d)"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006376 }
6377 }
6378 else
6379 {//we might need another flag to check if CSR needs to request imps at all
6380
6381 tANI_U32 nTime = 0;
6382
6383 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
6384 if(!HAL_STATUS_SUCCESS(csrScanTriggerIdleScan(pMac, &nTime)))
6385 {
6386 csrScanStartIdleScanTimer(pMac, nTime);
6387 }
6388 }
6389 }
6390}
6391
6392
6393//Param: pTimeInterval -- Caller allocated memory in return, if failed, to specify the nxt time interval for
6394//idle scan timer interval
6395//Return: Not success -- meaning it cannot start IMPS, caller needs to start a timer for idle scan
6396eHalStatus csrScanTriggerIdleScan(tpAniSirGlobal pMac, tANI_U32 *pTimeInterval)
6397{
6398 eHalStatus status = eHAL_STATUS_CSR_WRONG_STATE;
6399
6400 //Do not trigger IMPS in case of concurrency
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006401 if (vos_concurrent_sessions_running() && csrIsAnySessionInConnectState(pMac))
6402 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006403 smsLog( pMac, LOG1, FL("Cannot request IMPS because Concurrent Sessions Running") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006404 return (status);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006405 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006406
6407 if(pTimeInterval)
6408 {
6409 *pTimeInterval = 0;
6410 }
6411
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006412 smsLog(pMac, LOG3, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006413 if( smeCommandPending( pMac ) )
6414 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006415 smsLog( pMac, LOG1, FL(" Cannot request IMPS because command pending") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006416 //Not to enter IMPS because more work to do
6417 if(pTimeInterval)
6418 {
6419 *pTimeInterval = 0;
6420 }
6421 //restart when ready
6422 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE;
6423
6424 return (status);
6425 }
Kiran Kumar Lokeref8c39922013-03-18 11:08:11 -07006426 if (IsPmcImpsReqFailed (pMac))
6427 {
6428 if(pTimeInterval)
6429 {
6430 *pTimeInterval = 1000000; //usec
6431 }
6432 //restart when ready
6433 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006434
Kiran Kumar Lokeref8c39922013-03-18 11:08:11 -07006435 return status;
6436 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006437 if((pMac->scan.fScanEnable) && (eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan)
6438 /*&& pMac->roam.configParam.impsSleepTime*/)
6439 {
6440 //Stop get result timer because idle scan gets scan result out of PE
6441 csrScanStopGetResultTimer(pMac);
6442 if(pTimeInterval)
6443 {
6444 *pTimeInterval = pMac->roam.configParam.impsSleepTime;
6445 }
6446 //pmcRequestImps take a period in millisecond unit.
6447 status = pmcRequestImps(pMac, pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_MS_UNIT, csrScanIMPSCallback, pMac);
6448 if(!HAL_STATUS_SUCCESS(status))
6449 {
6450 if(eHAL_STATUS_PMC_ALREADY_IN_IMPS != status)
6451 {
6452 //Do restart the timer if CSR thinks it cannot do IMPS
6453 if( !csrCheckPSReady( pMac ) )
6454 {
6455 if(pTimeInterval)
6456 {
6457 *pTimeInterval = 0;
6458 }
6459 //Set the restart flag to true because that idle scan
6460 //can be restarted even though the timer will not be running
6461 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE;
6462 }
6463 else
6464 {
6465 //For not now, we do a quicker retry
6466 if(pTimeInterval)
6467 {
6468 *pTimeInterval = CSR_IDLE_SCAN_WAIT_TIME;
6469 }
6470 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006471 smsLog(pMac, LOGW, FL("call pmcRequestImps and it returns status code (%d)"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006472 }
6473 else
6474 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006475 smsLog(pMac, LOGW, FL("already in IMPS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006476 //Since CSR is the only module to request for IMPS. If it is already in IMPS, CSR assumes
6477 //the callback will be called in the future. Should not happen though.
6478 status = eHAL_STATUS_SUCCESS;
6479 pMac->scan.nIdleScanTimeGap = 0;
6480 }
6481 }
6482 else
6483 {
6484 //requested so let's reset the value
6485 pMac->scan.nIdleScanTimeGap = 0;
6486 }
6487 }
6488
6489 return (status);
6490}
6491
6492
6493eHalStatus csrScanStartIdleScan(tpAniSirGlobal pMac)
6494{
6495 eHalStatus status = eHAL_STATUS_CSR_WRONG_STATE;
6496 tANI_U32 nTime = 0;
6497
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006498 smsLog(pMac, LOGW, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006499 if(pMac->roam.configParam.IsIdleScanEnabled)
6500 {
6501 //stop bg scan first
6502 csrScanBGScanAbort(pMac);
6503 //Stop get result timer because idle scan gets scan result out of PE
6504 csrScanStopGetResultTimer(pMac);
6505 //Enable aging timer since idle scan is going on
6506 csrScanStartResultAgingTimer(pMac);
6507 }
6508 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE;
6509 status = csrScanTriggerIdleScan(pMac, &nTime);
6510 if(!HAL_STATUS_SUCCESS(status))
6511 {
6512 csrScanStartIdleScanTimer(pMac, nTime);
6513 }
6514
6515 return (status);
6516}
6517
6518
6519void csrScanCancelIdleScan(tpAniSirGlobal pMac)
6520{
6521 if(eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan)
6522 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006523 if (vos_concurrent_sessions_running()) {
6524 return;
6525 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006526 smsLog(pMac, LOG1, " csrScanCancelIdleScan");
Jeff Johnson295189b2012-06-20 16:38:30 -07006527 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_TRUE;
6528 //Set the restart flag in case later on it is uncancelled
6529 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE;
6530 csrScanStopIdleScanTimer(pMac);
6531 csrScanRemoveNotRoamingScanCommand(pMac);
6532 }
6533}
6534
6535
6536void csrScanIdleScanTimerHandler(void *pv)
6537{
6538 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
6539 eHalStatus status;
6540 tANI_U32 nTime = 0;
6541
6542 smsLog(pMac, LOGW, " csrScanIdleScanTimerHandler called ");
Kiran Kumar Lokeref8c39922013-03-18 11:08:11 -07006543 pmcResetImpsFailStatus (pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07006544 status = csrScanTriggerIdleScan(pMac, &nTime);
6545 if(!HAL_STATUS_SUCCESS(status) && (eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan))
6546 {
6547 //Check whether it is time to actually do an idle scan
6548 if(pMac->scan.nIdleScanTimeGap >= pMac->roam.configParam.impsSleepTime)
6549 {
6550 pMac->scan.nIdleScanTimeGap = 0;
6551 csrScanIMPSCallback(pMac, eHAL_STATUS_SUCCESS);
6552 }
6553 else
6554 {
6555 csrScanStartIdleScanTimer(pMac, nTime);
6556 }
6557 }
6558}
6559
6560
6561
6562
6563tANI_BOOLEAN csrScanRemoveNotRoamingScanCommand(tpAniSirGlobal pMac)
6564{
6565 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
6566 tListElem *pEntry, *pEntryTmp;
6567 tSmeCmd *pCommand;
6568 tDblLinkList localList;
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +05306569 tDblLinkList *pCmdList;
Jeff Johnson295189b2012-06-20 16:38:30 -07006570
6571 vos_mem_zero(&localList, sizeof(tDblLinkList));
6572 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
6573 {
6574 smsLog(pMac, LOGE, FL(" failed to open list"));
6575 return fRet;
6576 }
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +05306577 if (!pMac->fScanOffload)
6578 pCmdList = &pMac->sme.smeCmdPendingList;
6579 else
6580 pCmdList = &pMac->sme.smeScanCmdPendingList;
Jeff Johnson295189b2012-06-20 16:38:30 -07006581
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +05306582 csrLLLock(pCmdList);
6583 pEntry = csrLLPeekHead(pCmdList, LL_ACCESS_NOLOCK);
Jeff Johnson295189b2012-06-20 16:38:30 -07006584 while(pEntry)
6585 {
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +05306586 pEntryTmp = csrLLNext(pCmdList, pEntry, LL_ACCESS_NOLOCK);
Jeff Johnson295189b2012-06-20 16:38:30 -07006587 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6588 if( eSmeCommandScan == pCommand->command )
6589 {
6590 switch( pCommand->u.scanCmd.reason )
6591 {
6592 case eCsrScanIdleScan:
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +05306593 if( csrLLRemoveEntry(pCmdList, pEntry, LL_ACCESS_NOLOCK) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006594 {
6595 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
6596 }
6597 fRet = eANI_BOOLEAN_TRUE;
6598 break;
6599
6600 default:
6601 break;
6602 } //switch
6603 }
6604 pEntry = pEntryTmp;
6605 }
6606
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +05306607 csrLLUnlock(pCmdList);
Jeff Johnson295189b2012-06-20 16:38:30 -07006608
6609 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
6610 {
6611 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6612 csrReleaseCommandScan( pMac, pCommand );
6613 }
6614
6615 csrLLClose(&localList);
6616
6617 return (fRet);
6618}
6619
6620
6621tANI_BOOLEAN csrScanRemoveFreshScanCommand(tpAniSirGlobal pMac, tANI_U8 sessionId)
6622{
6623 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
6624 tListElem *pEntry, *pEntryTmp;
6625 tSmeCmd *pCommand;
6626 tDblLinkList localList;
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +05306627 tDblLinkList *pCmdList;
Jeff Johnson295189b2012-06-20 16:38:30 -07006628
6629 vos_mem_zero(&localList, sizeof(tDblLinkList));
6630 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
6631 {
6632 smsLog(pMac, LOGE, FL(" failed to open list"));
6633 return fRet;
6634 }
6635
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +05306636 if (!pMac->fScanOffload)
6637 pCmdList = &pMac->sme.smeCmdPendingList;
6638 else
6639 pCmdList = &pMac->sme.smeScanCmdPendingList;
6640
6641 csrLLLock(pCmdList);
6642 pEntry = csrLLPeekHead(pCmdList, LL_ACCESS_NOLOCK);
Jeff Johnson295189b2012-06-20 16:38:30 -07006643 while(pEntry)
6644 {
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +05306645 pEntryTmp = csrLLNext(pCmdList, pEntry, LL_ACCESS_NOLOCK);
Jeff Johnson295189b2012-06-20 16:38:30 -07006646 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6647 if( (eSmeCommandScan == pCommand->command) && (sessionId == pCommand->sessionId) )
6648 {
6649 switch(pCommand->u.scanCmd.reason)
6650 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07006651#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
6652 case eCsrScanGetLfrResult:
6653#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006654 case eCsrScanGetResult:
6655 case eCsrScanSetBGScanParam:
6656 case eCsrScanBGScanAbort:
6657 case eCsrScanBGScanEnable:
6658 case eCsrScanGetScanChnInfo:
6659 break;
6660 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006661 smsLog (pMac, LOGW, "%s: -------- abort scan command reason = %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006662 __func__, pCommand->u.scanCmd.reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07006663 //The rest are fresh scan requests
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +05306664 if( csrLLRemoveEntry(pCmdList, pEntry, LL_ACCESS_NOLOCK) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006665 {
6666 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
6667 }
6668 fRet = eANI_BOOLEAN_TRUE;
6669 break;
6670 }
6671 }
6672 pEntry = pEntryTmp;
6673 }
6674
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +05306675 csrLLUnlock(pCmdList);
Jeff Johnson295189b2012-06-20 16:38:30 -07006676
6677 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
6678 {
6679 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6680 if (pCommand->u.scanCmd.callback)
6681 {
6682 /* User scan request is pending,
6683 * send response with status eCSR_SCAN_ABORT*/
6684 pCommand->u.scanCmd.callback(pMac,
6685 pCommand->u.scanCmd.pContext,
6686 pCommand->u.scanCmd.scanID,
6687 eCSR_SCAN_ABORT);
6688 }
6689 csrReleaseCommandScan( pMac, pCommand );
6690 }
6691 csrLLClose(&localList);
6692
6693 return (fRet);
6694}
6695
6696
6697void csrReleaseScanCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand, eCsrScanStatus scanStatus)
6698{
6699 eCsrScanReason reason = pCommand->u.scanCmd.reason;
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +05306700 tANI_BOOLEAN status;
6701
6702 if (!pMac->fScanOffload)
Jeff Johnson295189b2012-06-20 16:38:30 -07006703 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +05306704 tANI_U32 i;
6705 for(i = 0; i < CSR_ROAM_SESSION_MAX; i++)
6706 csrRoamStateChange(pMac, pCommand->u.scanCmd.lastRoamState[i], i);
6707 }
6708 else
6709 {
6710 csrRoamStateChange(pMac,
6711 pCommand->u.scanCmd.lastRoamState[pCommand->sessionId],
6712 pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006713 }
6714
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +05306715 csrScanCallCallback(pMac, pCommand, scanStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006716
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006717 smsLog(pMac, LOG3, " Remove Scan command reason = %d", reason);
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +05306718 if (pMac->fScanOffload)
6719 {
6720 status = csrLLRemoveEntry(&pMac->sme.smeScanCmdActiveList,
6721 &pCommand->Link, LL_ACCESS_LOCK);
6722 }
6723 else
6724 {
6725 status = csrLLRemoveEntry(&pMac->sme.smeCmdActiveList,
6726 &pCommand->Link, LL_ACCESS_LOCK);
6727 }
6728
6729 if(status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006730 {
6731 csrReleaseCommandScan( pMac, pCommand );
6732 }
6733 else
6734 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +05306735 smsLog(pMac, LOGE,
6736 " ********csrReleaseScanCommand cannot release command reason %d",
6737 pCommand->u.scanCmd.reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07006738 }
6739}
6740
6741
6742eHalStatus csrScanGetPMKIDCandidateList(tpAniSirGlobal pMac, tANI_U32 sessionId,
6743 tPmkidCandidateInfo *pPmkidList, tANI_U32 *pNumItems )
6744{
6745 eHalStatus status = eHAL_STATUS_SUCCESS;
6746 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
6747
Jeff Johnson32d95a32012-09-10 13:15:23 -07006748 if(!pSession)
6749 {
6750 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6751 return eHAL_STATUS_FAILURE;
6752 }
6753
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006754 smsLog(pMac, LOGW, " pMac->scan.NumPmkidCandidate = %d", pSession->NumPmkidCandidate);
Jeff Johnson295189b2012-06-20 16:38:30 -07006755 csrResetPMKIDCandidateList(pMac, sessionId);
6756 if(csrIsConnStateConnected(pMac, sessionId) && pSession->pCurRoamProfile)
6757 {
6758 tCsrScanResultFilter *pScanFilter;
6759 tCsrScanResultInfo *pScanResult;
6760 tScanResultHandle hBSSList;
6761 tANI_U32 nItems = *pNumItems;
6762
6763 *pNumItems = 0;
6764 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
6765 if(HAL_STATUS_SUCCESS(status))
6766 {
6767 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
6768 //Here is the profile we need to connect to
6769 status = csrRoamPrepareFilterFromProfile(pMac, pSession->pCurRoamProfile, pScanFilter);
6770 if(HAL_STATUS_SUCCESS(status))
6771 {
6772 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6773 if(HAL_STATUS_SUCCESS(status))
6774 {
6775 while(((pScanResult = csrScanResultGetNext(pMac, hBSSList)) != NULL) && ( pSession->NumPmkidCandidate < nItems))
6776 {
6777 //NumPmkidCandidate adds up here
6778 csrProcessBSSDescForPMKIDList(pMac, &pScanResult->BssDescriptor,
6779 (tDot11fBeaconIEs *)( pScanResult->pvIes ));
6780 }
6781 if(pSession->NumPmkidCandidate)
6782 {
6783 *pNumItems = pSession->NumPmkidCandidate;
6784 palCopyMemory(pMac->hHdd, pPmkidList, pSession->PmkidCandidateInfo,
6785 pSession->NumPmkidCandidate * sizeof(tPmkidCandidateInfo));
6786 }
6787 csrScanResultPurge(pMac, hBSSList);
6788 }//Have scan result
6789 csrFreeScanFilter(pMac, pScanFilter);
6790 }
6791 palFreeMemory(pMac->hHdd, pScanFilter);
6792 }
6793 }
6794
6795 return (status);
6796}
6797
6798
6799
6800#ifdef FEATURE_WLAN_WAPI
6801eHalStatus csrScanGetBKIDCandidateList(tpAniSirGlobal pMac, tANI_U32 sessionId,
6802 tBkidCandidateInfo *pBkidList, tANI_U32 *pNumItems )
6803{
6804 eHalStatus status = eHAL_STATUS_SUCCESS;
6805 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
6806
Jeff Johnson32d95a32012-09-10 13:15:23 -07006807 if(!pSession)
6808 {
6809 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6810 return eHAL_STATUS_FAILURE;
6811 }
6812
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006813 smsLog(pMac, LOGW, " pMac->scan.NumBkidCandidate = %d", pSession->NumBkidCandidate);
Jeff Johnson295189b2012-06-20 16:38:30 -07006814 csrResetBKIDCandidateList(pMac, sessionId);
6815 if(csrIsConnStateConnected(pMac, sessionId) && pSession->pCurRoamProfile)
6816 {
6817 tCsrScanResultFilter *pScanFilter;
6818 tCsrScanResultInfo *pScanResult;
6819 tScanResultHandle hBSSList;
6820 tANI_U32 nItems = *pNumItems;
6821 *pNumItems = 0;
6822 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
6823 if(HAL_STATUS_SUCCESS(status))
6824 {
6825 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
6826 //Here is the profile we need to connect to
6827 status = csrRoamPrepareFilterFromProfile(pMac, pSession->pCurRoamProfile, pScanFilter);
6828 if(HAL_STATUS_SUCCESS(status))
6829 {
6830 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6831 if(HAL_STATUS_SUCCESS(status))
6832 {
6833 while(((pScanResult = csrScanResultGetNext(pMac, hBSSList)) != NULL) && ( pSession->NumBkidCandidate < nItems))
6834 {
6835 //pMac->scan.NumBkidCandidate adds up here
6836 csrProcessBSSDescForBKIDList(pMac, &pScanResult->BssDescriptor,
6837 (tDot11fBeaconIEs *)( pScanResult->pvIes ));
6838
6839 }
6840 if(pSession->NumBkidCandidate)
6841 {
6842 *pNumItems = pSession->NumBkidCandidate;
6843 palCopyMemory(pMac->hHdd, pBkidList, pSession->BkidCandidateInfo, pSession->NumBkidCandidate * sizeof(tBkidCandidateInfo));
6844 }
6845 csrScanResultPurge(pMac, hBSSList);
6846 }//Have scan result
6847 }
6848 palFreeMemory(pMac->hHdd, pScanFilter);
6849 }
6850 }
6851
6852 return (status);
6853}
6854#endif /* FEATURE_WLAN_WAPI */
6855
6856
6857
6858//This function is usually used for BSSs that suppresses SSID so the profile
6859//shall have one and only one SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006860eHalStatus csrScanForSSID(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tANI_U32 roamId, tANI_BOOLEAN notify)
Jeff Johnson295189b2012-06-20 16:38:30 -07006861{
6862 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
6863 tSmeCmd *pScanCmd = NULL;
6864 tANI_U8 bAddr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
6865 tANI_U8 index = 0;
6866 tANI_U32 numSsid = pProfile->SSIDs.numOfSSIDs;
6867
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006868 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006869 //For WDS, we use the index 0. There must be at least one in there
6870 if( CSR_IS_WDS_STA( pProfile ) && numSsid )
6871 {
6872 numSsid = 1;
6873 }
6874 if(pMac->scan.fScanEnable && ( numSsid == 1 ) )
6875 {
6876 do
6877 {
6878 pScanCmd = csrGetCommandBuffer(pMac);
6879 if(!pScanCmd)
6880 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006881 smsLog(pMac, LOGE, FL("failed to allocate command buffer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006882 break;
6883 }
6884 palZeroMemory(pMac->hHdd, &pScanCmd->u.scanCmd, sizeof(tScanCmd));
6885 status = palAllocateMemory(pMac->hHdd, (void **)&pScanCmd->u.scanCmd.pToRoamProfile, sizeof(tCsrRoamProfile));
6886 if(!HAL_STATUS_SUCCESS(status))
6887 break;
6888 status = csrRoamCopyProfile(pMac, pScanCmd->u.scanCmd.pToRoamProfile, pProfile);
6889 if(!HAL_STATUS_SUCCESS(status))
6890 break;
6891 pScanCmd->u.scanCmd.roamId = roamId;
6892 pScanCmd->command = eSmeCommandScan;
Jeff Johnsone7245742012-09-05 17:12:55 -07006893 pScanCmd->sessionId = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07006894 pScanCmd->u.scanCmd.callback = NULL;
6895 pScanCmd->u.scanCmd.pContext = NULL;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006896 pScanCmd->u.scanCmd.reason = eCsrScanForSsid;//Need to check: might need a new reason for SSID scan for LFR during multisession with p2p
Jeff Johnson295189b2012-06-20 16:38:30 -07006897 pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around
6898 palZeroMemory(pMac->hHdd, &pScanCmd->u.scanCmd.u.scanRequest, sizeof(tCsrScanRequest));
6899 pScanCmd->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07006900 pScanCmd->u.scanCmd.u.scanRequest.BSSType = pProfile->BSSType;
Jeff Johnsone7245742012-09-05 17:12:55 -07006901 // To avoid 11b rate in probe request Set p2pSearch flag as 1 for P2P Client Mode
6902 if(VOS_P2P_CLIENT_MODE == pProfile->csrPersona)
6903 {
6904 pScanCmd->u.scanCmd.u.scanRequest.p2pSearch = 1;
6905 }
6906 if(pProfile->pAddIEScan)
6907 {
6908 status = palAllocateMemory(pMac->hHdd,
6909 (void **)&pScanCmd->u.scanCmd.u.scanRequest.pIEField,
6910 pProfile->nAddIEScanLength);
6911 palZeroMemory(pMac->hHdd, pScanCmd->u.scanCmd.u.scanRequest.pIEField, pProfile->nAddIEScanLength);
6912 if(HAL_STATUS_SUCCESS(status))
6913 {
6914 palCopyMemory(pMac->hHdd, pScanCmd->u.scanCmd.u.scanRequest.pIEField, pProfile->pAddIEScan, pProfile->nAddIEScanLength);
6915 pScanCmd->u.scanCmd.u.scanRequest.uIEFieldLen = pProfile->nAddIEScanLength;
6916 }
6917 else
6918 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006919 smsLog(pMac, LOGE, "No memory for scanning IE fields");
Jeff Johnsone7245742012-09-05 17:12:55 -07006920 }
6921 } //Allocate memory for IE field
6922 else
6923 {
6924 pScanCmd->u.scanCmd.u.scanRequest.uIEFieldLen = 0;
6925 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07006926 /* For one channel be good enpugh time to receive beacon atleast */
6927 if( 1 == pProfile->ChannelInfo.numOfChannels )
6928 {
6929 pScanCmd->u.scanCmd.u.scanRequest.maxChnTime = MAX_ACTIVE_SCAN_FOR_ONE_CHANNEL;
6930 pScanCmd->u.scanCmd.u.scanRequest.minChnTime = MIN_ACTIVE_SCAN_FOR_ONE_CHANNEL;
6931 }
6932 else
6933 {
6934 pScanCmd->u.scanCmd.u.scanRequest.maxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
6935 pScanCmd->u.scanCmd.u.scanRequest.minChnTime = pMac->roam.configParam.nActiveMinChnTime;
6936 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08006937 pScanCmd->u.scanCmd.u.scanRequest.maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
6938 pScanCmd->u.scanCmd.u.scanRequest.minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07006939 if(pProfile->BSSIDs.numOfBSSIDs == 1)
6940 {
6941 palCopyMemory(pMac->hHdd, pScanCmd->u.scanCmd.u.scanRequest.bssid, pProfile->BSSIDs.bssid, sizeof(tCsrBssid));
6942 }
6943 else
6944 {
6945 palCopyMemory(pMac->hHdd, pScanCmd->u.scanCmd.u.scanRequest.bssid, bAddr, 6);
6946 }
6947 if(pProfile->ChannelInfo.numOfChannels)
6948 {
6949 status = palAllocateMemory(pMac->hHdd, (void **)&pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList, sizeof(*pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList) * pProfile->ChannelInfo.numOfChannels);
6950 pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = 0;
6951 if(HAL_STATUS_SUCCESS(status))
6952 {
6953 csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[0]);
6954 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
6955 {
6956 if(csrRoamIsValidChannel(pMac, pProfile->ChannelInfo.ChannelList[index]))
6957 {
6958 pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels]
6959 = pProfile->ChannelInfo.ChannelList[index];
6960 pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels++;
6961 }
6962 else
6963 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006964 smsLog(pMac, LOGW, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006965 }
6966
6967 }
6968 }
6969 else
6970 {
6971 break;
6972 }
6973
6974 }
6975 else
6976 {
6977 pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = 0;
6978 }
6979 if(pProfile->SSIDs.numOfSSIDs)
6980 {
6981 status = palAllocateMemory(pMac->hHdd, (void **)&pScanCmd->u.scanCmd.u.scanRequest.SSIDs.SSIDList,
6982 pProfile->SSIDs.numOfSSIDs * sizeof(tCsrSSIDInfo));
6983 if(!HAL_STATUS_SUCCESS(status))
6984 {
6985 break;
6986 }
6987 pScanCmd->u.scanCmd.u.scanRequest.SSIDs.numOfSSIDs = 1;
6988 palCopyMemory(pMac->hHdd, pScanCmd->u.scanCmd.u.scanRequest.SSIDs.SSIDList, pProfile->SSIDs.SSIDList,
6989 sizeof(tCsrSSIDInfo));
6990 }
6991 //Start process the command
6992 status = csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_FALSE);
6993 if( !HAL_STATUS_SUCCESS( status ) )
6994 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006995 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006996 break;
6997 }
6998 }while(0);
6999 if(!HAL_STATUS_SUCCESS(status))
7000 {
7001 if(pScanCmd)
7002 {
7003 csrReleaseCommandScan(pMac, pScanCmd);
7004 //TODO:free the memory that is allocated in this function
7005 }
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07007006 if(notify)
7007 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007008 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
7009 }
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07007010 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007011 }//valid
7012 else
7013 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007014 smsLog(pMac, LOGE, FL("cannot scan because scanEnable (%d) or numSSID (%d) is invalid"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007015 pMac->scan.fScanEnable, pProfile->SSIDs.numOfSSIDs);
7016 }
7017
7018 return (status);
7019}
7020
7021
7022//Issue a scan base on the new capability infomation
7023//This should only happen when the associated AP changes its capability.
7024//After this scan is done, CSR reroams base on the new scan results
7025eHalStatus csrScanForCapabilityChange(tpAniSirGlobal pMac, tSirSmeApNewCaps *pNewCaps)
7026{
7027 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
7028 tSmeCmd *pScanCmd = NULL;
7029
7030 if(pNewCaps)
7031 {
7032 do
7033 {
7034 pScanCmd = csrGetCommandBuffer(pMac);
7035 if(!pScanCmd)
7036 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007037 smsLog(pMac, LOGE, FL("failed to allocate command buffer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007038 status = eHAL_STATUS_RESOURCES;
7039 break;
7040 }
7041 palZeroMemory(pMac->hHdd, &pScanCmd->u.scanCmd, sizeof(tScanCmd));
7042 status = eHAL_STATUS_SUCCESS;
7043 pScanCmd->u.scanCmd.roamId = 0;
7044 pScanCmd->command = eSmeCommandScan;
7045 pScanCmd->u.scanCmd.callback = NULL;
7046 pScanCmd->u.scanCmd.pContext = NULL;
7047 pScanCmd->u.scanCmd.reason = eCsrScanForCapsChange;
7048 pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around
7049 status = csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_FALSE);
7050 if( !HAL_STATUS_SUCCESS( status ) )
7051 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007052 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007053 break;
7054 }
7055 }while(0);
7056 if(!HAL_STATUS_SUCCESS(status))
7057 {
7058 if(pScanCmd)
7059 {
7060 csrReleaseCommandScan(pMac, pScanCmd);
7061 }
7062 }
7063 }
7064
7065 return (status);
7066}
7067
7068
7069
7070void csrInitBGScanChannelList(tpAniSirGlobal pMac)
7071{
7072 tANI_U32 len = CSR_MIN(sizeof(pMac->roam.validChannelList), sizeof(pMac->scan.bgScanChannelList));
7073
7074 palZeroMemory(pMac->hHdd, pMac->scan.bgScanChannelList, len);
7075 pMac->scan.numBGScanChannel = 0;
7076
7077 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
7078 {
7079 pMac->roam.numValidChannels = len;
7080 pMac->scan.numBGScanChannel = (tANI_U8)CSR_MIN(len, WNI_CFG_BG_SCAN_CHANNEL_LIST_LEN);
7081 palCopyMemory(pMac->hHdd, pMac->scan.bgScanChannelList, pMac->roam.validChannelList, pMac->scan.numBGScanChannel);
7082 csrSetBGScanChannelList(pMac, pMac->scan.bgScanChannelList, pMac->scan.numBGScanChannel);
7083 }
7084}
7085
7086
7087//This function return TRUE if background scan channel list is adjusted.
7088//this function will only shrink the background scan channel list
7089tANI_BOOLEAN csrAdjustBGScanChannelList(tpAniSirGlobal pMac, tANI_U8 *pChannelList, tANI_U8 NumChannels,
7090 tANI_U8 *pAdjustChannels, tANI_U8 *pNumAdjustChannels)
7091{
7092 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7093 tANI_U8 i, j, count = *pNumAdjustChannels;
7094
7095 i = 0;
7096 while(i < count)
7097 {
7098 for(j = 0; j < NumChannels; j++)
7099 {
7100 if(pChannelList[j] == pAdjustChannels[i])
7101 break;
7102 }
7103 if(j == NumChannels)
7104 {
7105 //This channel is not in the list, remove it
7106 fRet = eANI_BOOLEAN_TRUE;
7107 count--;
7108 if(count - i)
7109 {
7110 palCopyMemory(pMac->hHdd, &pAdjustChannels[i], &pAdjustChannels[i+1], count - i);
7111 }
7112 else
7113 {
7114 //already remove the last one. Done.
7115 break;
7116 }
7117 }
7118 else
7119 {
7120 i++;
7121 }
7122 }//while(i<count)
7123 *pNumAdjustChannels = count;
7124
7125 return (fRet);
7126}
7127
7128
7129//Get the list of the base channels to scan for passively 11d info
7130eHalStatus csrScanGetSupportedChannels( tpAniSirGlobal pMac )
7131{
7132 eHalStatus status = eHAL_STATUS_SUCCESS;
7133 int n = WNI_CFG_VALID_CHANNEL_LIST_LEN;
7134
7135 status = vos_nv_getSupportedChannels( pMac->scan.baseChannels.channelList, &n, NULL, NULL );
7136 if( HAL_STATUS_SUCCESS(status) )
7137 {
7138 pMac->scan.baseChannels.numChannels = (tANI_U8)n;
7139 }
7140 else
7141 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007142 smsLog( pMac, LOGE, FL(" failed") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007143 pMac->scan.baseChannels.numChannels = 0;
7144 }
7145
7146 return ( status );
7147}
7148
7149//This function use the input pChannelList to validate the current saved channel list
7150eHalStatus csrSetBGScanChannelList( tpAniSirGlobal pMac, tANI_U8 *pAdjustChannels, tANI_U8 NumAdjustChannels)
7151{
7152 tANI_U32 dataLen = sizeof( tANI_U8 ) * NumAdjustChannels;
7153
7154 return (ccmCfgSetStr(pMac, WNI_CFG_BG_SCAN_CHANNEL_LIST, pAdjustChannels, dataLen, NULL, eANI_BOOLEAN_FALSE));
7155}
7156
7157
7158void csrSetCfgValidChannelList( tpAniSirGlobal pMac, tANI_U8 *pChannelList, tANI_U8 NumChannels )
7159{
7160 tANI_U32 dataLen = sizeof( tANI_U8 ) * NumChannels;
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +05307161 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007162
7163 ccmCfgSetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST, pChannelList, dataLen, NULL, eANI_BOOLEAN_FALSE);
7164
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +05307165 if (pMac->fScanOffload)
7166 {
7167 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7168 "Scan offload is enabled, update default chan list");
7169 status = csrUpdateChannelList(&pMac->scan);
7170 if (eHAL_STATUS_SUCCESS != status)
7171 {
7172 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
7173 "failed to update the supported channel list");
7174 }
7175 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007176 return;
7177}
7178
7179
7180
7181/*
7182 * The Tx power limits are saved in the cfg for future usage.
7183 */
7184void csrSaveTxPowerToCfg( tpAniSirGlobal pMac, tDblLinkList *pList, tANI_U32 cfgId )
7185{
7186 tListElem *pEntry;
7187 tANI_U32 cbLen = 0, dataLen;
7188 tCsrChannelPowerInfo *pChannelSet;
7189 tANI_U32 idx;
7190 tSirMacChanInfo *pChannelPowerSet;
7191 tANI_U8 *pBuf = NULL;
7192
7193 //allocate maximum space for all channels
7194 dataLen = WNI_CFG_VALID_CHANNEL_LIST_LEN * sizeof(tSirMacChanInfo);
7195 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pBuf, dataLen)))
7196 {
7197 palZeroMemory(pMac->hHdd, pBuf, dataLen);
7198 pChannelPowerSet = (tSirMacChanInfo *)(pBuf);
7199
7200 pEntry = csrLLPeekHead( pList, LL_ACCESS_LOCK );
7201 // write the tuples (startChan, numChan, txPower) for each channel found in the channel power list.
7202 while( pEntry )
7203 {
7204 pChannelSet = GET_BASE_ADDR( pEntry, tCsrChannelPowerInfo, link );
7205 if ( 1 != pChannelSet->interChannelOffset )
7206 {
7207 // we keep the 5G channel sets internally with an interchannel offset of 4. Expand these
7208 // to the right format... (inter channel offset of 1 is the only option for the triplets
7209 // that 11d advertises.
7210 if ((cbLen + (pChannelSet->numChannels * sizeof(tSirMacChanInfo))) >= dataLen)
7211 {
7212 // expanding this entry will overflow our allocation
7213 smsLog(pMac, LOGE,
7214 "%s: Buffer overflow, start %d, num %d, offset %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007215 __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07007216 pChannelSet->firstChannel,
7217 pChannelSet->numChannels,
7218 pChannelSet->interChannelOffset);
7219 break;
7220 }
7221
7222 for( idx = 0; idx < pChannelSet->numChannels; idx++ )
7223 {
7224 pChannelPowerSet->firstChanNum = (tSirMacChanNum)(pChannelSet->firstChannel + ( idx * pChannelSet->interChannelOffset ));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007225 smsLog(pMac, LOG3, " Setting Channel Number %d", pChannelPowerSet->firstChanNum);
Jeff Johnson295189b2012-06-20 16:38:30 -07007226 pChannelPowerSet->numChannels = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007227 pChannelPowerSet->maxTxPower = CSR_ROAM_MIN( pChannelSet->txPower, pMac->roam.configParam.nTxPowerCap );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007228 smsLog(pMac, LOG3, " Setting Max Transmit Power %d", pChannelPowerSet->maxTxPower);
Jeff Johnson295189b2012-06-20 16:38:30 -07007229 cbLen += sizeof( tSirMacChanInfo );
7230 pChannelPowerSet++;
7231 }
7232 }
7233 else
7234 {
7235 if (cbLen >= dataLen)
7236 {
7237 // this entry will overflow our allocation
7238 smsLog(pMac, LOGE,
7239 "%s: Buffer overflow, start %d, num %d, offset %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007240 __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07007241 pChannelSet->firstChannel,
7242 pChannelSet->numChannels,
7243 pChannelSet->interChannelOffset);
7244 break;
7245 }
7246 pChannelPowerSet->firstChanNum = pChannelSet->firstChannel;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007247 smsLog(pMac, LOG3, " Setting Channel Number %d", pChannelPowerSet->firstChanNum);
Jeff Johnson295189b2012-06-20 16:38:30 -07007248 pChannelPowerSet->numChannels = pChannelSet->numChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07007249 pChannelPowerSet->maxTxPower = CSR_ROAM_MIN( pChannelSet->txPower, pMac->roam.configParam.nTxPowerCap );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007250 smsLog(pMac, LOG3, " Setting Max Transmit Power %d, nTxPower %d", pChannelPowerSet->maxTxPower,pMac->roam.configParam.nTxPowerCap );
Jeff Johnson295189b2012-06-20 16:38:30 -07007251
7252
7253 cbLen += sizeof( tSirMacChanInfo );
7254 pChannelPowerSet++;
7255 }
7256
7257 pEntry = csrLLNext( pList, pEntry, LL_ACCESS_LOCK );
7258 }
7259
7260 if(cbLen)
7261 {
7262 ccmCfgSetStr(pMac, cfgId, (tANI_U8 *)pBuf, cbLen, NULL, eANI_BOOLEAN_FALSE);
7263 }
7264 palFreeMemory( pMac->hHdd, pBuf );
7265 }//Allocate memory
7266}
7267
7268
7269void csrSetCfgCountryCode( tpAniSirGlobal pMac, tANI_U8 *countryCode )
7270{
7271 tANI_U8 cc[WNI_CFG_COUNTRY_CODE_LEN];
7272 ///v_REGDOMAIN_t DomainId;
7273
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007274 smsLog( pMac, LOG3, "Setting Country Code in Cfg from csrSetCfgCountryCode %s",countryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007275 palCopyMemory( pMac->hHdd, cc, countryCode, WNI_CFG_COUNTRY_CODE_LEN );
7276
7277 // don't program the bogus country codes that we created for Korea in the MAC. if we see
7278 // the bogus country codes, program the MAC with the right country code.
7279 if ( ( 'K' == countryCode[ 0 ] && '1' == countryCode[ 1 ] ) ||
7280 ( 'K' == countryCode[ 0 ] && '2' == countryCode[ 1 ] ) ||
7281 ( 'K' == countryCode[ 0 ] && '3' == countryCode[ 1 ] ) ||
7282 ( 'K' == countryCode[ 0 ] && '4' == countryCode[ 1 ] ) )
7283 {
7284 // replace the alternate Korea country codes, 'K1', 'K2', .. with 'KR' for Korea
7285 cc[ 1 ] = 'R';
7286 }
7287 ccmCfgSetStr(pMac, WNI_CFG_COUNTRY_CODE, cc, WNI_CFG_COUNTRY_CODE_LEN, NULL, eANI_BOOLEAN_FALSE);
7288
7289 //Need to let HALPHY know about the current domain so it can apply some
7290 //domain-specific settings (TX filter...)
7291 /*if(HAL_STATUS_SUCCESS(csrGetRegulatoryDomainForCountry(pMac, cc, &DomainId)))
7292 {
7293 halPhySetRegDomain(pMac, DomainId);
7294 }*/
7295}
7296
7297
7298
7299eHalStatus csrGetCountryCode(tpAniSirGlobal pMac, tANI_U8 *pBuf, tANI_U8 *pbLen)
7300{
7301 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
7302 tANI_U32 len;
7303
7304 if(pBuf && pbLen && (*pbLen >= WNI_CFG_COUNTRY_CODE_LEN))
7305 {
7306 len = *pbLen;
7307 status = ccmCfgGetStr(pMac, WNI_CFG_COUNTRY_CODE, pBuf, &len);
7308 if(HAL_STATUS_SUCCESS(status))
7309 {
7310 *pbLen = (tANI_U8)len;
7311 }
7312 }
7313
7314 return (status);
7315}
7316
7317
7318void csrSetCfgScanControlList( tpAniSirGlobal pMac, tANI_U8 *countryCode, tCsrChannel *pChannelList )
7319{
7320 tANI_U8 i, j;
7321 tANI_BOOLEAN found=FALSE;
7322 tANI_U8 *pControlList = NULL;
7323 tANI_U32 len = WNI_CFG_SCAN_CONTROL_LIST_LEN;
7324
7325 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pControlList, WNI_CFG_SCAN_CONTROL_LIST_LEN)))
7326 {
7327 palZeroMemory(pMac->hHdd, (void *)pControlList, WNI_CFG_SCAN_CONTROL_LIST_LEN);
7328 if(HAL_STATUS_SUCCESS(ccmCfgGetStr(pMac, WNI_CFG_SCAN_CONTROL_LIST, pControlList, &len)))
7329 {
7330 for (i = 0; i < pChannelList->numChannels; i++)
7331 {
7332 for (j = 0; j < len; j += 2)
7333 {
7334 if (pControlList[j] == pChannelList->channelList[i])
7335 {
7336 found = TRUE;
7337 break;
7338 }
7339 }
7340
7341 if (found) // insert a pair(channel#, flag)
7342 {
Gopichand Nakkala392cbc12013-05-28 16:15:00 +05307343 pControlList[j+1] = csrGetScanType(pMac, pControlList[j]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007344 found = FALSE; // reset the flag
7345 }
7346
7347 }
7348
7349 ccmCfgSetStr(pMac, WNI_CFG_SCAN_CONTROL_LIST, pControlList, len, NULL, eANI_BOOLEAN_FALSE);
7350 }//Successfully getting scan control list
7351 palFreeMemory(pMac->hHdd, pControlList);
7352 }//AllocateMemory
7353}
7354
7355
7356//if bgPeriod is 0, background scan is disabled. It is in millisecond units
7357eHalStatus csrSetCfgBackgroundScanPeriod(tpAniSirGlobal pMac, tANI_U32 bgPeriod)
7358{
7359 return (ccmCfgSetInt(pMac, WNI_CFG_BACKGROUND_SCAN_PERIOD, bgPeriod, (tCcmCfgSetCallback) csrScanCcmCfgSetCallback, eANI_BOOLEAN_FALSE));
7360}
7361
7362
7363void csrScanCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
7364{
7365 tListElem *pEntry = NULL;
7366 tSmeCmd *pCommand = NULL;
7367 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +05307368 tDblLinkList *pCmdList ;
7369
7370 if (!pMac->fScanOffload)
7371 pCmdList = &pMac->sme.smeCmdActiveList;
7372 else
7373 pCmdList = &pMac->sme.smeScanCmdActiveList;
7374
7375 pEntry = csrLLPeekHead( pCmdList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -07007376 if ( pEntry )
7377 {
7378 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7379 if ( eSmeCommandScan == pCommand->command )
7380 {
7381 eCsrScanStatus scanStatus = (CCM_IS_RESULT_SUCCESS(result)) ? eCSR_SCAN_SUCCESS : eCSR_SCAN_FAILURE;
7382 csrReleaseScanCommand(pMac, pCommand, scanStatus);
7383 }
7384 else
7385 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007386 smsLog( pMac, LOGW, "CSR: Scan Completion called but SCAN command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07007387 }
7388 }
7389 smeProcessPendingQueue( pMac );
7390}
7391
7392eHalStatus csrProcessSetBGScanParam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
7393{
7394 eHalStatus status;
7395 tCsrBGScanRequest *pScanReq = &pCommand->u.scanCmd.u.bgScanRequest;
7396 tANI_U32 dataLen = sizeof( tANI_U8 ) * pScanReq->ChannelInfo.numOfChannels;
7397
7398 //***setcfg for background scan channel list
7399 status = ccmCfgSetInt(pMac, WNI_CFG_ACTIVE_MINIMUM_CHANNEL_TIME, pScanReq->minChnTime, NULL, eANI_BOOLEAN_FALSE);
7400 status = ccmCfgSetInt(pMac, WNI_CFG_ACTIVE_MAXIMUM_CHANNEL_TIME, pScanReq->maxChnTime, NULL, eANI_BOOLEAN_FALSE);
7401 //Not set the background scan interval if not connected because bd scan should not be run if not connected
7402 if(!csrIsAllSessionDisconnected(pMac))
7403 {
7404 //If disbaling BG scan here, we need to stop aging as well
7405 if(pScanReq->scanInterval == 0)
7406 {
7407 //Stop aging because no new result is coming in
7408 csrScanStopResultAgingTimer(pMac);
7409 }
7410
7411#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7412 {
7413 vos_log_scan_pkt_type *pScanLog = NULL;
7414
7415 WLAN_VOS_DIAG_LOG_ALLOC(pScanLog, vos_log_scan_pkt_type, LOG_WLAN_SCAN_C);
7416 if(pScanLog)
7417 {
7418 pScanLog->eventId = WLAN_SCAN_EVENT_HO_SCAN_REQ;
7419 pScanLog->minChnTime = (v_U8_t)pScanReq->minChnTime;
7420 pScanLog->maxChnTime = (v_U8_t)pScanReq->maxChnTime;
7421 pScanLog->timeBetweenBgScan = (v_U8_t)pScanReq->scanInterval;
7422 pScanLog->numChannel = pScanReq->ChannelInfo.numOfChannels;
7423 if(pScanLog->numChannel && (pScanLog->numChannel < VOS_LOG_MAX_NUM_CHANNEL))
7424 {
7425 palCopyMemory(pMac->hHdd, pScanLog->channels, pScanReq->ChannelInfo.ChannelList,
7426 pScanLog->numChannel);
7427 }
7428 WLAN_VOS_DIAG_LOG_REPORT(pScanLog);
7429 }
7430 }
7431#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7432
7433 status = ccmCfgSetInt(pMac, WNI_CFG_BACKGROUND_SCAN_PERIOD, pScanReq->scanInterval, NULL, eANI_BOOLEAN_FALSE);
7434 }
7435 else
7436 {
7437 //No need to stop aging because IDLE scan is still running
7438 status = ccmCfgSetInt(pMac, WNI_CFG_BACKGROUND_SCAN_PERIOD, 0, NULL, eANI_BOOLEAN_FALSE);
7439 }
7440
7441 if(pScanReq->SSID.length > WNI_CFG_SSID_LEN)
7442 {
7443 pScanReq->SSID.length = WNI_CFG_SSID_LEN;
7444 }
7445
7446 status = ccmCfgSetStr(pMac, WNI_CFG_BG_SCAN_CHANNEL_LIST, pScanReq->ChannelInfo.ChannelList, dataLen, NULL, eANI_BOOLEAN_FALSE);
7447 status = ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pScanReq->SSID.ssId, pScanReq->SSID.length, NULL, eANI_BOOLEAN_FALSE);
7448
7449
7450
7451 return (status);
7452}
7453
7454
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307455eHalStatus csrScanAbortMacScan(tpAniSirGlobal pMac, tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07007456{
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307457 eHalStatus status = eHAL_STATUS_FAILURE;
7458 tSirSmeScanAbortReq *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07007459 tANI_U16 msgLen;
7460 tListElem *pEntry;
7461 tSmeCmd *pCommand;
7462
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307463 if (!pMac->fScanOffload)
Jeff Johnson295189b2012-06-20 16:38:30 -07007464 {
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307465#ifdef WLAN_AP_STA_CONCURRENCY
7466 csrLLLock(&pMac->scan.scanCmdPendingList);
7467 while(NULL !=
7468 (pEntry = csrLLRemoveHead(&pMac->scan.scanCmdPendingList,
7469 LL_ACCESS_NOLOCK)))
7470 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007471
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307472 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7473 csrAbortCommand( pMac, pCommand, eANI_BOOLEAN_FALSE);
7474 }
7475 csrLLUnlock(&pMac->scan.scanCmdPendingList);
Jeff Johnson295189b2012-06-20 16:38:30 -07007476#endif
7477
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307478 pMac->scan.fDropScanCmd = eANI_BOOLEAN_TRUE;
7479 csrRemoveCmdFromPendingList( pMac, &pMac->roam.roamCmdPendingList, eSmeCommandScan);
7480 csrRemoveCmdFromPendingList( pMac, &pMac->sme.smeCmdPendingList, eSmeCommandScan);
7481 pMac->scan.fDropScanCmd = eANI_BOOLEAN_FALSE;
7482
7483 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7484 }
7485 else
7486 {
7487 pMac->scan.fDropScanCmd = eANI_BOOLEAN_TRUE;
7488 csrRemoveCmdWithSessionIdFromPendingList(pMac,
7489 sessionId,
7490 &pMac->sme.smeScanCmdPendingList,
7491 eSmeCommandScan);
7492 pMac->scan.fDropScanCmd = eANI_BOOLEAN_FALSE;
7493
7494 pEntry = csrLLPeekHead(&pMac->sme.smeScanCmdActiveList, LL_ACCESS_LOCK);
7495 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007496
7497 //We need to abort scan only if we are scanning
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307498 if(NULL != pEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07007499 {
7500 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307501 if(eSmeCommandScan == pCommand->command &&
7502 pCommand->sessionId == sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07007503 {
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307504 msgLen = (tANI_U16)(sizeof(tSirSmeScanAbortReq));
Jeff Johnson295189b2012-06-20 16:38:30 -07007505 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
7506 if(HAL_STATUS_SUCCESS(status))
7507 {
7508 palZeroMemory(pMac->hHdd, (void *)pMsg, msgLen);
7509 pMsg->type = pal_cpu_to_be16((tANI_U16)eWNI_SME_SCAN_ABORT_IND);
7510 pMsg->msgLen = pal_cpu_to_be16(msgLen);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307511 pMsg->sessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007512 status = palSendMBMessage(pMac->hHdd, pMsg);
7513 }
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307514 else
7515 smsLog(pMac, LOGE, FL("Failed to allocate memory for"
7516 " SmeScanAbortReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007517 }
7518 }
7519
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307520 return(status);
7521}
7522
7523void csrRemoveCmdWithSessionIdFromPendingList(tpAniSirGlobal pMac,
7524 tANI_U8 sessionId,
7525 tDblLinkList *pList,
7526 eSmeCommandType commandType)
7527{
7528 tDblLinkList localList;
7529 tListElem *pEntry;
7530 tSmeCmd *pCommand;
7531 tListElem *pEntryToRemove;
7532
7533 vos_mem_zero(&localList, sizeof(tDblLinkList));
7534 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
7535 {
7536 smsLog(pMac, LOGE, FL(" failed to open list"));
7537 return;
7538 }
7539
7540 csrLLLock(pList);
7541 if ((pEntry = csrLLPeekHead( pList, LL_ACCESS_NOLOCK)))
7542 {
7543
7544 /* Have to make sure we don't loop back to the head of the list,
7545 * which will happen if the entry is NOT on the list */
7546 while (pEntry)
7547 {
7548 pEntryToRemove = pEntry;
7549 pEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
7550 pCommand = GET_BASE_ADDR( pEntryToRemove, tSmeCmd, Link );
7551 if ((pCommand->command == commandType) &&
7552 (pCommand->sessionId == sessionId))
7553 {
7554 /* Remove that entry only */
7555 if (csrLLRemoveEntry( pList, pEntryToRemove, LL_ACCESS_NOLOCK))
7556 {
7557 csrLLInsertTail(&localList, pEntryToRemove,
7558 LL_ACCESS_NOLOCK);
7559 }
7560 }
7561 }
7562 }
7563 csrLLUnlock(pList);
7564
7565 while ((pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)))
7566 {
7567 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7568 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
7569 }
7570
7571 csrLLClose(&localList);
Jeff Johnson295189b2012-06-20 16:38:30 -07007572}
7573
7574void csrRemoveCmdFromPendingList(tpAniSirGlobal pMac, tDblLinkList *pList,
7575 eSmeCommandType commandType )
7576{
7577 tDblLinkList localList;
7578 tListElem *pEntry;
7579 tSmeCmd *pCommand;
7580 tListElem *pEntryToRemove;
7581
7582 vos_mem_zero(&localList, sizeof(tDblLinkList));
7583 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
7584 {
7585 smsLog(pMac, LOGE, FL(" failed to open list"));
7586 return;
7587 }
7588
7589 csrLLLock(pList);
7590 if( !csrLLIsListEmpty( pList, LL_ACCESS_NOLOCK ) )
7591 {
7592 pEntry = csrLLPeekHead( pList, LL_ACCESS_NOLOCK);
7593
7594 // Have to make sure we don't loop back to the head of the list, which will
7595 // happen if the entry is NOT on the list...
7596 while( pEntry )
7597 {
7598 pEntryToRemove = pEntry;
7599 pEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
7600 pCommand = GET_BASE_ADDR( pEntryToRemove, tSmeCmd, Link );
7601 if ( pCommand->command == commandType )
7602 {
7603 // Remove that entry only
7604 if(csrLLRemoveEntry( pList, pEntryToRemove, LL_ACCESS_NOLOCK))
7605 {
7606 csrLLInsertTail(&localList, pEntryToRemove, LL_ACCESS_NOLOCK);
7607 }
7608 }
7609 }
7610
7611
7612 }
7613 csrLLUnlock(pList);
7614
7615 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
7616 {
7617 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7618 csrAbortCommand( pMac, pCommand, eANI_BOOLEAN_FALSE);
7619 }
7620 csrLLClose(&localList);
7621
7622}
7623
7624
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307625eHalStatus csrScanAbortMacScanNotForConnect(tpAniSirGlobal pMac,
7626 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07007627{
7628 eHalStatus status = eHAL_STATUS_SUCCESS;
7629
7630 if( !csrIsScanForRoamCommandActive( pMac ) )
7631 {
7632 //Only abort the scan if it is not used for other roam/connect purpose
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307633 status = csrScanAbortMacScan(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007634 }
7635
7636 return (status);
7637}
7638
7639
Madan Mohan Koyyalamudide1b5bc2013-07-12 00:56:04 +05307640eHalStatus csrScanGetScanChannelInfo(tpAniSirGlobal pMac, tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07007641{
7642 eHalStatus status = eHAL_STATUS_SUCCESS;
7643 tSirMbMsg *pMsg;
7644 tANI_U16 msgLen;
7645
Madan Mohan Koyyalamudide1b5bc2013-07-12 00:56:04 +05307646 if (pMac->fScanOffload)
7647 msgLen = (tANI_U16)(sizeof(tSirSmeGetScanChanReq));
7648 else
7649 msgLen = (tANI_U16)(sizeof(tSirMbMsg));
7650
Jeff Johnson295189b2012-06-20 16:38:30 -07007651 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
7652 if(HAL_STATUS_SUCCESS(status))
7653 {
7654 palZeroMemory(pMac->hHdd, pMsg, msgLen);
7655 pMsg->type = eWNI_SME_GET_SCANNED_CHANNEL_REQ;
7656 pMsg->msgLen = msgLen;
Madan Mohan Koyyalamudide1b5bc2013-07-12 00:56:04 +05307657 if (pMac->fScanOffload)
7658 ((tSirSmeGetScanChanReq *)pMsg)->sessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007659 status = palSendMBMessage(pMac->hHdd, pMsg);
7660 }
7661
7662 return( status );
7663}
7664
7665tANI_BOOLEAN csrRoamIsValidChannel( tpAniSirGlobal pMac, tANI_U8 channel )
7666{
7667 tANI_BOOLEAN fValid = FALSE;
7668 tANI_U32 idxValidChannels;
7669 tANI_U32 len = pMac->roam.numValidChannels;
7670
7671 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
7672 {
7673 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
7674 {
7675 fValid = TRUE;
7676 break;
7677 }
7678 }
7679
7680 return fValid;
7681}
7682
Srikant Kuppa066904f2013-05-07 13:56:02 -07007683eHalStatus csrScanSavePreferredNetworkFound(tpAniSirGlobal pMac,
7684 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
7685{
7686 v_U32_t uLen = 0;
7687 tpSirProbeRespBeacon pParsedFrame;
7688 tCsrScanResult *pScanResult = NULL;
7689 tSirBssDescription *pBssDescr = NULL;
7690 tANI_BOOLEAN fDupBss;
7691 tDot11fBeaconIEs *pIesLocal = NULL;
7692 tAniSSID tmpSsid;
7693 v_TIME_t timer=0;
7694 tpSirMacMgmtHdr macHeader = (tpSirMacMgmtHdr)pPrefNetworkFoundInd->data;
7695
7696 pParsedFrame =
7697 (tpSirProbeRespBeacon) vos_mem_malloc(sizeof(tSirProbeRespBeacon));
7698
7699 if (NULL == pParsedFrame)
7700 {
7701 smsLog(pMac, LOGE, FL(" fail to allocate memory for frame"));
7702 return eHAL_STATUS_RESOURCES;
7703 }
7704
7705 if ( pPrefNetworkFoundInd->frameLength <= SIR_MAC_HDR_LEN_3A )
7706 {
7707 smsLog(pMac, LOGE,
7708 FL("Not enough bytes in PNO indication probe resp frame! length=%d"),
7709 pPrefNetworkFoundInd->frameLength);
7710 vos_mem_free(pParsedFrame);
7711 return eHAL_STATUS_FAILURE;
7712 }
7713
7714 if (sirConvertProbeFrame2Struct(pMac,
7715 &pPrefNetworkFoundInd->data[SIR_MAC_HDR_LEN_3A],
7716 pPrefNetworkFoundInd->frameLength - SIR_MAC_HDR_LEN_3A,
7717 pParsedFrame) != eSIR_SUCCESS ||
7718 !pParsedFrame->ssidPresent)
7719 {
7720 smsLog(pMac, LOGE,
7721 FL("Parse error ProbeResponse, length=%d"),
7722 pPrefNetworkFoundInd->frameLength);
7723 vos_mem_free(pParsedFrame);
7724 return eHAL_STATUS_FAILURE;
7725 }
7726 //24 byte MAC header and 12 byte to ssid IE
7727 if (pPrefNetworkFoundInd->frameLength >
7728 (SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_SSID_OFFSET))
7729 {
7730 uLen = pPrefNetworkFoundInd->frameLength -
7731 (SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_SSID_OFFSET);
7732 }
7733
7734 if ( !HAL_STATUS_SUCCESS(palAllocateMemory( pMac->hHdd,
7735 (void **)&pScanResult, sizeof(tCsrScanResult) + uLen )) )
7736 {
7737 smsLog(pMac, LOGE, FL(" fail to allocate memory for frame"));
7738 vos_mem_free(pParsedFrame);
7739 return eHAL_STATUS_RESOURCES;
7740 }
7741
7742 palZeroMemory( pMac->hHdd, pScanResult, sizeof(tCsrScanResult) + uLen );
7743 pBssDescr = &pScanResult->Result.BssDescriptor;
7744 /**
7745 * Length of BSS desription is without length of
7746 * length itself and length of pointer
7747 * that holds the next BSS description
7748 */
7749 pBssDescr->length = (tANI_U16)(
7750 sizeof(tSirBssDescription) - sizeof(tANI_U16) -
7751 sizeof(tANI_U32) + uLen);
7752 if (pParsedFrame->dsParamsPresent)
7753 {
7754 pBssDescr->channelId = pParsedFrame->channelNumber;
7755 }
7756 else if (pParsedFrame->HTInfo.present)
7757 {
7758 pBssDescr->channelId = pParsedFrame->HTInfo.primaryChannel;
7759 }
7760 else
7761 {
7762 pBssDescr->channelId = pParsedFrame->channelNumber;
7763 }
7764
7765 if ((pBssDescr->channelId > 0) && (pBssDescr->channelId < 15))
7766 {
7767 int i;
7768 // 11b or 11g packet
7769 // 11g iff extended Rate IE is present or
7770 // if there is an A rate in suppRate IE
7771 for (i = 0; i < pParsedFrame->supportedRates.numRates; i++)
7772 {
7773 if (sirIsArate(pParsedFrame->supportedRates.rate[i] & 0x7f))
7774 {
7775 pBssDescr->nwType = eSIR_11G_NW_TYPE;
7776 break;
7777 }
7778 }
7779 if (pParsedFrame->extendedRatesPresent)
7780 {
7781 pBssDescr->nwType = eSIR_11G_NW_TYPE;
7782 }
7783 }
7784 else
7785 {
7786 // 11a packet
7787 pBssDescr->nwType = eSIR_11A_NW_TYPE;
7788 }
7789
7790 pBssDescr->sinr = 0;
7791 pBssDescr->rssi = -1 * pPrefNetworkFoundInd->rssi;
7792 pBssDescr->beaconInterval = pParsedFrame->beaconInterval;
7793 pBssDescr->timeStamp[0] = pParsedFrame->timeStamp[0];
7794 pBssDescr->timeStamp[1] = pParsedFrame->timeStamp[1];
7795 pBssDescr->capabilityInfo = *((tANI_U16 *)&pParsedFrame->capabilityInfo);
7796 palCopyMemory( pMac->hHdd, (tANI_U8 *) &pBssDescr->bssId,
7797 (tANI_U8 *) macHeader->bssId,
7798 sizeof(tSirMacAddr));
7799 pBssDescr->nReceivedTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
7800
7801 smsLog( pMac, LOG2, "(%s):Bssid= %02x-%02x-%02x-%02x-%02x-%02x "
7802 "chan= %d, rssi = %d", __func__,
7803 pBssDescr->bssId[ 0 ], pBssDescr->bssId[ 1 ],
7804 pBssDescr->bssId[ 2 ], pBssDescr->bssId[ 3 ],
7805 pBssDescr->bssId[ 4 ], pBssDescr->bssId[ 5 ],
7806 pBssDescr->channelId,
7807 pBssDescr->rssi );
7808
7809 //IEs
7810 if (uLen)
7811 {
7812 vos_mem_copy( &pBssDescr->ieFields,
7813 pPrefNetworkFoundInd->data +
7814 (SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_SSID_OFFSET),
7815 uLen);
7816 }
7817
7818 pIesLocal = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
7819 if ( !pIesLocal &&
7820 (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac,
7821 &pScanResult->Result.BssDescriptor, &pIesLocal))) )
7822 {
7823 smsLog(pMac, LOGE, FL(" Cannot parse IEs"));
7824 csrFreeScanResultEntry(pMac, pScanResult);
7825 vos_mem_free(pParsedFrame);
7826 return eHAL_STATUS_RESOURCES;
7827 }
7828
7829 fDupBss = csrRemoveDupBssDescription( pMac,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05307830 &pScanResult->Result.BssDescriptor, pIesLocal, &tmpSsid, &timer, FALSE);
Srikant Kuppa066904f2013-05-07 13:56:02 -07007831 //Check whether we have reach out limit
7832 if ( CSR_SCAN_IS_OVER_BSS_LIMIT(pMac) )
7833 {
7834 //Limit reach
7835 smsLog(pMac, LOGE, FL(" BSS limit reached"));
7836 //Free the resources
7837 if( (pScanResult->Result.pvIes == NULL) && pIesLocal )
7838 {
7839 palFreeMemory(pMac->hHdd, pIesLocal);
7840 }
7841 csrFreeScanResultEntry(pMac, pScanResult);
7842 vos_mem_free(pParsedFrame);
7843 return eHAL_STATUS_RESOURCES;
7844 }
7845 //Add to scan cache
7846 csrScanAddResult(pMac, pScanResult, pIesLocal);
7847
7848 vos_mem_free(pParsedFrame);
7849
7850 return eHAL_STATUS_SUCCESS;
7851}
7852
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08007853#ifdef FEATURE_WLAN_LFR
7854void csrInitOccupiedChannelsList(tpAniSirGlobal pMac)
7855{
7856 tListElem *pEntry = NULL;
7857 tCsrScanResult *pBssDesc = NULL;
7858 tDot11fBeaconIEs *pIes = NULL;
Srinivas28b5b4e2012-12-12 13:07:53 -08007859 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7860
7861 if (0 != pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
7862 {
7863 smsLog(pMac, LOG1, FL("%s: Ini file contains neighbor scan channel list,"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007864 " hence NO need to build occupied channel list (numChannels = %d)"),
Srinivas28b5b4e2012-12-12 13:07:53 -08007865 __func__, pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
7866 return;
7867 }
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08007868
7869 if (!csrNeighborRoamIsNewConnectedProfile(pMac))
7870 {
7871 smsLog(pMac, LOG2, FL("%s: donot flush occupied list since current roam profile"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007872 " matches previous (numChannels = %d)"),
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08007873 __func__, pMac->scan.occupiedChannels.numChannels);
7874 return;
7875 }
7876
7877 /* Empty occupied channels here */
7878 pMac->scan.occupiedChannels.numChannels = 0;
7879
7880 csrLLLock(&pMac->scan.scanResultList);
7881 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
7882 while( pEntry )
7883 {
7884 pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
7885 pIes = (tDot11fBeaconIEs *)( pBssDesc->Result.pvIes );
7886
7887 //At this time, pBssDescription->Result.pvIes may be NULL
Srikant Kuppa866893f2012-12-27 17:28:14 -08007888 if( !pIes && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac,
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08007889 &pBssDesc->Result.BssDescriptor, &pIes))) )
7890 {
7891 continue;
7892 }
7893
7894 csrScanAddToOccupiedChannels(pMac, pBssDesc, &pMac->scan.occupiedChannels, pIes);
7895
7896 /*
7897 * Free the memory allocated for pIes in csrGetParsedBssDescriptionIEs
7898 */
7899 if( (pBssDesc->Result.pvIes == NULL) && pIes )
7900 {
7901 palFreeMemory(pMac->hHdd, pIes);
7902 }
7903
7904 pEntry = csrLLNext( &pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK );
7905 }//while
7906 csrLLUnlock(&pMac->scan.scanResultList);
Srikant Kuppa866893f2012-12-27 17:28:14 -08007907
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08007908}
7909#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007910
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07007911eHalStatus csrScanCreateEntryInScanCache(tpAniSirGlobal pMac, tANI_U32 sessionId,
7912 tCsrBssid bssid, tANI_U8 channel)
7913{
7914 eHalStatus status = eHAL_STATUS_SUCCESS;
7915 tDot11fBeaconIEs *pNewIes = NULL;
7916 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7917 tSirBssDescription *pNewBssDescriptor;
7918 tANI_U32 size = 0;
7919
7920 if(NULL == pSession)
7921 {
7922 status = eHAL_STATUS_FAILURE;
7923 return status;
7924 }
7925 smsLog(pMac, LOG2, FL("csrScanCreateEntryInScanCache: Current bssid::"
7926 "0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x"),
7927 pSession->pConnectBssDesc->bssId[0],
7928 pSession->pConnectBssDesc->bssId[1],
7929 pSession->pConnectBssDesc->bssId[2],
7930 pSession->pConnectBssDesc->bssId[3],
7931 pSession->pConnectBssDesc->bssId[4],
7932 pSession->pConnectBssDesc->bssId[5]);
7933 smsLog(pMac, LOG2, FL("csrScanCreateEntryInScanCache: My bssid::"
7934 "0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x channel %d"),
7935 bssid[0],bssid[1],bssid[2],
7936 bssid[3],bssid[4],bssid[5],channel);
7937
7938 do
7939 {
7940 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac,
7941 pSession->pConnectBssDesc, &pNewIes)))
7942 {
7943 smsLog(pMac, LOGE, FL("%s: Failed to parse IEs"),
7944 __func__);
7945 status = eHAL_STATUS_FAILURE;
7946 break;
7947 }
7948
7949 size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length);
7950 if(size)
7951 {
7952 status = palAllocateMemory(pMac->hHdd, (void **)&pNewBssDescriptor, size);
7953 if(HAL_STATUS_SUCCESS(status))
7954 {
7955 palCopyMemory(pMac->hHdd, pNewBssDescriptor, pSession->pConnectBssDesc, size);
7956 }
7957 else
7958 {
7959 smsLog(pMac, LOGE, FL("%s: memory allocation failed"),
7960 __func__);
7961 status = eHAL_STATUS_FAILURE;
7962 break;
7963 }
7964
7965 //change the BSSID & channel as passed
7966 palCopyMemory( pMac->hHdd, pNewBssDescriptor->bssId, bssid,
7967 sizeof(tSirMacAddr) );
7968 pNewBssDescriptor->channelId = channel;
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07007969 if(NULL == csrScanAppendBssDescription( pMac, pNewBssDescriptor, pNewIes, TRUE ))
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07007970 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07007971 smsLog(pMac, LOGE, FL("%s: csrScanAppendBssDescription failed"),
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07007972 __func__);
7973 status = eHAL_STATUS_FAILURE;
7974 break;
7975 }
7976 }
7977 else
7978 {
7979 smsLog(pMac, LOGE, FL("%s: length of bss descriptor is 0"),
7980 __func__);
7981 status = eHAL_STATUS_FAILURE;
7982 break;
7983 }
7984 smsLog(pMac, LOGE, FL("%s: entry successfully added in scan cache"),
7985 __func__);
7986 }while(0);
7987
7988 if(pNewIes)
7989 {
7990 palFreeMemory(pMac->hHdd, pNewIes);
7991 }
7992 if(pNewBssDescriptor)
7993 {
7994 palFreeMemory(pMac->hHdd, pNewBssDescriptor);
7995 }
7996 return status;
7997}