blob: af7d36fc15a0f20db598d8a65cefe37eab66a2c1 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002 * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved.
Kiet Lam0fb93dd2014-02-19 00:32:59 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080020 */
Kiet Lam0fb93dd2014-02-19 00:32:59 -080021
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Jeff Johnson40b59aa2013-03-19 14:43:18 -070028/** ------------------------------------------------------------------------- *
29 ------------------------------------------------------------------------- *
Jeff Johnson295189b2012-06-20 16:38:30 -070030
Jeff Johnson40b59aa2013-03-19 14:43:18 -070031
Jeff Johnson295189b2012-06-20 16:38:30 -070032 \file csrApiScan.c
Jeff Johnson40b59aa2013-03-19 14:43:18 -070033
Jeff Johnson295189b2012-06-20 16:38:30 -070034 Implementation for the Common Scan interfaces.
Jeff Johnson295189b2012-06-20 16:38:30 -070035 ========================================================================== */
36
37#include "aniGlobal.h"
38
39#include "palApi.h"
40#include "csrInsideApi.h"
41#include "smeInside.h"
42#include "smsDebug.h"
43
44#include "csrSupport.h"
45#include "wlan_qct_tl.h"
46
47#include "vos_diag_core_log.h"
48#include "vos_diag_core_event.h"
49
50#include "vos_nvitem.h"
51#include "wlan_qct_wda.h"
Abhishek Singhe3fa11f2014-05-13 11:11:10 +053052#include "vos_utils.h"
Jeff Johnson40b59aa2013-03-19 14:43:18 -070053
Kiet Lamd1f3dc82013-11-05 20:45:04 +053054#define MIN_CHN_TIME_TO_FIND_GO 100
55#define MAX_CHN_TIME_TO_FIND_GO 100
56#define DIRECT_SSID_LEN 7
Jeff Johnson295189b2012-06-20 16:38:30 -070057
Jeff Johnson295189b2012-06-20 16:38:30 -070058
59/* Purpose of HIDDEN_TIMER
60** When we remove hidden ssid from the profile i.e., forget the SSID via GUI that SSID shouldn't see in the profile
61** For above requirement we used timer limit, logic is explained below
62** Timer value is initialsed to current time when it receives corresponding probe response of hidden SSID (The probe request is
63** received regularly till SSID in the profile. Once it is removed from profile probe request is not sent.) when we receive probe response
64** 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
65** then we are not updating with old one
66*/
67
68#define HIDDEN_TIMER (1*60*1000)
69#define CSR_SCAN_RESULT_RSSI_WEIGHT 80 // must be less than 100, represent the persentage of new RSSI
70
71/*---------------------------------------------------------------------------
72 PER filter constant fraction: it is a %
73---------------------------------------------------------------------------*/
74#define CSR_SCAN_PER_FILTER_FRAC 100
75
76/*---------------------------------------------------------------------------
77 RSSI filter constant fraction: it is a %
78---------------------------------------------------------------------------*/
79#define CSR_SCAN_RSSI_FILTER_FRAC 100
80
81/*---------------------------------------------------------------------------
82Convert RSSI into overall score: Since RSSI is in -dBm values, and the
83overall needs to be weighted inversely (where greater value means better
84system), we convert.
85RSSI *cannot* be more than 0xFF or less than 0 for meaningful WLAN operation
86---------------------------------------------------------------------------*/
87#define CSR_SCAN_MAX_SCORE_VAL 0xFF
88#define CSR_SCAN_MIN_SCORE_VAL 0x0
89#define CSR_SCAN_HANDOFF_DELTA 10
Jeff Johnson32d95a32012-09-10 13:15:23 -070090#define MAX_ACTIVE_SCAN_FOR_ONE_CHANNEL 140
91#define MIN_ACTIVE_SCAN_FOR_ONE_CHANNEL 120
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -080092#define CSR_SCAN_OVERALL_SCORE( rssi ) \
93 (( rssi < CSR_SCAN_MAX_SCORE_VAL ) \
94 ? (CSR_SCAN_MAX_SCORE_VAL-rssi) : CSR_SCAN_MIN_SCORE_VAL)
Jeff Johnson295189b2012-06-20 16:38:30 -070095
96
97#define CSR_SCAN_IS_OVER_BSS_LIMIT(pMac) \
98 ( (pMac)->scan.nBssLimit <= (csrLLCount(&(pMac)->scan.scanResultList)) )
99
Gopichand Nakkala10ba6fc2013-04-23 20:30:01 +0530100/* Maximum number of channels per country can be ignored */
101#define MAX_CHANNELS_IGNORE 10
102
Wilson Yange3d2b292013-10-09 00:35:43 -0700103#define MAX_COUNTRY_IGNORE 5
Gopichand Nakkala10ba6fc2013-04-23 20:30:01 +0530104
krunal soni5f112f02013-11-25 15:00:11 -0800105#define MANDATORY_BG_CHANNEL 11
106
Gopichand Nakkala10ba6fc2013-04-23 20:30:01 +0530107/*struct to hold the ignored channel list based on country */
108typedef struct sCsrIgnoreChannels
109{
110 tANI_U8 countryCode[NV_FIELD_COUNTRY_CODE_SIZE];
111 tANI_U16 channelList[MAX_CHANNELS_IGNORE];
112 tANI_U16 channelCount;
113}tCsrIgnoreChannels;
114
Tushnim Bhattacharyya582ac1d2013-11-07 23:44:09 -0800115#ifndef CONFIG_ENABLE_LINUX_REG
Gopichand Nakkala10ba6fc2013-04-23 20:30:01 +0530116static tCsrIgnoreChannels countryIgnoreList[MAX_COUNTRY_IGNORE] = {
117 { {'U','A'}, { 136, 140}, 2},
118 { {'T','W'}, { 36, 40, 44, 48, 52}, 5},
Madan Mohan Koyyalamudi28dd0422013-08-12 15:06:21 +0530119 { {'I','D'}, { 165}, 1 },
Wilson Yange3d2b292013-10-09 00:35:43 -0700120 { {'A','U'}, { 120, 124, 128}, 3 },
Wilson Yangce31eaf2013-11-11 14:40:34 -0800121 { {'A','R'}, { 120, 124, 128}, 3 }
Gopichand Nakkala10ba6fc2013-04-23 20:30:01 +0530122 };
Tushnim Bhattacharyya582ac1d2013-11-07 23:44:09 -0800123#else
124static tCsrIgnoreChannels countryIgnoreList[MAX_COUNTRY_IGNORE] = { };
125#endif //CONFIG_ENABLE_LINUX_REG
Gopichand Nakkala10ba6fc2013-04-23 20:30:01 +0530126
Jeff Johnson295189b2012-06-20 16:38:30 -0700127//*** This is temporary work around. It need to call CCM api to get to CFG later
128/// Get string parameter value
129extern tSirRetStatus wlan_cfgGetStr(tpAniSirGlobal, tANI_U16, tANI_U8*, tANI_U32*);
Gopichand Nakkala10ba6fc2013-04-23 20:30:01 +0530130
Jeff Johnson295189b2012-06-20 16:38:30 -0700131void csrScanGetResultTimerHandler(void *);
132void csrScanResultAgingTimerHandler(void *pv);
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -0800133static void csrScanResultCfgAgingTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700134void csrScanIdleScanTimerHandler(void *);
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700135static void csrSetDefaultScanTiming( tpAniSirGlobal pMac, tSirScanType scanType, tCsrScanRequest *pScanRequest);
Jeff Johnson295189b2012-06-20 16:38:30 -0700136#ifdef WLAN_AP_STA_CONCURRENCY
137static void csrStaApConcTimerHandler(void *);
138#endif
Jeff Johnsone7245742012-09-05 17:12:55 -0700139tANI_BOOLEAN csrIsSupportedChannel(tpAniSirGlobal pMac, tANI_U8 channelId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700140eHalStatus csrScanChannels( tpAniSirGlobal pMac, tSmeCmd *pCommand );
141void csrSetCfgValidChannelList( tpAniSirGlobal pMac, tANI_U8 *pChannelList, tANI_U8 NumChannels );
142void csrSaveTxPowerToCfg( tpAniSirGlobal pMac, tDblLinkList *pList, tANI_U32 cfgId );
143void csrSetCfgCountryCode( tpAniSirGlobal pMac, tANI_U8 *countryCode );
144void csrPurgeChannelPower( tpAniSirGlobal pMac, tDblLinkList *pChannelList );
145//if bgPeriod is 0, background scan is disabled. It is in millisecond units
146eHalStatus csrSetCfgBackgroundScanPeriod(tpAniSirGlobal pMac, tANI_U32 bgPeriod);
147eHalStatus csrProcessSetBGScanParam(tpAniSirGlobal pMac, tSmeCmd *pCommand);
148void csrReleaseScanCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand, eCsrScanStatus scanStatus);
149static tANI_BOOLEAN csrScanValidateScanResult( tpAniSirGlobal pMac, tANI_U8 *pChannels,
150 tANI_U8 numChn, tSirBssDescription *pBssDesc,
151 tDot11fBeaconIEs **ppIes );
152eHalStatus csrSetBGScanChannelList( tpAniSirGlobal pMac, tANI_U8 *pAdjustChannels, tANI_U8 NumAdjustChannels);
153void csrReleaseCmdSingle(tpAniSirGlobal pMac, tSmeCmd *pCommand);
154tANI_BOOLEAN csrRoamIsValidChannel( tpAniSirGlobal pMac, tANI_U8 channel );
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700155void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList );
Jeff Johnson295189b2012-06-20 16:38:30 -0700156
Madan Mohan Koyyalamudi783b2362012-10-21 11:54:41 -0700157#define CSR_IS_SOCIAL_CHANNEL(channel) (((channel) == 1) || ((channel) == 6) || ((channel) == 11) )
158
Madan Mohan Koyyalamudi783b2362012-10-21 11:54:41 -0700159
Madan Mohan Koyyalamudi783b2362012-10-21 11:54:41 -0700160
Madan Mohan Koyyalamudi923c1e12012-11-30 17:53:27 -0800161static void csrReleaseScanCmdPendingList(tpAniSirGlobal pMac)
162{
163 tListElem *pEntry;
164 tSmeCmd *pCommand;
165
166 while((pEntry = csrLLRemoveHead( &pMac->scan.scanCmdPendingList, LL_ACCESS_LOCK)) != NULL)
167 {
168 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
169 if ( eSmeCsrCommandMask & pCommand->command )
170 {
171 csrAbortCommand( pMac, pCommand, eANI_BOOLEAN_TRUE );
172 }
173 else
174 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800175 smsLog(pMac, LOGE, FL("Error: Received command : %d"),pCommand->command);
Madan Mohan Koyyalamudi923c1e12012-11-30 17:53:27 -0800176 }
177 }
178}
Jeff Johnson295189b2012-06-20 16:38:30 -0700179//pResult is invalid calling this function.
180void csrFreeScanResultEntry( tpAniSirGlobal pMac, tCsrScanResult *pResult )
181{
182 if( NULL != pResult->Result.pvIes )
183 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530184 vos_mem_free(pResult->Result.pvIes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700185 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530186 vos_mem_free(pResult);
Jeff Johnson295189b2012-06-20 16:38:30 -0700187}
188
189
190static eHalStatus csrLLScanPurgeResult(tpAniSirGlobal pMac, tDblLinkList *pList)
191{
192 eHalStatus status = eHAL_STATUS_SUCCESS;
193 tListElem *pEntry;
194 tCsrScanResult *pBssDesc;
195
196 csrLLLock(pList);
197
198 while((pEntry = csrLLRemoveHead(pList, LL_ACCESS_NOLOCK)) != NULL)
199 {
200 pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
201 csrFreeScanResultEntry( pMac, pBssDesc );
202 }
203
204 csrLLUnlock(pList);
205
206 return (status);
207}
208
Jeff Johnson295189b2012-06-20 16:38:30 -0700209eHalStatus csrScanOpen( tpAniSirGlobal pMac )
210{
211 eHalStatus status;
212
213 do
214 {
215 csrLLOpen(pMac->hHdd, &pMac->scan.scanResultList);
216 csrLLOpen(pMac->hHdd, &pMac->scan.tempScanResults);
217 csrLLOpen(pMac->hHdd, &pMac->scan.channelPowerInfoList24);
218 csrLLOpen(pMac->hHdd, &pMac->scan.channelPowerInfoList5G);
219#ifdef WLAN_AP_STA_CONCURRENCY
220 csrLLOpen(pMac->hHdd, &pMac->scan.scanCmdPendingList);
221#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700222 pMac->scan.fFullScanIssued = eANI_BOOLEAN_FALSE;
223 pMac->scan.nBssLimit = CSR_MAX_BSS_SUPPORT;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530224 status = vos_timer_init(&pMac->scan.hTimerGetResult, VOS_TIMER_TYPE_SW, csrScanGetResultTimerHandler, pMac);
225 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700226 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800227 smsLog(pMac, LOGE, FL("cannot allocate memory for getResult timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700228 break;
229 }
230#ifdef WLAN_AP_STA_CONCURRENCY
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530231 status = vos_timer_init(&pMac->scan.hTimerStaApConcTimer, VOS_TIMER_TYPE_SW, csrStaApConcTimerHandler, pMac);
232 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700233 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800234 smsLog(pMac, LOGE, FL("cannot allocate memory for hTimerStaApConcTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700235 break;
236 }
237#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530238 status = vos_timer_init(&pMac->scan.hTimerIdleScan, VOS_TIMER_TYPE_SW, csrScanIdleScanTimerHandler, pMac);
239 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700240 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800241 smsLog(pMac, LOGE, FL("cannot allocate memory for idleScan timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700242 break;
243 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530244 status = vos_timer_init(&pMac->scan.hTimerResultAging, VOS_TIMER_TYPE_SW, csrScanResultAgingTimerHandler, pMac);
245 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700246 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800247 smsLog(pMac, LOGE, FL("cannot allocate memory for ResultAging timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700248 break;
249 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530250 status = vos_timer_init(&pMac->scan.hTimerResultCfgAging, VOS_TIMER_TYPE_SW,
251 csrScanResultCfgAgingTimerHandler, pMac);
252 if (!HAL_STATUS_SUCCESS(status))
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -0800253 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800254 smsLog(pMac, LOGE, FL("cannot allocate memory for CFG ResultAging timer"));
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -0800255 break;
256 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700257 }while(0);
258
259 return (status);
260}
261
262
263eHalStatus csrScanClose( tpAniSirGlobal pMac )
264{
Jeff Johnson295189b2012-06-20 16:38:30 -0700265 csrLLScanPurgeResult(pMac, &pMac->scan.tempScanResults);
266 csrLLScanPurgeResult(pMac, &pMac->scan.scanResultList);
267#ifdef WLAN_AP_STA_CONCURRENCY
Madan Mohan Koyyalamudi923c1e12012-11-30 17:53:27 -0800268 csrReleaseScanCmdPendingList(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700269#endif
270 csrLLClose(&pMac->scan.scanResultList);
271 csrLLClose(&pMac->scan.tempScanResults);
272#ifdef WLAN_AP_STA_CONCURRENCY
273 csrLLClose(&pMac->scan.scanCmdPendingList);
274#endif
275 csrPurgeChannelPower(pMac, &pMac->scan.channelPowerInfoList24);
276 csrPurgeChannelPower(pMac, &pMac->scan.channelPowerInfoList5G);
277 csrLLClose(&pMac->scan.channelPowerInfoList24);
278 csrLLClose(&pMac->scan.channelPowerInfoList5G);
279 csrScanDisable(pMac);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530280 vos_timer_destroy(&pMac->scan.hTimerResultAging);
281 vos_timer_destroy(&pMac->scan.hTimerResultCfgAging);
282 vos_timer_destroy(&pMac->scan.hTimerGetResult);
Jeff Johnson295189b2012-06-20 16:38:30 -0700283#ifdef WLAN_AP_STA_CONCURRENCY
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530284 vos_timer_destroy(&pMac->scan.hTimerStaApConcTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700285#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530286 vos_timer_destroy(&pMac->scan.hTimerIdleScan);
Jeff Johnson295189b2012-06-20 16:38:30 -0700287 return eHAL_STATUS_SUCCESS;
288}
289
290
291eHalStatus csrScanEnable( tpAniSirGlobal pMac )
292{
293
294 pMac->scan.fScanEnable = eANI_BOOLEAN_TRUE;
295 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE;
296
297 return eHAL_STATUS_SUCCESS;
298}
299
300
301eHalStatus csrScanDisable( tpAniSirGlobal pMac )
302{
303
304 csrScanStopTimers(pMac);
305 pMac->scan.fScanEnable = eANI_BOOLEAN_FALSE;
306
307 return eHAL_STATUS_SUCCESS;
308}
309
310
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700311//Set scan timing parameters according to state of other driver sessions
312//No validation of the parameters is performed.
313static void csrSetDefaultScanTiming( tpAniSirGlobal pMac, tSirScanType scanType, tCsrScanRequest *pScanRequest)
314{
315#ifdef WLAN_AP_STA_CONCURRENCY
316 if(csrIsAnySessionConnected(pMac))
317 {
318 //If multi-session, use the appropriate default scan times
319 if(scanType == eSIR_ACTIVE_SCAN)
320 {
321 pScanRequest->maxChnTime = pMac->roam.configParam.nActiveMaxChnTimeConc;
322 pScanRequest->minChnTime = pMac->roam.configParam.nActiveMinChnTimeConc;
323 }
324 else
325 {
326 pScanRequest->maxChnTime = pMac->roam.configParam.nPassiveMaxChnTimeConc;
327 pScanRequest->minChnTime = pMac->roam.configParam.nPassiveMinChnTimeConc;
328 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530329 pScanRequest->maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
330 pScanRequest->minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700331
332 pScanRequest->restTime = pMac->roam.configParam.nRestTimeConc;
333
334 //Return so that fields set above will not be overwritten.
335 return;
336 }
337#endif
338
339 //This portion of the code executed if multi-session not supported
340 //(WLAN_AP_STA_CONCURRENCY not defined) or no multi-session.
341 //Use the "regular" (non-concurrency) default scan timing.
342 if(pScanRequest->scanType == eSIR_ACTIVE_SCAN)
343 {
344 pScanRequest->maxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
345 pScanRequest->minChnTime = pMac->roam.configParam.nActiveMinChnTime;
346 }
347 else
348 {
349 pScanRequest->maxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
350 pScanRequest->minChnTime = pMac->roam.configParam.nPassiveMinChnTime;
351 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530352 pScanRequest->maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
353 pScanRequest->minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700354
355#ifdef WLAN_AP_STA_CONCURRENCY
356 //No rest time if no sessions are connected.
357 pScanRequest->restTime = 0;
358#endif
359}
360
Jeff Johnson295189b2012-06-20 16:38:30 -0700361#ifdef WLAN_AP_STA_CONCURRENCY
362//Return SUCCESS is the command is queued, else returns eHAL_STATUS_FAILURE
363eHalStatus csrQueueScanRequest( tpAniSirGlobal pMac, tSmeCmd *pScanCmd )
364{
365 eHalStatus status = eHAL_STATUS_SUCCESS;
366
367 tANI_BOOLEAN fNoCmdPending;
368 tSmeCmd *pQueueScanCmd=NULL;
369 tSmeCmd *pSendScanCmd=NULL;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -0700370 tANI_U8 nNumChanCombinedConc = 0;
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700371 if (NULL == pScanCmd)
372 {
373 smsLog (pMac, LOGE, FL("Scan Req cmd is NULL"));
374 return eHAL_STATUS_FAILURE;
375 }
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -0800376 /* split scan if any one of the following:
377 * - STA session is connected and the scan is not a P2P search
378 * - any P2P session is connected
Srikant Kuppa866893f2012-12-27 17:28:14 -0800379 * Do not split scans if no concurrent infra connections are
380 * active and if the scan is a BG scan triggered by LFR (OR)
381 * any scan if LFR is in the middle of a BG scan. Splitting
382 * the scan is delaying the time it takes for LFR to find
383 * candidates and resulting in disconnects.
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -0800384 */
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -0700385
386 if(csrIsStaSessionConnected(pMac) &&
387 !csrIsP2pSessionConnected(pMac))
388 {
389 nNumChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
390 }
391 else if(csrIsP2pSessionConnected(pMac))
392 {
393 nNumChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
394 }
Srikant Kuppa866893f2012-12-27 17:28:14 -0800395 if ( (csrIsStaSessionConnected(pMac) &&
396#ifdef FEATURE_WLAN_LFR
397 (csrIsConcurrentInfraConnected(pMac) ||
398 ((pScanCmd->u.scanCmd.reason != eCsrScanBgScan) &&
399 (pMac->roam.neighborRoamInfo.neighborRoamState !=
400 eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN))) &&
401#endif
402 (pScanCmd->u.scanCmd.u.scanRequest.p2pSearch != 1)) ||
Vinay Malekal05fdc812012-12-17 13:04:30 -0800403 (csrIsP2pSessionConnected(pMac)) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700404 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700405 tCsrScanRequest scanReq;
406 tANI_U8 numChn = pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels;
407 tCsrChannelInfo *pChnInfo = &scanReq.ChannelInfo;
408 tANI_U8 channelToScan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -0700409 tANI_BOOLEAN bMemAlloc = eANI_BOOLEAN_FALSE;
410
411 if (numChn == 0)
412 {
413
414 numChn = pMac->scan.baseChannels.numChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -0700415
Kiet Lam64c1b492013-07-12 13:56:44 +0530416 pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = vos_mem_malloc(numChn);
417 if ( NULL == pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList )
Jeff Johnson295189b2012-06-20 16:38:30 -0700418 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800419 smsLog( pMac, LOGE, FL(" Failed to get memory for channel list ") );
Vinay Malekal05fdc812012-12-17 13:04:30 -0800420 return eHAL_STATUS_FAILURE;
421 }
422 bMemAlloc = eANI_BOOLEAN_TRUE;
Kiet Lam64c1b492013-07-12 13:56:44 +0530423 vos_mem_copy(pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList,
424 pMac->scan.baseChannels.channelList, numChn);
425 status = eHAL_STATUS_SUCCESS;
Vinay Malekal05fdc812012-12-17 13:04:30 -0800426 if( !HAL_STATUS_SUCCESS( status ) )
427 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530428 vos_mem_free(pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList);
Vinay Malekal05fdc812012-12-17 13:04:30 -0800429 pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = NULL;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800430 smsLog( pMac, LOGE, FL(" Failed to copy memory to channel list ") );
Vinay Malekal05fdc812012-12-17 13:04:30 -0800431 return eHAL_STATUS_FAILURE;
432 }
433 pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = numChn;
434 }
Sushant Kaushik826de802014-05-08 18:04:11 +0530435 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
436 "%s: Total Number of channels to scan : %d "
437 "Splitted in group of %d ", __func__, numChn,
438 nNumChanCombinedConc);
Vinay Malekal05fdc812012-12-17 13:04:30 -0800439 //Whenever we get a scan request with multiple channels we break it up into 2 requests
440 //First request for first channel to scan and second request to scan remaining channels
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -0700441 if ( numChn > nNumChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -0800442 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530443 vos_mem_set(&scanReq, sizeof(tCsrScanRequest), 0);
Vinay Malekal05fdc812012-12-17 13:04:30 -0800444
445 pQueueScanCmd = csrGetCommandBuffer(pMac); //optimize this to use 2 command buffer only
446 if (!pQueueScanCmd)
447 {
448 if (bMemAlloc)
Jeff Johnson295189b2012-06-20 16:38:30 -0700449 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530450 vos_mem_free(pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList);
Vinay Malekal05fdc812012-12-17 13:04:30 -0800451 pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = NULL;
452
Jeff Johnson295189b2012-06-20 16:38:30 -0700453 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800454 smsLog( pMac, LOGE, FL(" Failed to get Queue command buffer") );
Vinay Malekal05fdc812012-12-17 13:04:30 -0800455 return eHAL_STATUS_FAILURE;
456 }
457 pQueueScanCmd->command = pScanCmd->command;
458 pQueueScanCmd->sessionId = pScanCmd->sessionId;
459 pQueueScanCmd->u.scanCmd.callback = pScanCmd->u.scanCmd.callback;
460 pQueueScanCmd->u.scanCmd.pContext = pScanCmd->u.scanCmd.pContext;
461 pQueueScanCmd->u.scanCmd.reason = pScanCmd->u.scanCmd.reason;
462 pQueueScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around
Jeff Johnson295189b2012-06-20 16:38:30 -0700463
Vinay Malekal05fdc812012-12-17 13:04:30 -0800464 /* First copy all the parameters to local variable of scan request */
465 csrScanCopyRequest(pMac, &scanReq, &pScanCmd->u.scanCmd.u.scanRequest);
Madan Mohan Koyyalamudiaf2a8b92012-10-09 14:58:07 -0700466
Vinay Malekal05fdc812012-12-17 13:04:30 -0800467 /* Now modify the elements of local var scan request required to be modified for split scan */
468 if(scanReq.ChannelInfo.ChannelList != NULL)
469 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530470 vos_mem_free(scanReq.ChannelInfo.ChannelList);
Madan Mohan Koyyalamudi0c626f32012-11-30 15:10:25 -0800471 scanReq.ChannelInfo.ChannelList = NULL;
Vinay Malekal05fdc812012-12-17 13:04:30 -0800472 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700473
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -0700474 pChnInfo->numOfChannels = pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels - nNumChanCombinedConc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700475
Vinay Malekal05fdc812012-12-17 13:04:30 -0800476 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +0530477 FL(" &channelToScan %p pScanCmd(%p) pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList(%p)numChn(%d)"),
478 &channelToScan[0], pScanCmd,
479 pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList, numChn);
Jeff Johnson295189b2012-06-20 16:38:30 -0700480
Kiet Lam64c1b492013-07-12 13:56:44 +0530481 vos_mem_copy(&channelToScan[0],
482 &pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[
483 nNumChanCombinedConc],
484 pChnInfo->numOfChannels * sizeof(tANI_U8));
Vinay Malekal05fdc812012-12-17 13:04:30 -0800485
486 pChnInfo->ChannelList = &channelToScan[0];
487
488 scanReq.BSSType = eCSR_BSS_TYPE_ANY;
c_hpothudbefd3e2014-04-28 15:59:47 +0530489
Vinay Malekal05fdc812012-12-17 13:04:30 -0800490 //Use concurrency values for min/maxChnTime.
491 //We know csrIsAnySessionConnected(pMac) returns TRUE here
492 csrSetDefaultScanTiming(pMac, scanReq.scanType, &scanReq);
493
494 status = csrScanCopyRequest(pMac, &pQueueScanCmd->u.scanCmd.u.scanRequest, &scanReq);
495
496 if(!HAL_STATUS_SUCCESS(status))
497 {
498 if (bMemAlloc)
499 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530500 vos_mem_free(pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList);
Vinay Malekal05fdc812012-12-17 13:04:30 -0800501 pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = NULL;
502
503 }
504 if( scanReq.pIEField != NULL)
505 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530506 vos_mem_free(scanReq.pIEField);
Vinay Malekal05fdc812012-12-17 13:04:30 -0800507 scanReq.pIEField = NULL;
508 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800509 smsLog( pMac, LOGE, FL(" Failed to get copy csrScanRequest = %d"), status );
Vinay Malekal05fdc812012-12-17 13:04:30 -0800510 return eHAL_STATUS_FAILURE;
511 }
512 /* Clean the local scan variable */
513 scanReq.ChannelInfo.ChannelList = NULL;
514 scanReq.ChannelInfo.numOfChannels = 0;
515 csrScanFreeRequest(pMac, &scanReq);
516
517 /* setup the command to scan 2 channels */
518 pSendScanCmd = pScanCmd;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -0700519 pSendScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = nNumChanCombinedConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -0800520 pSendScanCmd->u.scanCmd.u.scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
c_hpothudbefd3e2014-04-28 15:59:47 +0530521
Vinay Malekal05fdc812012-12-17 13:04:30 -0800522 //Use concurrency values for min/maxChnTime.
523 //We know csrIsAnySessionConnected(pMac) returns TRUE here
524 csrSetDefaultScanTiming(pMac, pSendScanCmd->u.scanCmd.u.scanRequest.scanType, &pSendScanCmd->u.scanCmd.u.scanRequest);
525 pSendScanCmd->u.scanCmd.callback = NULL;
526 } else {
527 pSendScanCmd = pScanCmd;
528 pSendScanCmd->u.scanCmd.u.scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
c_hpothudbefd3e2014-04-28 15:59:47 +0530529
Vinay Malekal05fdc812012-12-17 13:04:30 -0800530 //Use concurrency values for min/maxChnTime.
531 //We know csrIsAnySessionConnected(pMac) returns TRUE here
532 csrSetDefaultScanTiming(pMac, pSendScanCmd->u.scanCmd.u.scanRequest.scanType, &pSendScanCmd->u.scanCmd.u.scanRequest);
533 }
534
535 fNoCmdPending = csrLLIsListEmpty( &pMac->scan.scanCmdPendingList, LL_ACCESS_LOCK );
536
537 //Logic Below is as follows
538 // If the scanCmdPendingList is empty then we directly send that command
539 // to smeCommandQueue else we buffer it in our scanCmdPendingList Queue
540 if( fNoCmdPending )
541 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700542 if (pQueueScanCmd != NULL)
543 {
Vinay Malekal05fdc812012-12-17 13:04:30 -0800544 csrLLInsertTail( &pMac->scan.scanCmdPendingList, &pQueueScanCmd->Link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -0700545 }
546
547 if (pSendScanCmd != NULL)
548 {
549 return csrQueueSmeCommand(pMac, pSendScanCmd, eANI_BOOLEAN_FALSE);
550 }
Vinay Malekal05fdc812012-12-17 13:04:30 -0800551 }
552 else
553 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700554 if (pSendScanCmd != NULL)
555 {
556 csrLLInsertTail( &pMac->scan.scanCmdPendingList, &pSendScanCmd->Link, LL_ACCESS_LOCK );
557 }
Vinay Malekal05fdc812012-12-17 13:04:30 -0800558
Jeff Johnson295189b2012-06-20 16:38:30 -0700559 if (pQueueScanCmd != NULL)
560 {
561 csrLLInsertTail( &pMac->scan.scanCmdPendingList, &pQueueScanCmd->Link, LL_ACCESS_LOCK );
562 }
Vinay Malekal05fdc812012-12-17 13:04:30 -0800563 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700564 }
565 else
566 { //No concurrency case
Srikant Kuppa866893f2012-12-27 17:28:14 -0800567 smsLog( pMac, LOG2, FL("Queuing scan command (reason=%d, roamState=%d"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800568 " numOfChannels=%d)"),
Srikant Kuppa866893f2012-12-27 17:28:14 -0800569 pScanCmd->u.scanCmd.reason,
570 pMac->roam.neighborRoamInfo.neighborRoamState,
571 pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -0700572 return csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_FALSE);
573 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700574
575 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -0700576}
577#endif
578
Jeff Johnsone7245742012-09-05 17:12:55 -0700579/* ---------------------------------------------------------------------------
580 \fn csrScan2GOnyRequest
581 \brief This function will update the scan request with only
Jeff Johnsonb88db982012-12-10 13:34:59 -0800582 2.4GHz valid channel list.
Jeff Johnsone7245742012-09-05 17:12:55 -0700583 \param pMac
584 \param pScanCmd
585 \param pScanRequest
586 \return None
587 -------------------------------------------------------------------------------*/
588static void csrScan2GOnyRequest(tpAniSirGlobal pMac,tSmeCmd *pScanCmd,
589 tCsrScanRequest *pScanRequest)
590{
591 tANI_U8 index, channelId, channelListSize = 0;
592 tANI_U8 channelList2G[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14};
593 static tANI_U8 validchannelList[CSR_MAX_2_4_GHZ_SUPPORTED_CHANNELS] = {0};
594
595 VOS_ASSERT(pScanCmd && pScanRequest);
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -0700596 /* To silence the KW tool null check is added */
597 if((pScanCmd == NULL) || (pScanRequest == NULL))
598 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800599 smsLog( pMac, LOGE, FL(" pScanCmd or pScanRequest is NULL "));
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -0700600 return;
601 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700602
603 if (pScanCmd->u.scanCmd.scanID ||
604 (eCSR_SCAN_REQUEST_FULL_SCAN != pScanRequest->requestType))
605 return;
606
607 //Contsruct valid Supported 2.4 GHz Channel List
608 for( index = 0; index < ARRAY_SIZE(channelList2G); index++ )
609 {
610 channelId = channelList2G[index];
611 if ( csrIsSupportedChannel( pMac, channelId ) )
612 {
613 validchannelList[channelListSize++] = channelId;
614 }
615 }
616
617 pScanRequest->ChannelInfo.numOfChannels = channelListSize;
618 pScanRequest->ChannelInfo.ChannelList = validchannelList;
619}
620
Jeff Johnson295189b2012-06-20 16:38:30 -0700621eHalStatus csrScanRequest(tpAniSirGlobal pMac, tANI_U16 sessionId,
622 tCsrScanRequest *pScanRequest, tANI_U32 *pScanRequestID,
623 csrScanCompleteCallback callback, void *pContext)
624{
625 eHalStatus status = eHAL_STATUS_FAILURE;
626 tSmeCmd *pScanCmd = NULL;
Madan Mohan Koyyalamudicb90bb22012-10-30 18:24:43 -0700627 eCsrConnectState ConnectState;
Jeff Johnson295189b2012-06-20 16:38:30 -0700628
Gopichand Nakkala9b89a732012-12-31 16:31:46 -0800629 if(pScanRequest == NULL)
630 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800631 smsLog( pMac, LOGE, FL(" pScanRequest is NULL"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -0800632 VOS_ASSERT(0);
Kaushik, Sushant488df382014-03-05 11:43:47 +0530633 return eHAL_STATUS_FAILURE ;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -0800634 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700635
Kiet Lamd1f3dc82013-11-05 20:45:04 +0530636 /* During group formation, the P2P client scans for GO with the specific SSID.
637 * There will be chances of GO switching to other channels because of scan or
638 * to STA channel in case of STA+GO MCC scenario. So to increase the possibility
639 * of client to find the GO, the dwell time of scan is increased to 100ms.
640 */
641 if(pScanRequest->p2pSearch)
642 {
Rashmi Ramanna6f7931c2013-12-20 09:04:12 +0530643 if(pScanRequest->SSIDs.numOfSSIDs)
Kiet Lamd1f3dc82013-11-05 20:45:04 +0530644 {
Rashmi Ramanna6f7931c2013-12-20 09:04:12 +0530645 //If the scan request is for specific SSId the length of SSID will be
646 //greater than 7 as SSID for p2p search contains "DIRECT-")
647 if(pScanRequest->SSIDs.SSIDList->SSID.length > DIRECT_SSID_LEN)
648 {
Vinay Krishna Eranna636b7bc2013-12-18 20:49:08 +0530649 smsLog( pMac, LOG1, FL("P2P: Increasing the min and max Dwell"
650 " time to %d for specific SSID scan %.*s"),
651 MAX_CHN_TIME_TO_FIND_GO,
652 pScanRequest->SSIDs.SSIDList->SSID.length,
653 pScanRequest->SSIDs.SSIDList->SSID.ssId);
Rashmi Ramanna6f7931c2013-12-20 09:04:12 +0530654 pScanRequest->maxChnTime = MAX_CHN_TIME_TO_FIND_GO;
655 pScanRequest->minChnTime = MIN_CHN_TIME_TO_FIND_GO;
656 }
Kiet Lamd1f3dc82013-11-05 20:45:04 +0530657 }
658 }
659
Jeff Johnson295189b2012-06-20 16:38:30 -0700660 do
661 {
662 if(pMac->scan.fScanEnable)
663 {
664 pScanCmd = csrGetCommandBuffer(pMac);
665 if(pScanCmd)
666 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530667 vos_mem_set(&pScanCmd->u.scanCmd, sizeof(tScanCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700668 pScanCmd->command = eSmeCommandScan;
669 pScanCmd->sessionId = sessionId;
670 pScanCmd->u.scanCmd.callback = callback;
671 pScanCmd->u.scanCmd.pContext = pContext;
672 if(eCSR_SCAN_REQUEST_11D_SCAN == pScanRequest->requestType)
673 {
674 pScanCmd->u.scanCmd.reason = eCsrScan11d1;
675 }
676 else if((eCSR_SCAN_REQUEST_FULL_SCAN == pScanRequest->requestType) ||
677 (eCSR_SCAN_P2P_DISCOVERY == pScanRequest->requestType)
678#ifdef SOFTAP_CHANNEL_RANGE
679 ||(eCSR_SCAN_SOFTAP_CHANNEL_RANGE == pScanRequest->requestType)
680#endif
681 )
682 {
683 pScanCmd->u.scanCmd.reason = eCsrScanUserRequest;
684 }
685 else if(eCSR_SCAN_HO_BG_SCAN == pScanRequest->requestType)
686 {
687 pScanCmd->u.scanCmd.reason = eCsrScanBgScan;
688 }
689 else if(eCSR_SCAN_HO_PROBE_SCAN == pScanRequest->requestType)
690 {
691 pScanCmd->u.scanCmd.reason = eCsrScanProbeBss;
692 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700693 else if(eCSR_SCAN_P2P_FIND_PEER == pScanRequest->requestType)
694 {
695 pScanCmd->u.scanCmd.reason = eCsrScanP2PFindPeer;
696 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700697 else
698 {
699 pScanCmd->u.scanCmd.reason = eCsrScanIdleScan;
700 }
701 if(pScanRequest->minChnTime == 0 && pScanRequest->maxChnTime == 0)
702 {
703 //The caller doesn't set the time correctly. Set it here
Vinay Krishna Eranna636b7bc2013-12-18 20:49:08 +0530704 csrSetDefaultScanTiming(pMac, pScanRequest->scanType,
705 pScanRequest);
706 smsLog(pMac, LOG1, FL("Setting default min %d and max %d"
707 " ChnTime"), pScanRequest->minChnTime,
708 pScanRequest->maxChnTime);
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700709 }
710#ifdef WLAN_AP_STA_CONCURRENCY
711 if(pScanRequest->restTime == 0)
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -0800712 {
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700713 //Need to set restTime only if at least one session is connected
714 if(csrIsAnySessionConnected(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -0700715 {
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700716 pScanRequest->restTime = pMac->roam.configParam.nRestTimeConc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700717 }
718 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700719#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -0700720 /*For Standalone wlan : channel time will remain the same.
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530721 For BTC with A2DP up: Channel time = Channel time * 2, if station is not already associated.
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -0800722 This has been done to provide a larger scan window for faster connection during btc.Else Scan is seen
723 to take a long time.
724 For BTC with A2DP up: Channel time will not be doubled, if station is already associated.
725 */
Jeff Johnson32d95a32012-09-10 13:15:23 -0700726 status = csrRoamGetConnectState(pMac,sessionId,&ConnectState);
Srinivas Girigowdac84c57c2013-02-19 17:41:56 -0800727 if (HAL_STATUS_SUCCESS(status) &&
728 pMac->btc.fA2DPUp &&
Jeff Johnson32d95a32012-09-10 13:15:23 -0700729 (eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED != ConnectState) &&
730 (eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED != ConnectState))
731 {
732 pScanRequest->maxChnTime = pScanRequest->maxChnTime << 1;
733 pScanRequest->minChnTime = pScanRequest->minChnTime << 1;
Vinay Krishna Eranna636b7bc2013-12-18 20:49:08 +0530734 smsLog( pMac, LOG1, FL("BTC A2DP up, doubling max and min"
735 " ChnTime (Max=%d Min=%d)"),
736 pScanRequest->maxChnTime,
737 pScanRequest->minChnTime);
Jeff Johnson32d95a32012-09-10 13:15:23 -0700738 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -0800739
Kiet Lam64c1b492013-07-12 13:56:44 +0530740 pScanRequest->maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
741 pScanRequest->minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700742 //Need to make the following atomic
743 pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around
744
745 if(pScanRequestID)
746 {
747 *pScanRequestID = pScanCmd->u.scanCmd.scanID;
748 }
749
Gopichand Nakkala9b89a732012-12-31 16:31:46 -0800750 // If it is the first scan request from HDD, CSR checks if it is for 11d.
Jeff Johnson295189b2012-06-20 16:38:30 -0700751 // If it is not, CSR will save the scan request in the pending cmd queue
752 // & issue an 11d scan request to PE.
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -0800753 if (((0 == pScanCmd->u.scanCmd.scanID)
Jeff Johnson295189b2012-06-20 16:38:30 -0700754 && (eCSR_SCAN_REQUEST_11D_SCAN != pScanRequest->requestType))
755#ifdef SOFTAP_CHANNEL_RANGE
756 && (eCSR_SCAN_SOFTAP_CHANNEL_RANGE != pScanRequest->requestType)
757#endif
758 && (eANI_BOOLEAN_FALSE == pMac->scan.fEnableBypass11d)
759 )
760 {
761 tSmeCmd *p11dScanCmd;
762 tCsrScanRequest scanReq;
763 tCsrChannelInfo *pChnInfo = &scanReq.ChannelInfo;
764
Kiet Lam64c1b492013-07-12 13:56:44 +0530765 vos_mem_set(&scanReq, sizeof(tCsrScanRequest), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700766
767 p11dScanCmd = csrGetCommandBuffer(pMac);
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -0800768 if (p11dScanCmd)
Jeff Johnson295189b2012-06-20 16:38:30 -0700769 {
770 tANI_U32 numChn = pMac->scan.baseChannels.numChannels;
771
Kiet Lam64c1b492013-07-12 13:56:44 +0530772 vos_mem_set(&p11dScanCmd->u.scanCmd, sizeof(tScanCmd), 0);
773 pChnInfo->ChannelList = vos_mem_malloc(numChn);
774 if ( NULL == pChnInfo->ChannelList )
Jeff Johnson295189b2012-06-20 16:38:30 -0700775 {
Vinay Krishna Eranna636b7bc2013-12-18 20:49:08 +0530776 smsLog(pMac, LOGE, FL("Failed to allocate memory"));
777 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700778 break;
779 }
Vinay Krishna Eranna636b7bc2013-12-18 20:49:08 +0530780 vos_mem_copy(pChnInfo->ChannelList,
781 pMac->scan.baseChannels.channelList,
782 numChn);
Jeff Johnson295189b2012-06-20 16:38:30 -0700783 pChnInfo->numOfChannels = (tANI_U8)numChn;
Vinay Krishna Eranna636b7bc2013-12-18 20:49:08 +0530784
Jeff Johnson295189b2012-06-20 16:38:30 -0700785 p11dScanCmd->command = eSmeCommandScan;
Mihir Shetefc7ff5b2014-01-27 11:30:05 +0530786 p11dScanCmd->u.scanCmd.callback = pMac->scan.callback11dScanDone;
Jeff Johnson295189b2012-06-20 16:38:30 -0700787 p11dScanCmd->u.scanCmd.pContext = NULL;
c_hpothu0d5a7352014-03-22 12:30:25 +0530788 p11dScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID;
Jeff Johnson295189b2012-06-20 16:38:30 -0700789 scanReq.BSSType = eCSR_BSS_TYPE_ANY;
790
791 if ( csrIs11dSupported(pMac) )
792 {
c_hpothudbefd3e2014-04-28 15:59:47 +0530793 scanReq.scanType = eSIR_PASSIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700794 scanReq.requestType = eCSR_SCAN_REQUEST_11D_SCAN;
795 p11dScanCmd->u.scanCmd.reason = eCsrScan11d1;
796 scanReq.maxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
797 scanReq.minChnTime = pMac->roam.configParam.nPassiveMinChnTime;
798 }
799 else
800 {
c_hpothudbefd3e2014-04-28 15:59:47 +0530801 scanReq.scanType = pScanRequest->scanType;
Jeff Johnson295189b2012-06-20 16:38:30 -0700802 scanReq.requestType = eCSR_SCAN_IDLE_MODE_SCAN;
803 p11dScanCmd->u.scanCmd.reason = eCsrScanIdleScan;
804 scanReq.maxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
805 scanReq.minChnTime = pMac->roam.configParam.nActiveMinChnTime;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -0800806
Madan Mohan Koyyalamudi04a65f02013-07-26 13:58:38 +0530807 scanReq.maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
808 scanReq.minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700809 }
c_hpothu059edb02014-03-12 21:44:28 +0530810 if (pMac->roam.configParam.nInitialDwellTime)
811 {
812 scanReq.maxChnTime =
813 pMac->roam.configParam.nInitialDwellTime;
814 smsLog(pMac, LOG1, FL("11d scan, updating"
815 "dwell time for first scan %u"),
816 scanReq.maxChnTime);
817 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700818
Jeff Johnson295189b2012-06-20 16:38:30 -0700819 status = csrScanCopyRequest(pMac, &p11dScanCmd->u.scanCmd.u.scanRequest, &scanReq);
820 //Free the channel list
Kiet Lam64c1b492013-07-12 13:56:44 +0530821 vos_mem_free(pChnInfo->ChannelList);
James Zmuda9ea1edd2013-04-18 18:20:54 -0700822 pChnInfo->ChannelList = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700823
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -0800824 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700825 {
krunal soni5f112f02013-11-25 15:00:11 -0800826 pMac->scan.scanProfile.numOfChannels =
827 p11dScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -0700828 //Start process the command
829#ifdef WLAN_AP_STA_CONCURRENCY
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530830 if (!pMac->fScanOffload)
831 status = csrQueueScanRequest(pMac, p11dScanCmd);
832 else
833 status = csrQueueSmeCommand(pMac, p11dScanCmd,
834 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700835#else
836 status = csrQueueSmeCommand(pMac, p11dScanCmd, eANI_BOOLEAN_FALSE);
837#endif
838 if( !HAL_STATUS_SUCCESS( status ) )
839 {
Vinay Krishna Eranna636b7bc2013-12-18 20:49:08 +0530840 smsLog(pMac, LOGE, FL("Failed to send message"
841 " status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -0700842 break;
843 }
844 }
845 else
846 {
Vinay Krishna Eranna636b7bc2013-12-18 20:49:08 +0530847 smsLog(pMac, LOGE, FL("csrScanCopyRequest failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700848 break;
849 }
850 }
851 else
852 {
853 //error
Vinay Krishna Eranna636b7bc2013-12-18 20:49:08 +0530854 smsLog( pMac, LOGE, FL("p11dScanCmd failed") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700855 break;
856 }
857 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700858
859 //Scan only 2G Channels if set in ini file
860 //This is mainly to reduce the First Scan duration
861 //Once we turn on Wifi
862 if(pMac->scan.fFirstScanOnly2GChnl)
863 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800864 smsLog( pMac, LOG1, FL("Scanning only 2G Channels during first scan"));
Jeff Johnsone7245742012-09-05 17:12:55 -0700865 csrScan2GOnyRequest(pMac, pScanCmd, pScanRequest);
866 }
867
c_hpothu059edb02014-03-12 21:44:28 +0530868 if (pMac->roam.configParam.nInitialDwellTime)
869 {
870 pScanRequest->maxChnTime =
871 pMac->roam.configParam.nInitialDwellTime;
872 pMac->roam.configParam.nInitialDwellTime = 0;
873 smsLog(pMac, LOG1,
874 FL("updating dwell time for first scan %u"),
875 pScanRequest->maxChnTime);
876 }
877
Jeff Johnson295189b2012-06-20 16:38:30 -0700878 status = csrScanCopyRequest(pMac, &pScanCmd->u.scanCmd.u.scanRequest, pScanRequest);
879 if(HAL_STATUS_SUCCESS(status))
880 {
Vinay Krishna Eranna636b7bc2013-12-18 20:49:08 +0530881 tCsrScanRequest *pTempScanReq =
882 &pScanCmd->u.scanCmd.u.scanRequest;
krunal soni5f112f02013-11-25 15:00:11 -0800883 pMac->scan.scanProfile.numOfChannels =
Vinay Krishna Eranna636b7bc2013-12-18 20:49:08 +0530884 pTempScanReq->ChannelInfo.numOfChannels;
krunal soni5f112f02013-11-25 15:00:11 -0800885
Vinay Krishna Eranna636b7bc2013-12-18 20:49:08 +0530886 smsLog( pMac, LOG1, FL(" SId=%d scanId=%d"
887 " Scan reason=%u numSSIDs=%d"
888 " numChan=%d P2P search=%d minCT=%d maxCT=%d"
889 " minCBtc=%d maxCBtx=%d"),
890 sessionId, pScanCmd->u.scanCmd.scanID,
891 pScanCmd->u.scanCmd.reason,
892 pTempScanReq->SSIDs.numOfSSIDs,
893 pTempScanReq->ChannelInfo.numOfChannels,
894 pTempScanReq->p2pSearch,
895 pTempScanReq->minChnTime,
896 pTempScanReq->maxChnTime,
897 pTempScanReq->minChnTimeBtc,
898 pTempScanReq->maxChnTimeBtc );
Jeff Johnson295189b2012-06-20 16:38:30 -0700899 //Start process the command
900#ifdef WLAN_AP_STA_CONCURRENCY
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +0530901 if (!pMac->fScanOffload)
902 status = csrQueueScanRequest(pMac,pScanCmd);
903 else
904 status = csrQueueSmeCommand(pMac, pScanCmd,
905 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700906#else
Vinay Krishna Eranna636b7bc2013-12-18 20:49:08 +0530907 status = csrQueueSmeCommand(pMac, pScanCmd,
908 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700909#endif
910 if( !HAL_STATUS_SUCCESS( status ) )
911 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800912 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -0700913 break;
914 }
915 }
916 else
917 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800918 smsLog( pMac, LOGE, FL(" fail to copy request status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -0700919 break;
920 }
921 }
922 else
923 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800924 smsLog( pMac, LOGE, FL(" pScanCmd is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700925 break;
926 }
927 }
Vinay Krishna Eranna636b7bc2013-12-18 20:49:08 +0530928 else
929 {
930 smsLog( pMac, LOGE, FL("SId: %d Scanning not enabled"
931 " Scan type=%u, numOfSSIDs=%d P2P search=%d"),
932 sessionId, pScanRequest->requestType,
933 pScanRequest->SSIDs.numOfSSIDs,
934 pScanRequest->p2pSearch );
935 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700936 } while(0);
Vinay Krishna Eranna636b7bc2013-12-18 20:49:08 +0530937
938
Jeff Johnson295189b2012-06-20 16:38:30 -0700939 if(!HAL_STATUS_SUCCESS(status) && pScanCmd)
940 {
941 if( eCsrScanIdleScan == pScanCmd->u.scanCmd.reason )
942 {
943 //Set the flag back for restarting idle scan
944 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE;
945 }
Vinay Krishna Eranna636b7bc2013-12-18 20:49:08 +0530946 smsLog( pMac, LOGE, FL(" SId: %d Failed with status=%d"
947 " Scan reason=%u numOfSSIDs=%d"
948 " P2P search=%d scanId=%d"),
949 sessionId, status, pScanCmd->u.scanCmd.reason,
950 pScanRequest->SSIDs.numOfSSIDs, pScanRequest->p2pSearch,
951 pScanCmd->u.scanCmd.scanID );
Jeff Johnson295189b2012-06-20 16:38:30 -0700952 csrReleaseCommandScan(pMac, pScanCmd);
953 }
954
955 return (status);
956}
957
958
959eHalStatus csrScanRequestResult(tpAniSirGlobal pMac)
960{
961 eHalStatus status = eHAL_STATUS_SUCCESS;
962 tSmeCmd *pScanCmd;
963
964 if(pMac->scan.fScanEnable)
965 {
966 pScanCmd = csrGetCommandBuffer(pMac);
967 if(pScanCmd)
968 {
969 pScanCmd->command = eSmeCommandScan;
Kiet Lam64c1b492013-07-12 13:56:44 +0530970 vos_mem_set(&pScanCmd->u.scanCmd, sizeof(tScanCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700971 pScanCmd->u.scanCmd.callback = NULL;
972 pScanCmd->u.scanCmd.pContext = NULL;
973 pScanCmd->u.scanCmd.reason = eCsrScanGetResult;
974 //Need to make the following atomic
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -0700975 pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID; //let it wrap around
Jeff Johnson295189b2012-06-20 16:38:30 -0700976 status = csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_FALSE);
977 if( !HAL_STATUS_SUCCESS( status ) )
978 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800979 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -0700980 csrReleaseCommandScan(pMac, pScanCmd);
981 }
982 }
983 else
984 {
985 //log error
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800986 smsLog(pMac, LOGE, FL("can not obtain a common buffer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700987 status = eHAL_STATUS_RESOURCES;
988 }
989 }
990
991 return (status);
992}
993
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700994#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
995eHalStatus csrScanRequestLfrResult(tpAniSirGlobal pMac, tANI_U32 sessionId,
996 csrScanCompleteCallback callback, void *pContext)
997{
998 eHalStatus status = eHAL_STATUS_SUCCESS;
999 tSmeCmd *pScanCmd;
1000
1001 if (pMac->scan.fScanEnable)
1002 {
1003 pScanCmd = csrGetCommandBuffer(pMac);
1004 if (pScanCmd)
1005 {
1006 pScanCmd->command = eSmeCommandScan;
1007 pScanCmd->sessionId = sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +05301008 vos_mem_set(&pScanCmd->u.scanCmd, sizeof(tScanCmd), 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001009 pScanCmd->u.scanCmd.callback = callback;
1010 pScanCmd->u.scanCmd.pContext = pContext;
1011 pScanCmd->u.scanCmd.reason = eCsrScanGetLfrResult;
1012 //Need to make the following atomic
1013 pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID; //let it wrap around
1014 status = csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_TRUE);
1015 if ( !HAL_STATUS_SUCCESS( status ) )
1016 {
1017 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
1018 csrReleaseCommandScan(pMac, pScanCmd);
1019 }
1020 }
1021 else
1022 {
1023 //log error
1024 smsLog(pMac, LOGE, FL("can not obtain a common buffer\n"));
1025 status = eHAL_STATUS_RESOURCES;
1026 }
1027 }
1028
1029 return (status);
1030}
1031#endif //WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Jeff Johnson295189b2012-06-20 16:38:30 -07001032
1033eHalStatus csrScanAllChannels(tpAniSirGlobal pMac, eCsrRequestType reqType)
1034{
1035 eHalStatus status = eHAL_STATUS_SUCCESS;
1036 tANI_U32 scanId;
1037 tCsrScanRequest scanReq;
1038
Kiet Lam64c1b492013-07-12 13:56:44 +05301039 vos_mem_set(&scanReq, sizeof(tCsrScanRequest), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001040 scanReq.BSSType = eCSR_BSS_TYPE_ANY;
1041 scanReq.scanType = eSIR_ACTIVE_SCAN;
1042 scanReq.requestType = reqType;
1043 scanReq.maxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1044 scanReq.minChnTime = pMac->roam.configParam.nActiveMinChnTime;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001045 scanReq.maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
1046 scanReq.minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001047 //Scan with invalid sessionId.
1048 //This results in SME using the first available session to scan.
1049 status = csrScanRequest(pMac, CSR_SESSION_ID_INVALID, &scanReq,
1050 &scanId, NULL, NULL);
1051
1052 return (status);
1053}
1054
1055
1056
1057
1058eHalStatus csrIssueRoamAfterLostlinkScan(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamReason reason)
1059{
1060 eHalStatus status = eHAL_STATUS_FAILURE;
1061 tScanResultHandle hBSSList = NULL;
1062 tCsrScanResultFilter *pScanFilter = NULL;
1063 tANI_U32 roamId = 0;
1064 tCsrRoamProfile *pProfile = NULL;
1065 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
1066
Jeff Johnson32d95a32012-09-10 13:15:23 -07001067 if(!pSession)
1068 {
1069 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
1070 return eHAL_STATUS_FAILURE;
1071 }
1072
Jeff Johnson295189b2012-06-20 16:38:30 -07001073 do
1074 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001075 smsLog(pMac, LOG1, " csrIssueRoamAfterLostlinkScan called");
Jeff Johnson295189b2012-06-20 16:38:30 -07001076 if(pSession->fCancelRoaming)
1077 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001078 smsLog(pMac, LOGW, " lostlink roaming is cancelled");
Jeff Johnson295189b2012-06-20 16:38:30 -07001079 csrScanStartIdleScan(pMac);
1080 status = eHAL_STATUS_SUCCESS;
1081 break;
1082 }
1083 //Here is the profile we need to connect to
Kiet Lam64c1b492013-07-12 13:56:44 +05301084 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
1085 if ( NULL == pScanFilter)
1086 status = eHAL_STATUS_FAILURE;
1087 else
1088 status = eHAL_STATUS_SUCCESS;
1089 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07001090 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05301091 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001092 if(NULL == pSession->pCurRoamProfile)
1093 {
1094 pScanFilter->EncryptionType.numEntries = 1;
1095 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
1096 }
1097 else
1098 {
1099 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
Kiet Lam64c1b492013-07-12 13:56:44 +05301100 pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
1101 if ( NULL == pProfile )
1102 status = eHAL_STATUS_FAILURE;
1103 else
1104 status = eHAL_STATUS_SUCCESS;
1105 if (!HAL_STATUS_SUCCESS(status))
1106 break;
1107 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001108 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
1109 if(!HAL_STATUS_SUCCESS(status))
1110 break;
1111 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
1112 }//We have a profile
1113 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
1114 if(HAL_STATUS_SUCCESS(status))
1115 {
1116 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
1117 if(HAL_STATUS_SUCCESS(status))
1118 {
1119 if(eCsrLostLink1 == reason)
1120 {
1121 //we want to put the last connected BSS to the very beginning, if possible
1122 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
1123 }
1124 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, reason,
1125 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE);
1126 if(!HAL_STATUS_SUCCESS(status))
1127 {
1128 csrScanResultPurge(pMac, hBSSList);
1129 }
1130 }//Have scan result
1131 }
1132 }while(0);
1133 if(pScanFilter)
1134 {
1135 //we need to free memory for filter if profile exists
1136 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05301137 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001138 }
1139 if(NULL != pProfile)
1140 {
1141 csrReleaseProfile(pMac, pProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05301142 vos_mem_free(pProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07001143 }
1144
1145 return (status);
1146}
1147
1148
Madan Mohan Koyyalamudide1b5bc2013-07-12 00:56:04 +05301149eHalStatus csrScanGetScanChnInfo(tpAniSirGlobal pMac, tANI_U8 sessionId,
1150 void *pContext, void *callback)
Jeff Johnson295189b2012-06-20 16:38:30 -07001151{
1152 eHalStatus status = eHAL_STATUS_SUCCESS;
1153 tSmeCmd *pScanCmd;
1154
1155 if(pMac->scan.fScanEnable)
1156 {
1157 pScanCmd = csrGetCommandBuffer(pMac);
1158 if(pScanCmd)
1159 {
1160 pScanCmd->command = eSmeCommandScan;
Kiet Lam64c1b492013-07-12 13:56:44 +05301161 vos_mem_set(&pScanCmd->u.scanCmd, sizeof(tScanCmd), 0);
Jeff Johnson32d95a32012-09-10 13:15:23 -07001162 pScanCmd->u.scanCmd.callback = callback;
1163 pScanCmd->u.scanCmd.pContext = pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07001164 pScanCmd->u.scanCmd.reason = eCsrScanGetScanChnInfo;
1165 //Need to make the following atomic
1166 pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around
Madan Mohan Koyyalamudide1b5bc2013-07-12 00:56:04 +05301167 pScanCmd->sessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07001168 status = csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_FALSE);
1169 if( !HAL_STATUS_SUCCESS( status ) )
1170 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001171 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07001172 csrReleaseCommandScan(pMac, pScanCmd);
1173 }
1174 }
1175 else
1176 {
1177 //log error
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001178 smsLog(pMac, LOGE, FL("can not obtain a common buffer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001179 status = eHAL_STATUS_RESOURCES;
1180 }
1181 }
1182
1183 return (status);
1184}
1185
1186
1187eHalStatus csrScanHandleFailedLostlink1(tpAniSirGlobal pMac, tANI_U32 sessionId)
1188{
1189 eHalStatus status = eHAL_STATUS_FAILURE;
1190 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
1191
Jeff Johnson32d95a32012-09-10 13:15:23 -07001192 if(!pSession)
1193 {
1194 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
1195 return eHAL_STATUS_FAILURE;
1196 }
1197
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001198 smsLog(pMac, LOGW, " Lostlink scan 1 failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07001199 if(pSession->fCancelRoaming)
1200 {
1201 csrScanStartIdleScan(pMac);
1202 }
1203 else if(pSession->pCurRoamProfile)
1204 {
1205 //We fail lostlink1 but there may be other BSS in the cached result fit the profile. Give it a try first
1206 if(pSession->pCurRoamProfile->SSIDs.numOfSSIDs == 0 ||
1207 pSession->pCurRoamProfile->SSIDs.numOfSSIDs > 1)
1208 {
1209 //try lostlink scan2
1210 status = csrScanRequestLostLink2(pMac, sessionId);
1211 }
1212 else if(!pSession->pCurRoamProfile->ChannelInfo.ChannelList ||
1213 pSession->pCurRoamProfile->ChannelInfo.ChannelList[0] == 0)
1214 {
1215 //go straight to lostlink scan3
1216 status = csrScanRequestLostLink3(pMac, sessionId);
1217 }
1218 else
1219 {
1220 //we are done with lostlink
1221 if(csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_FALSE, eCSR_ROAM_RESULT_FAILURE))
1222 {
1223 csrScanStartIdleScan(pMac);
1224 }
1225 status = eHAL_STATUS_SUCCESS;
1226 }
1227 }
1228 else
1229 {
1230 status = csrScanRequestLostLink3(pMac, sessionId);
1231 }
1232
1233 return (status);
1234}
1235
1236
1237
1238eHalStatus csrScanHandleFailedLostlink2(tpAniSirGlobal pMac, tANI_U32 sessionId)
1239{
1240 eHalStatus status = eHAL_STATUS_FAILURE;
1241 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
1242
Jeff Johnson32d95a32012-09-10 13:15:23 -07001243 if(!pSession)
1244 {
1245 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
1246 return eHAL_STATUS_FAILURE;
1247 }
1248
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001249 smsLog(pMac, LOGW, " Lostlink scan 2 failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07001250 if(pSession->fCancelRoaming)
1251 {
1252 csrScanStartIdleScan(pMac);
1253 }
1254 else if(!pSession->pCurRoamProfile || !pSession->pCurRoamProfile->ChannelInfo.ChannelList ||
1255 pSession->pCurRoamProfile->ChannelInfo.ChannelList[0] == 0)
1256 {
1257 //try lostlink scan3
1258 status = csrScanRequestLostLink3(pMac, sessionId);
1259 }
1260 else
1261 {
1262 //we are done with lostlink
1263 if(csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_FALSE, eCSR_ROAM_RESULT_FAILURE))
1264 {
1265 csrScanStartIdleScan(pMac);
1266 }
1267 }
1268
1269 return (status);
1270}
1271
1272
1273
1274eHalStatus csrScanHandleFailedLostlink3(tpAniSirGlobal pMac, tANI_U32 sessionId)
1275{
1276 eHalStatus status = eHAL_STATUS_SUCCESS;
1277
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001278 smsLog(pMac, LOGW, " Lostlink scan 3 failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07001279 if(eANI_BOOLEAN_TRUE == csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_FALSE, eCSR_ROAM_RESULT_FAILURE))
1280 {
1281 //we are done with lostlink
1282 csrScanStartIdleScan(pMac);
1283 }
1284
1285 return (status);
1286}
1287
1288
1289
1290
1291//Lostlink1 scan is to actively scan the last connected profile's SSID on all matched BSS channels.
1292//If no roam profile (it should not), it is like lostlinkscan3
1293eHalStatus csrScanRequestLostLink1( tpAniSirGlobal pMac, tANI_U32 sessionId )
1294{
1295 eHalStatus status = eHAL_STATUS_SUCCESS;
1296 tSmeCmd *pCommand = NULL;
1297 tANI_U8 bAddr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
1298 tCsrScanResultFilter *pScanFilter = NULL;
1299 tScanResultHandle hBSSList = NULL;
1300 tCsrScanResultInfo *pScanResult = NULL;
1301 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
1302
Jeff Johnson32d95a32012-09-10 13:15:23 -07001303 if(!pSession)
1304 {
1305 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
1306 return eHAL_STATUS_FAILURE;
1307 }
1308
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001309 smsLog(pMac, LOGW, FL(" called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001310 do
1311 {
1312 pCommand = csrGetCommandBuffer(pMac);
1313 if(!pCommand)
1314 {
1315 status = eHAL_STATUS_RESOURCES;
1316 break;
1317 }
Kiet Lam64c1b492013-07-12 13:56:44 +05301318 vos_mem_set(&pCommand->u.scanCmd, sizeof(tScanCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001319 pCommand->command = eSmeCommandScan;
1320 pCommand->sessionId = (tANI_U8)sessionId;
1321 pCommand->u.scanCmd.reason = eCsrScanLostLink1;
1322 pCommand->u.scanCmd.callback = NULL;
1323 pCommand->u.scanCmd.pContext = NULL;
1324 pCommand->u.scanCmd.u.scanRequest.maxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1325 pCommand->u.scanCmd.u.scanRequest.minChnTime = pMac->roam.configParam.nActiveMinChnTime;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001326 pCommand->u.scanCmd.u.scanRequest.maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
1327 pCommand->u.scanCmd.u.scanRequest.minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001328 pCommand->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN;
1329 if(pSession->connectedProfile.SSID.length)
1330 {
Kiet Lam64c1b492013-07-12 13:56:44 +05301331 pCommand->u.scanCmd.u.scanRequest.SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
1332 if ( NULL == pCommand->u.scanCmd.u.scanRequest.SSIDs.SSIDList )
1333 status = eHAL_STATUS_FAILURE;
1334 else
1335 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001336 if(!HAL_STATUS_SUCCESS(status))
1337 {
1338 break;
1339 }
1340 pCommand->u.scanCmd.u.scanRequest.SSIDs.numOfSSIDs = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05301341 vos_mem_copy(&pCommand->u.scanCmd.u.scanRequest.SSIDs.SSIDList[0].SSID,
1342 &pSession->connectedProfile.SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07001343 }
1344 else
1345 {
1346 pCommand->u.scanCmd.u.scanRequest.SSIDs.numOfSSIDs = 0;
1347 }
1348 if(pSession->pCurRoamProfile)
1349 {
Kiet Lam64c1b492013-07-12 13:56:44 +05301350 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
1351 if ( NULL == pScanFilter )
1352 status = eHAL_STATUS_FAILURE;
1353 else
1354 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001355 if(!HAL_STATUS_SUCCESS(status))
1356 {
1357 break;
1358 }
Kiet Lam64c1b492013-07-12 13:56:44 +05301359 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001360 status = csrRoamPrepareFilterFromProfile(pMac, pSession->pCurRoamProfile, pScanFilter);
1361 if(!HAL_STATUS_SUCCESS(status))
1362 {
1363 break;
1364 }
1365 //Don't change variable status here because whether we can get result or not, the command goes to PE.
1366 //The status is also used to indicate whether the command is queued. Not success meaning not queue
1367 if(HAL_STATUS_SUCCESS((csrScanGetResult(pMac, pScanFilter, &hBSSList))) && hBSSList)
1368 {
1369 tANI_U8 i, nChn = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05301370 pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList =
1371 vos_mem_malloc(WNI_CFG_VALID_CHANNEL_LIST_LEN);
1372 if ( NULL == pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList )
1373 status = eHAL_STATUS_FAILURE;
1374 else
1375 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001376 if(!HAL_STATUS_SUCCESS(status))
1377 {
1378 break;
1379 }
1380 while(((pScanResult = csrScanResultGetNext(pMac, hBSSList)) != NULL) &&
1381 nChn < WNI_CFG_VALID_CHANNEL_LIST_LEN)
1382 {
1383 for(i = 0; i < nChn; i++)
1384 {
1385 if(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[i] ==
1386 pScanResult->BssDescriptor.channelId)
1387 {
1388 break;
1389 }
1390 }
1391 if(i == nChn)
1392 {
1393 pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[nChn++] = pScanResult->BssDescriptor.channelId;
1394 }
1395 }
1396 //Include the last connected BSS' channel
1397 if(csrRoamIsChannelValid(pMac, pSession->connectedProfile.operationChannel))
1398 {
1399 for(i = 0; i < nChn; i++)
1400 {
1401 if(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[i] ==
1402 pSession->connectedProfile.operationChannel)
1403 {
1404 break;
1405 }
1406 }
1407 if(i == nChn)
1408 {
1409 pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[nChn++] = pSession->connectedProfile.operationChannel;
1410 }
1411 }
1412 pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = nChn;
1413 }
1414 else
1415 {
1416 if(csrRoamIsChannelValid(pMac, pSession->connectedProfile.operationChannel))
1417 {
Kiet Lam64c1b492013-07-12 13:56:44 +05301418 pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = vos_mem_malloc(1);
1419 if ( NULL == pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList )
1420 status = eHAL_STATUS_FAILURE;
1421 else
1422 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001423 //just try the last connected channel
1424 if(HAL_STATUS_SUCCESS(status))
1425 {
1426 pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[0] = pSession->connectedProfile.operationChannel;
1427 pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = 1;
1428 }
1429 else
1430 {
1431 break;
1432 }
1433 }
1434 }
1435 }
Kiet Lam64c1b492013-07-12 13:56:44 +05301436 vos_mem_copy(&pCommand->u.scanCmd.u.scanRequest.bssid, bAddr, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07001437 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
1438 if( !HAL_STATUS_SUCCESS( status ) )
1439 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001440 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07001441 break;
1442 }
1443 } while( 0 );
1444
1445 if(!HAL_STATUS_SUCCESS(status))
1446 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001447 smsLog(pMac, LOGW, " csrScanRequestLostLink1 failed with status %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001448 if(pCommand)
1449 {
1450 csrReleaseCommandScan(pMac, pCommand);
1451 }
1452 status = csrScanHandleFailedLostlink1( pMac, sessionId );
1453 }
1454 if(pScanFilter)
1455 {
1456 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05301457 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001458 }
1459 if(hBSSList)
1460 {
1461 csrScanResultPurge(pMac, hBSSList);
1462 }
1463
1464 return( status );
1465}
1466
1467
1468//Lostlink2 scan is to actively scan the all SSIDs of the last roaming profile's on all matched BSS channels.
1469//Since MAC doesn't support multiple SSID, we scan all SSIDs and filter them afterwards
1470eHalStatus csrScanRequestLostLink2( tpAniSirGlobal pMac, tANI_U32 sessionId )
1471{
1472 eHalStatus status = eHAL_STATUS_SUCCESS;
1473 tANI_U8 bAddr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
1474 tCsrScanResultFilter *pScanFilter = NULL;
1475 tScanResultHandle hBSSList = NULL;
1476 tCsrScanResultInfo *pScanResult = NULL;
1477 tSmeCmd *pCommand = NULL;
1478 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
1479
Jeff Johnson32d95a32012-09-10 13:15:23 -07001480 if(!pSession)
1481 {
1482 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
1483 return eHAL_STATUS_FAILURE;
1484 }
1485
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001486 smsLog(pMac, LOGW, FL(" called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001487 do
1488 {
1489 pCommand = csrGetCommandBuffer(pMac);
1490 if(!pCommand)
1491 {
1492 status = eHAL_STATUS_RESOURCES;
1493 break;
1494 }
Kiet Lam64c1b492013-07-12 13:56:44 +05301495 vos_mem_set(&pCommand->u.scanCmd, sizeof(tScanCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001496 pCommand->command = eSmeCommandScan;
1497 pCommand->sessionId = (tANI_U8)sessionId;
1498 pCommand->u.scanCmd.reason = eCsrScanLostLink2;
1499 pCommand->u.scanCmd.callback = NULL;
1500 pCommand->u.scanCmd.pContext = NULL;
1501 pCommand->u.scanCmd.u.scanRequest.maxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1502 pCommand->u.scanCmd.u.scanRequest.minChnTime = pMac->roam.configParam.nActiveMinChnTime;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001503 pCommand->u.scanCmd.u.scanRequest.maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
1504 pCommand->u.scanCmd.u.scanRequest.minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001505 pCommand->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN;
1506 if(pSession->pCurRoamProfile)
1507 {
Kiet Lam64c1b492013-07-12 13:56:44 +05301508 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
1509 if ( NULL == pScanFilter )
1510 status = eHAL_STATUS_FAILURE;
1511 else
1512 status = eHAL_STATUS_SUCCESS;
1513 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07001514 {
1515 break;
1516 }
Kiet Lam64c1b492013-07-12 13:56:44 +05301517 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001518 status = csrRoamPrepareFilterFromProfile(pMac, pSession->pCurRoamProfile, pScanFilter);
1519 if(!HAL_STATUS_SUCCESS(status))
1520 {
1521 break;
1522 }
1523 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
1524 if(!HAL_STATUS_SUCCESS(status))
1525 {
1526 break;
1527 }
1528 if(hBSSList)
1529 {
1530 tANI_U8 i, nChn = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05301531 pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList =
1532 vos_mem_malloc(WNI_CFG_VALID_CHANNEL_LIST_LEN);
1533 if ( NULL == pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList )
1534 status = eHAL_STATUS_FAILURE;
1535 else
1536 status = eHAL_STATUS_SUCCESS;
1537 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07001538 {
1539 break;
1540 }
1541 while(((pScanResult = csrScanResultGetNext(pMac, hBSSList)) != NULL) &&
1542 nChn < WNI_CFG_VALID_CHANNEL_LIST_LEN)
1543 {
1544 for(i = 0; i < nChn; i++)
1545 {
1546 if(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[i] ==
1547 pScanResult->BssDescriptor.channelId)
1548 {
1549 break;
1550 }
1551 }
1552 if(i == nChn)
1553 {
1554 pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[nChn++] = pScanResult->BssDescriptor.channelId;
1555 }
1556 }
1557 pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = nChn;
1558 }
1559 }
Kiet Lam64c1b492013-07-12 13:56:44 +05301560 vos_mem_copy(&pCommand->u.scanCmd.u.scanRequest.bssid, bAddr, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07001561 //Put to the head in pending queue
1562 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
1563 if( !HAL_STATUS_SUCCESS( status ) )
1564 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001565 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07001566 break;
1567 }
1568 } while( 0 );
1569
1570 if(!HAL_STATUS_SUCCESS(status))
1571 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001572 smsLog(pMac, LOGW, " csrScanRequestLostLink2 failed with status %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001573 if(pCommand)
1574 {
1575 csrReleaseCommandScan(pMac, pCommand);
1576 }
1577 status = csrScanHandleFailedLostlink2( pMac, sessionId );
1578 }
1579 if(pScanFilter)
1580 {
1581 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05301582 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001583 }
1584 if(hBSSList)
1585 {
1586 csrScanResultPurge(pMac, hBSSList);
1587 }
1588
1589 return( status );
1590}
1591
1592
1593//To actively scan all valid channels
1594eHalStatus csrScanRequestLostLink3( tpAniSirGlobal pMac, tANI_U32 sessionId )
1595{
1596 eHalStatus status = eHAL_STATUS_SUCCESS;
1597 tSmeCmd *pCommand;
1598 tANI_U8 bAddr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
1599
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001600 smsLog(pMac, LOGW, FL(" called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001601 do
1602 {
1603 pCommand = csrGetCommandBuffer(pMac);
1604 if(!pCommand)
1605 {
1606 status = eHAL_STATUS_RESOURCES;
1607 break;
1608 }
Kiet Lam64c1b492013-07-12 13:56:44 +05301609 vos_mem_set(&pCommand->u.scanCmd, sizeof(tScanCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001610 pCommand->command = eSmeCommandScan;
1611 pCommand->sessionId = (tANI_U8)sessionId;
1612 pCommand->u.scanCmd.reason = eCsrScanLostLink3;
1613 pCommand->u.scanCmd.callback = NULL;
1614 pCommand->u.scanCmd.pContext = NULL;
1615 pCommand->u.scanCmd.u.scanRequest.maxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1616 pCommand->u.scanCmd.u.scanRequest.minChnTime = pMac->roam.configParam.nActiveMinChnTime;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001617 pCommand->u.scanCmd.u.scanRequest.maxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
1618 pCommand->u.scanCmd.u.scanRequest.minChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001619 pCommand->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN;
Kiet Lam64c1b492013-07-12 13:56:44 +05301620 vos_mem_copy(&pCommand->u.scanCmd.u.scanRequest.bssid, bAddr, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07001621 //Put to the head of pending queue
1622 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
1623 if( !HAL_STATUS_SUCCESS( status ) )
1624 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001625 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07001626 break;
1627 }
1628 } while( 0 );
1629 if(!HAL_STATUS_SUCCESS(status))
1630 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001631 smsLog(pMac, LOGW, " csrScanRequestLostLink3 failed with status %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001632 if(csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_FALSE, eCSR_ROAM_RESULT_FAILURE))
1633 {
1634 csrScanStartIdleScan(pMac);
1635 }
1636 if(pCommand)
1637 {
1638 csrReleaseCommandScan(pMac, pCommand);
1639 }
1640 }
1641
1642 return( status );
1643}
1644
1645
1646eHalStatus csrScanHandleSearchForSSID(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1647{
1648 eHalStatus status = eHAL_STATUS_FAILURE;
1649 tScanResultHandle hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
1650 tCsrScanResultFilter *pScanFilter = NULL;
1651 tCsrRoamProfile *pProfile = pCommand->u.scanCmd.pToRoamProfile;
1652 tANI_U32 sessionId = pCommand->sessionId;
1653#ifdef FEATURE_WLAN_BTAMP_UT_RF
1654 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
1655#endif
1656 do
1657 {
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07001658#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1659 //if this scan is for LFR
1660 if(pMac->roam.neighborRoamInfo.uOsRequestedHandoff)
1661 {
1662 //notify LFR state m/c
1663 if(eHAL_STATUS_SUCCESS != csrNeighborRoamSssidScanDone(pMac, eHAL_STATUS_SUCCESS))
1664 {
Varun Reddy Yeturue3af4282013-06-07 00:56:52 -07001665 csrNeighborRoamStartLfrScan(pMac);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07001666 }
1667 status = eHAL_STATUS_SUCCESS;
1668 break;
1669 }
1670#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001671 //If there is roam command waiting, ignore this roam because the newer roam command is the one to execute
1672 if(csrIsRoamCommandWaitingForSession(pMac, sessionId))
1673 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001674 smsLog(pMac, LOGW, FL(" aborts because roam command waiting"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001675 break;
1676 }
1677 if(pProfile == NULL)
1678 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05301679 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
1680 if ( NULL == pScanFilter )
1681 status = eHAL_STATUS_FAILURE;
1682 else
1683 status = eHAL_STATUS_SUCCESS;
1684 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07001685 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05301686 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001687 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
1688 if(!HAL_STATUS_SUCCESS(status))
1689 break;
1690 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
1691 if(!HAL_STATUS_SUCCESS(status))
1692 break;
1693 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
1694 pCommand->u.scanCmd.roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE);
1695 if(!HAL_STATUS_SUCCESS(status))
1696 {
1697 break;
1698 }
1699 }while(0);
1700 if(!HAL_STATUS_SUCCESS(status))
1701 {
1702 if(CSR_INVALID_SCANRESULT_HANDLE != hBSSList)
1703 {
1704 csrScanResultPurge(pMac, hBSSList);
1705 }
1706 //We haven't done anything to this profile
1707 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.scanCmd.roamId,
1708 eCSR_ROAM_ASSOCIATION_FAILURE, eCSR_ROAM_RESULT_FAILURE);
1709 //In case we have nothing else to do, restart idle scan
1710 if(csrIsConnStateDisconnected(pMac, sessionId) && !csrIsRoamCommandWaiting(pMac))
1711 {
1712 status = csrScanStartIdleScan(pMac);
1713 }
1714#ifdef FEATURE_WLAN_BTAMP_UT_RF
1715 //In case of WDS station, let it retry.
1716 if( CSR_IS_WDS_STA(pProfile) )
1717 {
1718 //Save the roma profile so we can retry
1719 csrFreeRoamProfile( pMac, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05301720 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
1721 if ( NULL != pSession->pCurRoamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07001722 {
Kiet Lam64c1b492013-07-12 13:56:44 +05301723 vos_mem_set(pSession->pCurRoamProfilee, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001724 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
1725 }
1726 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
1727 }
1728#endif
1729 }
Kiet Lam64c1b492013-07-12 13:56:44 +05301730 if (pScanFilter)
Jeff Johnson295189b2012-06-20 16:38:30 -07001731 {
1732 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05301733 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001734 }
1735
1736 return (status);
1737}
1738
1739
1740eHalStatus csrScanHandleSearchForSSIDFailure(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1741{
1742 eHalStatus status = eHAL_STATUS_SUCCESS;
1743 tANI_U32 sessionId = pCommand->sessionId;
1744 tCsrRoamProfile *pProfile = pCommand->u.scanCmd.pToRoamProfile;
1745 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07001746#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1747 //if this scan is for LFR
1748 if(pMac->roam.neighborRoamInfo.uOsRequestedHandoff)
1749 {
1750 //notify LFR state m/c
1751 if(eHAL_STATUS_SUCCESS != csrNeighborRoamSssidScanDone(pMac, eHAL_STATUS_FAILURE))
1752 {
Varun Reddy Yeturue3af4282013-06-07 00:56:52 -07001753 csrNeighborRoamStartLfrScan(pMac);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07001754 }
1755 return eHAL_STATUS_SUCCESS;
1756 }
1757#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07001758 if(!pSession)
1759 {
1760 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
1761 return eHAL_STATUS_FAILURE;
1762 }
1763
Jeff Johnson295189b2012-06-20 16:38:30 -07001764#if defined(WLAN_DEBUG)
1765 if(pCommand->u.scanCmd.u.scanRequest.SSIDs.numOfSSIDs == 1)
1766 {
1767 char str[36];
Kiet Lam64c1b492013-07-12 13:56:44 +05301768 vos_mem_copy(str,
1769 pCommand->u.scanCmd.u.scanRequest.SSIDs.SSIDList[0].SSID.ssId,
1770 pCommand->u.scanCmd.u.scanRequest.SSIDs.SSIDList[0].SSID.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07001771 str[pCommand->u.scanCmd.u.scanRequest.SSIDs.SSIDList[0].SSID.length] = 0;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001772 smsLog(pMac, LOGW, FL(" SSID = %s"), str);
Jeff Johnson295189b2012-06-20 16:38:30 -07001773 }
1774#endif
1775 //Check whether it is for start ibss. No need to do anything if it is a JOIN request
1776 if(pProfile && CSR_IS_START_IBSS(pProfile))
1777 {
1778 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
1779 pCommand->u.scanCmd.roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE);
1780 if(!HAL_STATUS_SUCCESS(status))
1781 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001782 smsLog(pMac, LOGE, FL("failed to issue startIBSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001783 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.scanCmd.roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
1784 }
1785 }
1786 else
1787 {
1788 eCsrRoamResult roamResult = eCSR_ROAM_RESULT_FAILURE;
1789
1790 if(csrIsConnStateDisconnected(pMac, sessionId) &&
1791 !csrIsRoamCommandWaitingForSession(pMac, sessionId))
1792 {
1793 status = csrScanStartIdleScan(pMac);
1794 }
1795 if((NULL == pProfile) || !csrIsBssTypeIBSS(pProfile->BSSType))
1796 {
1797 //Only indicate assoc_completion if we indicate assoc_start.
1798 if(pSession->bRefAssocStartCnt > 0)
1799 {
1800 tCsrRoamInfo *pRoamInfo = NULL, roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05301801 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001802 pRoamInfo = &roamInfo;
1803 if(pCommand->u.roamCmd.pRoamBssEntry)
1804 {
1805 tCsrScanResult *pScanResult =
1806 GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry,
1807 tCsrScanResult, Link);
1808 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
1809 }
1810 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
1811 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
1812 pSession->bRefAssocStartCnt--;
1813 csrRoamCallCallback(pMac, sessionId, pRoamInfo,
1814 pCommand->u.scanCmd.roamId,
1815 eCSR_ROAM_ASSOCIATION_COMPLETION,
1816 eCSR_ROAM_RESULT_FAILURE);
1817 }
Madan Mohan Koyyalamudiee255f12012-09-28 15:41:19 -07001818 else
1819 {
1820 csrRoamCallCallback(pMac, sessionId, NULL,
1821 pCommand->u.scanCmd.roamId,
1822 eCSR_ROAM_ASSOCIATION_FAILURE,
1823 eCSR_ROAM_RESULT_FAILURE);
1824 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001825#ifdef FEATURE_WLAN_BTAMP_UT_RF
1826 //In case of WDS station, let it retry.
1827 if( CSR_IS_WDS_STA(pProfile) )
1828 {
1829 //Save the roma profile so we can retry
1830 csrFreeRoamProfile( pMac, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05301831 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
1832 if ( NULL != pSession->pCurRoamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07001833 {
Kiet Lam64c1b492013-07-12 13:56:44 +05301834 vos_mem_set(pSession->pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001835 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
1836 }
1837 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
1838 }
1839#endif
1840 }
1841 else
1842 {
1843 roamResult = eCSR_ROAM_RESULT_IBSS_START_FAILED;
1844 }
1845 csrRoamCompletion(pMac, sessionId, NULL, pCommand, roamResult, eANI_BOOLEAN_FALSE);
1846 }
1847
1848 return (status);
1849}
1850
1851
1852//After scan for cap changes, issue a roaming command to either reconnect to the AP or pick another one to connect
1853eHalStatus csrScanHandleCapChangeScanComplete(tpAniSirGlobal pMac, tANI_U32 sessionId)
1854{
1855 eHalStatus status = eHAL_STATUS_FAILURE;
1856 tScanResultHandle hBSSList = NULL;
1857 tCsrScanResultFilter *pScanFilter = NULL;
1858 tANI_U32 roamId = 0;
1859 tCsrRoamProfile *pProfile = NULL;
1860 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
1861
1862 do
1863 {
1864 //Here is the profile we need to connect to
Kiet Lam64c1b492013-07-12 13:56:44 +05301865 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
1866 if ( NULL == pScanFilter )
1867 status = eHAL_STATUS_FAILURE;
1868 else
1869 status = eHAL_STATUS_SUCCESS;
1870 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07001871 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05301872 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
1873 if (NULL == pSession) break;
1874 if (NULL == pSession->pCurRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07001875 {
1876 pScanFilter->EncryptionType.numEntries = 1;
1877 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
1878 }
1879 else
1880 {
1881 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
Kiet Lam64c1b492013-07-12 13:56:44 +05301882 pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
1883 if ( NULL == pProfile )
1884 status = eHAL_STATUS_FAILURE;
1885 else
1886 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001887 if(!HAL_STATUS_SUCCESS(status))
1888 break;
1889 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
1890 if(!HAL_STATUS_SUCCESS(status))
1891 break;
1892 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
1893 }//We have a profile
1894 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
1895 if(HAL_STATUS_SUCCESS(status))
1896 {
1897 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
1898 if(HAL_STATUS_SUCCESS(status))
1899 {
1900 //we want to put the last connected BSS to the very beginning, if possible
1901 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
1902 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList,
1903 eCsrCapsChange, 0, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE);
1904 if(!HAL_STATUS_SUCCESS(status))
1905 {
1906 csrScanResultPurge(pMac, hBSSList);
1907 }
1908 }//Have scan result
1909 else
1910 {
Arif Hussaina7c8e412013-11-20 11:06:42 -08001911 smsLog(pMac, LOGW, FL("cannot find matching BSS of "
1912 MAC_ADDRESS_STR),
1913 MAC_ADDR_ARRAY(pSession->connectedProfile.bssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07001914 //Disconnect
1915 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
1916 }
1917 }
1918 }while(0);
1919 if(pScanFilter)
1920 {
1921 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05301922 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001923 }
1924 if(NULL != pProfile)
1925 {
1926 csrReleaseProfile(pMac, pProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05301927 vos_mem_free(pProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07001928 }
1929
1930 return (status);
1931}
1932
1933
1934
1935eHalStatus csrScanResultPurge(tpAniSirGlobal pMac, tScanResultHandle hScanList)
1936{
1937 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
1938 tScanResultList *pScanList = (tScanResultList *)hScanList;
1939
1940 if(pScanList)
1941 {
1942 status = csrLLScanPurgeResult(pMac, &pScanList->List);
1943 csrLLClose(&pScanList->List);
Kiet Lam64c1b492013-07-12 13:56:44 +05301944 vos_mem_free(pScanList);
Jeff Johnson295189b2012-06-20 16:38:30 -07001945 }
1946 return (status);
1947}
1948
1949
1950static tANI_U32 csrGetBssPreferValue(tpAniSirGlobal pMac, int rssi)
1951{
1952 tANI_U32 ret = 0;
1953 int i = CSR_NUM_RSSI_CAT - 1;
1954
1955 while(i >= 0)
1956 {
1957 if(rssi >= pMac->roam.configParam.RSSICat[i])
1958 {
1959 ret = pMac->roam.configParam.BssPreferValue[i];
1960 break;
1961 }
1962 i--;
1963 };
1964
1965 return (ret);
1966}
1967
1968
1969//Return a CapValue base on the capabilities of a BSS
1970static tANI_U32 csrGetBssCapValue(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
1971{
1972 tANI_U32 ret = CSR_BSS_CAP_VALUE_NONE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001973#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001974 if(CSR_IS_ROAM_PREFER_5GHZ(pMac))
1975 {
1976 if((pBssDesc) && CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
1977 {
1978 ret += CSR_BSS_CAP_VALUE_5GHZ;
1979 }
1980 }
1981#endif
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001982 /* if strict select 5GHz is non-zero then ignore the capability checking */
1983 if (pIes && !CSR_IS_SELECT_5GHZ_MARGIN(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07001984 {
1985 //We only care about 11N capability
1986 if(pIes->HTCaps.present)
1987 {
1988 ret += CSR_BSS_CAP_VALUE_HT;
1989 }
1990 if(CSR_IS_QOS_BSS(pIes))
1991 {
1992 ret += CSR_BSS_CAP_VALUE_WMM;
1993 //Give advantage to UAPSD
1994 if(CSR_IS_UAPSD_BSS(pIes))
1995 {
1996 ret += CSR_BSS_CAP_VALUE_UAPSD;
1997 }
1998 }
1999 }
2000
2001 return (ret);
2002}
2003
2004
2005//To check whther pBss1 is better than pBss2
2006static tANI_BOOLEAN csrIsBetterBss(tCsrScanResult *pBss1, tCsrScanResult *pBss2)
2007{
2008 tANI_BOOLEAN ret;
2009
2010 if(CSR_IS_BETTER_PREFER_VALUE(pBss1->preferValue, pBss2->preferValue))
2011 {
2012 ret = eANI_BOOLEAN_TRUE;
2013 }
2014 else if(CSR_IS_EQUAL_PREFER_VALUE(pBss1->preferValue, pBss2->preferValue))
2015 {
2016 if(CSR_IS_BETTER_CAP_VALUE(pBss1->capValue, pBss2->capValue))
2017 {
2018 ret = eANI_BOOLEAN_TRUE;
2019 }
2020 else
2021 {
2022 ret = eANI_BOOLEAN_FALSE;
2023 }
2024 }
2025 else
2026 {
2027 ret = eANI_BOOLEAN_FALSE;
2028 }
2029
2030 return (ret);
2031}
2032
2033
Srikant Kuppa866893f2012-12-27 17:28:14 -08002034#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002035//Add the channel to the occupiedChannels array
2036static void csrScanAddToOccupiedChannels(
Srikant Kuppa866893f2012-12-27 17:28:14 -08002037 tpAniSirGlobal pMac,
2038 tCsrScanResult *pResult,
2039 tCsrChannel *pOccupiedChannels,
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002040 tDot11fBeaconIEs *pIes)
2041{
2042 eHalStatus status;
2043 tANI_U8 channel;
2044 tANI_U8 numOccupiedChannels = pOccupiedChannels->numChannels;
2045 tANI_U8 *pOccupiedChannelList = pOccupiedChannels->channelList;
2046
2047 channel = pResult->Result.BssDescriptor.channelId;
2048
2049 if (!csrIsChannelPresentInList(pOccupiedChannelList, numOccupiedChannels, channel)
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002050 && csrNeighborRoamConnectedProfileMatch(pMac, pResult, pIes))
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002051 {
Srikant Kuppa866893f2012-12-27 17:28:14 -08002052 status = csrAddToChannelListFront(pOccupiedChannelList, numOccupiedChannels, channel);
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002053 if(HAL_STATUS_SUCCESS(status))
Srikant Kuppa866893f2012-12-27 17:28:14 -08002054 {
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002055 pOccupiedChannels->numChannels++;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002056 smsLog(pMac, LOG2, FL("%s: added channel %d to the list (count=%d)"),
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08002057 __func__, channel, pOccupiedChannels->numChannels);
Srikant Kuppa866893f2012-12-27 17:28:14 -08002058 if (pOccupiedChannels->numChannels > CSR_BG_SCAN_OCCUPIED_CHANNEL_LIST_LEN)
2059 pOccupiedChannels->numChannels = CSR_BG_SCAN_OCCUPIED_CHANNEL_LIST_LEN;
2060 }
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002061 }
2062}
2063#endif
2064
Jeff Johnson295189b2012-06-20 16:38:30 -07002065//Put the BSS into the scan result list
2066//pIes can not be NULL
2067static void csrScanAddResult(tpAniSirGlobal pMac, tCsrScanResult *pResult, tDot11fBeaconIEs *pIes)
2068{
Srinivas28b5b4e2012-12-12 13:07:53 -08002069#ifdef FEATURE_WLAN_LFR
2070 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2071#endif
2072
Jeff Johnson295189b2012-06-20 16:38:30 -07002073 pResult->preferValue = csrGetBssPreferValue(pMac, (int)pResult->Result.BssDescriptor.rssi);
2074 pResult->capValue = csrGetBssCapValue(pMac, &pResult->Result.BssDescriptor, pIes);
2075 csrLLInsertTail( &pMac->scan.scanResultList, &pResult->Link, LL_ACCESS_LOCK );
Srikant Kuppa866893f2012-12-27 17:28:14 -08002076#ifdef FEATURE_WLAN_LFR
Srinivas28b5b4e2012-12-12 13:07:53 -08002077 if(0 == pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
2078 {
2079 /* Build the occupied channel list, only if "gNeighborScanChannelList" is
2080 NOT set in the cfg.ini file */
2081 csrScanAddToOccupiedChannels(pMac, pResult, &pMac->scan.occupiedChannels, pIes);
2082 }
Madan Mohan Koyyalamudi470d2cf2012-09-28 14:43:44 -07002083#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002084}
2085
2086
2087eHalStatus csrScanGetResult(tpAniSirGlobal pMac, tCsrScanResultFilter *pFilter, tScanResultHandle *phResult)
2088{
2089 eHalStatus status;
2090 tScanResultList *pRetList;
2091 tCsrScanResult *pResult, *pBssDesc;
2092 tANI_U32 count = 0;
2093 tListElem *pEntry;
2094 tANI_U32 bssLen, allocLen;
2095 eCsrEncryptionType uc = eCSR_ENCRYPT_TYPE_NONE, mc = eCSR_ENCRYPT_TYPE_NONE;
2096 eCsrAuthType auth = eCSR_AUTH_TYPE_OPEN_SYSTEM;
2097 tDot11fBeaconIEs *pIes, *pNewIes;
2098 tANI_BOOLEAN fMatch;
Srinivas Girigowda8e7e1052013-11-13 18:53:14 -08002099 tANI_U16 i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002100
2101 if(phResult)
2102 {
2103 *phResult = CSR_INVALID_SCANRESULT_HANDLE;
2104 }
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07002105
2106 if (pMac->roam.configParam.nSelect5GHzMargin)
2107 {
2108 pMac->scan.inScanResultBestAPRssi = -128;
2109 csrLLLock(&pMac->scan.scanResultList);
2110
2111 /* Find out the best AP Rssi going thru the scan results */
2112 pEntry = csrLLPeekHead(&pMac->scan.scanResultList, LL_ACCESS_NOLOCK);
2113 while ( NULL != pEntry)
2114 {
2115 pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
Srinivas Girigowda8e7e1052013-11-13 18:53:14 -08002116 fMatch = FALSE;
2117
2118 if (pFilter)
2119 for(i = 0; i < pFilter->SSIDs.numOfSSIDs; i++)
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07002120 {
Srinivas Girigowda8e7e1052013-11-13 18:53:14 -08002121 fMatch = csrIsSsidMatch( pMac, pFilter->SSIDs.SSIDList[i].SSID.ssId, pFilter->SSIDs.SSIDList[i].SSID.length,
2122 pBssDesc->Result.ssId.ssId,
2123 pBssDesc->Result.ssId.length, eANI_BOOLEAN_TRUE );
2124 if (fMatch)
2125 {
2126 pIes = (tDot11fBeaconIEs *)( pBssDesc->Result.pvIes );
2127
2128 //At this time, pBssDescription->Result.pvIes may be NULL
2129 if( !pIes && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac,
2130 &pBssDesc->Result.BssDescriptor, &pIes))) )
2131 {
2132 continue;
2133 }
2134
2135 smsLog(pMac, LOG1, FL("SSID Matched"));
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -07002136
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07002137 if ( pFilter->bOSENAssociation )
2138 {
2139 fMatch = TRUE;
2140 }
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -07002141 else
2142 {
2143 fMatch = csrIsSecurityMatch( pMac, &pFilter->authType, &pFilter->EncryptionType, &pFilter->mcEncryptionType,
2144 &pBssDesc->Result.BssDescriptor, pIes, NULL, NULL, NULL );
2145 }
2146 if ((pBssDesc->Result.pvIes == NULL) && pIes)
2147 vos_mem_free(pIes);
Srinivas Girigowda8e7e1052013-11-13 18:53:14 -08002148
2149 if (fMatch)
2150 smsLog(pMac, LOG1, FL(" Security Matched"));
2151 }
2152 }
2153
2154 if (fMatch && (pBssDesc->Result.BssDescriptor.rssi > pMac->scan.inScanResultBestAPRssi))
2155 {
2156 smsLog(pMac, LOG1, FL("Best AP Rssi changed from %d to %d"),
2157 pMac->scan.inScanResultBestAPRssi,
2158 pBssDesc->Result.BssDescriptor.rssi);
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07002159 pMac->scan.inScanResultBestAPRssi = pBssDesc->Result.BssDescriptor.rssi;
2160 }
2161 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
2162 }
2163
Srinivas Girigowda8e7e1052013-11-13 18:53:14 -08002164 if ( -128 != pMac->scan.inScanResultBestAPRssi)
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07002165 {
Srinivas Girigowda8e7e1052013-11-13 18:53:14 -08002166 smsLog(pMac, LOG1, FL("Best AP Rssi is %d"), pMac->scan.inScanResultBestAPRssi);
2167 /* Modify Rssi category based on best AP Rssi */
2168 csrAssignRssiForCategory(pMac, pMac->scan.inScanResultBestAPRssi, pMac->roam.configParam.bCatRssiOffset);
2169 pEntry = csrLLPeekHead(&pMac->scan.scanResultList, LL_ACCESS_NOLOCK);
2170 while ( NULL != pEntry)
2171 {
2172 pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07002173
Srinivas Girigowda8e7e1052013-11-13 18:53:14 -08002174 /* re-assign preference value based on modified rssi bucket */
2175 pBssDesc->preferValue = csrGetBssPreferValue(pMac, (int)pBssDesc->Result.BssDescriptor.rssi);
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07002176
Arif Hussaina7c8e412013-11-20 11:06:42 -08002177 smsLog(pMac, LOG2, FL("BSSID("MAC_ADDRESS_STR
Jeff Johnson123ed002013-11-22 17:39:55 -08002178 ") Rssi(%d) Chnl(%d) PrefVal(%u) SSID=%.*s"),
Arif Hussaina7c8e412013-11-20 11:06:42 -08002179 MAC_ADDR_ARRAY(pBssDesc->Result.BssDescriptor.bssId),
2180 pBssDesc->Result.BssDescriptor.rssi,
2181 pBssDesc->Result.BssDescriptor.channelId,
2182 pBssDesc->preferValue,
2183 pBssDesc->Result.ssId.length, pBssDesc->Result.ssId.ssId);
Srinivas Girigowda8e7e1052013-11-13 18:53:14 -08002184
2185 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
2186 }
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07002187 }
2188
2189 csrLLUnlock(&pMac->scan.scanResultList);
2190 }
2191
Kiet Lam64c1b492013-07-12 13:56:44 +05302192 pRetList = vos_mem_malloc(sizeof(tScanResultList));
2193 if ( NULL == pRetList )
2194 status = eHAL_STATUS_FAILURE;
2195 else
2196 status = eHAL_STATUS_SUCCESS;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07002197 if(HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07002198 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302199 vos_mem_set(pRetList, sizeof(tScanResultList), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002200 csrLLOpen(pMac->hHdd, &pRetList->List);
2201 pRetList->pCurEntry = NULL;
2202
2203 csrLLLock(&pMac->scan.scanResultList);
2204 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
2205 while( pEntry )
2206 {
2207 pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
2208 pIes = (tDot11fBeaconIEs *)( pBssDesc->Result.pvIes );
2209 //if pBssDesc->Result.pvIes is NULL, we need to free any memory allocated by csrMatchBSS
2210 //for any error condition, otherwiase, it will be freed later.
2211 //reset
2212 fMatch = eANI_BOOLEAN_FALSE;
2213 pNewIes = NULL;
2214
2215 if(pFilter)
2216 {
2217 fMatch = csrMatchBSS(pMac, &pBssDesc->Result.BssDescriptor, pFilter, &auth, &uc, &mc, &pIes);
2218 if( NULL != pIes )
2219 {
2220 //Only save it when matching
2221 if(fMatch)
2222 {
2223 if( !pBssDesc->Result.pvIes )
2224 {
2225 //csrMatchBSS allocates the memory. Simply pass it and it is freed later
2226 pNewIes = pIes;
2227 }
2228 else
2229 {
2230 //The pIes is allocated by someone else. make a copy
2231 //Only to save parsed IEs if caller provides a filter. Most likely the caller
2232 //is using to for association, hence save the parsed IEs
Kiet Lam64c1b492013-07-12 13:56:44 +05302233 pNewIes = vos_mem_malloc(sizeof(tDot11fBeaconIEs));
2234 if ( NULL == pNewIes )
2235 status = eHAL_STATUS_FAILURE;
2236 else
2237 status = eHAL_STATUS_SUCCESS;
2238 if ( HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002239 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302240 vos_mem_copy(pNewIes, pIes, sizeof( tDot11fBeaconIEs ));
Jeff Johnson295189b2012-06-20 16:38:30 -07002241 }
2242 else
2243 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002244 smsLog(pMac, LOGE, FL(" fail to allocate memory for IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002245 //Need to free memory allocated by csrMatchBSS
2246 if( !pBssDesc->Result.pvIes )
2247 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302248 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07002249 }
2250 break;
2251 }
2252 }
2253 }//fMatch
2254 else if( !pBssDesc->Result.pvIes )
2255 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302256 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07002257 }
2258 }
2259 }
2260 if(NULL == pFilter || fMatch)
2261 {
2262 bssLen = pBssDesc->Result.BssDescriptor.length + sizeof(pBssDesc->Result.BssDescriptor.length);
2263 allocLen = sizeof( tCsrScanResult ) + bssLen;
Kiet Lam64c1b492013-07-12 13:56:44 +05302264 pResult = vos_mem_malloc(allocLen);
2265 if ( NULL == pResult )
2266 status = eHAL_STATUS_FAILURE;
2267 else
2268 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002269 if(!HAL_STATUS_SUCCESS(status))
2270 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002271 smsLog(pMac, LOGE, FL(" fail to allocate memory for scan result, len=%d"), allocLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07002272 if(pNewIes)
2273 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302274 vos_mem_free(pNewIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07002275 }
2276 break;
2277 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302278 vos_mem_set(pResult, allocLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002279 pResult->capValue = pBssDesc->capValue;
2280 pResult->preferValue = pBssDesc->preferValue;
2281 pResult->ucEncryptionType = uc;
2282 pResult->mcEncryptionType = mc;
2283 pResult->authType = auth;
2284 pResult->Result.ssId = pBssDesc->Result.ssId;
2285 pResult->Result.timer = 0;
2286 //save the pIes for later use
2287 pResult->Result.pvIes = pNewIes;
2288 //save bss description
Kiet Lam64c1b492013-07-12 13:56:44 +05302289 vos_mem_copy(&pResult->Result.BssDescriptor,
2290 &pBssDesc->Result.BssDescriptor, bssLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07002291 //No need to lock pRetList because it is locally allocated and no outside can access it at this time
2292 if(csrLLIsListEmpty(&pRetList->List, LL_ACCESS_NOLOCK))
2293 {
2294 csrLLInsertTail(&pRetList->List, &pResult->Link, LL_ACCESS_NOLOCK);
2295 }
2296 else
2297 {
2298 //To sort the list
2299 tListElem *pTmpEntry;
2300 tCsrScanResult *pTmpResult;
2301
2302 pTmpEntry = csrLLPeekHead(&pRetList->List, LL_ACCESS_NOLOCK);
2303 while(pTmpEntry)
2304 {
2305 pTmpResult = GET_BASE_ADDR( pTmpEntry, tCsrScanResult, Link );
2306 if(csrIsBetterBss(pResult, pTmpResult))
2307 {
2308 csrLLInsertEntry(&pRetList->List, pTmpEntry, &pResult->Link, LL_ACCESS_NOLOCK);
2309 //To indicate we are done
2310 pResult = NULL;
2311 break;
2312 }
2313 pTmpEntry = csrLLNext(&pRetList->List, pTmpEntry, LL_ACCESS_NOLOCK);
2314 }
2315 if(pResult != NULL)
2316 {
2317 //This one is not better than any one
2318 csrLLInsertTail(&pRetList->List, &pResult->Link, LL_ACCESS_NOLOCK);
2319 }
2320 }
2321 count++;
2322 }
2323 pEntry = csrLLNext( &pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK );
2324 }//while
2325 csrLLUnlock(&pMac->scan.scanResultList);
2326
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002327 smsLog(pMac, LOG2, FL("return %d BSS"), csrLLCount(&pRetList->List));
Jeff Johnson295189b2012-06-20 16:38:30 -07002328
2329 if( !HAL_STATUS_SUCCESS(status) || (phResult == NULL) )
2330 {
2331 //Fail or No one wants the result.
2332 csrScanResultPurge(pMac, (tScanResultHandle)pRetList);
2333 }
2334 else
2335 {
2336 if(0 == count)
2337 {
2338 //We are here meaning the there is no match
2339 csrLLClose(&pRetList->List);
Kiet Lam64c1b492013-07-12 13:56:44 +05302340 vos_mem_free(pRetList);
Jeff Johnson295189b2012-06-20 16:38:30 -07002341 status = eHAL_STATUS_E_NULL_VALUE;
2342 }
2343 else if(phResult)
2344 {
2345 *phResult = pRetList;
2346 }
2347 }
2348 }//Allocated pRetList
2349
2350 return (status);
2351}
2352
Madan Mohan Koyyalamudiab41d0f2012-10-31 17:17:10 -07002353/*
2354 * NOTE: This routine is being added to make
2355 * sure that scan results are not being flushed
2356 * while roaming. If the scan results are flushed,
2357 * we are unable to recover from
2358 * csrRoamRoamingStateDisassocRspProcessor.
2359 * If it is needed to remove this routine,
2360 * first ensure that we recover gracefully from
2361 * csrRoamRoamingStateDisassocRspProcessor if
2362 * csrScanGetResult returns with a failure because
2363 * of not being able to find the roaming BSS.
2364 */
2365tANI_U8 csrScanFlushDenied(tpAniSirGlobal pMac)
2366{
2367 switch(pMac->roam.neighborRoamInfo.neighborRoamState) {
2368 case eCSR_NEIGHBOR_ROAM_STATE_REPORT_SCAN:
2369 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTHENTICATING:
2370 case eCSR_NEIGHBOR_ROAM_STATE_PREAUTH_DONE:
2371 case eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING:
2372 return (pMac->roam.neighborRoamInfo.neighborRoamState);
2373 default:
2374 return 0;
2375 }
2376}
2377
Jeff Johnson295189b2012-06-20 16:38:30 -07002378eHalStatus csrScanFlushResult(tpAniSirGlobal pMac)
2379{
Madan Mohan Koyyalamudiab41d0f2012-10-31 17:17:10 -07002380 tANI_U8 isFlushDenied = csrScanFlushDenied(pMac);
Srinivas, Dasari42bf7702014-02-07 11:29:53 +05302381 eHalStatus status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudiab41d0f2012-10-31 17:17:10 -07002382 if (isFlushDenied) {
2383 smsLog(pMac, LOGW, "%s: scan flush denied in roam state %d",
2384 __func__, isFlushDenied);
2385 return eHAL_STATUS_FAILURE;
2386 }
Srinivas, Dasari42bf7702014-02-07 11:29:53 +05302387 csrLLScanPurgeResult( pMac, &pMac->scan.tempScanResults );
2388 csrLLScanPurgeResult( pMac, &pMac->scan.scanResultList );
2389 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002390}
2391
Madan Mohan Koyyalamudi5850f312012-11-27 19:00:25 +05302392eHalStatus csrScanFlushSelectiveResult(tpAniSirGlobal pMac, v_BOOL_t flushP2P)
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07002393{
Madan Mohan Koyyalamudi5850f312012-11-27 19:00:25 +05302394 eHalStatus status = eHAL_STATUS_SUCCESS;
2395 tListElem *pEntry,*pFreeElem;
2396 tCsrScanResult *pBssDesc;
2397 tDblLinkList *pList = &pMac->scan.scanResultList;
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07002398
Madan Mohan Koyyalamudi5850f312012-11-27 19:00:25 +05302399 csrLLLock(pList);
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07002400
Madan Mohan Koyyalamudi5850f312012-11-27 19:00:25 +05302401 pEntry = csrLLPeekHead( pList, LL_ACCESS_NOLOCK );
2402 while( pEntry != NULL)
2403 {
2404 pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
2405 if( flushP2P == vos_mem_compare( pBssDesc->Result.ssId.ssId,
2406 "DIRECT-", 7) )
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07002407 {
Madan Mohan Koyyalamudi5850f312012-11-27 19:00:25 +05302408 pFreeElem = pEntry;
2409 pEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
2410 csrLLRemoveEntry(pList, pFreeElem, LL_ACCESS_NOLOCK);
2411 csrFreeScanResultEntry( pMac, pBssDesc );
2412 continue;
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07002413 }
Madan Mohan Koyyalamudi5850f312012-11-27 19:00:25 +05302414 pEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
2415 }
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07002416
Madan Mohan Koyyalamudi5850f312012-11-27 19:00:25 +05302417 csrLLUnlock(pList);
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07002418
Madan Mohan Koyyalamudi5850f312012-11-27 19:00:25 +05302419 return (status);
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07002420}
2421
Jeff Johnson295189b2012-06-20 16:38:30 -07002422/**
2423 * csrCheck11dChannel
2424 *
2425 *FUNCTION:
Srinivas, Dasari42bf7702014-02-07 11:29:53 +05302426 * This function is called from csrScanFilterResults function and
Jeff Johnson295189b2012-06-20 16:38:30 -07002427 * compare channel number with given channel list.
2428 *
2429 *LOGIC:
2430 * Check Scan result channel number with CFG channel list
2431 *
2432 *ASSUMPTIONS:
2433 *
2434 *
2435 *NOTE:
2436 *
2437 * @param channelId channel number
2438 * @param pChannelList Pointer to channel list
2439 * @param numChannels Number of channel in channel list
2440 *
2441 * @return Status
2442 */
2443
2444eHalStatus csrCheck11dChannel(tANI_U8 channelId, tANI_U8 *pChannelList, tANI_U32 numChannels)
2445{
2446 eHalStatus status = eHAL_STATUS_FAILURE;
2447 tANI_U8 i = 0;
2448
2449 for (i = 0; i < numChannels; i++)
2450 {
2451 if(pChannelList[ i ] == channelId)
2452 {
2453 status = eHAL_STATUS_SUCCESS;
2454 break;
2455 }
2456 }
2457 return status;
2458}
2459
2460/**
Srinivas, Dasari42bf7702014-02-07 11:29:53 +05302461 * csrScanFilterResults
Jeff Johnson295189b2012-06-20 16:38:30 -07002462 *
2463 *FUNCTION:
2464 * This function is called from csrApplyCountryInformation function and
2465 * filter scan result based on valid channel list number.
2466 *
2467 *LOGIC:
2468 * Get scan result from scan list and Check Scan result channel number
2469 * with 11d channel list if channel number is found in 11d channel list
2470 * then do not remove scan result entry from scan list
2471 *
2472 *ASSUMPTIONS:
2473 *
2474 *
2475 *NOTE:
2476 *
2477 * @param pMac Pointer to Global MAC structure
2478 *
2479 * @return Status
2480 */
2481
Srinivas, Dasari42bf7702014-02-07 11:29:53 +05302482eHalStatus csrScanFilterResults(tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -07002483{
2484 eHalStatus status = eHAL_STATUS_SUCCESS;
2485 tListElem *pEntry,*pTempEntry;
2486 tCsrScanResult *pBssDesc;
2487 tANI_U32 len = sizeof(pMac->roam.validChannelList);
2488
2489 /* Get valid channels list from CFG */
2490 if (!HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac,
2491 pMac->roam.validChannelList, &len)))
2492 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05302493 smsLog( pMac, LOGE, "Failed to get Channel list from CFG");
Jeff Johnson295189b2012-06-20 16:38:30 -07002494 }
2495
2496 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_LOCK );
2497 while( pEntry )
2498 {
2499 pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
Srinivas, Dasari42bf7702014-02-07 11:29:53 +05302500 pTempEntry = csrLLNext( &pMac->scan.scanResultList, pEntry,
Jeff Johnson295189b2012-06-20 16:38:30 -07002501 LL_ACCESS_LOCK );
2502 if(csrCheck11dChannel(pBssDesc->Result.BssDescriptor.channelId,
Srinivas, Dasari42bf7702014-02-07 11:29:53 +05302503 pMac->roam.validChannelList, len))
Jeff Johnson295189b2012-06-20 16:38:30 -07002504 {
2505 /* Remove Scan result which does not have 11d channel */
2506 if( csrLLRemoveEntry( &pMac->scan.scanResultList, pEntry,
2507 LL_ACCESS_LOCK ))
2508 {
2509 csrFreeScanResultEntry( pMac, pBssDesc );
2510 }
2511 }
Srinivas, Dasari42bf7702014-02-07 11:29:53 +05302512 else
2513 {
2514 smsLog( pMac, LOG1, FL("%d is a Valid channel"),
2515 pBssDesc->Result.BssDescriptor.channelId);
2516 }
2517 pEntry = pTempEntry;
2518 }
2519
2520 pEntry = csrLLPeekHead( &pMac->scan.tempScanResults, LL_ACCESS_LOCK );
2521 while( pEntry )
2522 {
2523 pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
2524 pTempEntry = csrLLNext( &pMac->scan.tempScanResults, pEntry,
2525 LL_ACCESS_LOCK );
2526 if(csrCheck11dChannel(pBssDesc->Result.BssDescriptor.channelId,
2527 pMac->roam.validChannelList, len))
2528 {
2529 /* Remove Scan result which does not have 11d channel */
2530 if( csrLLRemoveEntry( &pMac->scan.tempScanResults, pEntry,
2531 LL_ACCESS_LOCK ))
2532 {
2533 csrFreeScanResultEntry( pMac, pBssDesc );
2534 }
2535 }
2536 else
2537 {
2538 smsLog( pMac, LOG1, FL("%d is a Valid channel"),
2539 pBssDesc->Result.BssDescriptor.channelId);
2540 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002541 pEntry = pTempEntry;
2542 }
2543 return status;
2544}
2545
2546
2547eHalStatus csrScanCopyResultList(tpAniSirGlobal pMac, tScanResultHandle hIn, tScanResultHandle *phResult)
2548{
2549 eHalStatus status = eHAL_STATUS_SUCCESS;
2550 tScanResultList *pRetList, *pInList = (tScanResultList *)hIn;
2551 tCsrScanResult *pResult, *pScanResult;
2552 tANI_U32 count = 0;
2553 tListElem *pEntry;
2554 tANI_U32 bssLen, allocLen;
2555
2556 if(phResult)
2557 {
2558 *phResult = CSR_INVALID_SCANRESULT_HANDLE;
2559 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302560 pRetList = vos_mem_malloc(sizeof(tScanResultList));
2561 if ( NULL == pRetList )
2562 status = eHAL_STATUS_FAILURE;
2563 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002564 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302565 vos_mem_set(pRetList, sizeof(tScanResultList), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002566 csrLLOpen(pMac->hHdd, &pRetList->List);
2567 pRetList->pCurEntry = NULL;
2568 csrLLLock(&pMac->scan.scanResultList);
2569 csrLLLock(&pInList->List);
2570
2571 pEntry = csrLLPeekHead( &pInList->List, LL_ACCESS_NOLOCK );
2572 while( pEntry )
2573 {
2574 pScanResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
2575 bssLen = pScanResult->Result.BssDescriptor.length + sizeof(pScanResult->Result.BssDescriptor.length);
2576 allocLen = sizeof( tCsrScanResult ) + bssLen;
Kiet Lam64c1b492013-07-12 13:56:44 +05302577 pResult = vos_mem_malloc(allocLen);
2578 if ( NULL == pResult )
2579 status = eHAL_STATUS_FAILURE;
2580 else
2581 status = eHAL_STATUS_SUCCESS;
2582 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07002583 {
2584 csrScanResultPurge(pMac, (tScanResultHandle *)pRetList);
2585 count = 0;
2586 break;
2587 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302588 vos_mem_set(pResult, allocLen , 0);
2589 vos_mem_copy(&pResult->Result.BssDescriptor, &pScanResult->Result.BssDescriptor, bssLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07002590 if( pScanResult->Result.pvIes )
2591 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302592 pResult->Result.pvIes = vos_mem_malloc(sizeof( tDot11fBeaconIEs ));
2593 if ( NULL == pResult->Result.pvIes )
2594 status = eHAL_STATUS_FAILURE;
2595 else
2596 status = eHAL_STATUS_SUCCESS;
2597 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07002598 {
2599 //Free the memory we allocate above first
Kiet Lam64c1b492013-07-12 13:56:44 +05302600 vos_mem_free(pResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07002601 csrScanResultPurge(pMac, (tScanResultHandle *)pRetList);
2602 count = 0;
2603 break;
2604 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302605 vos_mem_copy(pResult->Result.pvIes, pScanResult->Result.pvIes,
2606 sizeof( tDot11fBeaconIEs ));
Jeff Johnson295189b2012-06-20 16:38:30 -07002607 }
2608 csrLLInsertTail(&pRetList->List, &pResult->Link, LL_ACCESS_LOCK);
2609 count++;
2610 pEntry = csrLLNext( &pInList->List, pEntry, LL_ACCESS_NOLOCK );
2611 }//while
2612 csrLLUnlock(&pInList->List);
2613 csrLLUnlock(&pMac->scan.scanResultList);
2614
2615 if(HAL_STATUS_SUCCESS(status))
2616 {
2617 if(0 == count)
2618 {
2619 csrLLClose(&pRetList->List);
Kiet Lam64c1b492013-07-12 13:56:44 +05302620 vos_mem_free(pRetList);
Jeff Johnson295189b2012-06-20 16:38:30 -07002621 status = eHAL_STATUS_E_NULL_VALUE;
2622 }
2623 else if(phResult)
2624 {
2625 *phResult = pRetList;
2626 }
2627 }
2628 }//Allocated pRetList
2629
2630 return (status);
2631}
2632
2633
2634
2635eHalStatus csrScanningStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
2636{
2637 eHalStatus status = eHAL_STATUS_SUCCESS;
2638 tSirMbMsg *pMsg = (tSirMbMsg *)pMsgBuf;
2639
2640 if((eWNI_SME_SCAN_RSP == pMsg->type) || (eWNI_SME_GET_SCANNED_CHANNEL_RSP == pMsg->type))
2641 {
2642 status = csrScanSmeScanResponse( pMac, pMsgBuf );
2643 }
2644 else
2645 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002646 if(pMsg->type == eWNI_SME_UPPER_LAYER_ASSOC_CNF)
Jeff Johnson295189b2012-06-20 16:38:30 -07002647 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002648 tCsrRoamSession *pSession;
2649 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
2650 tCsrRoamInfo roamInfo;
2651 tCsrRoamInfo *pRoamInfo = NULL;
2652 tANI_U32 sessionId;
2653 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002654 smsLog( pMac, LOG1, FL("Scanning : ASSOCIATION confirmation can be given to upper layer "));
Kiet Lam64c1b492013-07-12 13:56:44 +05302655 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002656 pRoamInfo = &roamInfo;
2657 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
2658 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
2659 pSession = CSR_GET_SESSION(pMac, sessionId);
2660
2661 if(!pSession)
2662 {
2663 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2664 return eHAL_STATUS_FAILURE;
2665 }
2666
2667 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
2668 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
2669 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
2670 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
2671 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
2672 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
2673 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05302674 vos_mem_copy(pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr, sizeof(tSirMacAddr));
2675 vos_mem_copy(&pRoamInfo->bssid, pUpperLayerAssocCnf->bssId, sizeof(tCsrBssid));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002676 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
2677 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
2678 {
2679 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
2680 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
2681 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
2682 }
2683 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
2684 {
2685 vos_sleep( 100 );
2686 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
2687 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
2688 }
2689
Jeff Johnson295189b2012-06-20 16:38:30 -07002690 }
2691 else
2692 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002693
2694 if( csrIsAnySessionInConnectState( pMac ) )
2695 {
2696 //In case of we are connected, we need to check whether connect status changes
2697 //because scan may also run while connected.
2698 csrRoamCheckForLinkStatusChange( pMac, ( tSirSmeRsp * )pMsgBuf );
2699 }
2700 else
2701 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002702 smsLog( pMac, LOGW, "Message [0x%04x] received in state, when expecting Scan Response", pMsg->type );
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002703 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002704 }
2705 }
2706
2707 return (status);
2708}
2709
2710
2711
2712void csrCheckNSaveWscIe(tpAniSirGlobal pMac, tSirBssDescription *pNewBssDescr, tSirBssDescription *pOldBssDescr)
2713{
2714 int idx, len;
2715 tANI_U8 *pbIe;
2716
2717 //If failed to remove, assuming someone else got it.
2718 if((pNewBssDescr->fProbeRsp != pOldBssDescr->fProbeRsp) &&
2719 (0 == pNewBssDescr->WscIeLen))
2720 {
2721 idx = 0;
2722 len = pOldBssDescr->length - sizeof(tSirBssDescription) +
2723 sizeof(tANI_U16) + sizeof(tANI_U32) - DOT11F_IE_WSCPROBERES_MIN_LEN - 2;
2724 pbIe = (tANI_U8 *)pOldBssDescr->ieFields;
2725 //Save WPS IE if it exists
2726 pNewBssDescr->WscIeLen = 0;
2727 while(idx < len)
2728 {
2729 if((DOT11F_EID_WSCPROBERES == pbIe[0]) &&
2730 (0x00 == pbIe[2]) && (0x50 == pbIe[3]) && (0xf2 == pbIe[4]) && (0x04 == pbIe[5]))
2731 {
2732 //Founrd it
2733 if((DOT11F_IE_WSCPROBERES_MAX_LEN - 2) >= pbIe[1])
2734 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302735 vos_mem_copy(pNewBssDescr->WscIeProbeRsp, pbIe, pbIe[1] + 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002736 pNewBssDescr->WscIeLen = pbIe[1] + 2;
2737 }
2738 break;
2739 }
2740 idx += pbIe[1] + 2;
2741 pbIe += pbIe[1] + 2;
2742 }
2743 }
2744}
2745
2746
2747
2748//pIes may be NULL
2749tANI_BOOLEAN csrRemoveDupBssDescription( tpAniSirGlobal pMac, tSirBssDescription *pSirBssDescr,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302750 tDot11fBeaconIEs *pIes, tAniSSID *pSsid, v_TIME_t *timer, tANI_BOOLEAN fForced )
Jeff Johnson295189b2012-06-20 16:38:30 -07002751{
2752 tListElem *pEntry;
2753
2754 tCsrScanResult *pBssDesc;
2755 tANI_BOOLEAN fRC = FALSE;
2756
2757 // Walk through all the chained BssDescriptions. If we find a chained BssDescription that
2758 // matches the BssID of the BssDescription passed in, then these must be duplicate scan
2759 // results for this Bss. In that case, remove the 'old' Bss description from the linked list.
2760 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_LOCK );
2761
2762 while( pEntry )
2763 {
2764 pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
2765
2766 // we have a duplicate scan results only when BSSID, SSID, Channel and NetworkType
2767 // matches
2768 if ( csrIsDuplicateBssDescription( pMac, &pBssDesc->Result.BssDescriptor,
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07002769 pSirBssDescr, pIes, fForced ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002770 {
2771 pSirBssDescr->rssi = (tANI_S8)( (((tANI_S32)pSirBssDescr->rssi * CSR_SCAN_RESULT_RSSI_WEIGHT ) +
2772 ((tANI_S32)pBssDesc->Result.BssDescriptor.rssi * (100 - CSR_SCAN_RESULT_RSSI_WEIGHT) )) / 100 );
2773 // Remove the 'old' entry from the list....
2774 if( csrLLRemoveEntry( &pMac->scan.scanResultList, pEntry, LL_ACCESS_LOCK ) )
2775 {
2776 // !we need to free the memory associated with this node
2777 //If failed to remove, assuming someone else got it.
2778 *pSsid = pBssDesc->Result.ssId;
2779 *timer = pBssDesc->Result.timer;
2780 csrCheckNSaveWscIe(pMac, pSirBssDescr, &pBssDesc->Result.BssDescriptor);
2781
2782 csrFreeScanResultEntry( pMac, pBssDesc );
2783 }
2784 else
2785 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002786 smsLog( pMac, LOGW, FL( " fail to remove entry" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -07002787 }
2788 fRC = TRUE;
2789
2790 // If we found a match, we can stop looking through the list.
2791 break;
2792 }
2793
2794 pEntry = csrLLNext( &pMac->scan.scanResultList, pEntry, LL_ACCESS_LOCK );
2795 }
2796
2797 return fRC;
2798}
2799
2800
2801eHalStatus csrAddPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId,
2802 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes )
2803{
2804 eHalStatus status = eHAL_STATUS_FAILURE;
2805 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2806
Jeff Johnson32d95a32012-09-10 13:15:23 -07002807 if(!pSession)
2808 {
2809 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2810 return eHAL_STATUS_FAILURE;
2811 }
2812
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002813 smsLog(pMac, LOGW, "csrAddPMKIDCandidateList called pMac->scan.NumPmkidCandidate = %d", pSession->NumPmkidCandidate);
Jeff Johnson295189b2012-06-20 16:38:30 -07002814 if( pIes )
2815 {
2816 // check if this is a RSN BSS
2817 if( pIes->RSN.present )
2818 {
2819 // Check if the BSS is capable of doing pre-authentication
2820 if( pSession->NumPmkidCandidate < CSR_MAX_PMKID_ALLOWED )
2821 {
2822
2823#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2824 {
2825 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05302826 vos_mem_set(&secEvent, sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002827 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_CANDIDATE_FOUND;
2828 secEvent.encryptionModeMulticast =
2829 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
2830 secEvent.encryptionModeUnicast =
2831 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05302832 vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07002833 secEvent.authMode =
2834 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
2835 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
2836 }
2837#endif//#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2838
2839 // if yes, then add to PMKIDCandidateList
Kiet Lam64c1b492013-07-12 13:56:44 +05302840 vos_mem_copy(pSession->PmkidCandidateInfo[pSession->NumPmkidCandidate].BSSID,
2841 pBssDesc->bssId, WNI_CFG_BSSID_LEN);
2842 // Bit 0 offirst byte - PreAuthentication Capability
2843 if ( (pIes->RSN.RSN_Cap[0] >> 0) & 0x1 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002844 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302845 pSession->PmkidCandidateInfo[pSession->NumPmkidCandidate].preAuthSupported
2846 = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002847 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302848 else
2849 {
2850 pSession->PmkidCandidateInfo[pSession->NumPmkidCandidate].preAuthSupported
2851 = eANI_BOOLEAN_FALSE;
2852 }
2853 pSession->NumPmkidCandidate++;
Jeff Johnson295189b2012-06-20 16:38:30 -07002854 }
2855 else
2856 {
2857 status = eHAL_STATUS_FAILURE;
2858 }
2859 }
2860 }
2861
2862 return (status);
2863}
2864
2865//This function checks whether new AP is found for the current connected profile
2866//If it is found, it return the sessionId, else it return invalid sessionID
2867tANI_U32 csrProcessBSSDescForPMKIDList(tpAniSirGlobal pMac,
2868 tSirBssDescription *pBssDesc,
2869 tDot11fBeaconIEs *pIes)
2870{
2871 tANI_U32 i, bRet = CSR_SESSION_ID_INVALID;
2872 tCsrRoamSession *pSession;
2873 tDot11fBeaconIEs *pIesLocal = pIes;
2874
2875 if( pIesLocal || HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal)) )
2876 {
2877 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
2878 {
2879 if( CSR_IS_SESSION_VALID( pMac, i ) )
2880 {
2881 pSession = CSR_GET_SESSION( pMac, i );
2882 if( csrIsConnStateConnectedInfra( pMac, i ) &&
2883 ( eCSR_AUTH_TYPE_RSN == pSession->connectedProfile.AuthType ) )
2884 {
2885 if(csrMatchBSSToConnectProfile(pMac, &pSession->connectedProfile, pBssDesc, pIesLocal))
2886 {
2887 //this new BSS fits the current profile connected
2888 if(HAL_STATUS_SUCCESS(csrAddPMKIDCandidateList(pMac, i, pBssDesc, pIesLocal)))
2889 {
2890 bRet = i;
2891 }
2892 break;
2893 }
2894 }
2895 }
2896 }
2897 if( !pIes )
2898 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302899 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07002900 }
2901 }
2902
2903 return (tANI_U8)bRet;
2904}
2905
2906#ifdef FEATURE_WLAN_WAPI
2907eHalStatus csrAddBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId,
2908 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes )
2909{
2910 eHalStatus status = eHAL_STATUS_FAILURE;
2911 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2912
Jeff Johnson32d95a32012-09-10 13:15:23 -07002913 if(!pSession)
2914 {
2915 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2916 return eHAL_STATUS_FAILURE;
2917 }
2918
Kiet Lam64c1b492013-07-12 13:56:44 +05302919 smsLog(pMac, LOGW, "csrAddBKIDCandidateList called pMac->scan.NumBkidCandidate = %d",
2920 pSession->NumBkidCandidate);
Jeff Johnson295189b2012-06-20 16:38:30 -07002921 if( pIes )
2922 {
2923 // check if this is a WAPI BSS
2924 if( pIes->WAPI.present )
2925 {
2926 // Check if the BSS is capable of doing pre-authentication
2927 if( pSession->NumBkidCandidate < CSR_MAX_BKID_ALLOWED )
2928 {
2929
2930 // if yes, then add to BKIDCandidateList
Kiet Lam64c1b492013-07-12 13:56:44 +05302931 vos_mem_copy(pSession->BkidCandidateInfo[pSession->NumBkidCandidate].BSSID,
2932 pBssDesc->bssId, WNI_CFG_BSSID_LEN);
2933 if ( pIes->WAPI.preauth )
Jeff Johnson295189b2012-06-20 16:38:30 -07002934 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302935 pSession->BkidCandidateInfo[pSession->NumBkidCandidate].preAuthSupported
2936 = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002937 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302938 else
2939 {
2940 pSession->BkidCandidateInfo[pSession->NumBkidCandidate].preAuthSupported
2941 = eANI_BOOLEAN_FALSE;
2942 }
2943 pSession->NumBkidCandidate++;
Jeff Johnson295189b2012-06-20 16:38:30 -07002944 }
2945 else
2946 {
2947 status = eHAL_STATUS_FAILURE;
2948 }
2949 }
2950 }
2951
2952 return (status);
2953}
2954
2955//This function checks whether new AP is found for the current connected profile
2956//if so add to BKIDCandidateList
2957tANI_BOOLEAN csrProcessBSSDescForBKIDList(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
2958 tDot11fBeaconIEs *pIes)
2959{
2960 tANI_BOOLEAN fRC = FALSE;
2961 tDot11fBeaconIEs *pIesLocal = pIes;
2962 tANI_U32 sessionId;
2963 tCsrRoamSession *pSession;
2964
2965 if( pIesLocal || HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal)) )
2966 {
2967 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
2968 {
2969 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2970 {
2971 pSession = CSR_GET_SESSION( pMac, sessionId );
2972 if( csrIsConnStateConnectedInfra( pMac, sessionId ) &&
2973 eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == pSession->connectedProfile.AuthType)
2974 {
2975 if(csrMatchBSSToConnectProfile(pMac, &pSession->connectedProfile,pBssDesc, pIesLocal))
2976 {
2977 //this new BSS fits the current profile connected
2978 if(HAL_STATUS_SUCCESS(csrAddBKIDCandidateList(pMac, sessionId, pBssDesc, pIesLocal)))
2979 {
2980 fRC = TRUE;
2981 }
2982 }
2983 }
2984 }
2985 }
2986 if(!pIes)
2987 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302988 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07002989 }
2990
2991 }
2992 return fRC;
2993}
2994
2995#endif
2996
2997
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07002998static void csrMoveTempScanResultsToMainList( tpAniSirGlobal pMac, tANI_U8 reason )
Jeff Johnson295189b2012-06-20 16:38:30 -07002999{
3000 tListElem *pEntry;
3001 tCsrScanResult *pBssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07003002 tANI_BOOLEAN fDupBss;
3003#ifdef FEATURE_WLAN_WAPI
3004 tANI_BOOLEAN fNewWapiBSSForCurConnection = eANI_BOOLEAN_FALSE;
3005#endif /* FEATURE_WLAN_WAPI */
3006 tDot11fBeaconIEs *pIesLocal = NULL;
3007 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
3008 tAniSSID tmpSsid;
3009 v_TIME_t timer=0;
3010
3011 tmpSsid.length = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003012
3013 // remove the BSS descriptions from temporary list
3014 while( ( pEntry = csrLLRemoveTail( &pMac->scan.tempScanResults, LL_ACCESS_LOCK ) ) != NULL)
3015 {
3016 pBssDescription = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
3017
Arif Hussain24bafea2013-11-15 15:10:03 -08003018 smsLog( pMac, LOGW, "...Bssid= "MAC_ADDRESS_STR" chan= %d, rssi = -%d",
3019 MAC_ADDR_ARRAY(pBssDescription->Result.BssDescriptor.bssId),
Jeff Johnson295189b2012-06-20 16:38:30 -07003020 pBssDescription->Result.BssDescriptor.channelId,
3021 pBssDescription->Result.BssDescriptor.rssi * (-1) );
3022
3023 //At this time, pBssDescription->Result.pvIes may be NULL
3024 pIesLocal = (tDot11fBeaconIEs *)( pBssDescription->Result.pvIes );
3025 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pBssDescription->Result.BssDescriptor, &pIesLocal))) )
3026 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003027 smsLog(pMac, LOGE, FL(" Cannot pared IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003028 csrFreeScanResultEntry(pMac, pBssDescription);
3029 continue;
3030 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05303031 fDupBss = csrRemoveDupBssDescription( pMac, &pBssDescription->Result.BssDescriptor, pIesLocal, &tmpSsid, &timer, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07003032 //Check whether we have reach out limit, but don't lose the LFR candidates came from FW
3033 if( CSR_SCAN_IS_OVER_BSS_LIMIT(pMac)
3034#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
3035 && !( eCsrScanGetLfrResult == reason )
3036#endif
3037 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003038 {
3039 //Limit reach
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003040 smsLog(pMac, LOGW, FL(" BSS limit reached"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003041 //Free the resources
3042 if( (pBssDescription->Result.pvIes == NULL) && pIesLocal )
3043 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303044 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07003045 }
3046 csrFreeScanResultEntry(pMac, pBssDescription);
3047 //Continue because there may be duplicated BSS
3048 continue;
3049 }
3050 // check for duplicate scan results
3051 if ( !fDupBss )
3052 {
3053 //Found a new BSS
3054 sessionId = csrProcessBSSDescForPMKIDList(pMac,
3055 &pBssDescription->Result.BssDescriptor, pIesLocal);
3056 if( CSR_SESSION_ID_INVALID != sessionId)
3057 {
3058 csrRoamCallCallback(pMac, sessionId, NULL, 0,
3059 eCSR_ROAM_SCAN_FOUND_NEW_BSS, eCSR_ROAM_RESULT_NONE);
3060 }
3061 }
3062 else
3063 {
3064 //Check if the new one has SSID it it, if not, use the older SSID if it exists.
3065 if( (0 == pBssDescription->Result.ssId.length) && tmpSsid.length )
3066 {
3067 //New BSS has a hidden SSID and old one has the SSID. Keep the SSID only
3068 //if diff of saved SSID time and current time is less than 1 min to avoid
3069 //side effect of saving SSID with old one is that if AP changes its SSID while remain
3070 //hidden, we may never see it and also to address the requirement of
3071 //When we remove hidden ssid from the profile i.e., forget the SSID via
3072 // GUI that SSID shouldn't see in the profile
3073 if( (vos_timer_get_system_time() - timer) <= HIDDEN_TIMER)
3074 {
3075 pBssDescription->Result.timer = timer;
3076 pBssDescription->Result.ssId = tmpSsid;
3077 }
3078 }
3079 }
3080
Agarwal Ashishd9d72602013-09-13 00:06:17 +05303081 //Find a good AP for 11d info
3082 if ( csrIs11dSupported( pMac ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003083 {
Agrawal Ashish0b6984f2014-04-05 18:35:45 +05303084 // check if country information element is present
3085 if (pIesLocal->Country.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07003086 {
Agrawal Ashish0b6984f2014-04-05 18:35:45 +05303087 csrAddVoteForCountryInfo(pMac, pIesLocal->Country.country);
3088 smsLog(pMac, LOGW, FL("11d AP Bssid " MAC_ADDRESS_STR
3089 " chan= %d, rssi = -%d, countryCode %c%c"),
3090 MAC_ADDR_ARRAY( pBssDescription->Result.BssDescriptor.bssId),
3091 pBssDescription->Result.BssDescriptor.channelId,
3092 pBssDescription->Result.BssDescriptor.rssi * (-1),
3093 pIesLocal->Country.country[0],pIesLocal->Country.country[1] );
3094 }
Agarwal Ashishd9d72602013-09-13 00:06:17 +05303095
Jeff Johnson295189b2012-06-20 16:38:30 -07003096 }
Madan Mohan Koyyalamudi527935a2012-12-04 16:41:16 -08003097
Jeff Johnson295189b2012-06-20 16:38:30 -07003098 // append to main list
3099 csrScanAddResult(pMac, pBssDescription, pIesLocal);
Agarwal Ashishd9d72602013-09-13 00:06:17 +05303100 if ( (pBssDescription->Result.pvIes == NULL) && pIesLocal )
Jeff Johnson295189b2012-06-20 16:38:30 -07003101 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303102 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07003103 }
3104 }
3105
Tushnim Bhattacharyyaae317772013-10-23 18:55:38 -07003106 //we don't need to update CC while connected to an AP which is advertising CC already
3107 if (csrIs11dSupported(pMac))
3108 {
3109 tANI_U32 i;
3110 tCsrRoamSession *pSession;
3111
3112 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
3113 {
3114 if (CSR_IS_SESSION_VALID( pMac, i ) )
3115 {
3116 pSession = CSR_GET_SESSION( pMac, i );
3117 if (csrIsConnStateConnected(pMac, i))
3118 {
Agrawal Ashish0b6984f2014-04-05 18:35:45 +05303119 smsLog(pMac, LOGW, FL("No need for updating CC in"
3120 "connected state"));
3121 goto end;
Tushnim Bhattacharyyaae317772013-10-23 18:55:38 -07003122 }
3123 }
3124 }
Agrawal Ashish0b6984f2014-04-05 18:35:45 +05303125 csrElectedCountryInfo(pMac);
3126 csrLearnCountryInformation( pMac, eANI_BOOLEAN_TRUE );
Agarwal Ashishd9d72602013-09-13 00:06:17 +05303127 }
3128
Tushnim Bhattacharyyaae317772013-10-23 18:55:38 -07003129end:
3130 //If we can find the current 11d info in any of the scan results, or
Jeff Johnson295189b2012-06-20 16:38:30 -07003131 // a good enough AP with the 11d info from the scan results then no need to
3132 // get into ambiguous state
3133 if(pMac->scan.fAmbiguous11dInfoFound)
3134 {
Agrawal Ashish0b6984f2014-04-05 18:35:45 +05303135 if((pMac->scan.fCurrent11dInfoMatch))
Jeff Johnson295189b2012-06-20 16:38:30 -07003136 {
3137 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
3138 }
3139 }
3140
3141#ifdef FEATURE_WLAN_WAPI
3142 if(fNewWapiBSSForCurConnection)
3143 {
3144 //remember it first
3145 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_SCAN_FOUND_NEW_BSS, eCSR_ROAM_RESULT_NEW_WAPI_BSS);
3146 }
3147#endif /* FEATURE_WLAN_WAPI */
3148
3149 return;
3150}
3151
3152
3153static tCsrScanResult *csrScanSaveBssDescription( tpAniSirGlobal pMac, tSirBssDescription *pBSSDescription,
3154 tDot11fBeaconIEs *pIes)
3155{
3156 tCsrScanResult *pCsrBssDescription = NULL;
3157 tANI_U32 cbBSSDesc;
3158 tANI_U32 cbAllocated;
Jeff Johnson295189b2012-06-20 16:38:30 -07003159
3160 // figure out how big the BSS description is (the BSSDesc->length does NOT
3161 // include the size of the length field itself).
3162 cbBSSDesc = pBSSDescription->length + sizeof( pBSSDescription->length );
3163
3164 cbAllocated = sizeof( tCsrScanResult ) + cbBSSDesc;
3165
Kiet Lam64c1b492013-07-12 13:56:44 +05303166 pCsrBssDescription = vos_mem_malloc(cbAllocated);
3167 if ( NULL != pCsrBssDescription )
Jeff Johnson295189b2012-06-20 16:38:30 -07003168 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303169 vos_mem_set(pCsrBssDescription, cbAllocated, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003170 pCsrBssDescription->AgingCount = (tANI_S32)pMac->roam.configParam.agingCount;
Kiet Lam64c1b492013-07-12 13:56:44 +05303171 vos_mem_copy(&pCsrBssDescription->Result.BssDescriptor, pBSSDescription, cbBSSDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07003172#if defined(VOSS_ENSBALED)
3173 VOS_ASSERT( pCsrBssDescription->Result.pvIes == NULL );
3174#endif
3175 csrScanAddResult(pMac, pCsrBssDescription, pIes);
3176 }
3177
3178 return( pCsrBssDescription );
3179}
3180
3181// Append a Bss Description...
3182tCsrScanResult *csrScanAppendBssDescription( tpAniSirGlobal pMac,
3183 tSirBssDescription *pSirBssDescription,
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07003184 tDot11fBeaconIEs *pIes, tANI_BOOLEAN fForced )
Jeff Johnson295189b2012-06-20 16:38:30 -07003185{
3186 tCsrScanResult *pCsrBssDescription = NULL;
3187 tAniSSID tmpSsid;
3188 v_TIME_t timer = 0;
3189 int result;
3190
3191 tmpSsid.length = 0;
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07003192 result = csrRemoveDupBssDescription( pMac, pSirBssDescription, pIes, &tmpSsid, &timer, fForced );
Jeff Johnson295189b2012-06-20 16:38:30 -07003193 pCsrBssDescription = csrScanSaveBssDescription( pMac, pSirBssDescription, pIes );
3194 if (result && (pCsrBssDescription != NULL))
3195 {
3196 //Check if the new one has SSID it it, if not, use the older SSID if it exists.
3197 if( (0 == pCsrBssDescription->Result.ssId.length) && tmpSsid.length )
3198 {
3199 //New BSS has a hidden SSID and old one has the SSID. Keep the SSID only
3200 //if diff of saved SSID time and current time is less than 1 min to avoid
3201 //side effect of saving SSID with old one is that if AP changes its SSID while remain
3202 //hidden, we may never see it and also to address the requirement of
3203 //When we remove hidden ssid from the profile i.e., forget the SSID via
3204 // GUI that SSID shouldn't see in the profile
3205 if((vos_timer_get_system_time()-timer) <= HIDDEN_TIMER)
3206 {
3207 pCsrBssDescription->Result.ssId = tmpSsid;
3208 pCsrBssDescription->Result.timer = timer;
3209 }
3210 }
3211 }
3212
3213
3214 return( pCsrBssDescription );
3215}
3216
3217
3218
3219void csrPurgeChannelPower( tpAniSirGlobal pMac, tDblLinkList *pChannelList )
3220{
3221 tCsrChannelPowerInfo *pChannelSet;
3222 tListElem *pEntry;
3223
3224 csrLLLock(pChannelList);
3225 // Remove the channel sets from the learned list and put them in the free list
3226 while( ( pEntry = csrLLRemoveHead( pChannelList, LL_ACCESS_NOLOCK ) ) != NULL)
3227 {
3228 pChannelSet = GET_BASE_ADDR( pEntry, tCsrChannelPowerInfo, link );
3229 if( pChannelSet )
3230 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303231 vos_mem_free(pChannelSet);
Jeff Johnson295189b2012-06-20 16:38:30 -07003232 }
3233 }
3234 csrLLUnlock(pChannelList);
3235 return;
3236}
3237
3238
3239/*
3240 * Save the channelList into the ultimate storage as the final stage of channel
3241 * Input: pCountryInfo -- the country code (e.g. "USI"), channel list, and power limit are all stored inside this data structure
3242 */
Jeff Johnsone7245742012-09-05 17:12:55 -07003243eHalStatus csrSaveToChannelPower2G_5G( tpAniSirGlobal pMac, tANI_U32 tableSize, tSirMacChanInfo *channelTable )
Jeff Johnson295189b2012-06-20 16:38:30 -07003244{
3245 tANI_U32 i = tableSize / sizeof( tSirMacChanInfo );
3246 tSirMacChanInfo *pChannelInfo;
3247 tCsrChannelPowerInfo *pChannelSet;
3248 tANI_BOOLEAN f2GHzInfoFound = FALSE;
3249 tANI_BOOLEAN f2GListPurged = FALSE, f5GListPurged = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003250
3251 pChannelInfo = channelTable;
3252 // atleast 3 bytes have to be remaining -- from "countryString"
3253 while ( i-- )
3254 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303255 pChannelSet = vos_mem_malloc(sizeof(tCsrChannelPowerInfo));
3256 if ( NULL != pChannelSet )
Jeff Johnson295189b2012-06-20 16:38:30 -07003257 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303258 vos_mem_set(pChannelSet, sizeof(tCsrChannelPowerInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003259 pChannelSet->firstChannel = pChannelInfo->firstChanNum;
3260 pChannelSet->numChannels = pChannelInfo->numChannels;
3261
3262 // Now set the inter-channel offset based on the frequency band the channel set lies in
Jeff Johnsone7245742012-09-05 17:12:55 -07003263 if( (CSR_IS_CHANNEL_24GHZ(pChannelSet->firstChannel)) &&
Madan Mohan Koyyalamudi5904d7c2012-09-24 13:49:03 -07003264 ((pChannelSet->firstChannel + (pChannelSet->numChannels - 1)) <= CSR_MAX_24GHz_CHANNEL_NUMBER) )
Jeff Johnsone7245742012-09-05 17:12:55 -07003265
Jeff Johnson295189b2012-06-20 16:38:30 -07003266 {
3267 pChannelSet->interChannelOffset = 1;
3268 f2GHzInfoFound = TRUE;
3269 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003270 else if ( (CSR_IS_CHANNEL_5GHZ(pChannelSet->firstChannel)) &&
Madan Mohan Koyyalamudi5904d7c2012-09-24 13:49:03 -07003271 ((pChannelSet->firstChannel + ((pChannelSet->numChannels - 1) * 4)) <= CSR_MAX_5GHz_CHANNEL_NUMBER) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003272 {
3273 pChannelSet->interChannelOffset = 4;
3274 f2GHzInfoFound = FALSE;
3275 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003276 else
3277 {
Madan Mohan Koyyalamudi5904d7c2012-09-24 13:49:03 -07003278 smsLog( pMac, LOGW, FL("Invalid Channel %d Present in Country IE"),
Jeff Johnsone7245742012-09-05 17:12:55 -07003279 pChannelSet->firstChannel);
Kiet Lam64c1b492013-07-12 13:56:44 +05303280 vos_mem_free(pChannelSet);
Jeff Johnsone7245742012-09-05 17:12:55 -07003281 return eHAL_STATUS_FAILURE;
3282 }
3283
Jeff Johnson295189b2012-06-20 16:38:30 -07003284 pChannelSet->txPower = CSR_ROAM_MIN( pChannelInfo->maxTxPower, pMac->roam.configParam.nTxPowerCap );
3285
3286 if( f2GHzInfoFound )
3287 {
3288 if( !f2GListPurged )
3289 {
3290 // purge previous results if found new
3291 csrPurgeChannelPower( pMac, &pMac->scan.channelPowerInfoList24 );
3292 f2GListPurged = TRUE;
3293 }
3294
3295 if(CSR_IS_OPERATING_BG_BAND(pMac))
3296 {
3297 // add to the list of 2.4 GHz channel sets
3298 csrLLInsertTail( &pMac->scan.channelPowerInfoList24, &pChannelSet->link, LL_ACCESS_LOCK );
3299 }
3300 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003301 smsLog( pMac, LOGW, FL("Adding 11B/G channels in 11A mode -- First Channel is %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003302 pChannelSet->firstChannel);
Kiet Lam64c1b492013-07-12 13:56:44 +05303303 vos_mem_free(pChannelSet);
Jeff Johnson295189b2012-06-20 16:38:30 -07003304 }
3305 }
3306 else
3307 {
3308 // 5GHz info found
3309 if( !f5GListPurged )
3310 {
3311 // purge previous results if found new
3312 csrPurgeChannelPower( pMac, &pMac->scan.channelPowerInfoList5G );
3313 f5GListPurged = TRUE;
3314 }
3315
3316 if(CSR_IS_OPERATING_A_BAND(pMac))
3317 {
3318 // add to the list of 5GHz channel sets
3319 csrLLInsertTail( &pMac->scan.channelPowerInfoList5G, &pChannelSet->link, LL_ACCESS_LOCK );
3320 }
3321 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003322 smsLog( pMac, LOGW, FL("Adding 11A channels in B/G mode -- First Channel is %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003323 pChannelSet->firstChannel);
Kiet Lam64c1b492013-07-12 13:56:44 +05303324 vos_mem_free(pChannelSet);
Jeff Johnson295189b2012-06-20 16:38:30 -07003325 }
3326 }
3327 }
3328
3329 pChannelInfo++; // move to next entry
3330 }
3331
Jeff Johnsone7245742012-09-05 17:12:55 -07003332 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003333}
3334
Gopichand Nakkalac178ac82013-05-30 19:53:39 +05303335static void csrClearDfsChannelList( tpAniSirGlobal pMac )
3336{
3337 tSirMbMsg *pMsg;
3338 tANI_U16 msgLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003339
Gopichand Nakkalac178ac82013-05-30 19:53:39 +05303340 msgLen = (tANI_U16)(sizeof( tSirMbMsg ));
Kiet Lam64c1b492013-07-12 13:56:44 +05303341 pMsg = vos_mem_malloc(msgLen);
3342 if ( NULL != pMsg )
Gopichand Nakkalac178ac82013-05-30 19:53:39 +05303343 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303344 vos_mem_set((void *)pMsg, msgLen, 0);
Gopichand Nakkalac178ac82013-05-30 19:53:39 +05303345 pMsg->type = pal_cpu_to_be16((tANI_U16)eWNI_SME_CLEAR_DFS_CHANNEL_LIST);
3346 pMsg->msgLen = pal_cpu_to_be16(msgLen);
3347 palSendMBMessage(pMac->hHdd, pMsg);
3348 }
3349}
Jeff Johnson295189b2012-06-20 16:38:30 -07003350
3351void csrApplyPower2Current( tpAniSirGlobal pMac )
3352{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003353 smsLog( pMac, LOG3, FL(" Updating Cfg with power settings"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003354 csrSaveTxPowerToCfg( pMac, &pMac->scan.channelPowerInfoList24, WNI_CFG_MAX_TX_POWER_2_4 );
3355 csrSaveTxPowerToCfg( pMac, &pMac->scan.channelPowerInfoList5G, WNI_CFG_MAX_TX_POWER_5 );
3356}
3357
3358
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08003359void csrApplyChannelPowerCountryInfo( tpAniSirGlobal pMac, tCsrChannel *pChannelList, tANI_U8 *countryCode, tANI_BOOLEAN updateRiva)
Jeff Johnson295189b2012-06-20 16:38:30 -07003360{
Gopichand Nakkala10ba6fc2013-04-23 20:30:01 +05303361 int i, j, count, countryIndex = -1;
Jeff Johnson295189b2012-06-20 16:38:30 -07003362 eNVChannelEnabledType channelEnabledType;
3363 tANI_U8 numChannels = 0;
3364 tANI_U8 tempNumChannels = 0;
Gopichand Nakkala10ba6fc2013-04-23 20:30:01 +05303365 tANI_U8 channelIgnore = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003366 tCsrChannel ChannelList;
Gopichand Nakkala10ba6fc2013-04-23 20:30:01 +05303367
Jeff Johnson295189b2012-06-20 16:38:30 -07003368 if( pChannelList->numChannels )
3369 {
Gopichand Nakkala10ba6fc2013-04-23 20:30:01 +05303370 for(count=0; count < MAX_COUNTRY_IGNORE; count++)
3371 {
3372 if(vos_mem_compare(countryCode, countryIgnoreList[count].countryCode,
3373 VOS_COUNTRY_CODE_LEN))
3374 {
3375 countryIndex = count;
3376 break;
3377 }
3378 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003379 tempNumChannels = CSR_MIN(pChannelList->numChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN);
3380 /* If user doesn't want to scan the DFS channels lets trim them from
3381 the valid channel list*/
Gopichand Nakkala10ba6fc2013-04-23 20:30:01 +05303382 for(i=0; i < tempNumChannels; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07003383 {
Gopichand Nakkala10ba6fc2013-04-23 20:30:01 +05303384 channelIgnore = FALSE;
3385 if( FALSE == pMac->scan.fEnableDFSChnlScan )
3386 {
3387 channelEnabledType =
3388 vos_nv_getChannelEnabledState(pChannelList->channelList[i]);
3389 }
3390 else
3391 {
Madan Mohan Koyyalamudi3f65e312012-11-06 15:31:12 -08003392 channelEnabledType = NV_CHANNEL_ENABLE;
Gopichand Nakkala10ba6fc2013-04-23 20:30:01 +05303393 }
3394 if( NV_CHANNEL_ENABLE == channelEnabledType )
3395 {
3396 if( countryIndex != -1 )
3397 {
3398 for(j=0; j < countryIgnoreList[countryIndex].channelCount; j++)
3399 {
3400 if( pChannelList->channelList[i] ==
3401 countryIgnoreList[countryIndex].channelList[j] )
3402 {
3403 channelIgnore = TRUE;
3404 break;
3405 }
3406 }
3407 }
3408 if( FALSE == channelIgnore )
3409 {
3410 ChannelList.channelList[numChannels] = pChannelList->channelList[i];
3411 numChannels++;
3412 }
3413 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003414 }
Gopichand Nakkala10ba6fc2013-04-23 20:30:01 +05303415 ChannelList.numChannels = numChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07003416 csrSetCfgValidChannelList(pMac, ChannelList.channelList, ChannelList.numChannels);
3417 // extend scan capability
Gopichand Nakkala10ba6fc2013-04-23 20:30:01 +05303418 // build a scan list based on the channel list : channel# + active/passive scan
3419 csrSetCfgScanControlList(pMac, countryCode, &ChannelList);
Gopichand Nakkalac178ac82013-05-30 19:53:39 +05303420 /*Send msg to Lim to clear DFS channel list */
3421 csrClearDfsChannelList(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07003422#ifdef FEATURE_WLAN_SCAN_PNO
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08003423 if (updateRiva)
3424 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003425 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, FL(" Sending 11d PNO info to Riva"));
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08003426 // Send HAL UpdateScanParams message
3427 pmcUpdateScanParams(pMac, &(pMac->roam.configParam), &ChannelList, TRUE);
3428 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003429#endif // FEATURE_WLAN_SCAN_PNO
3430 }
3431 else
3432 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003433 smsLog( pMac, LOGE, FL(" 11D channel list is empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003434 }
3435 csrApplyPower2Current( pMac ); // Store the channel+power info in the global place: Cfg
3436 csrSetCfgCountryCode(pMac, countryCode);
3437}
3438
3439
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08003440void csrResetCountryInformation( tpAniSirGlobal pMac, tANI_BOOLEAN fForce, tANI_BOOLEAN updateRiva )
Jeff Johnson295189b2012-06-20 16:38:30 -07003441{
3442 if( fForce || (csrIs11dSupported( pMac ) && (!pMac->scan.f11dInfoReset)))
3443 {
3444
3445#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
3446 {
3447 vos_log_802_11d_pkt_type *p11dLog;
3448 int Index;
3449
3450 WLAN_VOS_DIAG_LOG_ALLOC(p11dLog, vos_log_802_11d_pkt_type, LOG_WLAN_80211D_C);
3451 if(p11dLog)
3452 {
3453 p11dLog->eventId = WLAN_80211D_EVENT_RESET;
Kiet Lam64c1b492013-07-12 13:56:44 +05303454 vos_mem_copy(p11dLog->countryCode, pMac->scan.countryCodeCurrent, 3);
Jeff Johnson295189b2012-06-20 16:38:30 -07003455 p11dLog->numChannel = pMac->scan.base20MHzChannels.numChannels;
3456 if(p11dLog->numChannel <= VOS_LOG_MAX_NUM_CHANNEL)
3457 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303458 vos_mem_copy(p11dLog->Channels,
3459 pMac->scan.base20MHzChannels.channelList,
3460 p11dLog->numChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07003461 for (Index=0; Index < pMac->scan.base20MHzChannels.numChannels; Index++)
3462 {
3463 p11dLog->TxPwr[Index] = CSR_ROAM_MIN( pMac->scan.defaultPowerTable[Index].pwr, pMac->roam.configParam.nTxPowerCap );
3464 }
3465 }
3466 if(!pMac->roam.configParam.Is11dSupportEnabled)
3467 {
3468 p11dLog->supportMultipleDomain = WLAN_80211D_DISABLED;
3469 }
3470 else if(pMac->roam.configParam.fEnforceDefaultDomain)
3471 {
3472 p11dLog->supportMultipleDomain = WLAN_80211D_NOT_SUPPORT_MULTI_DOMAIN;
3473 }
3474 else
3475 {
3476 p11dLog->supportMultipleDomain = WLAN_80211D_SUPPORT_MULTI_DOMAIN;
3477 }
3478 WLAN_VOS_DIAG_LOG_REPORT(p11dLog);
3479 }
3480 }
3481#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
3482
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003483 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
3484 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
3485
Jeff Johnson295189b2012-06-20 16:38:30 -07003486 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
3487 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
3488 // ... and apply the channel list, power settings, and the country code.
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08003489 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, updateRiva );
Jeff Johnson295189b2012-06-20 16:38:30 -07003490 // clear the 11d channel list
Kiet Lam64c1b492013-07-12 13:56:44 +05303491 vos_mem_set(&pMac->scan.channels11d, sizeof(pMac->scan.channels11d), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003492 pMac->scan.f11dInfoReset = eANI_BOOLEAN_TRUE;
3493 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE;
3494 }
3495
3496 return;
3497}
3498
3499
3500eHalStatus csrResetCountryCodeInformation(tpAniSirGlobal pMac, tANI_BOOLEAN *pfRestartNeeded)
3501{
3502 eHalStatus status = eHAL_STATUS_SUCCESS;
3503 tANI_BOOLEAN fRestart = eANI_BOOLEAN_FALSE;
3504
3505 //Use the Country code and domain from EEPROM
Kiet Lam64c1b492013-07-12 13:56:44 +05303506 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
3507 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07003508 csrSetRegulatoryDomain(pMac, pMac->scan.domainIdCurrent, &fRestart);
Jeff Johnson43971f52012-07-17 12:26:56 -07003509 if( ((eANI_BOOLEAN_FALSE == fRestart) || (pfRestartNeeded == NULL) )
3510 && !csrIsInfraConnected(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07003511 {
3512 //Only reset the country info if we don't need to restart
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08003513 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003514 }
3515 if(pfRestartNeeded)
3516 {
3517 *pfRestartNeeded = fRestart;
3518 }
3519
3520 return (status);
3521}
3522
Agrawal Ashish0b6984f2014-04-05 18:35:45 +05303523void csrClearVotesForCountryInfo(tpAniSirGlobal pMac)
3524{
3525 pMac->scan.countryCodeCount = 0;
3526 vos_mem_set(pMac->scan.votes11d,
3527 sizeof(tCsrVotes11d) * CSR_MAX_NUM_COUNTRY_CODE, 0);
3528}
3529
3530void csrAddVoteForCountryInfo(tpAniSirGlobal pMac, tANI_U8 *pCountryCode)
3531{
3532 tANI_BOOLEAN match = FALSE;
3533 tANI_U8 i;
3534
3535 /* convert to UPPER here so we are assured
3536 * the strings are always in upper case.
3537 */
3538 for( i = 0; i < 3; i++ )
3539 {
3540 pCountryCode[ i ] = (tANI_U8)csrToUpper( pCountryCode[ i ] );
3541 }
3542
3543 /* Some of the 'old' Cisco 350 series AP's advertise NA as the
3544 * country code (for North America ??). NA is not a valid country code
3545 * or domain so let's allow this by changing it to the proper
3546 * country code (which is US). We've also seen some NETGEAR AP's
3547 * that have "XX " as the country code with valid 2.4 GHz US channel
3548 * information. If we cannot find the country code advertised in the
3549 * 11d information element, let's default to US.
3550 */
3551
3552 if ( !HAL_STATUS_SUCCESS(csrGetRegulatoryDomainForCountry( pMac,
3553 pCountryCode, NULL,COUNTRY_QUERY ) ) )
3554 {
3555 pCountryCode[ 0 ] = '0';
3556 pCountryCode[ 1 ] = '0';
3557 }
3558
3559 /* We've seen some of the AP's improperly put a 0 for the
3560 * third character of the country code. spec says valid charcters are
3561 * 'O' (for outdoor), 'I' for Indoor, or ' ' (space; for either).
3562 * if we see a 0 in this third character, let's change it to a ' '.
3563 */
3564 if ( 0 == pCountryCode[ 2 ] )
3565 {
3566 pCountryCode[ 2 ] = ' ';
3567 }
3568
3569 for (i = 0; i < pMac->scan.countryCodeCount; i++)
3570 {
3571 match = (vos_mem_compare(pMac->scan.votes11d[i].countryCode,
3572 pCountryCode, 2));
3573 if(match)
3574 {
3575 break;
3576 }
3577 }
3578
3579 if (match)
3580 {
3581 pMac->scan.votes11d[i].votes++;
3582 }
3583 else
3584 {
3585 vos_mem_copy( pMac->scan.votes11d[pMac->scan.countryCodeCount].countryCode,
3586 pCountryCode, 3 );
3587 pMac->scan.votes11d[pMac->scan.countryCodeCount].votes = 1;
3588 pMac->scan.countryCodeCount++;
3589 }
3590
3591 return;
3592}
3593
3594tANI_BOOLEAN csrElectedCountryInfo(tpAniSirGlobal pMac)
3595{
3596 tANI_BOOLEAN fRet = FALSE;
3597 tANI_U8 maxVotes = 0;
3598 tANI_U8 i, j=0;
3599
3600 if (!pMac->scan.countryCodeCount)
3601 {
3602 return fRet;
3603 }
3604 maxVotes = pMac->scan.votes11d[0].votes;
3605 fRet = TRUE;
3606
3607 for(i = 1; i < pMac->scan.countryCodeCount; i++)
3608 {
3609 /* If we have a tie for max votes for 2 different country codes,
3610 * pick random.we can put some more intelligence - TBD
3611 */
3612 if (maxVotes < pMac->scan.votes11d[i].votes)
3613 {
3614 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
3615 " Votes for Country %c%c : %d\n",
3616 pMac->scan.votes11d[i].countryCode[0],
3617 pMac->scan.votes11d[i].countryCode[1],
3618 pMac->scan.votes11d[i].votes);
3619
3620 maxVotes = pMac->scan.votes11d[i].votes;
3621 j = i;
3622 fRet = TRUE;
3623 }
3624
3625 }
3626 if (fRet)
3627 {
3628 memcpy(pMac->scan.countryCodeElected,
3629 pMac->scan.votes11d[j].countryCode, WNI_CFG_COUNTRY_CODE_LEN);
3630 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
3631 "Selected Country is %c%c With count %d\n",
3632 pMac->scan.votes11d[j].countryCode[0],
3633 pMac->scan.votes11d[j].countryCode[1],
3634 pMac->scan.votes11d[j].votes);
3635 }
3636 return fRet;
3637}
Jeff Johnson295189b2012-06-20 16:38:30 -07003638
3639eHalStatus csrSetCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry, tANI_BOOLEAN *pfRestartNeeded)
3640{
3641 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
3642 v_REGDOMAIN_t domainId;
3643
3644 if(pCountry)
3645 {
Kiet Lam6c583332013-10-14 05:37:09 +05303646 status = csrGetRegulatoryDomainForCountry(pMac, pCountry, &domainId, COUNTRY_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -07003647 if(HAL_STATUS_SUCCESS(status))
3648 {
3649 status = csrSetRegulatoryDomain(pMac, domainId, pfRestartNeeded);
3650 if(HAL_STATUS_SUCCESS(status))
3651 {
3652 //We don't need to check the pMac->roam.configParam.fEnforceDefaultDomain flag here,
3653 //csrSetRegulatoryDomain will fail if the country doesn't fit our domain criteria.
Kiet Lam64c1b492013-07-12 13:56:44 +05303654 vos_mem_copy(pMac->scan.countryCodeCurrent, pCountry, WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07003655 if((pfRestartNeeded == NULL) || !(*pfRestartNeeded))
3656 {
3657 //Simply set it to cfg. If we need to restart, restart will apply it to the CFG
3658 csrSetCfgCountryCode(pMac, pCountry);
3659 }
3660 }
3661 }
3662 }
3663
3664 return (status);
3665}
3666
3667
3668
3669//caller allocated memory for pNumChn and pChnPowerInfo
3670//As input, *pNumChn has the size of the array of pChnPowerInfo
3671//Upon return, *pNumChn has the number of channels assigned.
3672void csrGetChannelPowerInfo( tpAniSirGlobal pMac, tDblLinkList *pList,
3673 tANI_U32 *pNumChn, tChannelListWithPower *pChnPowerInfo)
3674{
3675 tListElem *pEntry;
3676 tANI_U32 chnIdx = 0, idx;
3677 tCsrChannelPowerInfo *pChannelSet;
3678
3679 //Get 2.4Ghz first
3680 pEntry = csrLLPeekHead( pList, LL_ACCESS_LOCK );
3681 while( pEntry && (chnIdx < *pNumChn) )
3682 {
3683 pChannelSet = GET_BASE_ADDR( pEntry, tCsrChannelPowerInfo, link );
3684 if ( 1 != pChannelSet->interChannelOffset )
3685 {
3686 for( idx = 0; (idx < pChannelSet->numChannels) && (chnIdx < *pNumChn); idx++ )
3687 {
3688 pChnPowerInfo[chnIdx].chanId = (tANI_U8)(pChannelSet->firstChannel + ( idx * pChannelSet->interChannelOffset ));
3689 pChnPowerInfo[chnIdx++].pwr = pChannelSet->txPower;
3690 }
3691 }
3692 else
3693 {
3694 for( idx = 0; (idx < pChannelSet->numChannels) && (chnIdx < *pNumChn); idx++ )
3695 {
3696 pChnPowerInfo[chnIdx].chanId = (tANI_U8)(pChannelSet->firstChannel + idx);
3697 pChnPowerInfo[chnIdx++].pwr = pChannelSet->txPower;
3698 }
3699 }
3700
3701 pEntry = csrLLNext( pList, pEntry, LL_ACCESS_LOCK );
3702 }
3703 *pNumChn = chnIdx;
3704
3705 return ;
3706}
3707
3708
3709
3710void csrApplyCountryInformation( tpAniSirGlobal pMac, tANI_BOOLEAN fForce )
3711{
3712 v_REGDOMAIN_t domainId;
3713 eHalStatus status = eHAL_STATUS_SUCCESS;
3714
3715 do
3716 {
3717 if( !csrIs11dSupported( pMac ) || 0 == pMac->scan.channelOf11dInfo) break;
3718 if( pMac->scan.fAmbiguous11dInfoFound )
3719 {
3720 // ambiguous info found
3721 //Restore te default domain as well
Kiet Lam6c583332013-10-14 05:37:09 +05303722 if(HAL_STATUS_SUCCESS(csrGetRegulatoryDomainForCountry(
3723 pMac, pMac->scan.countryCodeCurrent,
3724 &domainId, COUNTRY_QUERY)))
Jeff Johnson295189b2012-06-20 16:38:30 -07003725 {
3726 pMac->scan.domainIdCurrent = domainId;
3727 }
3728 else
3729 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003730 smsLog(pMac, LOGE, FL(" failed to get domain from currentCountryCode %02X%02X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003731 pMac->scan.countryCodeCurrent[0], pMac->scan.countryCodeCurrent[1]);
3732 }
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08003733 csrResetCountryInformation( pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07003734 break;
3735 }
3736 if ( pMac->scan.f11dInfoApplied && !fForce ) break;
Kiet Lam6c583332013-10-14 05:37:09 +05303737 if(HAL_STATUS_SUCCESS(csrGetRegulatoryDomainForCountry(
3738 pMac, pMac->scan.countryCode11d,
3739 &domainId, COUNTRY_QUERY)))
Jeff Johnson295189b2012-06-20 16:38:30 -07003740 {
3741 //Check whether we need to enforce default domain
3742 if( ( !pMac->roam.configParam.fEnforceDefaultDomain ) ||
3743 (pMac->scan.domainIdCurrent == domainId) )
3744 {
3745
3746#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
3747 {
3748 vos_log_802_11d_pkt_type *p11dLog;
3749 tChannelListWithPower chnPwrInfo[WNI_CFG_VALID_CHANNEL_LIST_LEN];
3750 tANI_U32 nChnInfo = WNI_CFG_VALID_CHANNEL_LIST_LEN, nTmp;
3751
3752 WLAN_VOS_DIAG_LOG_ALLOC(p11dLog, vos_log_802_11d_pkt_type, LOG_WLAN_80211D_C);
3753 if(p11dLog)
3754 {
3755 p11dLog->eventId = WLAN_80211D_EVENT_COUNTRY_SET;
Kiet Lam64c1b492013-07-12 13:56:44 +05303756 vos_mem_copy(p11dLog->countryCode, pMac->scan.countryCode11d, 3);
Jeff Johnson295189b2012-06-20 16:38:30 -07003757 p11dLog->numChannel = pMac->scan.channels11d.numChannels;
3758 if(p11dLog->numChannel <= VOS_LOG_MAX_NUM_CHANNEL)
3759 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303760 vos_mem_copy(p11dLog->Channels,
3761 pMac->scan.channels11d.channelList,
3762 p11dLog->numChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07003763 csrGetChannelPowerInfo(pMac, &pMac->scan.channelPowerInfoList24,
3764 &nChnInfo, chnPwrInfo);
3765 nTmp = nChnInfo;
3766 nChnInfo = WNI_CFG_VALID_CHANNEL_LIST_LEN - nTmp;
3767 csrGetChannelPowerInfo(pMac, &pMac->scan.channelPowerInfoList5G,
3768 &nChnInfo, &chnPwrInfo[nTmp]);
3769 for(nTmp = 0; nTmp < p11dLog->numChannel; nTmp++)
3770 {
3771 for(nChnInfo = 0; nChnInfo < WNI_CFG_VALID_CHANNEL_LIST_LEN; nChnInfo++)
3772 {
3773 if(p11dLog->Channels[nTmp] == chnPwrInfo[nChnInfo].chanId)
3774 {
3775 p11dLog->TxPwr[nTmp] = chnPwrInfo[nChnInfo].pwr;
3776 break;
3777 }
3778 }
3779 }
3780 }
3781 if(!pMac->roam.configParam.Is11dSupportEnabled)
3782 {
3783 p11dLog->supportMultipleDomain = WLAN_80211D_DISABLED;
3784 }
3785 else if(pMac->roam.configParam.fEnforceDefaultDomain)
3786 {
3787 p11dLog->supportMultipleDomain = WLAN_80211D_NOT_SUPPORT_MULTI_DOMAIN;
3788 }
3789 else
3790 {
3791 p11dLog->supportMultipleDomain = WLAN_80211D_SUPPORT_MULTI_DOMAIN;
3792 }
3793 WLAN_VOS_DIAG_LOG_REPORT(p11dLog);
3794 }
3795 }
3796#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
3797 if(pMac->scan.domainIdCurrent != domainId)
3798 {
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05303799 smsLog(pMac, LOGW, FL("Domain Changed Old %s (%d), new %s"),
3800 voss_DomainIdtoString(pMac->scan.domainIdCurrent),
3801 pMac->scan.domainIdCurrent,
3802 voss_DomainIdtoString(domainId));
Abhishek Singha306a442013-11-07 18:39:01 +05303803 status = WDA_SetRegDomain(pMac, domainId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003804 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003805 if (status != eHAL_STATUS_SUCCESS)
3806 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003807 smsLog( pMac, LOGE, FL(" fail to set regId %d"), domainId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003808 }
3809 pMac->scan.domainIdCurrent = domainId;
Kiet Lam6c583332013-10-14 05:37:09 +05303810#ifndef CONFIG_ENABLE_LINUX_REG
Kiet Lambb14e952013-11-19 14:58:29 +05303811 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels,
3812 pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Kiet Lam6c583332013-10-14 05:37:09 +05303813#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003814 // switch to active scans using this new channel list
3815 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
3816 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_TRUE;
3817 pMac->scan.f11dInfoReset = eANI_BOOLEAN_FALSE;
3818 }
3819 }
3820
3821 } while( 0 );
3822
3823 return;
3824}
3825
3826
3827
3828tANI_BOOLEAN csrSave11dCountryString( tpAniSirGlobal pMac, tANI_U8 *pCountryCode,
3829 tANI_BOOLEAN fForce)
3830{
3831 tANI_BOOLEAN fCountryStringChanged = FALSE, fUnknownCountryCode = FALSE;
3832 tANI_U32 i;
Kiet Lam6c583332013-10-14 05:37:09 +05303833 v_REGDOMAIN_t regd;
Tushnim Bhattacharyya582ac1d2013-11-07 23:44:09 -08003834 tANI_BOOLEAN fCountryNotPresentInDriver = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003835
3836 // convert to UPPER here so we are assured the strings are always in upper case.
3837 for( i = 0; i < 3; i++ )
3838 {
3839 pCountryCode[ i ] = (tANI_U8)csrToUpper( pCountryCode[ i ] );
3840 }
3841
3842 // Some of the 'old' Cisco 350 series AP's advertise NA as the country code (for North America ??).
3843 // NA is not a valid country code or domain so let's allow this by changing it to the proper
3844 // country code (which is US). We've also seen some NETGEAR AP's that have "XX " as the country code
3845 // with valid 2.4 GHz US channel information. If we cannot find the country code advertised in the
3846 // 11d information element, let's default to US.
Kiet Lam6c583332013-10-14 05:37:09 +05303847 if ( !HAL_STATUS_SUCCESS(csrGetRegulatoryDomainForCountry(pMac,
3848 pCountryCode,
3849 &regd,
3850 COUNTRY_QUERY) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003851 {
3852 // Check the enforcement first
3853 if( pMac->roam.configParam.fEnforceDefaultDomain || pMac->roam.configParam.fEnforceCountryCodeMatch )
3854 {
3855 fUnknownCountryCode = TRUE;
3856 }
3857 else
3858 {
Tushnim Bhattacharyya582ac1d2013-11-07 23:44:09 -08003859 fCountryNotPresentInDriver = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003860 }
3861 }
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003862 //right now, even if we don't find the CC in driver we set to world. Making
3863 //sure countryCode11d doesn't get updated with the invalid CC, instead
3864 //reflect the world CC
3865 else if (REGDOMAIN_WORLD == regd)
3866 {
Tushnim Bhattacharyya582ac1d2013-11-07 23:44:09 -08003867 fCountryNotPresentInDriver = TRUE;
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003868 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003869
3870 // We've seen some of the AP's improperly put a 0 for the third character of the country code.
3871 // spec says valid charcters are 'O' (for outdoor), 'I' for Indoor, or ' ' (space; for either).
3872 // if we see a 0 in this third character, let's change it to a ' '.
3873 if ( 0 == pCountryCode[ 2 ] )
3874 {
3875 pCountryCode[ 2 ] = ' ';
3876 }
3877
3878 if( !fUnknownCountryCode )
3879 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303880 fCountryStringChanged = (!vos_mem_compare(pMac->scan.countryCode11d, pCountryCode, 2));
Jeff Johnson295189b2012-06-20 16:38:30 -07003881
3882
3883 if(( 0 == pMac->scan.countryCode11d[ 0 ] && 0 == pMac->scan.countryCode11d[ 1 ] )
3884 || (fForce))
3885 {
Tushnim Bhattacharyya582ac1d2013-11-07 23:44:09 -08003886 if (!fCountryNotPresentInDriver)
3887 {
3888 // this is the first .11d information
3889 vos_mem_copy(pMac->scan.countryCode11d, pCountryCode,
Kiet Lam64c1b492013-07-12 13:56:44 +05303890 sizeof( pMac->scan.countryCode11d ));
Tushnim Bhattacharyya582ac1d2013-11-07 23:44:09 -08003891
3892 }
3893 else
3894 {
3895 pMac->scan.countryCode11d[0] = '0';
3896 pMac->scan.countryCode11d[1] = '0';
3897 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003898 }
3899 }
3900
3901 return( fCountryStringChanged );
3902}
3903
3904
3905void csrSaveChannelPowerForBand( tpAniSirGlobal pMac, tANI_BOOLEAN fPopulate5GBand )
3906{
3907 tANI_U32 Index, count=0;
3908 tSirMacChanInfo *pChanInfo;
3909 tSirMacChanInfo *pChanInfoStart;
Leela V Kiran Kumar Reddy Chirala6a458752013-02-16 15:41:27 -08003910 tANI_S32 maxChannelIndex;
3911
3912 maxChannelIndex = ( pMac->scan.base20MHzChannels.numChannels < WNI_CFG_VALID_CHANNEL_LIST_LEN ) ?
3913 pMac->scan.base20MHzChannels.numChannels : WNI_CFG_VALID_CHANNEL_LIST_LEN ;
Jeff Johnson295189b2012-06-20 16:38:30 -07003914
Kiet Lam64c1b492013-07-12 13:56:44 +05303915 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
3916 if ( NULL != pChanInfo )
Jeff Johnson295189b2012-06-20 16:38:30 -07003917 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303918 vos_mem_set(pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003919 pChanInfoStart = pChanInfo;
Leela V Kiran Kumar Reddy Chirala6a458752013-02-16 15:41:27 -08003920 for (Index=0; Index < maxChannelIndex; Index++)
Jeff Johnson295189b2012-06-20 16:38:30 -07003921 {
3922 if ((fPopulate5GBand && (CSR_IS_CHANNEL_5GHZ(pMac->scan.defaultPowerTable[Index].chanId))) ||
3923 (!fPopulate5GBand && (CSR_IS_CHANNEL_24GHZ(pMac->scan.defaultPowerTable[Index].chanId))) )
3924 {
Leela V Kiran Kumar Reddy Chirala6a458752013-02-16 15:41:27 -08003925 if(count >= WNI_CFG_VALID_CHANNEL_LIST_LEN)
3926 {
3927 smsLog( pMac, LOGW, FL(" csrSaveChannelPowerForBand, count exceeded, count = %d"), count);
3928 break;
3929 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003930 pChanInfo->firstChanNum = pMac->scan.defaultPowerTable[Index].chanId;
3931 pChanInfo->numChannels = 1;
3932 pChanInfo->maxTxPower = CSR_ROAM_MIN( pMac->scan.defaultPowerTable[Index].pwr, pMac->roam.configParam.nTxPowerCap );
3933 pChanInfo++;
3934 count++;
3935 }
3936 }
3937 if(count)
3938 {
3939 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
3940 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303941 vos_mem_free(pChanInfoStart);
Jeff Johnson295189b2012-06-20 16:38:30 -07003942 }
3943}
3944
3945
3946void csrSetOppositeBandChannelInfo( tpAniSirGlobal pMac )
3947{
3948 tANI_BOOLEAN fPopulate5GBand = FALSE;
3949
3950 do
3951 {
3952 // if this is not a dual band product, then we don't need to set the opposite
3953 // band info. We only work in one band so no need to look in the other band.
3954 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) ) break;
3955 // if we found channel info on the 5.0 band and...
3956 if ( CSR_IS_CHANNEL_5GHZ( pMac->scan.channelOf11dInfo ) )
3957 {
3958 // and the 2.4 band is empty, then populate the 2.4 channel info
Kiet Lam8d985a02013-10-11 03:39:41 +05303959 if ( !csrLLIsListEmpty( &pMac->scan.channelPowerInfoList24, LL_ACCESS_LOCK ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003960 fPopulate5GBand = FALSE;
3961 }
3962 else
3963 {
3964 // else, we found channel info in the 2.4 GHz band. If the 5.0 band is empty
3965 // set the 5.0 band info from the 2.4 country code.
Kiet Lam8d985a02013-10-11 03:39:41 +05303966 if ( !csrLLIsListEmpty( &pMac->scan.channelPowerInfoList5G, LL_ACCESS_LOCK ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003967 fPopulate5GBand = TRUE;
3968 }
3969 csrSaveChannelPowerForBand( pMac, fPopulate5GBand );
3970
3971 } while( 0 );
3972}
3973
3974
3975tANI_BOOLEAN csrIsSupportedChannel(tpAniSirGlobal pMac, tANI_U8 channelId)
3976{
3977 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
3978 tANI_U32 i;
3979
3980 //Make sure it is a channel that is in our supported list.
3981 for ( i = 0; i < pMac->scan.baseChannels.numChannels; i++ )
3982 {
3983 if ( channelId == pMac->scan.baseChannels.channelList[i] )
3984 {
3985 fRet = eANI_BOOLEAN_TRUE;
3986 break;
3987 }
3988 }
3989
3990 //If it is configured to limit a set of the channels
3991 if( fRet && pMac->roam.configParam.fEnforce11dChannels )
3992 {
3993 fRet = eANI_BOOLEAN_FALSE;
3994 for ( i = 0; i < pMac->scan.base20MHzChannels.numChannels; i++ )
3995 {
3996 if ( channelId == pMac->scan.base20MHzChannels.channelList[i] )
3997 {
3998 fRet = eANI_BOOLEAN_TRUE;
3999 break;
4000 }
4001 }
4002 }
4003
4004 return (fRet);
4005}
4006
4007
4008
4009//bSize specify the buffer size of pChannelList
4010tANI_U8 csrGetChannelListFromChannelSet( tpAniSirGlobal pMac, tANI_U8 *pChannelList, tANI_U8 bSize, tCsrChannelPowerInfo *pChannelSet )
4011{
4012 tANI_U8 i, j = 0, chnId;
4013
4014 bSize = CSR_MIN(bSize, pChannelSet->numChannels);
4015 for( i = 0; i < bSize; i++ )
4016 {
4017 chnId = (tANI_U8)(pChannelSet->firstChannel + ( i * pChannelSet->interChannelOffset ));
4018 if ( csrIsSupportedChannel( pMac, chnId ) )
4019 {
4020 pChannelList[j++] = chnId;
4021 }
4022 }
4023
4024 return (j);
4025}
4026
4027
4028
4029//bSize -- specify the buffer size of pChannelList
4030void csrConstructCurrentValidChannelList( tpAniSirGlobal pMac, tDblLinkList *pChannelSetList,
4031 tANI_U8 *pChannelList, tANI_U8 bSize, tANI_U8 *pNumChannels )
4032{
4033 tListElem *pEntry;
4034 tCsrChannelPowerInfo *pChannelSet;
4035 tANI_U8 numChannels;
4036 tANI_U8 *pChannels;
4037
4038 if( pChannelSetList && pChannelList && pNumChannels )
4039 {
4040 pChannels = pChannelList;
4041 *pNumChannels = 0;
4042 pEntry = csrLLPeekHead( pChannelSetList, LL_ACCESS_LOCK );
4043 while( pEntry )
4044 {
4045 pChannelSet = GET_BASE_ADDR( pEntry, tCsrChannelPowerInfo, link );
4046 numChannels = csrGetChannelListFromChannelSet( pMac, pChannels, bSize, pChannelSet );
4047 pChannels += numChannels;
4048 *pNumChannels += numChannels;
4049 pEntry = csrLLNext( pChannelSetList, pEntry, LL_ACCESS_LOCK );
4050 }
4051 }
4052}
4053
4054
4055/*
4056 * 802.11D only: Gather 11d IE via beacon or Probe response and store them in pAdapter->channels11d
4057*/
Agrawal Ashish0b6984f2014-04-05 18:35:45 +05304058tANI_BOOLEAN csrLearnCountryInformation( tpAniSirGlobal pMac, tANI_BOOLEAN fForce)
Jeff Johnson295189b2012-06-20 16:38:30 -07004059{
Jeff Johnson295189b2012-06-20 16:38:30 -07004060 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
4061 v_REGDOMAIN_t domainId;
Jeff Johnson295189b2012-06-20 16:38:30 -07004062
Jeff Johnson295189b2012-06-20 16:38:30 -07004063 if (VOS_STA_SAP_MODE == vos_get_conparam ())
4064 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004065
4066 do
4067 {
4068 // check if .11d support is enabled
4069 if( !csrIs11dSupported( pMac ) ) break;
Kiet Lam6c583332013-10-14 05:37:09 +05304070#ifdef CONFIG_ENABLE_LINUX_REG
Agrawal Ashish0b6984f2014-04-05 18:35:45 +05304071 csrGetRegulatoryDomainForCountry(pMac, pMac->scan.countryCodeElected,
Kiet Lam6c583332013-10-14 05:37:09 +05304072 &domainId, COUNTRY_IE);
4073#endif
Kiet Lam6c583332013-10-14 05:37:09 +05304074#ifndef CONFIG_ENABLE_LINUX_REG
Kiet Lam8d985a02013-10-11 03:39:41 +05304075 status = csrGetRegulatoryDomainForCountry(pMac,
Agrawal Ashish0b6984f2014-04-05 18:35:45 +05304076 pMac->scan.countryCodeElected, &domainId, COUNTRY_IE);
Kiet Lam8d985a02013-10-11 03:39:41 +05304077 if ( status != eHAL_STATUS_SUCCESS )
4078 {
4079 smsLog( pMac, LOGE, FL(" fail to get regId %d"), domainId );
4080 fRet = eANI_BOOLEAN_FALSE;
4081 break;
4082 }
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07004083 // Checking for Domain Id change
4084 if ( domainId != pMac->scan.domainIdCurrent )
4085 {
Kiet Lam8d985a02013-10-11 03:39:41 +05304086 vos_mem_copy(pMac->scan.countryCode11d,
Agrawal Ashish0b6984f2014-04-05 18:35:45 +05304087 pMac->scan.countryCodeElected,
Kiet Lam8d985a02013-10-11 03:39:41 +05304088 sizeof( pMac->scan.countryCode11d ) );
4089 /* Set Current Country code and Current Regulatory domain */
4090 status = csrSetRegulatoryDomain(pMac, domainId, NULL);
4091 if (eHAL_STATUS_SUCCESS != status)
4092 {
4093 smsLog(pMac, LOGE, "Set Reg Domain Fail %d", status);
4094 fRet = eANI_BOOLEAN_FALSE;
4095 return fRet;
4096 }
4097 //csrSetRegulatoryDomain will fail if the country doesn't fit our domain criteria.
4098 vos_mem_copy(pMac->scan.countryCodeCurrent,
Agrawal Ashish0b6984f2014-04-05 18:35:45 +05304099 pMac->scan.countryCodeElected, WNI_CFG_COUNTRY_CODE_LEN);
Kiet Lam8d985a02013-10-11 03:39:41 +05304100 //Simply set it to cfg.
Agrawal Ashish0b6984f2014-04-05 18:35:45 +05304101 csrSetCfgCountryCode(pMac, pMac->scan.countryCodeElected);
Kiet Lam8d985a02013-10-11 03:39:41 +05304102
4103 /* overwrite the defualt country code */
4104 vos_mem_copy(pMac->scan.countryCodeDefault,
4105 pMac->scan.countryCodeCurrent,
4106 WNI_CFG_COUNTRY_CODE_LEN);
4107 /* Set Current RegDomain */
Abhishek Singha306a442013-11-07 18:39:01 +05304108 status = WDA_SetRegDomain(pMac, domainId, eSIR_TRUE);
Kiet Lam8d985a02013-10-11 03:39:41 +05304109 if ( status != eHAL_STATUS_SUCCESS )
4110 {
4111 smsLog( pMac, LOGE, FL(" fail to Set regId %d"), domainId );
4112 fRet = eANI_BOOLEAN_FALSE;
4113 return fRet;
4114 }
4115 /* set to default domain ID */
Madan Mohan Koyyalamudi0e5922d2013-09-10 15:45:24 +05304116 pMac->scan.domainIdCurrent = domainId;
Kiet Lam8d985a02013-10-11 03:39:41 +05304117 /* get the channels based on new cc */
4118 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07004119
Kiet Lam8d985a02013-10-11 03:39:41 +05304120 if ( status != eHAL_STATUS_SUCCESS )
4121 {
4122 smsLog( pMac, LOGE, FL(" fail to get Channels "));
4123 fRet = eANI_BOOLEAN_FALSE;
4124 return fRet;
4125 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004126
Kiet Lam8d985a02013-10-11 03:39:41 +05304127 /* reset info based on new cc, and we are done */
4128 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE);
Agarwal Ashishfaef6692014-01-29 19:40:30 +05304129 /* Regulatory Domain Changed, Purge Only scan result
4130 * which does not have channel number belong to 11d
4131 * channel list
4132 */
Srinivas, Dasari42bf7702014-02-07 11:29:53 +05304133 csrScanFilterResults(pMac);
Kiet Lam8d985a02013-10-11 03:39:41 +05304134 }
Kiet Lam6c583332013-10-14 05:37:09 +05304135#endif
4136 fRet = eANI_BOOLEAN_TRUE;
4137
Jeff Johnson295189b2012-06-20 16:38:30 -07004138 } while( 0 );
4139
Jeff Johnson295189b2012-06-20 16:38:30 -07004140
4141 return( fRet );
4142}
4143
4144
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004145static void csrSaveScanResults( tpAniSirGlobal pMac, tANI_U8 reason )
Jeff Johnson295189b2012-06-20 16:38:30 -07004146{
4147 // initialize this to FALSE. profMoveInterimScanResultsToMainList() routine
4148 // will set this to the channel where an .11d beacon is seen
4149 pMac->scan.channelOf11dInfo = 0;
4150 // if we get any ambiguous .11d information then this will be set to TRUE
4151 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
4152 //Tush
4153 // if we get any ambiguous .11d information, then this will be set to TRUE
4154 // only if the applied 11d info could be found in one of the scan results
4155 pMac->scan.fCurrent11dInfoMatch = eANI_BOOLEAN_FALSE;
4156 // move the scan results from interim list to the main scan list
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004157 csrMoveTempScanResultsToMainList( pMac, reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004158}
4159
4160
4161void csrReinitScanCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4162{
4163 switch (pCommand->u.scanCmd.reason)
4164 {
4165 case eCsrScanSetBGScanParam:
4166 case eCsrScanAbortBgScan:
4167 if(pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList)
4168 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304169 vos_mem_free(pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList);
Jeff Johnson295189b2012-06-20 16:38:30 -07004170 pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList = NULL;
4171 }
4172 break;
4173 case eCsrScanBGScanAbort:
4174 case eCsrScanBGScanEnable:
4175 case eCsrScanGetScanChnInfo:
4176 break;
4177 case eCsrScanAbortNormalScan:
4178 default:
4179 csrScanFreeRequest(pMac, &pCommand->u.scanCmd.u.scanRequest);
4180 break;
4181 }
4182 if(pCommand->u.scanCmd.pToRoamProfile)
4183 {
4184 csrReleaseProfile(pMac, pCommand->u.scanCmd.pToRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05304185 vos_mem_free(pCommand->u.scanCmd.pToRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07004186 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304187 vos_mem_set(&pCommand->u.scanCmd, sizeof(tScanCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004188}
4189
4190
4191tANI_BOOLEAN csrGetRemainingChannelsFor11dScan( tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U8 *pcChannels )
4192{
4193 tANI_U32 index11dChannels, index;
4194 tANI_U32 indexCurrentChannels;
4195 tANI_BOOLEAN fChannelAlreadyScanned;
4196 tANI_U32 len = sizeof(pMac->roam.validChannelList);
4197
4198 *pcChannels = 0;
4199 if ( CSR_IS_11D_INFO_FOUND(pMac) && csrRoamIsChannelValid(pMac, pMac->scan.channelOf11dInfo) )
4200 {
4201 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
4202 {
4203 //Find the channel index where we found the 11d info
4204 for(index = 0; index < len; index++)
4205 {
4206 if(pMac->scan.channelOf11dInfo == pMac->roam.validChannelList[index])
4207 break;
4208 }
4209 //check whether we found the channel index
4210 if(index < len)
4211 {
4212 // Now, look through the 11d channel list and create a list of all channels in the 11d list that are
4213 // NOT in the current channel list. This gives us a list of the new channels that have not been
4214 // scanned. We'll scan this new list so we have a complete set of scan results on all of the domain channels
4215 // initially.
4216 for ( index11dChannels = 0; index11dChannels < pMac->scan.channels11d.numChannels; index11dChannels++ )
4217 {
4218 fChannelAlreadyScanned = eANI_BOOLEAN_FALSE;
4219
4220 for( indexCurrentChannels = 0; indexCurrentChannels < index; indexCurrentChannels++ )
4221 {
4222 if ( pMac->roam.validChannelList[ indexCurrentChannels ] == pMac->scan.channels11d.channelList[ index11dChannels ] )
4223 {
4224 fChannelAlreadyScanned = eANI_BOOLEAN_TRUE;
4225 break;
4226 }
4227 }
4228
4229 if ( !fChannelAlreadyScanned )
4230 {
4231 pChannels[ *pcChannels ] = pMac->scan.channels11d.channelList[ index11dChannels ];
4232 ( *pcChannels )++;
4233 }
4234 }
4235 }
4236 }//GetCFG
4237 }
4238 return( *pcChannels );
4239}
4240
4241
4242eCsrScanCompleteNextCommand csrScanGetNextCommandState( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fSuccess )
4243{
4244 eCsrScanCompleteNextCommand NextCommand = eCsrNextScanNothing;
4245
4246 switch( pCommand->u.scanCmd.reason )
4247 {
4248 case eCsrScan11d1:
4249 NextCommand = (fSuccess) ? eCsrNext11dScan1Success : eCsrNext11dScan1Failure;
4250 break;
4251 case eCsrScan11d2:
4252 NextCommand = (fSuccess) ? eCsrNext11dScan2Success : eCsrNext11dScan2Failure;
4253 break;
4254 case eCsrScan11dDone:
4255 NextCommand = eCsrNext11dScanComplete;
4256 break;
4257 case eCsrScanLostLink1:
4258 NextCommand = (fSuccess) ? eCsrNextLostLinkScan1Success : eCsrNextLostLinkScan1Failed;
4259 break;
4260 case eCsrScanLostLink2:
4261 NextCommand = (fSuccess) ? eCsrNextLostLinkScan2Success : eCsrNextLostLinkScan2Failed;
4262 break;
4263 case eCsrScanLostLink3:
4264 NextCommand = (fSuccess) ? eCsrNextLostLinkScan3Success : eCsrNextLostLinkScan3Failed;
4265 break;
4266 case eCsrScanForSsid:
4267 NextCommand = (fSuccess) ? eCsrNexteScanForSsidSuccess : eCsrNexteScanForSsidFailure;
4268 break;
4269 case eCsrScanForCapsChange:
4270 NextCommand = eCsrNextCapChangeScanComplete; //don't care success or not
4271 break;
4272 case eCsrScanIdleScan:
4273 NextCommand = eCsrNextIdleScanComplete;
4274 break;
4275 default:
4276 NextCommand = eCsrNextScanNothing;
4277 break;
4278 }
4279 return( NextCommand );
4280}
4281
4282
4283//Return whether the pCommand is finished.
4284tANI_BOOLEAN csrHandleScan11d1Failure(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4285{
4286 tANI_BOOLEAN fRet = eANI_BOOLEAN_TRUE;
4287
4288 //Apply back the default setting and passively scan one more time.
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08004289 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004290 pCommand->u.scanCmd.reason = eCsrScan11d2;
4291 if(HAL_STATUS_SUCCESS(csrScanChannels(pMac, pCommand)))
4292 {
4293 fRet = eANI_BOOLEAN_FALSE;
4294 }
4295
4296 return (fRet);
4297}
4298
4299
4300tANI_BOOLEAN csrHandleScan11dSuccess(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4301{
4302 tANI_BOOLEAN fRet = eANI_BOOLEAN_TRUE;
4303 tANI_U8 *pChannels;
4304 tANI_U8 cChannels;
4305
Kiet Lam64c1b492013-07-12 13:56:44 +05304306 pChannels = vos_mem_malloc(WNI_CFG_VALID_CHANNEL_LIST_LEN);
4307 if ( NULL != pChannels )
Jeff Johnson295189b2012-06-20 16:38:30 -07004308 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304309 vos_mem_set(pChannels, WNI_CFG_VALID_CHANNEL_LIST_LEN, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004310 if ( csrGetRemainingChannelsFor11dScan( pMac, pChannels, &cChannels ) )
4311 {
4312 pCommand->u.scanCmd.reason = eCsrScan11dDone;
4313 if(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList)
4314 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304315 vos_mem_free(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList);
James Zmuda9ea1edd2013-04-18 18:20:54 -07004316 pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004317 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304318 pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = vos_mem_malloc(cChannels);
4319 if ( NULL != pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList )
Jeff Johnson295189b2012-06-20 16:38:30 -07004320 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304321 vos_mem_copy(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList,
4322 pChannels, cChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07004323 pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = cChannels;
4324 pCommand->u.scanCmd.u.scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
4325 pCommand->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN;
4326 if(HAL_STATUS_SUCCESS(csrScanChannels(pMac, pCommand)))
4327 {
4328 //Reuse the same command buffer
4329 fRet = eANI_BOOLEAN_FALSE;
4330 }
4331 }
4332 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304333 vos_mem_free(pChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07004334 }
4335
4336 return (fRet);
4337}
4338
4339//Return whether the command should be removed
4340tANI_BOOLEAN csrScanComplete( tpAniSirGlobal pMac, tSirSmeScanRsp *pScanRsp )
4341{
4342 eCsrScanCompleteNextCommand NextCommand = eCsrNextScanNothing;
4343 tListElem *pEntry;
4344 tSmeCmd *pCommand;
4345 tANI_BOOLEAN fRemoveCommand = eANI_BOOLEAN_TRUE;
4346 tANI_BOOLEAN fSuccess;
4347
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +05304348 if (pMac->fScanOffload)
4349 pEntry = csrLLPeekHead(&pMac->sme.smeScanCmdActiveList, LL_ACCESS_LOCK);
4350 else
4351 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
Jeff Johnson295189b2012-06-20 16:38:30 -07004352
4353 if ( pEntry )
4354 {
4355 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
4356
4357 // If the head of the queue is Active and it is a SCAN command, remove
4358 // and put this on the Free queue.
4359 if ( eSmeCommandScan == pCommand->command )
4360 {
4361 tANI_U32 sessionId = pCommand->sessionId;
4362
4363 if(eSIR_SME_SUCCESS != pScanRsp->statusCode)
4364 {
4365 fSuccess = eANI_BOOLEAN_FALSE;
4366 }
4367 else
4368 {
4369 //pMac->scan.tempScanResults is not empty meaning the scan found something
4370 //This check only valid here because csrSaveScanresults is not yet called
4371 fSuccess = (!csrLLIsListEmpty(&pMac->scan.tempScanResults, LL_ACCESS_LOCK));
4372 }
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05304373 if (pCommand->u.scanCmd.abortScanDueToBandChange)
4374 {
4375 /*
4376 * Scan aborted due to band change
4377 * The scan results need to be flushed
4378 */
4379 if (pCommand->u.scanCmd.callback
4380 != pMac->scan.callback11dScanDone)
4381 {
4382 smsLog(pMac, LOG1, FL("Filtering the scan results as the "
4383 "results may belong to wrong band"));
4384 csrScanFilterResults(pMac);
4385 }
4386 else
4387 {
4388 smsLog(pMac, LOG1, FL("11d_scan_done will flush the scan"
4389 " results"));
4390 }
4391 pCommand->u.scanCmd.abortScanDueToBandChange
4392 = eANI_BOOLEAN_FALSE;
4393 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004394 csrSaveScanResults(pMac, pCommand->u.scanCmd.reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07004395
4396#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
4397 {
4398 vos_log_scan_pkt_type *pScanLog = NULL;
4399 tScanResultHandle hScanResult;
4400 tCsrScanResultInfo *pScanResult;
4401 tDot11fBeaconIEs *pIes;
4402 int n = 0, c = 0;
4403
4404 WLAN_VOS_DIAG_LOG_ALLOC(pScanLog, vos_log_scan_pkt_type, LOG_WLAN_SCAN_C);
4405 if(pScanLog)
4406 {
4407 if(eCsrScanBgScan == pCommand->u.scanCmd.reason ||
4408 eCsrScanProbeBss == pCommand->u.scanCmd.reason ||
4409 eCsrScanSetBGScanParam == pCommand->u.scanCmd.reason)
4410 {
4411 pScanLog->eventId = WLAN_SCAN_EVENT_HO_SCAN_RSP;
4412 }
4413 else
4414 {
4415 if( eSIR_PASSIVE_SCAN != pMac->scan.curScanType )
4416 {
4417 pScanLog->eventId = WLAN_SCAN_EVENT_ACTIVE_SCAN_RSP;
4418 }
4419 else
4420 {
4421 pScanLog->eventId = WLAN_SCAN_EVENT_PASSIVE_SCAN_RSP;
4422 }
4423 }
4424 if(eSIR_SME_SUCCESS == pScanRsp->statusCode)
4425 {
4426 if(HAL_STATUS_SUCCESS(csrScanGetResult(pMac, NULL, &hScanResult)))
4427 {
4428 while(((pScanResult = csrScanResultGetNext(pMac, hScanResult)) != NULL))
4429 {
4430 if( n < VOS_LOG_MAX_NUM_BSSID )
4431 {
4432 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->BssDescriptor, &pIes)))
4433 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004434 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004435 break;
4436 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304437 vos_mem_copy(pScanLog->bssid[n],
4438 pScanResult->BssDescriptor.bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07004439 if(pIes && pIes->SSID.present && VOS_LOG_MAX_SSID_SIZE >= pIes->SSID.num_ssid)
4440 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304441 vos_mem_copy(pScanLog->ssid[n],
4442 pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07004443 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304444 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004445 n++;
4446 }
4447 c++;
4448 }
4449 pScanLog->numSsid = (v_U8_t)n;
4450 pScanLog->totalSsid = (v_U8_t)c;
4451 csrScanResultPurge(pMac, hScanResult);
4452 }
4453 }
4454 else
4455 {
4456 pScanLog->status = WLAN_SCAN_STATUS_FAILURE;
4457 }
4458 WLAN_VOS_DIAG_LOG_REPORT(pScanLog);
4459 }
4460 }
4461#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
4462
4463 NextCommand = csrScanGetNextCommandState(pMac, pCommand, fSuccess);
4464 //We reuse the command here instead reissue a new command
4465 switch(NextCommand)
4466 {
4467 case eCsrNext11dScan1Success:
4468 case eCsrNext11dScan2Success:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004469 smsLog( pMac, LOG2, FL("11dScan1/3 produced results. Reissue Active scan..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07004470 // if we found country information, no need to continue scanning further, bail out
4471 fRemoveCommand = eANI_BOOLEAN_TRUE;
4472 NextCommand = eCsrNext11dScanComplete;
4473 break;
4474 case eCsrNext11dScan1Failure:
4475 //We are not done yet. 11d scan fail once. We will try to reset anything and do it over again
4476 //The only meaningful thing for this retry is that we cannot find 11d information after a reset so
4477 //we clear the "old" 11d info and give it once more chance
4478 fRemoveCommand = csrHandleScan11d1Failure(pMac, pCommand);
4479 if(fRemoveCommand)
4480 {
4481 NextCommand = eCsrNext11dScanComplete;
4482 }
4483 break;
4484 case eCsrNextLostLinkScan1Success:
4485 if(!HAL_STATUS_SUCCESS(csrIssueRoamAfterLostlinkScan(pMac, sessionId, eCsrLostLink1)))
4486 {
4487 csrScanHandleFailedLostlink1(pMac, sessionId);
4488 }
4489 break;
4490 case eCsrNextLostLinkScan2Success:
4491 if(!HAL_STATUS_SUCCESS(csrIssueRoamAfterLostlinkScan(pMac, sessionId, eCsrLostLink2)))
4492 {
4493 csrScanHandleFailedLostlink2(pMac, sessionId);
4494 }
4495 break;
4496 case eCsrNextLostLinkScan3Success:
4497 if(!HAL_STATUS_SUCCESS(csrIssueRoamAfterLostlinkScan(pMac, sessionId, eCsrLostLink3)))
4498 {
4499 csrScanHandleFailedLostlink3(pMac, sessionId);
4500 }
4501 break;
4502 case eCsrNextLostLinkScan1Failed:
4503 csrScanHandleFailedLostlink1(pMac, sessionId);
4504 break;
4505 case eCsrNextLostLinkScan2Failed:
4506 csrScanHandleFailedLostlink2(pMac, sessionId);
4507 break;
4508 case eCsrNextLostLinkScan3Failed:
4509 csrScanHandleFailedLostlink3(pMac, sessionId);
4510 break;
4511 case eCsrNexteScanForSsidSuccess:
4512 csrScanHandleSearchForSSID(pMac, pCommand);
4513 break;
4514 case eCsrNexteScanForSsidFailure:
4515 csrScanHandleSearchForSSIDFailure(pMac, pCommand);
4516 break;
4517 case eCsrNextIdleScanComplete:
4518 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE;
4519 break;
4520 case eCsrNextCapChangeScanComplete:
4521 csrScanHandleCapChangeScanComplete(pMac, sessionId);
4522 break;
4523 default:
4524
4525 break;
4526 }
4527 }
4528 else
4529 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004530 smsLog( pMac, LOGW, FL("Scan Completion called but SCAN command is not ACTIVE ..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07004531 fRemoveCommand = eANI_BOOLEAN_FALSE;
4532 }
4533 }
4534 else
4535 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004536 smsLog( pMac, LOGW, FL("Scan Completion called but NO commands are ACTIVE ..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07004537 fRemoveCommand = eANI_BOOLEAN_FALSE;
4538 }
4539
4540 return( fRemoveCommand );
4541}
4542
4543
4544
4545static void csrScanRemoveDupBssDescriptionFromInterimList( tpAniSirGlobal pMac,
4546 tSirBssDescription *pSirBssDescr,
4547 tDot11fBeaconIEs *pIes)
4548{
4549 tListElem *pEntry;
4550 tCsrScanResult *pCsrBssDescription;
4551
4552 // Walk through all the chained BssDescriptions. If we find a chained BssDescription that
4553 // matches the BssID of the BssDescription passed in, then these must be duplicate scan
4554 // results for this Bss. In that case, remove the 'old' Bss description from the linked list.
4555 pEntry = csrLLPeekHead( &pMac->scan.tempScanResults, LL_ACCESS_LOCK );
4556 while( pEntry )
4557 {
4558 pCsrBssDescription = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
4559
4560 // we have a duplicate scan results only when BSSID, SSID, Channel and NetworkType
4561 // matches
4562
4563 if ( csrIsDuplicateBssDescription( pMac, &pCsrBssDescription->Result.BssDescriptor,
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07004564 pSirBssDescr, pIes, FALSE ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004565 {
4566 pSirBssDescr->rssi = (tANI_S8)( (((tANI_S32)pSirBssDescr->rssi * CSR_SCAN_RESULT_RSSI_WEIGHT ) +
4567 ((tANI_S32)pCsrBssDescription->Result.BssDescriptor.rssi * (100 - CSR_SCAN_RESULT_RSSI_WEIGHT) )) / 100 );
4568
4569 // Remove the 'old' entry from the list....
4570 if( csrLLRemoveEntry( &pMac->scan.tempScanResults, pEntry, LL_ACCESS_LOCK ) )
4571 {
4572 csrCheckNSaveWscIe(pMac, pSirBssDescr, &pCsrBssDescription->Result.BssDescriptor);
4573 // we need to free the memory associated with this node
4574 csrFreeScanResultEntry( pMac, pCsrBssDescription );
4575 }
4576
4577 // If we found a match, we can stop looking through the list.
4578 break;
4579 }
4580
4581 pEntry = csrLLNext( &pMac->scan.tempScanResults, pEntry, LL_ACCESS_LOCK );
4582 }
4583}
4584
4585
4586
4587//Caller allocated memory pfNewBssForConn to return whether new candidate for
4588//current connection is found. Cannot be NULL
4589tCsrScanResult *csrScanSaveBssDescriptionToInterimList( tpAniSirGlobal pMac,
4590 tSirBssDescription *pBSSDescription,
4591 tDot11fBeaconIEs *pIes)
4592{
4593 tCsrScanResult *pCsrBssDescription = NULL;
4594 tANI_U32 cbBSSDesc;
4595 tANI_U32 cbAllocated;
Jeff Johnson295189b2012-06-20 16:38:30 -07004596
4597 // figure out how big the BSS description is (the BSSDesc->length does NOT
4598 // include the size of the length field itself).
4599 cbBSSDesc = pBSSDescription->length + sizeof( pBSSDescription->length );
4600
4601 cbAllocated = sizeof( tCsrScanResult ) + cbBSSDesc;
4602
Kiet Lam64c1b492013-07-12 13:56:44 +05304603 pCsrBssDescription = vos_mem_malloc(cbAllocated);
4604 if ( NULL != pCsrBssDescription )
Jeff Johnson295189b2012-06-20 16:38:30 -07004605 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304606 vos_mem_set(pCsrBssDescription, cbAllocated, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004607 pCsrBssDescription->AgingCount = (tANI_S32)pMac->roam.configParam.agingCount;
Kiet Lam64c1b492013-07-12 13:56:44 +05304608 vos_mem_copy(&pCsrBssDescription->Result.BssDescriptor, pBSSDescription, cbBSSDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -07004609 //Save SSID separately for later use
4610 if( pIes->SSID.present && !csrIsNULLSSID(pIes->SSID.ssid, pIes->SSID.num_ssid) )
4611 {
4612 //SSID not hidden
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07004613 tANI_U32 len = pIes->SSID.num_ssid;
Jeff Johnson295189b2012-06-20 16:38:30 -07004614 if (len > SIR_MAC_MAX_SSID_LENGTH)
4615 {
4616 // truncate to fit in our struct
4617 len = SIR_MAC_MAX_SSID_LENGTH;
4618 }
4619 pCsrBssDescription->Result.ssId.length = len;
4620 pCsrBssDescription->Result.timer = vos_timer_get_system_time();
Kiet Lam64c1b492013-07-12 13:56:44 +05304621 vos_mem_copy(pCsrBssDescription->Result.ssId.ssId, pIes->SSID.ssid, len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004622 }
4623 csrLLInsertTail( &pMac->scan.tempScanResults, &pCsrBssDescription->Link, LL_ACCESS_LOCK );
4624 }
4625
4626 return( pCsrBssDescription );
4627}
4628
4629
4630
4631
4632tANI_BOOLEAN csrIsDuplicateBssDescription( tpAniSirGlobal pMac, tSirBssDescription *pSirBssDesc1,
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07004633 tSirBssDescription *pSirBssDesc2, tDot11fBeaconIEs *pIes2, tANI_BOOLEAN fForced )
Jeff Johnson295189b2012-06-20 16:38:30 -07004634{
4635 tANI_BOOLEAN fMatch = FALSE;
4636 tSirMacCapabilityInfo *pCap1, *pCap2;
4637 tDot11fBeaconIEs *pIes1 = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07004638 tDot11fBeaconIEs *pIesTemp = pIes2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004639
4640 pCap1 = (tSirMacCapabilityInfo *)&pSirBssDesc1->capabilityInfo;
4641 pCap2 = (tSirMacCapabilityInfo *)&pSirBssDesc2->capabilityInfo;
4642 if(pCap1->ess == pCap2->ess)
4643 {
4644 if (pCap1->ess &&
Jeff Johnsone7245742012-09-05 17:12:55 -07004645 csrIsMacAddressEqual( pMac, (tCsrBssid *)pSirBssDesc1->bssId, (tCsrBssid *)pSirBssDesc2->bssId)&&
Abhishek Singhe3fa11f2014-05-13 11:11:10 +05304646 (fForced || (vos_chan_to_band(pSirBssDesc1->channelId) == vos_chan_to_band((pSirBssDesc2->channelId)))))
Jeff Johnson295189b2012-06-20 16:38:30 -07004647 {
4648 fMatch = TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004649 // Check for SSID match, if exists
4650 do
4651 {
4652 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc1, &pIes1)))
4653 {
4654 break;
4655 }
4656 if( NULL == pIesTemp )
4657 {
4658 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc2, &pIesTemp)))
4659 {
4660 break;
4661 }
4662 }
4663 if(pIes1->SSID.present && pIesTemp->SSID.present)
4664 {
4665 fMatch = csrIsSsidMatch(pMac, pIes1->SSID.ssid, pIes1->SSID.num_ssid,
4666 pIesTemp->SSID.ssid, pIesTemp->SSID.num_ssid, eANI_BOOLEAN_TRUE);
4667 }
4668 }while(0);
4669
Jeff Johnson295189b2012-06-20 16:38:30 -07004670 }
4671 else if (pCap1->ibss && (pSirBssDesc1->channelId == pSirBssDesc2->channelId))
4672 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004673
4674 do
4675 {
4676 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc1, &pIes1)))
4677 {
4678 break;
4679 }
4680 if( NULL == pIesTemp )
4681 {
4682 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc2, &pIesTemp)))
4683 {
4684 break;
4685 }
4686 }
4687 //Same channel cannot have same SSID for different IBSS
4688 if(pIes1->SSID.present && pIesTemp->SSID.present)
4689 {
4690 fMatch = csrIsSsidMatch(pMac, pIes1->SSID.ssid, pIes1->SSID.num_ssid,
4691 pIesTemp->SSID.ssid, pIesTemp->SSID.num_ssid, eANI_BOOLEAN_TRUE);
4692 }
4693 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004694 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004695 /* In case of P2P devices, ess and ibss will be set to zero */
4696 else if (!pCap1->ess &&
4697 csrIsMacAddressEqual( pMac, (tCsrBssid *)pSirBssDesc1->bssId, (tCsrBssid *)pSirBssDesc2->bssId))
4698 {
4699 fMatch = TRUE;
4700 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004701 }
4702
4703 if(pIes1)
4704 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304705 vos_mem_free(pIes1);
Jeff Johnson295189b2012-06-20 16:38:30 -07004706 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004707
4708 if( (NULL == pIes2) && pIesTemp )
4709 {
4710 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05304711 vos_mem_free(pIesTemp);
Jeff Johnsone7245742012-09-05 17:12:55 -07004712 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004713
4714 return( fMatch );
4715}
4716
4717
4718tANI_BOOLEAN csrIsNetworkTypeEqual( tSirBssDescription *pSirBssDesc1, tSirBssDescription *pSirBssDesc2 )
4719{
4720 return( pSirBssDesc1->nwType == pSirBssDesc2->nwType );
4721}
4722
4723
4724//to check whether the BSS matches the dot11Mode
4725static tANI_BOOLEAN csrScanIsBssAllowed(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
4726 tDot11fBeaconIEs *pIes)
4727{
4728 tANI_BOOLEAN fAllowed = eANI_BOOLEAN_FALSE;
4729 eCsrPhyMode phyMode;
4730
4731 if(HAL_STATUS_SUCCESS(csrGetPhyModeFromBss(pMac, pBssDesc, &phyMode, pIes)))
4732 {
4733 switch(pMac->roam.configParam.phyMode)
4734 {
4735 case eCSR_DOT11_MODE_11b:
4736 fAllowed = (tANI_BOOLEAN)(eCSR_DOT11_MODE_11a != phyMode);
4737 break;
4738 case eCSR_DOT11_MODE_11g:
4739 fAllowed = (tANI_BOOLEAN)(eCSR_DOT11_MODE_11a != phyMode);
4740 break;
4741 case eCSR_DOT11_MODE_11g_ONLY:
4742 fAllowed = (tANI_BOOLEAN)(eCSR_DOT11_MODE_11g == phyMode);
4743 break;
4744 case eCSR_DOT11_MODE_11a:
4745 fAllowed = (tANI_BOOLEAN)((eCSR_DOT11_MODE_11b != phyMode) && (eCSR_DOT11_MODE_11g != phyMode));
4746 break;
4747 case eCSR_DOT11_MODE_11n_ONLY:
4748 fAllowed = (tANI_BOOLEAN)((eCSR_DOT11_MODE_11n == phyMode) || (eCSR_DOT11_MODE_TAURUS == phyMode));
4749 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004750
4751#ifdef WLAN_FEATURE_11AC
4752 case eCSR_DOT11_MODE_11ac_ONLY:
4753 fAllowed = (tANI_BOOLEAN)((eCSR_DOT11_MODE_11ac == phyMode) || (eCSR_DOT11_MODE_TAURUS == phyMode));
4754 break;
4755#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004756 case eCSR_DOT11_MODE_11b_ONLY:
4757 fAllowed = (tANI_BOOLEAN)(eCSR_DOT11_MODE_11b == phyMode);
4758 break;
4759 case eCSR_DOT11_MODE_11a_ONLY:
4760 fAllowed = (tANI_BOOLEAN)(eCSR_DOT11_MODE_11a == phyMode);
4761 break;
4762 case eCSR_DOT11_MODE_11n:
Jeff Johnsone7245742012-09-05 17:12:55 -07004763#ifdef WLAN_FEATURE_11AC
4764 case eCSR_DOT11_MODE_11ac:
4765#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004766 case eCSR_DOT11_MODE_TAURUS:
4767 default:
4768 fAllowed = eANI_BOOLEAN_TRUE;
4769 break;
4770 }
4771 }
4772
4773 return (fAllowed);
4774}
4775
4776
4777
4778//Return pIes to caller for future use when returning TRUE.
4779static tANI_BOOLEAN csrScanValidateScanResult( tpAniSirGlobal pMac, tANI_U8 *pChannels,
4780 tANI_U8 numChn, tSirBssDescription *pBssDesc,
4781 tDot11fBeaconIEs **ppIes )
4782{
4783 tANI_BOOLEAN fValidChannel = FALSE;
4784 tDot11fBeaconIEs *pIes = NULL;
4785 tANI_U8 index;
4786
4787 for( index = 0; index < numChn; index++ )
4788 {
4789 // This check relies on the fact that a single BSS description is returned in each
4790 // ScanRsp call, which is the way LIM implemented the scan req/rsp funtions. We changed
4791 // to this model when we ran with a large number of APs. If this were to change, then
4792 // this check would have to mess with removing the bssDescription from somewhere in an
4793 // arbitrary index in the bssDescription array.
4794 if ( pChannels[ index ] == pBssDesc->channelId )
4795 {
4796 fValidChannel = TRUE;
4797 break;
4798 }
4799 }
4800 *ppIes = NULL;
4801 if(fValidChannel)
4802 {
4803 if( HAL_STATUS_SUCCESS( csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes) ) )
4804 {
4805 fValidChannel = csrScanIsBssAllowed(pMac, pBssDesc, pIes);
4806 if( fValidChannel )
4807 {
4808 *ppIes = pIes;
4809 }
4810 else
4811 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304812 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004813 }
4814 }
4815 else
4816 {
4817 fValidChannel = FALSE;
4818 }
4819 }
4820
4821 return( fValidChannel );
4822}
4823
4824
4825//Return whether last scan result is received
4826static tANI_BOOLEAN csrScanProcessScanResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
4827 tSirSmeScanRsp *pScanRsp, tANI_BOOLEAN *pfRemoveCommand )
4828{
4829 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE, fRemoveCommand = eANI_BOOLEAN_FALSE;
4830 tDot11fBeaconIEs *pIes = NULL;
4831 tANI_U32 cbParsed;
4832 tSirBssDescription *pSirBssDescription;
4833 tANI_U32 cbBssDesc;
4834 tANI_U32 cbScanResult = GET_FIELD_OFFSET( tSirSmeScanRsp, bssDescription )
4835 + sizeof(tSirBssDescription); //We need at least one CB
4836
4837 // don't consider the scan rsp to be valid if the status code is Scan Failure. Scan Failure
4838 // is returned when the scan could not find anything. so if we get scan failure return that
4839 // the scan response is invalid. Also check the lenght in the scan result for valid scan
4840 // BssDescriptions....
4841 do
4842 {
4843 if ( ( cbScanResult <= pScanRsp->length ) &&
4844 (( eSIR_SME_SUCCESS == pScanRsp->statusCode ) ||
4845 ( eSIR_SME_MORE_SCAN_RESULTS_FOLLOW == pScanRsp->statusCode ) ) )
4846 {
4847 tANI_U8 *pChannelList = NULL;
4848 tANI_U8 cChannels = 0;
4849
4850 //Different scan type can reach this point, we need to distinguish it
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004851#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
4852 if( eCsrScanGetLfrResult == pCommand->u.scanCmd.reason )
4853 {
4854 pChannelList = NULL;
4855 cChannels = 0;
4856 }
4857 else
4858#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004859 if( eCsrScanSetBGScanParam == pCommand->u.scanCmd.reason )
4860 {
4861 //eCsrScanSetBGScanParam uses different structure
4862 tCsrBGScanRequest *pBgScanReq = &pCommand->u.scanCmd.u.bgScanRequest;
4863
4864 cChannels = pBgScanReq->ChannelInfo.numOfChannels;
4865 pChannelList = pBgScanReq->ChannelInfo.ChannelList;
4866 }
4867 else
4868 {
4869 //the rest use generic scan request
4870 cChannels = pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels;
4871 pChannelList = pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList;
4872 }
4873
4874 // if the scan result is not on one of the channels in the Valid channel list, then it
4875 // must have come from an AP on an overlapping channel (in the 2.4GHz band). In this case,
4876 // let's drop the scan result.
4877 //
4878 // The other situation is where the scan request is for a scan on a particular channel set
4879 // and the scan result is from a
4880
4881 // if the NumChannels is 0, then we are supposed to be scanning all channels. Use the full channel
4882 // list as the 'valid' channel list. Otherwise, use the specific channel list in the scan parms
4883 // as the valid channels.
4884 if ( 0 == cChannels )
4885 {
4886 tANI_U32 len = sizeof(pMac->roam.validChannelList);
4887
4888 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
4889 {
4890 pChannelList = pMac->roam.validChannelList;
4891 cChannels = (tANI_U8)len;
4892 }
4893 else
4894 {
4895 //Cannot continue
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004896 smsLog( pMac, LOGE, "CSR: Processing internal SCAN results...csrGetCfgValidChannels failed" );
Jeff Johnson295189b2012-06-20 16:38:30 -07004897 break;
4898 }
4899 }
4900
4901 smsLog( pMac, LOG2, "CSR: Processing internal SCAN results..." );
4902 cbParsed = GET_FIELD_OFFSET( tSirSmeScanRsp, bssDescription );
4903 pSirBssDescription = pScanRsp->bssDescription;
4904 while( cbParsed < pScanRsp->length )
4905 {
4906 if ( csrScanValidateScanResult( pMac, pChannelList, cChannels, pSirBssDescription, &pIes ) )
4907 {
4908 csrScanRemoveDupBssDescriptionFromInterimList(pMac, pSirBssDescription, pIes);
4909 csrScanSaveBssDescriptionToInterimList( pMac, pSirBssDescription, pIes );
4910 if( eSIR_PASSIVE_SCAN == pMac->scan.curScanType )
4911 {
4912 if( csrIs11dSupported( pMac) )
4913 {
4914 //Check whether the BSS is acceptable base on 11d info and our configs.
4915 if( csrMatchCountryCode( pMac, NULL, pIes ) )
4916 {
4917 //Double check whether the channel is acceptable by us.
4918 if( csrIsSupportedChannel( pMac, pSirBssDescription->channelId ) )
4919 {
4920 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
4921 }
4922 }
4923 }
4924 else
4925 {
4926 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
4927 }
4928 }
4929 //Free the resource
Kiet Lam64c1b492013-07-12 13:56:44 +05304930 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004931 }
4932 // skip over the BSS description to the next one...
4933 cbBssDesc = pSirBssDescription->length + sizeof( pSirBssDescription->length );
4934
4935 cbParsed += cbBssDesc;
4936 pSirBssDescription = (tSirBssDescription *)((tANI_U8 *)pSirBssDescription + cbBssDesc );
4937
4938 } //while
4939 }
4940 else
4941 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004942 smsLog( pMac, LOGW, " Scanrsp fail (0x%08X), length = %d (expected %d)",
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08004943 pScanRsp->statusCode, pScanRsp->length, cbScanResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07004944 //HO bg scan/probe failed no need to try autonomously
4945 if(eCsrScanBgScan == pCommand->u.scanCmd.reason ||
4946 eCsrScanProbeBss == pCommand->u.scanCmd.reason ||
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004947#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
4948 eCsrScanGetLfrResult == pCommand->u.scanCmd.reason ||
4949#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004950 eCsrScanSetBGScanParam == pCommand->u.scanCmd.reason)
4951 {
4952 fRemoveCommand = eANI_BOOLEAN_TRUE;
4953 }
4954 }
4955 }while(0);
4956 if ( eSIR_SME_MORE_SCAN_RESULTS_FOLLOW != pScanRsp->statusCode )
4957 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004958 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 -07004959 fRemoveCommand = csrScanComplete( pMac, pScanRsp );
4960 fRet = eANI_BOOLEAN_TRUE;
4961 }//if ( eSIR_SME_MORE_SCAN_RESULTS_FOLLOW != pScanRsp->statusCode )
4962 if(pfRemoveCommand)
4963 {
4964 *pfRemoveCommand = fRemoveCommand;
4965 }
4966
4967#ifdef WLAN_AP_STA_CONCURRENCY
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +05304968 if (pMac->fScanOffload)
4969 return fRet;
4970
Jeff Johnson295189b2012-06-20 16:38:30 -07004971 if (!csrLLIsListEmpty( &pMac->scan.scanCmdPendingList, LL_ACCESS_LOCK ))
4972 {
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08004973 /* Pending scan commands in the list because the previous scan command
4974 * was split into a scan command on one channel + a scan command for all
4975 * remaining channels.
4976 *
4977 * Start timer to trigger processing of the next scan command.
Srikant Kuppa866893f2012-12-27 17:28:14 -08004978 * NOTE for LFR:
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +05304979 * Do not split scans if no concurrent infra connections are
Srikant Kuppa866893f2012-12-27 17:28:14 -08004980 * active and if the scan is a BG scan triggered by LFR (OR)
4981 * any scan if LFR is in the middle of a BG scan. Splitting
4982 * the scan is delaying the time it takes for LFR to find
4983 * candidates and resulting in disconnects.
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08004984 */
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +05304985 if ( (csrIsStaSessionConnected(pMac) &&
Srikant Kuppa866893f2012-12-27 17:28:14 -08004986#ifdef FEATURE_WLAN_LFR
4987 (csrIsConcurrentInfraConnected(pMac) ||
4988 ((pCommand->u.scanCmd.reason != eCsrScanBgScan) &&
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +05304989 (pMac->roam.neighborRoamInfo.neighborRoamState !=
Srikant Kuppa866893f2012-12-27 17:28:14 -08004990 eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN))) &&
4991#endif
4992 (pCommand->u.scanCmd.u.scanRequest.p2pSearch != 1)) ||
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +05304993 (csrIsP2pSessionConnected(pMac)) )
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08004994 {
Madan Mohan Koyyalamudid6713582012-11-09 16:56:56 -08004995 /* if active connected sessions present then continue to split scan
4996 * with specified interval between consecutive scans */
4997 csrSetDefaultScanTiming(pMac, pCommand->u.scanCmd.u.scanRequest.scanType, &(pCommand->u.scanCmd.u.scanRequest));
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05304998 vos_timer_start(&pMac->scan.hTimerStaApConcTimer,
4999 pCommand->u.scanCmd.u.scanRequest.restTime);
Madan Mohan Koyyalamudid6713582012-11-09 16:56:56 -08005000 } else {
5001 /* if no connected sessions present then initiate next scan command immediately */
5002 /* minimum timer granularity is 10ms */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05305003 vos_timer_start(&pMac->scan.hTimerStaApConcTimer, 10);
Madan Mohan Koyyalamudid6713582012-11-09 16:56:56 -08005004 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005005 }
5006#endif
5007 return (fRet);
5008}
5009
5010
5011tANI_BOOLEAN csrScanIsWildCardScan( tpAniSirGlobal pMac, tSmeCmd *pCommand )
5012{
5013 tANI_U8 bssid[WNI_CFG_BSSID_LEN] = {0, 0, 0, 0, 0, 0};
Kiet Lam64c1b492013-07-12 13:56:44 +05305014 tANI_BOOLEAN f = vos_mem_compare(pCommand->u.scanCmd.u.scanRequest.bssid,
5015 bssid, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005016
5017 //It is not a wild card scan if the bssid is not broadcast and the number of SSID is 1.
5018 return ((tANI_BOOLEAN)( (f || (0xff == pCommand->u.scanCmd.u.scanRequest.bssid[0])) &&
5019 (pCommand->u.scanCmd.u.scanRequest.SSIDs.numOfSSIDs != 1) ));
5020}
5021
5022
5023eHalStatus csrScanSmeScanResponse( tpAniSirGlobal pMac, void *pMsgBuf )
5024{
5025 eHalStatus status = eHAL_STATUS_SUCCESS;
5026 tListElem *pEntry;
5027 tSmeCmd *pCommand;
5028 eCsrScanStatus scanStatus;
5029 tSirSmeScanRsp *pScanRsp = (tSirSmeScanRsp *)pMsgBuf;
5030 tSmeGetScanChnRsp *pScanChnInfo;
5031 tANI_BOOLEAN fRemoveCommand = eANI_BOOLEAN_TRUE;
5032 eCsrScanReason reason = eCsrScanOther;
5033
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +05305034 if (pMac->fScanOffload)
5035 pEntry = csrLLPeekHead(&pMac->sme.smeScanCmdActiveList,
5036 LL_ACCESS_LOCK);
5037 else
5038 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
Jeff Johnson295189b2012-06-20 16:38:30 -07005039
5040 if ( pEntry )
5041 {
5042 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
5043 if ( eSmeCommandScan == pCommand->command )
5044 {
5045 scanStatus = (eSIR_SME_SUCCESS == pScanRsp->statusCode) ? eCSR_SCAN_SUCCESS : eCSR_SCAN_FAILURE;
5046 reason = pCommand->u.scanCmd.reason;
5047 switch(pCommand->u.scanCmd.reason)
5048 {
5049 case eCsrScanAbortBgScan:
5050 case eCsrScanAbortNormalScan:
5051 case eCsrScanBGScanAbort:
5052 case eCsrScanBGScanEnable:
5053 break;
5054 case eCsrScanGetScanChnInfo:
5055 pScanChnInfo = (tSmeGetScanChnRsp *)pMsgBuf;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005056 /*
5057 * status code not available in tSmeGetScanChnRsp, so
5058 * by default considereing it to be success
5059 */
5060 scanStatus = eSIR_SME_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005061 csrScanAgeResults(pMac, pScanChnInfo);
5062 break;
5063 case eCsrScanForCapsChange:
5064 csrScanProcessScanResults( pMac, pCommand, pScanRsp, &fRemoveCommand );
5065 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005066 case eCsrScanP2PFindPeer:
5067 scanStatus = ((eSIR_SME_SUCCESS == pScanRsp->statusCode) && (pScanRsp->length > 50)) ? eCSR_SCAN_FOUND_PEER : eCSR_SCAN_FAILURE;
5068 csrScanProcessScanResults( pMac, pCommand, pScanRsp, NULL );
5069 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005070 case eCsrScanSetBGScanParam:
5071 default:
5072 if(csrScanProcessScanResults( pMac, pCommand, pScanRsp, &fRemoveCommand ))
5073 {
5074 //Not to get channel info if the scan is not a wildcard scan because
5075 //it may cause scan results got aged out incorrectly.
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005076 if( csrScanIsWildCardScan( pMac, pCommand ) && (!pCommand->u.scanCmd.u.scanRequest.p2pSearch)
5077#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5078 && (pCommand->u.scanCmd.reason != eCsrScanGetLfrResult)
5079#endif
5080 )
Jeff Johnson295189b2012-06-20 16:38:30 -07005081 {
5082 //Get the list of channels scanned
Jeff Johnson32d95a32012-09-10 13:15:23 -07005083 if( pCommand->u.scanCmd.reason != eCsrScanUserRequest)
5084 {
Madan Mohan Koyyalamudide1b5bc2013-07-12 00:56:04 +05305085 csrScanGetScanChnInfo(pMac, pCommand->sessionId,
5086 NULL, NULL);
Jeff Johnson32d95a32012-09-10 13:15:23 -07005087 }
5088 else
5089 {
Madan Mohan Koyyalamudide1b5bc2013-07-12 00:56:04 +05305090 csrScanGetScanChnInfo(pMac,
5091 pCommand->sessionId,
5092 pCommand->u.scanCmd.pContext,
5093 pCommand->u.scanCmd.callback);
Jeff Johnson32d95a32012-09-10 13:15:23 -07005094 pCommand->u.scanCmd.callback = NULL;
5095 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005096 }
5097 }
5098 break;
5099 }//switch
5100 if(fRemoveCommand)
5101 {
5102
5103 csrReleaseScanCommand(pMac, pCommand, scanStatus);
5104
Srikant Kuppa866893f2012-12-27 17:28:14 -08005105 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005106 smeProcessPendingQueue( pMac );
5107 }
5108 else
5109 {
5110 smsLog( pMac, LOGW, "CSR: Scan Completion called but SCAN command is not ACTIVE ..." );
5111 status = eHAL_STATUS_FAILURE;
5112 }
5113 }
5114 else
5115 {
5116 smsLog( pMac, LOGW, "CSR: Scan Completion called but NO commands are ACTIVE ..." );
5117 status = eHAL_STATUS_FAILURE;
5118 }
5119
5120 return (status);
5121}
5122
5123
5124
5125
5126tCsrScanResultInfo *csrScanResultGetFirst(tpAniSirGlobal pMac, tScanResultHandle hScanResult)
5127{
5128 tListElem *pEntry;
5129 tCsrScanResult *pResult;
5130 tCsrScanResultInfo *pRet = NULL;
5131 tScanResultList *pResultList = (tScanResultList *)hScanResult;
5132
5133 if(pResultList)
5134 {
5135 csrLLLock(&pResultList->List);
5136 pEntry = csrLLPeekHead(&pResultList->List, LL_ACCESS_NOLOCK);
5137 if(pEntry)
5138 {
5139 pResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
5140 pRet = &pResult->Result;
5141 }
5142 pResultList->pCurEntry = pEntry;
5143 csrLLUnlock(&pResultList->List);
5144 }
5145
5146 return pRet;
5147}
5148
5149
5150tCsrScanResultInfo *csrScanResultGetNext(tpAniSirGlobal pMac, tScanResultHandle hScanResult)
5151{
5152 tListElem *pEntry = NULL;
5153 tCsrScanResult *pResult = NULL;
5154 tCsrScanResultInfo *pRet = NULL;
5155 tScanResultList *pResultList = (tScanResultList *)hScanResult;
5156
5157 if(pResultList)
5158 {
5159 csrLLLock(&pResultList->List);
5160 if(NULL == pResultList->pCurEntry)
5161 {
5162 pEntry = csrLLPeekHead(&pResultList->List, LL_ACCESS_NOLOCK);
5163 }
5164 else
5165 {
5166 pEntry = csrLLNext(&pResultList->List, pResultList->pCurEntry, LL_ACCESS_NOLOCK);
5167 }
5168 if(pEntry)
5169 {
5170 pResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
5171 pRet = &pResult->Result;
5172 }
5173 pResultList->pCurEntry = pEntry;
5174 csrLLUnlock(&pResultList->List);
5175 }
5176
5177 return pRet;
5178}
5179
5180
5181//This function moves the first BSS that matches the bssid to the head of the result
5182eHalStatus csrMoveBssToHeadFromBSSID(tpAniSirGlobal pMac, tCsrBssid *bssid, tScanResultHandle hScanResult)
5183{
5184 eHalStatus status = eHAL_STATUS_FAILURE;
5185 tScanResultList *pResultList = (tScanResultList *)hScanResult;
5186 tCsrScanResult *pResult = NULL;
5187 tListElem *pEntry = NULL;
5188
5189 if(pResultList && bssid)
5190 {
5191 csrLLLock(&pResultList->List);
5192 pEntry = csrLLPeekHead(&pResultList->List, LL_ACCESS_NOLOCK);
5193 while(pEntry)
5194 {
5195 pResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
Kiet Lam64c1b492013-07-12 13:56:44 +05305196 if (vos_mem_compare(bssid, pResult->Result.BssDescriptor.bssId, sizeof(tCsrBssid)))
Jeff Johnson295189b2012-06-20 16:38:30 -07005197 {
5198 status = eHAL_STATUS_SUCCESS;
5199 csrLLRemoveEntry(&pResultList->List, pEntry, LL_ACCESS_NOLOCK);
5200 csrLLInsertHead(&pResultList->List, pEntry, LL_ACCESS_NOLOCK);
5201 break;
5202 }
5203 pEntry = csrLLNext(&pResultList->List, pResultList->pCurEntry, LL_ACCESS_NOLOCK);
5204 }
5205 csrLLUnlock(&pResultList->List);
5206 }
5207
5208 return (status);
5209}
5210
5211
5212//Remove the BSS if possible.
5213//Return -- TRUE == the BSS is remove. False == Fail to remove it
5214//This function is called when list lock is held. Be caution what functions it can call.
5215tANI_BOOLEAN csrScanAgeOutBss(tpAniSirGlobal pMac, tCsrScanResult *pResult)
5216{
5217 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
5218 tANI_U32 i;
5219 tCsrRoamSession *pSession;
5220
5221 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
5222 {
5223 if( CSR_IS_SESSION_VALID( pMac, i ) )
5224 {
5225 pSession = CSR_GET_SESSION( pMac, i );
5226 //Not to remove the BSS we are connected to.
5227 if(csrIsConnStateDisconnected(pMac, i) || (NULL == pSession->pConnectBssDesc) ||
5228 (!csrIsDuplicateBssDescription(pMac, &pResult->Result.BssDescriptor,
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07005229 pSession->pConnectBssDesc, NULL, FALSE))
Jeff Johnson295189b2012-06-20 16:38:30 -07005230 )
5231 {
Arif Hussaina7c8e412013-11-20 11:06:42 -08005232 smsLog(pMac, LOGW, "Aging out BSS "MAC_ADDRESS_STR" Channel %d",
5233 MAC_ADDR_ARRAY(pResult->Result.BssDescriptor.bssId),
5234 pResult->Result.BssDescriptor.channelId);
Mihir Shetebc866f62014-02-13 16:08:53 +05305235
Jeff Johnson295189b2012-06-20 16:38:30 -07005236 //No need to hold the spin lock because caller should hold the lock for pMac->scan.scanResultList
5237 if( csrLLRemoveEntry(&pMac->scan.scanResultList, &pResult->Link, LL_ACCESS_NOLOCK) )
5238 {
Mihir Shetebc866f62014-02-13 16:08:53 +05305239 if (csrIsMacAddressEqual(pMac,
5240 (tCsrBssid *) pResult->Result.BssDescriptor.bssId,
5241 (tCsrBssid *) pMac->scan.currentCountryBssid))
5242 {
5243 smsLog(pMac, LOGW, "Aging out 11d BSS "MAC_ADDRESS_STR,
5244 MAC_ADDR_ARRAY(pResult->Result.BssDescriptor.bssId));
5245 pMac->scan.currentCountryRSSI = -128;
5246 }
5247
Jeff Johnson295189b2012-06-20 16:38:30 -07005248 csrFreeScanResultEntry(pMac, pResult);
Madan Mohan Koyyalamudi2e068bc2012-10-22 14:58:47 -07005249 fRet = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005250 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005251 break;
5252 }
5253 } //valid session
5254 } //for
Madan Mohan Koyyalamudi2e068bc2012-10-22 14:58:47 -07005255 if( CSR_ROAM_SESSION_MAX == i && fRet != eANI_BOOLEAN_TRUE )
Jeff Johnson295189b2012-06-20 16:38:30 -07005256 {
5257 //reset the counter so this won't hapeen too soon
5258 pResult->AgingCount = (tANI_S32)pMac->roam.configParam.agingCount;
5259 pResult->Result.BssDescriptor.nReceivedTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
5260 }
5261
5262 return (fRet);
5263}
5264
5265
5266eHalStatus csrScanAgeResults(tpAniSirGlobal pMac, tSmeGetScanChnRsp *pScanChnInfo)
5267{
5268 eHalStatus status = eHAL_STATUS_SUCCESS;
5269 tListElem *pEntry, *tmpEntry;
5270 tCsrScanResult *pResult;
5271 tLimScanChn *pChnInfo;
5272 tANI_U8 i;
5273
5274 csrLLLock(&pMac->scan.scanResultList);
5275 for(i = 0; i < pScanChnInfo->numChn; i++)
5276 {
5277 pChnInfo = &pScanChnInfo->scanChn[i];
5278 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
5279 while( pEntry )
5280 {
5281 tmpEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
5282 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
5283 if(pResult->Result.BssDescriptor.channelId == pChnInfo->channelId)
5284 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005285 if(pResult->AgingCount <= 0)
5286 {
5287 smsLog(pMac, LOGW, " age out due to ref count");
5288 csrScanAgeOutBss(pMac, pResult);
5289 }
Madan Mohan Koyyalamudib9d3dcc2012-09-28 16:47:50 -07005290 else
5291 {
5292 pResult->AgingCount--;
5293 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005294 }
5295 pEntry = tmpEntry;
5296 }
5297 }
5298 csrLLUnlock(&pMac->scan.scanResultList);
5299
5300 return (status);
5301}
5302
5303
5304eHalStatus csrSendMBScanReq( tpAniSirGlobal pMac, tANI_U16 sessionId,
5305 tCsrScanRequest *pScanReq, tScanReqParam *pScanReqParam )
5306{
5307 eHalStatus status = eHAL_STATUS_SUCCESS;
5308 tSirSmeScanReq *pMsg;
5309 tANI_U16 msgLen;
5310 tANI_U8 bssid[WNI_CFG_BSSID_LEN] = {0, 0, 0, 0, 0, 0};
5311 tSirScanType scanType = pScanReq->scanType;
5312 tANI_U32 minChnTime; //in units of milliseconds
5313 tANI_U32 maxChnTime; //in units of milliseconds
5314 tANI_U32 i;
5315 tANI_U8 selfMacAddr[WNI_CFG_BSSID_LEN];
5316 tANI_U8 *pSelfMac = NULL;
5317
5318 msgLen = (tANI_U16)(sizeof( tSirSmeScanReq ) - sizeof( pMsg->channelList.channelNumber ) +
5319 ( sizeof( pMsg->channelList.channelNumber ) * pScanReq->ChannelInfo.numOfChannels )) +
5320 ( pScanReq->uIEFieldLen ) ;
5321
Kiet Lam64c1b492013-07-12 13:56:44 +05305322 pMsg = vos_mem_malloc(msgLen);
5323 if ( NULL == pMsg )
5324 status = eHAL_STATUS_FAILURE;
5325 else
5326 status = eHAL_STATUS_SUCCESS;
5327 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07005328 {
5329 do
5330 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305331 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005332 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SCAN_REQ);
5333 pMsg->length = pal_cpu_to_be16(msgLen);
5334 //ToDO: Fill in session info when we need to do scan base on session.
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05305335 if ((pMac->fScanOffload) && (sessionId != CSR_SESSION_ID_INVALID))
5336 {
5337 pMsg->sessionId = sessionId;
5338 }
5339 else
5340 {
5341 /* if sessionId == CSR_SESSION_ID_INVALID, then send the scan
5342 request on first available session */
5343 pMsg->sessionId = 0;
5344 }
5345
Jeff Johnson295189b2012-06-20 16:38:30 -07005346 pMsg->transactionId = 0;
5347 pMsg->dot11mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac, csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
5348 pMsg->bssType = pal_cpu_to_be32(csrTranslateBsstypeToMacType(pScanReq->BSSType));
5349
5350 if ( CSR_IS_SESSION_VALID( pMac, sessionId ) )
5351 {
5352 pSelfMac = (tANI_U8 *)&pMac->roam.roamSession[sessionId].selfMacAddr;
5353 }
5354 else
5355 {
5356 // Since we don't have session for the scanning, we find a valid session. In case we fail to
5357 // do so, get the WNI_CFG_STA_ID
5358 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
5359 {
5360 if( CSR_IS_SESSION_VALID( pMac, i ) )
5361 {
5362 pSelfMac = (tANI_U8 *)&pMac->roam.roamSession[i].selfMacAddr;
5363 break;
5364 }
5365 }
5366 if( CSR_ROAM_SESSION_MAX == i )
5367 {
5368 tANI_U32 len = WNI_CFG_BSSID_LEN;
5369 pSelfMac = selfMacAddr;
5370 status = ccmCfgGetStr( pMac, WNI_CFG_STA_ID, pSelfMac, &len );
5371 if( !HAL_STATUS_SUCCESS( status ) ||
5372 ( len < WNI_CFG_BSSID_LEN ) )
5373 {
5374 smsLog( pMac, LOGE, FL(" Can not get self MAC address from CFG status = %d"), status );
5375 //Force failed status
5376 status = eHAL_STATUS_FAILURE;
5377 break;
5378 }
5379 }
5380 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305381 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, pSelfMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07005382
5383 //sirCopyMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +05305384 vos_mem_copy((tANI_U8 *)pMsg->bssId, (tANI_U8 *)&pScanReq->bssid, sizeof(tSirMacAddr));
5385 if ( vos_mem_compare(pScanReq->bssid, bssid, sizeof(tCsrBssid)))
Jeff Johnson295189b2012-06-20 16:38:30 -07005386 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305387 vos_mem_set(pMsg->bssId, sizeof(tSirMacAddr), 0xff);
Jeff Johnson295189b2012-06-20 16:38:30 -07005388 }
5389 else
5390 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305391 vos_mem_copy(pMsg->bssId, pScanReq->bssid, WNI_CFG_BSSID_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07005392 }
5393 minChnTime = pScanReq->minChnTime;
5394 maxChnTime = pScanReq->maxChnTime;
5395
5396 //Verify the scan type first, if the scan is active scan, we need to make sure we
5397 //are allowed to do so.
5398 /* if 11d is enabled & we don't see any beacon around, scan type falls
5399 back to passive. But in BT AMP STA mode we need to send out a
5400 directed probe*/
5401 if( (eSIR_PASSIVE_SCAN != scanType) && (eCSR_SCAN_P2P_DISCOVERY != pScanReq->requestType)
5402 && (eCSR_BSS_TYPE_WDS_STA != pScanReq->BSSType)
5403 && (eANI_BOOLEAN_FALSE == pMac->scan.fEnableBypass11d))
5404 {
5405 scanType = pMac->scan.curScanType;
5406 if(eSIR_PASSIVE_SCAN == pMac->scan.curScanType)
5407 {
5408 if(minChnTime < pMac->roam.configParam.nPassiveMinChnTime)
5409 {
5410 minChnTime = pMac->roam.configParam.nPassiveMinChnTime;
5411 }
5412 if(maxChnTime < pMac->roam.configParam.nPassiveMaxChnTime)
5413 {
5414 maxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
5415 }
5416 }
5417 }
5418 pMsg->scanType = pal_cpu_to_be32(scanType);
5419
Vinay Krishna Eranna636b7bc2013-12-18 20:49:08 +05305420 pMsg->numSsid =
5421 (pScanReq->SSIDs.numOfSSIDs < SIR_SCAN_MAX_NUM_SSID) ?
5422 pScanReq->SSIDs.numOfSSIDs : SIR_SCAN_MAX_NUM_SSID;
Jeff Johnson295189b2012-06-20 16:38:30 -07005423 if((pScanReq->SSIDs.numOfSSIDs != 0) && ( eSIR_PASSIVE_SCAN != scanType ))
5424 {
Jeff Johnson40b59aa2013-03-19 14:43:18 -07005425 for (i = 0; i < pMsg->numSsid; i++)
5426 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305427 vos_mem_copy(&pMsg->ssId[i],
5428 &pScanReq->SSIDs.SSIDList[i].SSID, sizeof(tSirMacSSid));
Jeff Johnson40b59aa2013-03-19 14:43:18 -07005429 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005430 }
5431 else
5432 {
5433 //Otherwise we scan all SSID and let the result filter later
Jeff Johnson40b59aa2013-03-19 14:43:18 -07005434 for (i = 0; i < SIR_SCAN_MAX_NUM_SSID; i++)
5435 {
5436 pMsg->ssId[i].length = 0;
5437 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005438 }
5439
Jeff Johnson295189b2012-06-20 16:38:30 -07005440 pMsg->minChannelTime = pal_cpu_to_be32(minChnTime);
5441 pMsg->maxChannelTime = pal_cpu_to_be32(maxChnTime);
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08005442 pMsg->minChannelTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
5443 pMsg->maxChannelTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005444 //hidden SSID option
5445 pMsg->hiddenSsid = pScanReqParam->hiddenSsid;
5446 //rest time
5447 //pMsg->restTime = pScanReq->restTime;
5448 pMsg->returnAfterFirstMatch = pScanReqParam->bReturnAfter1stMatch;
5449 // All the scan results caching will be done by Roaming
5450 // We do not want LIM to do any caching of scan results,
5451 // so delete the LIM cache on all scan requests
5452 pMsg->returnFreshResults = pScanReqParam->freshScan;
5453 //Always ask for unique result
5454 pMsg->returnUniqueResults = pScanReqParam->fUniqueResult;
5455 pMsg->channelList.numChannels = (tANI_U8)pScanReq->ChannelInfo.numOfChannels;
5456 if(pScanReq->ChannelInfo.numOfChannels)
5457 {
5458 //Assuming the channelNumber is tANI_U8 (1 byte)
Kiet Lam64c1b492013-07-12 13:56:44 +05305459 vos_mem_copy(pMsg->channelList.channelNumber,
5460 pScanReq->ChannelInfo.ChannelList,
5461 pScanReq->ChannelInfo.numOfChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07005462 }
5463
5464 pMsg->uIEFieldLen = (tANI_U16) pScanReq->uIEFieldLen;
5465 pMsg->uIEFieldOffset = (tANI_U16)(sizeof( tSirSmeScanReq ) - sizeof( pMsg->channelList.channelNumber ) +
5466 ( sizeof( pMsg->channelList.channelNumber ) * pScanReq->ChannelInfo.numOfChannels )) ;
5467 if(pScanReq->uIEFieldLen != 0)
5468 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305469 vos_mem_copy((tANI_U8 *)pMsg+pMsg->uIEFieldOffset, pScanReq->pIEField,
5470 pScanReq->uIEFieldLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005471 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005472 pMsg->p2pSearch = pScanReq->p2pSearch;
Jeff Johnson295189b2012-06-20 16:38:30 -07005473
Madan Mohan Koyyalamudi9b876782012-10-11 16:22:51 -07005474 if (pScanReq->requestType == eCSR_SCAN_HO_BG_SCAN)
5475 {
5476 pMsg->backgroundScanMode = eSIR_ROAMING_SCAN;
5477 }
5478
Jeff Johnson295189b2012-06-20 16:38:30 -07005479 }while(0);
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05305480 smsLog(pMac, LOG1, FL("domainIdCurrent %s (%d) scanType %s (%d)"
5481 "bssType %s (%d), requestType %s(%d)"
5482 "numChannels %d"),
5483 voss_DomainIdtoString(pMac->scan.domainIdCurrent),
5484 pMac->scan.domainIdCurrent,
5485 lim_ScanTypetoString(pMsg->scanType), pMsg->scanType,
5486 lim_BssTypetoString(pMsg->bssType), pMsg->bssType,
5487 sme_requestTypetoString(pScanReq->requestType),
5488 pScanReq->requestType,
5489 pMsg->channelList.numChannels);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005490
5491 for(i = 0; i < pMsg->channelList.numChannels; i++)
5492 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005493 smsLog(pMac, LOG3, FL("channelNumber[%d]= %d"), i, pMsg->channelList.channelNumber[i]);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005494 }
5495
Jeff Johnson295189b2012-06-20 16:38:30 -07005496 if(HAL_STATUS_SUCCESS(status))
5497 {
5498 status = palSendMBMessage(pMac->hHdd, pMsg);
5499 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005500 else
5501 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005502 smsLog( pMac, LOGE, FL(" failed to send down scan req with status = %d"), status );
Kiet Lam64c1b492013-07-12 13:56:44 +05305503 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -07005504 }
5505 }//Success allocated memory
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005506 else
5507 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005508 smsLog( pMac, LOGE, FL(" memory allocation failure"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005509 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005510
Vinay Krishna Eranna636b7bc2013-12-18 20:49:08 +05305511 if(!HAL_STATUS_SUCCESS(status))
5512 {
5513 smsLog( pMac, LOG1, FL("Failed: SId: %d FirstMatch = %d"
5514 " UniqueResult = %d freshScan = %d hiddenSsid = %d"),
5515 sessionId, pScanReqParam->bReturnAfter1stMatch,
5516 pScanReqParam->fUniqueResult, pScanReqParam->freshScan,
5517 pScanReqParam->hiddenSsid );
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05305518 smsLog( pMac, LOG1, FL("scanType = %s (%d) BSSType = %s (%d) "
5519 "numOfSSIDs = %d numOfChannels = %d requestType = %s (%d)"
5520 " p2pSearch = %d\n"),
5521 lim_ScanTypetoString(pScanReq->scanType),
5522 pScanReq->scanType,
5523 lim_BssTypetoString(pScanReq->BSSType),
5524 pScanReq->BSSType,
Vinay Krishna Eranna636b7bc2013-12-18 20:49:08 +05305525 pScanReq->SSIDs.numOfSSIDs,
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05305526 pScanReq->ChannelInfo.numOfChannels,
5527 sme_requestTypetoString(pScanReq->requestType),
5528 pScanReq->requestType,
Vinay Krishna Eranna636b7bc2013-12-18 20:49:08 +05305529 pScanReq->p2pSearch );
5530
5531 }
5532
Jeff Johnson295189b2012-06-20 16:38:30 -07005533 return( status );
5534}
5535
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005536eHalStatus csrSendMBScanResultReq( tpAniSirGlobal pMac, tANI_U32 sessionId, tScanReqParam *pScanReqParam )
Jeff Johnson295189b2012-06-20 16:38:30 -07005537{
5538 eHalStatus status = eHAL_STATUS_SUCCESS;
5539 tSirSmeScanReq *pMsg;
5540 tANI_U16 msgLen;
5541
5542 msgLen = (tANI_U16)(sizeof( tSirSmeScanReq ));
Kiet Lam64c1b492013-07-12 13:56:44 +05305543 pMsg = vos_mem_malloc(msgLen);
5544 if ( NULL == pMsg )
5545 status = eHAL_STATUS_FAILURE;
5546 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005547 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305548 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005549 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SCAN_REQ);
5550 pMsg->length = pal_cpu_to_be16(msgLen);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005551 pMsg->sessionId = sessionId;
5552 pMsg->transactionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005553 pMsg->returnFreshResults = pScanReqParam->freshScan;
5554 //Always ask for unique result
5555 pMsg->returnUniqueResults = pScanReqParam->fUniqueResult;
5556 pMsg->returnAfterFirstMatch = pScanReqParam->bReturnAfter1stMatch;
5557 status = palSendMBMessage(pMac->hHdd, pMsg);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005558 if (!HAL_STATUS_SUCCESS(status))
5559 {
5560 smsLog( pMac, LOGE, FL(" failed to send down scan req with status = %d\n"), status );
5561 }
5562
Jeff Johnson295189b2012-06-20 16:38:30 -07005563 }
5564
5565 return( status );
5566}
5567
5568
5569
5570eHalStatus csrScanChannels( tpAniSirGlobal pMac, tSmeCmd *pCommand )
5571{
5572 eHalStatus status = eHAL_STATUS_FAILURE;
5573 tScanReqParam scanReq;
5574
5575 do
5576 {
5577 scanReq.freshScan = CSR_SME_SCAN_FLAGS_DELETE_CACHE | TRUE;
5578 scanReq.fUniqueResult = TRUE;
5579 scanReq.hiddenSsid = SIR_SCAN_NO_HIDDEN_SSID;
5580 if(eCsrScanForSsid == pCommand->u.scanCmd.reason)
5581 {
5582 scanReq.bReturnAfter1stMatch = CSR_SCAN_RETURN_AFTER_FIRST_MATCH;
5583 }
5584 else
5585 {
5586 // Basically do scan on all channels even for 11D 1st scan case.
5587 scanReq.bReturnAfter1stMatch = CSR_SCAN_RETURN_AFTER_ALL_CHANNELS;
5588 }
5589 if((eCsrScanBgScan == pCommand->u.scanCmd.reason)||
5590 (eCsrScanProbeBss == pCommand->u.scanCmd.reason))
5591 {
5592 scanReq.hiddenSsid = SIR_SCAN_HIDDEN_SSID_PE_DECISION;
5593 }
5594
5595#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5596 {
5597 vos_log_scan_pkt_type *pScanLog = NULL;
5598
5599 WLAN_VOS_DIAG_LOG_ALLOC(pScanLog, vos_log_scan_pkt_type, LOG_WLAN_SCAN_C);
5600 if(pScanLog)
5601 {
5602 if(eCsrScanBgScan == pCommand->u.scanCmd.reason ||
5603 eCsrScanProbeBss == pCommand->u.scanCmd.reason)
5604 {
5605 pScanLog->eventId = WLAN_SCAN_EVENT_HO_SCAN_REQ;
5606 }
5607 else
5608 {
5609 if( (eSIR_PASSIVE_SCAN != pCommand->u.scanCmd.u.scanRequest.scanType) &&
5610 (eSIR_PASSIVE_SCAN != pMac->scan.curScanType) )
5611 {
5612 pScanLog->eventId = WLAN_SCAN_EVENT_ACTIVE_SCAN_REQ;
5613 }
5614 else
5615 {
5616 pScanLog->eventId = WLAN_SCAN_EVENT_PASSIVE_SCAN_REQ;
5617 }
5618 }
5619 pScanLog->minChnTime = (v_U8_t)pCommand->u.scanCmd.u.scanRequest.minChnTime;
5620 pScanLog->maxChnTime = (v_U8_t)pCommand->u.scanCmd.u.scanRequest.maxChnTime;
5621 pScanLog->numChannel = (v_U8_t)pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels;
5622 if(pScanLog->numChannel && (pScanLog->numChannel < VOS_LOG_MAX_NUM_CHANNEL))
5623 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305624 vos_mem_copy(pScanLog->channels,
5625 pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList,
5626 pScanLog->numChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07005627 }
5628 WLAN_VOS_DIAG_LOG_REPORT(pScanLog);
5629 }
5630 }
5631#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5632
Agrawal Ashish0b6984f2014-04-05 18:35:45 +05305633 csrClearVotesForCountryInfo(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07005634 status = csrSendMBScanReq(pMac, pCommand->sessionId,
5635 &pCommand->u.scanCmd.u.scanRequest, &scanReq);
5636 }while(0);
5637
5638 return( status );
5639}
5640
5641
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005642eHalStatus csrScanRetrieveResult(tpAniSirGlobal pMac, tSmeCmd *pCommand)
Jeff Johnson295189b2012-06-20 16:38:30 -07005643{
5644 eHalStatus status = eHAL_STATUS_FAILURE;
5645 tScanReqParam scanReq;
5646
5647 do
5648 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005649#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5650 if (eCsrScanGetLfrResult == pCommand->u.scanCmd.reason)
5651 {
5652 //to get the LFR candidates from PE cache
5653 scanReq.freshScan = SIR_BG_SCAN_RETURN_LFR_CACHED_RESULTS|SIR_BG_SCAN_PURGE_LFR_RESULTS;
5654 scanReq.fUniqueResult = TRUE;
5655 scanReq.bReturnAfter1stMatch = CSR_SCAN_RETURN_AFTER_ALL_CHANNELS;
5656 }
5657 else
5658#endif
5659 {
5660 //not a fresh scan
5661 scanReq.freshScan = CSR_SME_SCAN_FLAGS_DELETE_CACHE;
5662 scanReq.fUniqueResult = TRUE;
5663 scanReq.bReturnAfter1stMatch = CSR_SCAN_RETURN_AFTER_ALL_CHANNELS;
5664 }
5665 status = csrSendMBScanResultReq(pMac, pCommand->sessionId, &scanReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07005666 }while(0);
5667
5668 return (status);
5669}
5670
5671
5672
5673eHalStatus csrProcessScanCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
5674{
5675 eHalStatus status = eHAL_STATUS_SUCCESS;
5676 tCsrChannelInfo newChannelInfo = {0, NULL};
5677 int i, j;
5678 tANI_U8 *pChannel = NULL;
5679 tANI_U32 len = 0;
5680
5681 // Transition to Scanning state...
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +05305682 if (!pMac->fScanOffload)
Jeff Johnson295189b2012-06-20 16:38:30 -07005683 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +05305684 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
5685 {
5686 pCommand->u.scanCmd.lastRoamState[i] =
5687 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_SCANNING, i);
5688 smsLog( pMac, LOG3, "starting SCAN command from %d state...."
5689 " reason is %d", pCommand->u.scanCmd.lastRoamState[i],
5690 pCommand->u.scanCmd.reason );
5691 }
5692 }
5693 else
5694 {
5695 pCommand->u.scanCmd.lastRoamState[pCommand->sessionId] =
5696 csrRoamStateChange(pMac, eCSR_ROAMING_STATE_SCANNING,
5697 pCommand->sessionId);
5698 smsLog( pMac, LOG3,
5699 "starting SCAN command from %d state.... reason is %d",
5700 pCommand->u.scanCmd.lastRoamState[pCommand->sessionId],
5701 pCommand->u.scanCmd.reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07005702 }
5703
5704 switch(pCommand->u.scanCmd.reason)
5705 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005706#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5707 case eCsrScanGetLfrResult:
5708#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005709 case eCsrScanGetResult:
5710 case eCsrScanForCapsChange: //For cap change, LIM already save BSS description
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005711 status = csrScanRetrieveResult(pMac, pCommand);
Jeff Johnson295189b2012-06-20 16:38:30 -07005712 break;
5713 case eCsrScanSetBGScanParam:
5714 status = csrProcessSetBGScanParam(pMac, pCommand);
5715 break;
5716 case eCsrScanBGScanAbort:
5717 status = csrSetCfgBackgroundScanPeriod(pMac, 0);
5718 break;
5719 case eCsrScanBGScanEnable:
5720 status = csrSetCfgBackgroundScanPeriod(pMac, pMac->roam.configParam.bgScanInterval);
5721 break;
5722 case eCsrScanGetScanChnInfo:
Madan Mohan Koyyalamudide1b5bc2013-07-12 00:56:04 +05305723 status = csrScanGetScanChannelInfo(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005724 break;
5725 case eCsrScanUserRequest:
5726 if(pMac->roam.configParam.fScanTwice)
5727 {
5728 //We scan 2.4 channel twice
5729 if(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels &&
5730 (NULL != pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList))
5731 {
5732 len = pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels;
5733 //allocate twice the channel
5734 newChannelInfo.ChannelList = (tANI_U8 *)vos_mem_malloc(newChannelInfo.numOfChannels * 2);
5735 pChannel = pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList;
5736 }
5737 else
5738 {
5739 //get the valid channel list to scan all.
5740 len = sizeof(pMac->roam.validChannelList);
5741
5742 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
5743 {
5744 //allocate twice the channel
5745 newChannelInfo.ChannelList = (tANI_U8 *)vos_mem_malloc(len * 2);
5746 pChannel = pMac->roam.validChannelList;
5747 }
5748 }
5749 if(NULL == newChannelInfo.ChannelList)
5750 {
5751 newChannelInfo.numOfChannels = 0;
5752 }
5753 else
5754 {
5755 j = 0;
5756 for(i = 0; i < len; i++)
5757 {
5758 newChannelInfo.ChannelList[j++] = pChannel[i];
5759 if(CSR_MAX_24GHz_CHANNEL_NUMBER >= pChannel[i])
5760 {
5761 newChannelInfo.ChannelList[j++] = pChannel[i];
5762 }
5763 }
5764 if(NULL != pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList)
5765 {
5766 //pChannel points to the channellist from the command, free it.
5767 vos_mem_free(pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList);
James Zmuda9ea1edd2013-04-18 18:20:54 -07005768 pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005769 }
5770 pCommand->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = j;
5771 pCommand->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = newChannelInfo.ChannelList;
5772 }
5773 } //if(pMac->roam.configParam.fScanTwice)
5774
5775 status = csrScanChannels(pMac, pCommand);
5776
5777 break;
5778 default:
5779 status = csrScanChannels(pMac, pCommand);
5780 break;
5781 }
5782
5783 if(!HAL_STATUS_SUCCESS(status))
5784 {
5785 csrReleaseScanCommand(pMac, pCommand, eCSR_SCAN_FAILURE);
5786 }
5787
5788 return (status);
5789}
5790
5791
5792eHalStatus csrScanSetBGScanparams(tpAniSirGlobal pMac, tCsrBGScanRequest *pScanReq)
5793{
5794 eHalStatus status = eHAL_STATUS_SUCCESS;
5795 tSmeCmd *pCommand = NULL;
5796
5797 if(pScanReq)
5798 {
5799 do
5800 {
5801 pCommand = csrGetCommandBuffer(pMac);
5802 if(!pCommand)
5803 {
5804 status = eHAL_STATUS_RESOURCES;
5805 break;
5806 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305807 vos_mem_set(&pCommand->u.scanCmd, sizeof(tScanCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005808 pCommand->command = eSmeCommandScan;
5809 pCommand->u.scanCmd.reason = eCsrScanSetBGScanParam;
5810 pCommand->u.scanCmd.callback = NULL;
5811 pCommand->u.scanCmd.pContext = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +05305812 vos_mem_copy(&pCommand->u.scanCmd.u.bgScanRequest, pScanReq, sizeof(tCsrBGScanRequest));
Jeff Johnson295189b2012-06-20 16:38:30 -07005813 //we have to do the follow
5814 if(pScanReq->ChannelInfo.numOfChannels == 0)
5815 {
5816 pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList = NULL;
5817 }
5818 else
5819 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305820 pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList
5821 = vos_mem_malloc(pScanReq->ChannelInfo.numOfChannels);
5822 if ( NULL != pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList )
Jeff Johnson295189b2012-06-20 16:38:30 -07005823 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305824 vos_mem_copy(pCommand->u.scanCmd.u.bgScanRequest.ChannelInfo.ChannelList,
5825 pScanReq->ChannelInfo.ChannelList,
5826 pScanReq->ChannelInfo.numOfChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07005827 }
5828 else
5829 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005830 smsLog(pMac, LOGE, FL("ran out of memory"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005831 csrReleaseCommandScan(pMac, pCommand);
Kiet Lam64c1b492013-07-12 13:56:44 +05305832 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005833 }
5834 }
5835
5836 //scan req for SSID
5837 if(pScanReq->SSID.length)
5838 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305839 vos_mem_copy(pCommand->u.scanCmd.u.bgScanRequest.SSID.ssId,
5840 pScanReq->SSID.ssId, pScanReq->SSID.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07005841 pCommand->u.scanCmd.u.bgScanRequest.SSID.length = pScanReq->SSID.length;
5842
5843 }
5844 pCommand->u.scanCmd.u.bgScanRequest.maxChnTime= pScanReq->maxChnTime;
5845 pCommand->u.scanCmd.u.bgScanRequest.minChnTime = pScanReq->minChnTime;
5846 pCommand->u.scanCmd.u.bgScanRequest.scanInterval = pScanReq->scanInterval;
5847
5848
5849 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
5850 if( !HAL_STATUS_SUCCESS( status ) )
5851 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005852 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005853 csrReleaseCommandScan( pMac, pCommand );
5854 break;
5855 }
5856 }while(0);
5857 }
5858
5859 return (status);
5860}
5861
5862eHalStatus csrScanBGScanAbort( tpAniSirGlobal pMac )
5863{
5864 eHalStatus status = eHAL_STATUS_SUCCESS;
5865 tSmeCmd *pCommand = NULL;
5866
5867 do
5868 {
5869 pCommand = csrGetCommandBuffer(pMac);
5870 if(!pCommand)
5871 {
5872 status = eHAL_STATUS_RESOURCES;
5873 break;
5874 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305875 vos_mem_set(&pCommand->u.scanCmd, sizeof(tScanCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005876 pCommand->command = eSmeCommandScan;
5877 pCommand->u.scanCmd.reason = eCsrScanBGScanAbort;
5878 pCommand->u.scanCmd.callback = NULL;
5879 pCommand->u.scanCmd.pContext = NULL;
5880 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
5881 if( !HAL_STATUS_SUCCESS( status ) )
5882 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005883 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005884 csrReleaseCommandScan( pMac, pCommand );
5885 break;
5886 }
5887 }while(0);
5888
5889 return (status);
5890}
5891
5892
5893//This will enable the background scan with the non-zero interval
5894eHalStatus csrScanBGScanEnable(tpAniSirGlobal pMac)
5895{
5896 eHalStatus status = eHAL_STATUS_SUCCESS;
5897 tSmeCmd *pCommand = NULL;
5898
5899 if(pMac->roam.configParam.bgScanInterval)
5900 {
5901 do
5902 {
5903 pCommand = csrGetCommandBuffer(pMac);
5904 if(!pCommand)
5905 {
5906 status = eHAL_STATUS_RESOURCES;
5907 break;
5908 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305909 vos_mem_set(&pCommand->u.scanCmd, sizeof(tScanCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005910 pCommand->command = eSmeCommandScan;
5911 pCommand->u.scanCmd.reason = eCsrScanBGScanEnable;
5912 pCommand->u.scanCmd.callback = NULL;
5913 pCommand->u.scanCmd.pContext = NULL;
5914 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
5915 if( !HAL_STATUS_SUCCESS( status ) )
5916 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005917 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005918 csrReleaseCommandScan( pMac, pCommand );
5919 break;
5920 }
5921 }while(0);
5922 //BG scan results are reported automatically by PE to SME once the scan is done.
5923 //No need to fetch the results explicitly.
5924 //csrScanStartGetResultTimer(pMac);
5925 csrScanStartResultAgingTimer(pMac);
5926 }
5927 else
5928 {
5929 //We don't have BG scan so stop the aging timer
5930 csrScanStopResultAgingTimer(pMac);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005931 smsLog(pMac, LOGE, FL("cannot continue because the bgscan interval is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005932 status = eHAL_STATUS_INVALID_PARAMETER;
5933 }
5934
5935 return (status);
5936}
5937
5938
5939eHalStatus csrScanCopyRequest(tpAniSirGlobal pMac, tCsrScanRequest *pDstReq, tCsrScanRequest *pSrcReq)
5940{
5941 eHalStatus status = eHAL_STATUS_SUCCESS;
5942 tANI_U32 len = sizeof(pMac->roam.validChannelList);
5943 tANI_U32 index = 0;
5944 tANI_U32 new_index = 0;
Manjunathappa Prakashde7b2a52014-02-28 16:59:03 -08005945 eNVChannelEnabledType NVchannel_state;
Arif Hussain6af38622014-03-12 12:39:57 -07005946 tANI_U8 ch144_support = 0;
5947
5948 ch144_support = WDA_getFwWlanFeatCaps(WLAN_CH144);
Jeff Johnson295189b2012-06-20 16:38:30 -07005949
5950 do
5951 {
5952 status = csrScanFreeRequest(pMac, pDstReq);
5953 if(HAL_STATUS_SUCCESS(status))
5954 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305955 vos_mem_copy(pDstReq, pSrcReq, sizeof(tCsrScanRequest));
Gopichand Nakkalac7b1d3e2012-12-31 14:07:19 -08005956 /* Re-initialize the pointers to NULL since we did a copy */
5957 pDstReq->pIEField = NULL;
5958 pDstReq->ChannelInfo.ChannelList = NULL;
5959 pDstReq->SSIDs.SSIDList = NULL;
5960
Jeff Johnson295189b2012-06-20 16:38:30 -07005961 if(pSrcReq->uIEFieldLen == 0)
5962 {
5963 pDstReq->pIEField = NULL;
5964 }
5965 else
5966 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305967 pDstReq->pIEField = vos_mem_malloc(pSrcReq->uIEFieldLen);
5968 if ( NULL == pDstReq->pIEField )
Jeff Johnson295189b2012-06-20 16:38:30 -07005969 {
Vinay Krishna Eranna636b7bc2013-12-18 20:49:08 +05305970 status = eHAL_STATUS_FAILURE;
5971 smsLog(pMac, LOGE, FL("No memory for scanning IE fields"));
5972 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005973 }
5974 else
5975 {
Vinay Krishna Eranna636b7bc2013-12-18 20:49:08 +05305976 status = eHAL_STATUS_SUCCESS;
5977 vos_mem_copy(pDstReq->pIEField, pSrcReq->pIEField,
5978 pSrcReq->uIEFieldLen);
5979 pDstReq->uIEFieldLen = pSrcReq->uIEFieldLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005980 }
5981 }//Allocate memory for IE field
5982 {
5983 if(pSrcReq->ChannelInfo.numOfChannels == 0)
5984 {
5985 pDstReq->ChannelInfo.ChannelList = NULL;
5986 pDstReq->ChannelInfo.numOfChannels = 0;
5987 }
5988 else
5989 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305990 pDstReq->ChannelInfo.ChannelList = vos_mem_malloc(
5991 pSrcReq->ChannelInfo.numOfChannels
5992 * sizeof(*pDstReq->ChannelInfo.ChannelList));
5993 if ( NULL == pDstReq->ChannelInfo.ChannelList )
Jeff Johnson295189b2012-06-20 16:38:30 -07005994 {
Vinay Krishna Eranna636b7bc2013-12-18 20:49:08 +05305995 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005996 pDstReq->ChannelInfo.numOfChannels = 0;
Vinay Krishna Eranna636b7bc2013-12-18 20:49:08 +05305997 smsLog(pMac, LOGE, FL("No memory for scanning Channel"
5998 " List"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005999 break;
6000 }
6001
6002 if((pSrcReq->scanType == eSIR_PASSIVE_SCAN) && (pSrcReq->requestType == eCSR_SCAN_REQUEST_11D_SCAN))
6003 {
6004 for ( index = 0; index < pSrcReq->ChannelInfo.numOfChannels ; index++ )
6005 {
Arif Hussain6af38622014-03-12 12:39:57 -07006006 /* Skip CH 144 if firmware support not present */
6007 if (pSrcReq->ChannelInfo.ChannelList[index] == 144 && !ch144_support)
6008 continue;
6009
Manjunathappa Prakashde7b2a52014-02-28 16:59:03 -08006010 NVchannel_state = vos_nv_getChannelEnabledState(
6011 pSrcReq->ChannelInfo.ChannelList[index]);
6012 if ((NV_CHANNEL_ENABLE == NVchannel_state) ||
6013 (NV_CHANNEL_DFS == NVchannel_state))
6014 {
6015 pDstReq->ChannelInfo.ChannelList[new_index] =
6016 pSrcReq->ChannelInfo.ChannelList[index];
6017 new_index++;
6018 }
Vinay Krishna Eranna636b7bc2013-12-18 20:49:08 +05306019 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006020 pDstReq->ChannelInfo.numOfChannels = new_index;
6021 }
6022 else if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
6023 {
6024 new_index = 0;
6025 pMac->roam.numValidChannels = len;
c_hpothu0d5a7352014-03-22 12:30:25 +05306026
6027 /* Since in CsrScanRequest,value of pMac->scan.nextScanID
6028 * is incremented before calling CsrScanCopyRequest, as a
6029 * result pMac->scan.nextScanID is equal to ONE for the
6030 * first scan.
6031 */
6032 if (pMac->roam.configParam.initialScanSkipDFSCh &&
6033 1 == pMac->scan.nextScanID )
6034 {
6035 smsLog(pMac, LOG1,
6036 FL("Initial scan, scan only non-DFS channels"));
6037
6038 for (index = 0; index < pSrcReq->ChannelInfo.
6039 numOfChannels ; index++ )
6040 {
6041 if((csrRoamIsValidChannel(pMac, pSrcReq->ChannelInfo.
6042 ChannelList[index])))
6043 {
6044 /*Skiipping DFS Channels for 1st scan */
6045 if(NV_CHANNEL_DFS ==
6046 vos_nv_getChannelEnabledState(pSrcReq->ChannelInfo.
6047 ChannelList[index]))
6048 continue ;
6049
6050 pDstReq->ChannelInfo.ChannelList[new_index] =
6051 pSrcReq->ChannelInfo.ChannelList[index];
6052 new_index++;
6053
6054 }
6055 }
6056 pMac->roam.configParam.initialScanSkipDFSCh = 0;
6057 }
6058 else
6059 {
6060 for ( index = 0; index < pSrcReq->ChannelInfo.
6061 numOfChannels ; index++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07006062 {
Arif Hussain6af38622014-03-12 12:39:57 -07006063 /* Skip CH 144 if firmware support not present */
6064 if (pSrcReq->ChannelInfo.ChannelList[index] == 144 && !ch144_support)
6065 continue;
6066
Madan Mohan Koyyalamudi783b2362012-10-21 11:54:41 -07006067 /* Allow scan on valid channels only.
Arif Hussain6af38622014-03-12 12:39:57 -07006068 * If it is p2p scan and valid channel list doesnt contain
Madan Mohan Koyyalamudi783b2362012-10-21 11:54:41 -07006069 * social channels, enforce scan on social channels because
6070 * that is the only way to find p2p peers.
6071 * This can happen only if band is set to 5Ghz mode.
6072 */
Madan Mohan Koyyalamudic5992c92012-11-15 16:40:57 -08006073 if((csrRoamIsValidChannel(pMac, pSrcReq->ChannelInfo.ChannelList[index])) ||
6074 ((eCSR_SCAN_P2P_DISCOVERY == pSrcReq->requestType) &&
Madan Mohan Koyyalamudi783b2362012-10-21 11:54:41 -07006075 CSR_IS_SOCIAL_CHANNEL(pSrcReq->ChannelInfo.ChannelList[index])))
Jeff Johnson295189b2012-06-20 16:38:30 -07006076 {
Srikant Kuppa866893f2012-12-27 17:28:14 -08006077 if( (pSrcReq->skipDfsChnlInP2pSearch &&
Madan Mohan Koyyalamudic5992c92012-11-15 16:40:57 -08006078 (NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(pSrcReq->ChannelInfo.ChannelList[index])) )
Srikant Kuppa866893f2012-12-27 17:28:14 -08006079#ifdef FEATURE_WLAN_LFR
6080 /*
6081 * If LFR is requesting a contiguous scan
6082 * (i.e. numOfChannels > 1), then ignore
6083 * DFS channels.
6084 * TODO: vos_nv_getChannelEnabledState is returning
6085 * 120, 124 and 128 as non-DFS channels. Hence, the
6086 * use of direct check for channels below.
6087 */
6088 || ((eCSR_SCAN_HO_BG_SCAN == pSrcReq->requestType) &&
6089 (pSrcReq->ChannelInfo.numOfChannels > 1) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08006090 (CSR_IS_CHANNEL_DFS(pSrcReq->ChannelInfo.ChannelList[index])))
Srikant Kuppa866893f2012-12-27 17:28:14 -08006091#endif
6092 )
6093 {
6094#ifdef FEATURE_WLAN_LFR
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05306095 smsLog(pMac, LOG2,
6096 FL(" reqType=%s (%d), numOfChannels=%d,"
6097 " ignoring DFS channel %d"),
6098 sme_requestTypetoString(pSrcReq->requestType),
6099 pSrcReq->requestType,
6100 pSrcReq->ChannelInfo.numOfChannels,
6101 pSrcReq->ChannelInfo.ChannelList[index]);
Srikant Kuppa866893f2012-12-27 17:28:14 -08006102#endif
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05306103 continue;
Srikant Kuppa866893f2012-12-27 17:28:14 -08006104 }
Madan Mohan Koyyalamudic5992c92012-11-15 16:40:57 -08006105
Jeff Johnson295189b2012-06-20 16:38:30 -07006106 pDstReq->ChannelInfo.ChannelList[new_index] =
6107 pSrcReq->ChannelInfo.ChannelList[index];
6108 new_index++;
6109 }
6110 }
c_hpothu0d5a7352014-03-22 12:30:25 +05306111 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006112 pDstReq->ChannelInfo.numOfChannels = new_index;
Srikant Kuppa866893f2012-12-27 17:28:14 -08006113#ifdef FEATURE_WLAN_LFR
6114 if ((eCSR_SCAN_HO_BG_SCAN == pSrcReq->requestType) &&
6115 (0 == pDstReq->ChannelInfo.numOfChannels))
6116 {
6117 /*
6118 * No valid channels found in the request.
6119 * Only perform scan on the channels passed
6120 * pSrcReq if it is a eCSR_SCAN_HO_BG_SCAN.
6121 * Passing 0 to LIM will trigger a scan on
6122 * all valid channels which is not desirable.
6123 */
Vinay Krishna Eranna636b7bc2013-12-18 20:49:08 +05306124 smsLog(pMac, LOGE, FL(" no valid channels found"
6125 " (request=%d)"), pSrcReq->requestType);
Srikant Kuppa866893f2012-12-27 17:28:14 -08006126 for ( index = 0; index < pSrcReq->ChannelInfo.numOfChannels ; index++ )
6127 {
Vinay Krishna Eranna636b7bc2013-12-18 20:49:08 +05306128 smsLog(pMac, LOGE, FL("pSrcReq index=%d"
6129 " channel=%d"), index,
6130 pSrcReq->ChannelInfo.ChannelList[index]);
Srikant Kuppa866893f2012-12-27 17:28:14 -08006131 }
6132 status = eHAL_STATUS_FAILURE;
6133 break;
6134 }
6135#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006136 }
6137 else
6138 {
Vinay Krishna Eranna636b7bc2013-12-18 20:49:08 +05306139 smsLog(pMac, LOGE, FL("Couldn't get the valid Channel"
6140 " List, keeping requester's list"));
Kiet Lam64c1b492013-07-12 13:56:44 +05306141 vos_mem_copy(pDstReq->ChannelInfo.ChannelList,
6142 pSrcReq->ChannelInfo.ChannelList,
6143 pSrcReq->ChannelInfo.numOfChannels
6144 * sizeof(*pDstReq->ChannelInfo.ChannelList));
Jeff Johnson295189b2012-06-20 16:38:30 -07006145 pDstReq->ChannelInfo.numOfChannels = pSrcReq->ChannelInfo.numOfChannels;
6146 }
6147 }//Allocate memory for Channel List
6148 }
6149 if(pSrcReq->SSIDs.numOfSSIDs == 0)
6150 {
6151 pDstReq->SSIDs.numOfSSIDs = 0;
6152 pDstReq->SSIDs.SSIDList = NULL;
6153 }
6154 else
6155 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306156 pDstReq->SSIDs.SSIDList = vos_mem_malloc(
6157 pSrcReq->SSIDs.numOfSSIDs * sizeof(*pDstReq->SSIDs.SSIDList));
6158 if ( NULL == pDstReq->SSIDs.SSIDList )
6159 status = eHAL_STATUS_FAILURE;
6160 else
6161 status = eHAL_STATUS_SUCCESS;
6162 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006163 {
6164 pDstReq->SSIDs.numOfSSIDs = pSrcReq->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306165 vos_mem_copy(pDstReq->SSIDs.SSIDList,
6166 pSrcReq->SSIDs.SSIDList,
6167 pSrcReq->SSIDs.numOfSSIDs * sizeof(*pDstReq->SSIDs.SSIDList));
Jeff Johnson295189b2012-06-20 16:38:30 -07006168 }
6169 else
6170 {
6171 pDstReq->SSIDs.numOfSSIDs = 0;
Vinay Krishna Eranna636b7bc2013-12-18 20:49:08 +05306172 smsLog(pMac, LOGE, FL("No memory for scanning SSID List"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006173 break;
6174 }
6175 }//Allocate memory for SSID List
Jeff Johnson295189b2012-06-20 16:38:30 -07006176 pDstReq->p2pSearch = pSrcReq->p2pSearch;
Jeff Johnsone7245742012-09-05 17:12:55 -07006177 pDstReq->skipDfsChnlInP2pSearch = pSrcReq->skipDfsChnlInP2pSearch;
Jeff Johnson295189b2012-06-20 16:38:30 -07006178
6179 }
6180 }while(0);
6181
6182 if(!HAL_STATUS_SUCCESS(status))
6183 {
6184 csrScanFreeRequest(pMac, pDstReq);
6185 }
6186
6187 return (status);
6188}
6189
6190
6191eHalStatus csrScanFreeRequest(tpAniSirGlobal pMac, tCsrScanRequest *pReq)
6192{
Jeff Johnson295189b2012-06-20 16:38:30 -07006193
6194 if(pReq->ChannelInfo.ChannelList)
6195 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306196 vos_mem_free(pReq->ChannelInfo.ChannelList);
Jeff Johnson295189b2012-06-20 16:38:30 -07006197 pReq->ChannelInfo.ChannelList = NULL;
6198 }
6199 pReq->ChannelInfo.numOfChannels = 0;
6200 if(pReq->pIEField)
6201 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306202 vos_mem_free(pReq->pIEField);
Jeff Johnson295189b2012-06-20 16:38:30 -07006203 pReq->pIEField = NULL;
6204 }
6205 pReq->uIEFieldLen = 0;
6206 if(pReq->SSIDs.SSIDList)
6207 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306208 vos_mem_free(pReq->SSIDs.SSIDList);
Jeff Johnson295189b2012-06-20 16:38:30 -07006209 pReq->SSIDs.SSIDList = NULL;
6210 }
6211 pReq->SSIDs.numOfSSIDs = 0;
6212
Kiet Lam64c1b492013-07-12 13:56:44 +05306213 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006214}
6215
6216
6217void csrScanCallCallback(tpAniSirGlobal pMac, tSmeCmd *pCommand, eCsrScanStatus scanStatus)
6218{
6219 if(pCommand->u.scanCmd.callback)
6220 {
6221// sme_ReleaseGlobalLock( &pMac->sme );
6222 pCommand->u.scanCmd.callback(pMac, pCommand->u.scanCmd.pContext, pCommand->u.scanCmd.scanID, scanStatus);
6223// sme_AcquireGlobalLock( &pMac->sme );
6224 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006225 smsLog( pMac, LOG2, "%s:%d - Callback NULL!!!", __func__, __LINE__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006226 }
6227}
6228
6229
6230void csrScanStopTimers(tpAniSirGlobal pMac)
6231{
6232 csrScanStopResultAgingTimer(pMac);
6233 csrScanStopIdleScanTimer(pMac);
6234 csrScanStopGetResultTimer(pMac);
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08006235 if(0 != pMac->scan.scanResultCfgAgingTime )
6236 {
6237 csrScanStopResultCfgAgingTimer(pMac);
6238 }
6239
Jeff Johnson295189b2012-06-20 16:38:30 -07006240}
6241
6242
6243eHalStatus csrScanStartGetResultTimer(tpAniSirGlobal pMac)
6244{
6245 eHalStatus status;
6246
6247 if(pMac->scan.fScanEnable)
6248 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306249 status = vos_timer_start(&pMac->scan.hTimerGetResult, CSR_SCAN_GET_RESULT_INTERVAL/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -07006250 }
6251 else
6252 {
6253 status = eHAL_STATUS_FAILURE;
6254 }
6255
6256 return (status);
6257}
6258
6259
6260eHalStatus csrScanStopGetResultTimer(tpAniSirGlobal pMac)
6261{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306262 return (vos_timer_stop(&pMac->scan.hTimerGetResult));
Jeff Johnson295189b2012-06-20 16:38:30 -07006263}
6264
6265
6266void csrScanGetResultTimerHandler(void *pv)
6267{
6268 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
6269
6270 csrScanRequestResult(pMac);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306271
6272 vos_timer_start(&pMac->scan.hTimerGetResult, CSR_SCAN_GET_RESULT_INTERVAL/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -07006273}
6274
6275#ifdef WLAN_AP_STA_CONCURRENCY
6276static void csrStaApConcTimerHandler(void *pv)
6277{
6278 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
6279 tListElem *pEntry;
6280 tSmeCmd *pScanCmd;
6281
6282 csrLLLock(&pMac->scan.scanCmdPendingList);
6283
6284 if ( NULL != ( pEntry = csrLLPeekHead( &pMac->scan.scanCmdPendingList, LL_ACCESS_NOLOCK) ) )
6285 {
6286 tCsrScanRequest scanReq;
6287 tSmeCmd *pSendScanCmd = NULL;
6288 tANI_U8 numChn = 0;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07006289 tANI_U8 nNumChanCombinedConc = 0;
Vinay Malekal05fdc812012-12-17 13:04:30 -08006290 tANI_U8 i, j;
Jeff Johnson295189b2012-06-20 16:38:30 -07006291 tCsrChannelInfo *pChnInfo = &scanReq.ChannelInfo;
6292 tANI_U8 channelToScan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
6293 eHalStatus status;
6294
Jeff Johnson295189b2012-06-20 16:38:30 -07006295 pScanCmd = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6296 numChn = pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels;
Madan Mohan Koyyalamudid6713582012-11-09 16:56:56 -08006297
6298 /* if any session is connected and the number of channels to scan is
6299 * greater than 1 then split the scan into multiple scan operations
6300 * on each individual channel else continue to perform scan on all
6301 * specified channels */
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08006302
6303 /* split scan if number of channels to scan is greater than 1 and
6304 * any one of the following:
6305 * - STA session is connected and the scan is not a P2P search
6306 * - any P2P session is connected
Srikant Kuppa866893f2012-12-27 17:28:14 -08006307 * Do not split scans if no concurrent infra connections are
6308 * active and if the scan is a BG scan triggered by LFR (OR)
6309 * any scan if LFR is in the middle of a BG scan. Splitting
6310 * the scan is delaying the time it takes for LFR to find
6311 * candidates and resulting in disconnects.
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08006312 */
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07006313
6314 if((csrIsStaSessionConnected(pMac) &&
6315 !csrIsP2pSessionConnected(pMac)))
6316 {
6317 nNumChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
6318 }
6319 else if(csrIsP2pSessionConnected(pMac))
6320 {
6321 nNumChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
6322 }
6323
6324 if ( (numChn > nNumChanCombinedConc) &&
Srikant Kuppa866893f2012-12-27 17:28:14 -08006325 ((csrIsStaSessionConnected(pMac) &&
6326#ifdef FEATURE_WLAN_LFR
6327 (csrIsConcurrentInfraConnected(pMac) ||
6328 ((pScanCmd->u.scanCmd.reason != eCsrScanBgScan) &&
6329 (pMac->roam.neighborRoamInfo.neighborRoamState !=
6330 eCSR_NEIGHBOR_ROAM_STATE_CFG_CHAN_LIST_SCAN))) &&
6331#endif
6332 (pScanCmd->u.scanCmd.u.scanRequest.p2pSearch != 1)) ||
Madan Mohan Koyyalamudi48081ef2012-12-04 16:49:55 -08006333 (csrIsP2pSessionConnected(pMac))))
Jeff Johnson295189b2012-06-20 16:38:30 -07006334 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306335 vos_mem_set(&scanReq, sizeof(tCsrScanRequest), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006336
6337 pSendScanCmd = csrGetCommandBuffer(pMac); //optimize this to use 2 command buffer only
6338 if (!pSendScanCmd)
6339 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006340 smsLog( pMac, LOGE, FL(" Failed to get Queue command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006341 csrLLUnlock(&pMac->scan.scanCmdPendingList);
6342 return;
6343 }
6344 pSendScanCmd->command = pScanCmd->command;
6345 pSendScanCmd->sessionId = pScanCmd->sessionId;
6346 pSendScanCmd->u.scanCmd.callback = NULL;
6347 pSendScanCmd->u.scanCmd.pContext = pScanCmd->u.scanCmd.pContext;
6348 pSendScanCmd->u.scanCmd.reason = pScanCmd->u.scanCmd.reason;
6349 pSendScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around
6350
Madan Mohan Koyyalamudiaf2a8b92012-10-09 14:58:07 -07006351 /* First copy all the parameters to local variable of scan request */
6352 csrScanCopyRequest(pMac, &scanReq, &pScanCmd->u.scanCmd.u.scanRequest);
6353
6354 /* Now modify the elements of local var scan request required to be modified for split scan */
Madan Mohan Koyyalamudi0c626f32012-11-30 15:10:25 -08006355 if(scanReq.ChannelInfo.ChannelList != NULL)
6356 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306357 vos_mem_free(scanReq.ChannelInfo.ChannelList);
Madan Mohan Koyyalamudi0c626f32012-11-30 15:10:25 -08006358 scanReq.ChannelInfo.ChannelList = NULL;
6359 }
6360
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07006361 pChnInfo->numOfChannels = nNumChanCombinedConc;
Kiet Lam64c1b492013-07-12 13:56:44 +05306362 vos_mem_copy(&channelToScan[0],
6363 &pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[0],
6364 pChnInfo->numOfChannels * sizeof(tANI_U8));//just send one channel
Jeff Johnson295189b2012-06-20 16:38:30 -07006365 pChnInfo->ChannelList = &channelToScan[0];
6366
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07006367 for (i = 0, j = nNumChanCombinedConc; i < (numChn-nNumChanCombinedConc); i++, j++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006368 {
6369 pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[i] =
Vinay Malekal05fdc812012-12-17 13:04:30 -08006370 pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[j]; //Move all the channels one step
Jeff Johnson295189b2012-06-20 16:38:30 -07006371 }
6372
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07006373 pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = numChn - nNumChanCombinedConc; //reduce outstanding # of channels to be scanned
Jeff Johnson295189b2012-06-20 16:38:30 -07006374
6375 scanReq.BSSType = eCSR_BSS_TYPE_ANY;
c_hpothudbefd3e2014-04-28 15:59:47 +05306376
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07006377 //Use concurrency values for min/maxChnTime.
6378 //We know csrIsAnySessionConnected(pMac) returns TRUE here
6379 csrSetDefaultScanTiming(pMac, scanReq.scanType, &scanReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07006380
6381 status = csrScanCopyRequest(pMac, &pSendScanCmd->u.scanCmd.u.scanRequest, &scanReq);
6382 if(!HAL_STATUS_SUCCESS(status))
6383 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006384 smsLog( pMac, LOGE, FL(" Failed to get copy csrScanRequest = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006385 csrLLUnlock(&pMac->scan.scanCmdPendingList);
6386 return;
Madan Mohan Koyyalamudi0c626f32012-11-30 15:10:25 -08006387 }
6388 /* Clean the local scan variable */
6389 scanReq.ChannelInfo.ChannelList = NULL;
6390 scanReq.ChannelInfo.numOfChannels = 0;
6391 csrScanFreeRequest(pMac, &scanReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07006392 }
6393 else
Madan Mohan Koyyalamudid6713582012-11-09 16:56:56 -08006394 {
6395 /* no active connected session present or numChn == 1
6396 * scan all remaining channels */
Jeff Johnson295189b2012-06-20 16:38:30 -07006397 pSendScanCmd = pScanCmd;
6398 //remove this command from pending list
6399 if (csrLLRemoveHead( &pMac->scan.scanCmdPendingList, LL_ACCESS_NOLOCK) == NULL)
6400 { //In case between PeekHead and here, the entry got removed by another thread.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006401 smsLog( pMac, LOGE, FL(" Failed to remove entry from scanCmdPendingList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006402 }
6403
6404 }
6405 csrQueueSmeCommand(pMac, pSendScanCmd, eANI_BOOLEAN_FALSE);
6406
6407 }
6408
Jeff Johnson295189b2012-06-20 16:38:30 -07006409 csrLLUnlock(&pMac->scan.scanCmdPendingList);
6410
6411}
6412#endif
6413
6414eHalStatus csrScanStartResultAgingTimer(tpAniSirGlobal pMac)
6415{
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08006416 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006417
6418 if(pMac->scan.fScanEnable)
6419 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306420 status = vos_timer_start(&pMac->scan.hTimerResultAging, CSR_SCAN_RESULT_AGING_INTERVAL/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -07006421 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006422 return (status);
6423}
6424
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08006425eHalStatus csrScanStartResultCfgAgingTimer(tpAniSirGlobal pMac)
6426{
6427 eHalStatus status = eHAL_STATUS_FAILURE;
6428
6429 if(pMac->scan.fScanEnable)
6430 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306431 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 -08006432 }
6433 return (status);
6434}
Jeff Johnson295189b2012-06-20 16:38:30 -07006435
6436eHalStatus csrScanStopResultAgingTimer(tpAniSirGlobal pMac)
6437{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306438 return (vos_timer_stop(&pMac->scan.hTimerResultAging));
Jeff Johnson295189b2012-06-20 16:38:30 -07006439}
6440
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08006441eHalStatus csrScanStopResultCfgAgingTimer(tpAniSirGlobal pMac)
6442{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306443 return (vos_timer_stop(&pMac->scan.hTimerResultCfgAging));
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08006444}
Jeff Johnson295189b2012-06-20 16:38:30 -07006445
6446//This function returns the maximum time a BSS is allowed in the scan result.
6447//The time varies base on connection and power saving factors.
6448//Not connected, No PS
6449//Not connected, with PS
6450//Connected w/o traffic, No PS
6451//Connected w/o traffic, with PS
6452//Connected w/ traffic, no PS -- Not supported
6453//Connected w/ traffic, with PS -- Not supported
6454//the return unit is in seconds.
6455tANI_U32 csrScanGetAgeOutTime(tpAniSirGlobal pMac)
6456{
6457 tANI_U32 nRet;
6458
6459 if(pMac->scan.nAgingCountDown)
6460 {
6461 //Calculate what should be the timeout value for this
6462 nRet = pMac->scan.nLastAgeTimeOut * pMac->scan.nAgingCountDown;
6463 pMac->scan.nAgingCountDown--;
6464 }
6465 else
6466 {
6467 if( csrIsAllSessionDisconnected( pMac ) )
6468 {
6469 if(pmcIsPowerSaveEnabled(pMac, ePMC_IDLE_MODE_POWER_SAVE))
6470 {
6471 nRet = pMac->roam.configParam.scanAgeTimeNCPS;
6472 }
6473 else
6474 {
6475 nRet = pMac->roam.configParam.scanAgeTimeNCNPS;
6476 }
6477 }
6478 else
6479 {
6480 if(pmcIsPowerSaveEnabled(pMac, ePMC_BEACON_MODE_POWER_SAVE))
6481 {
6482 nRet = pMac->roam.configParam.scanAgeTimeCPS;
6483 }
6484 else
6485 {
6486 nRet = pMac->roam.configParam.scanAgeTimeCNPS;
6487 }
6488 }
6489 //If state-change causing aging time out change, we want to delay it somewhat to avoid
6490 //unnecessary removal of BSS. This is mostly due to transition from connect to disconnect.
6491 if(pMac->scan.nLastAgeTimeOut > nRet)
6492 {
6493 if(nRet)
6494 {
6495 pMac->scan.nAgingCountDown = (pMac->scan.nLastAgeTimeOut / nRet);
6496 }
6497 pMac->scan.nLastAgeTimeOut = nRet;
6498 nRet *= pMac->scan.nAgingCountDown;
6499 }
6500 else
6501 {
6502 pMac->scan.nLastAgeTimeOut = nRet;
6503 }
6504 }
6505
6506 return (nRet);
6507}
6508
6509
6510void csrScanResultAgingTimerHandler(void *pv)
6511{
6512 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
6513 tANI_BOOLEAN fDisconnected = csrIsAllSessionDisconnected(pMac);
6514
6515 //no scan, no aging
Kaushik, Sushant9073c0c2014-03-11 19:10:23 +05306516 if (pMac->scan.fScanEnable &&
Jeff Johnson295189b2012-06-20 16:38:30 -07006517 (((eANI_BOOLEAN_FALSE == fDisconnected) && pMac->roam.configParam.bgScanInterval)
Kaushik, Sushant9073c0c2014-03-11 19:10:23 +05306518 || (fDisconnected && (pMac->scan.fCancelIdleScan == eANI_BOOLEAN_FALSE))
6519 || (pMac->fScanOffload))
Jeff Johnson295189b2012-06-20 16:38:30 -07006520 )
6521 {
6522 tListElem *pEntry, *tmpEntry;
6523 tCsrScanResult *pResult;
6524 tANI_TIMESTAMP ageOutTime = (tANI_TIMESTAMP)(csrScanGetAgeOutTime(pMac) * PAL_TICKS_PER_SECOND); //turn it into 10ms units
6525 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
6526
6527 csrLLLock(&pMac->scan.scanResultList);
6528 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
6529 while( pEntry )
6530 {
6531 tmpEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
6532 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
6533 if((curTime - pResult->Result.BssDescriptor.nReceivedTime) > ageOutTime)
6534 {
6535 smsLog(pMac, LOGW, " age out due to time out");
6536 csrScanAgeOutBss(pMac, pResult);
6537 }
6538 pEntry = tmpEntry;
6539 }
6540 csrLLUnlock(&pMac->scan.scanResultList);
6541 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306542 vos_timer_start(&pMac->scan.hTimerResultAging, CSR_SCAN_RESULT_AGING_INTERVAL/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -07006543}
6544
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08006545static void csrScanResultCfgAgingTimerHandler(void *pv)
6546{
6547 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
6548 tListElem *pEntry, *tmpEntry;
6549 tCsrScanResult *pResult;
6550 tANI_TIMESTAMP ageOutTime = pMac->scan.scanResultCfgAgingTime * PAL_TICKS_PER_SECOND;
6551 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
6552
6553 csrLLLock(&pMac->scan.scanResultList);
6554 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
6555 while( pEntry )
6556 {
6557 tmpEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
6558 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
6559 if((curTime - pResult->Result.BssDescriptor.nReceivedTime) > ageOutTime)
6560 {
6561 smsLog(pMac, LOGW, " age out due to time out");
6562 csrScanAgeOutBss(pMac, pResult);
6563 }
6564 pEntry = tmpEntry;
6565 }
6566 csrLLUnlock(&pMac->scan.scanResultList);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306567 vos_timer_start(&pMac->scan.hTimerResultCfgAging, CSR_SCAN_RESULT_CFG_AGING_INTERVAL/PAL_TIMER_TO_MS_UNIT);
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08006568}
Jeff Johnson295189b2012-06-20 16:38:30 -07006569
6570eHalStatus csrScanStartIdleScanTimer(tpAniSirGlobal pMac, tANI_U32 interval)
6571{
6572 eHalStatus status;
6573
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006574 smsLog(pMac, LOG1, " csrScanStartIdleScanTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -07006575 if((pMac->scan.fScanEnable) && (eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan) && interval)
6576 {
6577 pMac->scan.nIdleScanTimeGap += interval;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306578 vos_timer_stop(&pMac->scan.hTimerIdleScan);
6579 status = vos_timer_start(&pMac->scan.hTimerIdleScan, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -07006580 if( !HAL_STATUS_SUCCESS(status) )
6581 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006582 smsLog(pMac, LOGE, " Fail to start Idle scan timer. status = %d interval = %d", status, interval);
Jeff Johnson295189b2012-06-20 16:38:30 -07006583 //This should not happen but set the flag to restart when ready
6584 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE;
6585 }
6586 }
6587 else
6588 {
6589 if( pMac->scan.fScanEnable && (eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan) )
6590 {
6591 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE;
6592 }
6593 status = eHAL_STATUS_FAILURE;
6594 }
6595
6596 return (status);
6597}
6598
6599
6600eHalStatus csrScanStopIdleScanTimer(tpAniSirGlobal pMac)
6601{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306602 return (vos_timer_stop(&pMac->scan.hTimerIdleScan));
Jeff Johnson295189b2012-06-20 16:38:30 -07006603}
6604
6605
6606//Stop CSR from asking for IMPS, This function doesn't disable IMPS from CSR
6607void csrScanSuspendIMPS( tpAniSirGlobal pMac )
6608{
6609 csrScanCancelIdleScan(pMac);
6610}
6611
6612
6613//Start CSR from asking for IMPS. This function doesn't trigger CSR to request entering IMPS
6614//because IMPS maybe disabled.
6615void csrScanResumeIMPS( tpAniSirGlobal pMac )
6616{
6617 csrScanStartIdleScan( pMac );
6618}
6619
6620
6621void csrScanIMPSCallback(void *callbackContext, eHalStatus status)
6622{
6623 tpAniSirGlobal pMac = PMAC_STRUCT( callbackContext );
6624
6625 if(eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan)
6626 {
6627 if(pMac->roam.configParam.IsIdleScanEnabled)
6628 {
6629 if(HAL_STATUS_SUCCESS(status))
6630 {
6631 if(csrIsAllSessionDisconnected(pMac) && !csrIsRoamCommandWaiting(pMac))
6632 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006633 smsLog(pMac, LOGW, FL("starts idle mode full scan"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006634 csrScanAllChannels(pMac, eCSR_SCAN_IDLE_MODE_SCAN);
6635 }
6636 else
6637 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006638 smsLog(pMac, LOGW, FL("cannot start idle mode full scan"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006639 //even though we are in timer handle, calling stop timer will make sure the timer
6640 //doesn't get to restart.
6641 csrScanStopIdleScanTimer(pMac);
6642 }
6643 }
6644 else
6645 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006646 smsLog(pMac, LOGE, FL("sees not success status (%d)"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006647 }
6648 }
6649 else
6650 {//we might need another flag to check if CSR needs to request imps at all
6651
6652 tANI_U32 nTime = 0;
6653
6654 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
6655 if(!HAL_STATUS_SUCCESS(csrScanTriggerIdleScan(pMac, &nTime)))
6656 {
6657 csrScanStartIdleScanTimer(pMac, nTime);
6658 }
6659 }
6660 }
6661}
6662
6663
6664//Param: pTimeInterval -- Caller allocated memory in return, if failed, to specify the nxt time interval for
6665//idle scan timer interval
6666//Return: Not success -- meaning it cannot start IMPS, caller needs to start a timer for idle scan
6667eHalStatus csrScanTriggerIdleScan(tpAniSirGlobal pMac, tANI_U32 *pTimeInterval)
6668{
6669 eHalStatus status = eHAL_STATUS_CSR_WRONG_STATE;
6670
6671 //Do not trigger IMPS in case of concurrency
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006672 if (vos_concurrent_sessions_running() && csrIsAnySessionInConnectState(pMac))
6673 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006674 smsLog( pMac, LOG1, FL("Cannot request IMPS because Concurrent Sessions Running") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006675 return (status);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006676 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006677
6678 if(pTimeInterval)
6679 {
6680 *pTimeInterval = 0;
6681 }
6682
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006683 smsLog(pMac, LOG3, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006684 if( smeCommandPending( pMac ) )
6685 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006686 smsLog( pMac, LOG1, FL(" Cannot request IMPS because command pending") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006687 //Not to enter IMPS because more work to do
6688 if(pTimeInterval)
6689 {
6690 *pTimeInterval = 0;
6691 }
6692 //restart when ready
6693 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE;
6694
6695 return (status);
6696 }
Kiran Kumar Lokeref8c39922013-03-18 11:08:11 -07006697 if (IsPmcImpsReqFailed (pMac))
6698 {
6699 if(pTimeInterval)
6700 {
6701 *pTimeInterval = 1000000; //usec
6702 }
6703 //restart when ready
6704 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006705
Kiran Kumar Lokeref8c39922013-03-18 11:08:11 -07006706 return status;
6707 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006708 if((pMac->scan.fScanEnable) && (eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan)
6709 /*&& pMac->roam.configParam.impsSleepTime*/)
6710 {
6711 //Stop get result timer because idle scan gets scan result out of PE
6712 csrScanStopGetResultTimer(pMac);
6713 if(pTimeInterval)
6714 {
6715 *pTimeInterval = pMac->roam.configParam.impsSleepTime;
6716 }
6717 //pmcRequestImps take a period in millisecond unit.
6718 status = pmcRequestImps(pMac, pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_MS_UNIT, csrScanIMPSCallback, pMac);
6719 if(!HAL_STATUS_SUCCESS(status))
6720 {
6721 if(eHAL_STATUS_PMC_ALREADY_IN_IMPS != status)
6722 {
6723 //Do restart the timer if CSR thinks it cannot do IMPS
6724 if( !csrCheckPSReady( pMac ) )
6725 {
6726 if(pTimeInterval)
6727 {
6728 *pTimeInterval = 0;
6729 }
6730 //Set the restart flag to true because that idle scan
6731 //can be restarted even though the timer will not be running
6732 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE;
6733 }
6734 else
6735 {
6736 //For not now, we do a quicker retry
6737 if(pTimeInterval)
6738 {
6739 *pTimeInterval = CSR_IDLE_SCAN_WAIT_TIME;
6740 }
6741 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006742 smsLog(pMac, LOGW, FL("call pmcRequestImps and it returns status code (%d)"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006743 }
6744 else
6745 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006746 smsLog(pMac, LOGW, FL("already in IMPS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006747 //Since CSR is the only module to request for IMPS. If it is already in IMPS, CSR assumes
6748 //the callback will be called in the future. Should not happen though.
6749 status = eHAL_STATUS_SUCCESS;
6750 pMac->scan.nIdleScanTimeGap = 0;
6751 }
6752 }
6753 else
6754 {
6755 //requested so let's reset the value
6756 pMac->scan.nIdleScanTimeGap = 0;
6757 }
6758 }
6759
6760 return (status);
6761}
6762
6763
6764eHalStatus csrScanStartIdleScan(tpAniSirGlobal pMac)
6765{
6766 eHalStatus status = eHAL_STATUS_CSR_WRONG_STATE;
6767 tANI_U32 nTime = 0;
6768
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006769 smsLog(pMac, LOGW, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006770 if(pMac->roam.configParam.IsIdleScanEnabled)
6771 {
6772 //stop bg scan first
6773 csrScanBGScanAbort(pMac);
6774 //Stop get result timer because idle scan gets scan result out of PE
6775 csrScanStopGetResultTimer(pMac);
6776 //Enable aging timer since idle scan is going on
6777 csrScanStartResultAgingTimer(pMac);
6778 }
6779 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE;
6780 status = csrScanTriggerIdleScan(pMac, &nTime);
6781 if(!HAL_STATUS_SUCCESS(status))
6782 {
6783 csrScanStartIdleScanTimer(pMac, nTime);
6784 }
6785
6786 return (status);
6787}
6788
6789
6790void csrScanCancelIdleScan(tpAniSirGlobal pMac)
6791{
6792 if(eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan)
6793 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006794 if (vos_concurrent_sessions_running()) {
6795 return;
6796 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006797 smsLog(pMac, LOG1, " csrScanCancelIdleScan");
Jeff Johnson295189b2012-06-20 16:38:30 -07006798 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_TRUE;
6799 //Set the restart flag in case later on it is uncancelled
6800 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_TRUE;
6801 csrScanStopIdleScanTimer(pMac);
6802 csrScanRemoveNotRoamingScanCommand(pMac);
6803 }
6804}
6805
6806
6807void csrScanIdleScanTimerHandler(void *pv)
6808{
6809 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
6810 eHalStatus status;
6811 tANI_U32 nTime = 0;
6812
6813 smsLog(pMac, LOGW, " csrScanIdleScanTimerHandler called ");
Kiran Kumar Lokeref8c39922013-03-18 11:08:11 -07006814 pmcResetImpsFailStatus (pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07006815 status = csrScanTriggerIdleScan(pMac, &nTime);
6816 if(!HAL_STATUS_SUCCESS(status) && (eANI_BOOLEAN_FALSE == pMac->scan.fCancelIdleScan))
6817 {
6818 //Check whether it is time to actually do an idle scan
6819 if(pMac->scan.nIdleScanTimeGap >= pMac->roam.configParam.impsSleepTime)
6820 {
6821 pMac->scan.nIdleScanTimeGap = 0;
6822 csrScanIMPSCallback(pMac, eHAL_STATUS_SUCCESS);
6823 }
6824 else
6825 {
6826 csrScanStartIdleScanTimer(pMac, nTime);
6827 }
6828 }
6829}
6830
6831
6832
6833
6834tANI_BOOLEAN csrScanRemoveNotRoamingScanCommand(tpAniSirGlobal pMac)
6835{
6836 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
6837 tListElem *pEntry, *pEntryTmp;
6838 tSmeCmd *pCommand;
6839 tDblLinkList localList;
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +05306840 tDblLinkList *pCmdList;
Jeff Johnson295189b2012-06-20 16:38:30 -07006841
6842 vos_mem_zero(&localList, sizeof(tDblLinkList));
6843 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
6844 {
6845 smsLog(pMac, LOGE, FL(" failed to open list"));
6846 return fRet;
6847 }
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +05306848 if (!pMac->fScanOffload)
6849 pCmdList = &pMac->sme.smeCmdPendingList;
6850 else
6851 pCmdList = &pMac->sme.smeScanCmdPendingList;
Jeff Johnson295189b2012-06-20 16:38:30 -07006852
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +05306853 csrLLLock(pCmdList);
6854 pEntry = csrLLPeekHead(pCmdList, LL_ACCESS_NOLOCK);
Jeff Johnson295189b2012-06-20 16:38:30 -07006855 while(pEntry)
6856 {
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +05306857 pEntryTmp = csrLLNext(pCmdList, pEntry, LL_ACCESS_NOLOCK);
Jeff Johnson295189b2012-06-20 16:38:30 -07006858 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6859 if( eSmeCommandScan == pCommand->command )
6860 {
6861 switch( pCommand->u.scanCmd.reason )
6862 {
6863 case eCsrScanIdleScan:
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +05306864 if( csrLLRemoveEntry(pCmdList, pEntry, LL_ACCESS_NOLOCK) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006865 {
6866 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
6867 }
6868 fRet = eANI_BOOLEAN_TRUE;
6869 break;
6870
6871 default:
6872 break;
6873 } //switch
6874 }
6875 pEntry = pEntryTmp;
6876 }
6877
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +05306878 csrLLUnlock(pCmdList);
Jeff Johnson295189b2012-06-20 16:38:30 -07006879
6880 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
6881 {
6882 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6883 csrReleaseCommandScan( pMac, pCommand );
6884 }
6885
6886 csrLLClose(&localList);
6887
6888 return (fRet);
6889}
6890
6891
6892tANI_BOOLEAN csrScanRemoveFreshScanCommand(tpAniSirGlobal pMac, tANI_U8 sessionId)
6893{
6894 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
6895 tListElem *pEntry, *pEntryTmp;
6896 tSmeCmd *pCommand;
6897 tDblLinkList localList;
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +05306898 tDblLinkList *pCmdList;
Jeff Johnson295189b2012-06-20 16:38:30 -07006899
6900 vos_mem_zero(&localList, sizeof(tDblLinkList));
6901 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
6902 {
6903 smsLog(pMac, LOGE, FL(" failed to open list"));
6904 return fRet;
6905 }
6906
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +05306907 if (!pMac->fScanOffload)
6908 pCmdList = &pMac->sme.smeCmdPendingList;
6909 else
6910 pCmdList = &pMac->sme.smeScanCmdPendingList;
6911
6912 csrLLLock(pCmdList);
6913 pEntry = csrLLPeekHead(pCmdList, LL_ACCESS_NOLOCK);
Jeff Johnson295189b2012-06-20 16:38:30 -07006914 while(pEntry)
6915 {
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +05306916 pEntryTmp = csrLLNext(pCmdList, pEntry, LL_ACCESS_NOLOCK);
Jeff Johnson295189b2012-06-20 16:38:30 -07006917 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6918 if( (eSmeCommandScan == pCommand->command) && (sessionId == pCommand->sessionId) )
6919 {
6920 switch(pCommand->u.scanCmd.reason)
6921 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07006922#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
6923 case eCsrScanGetLfrResult:
6924#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006925 case eCsrScanGetResult:
6926 case eCsrScanSetBGScanParam:
6927 case eCsrScanBGScanAbort:
6928 case eCsrScanBGScanEnable:
6929 case eCsrScanGetScanChnInfo:
6930 break;
6931 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006932 smsLog (pMac, LOGW, "%s: -------- abort scan command reason = %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07006933 __func__, pCommand->u.scanCmd.reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07006934 //The rest are fresh scan requests
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +05306935 if( csrLLRemoveEntry(pCmdList, pEntry, LL_ACCESS_NOLOCK) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006936 {
6937 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
6938 }
6939 fRet = eANI_BOOLEAN_TRUE;
6940 break;
6941 }
6942 }
6943 pEntry = pEntryTmp;
6944 }
6945
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +05306946 csrLLUnlock(pCmdList);
Jeff Johnson295189b2012-06-20 16:38:30 -07006947
6948 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
6949 {
6950 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6951 if (pCommand->u.scanCmd.callback)
6952 {
6953 /* User scan request is pending,
6954 * send response with status eCSR_SCAN_ABORT*/
6955 pCommand->u.scanCmd.callback(pMac,
6956 pCommand->u.scanCmd.pContext,
6957 pCommand->u.scanCmd.scanID,
6958 eCSR_SCAN_ABORT);
6959 }
6960 csrReleaseCommandScan( pMac, pCommand );
6961 }
6962 csrLLClose(&localList);
6963
6964 return (fRet);
6965}
6966
6967
6968void csrReleaseScanCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand, eCsrScanStatus scanStatus)
6969{
6970 eCsrScanReason reason = pCommand->u.scanCmd.reason;
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +05306971 tANI_BOOLEAN status;
6972
6973 if (!pMac->fScanOffload)
Jeff Johnson295189b2012-06-20 16:38:30 -07006974 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +05306975 tANI_U32 i;
6976 for(i = 0; i < CSR_ROAM_SESSION_MAX; i++)
6977 csrRoamStateChange(pMac, pCommand->u.scanCmd.lastRoamState[i], i);
6978 }
6979 else
6980 {
6981 csrRoamStateChange(pMac,
6982 pCommand->u.scanCmd.lastRoamState[pCommand->sessionId],
6983 pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006984 }
6985
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +05306986 csrScanCallCallback(pMac, pCommand, scanStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006987
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006988 smsLog(pMac, LOG3, " Remove Scan command reason = %d", reason);
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +05306989 if (pMac->fScanOffload)
6990 {
6991 status = csrLLRemoveEntry(&pMac->sme.smeScanCmdActiveList,
6992 &pCommand->Link, LL_ACCESS_LOCK);
6993 }
6994 else
6995 {
6996 status = csrLLRemoveEntry(&pMac->sme.smeCmdActiveList,
6997 &pCommand->Link, LL_ACCESS_LOCK);
6998 }
6999
7000 if(status)
Jeff Johnson295189b2012-06-20 16:38:30 -07007001 {
7002 csrReleaseCommandScan( pMac, pCommand );
7003 }
7004 else
7005 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +05307006 smsLog(pMac, LOGE,
7007 " ********csrReleaseScanCommand cannot release command reason %d",
7008 pCommand->u.scanCmd.reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07007009 }
7010}
7011
7012
7013eHalStatus csrScanGetPMKIDCandidateList(tpAniSirGlobal pMac, tANI_U32 sessionId,
7014 tPmkidCandidateInfo *pPmkidList, tANI_U32 *pNumItems )
7015{
7016 eHalStatus status = eHAL_STATUS_SUCCESS;
7017 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7018
Jeff Johnson32d95a32012-09-10 13:15:23 -07007019 if(!pSession)
7020 {
7021 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7022 return eHAL_STATUS_FAILURE;
7023 }
7024
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007025 smsLog(pMac, LOGW, " pMac->scan.NumPmkidCandidate = %d", pSession->NumPmkidCandidate);
Jeff Johnson295189b2012-06-20 16:38:30 -07007026 csrResetPMKIDCandidateList(pMac, sessionId);
7027 if(csrIsConnStateConnected(pMac, sessionId) && pSession->pCurRoamProfile)
7028 {
7029 tCsrScanResultFilter *pScanFilter;
7030 tCsrScanResultInfo *pScanResult;
7031 tScanResultHandle hBSSList;
7032 tANI_U32 nItems = *pNumItems;
7033
7034 *pNumItems = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05307035 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
7036 if ( NULL == pScanFilter )
7037 status = eHAL_STATUS_FAILURE;
7038 else
Jeff Johnson295189b2012-06-20 16:38:30 -07007039 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307040 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007041 //Here is the profile we need to connect to
7042 status = csrRoamPrepareFilterFromProfile(pMac, pSession->pCurRoamProfile, pScanFilter);
7043 if(HAL_STATUS_SUCCESS(status))
7044 {
7045 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7046 if(HAL_STATUS_SUCCESS(status))
7047 {
7048 while(((pScanResult = csrScanResultGetNext(pMac, hBSSList)) != NULL) && ( pSession->NumPmkidCandidate < nItems))
7049 {
7050 //NumPmkidCandidate adds up here
7051 csrProcessBSSDescForPMKIDList(pMac, &pScanResult->BssDescriptor,
7052 (tDot11fBeaconIEs *)( pScanResult->pvIes ));
7053 }
7054 if(pSession->NumPmkidCandidate)
7055 {
7056 *pNumItems = pSession->NumPmkidCandidate;
Kiet Lam64c1b492013-07-12 13:56:44 +05307057 vos_mem_copy(pPmkidList, pSession->PmkidCandidateInfo,
7058 pSession->NumPmkidCandidate * sizeof(tPmkidCandidateInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07007059 }
7060 csrScanResultPurge(pMac, hBSSList);
7061 }//Have scan result
7062 csrFreeScanFilter(pMac, pScanFilter);
7063 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307064 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007065 }
7066 }
7067
7068 return (status);
7069}
7070
7071
7072
7073#ifdef FEATURE_WLAN_WAPI
7074eHalStatus csrScanGetBKIDCandidateList(tpAniSirGlobal pMac, tANI_U32 sessionId,
7075 tBkidCandidateInfo *pBkidList, tANI_U32 *pNumItems )
7076{
7077 eHalStatus status = eHAL_STATUS_SUCCESS;
7078 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7079
Jeff Johnson32d95a32012-09-10 13:15:23 -07007080 if(!pSession)
7081 {
7082 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7083 return eHAL_STATUS_FAILURE;
7084 }
7085
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007086 smsLog(pMac, LOGW, " pMac->scan.NumBkidCandidate = %d", pSession->NumBkidCandidate);
Jeff Johnson295189b2012-06-20 16:38:30 -07007087 csrResetBKIDCandidateList(pMac, sessionId);
7088 if(csrIsConnStateConnected(pMac, sessionId) && pSession->pCurRoamProfile)
7089 {
7090 tCsrScanResultFilter *pScanFilter;
7091 tCsrScanResultInfo *pScanResult;
7092 tScanResultHandle hBSSList;
7093 tANI_U32 nItems = *pNumItems;
7094 *pNumItems = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05307095 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
7096 if ( NULL == pScanFilter )
7097 status = eHAL_STATUS_FAILURE;
7098 else
Jeff Johnson295189b2012-06-20 16:38:30 -07007099 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307100 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007101 //Here is the profile we need to connect to
7102 status = csrRoamPrepareFilterFromProfile(pMac, pSession->pCurRoamProfile, pScanFilter);
7103 if(HAL_STATUS_SUCCESS(status))
7104 {
7105 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7106 if(HAL_STATUS_SUCCESS(status))
7107 {
7108 while(((pScanResult = csrScanResultGetNext(pMac, hBSSList)) != NULL) && ( pSession->NumBkidCandidate < nItems))
7109 {
7110 //pMac->scan.NumBkidCandidate adds up here
7111 csrProcessBSSDescForBKIDList(pMac, &pScanResult->BssDescriptor,
7112 (tDot11fBeaconIEs *)( pScanResult->pvIes ));
7113
7114 }
7115 if(pSession->NumBkidCandidate)
7116 {
7117 *pNumItems = pSession->NumBkidCandidate;
Kiet Lam64c1b492013-07-12 13:56:44 +05307118 vos_mem_copy(pBkidList, pSession->BkidCandidateInfo, pSession->NumBkidCandidate * sizeof(tBkidCandidateInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07007119 }
7120 csrScanResultPurge(pMac, hBSSList);
7121 }//Have scan result
7122 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307123 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007124 }
7125 }
7126
7127 return (status);
7128}
7129#endif /* FEATURE_WLAN_WAPI */
7130
7131
7132
7133//This function is usually used for BSSs that suppresses SSID so the profile
7134//shall have one and only one SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07007135eHalStatus csrScanForSSID(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tANI_U32 roamId, tANI_BOOLEAN notify)
Jeff Johnson295189b2012-06-20 16:38:30 -07007136{
7137 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
7138 tSmeCmd *pScanCmd = NULL;
7139 tANI_U8 bAddr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
7140 tANI_U8 index = 0;
7141 tANI_U32 numSsid = pProfile->SSIDs.numOfSSIDs;
7142
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007143 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007144 //For WDS, we use the index 0. There must be at least one in there
7145 if( CSR_IS_WDS_STA( pProfile ) && numSsid )
7146 {
7147 numSsid = 1;
7148 }
7149 if(pMac->scan.fScanEnable && ( numSsid == 1 ) )
7150 {
7151 do
7152 {
7153 pScanCmd = csrGetCommandBuffer(pMac);
7154 if(!pScanCmd)
7155 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007156 smsLog(pMac, LOGE, FL("failed to allocate command buffer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007157 break;
7158 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307159 vos_mem_set(&pScanCmd->u.scanCmd, sizeof(tScanCmd), 0);
7160 pScanCmd->u.scanCmd.pToRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
7161 if ( NULL == pScanCmd->u.scanCmd.pToRoamProfile )
krunal soni587bf012014-02-04 12:35:11 -08007162 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307163 status = eHAL_STATUS_FAILURE;
krunal soni587bf012014-02-04 12:35:11 -08007164 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307165 else
krunal soni587bf012014-02-04 12:35:11 -08007166 {
7167 status = csrRoamCopyProfile(pMac, pScanCmd->u.scanCmd.pToRoamProfile, pProfile);
7168 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007169 if(!HAL_STATUS_SUCCESS(status))
7170 break;
7171 pScanCmd->u.scanCmd.roamId = roamId;
7172 pScanCmd->command = eSmeCommandScan;
Jeff Johnsone7245742012-09-05 17:12:55 -07007173 pScanCmd->sessionId = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007174 pScanCmd->u.scanCmd.callback = NULL;
7175 pScanCmd->u.scanCmd.pContext = NULL;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07007176 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 -07007177 pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around
Kiet Lam64c1b492013-07-12 13:56:44 +05307178 vos_mem_set(&pScanCmd->u.scanCmd.u.scanRequest, sizeof(tCsrScanRequest), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007179 pScanCmd->u.scanCmd.u.scanRequest.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07007180 pScanCmd->u.scanCmd.u.scanRequest.BSSType = pProfile->BSSType;
Jeff Johnsone7245742012-09-05 17:12:55 -07007181 // To avoid 11b rate in probe request Set p2pSearch flag as 1 for P2P Client Mode
7182 if(VOS_P2P_CLIENT_MODE == pProfile->csrPersona)
7183 {
7184 pScanCmd->u.scanCmd.u.scanRequest.p2pSearch = 1;
7185 }
Agarwal Ashish4f616132013-12-30 23:32:50 +05307186 if(pProfile->nAddIEScanLength)
Jeff Johnsone7245742012-09-05 17:12:55 -07007187 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307188 pScanCmd->u.scanCmd.u.scanRequest.pIEField = vos_mem_malloc(
7189 pProfile->nAddIEScanLength);
7190 if ( NULL == pScanCmd->u.scanCmd.u.scanRequest.pIEField )
7191 status = eHAL_STATUS_FAILURE;
7192 else
7193 status = eHAL_STATUS_SUCCESS;
7194 vos_mem_set(pScanCmd->u.scanCmd.u.scanRequest.pIEField,
7195 pProfile->nAddIEScanLength, 0);
7196 if (HAL_STATUS_SUCCESS(status))
Jeff Johnsone7245742012-09-05 17:12:55 -07007197 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307198 vos_mem_copy(pScanCmd->u.scanCmd.u.scanRequest.pIEField,
Agarwal Ashish4f616132013-12-30 23:32:50 +05307199 pProfile->addIEScan, pProfile->nAddIEScanLength);
Jeff Johnsone7245742012-09-05 17:12:55 -07007200 pScanCmd->u.scanCmd.u.scanRequest.uIEFieldLen = pProfile->nAddIEScanLength;
7201 }
7202 else
7203 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007204 smsLog(pMac, LOGE, "No memory for scanning IE fields");
Jeff Johnsone7245742012-09-05 17:12:55 -07007205 }
7206 } //Allocate memory for IE field
7207 else
7208 {
7209 pScanCmd->u.scanCmd.u.scanRequest.uIEFieldLen = 0;
7210 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07007211 /* For one channel be good enpugh time to receive beacon atleast */
7212 if( 1 == pProfile->ChannelInfo.numOfChannels )
7213 {
7214 pScanCmd->u.scanCmd.u.scanRequest.maxChnTime = MAX_ACTIVE_SCAN_FOR_ONE_CHANNEL;
7215 pScanCmd->u.scanCmd.u.scanRequest.minChnTime = MIN_ACTIVE_SCAN_FOR_ONE_CHANNEL;
7216 }
7217 else
7218 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307219 pScanCmd->u.scanCmd.u.scanRequest.maxChnTime =
7220 pMac->roam.configParam.nActiveMaxChnTime;
7221 pScanCmd->u.scanCmd.u.scanRequest.minChnTime =
7222 pMac->roam.configParam.nActiveMinChnTime;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007223 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307224 pScanCmd->u.scanCmd.u.scanRequest.maxChnTimeBtc =
7225 pMac->roam.configParam.nActiveMaxChnTimeBtc;
7226 pScanCmd->u.scanCmd.u.scanRequest.minChnTimeBtc =
7227 pMac->roam.configParam.nActiveMinChnTimeBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07007228 if(pProfile->BSSIDs.numOfBSSIDs == 1)
7229 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307230 vos_mem_copy(pScanCmd->u.scanCmd.u.scanRequest.bssid,
7231 pProfile->BSSIDs.bssid, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07007232 }
7233 else
7234 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307235 vos_mem_copy(pScanCmd->u.scanCmd.u.scanRequest.bssid, bAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07007236 }
7237 if(pProfile->ChannelInfo.numOfChannels)
7238 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307239 pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList = vos_mem_malloc(
7240 sizeof(*pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList)
7241 * pProfile->ChannelInfo.numOfChannels);
7242 if ( NULL == pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList )
7243 status = eHAL_STATUS_FAILURE;
7244 else
7245 status = eHAL_STATUS_SUCCESS;
7246 pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = 0;
7247 if(HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07007248 {
7249 csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[0]);
7250 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
7251 {
7252 if(csrRoamIsValidChannel(pMac, pProfile->ChannelInfo.ChannelList[index]))
7253 {
7254 pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.ChannelList[pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels]
7255 = pProfile->ChannelInfo.ChannelList[index];
7256 pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels++;
7257 }
7258 else
7259 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007260 smsLog(pMac, LOGW, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007261 }
7262
7263 }
7264 }
7265 else
7266 {
7267 break;
7268 }
7269
7270 }
7271 else
7272 {
7273 pScanCmd->u.scanCmd.u.scanRequest.ChannelInfo.numOfChannels = 0;
7274 }
7275 if(pProfile->SSIDs.numOfSSIDs)
7276 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307277 pScanCmd->u.scanCmd.u.scanRequest.SSIDs.SSIDList = vos_mem_malloc(
7278 pProfile->SSIDs.numOfSSIDs * sizeof(tCsrSSIDInfo));
7279 if ( NULL == pScanCmd->u.scanCmd.u.scanRequest.SSIDs.SSIDList )
7280 status = eHAL_STATUS_FAILURE;
7281 else
7282 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007283 if(!HAL_STATUS_SUCCESS(status))
7284 {
7285 break;
7286 }
7287 pScanCmd->u.scanCmd.u.scanRequest.SSIDs.numOfSSIDs = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05307288 vos_mem_copy(pScanCmd->u.scanCmd.u.scanRequest.SSIDs.SSIDList,
7289 pProfile->SSIDs.SSIDList, sizeof(tCsrSSIDInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07007290 }
7291 //Start process the command
7292 status = csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_FALSE);
7293 if( !HAL_STATUS_SUCCESS( status ) )
7294 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007295 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007296 break;
7297 }
7298 }while(0);
7299 if(!HAL_STATUS_SUCCESS(status))
7300 {
7301 if(pScanCmd)
7302 {
7303 csrReleaseCommandScan(pMac, pScanCmd);
7304 //TODO:free the memory that is allocated in this function
7305 }
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07007306 if(notify)
7307 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007308 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
7309 }
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07007310 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007311 }//valid
7312 else
7313 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007314 smsLog(pMac, LOGE, FL("cannot scan because scanEnable (%d) or numSSID (%d) is invalid"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007315 pMac->scan.fScanEnable, pProfile->SSIDs.numOfSSIDs);
7316 }
7317
7318 return (status);
7319}
7320
7321
7322//Issue a scan base on the new capability infomation
7323//This should only happen when the associated AP changes its capability.
7324//After this scan is done, CSR reroams base on the new scan results
7325eHalStatus csrScanForCapabilityChange(tpAniSirGlobal pMac, tSirSmeApNewCaps *pNewCaps)
7326{
7327 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
7328 tSmeCmd *pScanCmd = NULL;
7329
7330 if(pNewCaps)
7331 {
7332 do
7333 {
7334 pScanCmd = csrGetCommandBuffer(pMac);
7335 if(!pScanCmd)
7336 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007337 smsLog(pMac, LOGE, FL("failed to allocate command buffer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007338 status = eHAL_STATUS_RESOURCES;
7339 break;
7340 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307341 vos_mem_set(&pScanCmd->u.scanCmd, sizeof(tScanCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007342 status = eHAL_STATUS_SUCCESS;
7343 pScanCmd->u.scanCmd.roamId = 0;
7344 pScanCmd->command = eSmeCommandScan;
7345 pScanCmd->u.scanCmd.callback = NULL;
7346 pScanCmd->u.scanCmd.pContext = NULL;
7347 pScanCmd->u.scanCmd.reason = eCsrScanForCapsChange;
7348 pScanCmd->u.scanCmd.scanID = pMac->scan.nextScanID++; //let it wrap around
7349 status = csrQueueSmeCommand(pMac, pScanCmd, eANI_BOOLEAN_FALSE);
7350 if( !HAL_STATUS_SUCCESS( status ) )
7351 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007352 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007353 break;
7354 }
7355 }while(0);
7356 if(!HAL_STATUS_SUCCESS(status))
7357 {
7358 if(pScanCmd)
7359 {
7360 csrReleaseCommandScan(pMac, pScanCmd);
7361 }
7362 }
7363 }
7364
7365 return (status);
7366}
7367
7368
7369
7370void csrInitBGScanChannelList(tpAniSirGlobal pMac)
7371{
7372 tANI_U32 len = CSR_MIN(sizeof(pMac->roam.validChannelList), sizeof(pMac->scan.bgScanChannelList));
7373
Kiet Lam64c1b492013-07-12 13:56:44 +05307374 vos_mem_set(pMac->scan.bgScanChannelList, len, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007375 pMac->scan.numBGScanChannel = 0;
7376
7377 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
7378 {
7379 pMac->roam.numValidChannels = len;
7380 pMac->scan.numBGScanChannel = (tANI_U8)CSR_MIN(len, WNI_CFG_BG_SCAN_CHANNEL_LIST_LEN);
Kiet Lam64c1b492013-07-12 13:56:44 +05307381 vos_mem_copy(pMac->scan.bgScanChannelList, pMac->roam.validChannelList,
7382 pMac->scan.numBGScanChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07007383 csrSetBGScanChannelList(pMac, pMac->scan.bgScanChannelList, pMac->scan.numBGScanChannel);
7384 }
7385}
7386
7387
7388//This function return TRUE if background scan channel list is adjusted.
7389//this function will only shrink the background scan channel list
7390tANI_BOOLEAN csrAdjustBGScanChannelList(tpAniSirGlobal pMac, tANI_U8 *pChannelList, tANI_U8 NumChannels,
7391 tANI_U8 *pAdjustChannels, tANI_U8 *pNumAdjustChannels)
7392{
7393 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7394 tANI_U8 i, j, count = *pNumAdjustChannels;
7395
7396 i = 0;
7397 while(i < count)
7398 {
7399 for(j = 0; j < NumChannels; j++)
7400 {
7401 if(pChannelList[j] == pAdjustChannels[i])
7402 break;
7403 }
7404 if(j == NumChannels)
7405 {
7406 //This channel is not in the list, remove it
7407 fRet = eANI_BOOLEAN_TRUE;
7408 count--;
7409 if(count - i)
7410 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307411 vos_mem_copy(&pAdjustChannels[i], &pAdjustChannels[i+1], count - i);
Jeff Johnson295189b2012-06-20 16:38:30 -07007412 }
7413 else
7414 {
7415 //already remove the last one. Done.
7416 break;
7417 }
7418 }
7419 else
7420 {
7421 i++;
7422 }
7423 }//while(i<count)
7424 *pNumAdjustChannels = count;
7425
7426 return (fRet);
7427}
7428
7429
7430//Get the list of the base channels to scan for passively 11d info
7431eHalStatus csrScanGetSupportedChannels( tpAniSirGlobal pMac )
7432{
7433 eHalStatus status = eHAL_STATUS_SUCCESS;
7434 int n = WNI_CFG_VALID_CHANNEL_LIST_LEN;
7435
7436 status = vos_nv_getSupportedChannels( pMac->scan.baseChannels.channelList, &n, NULL, NULL );
7437 if( HAL_STATUS_SUCCESS(status) )
7438 {
7439 pMac->scan.baseChannels.numChannels = (tANI_U8)n;
7440 }
7441 else
7442 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007443 smsLog( pMac, LOGE, FL(" failed") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007444 pMac->scan.baseChannels.numChannels = 0;
7445 }
7446
7447 return ( status );
7448}
7449
7450//This function use the input pChannelList to validate the current saved channel list
7451eHalStatus csrSetBGScanChannelList( tpAniSirGlobal pMac, tANI_U8 *pAdjustChannels, tANI_U8 NumAdjustChannels)
7452{
7453 tANI_U32 dataLen = sizeof( tANI_U8 ) * NumAdjustChannels;
7454
7455 return (ccmCfgSetStr(pMac, WNI_CFG_BG_SCAN_CHANNEL_LIST, pAdjustChannels, dataLen, NULL, eANI_BOOLEAN_FALSE));
7456}
7457
7458
7459void csrSetCfgValidChannelList( tpAniSirGlobal pMac, tANI_U8 *pChannelList, tANI_U8 NumChannels )
7460{
7461 tANI_U32 dataLen = sizeof( tANI_U8 ) * NumChannels;
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +05307462 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007463
Mihir Shete31c435d2014-02-12 13:13:34 +05307464 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7465 "%s: dump valid channel list(NumChannels(%d))",
7466 __func__,NumChannels);
7467 VOS_TRACE_HEX_DUMP(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7468 pChannelList, NumChannels);
7469
Jeff Johnson295189b2012-06-20 16:38:30 -07007470 ccmCfgSetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST, pChannelList, dataLen, NULL, eANI_BOOLEAN_FALSE);
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -08007471#ifdef QCA_WIFI_2_0
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +05307472 if (pMac->fScanOffload)
7473 {
7474 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7475 "Scan offload is enabled, update default chan list");
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -08007476 status = csrUpdateChannelList(pMac);
7477 }
7478#else
7479 status = csrUpdateChannelList(pMac);
7480#endif
7481
7482 if (eHAL_STATUS_SUCCESS != status)
7483 {
7484 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
7485 "failed to update the supported channel list");
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +05307486 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007487 return;
7488}
7489
7490
7491
7492/*
7493 * The Tx power limits are saved in the cfg for future usage.
7494 */
7495void csrSaveTxPowerToCfg( tpAniSirGlobal pMac, tDblLinkList *pList, tANI_U32 cfgId )
7496{
7497 tListElem *pEntry;
7498 tANI_U32 cbLen = 0, dataLen;
7499 tCsrChannelPowerInfo *pChannelSet;
7500 tANI_U32 idx;
7501 tSirMacChanInfo *pChannelPowerSet;
7502 tANI_U8 *pBuf = NULL;
7503
7504 //allocate maximum space for all channels
7505 dataLen = WNI_CFG_VALID_CHANNEL_LIST_LEN * sizeof(tSirMacChanInfo);
Kiet Lam64c1b492013-07-12 13:56:44 +05307506 if ( (pBuf = vos_mem_malloc(dataLen)) != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07007507 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307508 vos_mem_set(pBuf, dataLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007509 pChannelPowerSet = (tSirMacChanInfo *)(pBuf);
7510
7511 pEntry = csrLLPeekHead( pList, LL_ACCESS_LOCK );
7512 // write the tuples (startChan, numChan, txPower) for each channel found in the channel power list.
7513 while( pEntry )
7514 {
7515 pChannelSet = GET_BASE_ADDR( pEntry, tCsrChannelPowerInfo, link );
7516 if ( 1 != pChannelSet->interChannelOffset )
7517 {
7518 // we keep the 5G channel sets internally with an interchannel offset of 4. Expand these
7519 // to the right format... (inter channel offset of 1 is the only option for the triplets
7520 // that 11d advertises.
7521 if ((cbLen + (pChannelSet->numChannels * sizeof(tSirMacChanInfo))) >= dataLen)
7522 {
7523 // expanding this entry will overflow our allocation
7524 smsLog(pMac, LOGE,
7525 "%s: Buffer overflow, start %d, num %d, offset %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007526 __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07007527 pChannelSet->firstChannel,
7528 pChannelSet->numChannels,
7529 pChannelSet->interChannelOffset);
7530 break;
7531 }
7532
7533 for( idx = 0; idx < pChannelSet->numChannels; idx++ )
7534 {
7535 pChannelPowerSet->firstChanNum = (tSirMacChanNum)(pChannelSet->firstChannel + ( idx * pChannelSet->interChannelOffset ));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007536 smsLog(pMac, LOG3, " Setting Channel Number %d", pChannelPowerSet->firstChanNum);
Jeff Johnson295189b2012-06-20 16:38:30 -07007537 pChannelPowerSet->numChannels = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007538 pChannelPowerSet->maxTxPower = CSR_ROAM_MIN( pChannelSet->txPower, pMac->roam.configParam.nTxPowerCap );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007539 smsLog(pMac, LOG3, " Setting Max Transmit Power %d", pChannelPowerSet->maxTxPower);
Jeff Johnson295189b2012-06-20 16:38:30 -07007540 cbLen += sizeof( tSirMacChanInfo );
7541 pChannelPowerSet++;
7542 }
7543 }
7544 else
7545 {
7546 if (cbLen >= dataLen)
7547 {
7548 // this entry will overflow our allocation
7549 smsLog(pMac, LOGE,
7550 "%s: Buffer overflow, start %d, num %d, offset %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007551 __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07007552 pChannelSet->firstChannel,
7553 pChannelSet->numChannels,
7554 pChannelSet->interChannelOffset);
7555 break;
7556 }
7557 pChannelPowerSet->firstChanNum = pChannelSet->firstChannel;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007558 smsLog(pMac, LOG3, " Setting Channel Number %d", pChannelPowerSet->firstChanNum);
Jeff Johnson295189b2012-06-20 16:38:30 -07007559 pChannelPowerSet->numChannels = pChannelSet->numChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07007560 pChannelPowerSet->maxTxPower = CSR_ROAM_MIN( pChannelSet->txPower, pMac->roam.configParam.nTxPowerCap );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007561 smsLog(pMac, LOG3, " Setting Max Transmit Power %d, nTxPower %d", pChannelPowerSet->maxTxPower,pMac->roam.configParam.nTxPowerCap );
Jeff Johnson295189b2012-06-20 16:38:30 -07007562
7563
7564 cbLen += sizeof( tSirMacChanInfo );
7565 pChannelPowerSet++;
7566 }
7567
7568 pEntry = csrLLNext( pList, pEntry, LL_ACCESS_LOCK );
7569 }
7570
7571 if(cbLen)
7572 {
7573 ccmCfgSetStr(pMac, cfgId, (tANI_U8 *)pBuf, cbLen, NULL, eANI_BOOLEAN_FALSE);
7574 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307575 vos_mem_free(pBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07007576 }//Allocate memory
7577}
7578
7579
7580void csrSetCfgCountryCode( tpAniSirGlobal pMac, tANI_U8 *countryCode )
7581{
7582 tANI_U8 cc[WNI_CFG_COUNTRY_CODE_LEN];
7583 ///v_REGDOMAIN_t DomainId;
7584
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007585 smsLog( pMac, LOG3, "Setting Country Code in Cfg from csrSetCfgCountryCode %s",countryCode );
Kiet Lam64c1b492013-07-12 13:56:44 +05307586 vos_mem_copy(cc, countryCode, WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07007587
7588 // don't program the bogus country codes that we created for Korea in the MAC. if we see
7589 // the bogus country codes, program the MAC with the right country code.
7590 if ( ( 'K' == countryCode[ 0 ] && '1' == countryCode[ 1 ] ) ||
7591 ( 'K' == countryCode[ 0 ] && '2' == countryCode[ 1 ] ) ||
7592 ( 'K' == countryCode[ 0 ] && '3' == countryCode[ 1 ] ) ||
7593 ( 'K' == countryCode[ 0 ] && '4' == countryCode[ 1 ] ) )
7594 {
7595 // replace the alternate Korea country codes, 'K1', 'K2', .. with 'KR' for Korea
7596 cc[ 1 ] = 'R';
7597 }
7598 ccmCfgSetStr(pMac, WNI_CFG_COUNTRY_CODE, cc, WNI_CFG_COUNTRY_CODE_LEN, NULL, eANI_BOOLEAN_FALSE);
7599
7600 //Need to let HALPHY know about the current domain so it can apply some
7601 //domain-specific settings (TX filter...)
7602 /*if(HAL_STATUS_SUCCESS(csrGetRegulatoryDomainForCountry(pMac, cc, &DomainId)))
7603 {
7604 halPhySetRegDomain(pMac, DomainId);
7605 }*/
7606}
7607
7608
7609
7610eHalStatus csrGetCountryCode(tpAniSirGlobal pMac, tANI_U8 *pBuf, tANI_U8 *pbLen)
7611{
7612 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
7613 tANI_U32 len;
7614
7615 if(pBuf && pbLen && (*pbLen >= WNI_CFG_COUNTRY_CODE_LEN))
7616 {
7617 len = *pbLen;
7618 status = ccmCfgGetStr(pMac, WNI_CFG_COUNTRY_CODE, pBuf, &len);
7619 if(HAL_STATUS_SUCCESS(status))
7620 {
7621 *pbLen = (tANI_U8)len;
7622 }
7623 }
7624
7625 return (status);
7626}
7627
7628
7629void csrSetCfgScanControlList( tpAniSirGlobal pMac, tANI_U8 *countryCode, tCsrChannel *pChannelList )
7630{
7631 tANI_U8 i, j;
7632 tANI_BOOLEAN found=FALSE;
7633 tANI_U8 *pControlList = NULL;
7634 tANI_U32 len = WNI_CFG_SCAN_CONTROL_LIST_LEN;
7635
Kiet Lam64c1b492013-07-12 13:56:44 +05307636 if ( (pControlList = vos_mem_malloc(WNI_CFG_SCAN_CONTROL_LIST_LEN)) != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07007637 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307638 vos_mem_set((void *)pControlList, WNI_CFG_SCAN_CONTROL_LIST_LEN, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007639 if(HAL_STATUS_SUCCESS(ccmCfgGetStr(pMac, WNI_CFG_SCAN_CONTROL_LIST, pControlList, &len)))
7640 {
7641 for (i = 0; i < pChannelList->numChannels; i++)
7642 {
7643 for (j = 0; j < len; j += 2)
7644 {
7645 if (pControlList[j] == pChannelList->channelList[i])
7646 {
7647 found = TRUE;
7648 break;
7649 }
7650 }
7651
7652 if (found) // insert a pair(channel#, flag)
7653 {
Gopichand Nakkala392cbc12013-05-28 16:15:00 +05307654 pControlList[j+1] = csrGetScanType(pMac, pControlList[j]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007655 found = FALSE; // reset the flag
7656 }
7657
7658 }
7659
Mihir Shete31c435d2014-02-12 13:13:34 +05307660 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7661 "%s: dump scan control list",__func__);
7662 VOS_TRACE_HEX_DUMP(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7663 pControlList, len);
7664
Jeff Johnson295189b2012-06-20 16:38:30 -07007665 ccmCfgSetStr(pMac, WNI_CFG_SCAN_CONTROL_LIST, pControlList, len, NULL, eANI_BOOLEAN_FALSE);
7666 }//Successfully getting scan control list
Kiet Lam64c1b492013-07-12 13:56:44 +05307667 vos_mem_free(pControlList);
Jeff Johnson295189b2012-06-20 16:38:30 -07007668 }//AllocateMemory
7669}
7670
7671
7672//if bgPeriod is 0, background scan is disabled. It is in millisecond units
7673eHalStatus csrSetCfgBackgroundScanPeriod(tpAniSirGlobal pMac, tANI_U32 bgPeriod)
7674{
7675 return (ccmCfgSetInt(pMac, WNI_CFG_BACKGROUND_SCAN_PERIOD, bgPeriod, (tCcmCfgSetCallback) csrScanCcmCfgSetCallback, eANI_BOOLEAN_FALSE));
7676}
7677
7678
7679void csrScanCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
7680{
7681 tListElem *pEntry = NULL;
7682 tSmeCmd *pCommand = NULL;
7683 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +05307684 tDblLinkList *pCmdList ;
7685
7686 if (!pMac->fScanOffload)
7687 pCmdList = &pMac->sme.smeCmdActiveList;
7688 else
7689 pCmdList = &pMac->sme.smeScanCmdActiveList;
7690
7691 pEntry = csrLLPeekHead( pCmdList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -07007692 if ( pEntry )
7693 {
7694 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7695 if ( eSmeCommandScan == pCommand->command )
7696 {
7697 eCsrScanStatus scanStatus = (CCM_IS_RESULT_SUCCESS(result)) ? eCSR_SCAN_SUCCESS : eCSR_SCAN_FAILURE;
7698 csrReleaseScanCommand(pMac, pCommand, scanStatus);
7699 }
7700 else
7701 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007702 smsLog( pMac, LOGW, "CSR: Scan Completion called but SCAN command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07007703 }
7704 }
7705 smeProcessPendingQueue( pMac );
7706}
7707
7708eHalStatus csrProcessSetBGScanParam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
7709{
7710 eHalStatus status;
7711 tCsrBGScanRequest *pScanReq = &pCommand->u.scanCmd.u.bgScanRequest;
7712 tANI_U32 dataLen = sizeof( tANI_U8 ) * pScanReq->ChannelInfo.numOfChannels;
7713
7714 //***setcfg for background scan channel list
7715 status = ccmCfgSetInt(pMac, WNI_CFG_ACTIVE_MINIMUM_CHANNEL_TIME, pScanReq->minChnTime, NULL, eANI_BOOLEAN_FALSE);
7716 status = ccmCfgSetInt(pMac, WNI_CFG_ACTIVE_MAXIMUM_CHANNEL_TIME, pScanReq->maxChnTime, NULL, eANI_BOOLEAN_FALSE);
7717 //Not set the background scan interval if not connected because bd scan should not be run if not connected
7718 if(!csrIsAllSessionDisconnected(pMac))
7719 {
7720 //If disbaling BG scan here, we need to stop aging as well
7721 if(pScanReq->scanInterval == 0)
7722 {
7723 //Stop aging because no new result is coming in
7724 csrScanStopResultAgingTimer(pMac);
7725 }
7726
7727#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7728 {
7729 vos_log_scan_pkt_type *pScanLog = NULL;
7730
7731 WLAN_VOS_DIAG_LOG_ALLOC(pScanLog, vos_log_scan_pkt_type, LOG_WLAN_SCAN_C);
7732 if(pScanLog)
7733 {
7734 pScanLog->eventId = WLAN_SCAN_EVENT_HO_SCAN_REQ;
7735 pScanLog->minChnTime = (v_U8_t)pScanReq->minChnTime;
7736 pScanLog->maxChnTime = (v_U8_t)pScanReq->maxChnTime;
7737 pScanLog->timeBetweenBgScan = (v_U8_t)pScanReq->scanInterval;
7738 pScanLog->numChannel = pScanReq->ChannelInfo.numOfChannels;
7739 if(pScanLog->numChannel && (pScanLog->numChannel < VOS_LOG_MAX_NUM_CHANNEL))
7740 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307741 vos_mem_copy(pScanLog->channels,
7742 pScanReq->ChannelInfo.ChannelList,
7743 pScanLog->numChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07007744 }
7745 WLAN_VOS_DIAG_LOG_REPORT(pScanLog);
7746 }
7747 }
7748#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7749
7750 status = ccmCfgSetInt(pMac, WNI_CFG_BACKGROUND_SCAN_PERIOD, pScanReq->scanInterval, NULL, eANI_BOOLEAN_FALSE);
7751 }
7752 else
7753 {
7754 //No need to stop aging because IDLE scan is still running
7755 status = ccmCfgSetInt(pMac, WNI_CFG_BACKGROUND_SCAN_PERIOD, 0, NULL, eANI_BOOLEAN_FALSE);
7756 }
7757
7758 if(pScanReq->SSID.length > WNI_CFG_SSID_LEN)
7759 {
7760 pScanReq->SSID.length = WNI_CFG_SSID_LEN;
7761 }
7762
7763 status = ccmCfgSetStr(pMac, WNI_CFG_BG_SCAN_CHANNEL_LIST, pScanReq->ChannelInfo.ChannelList, dataLen, NULL, eANI_BOOLEAN_FALSE);
7764 status = ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pScanReq->SSID.ssId, pScanReq->SSID.length, NULL, eANI_BOOLEAN_FALSE);
7765
7766
7767
7768 return (status);
7769}
7770
7771
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05307772eHalStatus csrScanAbortMacScan(tpAniSirGlobal pMac, tANI_U8 sessionId,
7773 eCsrAbortReason reason)
Jeff Johnson295189b2012-06-20 16:38:30 -07007774{
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307775 eHalStatus status = eHAL_STATUS_FAILURE;
7776 tSirSmeScanAbortReq *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07007777 tANI_U16 msgLen;
7778 tListElem *pEntry;
7779 tSmeCmd *pCommand;
7780
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307781 if (!pMac->fScanOffload)
Jeff Johnson295189b2012-06-20 16:38:30 -07007782 {
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307783#ifdef WLAN_AP_STA_CONCURRENCY
7784 csrLLLock(&pMac->scan.scanCmdPendingList);
7785 while(NULL !=
7786 (pEntry = csrLLRemoveHead(&pMac->scan.scanCmdPendingList,
7787 LL_ACCESS_NOLOCK)))
7788 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007789
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307790 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7791 csrAbortCommand( pMac, pCommand, eANI_BOOLEAN_FALSE);
7792 }
7793 csrLLUnlock(&pMac->scan.scanCmdPendingList);
Jeff Johnson295189b2012-06-20 16:38:30 -07007794#endif
7795
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307796 pMac->scan.fDropScanCmd = eANI_BOOLEAN_TRUE;
7797 csrRemoveCmdFromPendingList( pMac, &pMac->roam.roamCmdPendingList, eSmeCommandScan);
7798 csrRemoveCmdFromPendingList( pMac, &pMac->sme.smeCmdPendingList, eSmeCommandScan);
7799 pMac->scan.fDropScanCmd = eANI_BOOLEAN_FALSE;
7800
7801 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7802 }
7803 else
7804 {
7805 pMac->scan.fDropScanCmd = eANI_BOOLEAN_TRUE;
7806 csrRemoveCmdWithSessionIdFromPendingList(pMac,
7807 sessionId,
7808 &pMac->sme.smeScanCmdPendingList,
7809 eSmeCommandScan);
7810 pMac->scan.fDropScanCmd = eANI_BOOLEAN_FALSE;
7811
7812 pEntry = csrLLPeekHead(&pMac->sme.smeScanCmdActiveList, LL_ACCESS_LOCK);
7813 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007814
7815 //We need to abort scan only if we are scanning
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307816 if(NULL != pEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07007817 {
7818 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307819 if(eSmeCommandScan == pCommand->command &&
7820 pCommand->sessionId == sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07007821 {
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307822 msgLen = (tANI_U16)(sizeof(tSirSmeScanAbortReq));
Kiet Lam64c1b492013-07-12 13:56:44 +05307823 pMsg = vos_mem_malloc(msgLen);
7824 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -07007825 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307826 status = eHAL_STATUS_FAILURE;
7827 smsLog(pMac, LOGE, FL("Failed to allocate memory for SmeScanAbortReq"));
7828 }
7829 else
7830 {
Srinivas, Dasari187ca4e2014-02-07 12:40:09 +05307831 if(reason == eCSR_SCAN_ABORT_DUE_TO_BAND_CHANGE)
7832 {
7833 pCommand->u.scanCmd.abortScanDueToBandChange
7834 = eANI_BOOLEAN_TRUE;
7835 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307836 vos_mem_set((void *)pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007837 pMsg->type = pal_cpu_to_be16((tANI_U16)eWNI_SME_SCAN_ABORT_IND);
7838 pMsg->msgLen = pal_cpu_to_be16(msgLen);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307839 pMsg->sessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007840 status = palSendMBMessage(pMac->hHdd, pMsg);
7841 }
7842 }
7843 }
7844
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307845 return(status);
7846}
7847
7848void csrRemoveCmdWithSessionIdFromPendingList(tpAniSirGlobal pMac,
7849 tANI_U8 sessionId,
7850 tDblLinkList *pList,
7851 eSmeCommandType commandType)
7852{
7853 tDblLinkList localList;
7854 tListElem *pEntry;
7855 tSmeCmd *pCommand;
7856 tListElem *pEntryToRemove;
7857
7858 vos_mem_zero(&localList, sizeof(tDblLinkList));
7859 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
7860 {
7861 smsLog(pMac, LOGE, FL(" failed to open list"));
7862 return;
7863 }
7864
7865 csrLLLock(pList);
7866 if ((pEntry = csrLLPeekHead( pList, LL_ACCESS_NOLOCK)))
7867 {
7868
7869 /* Have to make sure we don't loop back to the head of the list,
7870 * which will happen if the entry is NOT on the list */
7871 while (pEntry)
7872 {
7873 pEntryToRemove = pEntry;
7874 pEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
7875 pCommand = GET_BASE_ADDR( pEntryToRemove, tSmeCmd, Link );
7876 if ((pCommand->command == commandType) &&
7877 (pCommand->sessionId == sessionId))
7878 {
7879 /* Remove that entry only */
7880 if (csrLLRemoveEntry( pList, pEntryToRemove, LL_ACCESS_NOLOCK))
7881 {
7882 csrLLInsertTail(&localList, pEntryToRemove,
7883 LL_ACCESS_NOLOCK);
7884 }
7885 }
7886 }
7887 }
7888 csrLLUnlock(pList);
7889
7890 while ((pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)))
7891 {
7892 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7893 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
7894 }
7895
7896 csrLLClose(&localList);
Jeff Johnson295189b2012-06-20 16:38:30 -07007897}
7898
7899void csrRemoveCmdFromPendingList(tpAniSirGlobal pMac, tDblLinkList *pList,
7900 eSmeCommandType commandType )
7901{
7902 tDblLinkList localList;
7903 tListElem *pEntry;
7904 tSmeCmd *pCommand;
7905 tListElem *pEntryToRemove;
7906
7907 vos_mem_zero(&localList, sizeof(tDblLinkList));
7908 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
7909 {
7910 smsLog(pMac, LOGE, FL(" failed to open list"));
7911 return;
7912 }
7913
7914 csrLLLock(pList);
7915 if( !csrLLIsListEmpty( pList, LL_ACCESS_NOLOCK ) )
7916 {
7917 pEntry = csrLLPeekHead( pList, LL_ACCESS_NOLOCK);
7918
7919 // Have to make sure we don't loop back to the head of the list, which will
7920 // happen if the entry is NOT on the list...
7921 while( pEntry )
7922 {
7923 pEntryToRemove = pEntry;
7924 pEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
7925 pCommand = GET_BASE_ADDR( pEntryToRemove, tSmeCmd, Link );
7926 if ( pCommand->command == commandType )
7927 {
7928 // Remove that entry only
7929 if(csrLLRemoveEntry( pList, pEntryToRemove, LL_ACCESS_NOLOCK))
7930 {
7931 csrLLInsertTail(&localList, pEntryToRemove, LL_ACCESS_NOLOCK);
7932 }
7933 }
7934 }
7935
7936
7937 }
7938 csrLLUnlock(pList);
7939
7940 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
7941 {
7942 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7943 csrAbortCommand( pMac, pCommand, eANI_BOOLEAN_FALSE);
7944 }
7945 csrLLClose(&localList);
7946
7947}
7948
7949
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307950eHalStatus csrScanAbortMacScanNotForConnect(tpAniSirGlobal pMac,
7951 tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07007952{
7953 eHalStatus status = eHAL_STATUS_SUCCESS;
7954
7955 if( !csrIsScanForRoamCommandActive( pMac ) )
7956 {
7957 //Only abort the scan if it is not used for other roam/connect purpose
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05307958 status = csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -07007959 }
7960
7961 return (status);
7962}
7963
7964
Madan Mohan Koyyalamudide1b5bc2013-07-12 00:56:04 +05307965eHalStatus csrScanGetScanChannelInfo(tpAniSirGlobal pMac, tANI_U8 sessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -07007966{
7967 eHalStatus status = eHAL_STATUS_SUCCESS;
7968 tSirMbMsg *pMsg;
7969 tANI_U16 msgLen;
7970
Madan Mohan Koyyalamudide1b5bc2013-07-12 00:56:04 +05307971 if (pMac->fScanOffload)
7972 msgLen = (tANI_U16)(sizeof(tSirSmeGetScanChanReq));
7973 else
7974 msgLen = (tANI_U16)(sizeof(tSirMbMsg));
7975
Kiet Lam64c1b492013-07-12 13:56:44 +05307976 pMsg = vos_mem_malloc(msgLen);
7977 if ( NULL == pMsg )
7978 status = eHAL_STATUS_FAILURE;
7979 else
Jeff Johnson295189b2012-06-20 16:38:30 -07007980 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307981 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007982 pMsg->type = eWNI_SME_GET_SCANNED_CHANNEL_REQ;
7983 pMsg->msgLen = msgLen;
Madan Mohan Koyyalamudide1b5bc2013-07-12 00:56:04 +05307984 if (pMac->fScanOffload)
7985 ((tSirSmeGetScanChanReq *)pMsg)->sessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007986 status = palSendMBMessage(pMac->hHdd, pMsg);
7987 }
7988
7989 return( status );
7990}
7991
7992tANI_BOOLEAN csrRoamIsValidChannel( tpAniSirGlobal pMac, tANI_U8 channel )
7993{
7994 tANI_BOOLEAN fValid = FALSE;
7995 tANI_U32 idxValidChannels;
7996 tANI_U32 len = pMac->roam.numValidChannels;
7997
7998 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
7999 {
8000 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
8001 {
8002 fValid = TRUE;
8003 break;
8004 }
8005 }
8006
8007 return fValid;
8008}
8009
Manjunathappa Prakash4f1d5a52013-11-11 16:22:19 -08008010#ifdef FEATURE_WLAN_SCAN_PNO
Srikant Kuppa066904f2013-05-07 13:56:02 -07008011eHalStatus csrScanSavePreferredNetworkFound(tpAniSirGlobal pMac,
8012 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
8013{
8014 v_U32_t uLen = 0;
8015 tpSirProbeRespBeacon pParsedFrame;
8016 tCsrScanResult *pScanResult = NULL;
8017 tSirBssDescription *pBssDescr = NULL;
8018 tANI_BOOLEAN fDupBss;
8019 tDot11fBeaconIEs *pIesLocal = NULL;
8020 tAniSSID tmpSsid;
8021 v_TIME_t timer=0;
8022 tpSirMacMgmtHdr macHeader = (tpSirMacMgmtHdr)pPrefNetworkFoundInd->data;
8023
8024 pParsedFrame =
Kiet Lam64c1b492013-07-12 13:56:44 +05308025 (tpSirProbeRespBeacon)vos_mem_malloc(sizeof(tSirProbeRespBeacon));
Srikant Kuppa066904f2013-05-07 13:56:02 -07008026
8027 if (NULL == pParsedFrame)
8028 {
8029 smsLog(pMac, LOGE, FL(" fail to allocate memory for frame"));
8030 return eHAL_STATUS_RESOURCES;
8031 }
8032
8033 if ( pPrefNetworkFoundInd->frameLength <= SIR_MAC_HDR_LEN_3A )
8034 {
8035 smsLog(pMac, LOGE,
8036 FL("Not enough bytes in PNO indication probe resp frame! length=%d"),
8037 pPrefNetworkFoundInd->frameLength);
8038 vos_mem_free(pParsedFrame);
8039 return eHAL_STATUS_FAILURE;
8040 }
8041
8042 if (sirConvertProbeFrame2Struct(pMac,
8043 &pPrefNetworkFoundInd->data[SIR_MAC_HDR_LEN_3A],
8044 pPrefNetworkFoundInd->frameLength - SIR_MAC_HDR_LEN_3A,
8045 pParsedFrame) != eSIR_SUCCESS ||
8046 !pParsedFrame->ssidPresent)
8047 {
8048 smsLog(pMac, LOGE,
8049 FL("Parse error ProbeResponse, length=%d"),
8050 pPrefNetworkFoundInd->frameLength);
8051 vos_mem_free(pParsedFrame);
8052 return eHAL_STATUS_FAILURE;
8053 }
8054 //24 byte MAC header and 12 byte to ssid IE
8055 if (pPrefNetworkFoundInd->frameLength >
8056 (SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_SSID_OFFSET))
8057 {
8058 uLen = pPrefNetworkFoundInd->frameLength -
8059 (SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_SSID_OFFSET);
8060 }
8061
Kiet Lam64c1b492013-07-12 13:56:44 +05308062 pScanResult = vos_mem_malloc(sizeof(tCsrScanResult) + uLen);
8063 if ( NULL == pScanResult )
Srikant Kuppa066904f2013-05-07 13:56:02 -07008064 {
8065 smsLog(pMac, LOGE, FL(" fail to allocate memory for frame"));
8066 vos_mem_free(pParsedFrame);
8067 return eHAL_STATUS_RESOURCES;
8068 }
8069
Kiet Lam64c1b492013-07-12 13:56:44 +05308070 vos_mem_set(pScanResult, sizeof(tCsrScanResult) + uLen, 0);
Srikant Kuppa066904f2013-05-07 13:56:02 -07008071 pBssDescr = &pScanResult->Result.BssDescriptor;
8072 /**
8073 * Length of BSS desription is without length of
8074 * length itself and length of pointer
8075 * that holds the next BSS description
8076 */
8077 pBssDescr->length = (tANI_U16)(
8078 sizeof(tSirBssDescription) - sizeof(tANI_U16) -
8079 sizeof(tANI_U32) + uLen);
8080 if (pParsedFrame->dsParamsPresent)
8081 {
8082 pBssDescr->channelId = pParsedFrame->channelNumber;
8083 }
8084 else if (pParsedFrame->HTInfo.present)
8085 {
8086 pBssDescr->channelId = pParsedFrame->HTInfo.primaryChannel;
8087 }
8088 else
8089 {
Mahesh A Saptasagaradd99792014-03-26 16:04:20 +05308090 /**
8091 * If Probe Responce received in PNO indication does not
8092 * contain DSParam IE or HT Info IE then add dummy channel
8093 * to the received BSS info so that Scan result received as
8094 * a part of PNO is updated to the supplicant. Specially
8095 * applicable in case of AP configured in 11A only mode.
8096 */
8097 if ((pMac->roam.configParam.bandCapability == eCSR_BAND_ALL) ||
8098 (pMac->roam.configParam.bandCapability == eCSR_BAND_24))
8099 {
8100 pBssDescr->channelId = 1;
8101 }
8102 else if(pMac->roam.configParam.bandCapability == eCSR_BAND_5G)
8103 {
8104 pBssDescr->channelId = 36;
8105 }
Srikant Kuppa066904f2013-05-07 13:56:02 -07008106 }
8107
8108 if ((pBssDescr->channelId > 0) && (pBssDescr->channelId < 15))
8109 {
8110 int i;
8111 // 11b or 11g packet
8112 // 11g iff extended Rate IE is present or
8113 // if there is an A rate in suppRate IE
8114 for (i = 0; i < pParsedFrame->supportedRates.numRates; i++)
8115 {
8116 if (sirIsArate(pParsedFrame->supportedRates.rate[i] & 0x7f))
8117 {
8118 pBssDescr->nwType = eSIR_11G_NW_TYPE;
8119 break;
8120 }
8121 }
8122 if (pParsedFrame->extendedRatesPresent)
8123 {
8124 pBssDescr->nwType = eSIR_11G_NW_TYPE;
8125 }
8126 }
8127 else
8128 {
8129 // 11a packet
8130 pBssDescr->nwType = eSIR_11A_NW_TYPE;
8131 }
8132
8133 pBssDescr->sinr = 0;
8134 pBssDescr->rssi = -1 * pPrefNetworkFoundInd->rssi;
8135 pBssDescr->beaconInterval = pParsedFrame->beaconInterval;
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +05308136 if (!pBssDescr->beaconInterval)
8137 {
8138 smsLog(pMac, LOGW,
8139 FL("Bcn Interval is Zero , default to 100" MAC_ADDRESS_STR),
8140 MAC_ADDR_ARRAY(pBssDescr->bssId) );
8141 pBssDescr->beaconInterval = 100;
8142 }
Srikant Kuppa066904f2013-05-07 13:56:02 -07008143 pBssDescr->timeStamp[0] = pParsedFrame->timeStamp[0];
8144 pBssDescr->timeStamp[1] = pParsedFrame->timeStamp[1];
8145 pBssDescr->capabilityInfo = *((tANI_U16 *)&pParsedFrame->capabilityInfo);
Kiet Lam64c1b492013-07-12 13:56:44 +05308146 vos_mem_copy((tANI_U8 *) &pBssDescr->bssId, (tANI_U8 *) macHeader->bssId, sizeof(tSirMacAddr));
Srikant Kuppa066904f2013-05-07 13:56:02 -07008147 pBssDescr->nReceivedTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
8148
Abhishek Singh195c03e2014-05-14 17:21:30 +05308149 smsLog( pMac, LOG1, FL("Bssid= "MAC_ADDRESS_STR
8150 " chan= %d, rssi = %d "),
Arif Hussain24bafea2013-11-15 15:10:03 -08008151 MAC_ADDR_ARRAY(pBssDescr->bssId),
Srikant Kuppa066904f2013-05-07 13:56:02 -07008152 pBssDescr->channelId,
Abhishek Singh195c03e2014-05-14 17:21:30 +05308153 pBssDescr->rssi);
Srikant Kuppa066904f2013-05-07 13:56:02 -07008154
8155 //IEs
8156 if (uLen)
8157 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308158 vos_mem_copy(&pBssDescr->ieFields,
8159 pPrefNetworkFoundInd->data + (SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_SSID_OFFSET),
8160 uLen);
Srikant Kuppa066904f2013-05-07 13:56:02 -07008161 }
8162
8163 pIesLocal = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
8164 if ( !pIesLocal &&
8165 (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac,
8166 &pScanResult->Result.BssDescriptor, &pIesLocal))) )
8167 {
8168 smsLog(pMac, LOGE, FL(" Cannot parse IEs"));
8169 csrFreeScanResultEntry(pMac, pScanResult);
8170 vos_mem_free(pParsedFrame);
8171 return eHAL_STATUS_RESOURCES;
8172 }
8173
8174 fDupBss = csrRemoveDupBssDescription( pMac,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05308175 &pScanResult->Result.BssDescriptor, pIesLocal, &tmpSsid, &timer, FALSE);
Srikant Kuppa066904f2013-05-07 13:56:02 -07008176 //Check whether we have reach out limit
8177 if ( CSR_SCAN_IS_OVER_BSS_LIMIT(pMac) )
8178 {
8179 //Limit reach
8180 smsLog(pMac, LOGE, FL(" BSS limit reached"));
8181 //Free the resources
8182 if( (pScanResult->Result.pvIes == NULL) && pIesLocal )
8183 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308184 vos_mem_free(pIesLocal);
Srikant Kuppa066904f2013-05-07 13:56:02 -07008185 }
8186 csrFreeScanResultEntry(pMac, pScanResult);
8187 vos_mem_free(pParsedFrame);
8188 return eHAL_STATUS_RESOURCES;
8189 }
8190 //Add to scan cache
8191 csrScanAddResult(pMac, pScanResult, pIesLocal);
8192
Kiet Lamb537cfb2013-11-07 12:56:49 +05308193 if( (pScanResult->Result.pvIes == NULL) && pIesLocal )
8194 {
8195 vos_mem_free(pIesLocal);
8196 }
8197
Srikant Kuppa066904f2013-05-07 13:56:02 -07008198 vos_mem_free(pParsedFrame);
8199
8200 return eHAL_STATUS_SUCCESS;
8201}
Manjunathappa Prakash4f1d5a52013-11-11 16:22:19 -08008202#endif //FEATURE_WLAN_SCAN_PNO
Srikant Kuppa066904f2013-05-07 13:56:02 -07008203
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08008204#ifdef FEATURE_WLAN_LFR
8205void csrInitOccupiedChannelsList(tpAniSirGlobal pMac)
8206{
8207 tListElem *pEntry = NULL;
8208 tCsrScanResult *pBssDesc = NULL;
8209 tDot11fBeaconIEs *pIes = NULL;
Srinivas28b5b4e2012-12-12 13:07:53 -08008210 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
8211
8212 if (0 != pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
8213 {
8214 smsLog(pMac, LOG1, FL("%s: Ini file contains neighbor scan channel list,"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008215 " hence NO need to build occupied channel list (numChannels = %d)"),
Srinivas28b5b4e2012-12-12 13:07:53 -08008216 __func__, pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
8217 return;
8218 }
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08008219
8220 if (!csrNeighborRoamIsNewConnectedProfile(pMac))
8221 {
8222 smsLog(pMac, LOG2, FL("%s: donot flush occupied list since current roam profile"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008223 " matches previous (numChannels = %d)"),
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08008224 __func__, pMac->scan.occupiedChannels.numChannels);
8225 return;
8226 }
8227
8228 /* Empty occupied channels here */
8229 pMac->scan.occupiedChannels.numChannels = 0;
8230
8231 csrLLLock(&pMac->scan.scanResultList);
8232 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
8233 while( pEntry )
8234 {
8235 pBssDesc = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
8236 pIes = (tDot11fBeaconIEs *)( pBssDesc->Result.pvIes );
8237
8238 //At this time, pBssDescription->Result.pvIes may be NULL
Srikant Kuppa866893f2012-12-27 17:28:14 -08008239 if( !pIes && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac,
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08008240 &pBssDesc->Result.BssDescriptor, &pIes))) )
8241 {
8242 continue;
8243 }
8244
8245 csrScanAddToOccupiedChannels(pMac, pBssDesc, &pMac->scan.occupiedChannels, pIes);
8246
8247 /*
8248 * Free the memory allocated for pIes in csrGetParsedBssDescriptionIEs
8249 */
8250 if( (pBssDesc->Result.pvIes == NULL) && pIes )
8251 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308252 vos_mem_free(pIes);
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08008253 }
8254
8255 pEntry = csrLLNext( &pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK );
8256 }//while
8257 csrLLUnlock(&pMac->scan.scanResultList);
Srikant Kuppa866893f2012-12-27 17:28:14 -08008258
Madan Mohan Koyyalamudidd3c9662012-11-09 17:39:30 -08008259}
8260#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008261
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07008262eHalStatus csrScanCreateEntryInScanCache(tpAniSirGlobal pMac, tANI_U32 sessionId,
8263 tCsrBssid bssid, tANI_U8 channel)
8264{
8265 eHalStatus status = eHAL_STATUS_SUCCESS;
8266 tDot11fBeaconIEs *pNewIes = NULL;
8267 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -07008268 tSirBssDescription *pNewBssDescriptor = NULL;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07008269 tANI_U32 size = 0;
8270
8271 if(NULL == pSession)
8272 {
8273 status = eHAL_STATUS_FAILURE;
8274 return status;
8275 }
8276 smsLog(pMac, LOG2, FL("csrScanCreateEntryInScanCache: Current bssid::"
Arif Hussain24bafea2013-11-15 15:10:03 -08008277 MAC_ADDRESS_STR),
8278 MAC_ADDR_ARRAY(pSession->pConnectBssDesc->bssId));
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07008279 smsLog(pMac, LOG2, FL("csrScanCreateEntryInScanCache: My bssid::"
Arif Hussain24bafea2013-11-15 15:10:03 -08008280 MAC_ADDRESS_STR" channel %d"),
8281 MAC_ADDR_ARRAY(bssid), channel);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07008282
8283 do
8284 {
8285 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac,
8286 pSession->pConnectBssDesc, &pNewIes)))
8287 {
8288 smsLog(pMac, LOGE, FL("%s: Failed to parse IEs"),
8289 __func__);
8290 status = eHAL_STATUS_FAILURE;
8291 break;
8292 }
8293
8294 size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length);
Kiet Lam64c1b492013-07-12 13:56:44 +05308295 if (size)
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07008296 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308297 pNewBssDescriptor = vos_mem_malloc(size);
8298 if ( NULL == pNewBssDescriptor )
8299 status = eHAL_STATUS_FAILURE;
8300 else
8301 status = eHAL_STATUS_SUCCESS;
8302 if (HAL_STATUS_SUCCESS(status))
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07008303 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308304 vos_mem_copy(pNewBssDescriptor, pSession->pConnectBssDesc, size);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07008305 }
8306 else
8307 {
8308 smsLog(pMac, LOGE, FL("%s: memory allocation failed"),
8309 __func__);
8310 status = eHAL_STATUS_FAILURE;
8311 break;
8312 }
8313
8314 //change the BSSID & channel as passed
Kiet Lam64c1b492013-07-12 13:56:44 +05308315 vos_mem_copy(pNewBssDescriptor->bssId, bssid, sizeof(tSirMacAddr));
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07008316 pNewBssDescriptor->channelId = channel;
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07008317 if(NULL == csrScanAppendBssDescription( pMac, pNewBssDescriptor, pNewIes, TRUE ))
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07008318 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07008319 smsLog(pMac, LOGE, FL("%s: csrScanAppendBssDescription failed"),
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07008320 __func__);
8321 status = eHAL_STATUS_FAILURE;
8322 break;
8323 }
8324 }
8325 else
8326 {
8327 smsLog(pMac, LOGE, FL("%s: length of bss descriptor is 0"),
8328 __func__);
8329 status = eHAL_STATUS_FAILURE;
8330 break;
8331 }
8332 smsLog(pMac, LOGE, FL("%s: entry successfully added in scan cache"),
8333 __func__);
8334 }while(0);
8335
8336 if(pNewIes)
8337 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308338 vos_mem_free(pNewIes);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07008339 }
8340 if(pNewBssDescriptor)
8341 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308342 vos_mem_free(pNewBssDescriptor);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07008343 }
8344 return status;
8345}
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008346
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008347#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008348// Update the TSF with the difference in system time
8349void UpdateCCKMTSF(tANI_U32 *timeStamp0, tANI_U32 *timeStamp1, tANI_U32 *incr)
8350{
8351 tANI_U64 timeStamp64 = ((tANI_U64)*timeStamp1 << 32) | (*timeStamp0);
8352
8353 timeStamp64 = (tANI_U64)(timeStamp64 + (tANI_U64)*incr);
8354 *timeStamp0 = (tANI_U32)(timeStamp64 & 0xffffffff);
8355 *timeStamp1 = (tANI_U32)((timeStamp64 >> 32) & 0xffffffff);
8356}
8357#endif