blob: c2c60590b6f48a01ede5cf48591cf9ff43fb0277 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
2 * Copyright (c) 2012, Code Aurora Forum. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/** ------------------------------------------------------------------------- *
23 ------------------------------------------------------------------------- *
24
25
26 \file csrApiRoam.c
27
28 Implementation for the Common Roaming interfaces.
29
30 Copyright (C) 2008 Qualcomm, Incorporated
31
32
33 ========================================================================== */
34
35/*===========================================================================
36
37 EDIT HISTORY FOR FILE
38
39
40 This section contains comments describing changes made to the module.
41 Notice that changes are listed in reverse chronological order.
42
43
44
45 when who what, where, why
46---------- --- --------------------------------------------------------
4706/03/10 js Added support to hostapd driven
48 * deauth/disassoc/mic failure
49
50===========================================================================*/
51
52#include "aniGlobal.h" //for tpAniSirGlobal
53#include "wlan_qct_wda.h"
54
55#ifdef FEATURE_WLAN_INTEGRATED_SOC
56#include "halMsgApi.h" //for HAL_STA_INVALID_IDX.
57#endif
58
59#ifdef FEATURE_WLAN_NON_INTEGRATED_SOC
60#include "halPhyApi.h"
61#include "halInternal.h"
62#endif
63
64#include "palApi.h"
65#include "csrInsideApi.h"
66#include "smsDebug.h"
67#include "logDump.h"
68#include "smeQosInternal.h"
69#include "wlan_qct_tl.h"
70#include "smeInside.h"
71#include "vos_diag_core_event.h"
72#include "vos_diag_core_log.h"
73#include "csrApi.h"
74#include "pmc.h"
75#include "vos_nvitem.h"
76
77#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
78#include "csrNeighborRoam.h"
79#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
80
81#ifdef FEATURE_WLAN_CCX
82#include "csrCcx.h"
83#endif /* FEATURE_WLAN_CCX */
84
85#define CSR_NUM_IBSS_START_CHANNELS_50 4
86#define CSR_NUM_IBSS_START_CHANNELS_24 3
87#define CSR_DEF_IBSS_START_CHANNEL_50 36
88#define CSR_DEF_IBSS_START_CHANNEL_24 1
89#define CSR_IBSS_JOIN_TIMEOUT_PERIOD ( 1 * PAL_TIMER_TO_SEC_UNIT ) // 1 second
90#define CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD ( 50 * PAL_TIMER_TO_SEC_UNIT ) // 50 seconds, for WPA, WPA2, CCKM
91#define CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD ( 120 * PAL_TIMER_TO_SEC_UNIT ) // 120 seconds, for WPS
92/*---------------------------------------------------------------------------
93 OBIWAN recommends [8 10]% : pick 9%
94---------------------------------------------------------------------------*/
95#define CSR_VCC_UL_MAC_LOSS_THRESHOLD 9
96
97/*---------------------------------------------------------------------------
98 OBIWAN recommends -85dBm
99---------------------------------------------------------------------------*/
100#define CSR_VCC_RSSI_THRESHOLD 80
101#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD 500 //ms
102#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS 2000 //ms
103#define CSR_MIN_TL_STAT_QUERY_PERIOD 500 //ms
104#define CSR_DIAG_LOG_STAT_PERIOD 3000 //ms
105
106//We use constatnt 4 here
107//This macro returns true when higher AC parameter is bigger than lower AC for a difference
108//The bigger the number, the less chance of TX
109//It must put lower AC as the first parameter.
110#define SME_DETECT_AC_WEIGHT_DIFF(loAC, hiAC) (v_BOOL_t)(((hiAC) > (loAC)) ? (((hiAC)-(loAC)) > 4) : 0)
111
112//Flag to send/do not send disassoc frame over the air
113#define CSR_DONT_SEND_DISASSOC_OVER_THE_AIR 1
114
115#define RSSI_HACK_BMPS (-40)
116/*--------------------------------------------------------------------------
117 Static Type declarations
118 ------------------------------------------------------------------------*/
119static tChannelListWithPower csrRoamPowerTableFromEeprom[WNI_CFG_VALID_CHANNEL_LIST_LEN];
120static tChannelListWithPower csrRoamPowerTableFromEeprom40MHz[WNI_CFG_VALID_CHANNEL_LIST_LEN];
121static tCsrRoamSession csrRoamRoamSession[CSR_ROAM_SESSION_MAX];
122
123/*--------------------------------------------------------------------------
124 Type declarations
125 ------------------------------------------------------------------------*/
126#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
127
128int diagAuthTypeFromCSRType(eCsrAuthType authType)
129{
130 int n = AUTH_OPEN;
131
132 switch(authType)
133 {
134 case eCSR_AUTH_TYPE_SHARED_KEY:
135 n = AUTH_SHARED;
136 break;
137
138 case eCSR_AUTH_TYPE_WPA:
139 n = AUTH_WPA_EAP;
140 break;
141
142 case eCSR_AUTH_TYPE_WPA_PSK:
143 n = AUTH_WPA_PSK;
144 break;
145
146 case eCSR_AUTH_TYPE_RSN:
147 n = AUTH_WPA2_EAP;
148 break;
149
150 case eCSR_AUTH_TYPE_RSN_PSK:
151 n = AUTH_WPA2_PSK;
152 break;
153#ifdef FEATURE_WLAN_WAPI
154 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
155 n = AUTH_WAPI_CERT;
156 break;
157
158 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
159 n = AUTH_WAPI_PSK;
160 break;
161#endif /* FEATURE_WLAN_WAPI */
162
163 default:
164 break;
165 }
166
167 return (n);
168}
169
170int diagEncTypeFromCSRType(eCsrEncryptionType encType)
171{
172 int n = ENC_MODE_OPEN;
173
174 switch(encType)
175 {
176 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
177 case eCSR_ENCRYPT_TYPE_WEP40:
178 n = ENC_MODE_WEP40;
179 break;
180
181 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
182 case eCSR_ENCRYPT_TYPE_WEP104:
183 n = ENC_MODE_WEP104;
184 break;
185
186 case eCSR_ENCRYPT_TYPE_TKIP:
187 n = ENC_MODE_TKIP;
188 break;
189
190 case eCSR_ENCRYPT_TYPE_AES:
191 n = ENC_MODE_AES;
192 break;
193
194#ifdef FEATURE_WLAN_WAPI
195 case eCSR_ENCRYPT_TYPE_WPI:
196 n = ENC_MODE_SMS4;
197 break;
198#endif /* FEATURE_WLAN_WAPI */
199 default:
200 break;
201 }
202
203 return (n);
204}
205
206#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
207
208static const tANI_U8 csrStartIbssChannels50[ CSR_NUM_IBSS_START_CHANNELS_50 ] = { 36, 40, 44, 48};
209static const tANI_U8 csrStartIbssChannels24[ CSR_NUM_IBSS_START_CHANNELS_24 ] = { 1, 6, 11 };
210
211static void initConfigParam(tpAniSirGlobal pMac);
212static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
213 eCsrRoamCompleteResult Result, void *Context );
214static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId,
215 tCsrRoamProfile *pProfile,
216 tANI_BOOLEAN *pfSameIbss );
217static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirSmeNewBssInfo *pNewBss );
218static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
219 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes);
220static tAniCBSecondaryMode csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes);
221eHalStatus csrInitGetChannels(tpAniSirGlobal pMac);
222static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result );
223eHalStatus csrRoamOpen(tpAniSirGlobal pMac);
224eHalStatus csrRoamClose(tpAniSirGlobal pMac);
225void csrRoamMICErrorTimerHandler(void *pv);
226void csrRoamTKIPCounterMeasureTimerHandler(void *pv);
227tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2);
228
229static eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval);
230static eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId);
231static void csrRoamRoamingTimerHandler(void *pv);
232eHalStatus csrRoamStartIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval);
233eHalStatus csrRoamStopIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId);
234static void csrRoamIbssJoinTimerHandler(void *pv);
235eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval);
236eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac);
237static void csrRoamWaitForKeyTimeOutHandler(void *pv);
238
239static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
240static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo );
241eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
242 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
243 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
244 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
245 tANI_U8 *pKeyRsc );
246static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
247 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes,
248 tCsrRoamProfile *pProfile );
249void csrRoamStatisticsTimerHandler(void *pv);
250void csrRoamStatsGlobalClassDTimerHandler(void *pv);
251
252static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid);
253VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
254 v_U8_t rssiNotification,
255 void * context);
256static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId);
257void csrRoamVccTrigger(tpAniSirGlobal pMac);
258eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId);
259/*
260 pStaEntry is no longer invalid upon the return of this function.
261*/
262static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry);
263
264#ifdef WLAN_SOFTAP_FEATURE
265static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,tANI_U8 operationChn, eCsrBand *pBand );
266#else
267static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, eCsrPhyMode phyModeIn, tANI_U8 operationChn, eCsrBand *pBand );
268#endif
269static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
270
271
272tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
273 tDblLinkList *pStaList,
274 tCsrStatsClientReqInfo *pStaEntry);
275void csrRoamStatsClientTimerHandler(void *pv);
276tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
277 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId);
278void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
279 tCsrStatsCallback callback, tANI_U8 staId, void *pContext);
280void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE tlStats);
281void csrRoamTlStatsTimerHandler(void *pv);
282void csrRoamPeStatsTimerHandler(void *pv);
283tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
284void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry);
285tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
286eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac);
287static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac );
288static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc );
289static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId );
290static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
291 tCsrRoamSetKey *pSetKey, tANI_U32 roamId );
292//static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand );
293static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
294void csrRoamReissueRoamCommand(tpAniSirGlobal pMac);
295#ifdef FEATURE_WLAN_BTAMP_UT_RF
296void csrRoamJoinRetryTimerHandler(void *pv);
297#endif
298extern void SysProcessMmhMsg(tpAniSirGlobal pMac, tSirMsgQ* pMsg);
299
300extern void btampEstablishLogLinkHdlr(void* pMsg);
301
302static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp);
303
304//Initialize global variables
305static void csrRoamInitGlobals(tpAniSirGlobal pMac)
306{
307 if(pMac)
308 {
309 pMac->roam.powerTableFromEeprom = csrRoamPowerTableFromEeprom;
310 pMac->roam.powerTableFromEeprom40MHz = csrRoamPowerTableFromEeprom40MHz;
311 pMac->roam.roamSession = csrRoamRoamSession;
312 }
313 return;
314}
315
316
317static void csrRoamDeInitGlobals(tpAniSirGlobal pMac)
318{
319 if(pMac)
320 {
321 pMac->roam.powerTableFromEeprom = NULL;
322 pMac->roam.powerTableFromEeprom40MHz = NULL;
323 pMac->roam.roamSession = NULL;
324 }
325 return;
326}
327
328eHalStatus csrOpen(tpAniSirGlobal pMac)
329{
330 eHalStatus status = eHAL_STATUS_SUCCESS;
331 static uNvTables nvTables;
332 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
333
334 v_REGDOMAIN_t regId;
335 tANI_U32 i;
336
337 do
338 {
339 /* Initialize CSR Roam Globals */
340 csrRoamInitGlobals(pMac);
341
342 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
343 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i);
344
345 initConfigParam(pMac);
346 if(!HAL_STATUS_SUCCESS((status = csrScanOpen(pMac))))
347 break;
348 if(!HAL_STATUS_SUCCESS((status = csrRoamOpen(pMac))))
349 break;
350 pMac->roam.nextRoamId = 1; //Must not be 0
351 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.statsClientReqList)))
352 break;
353 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.peStatsReqList)))
354 break;
355 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.roamCmdPendingList)))
356 break;
357
358 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
359 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
360 {
361 palCopyMemory( pMac->hHdd, pMac->scan.countryCodeDefault,
362 nvTables.defaultCountryTable.countryCode, WNI_CFG_COUNTRY_CODE_LEN );
363 status = eHAL_STATUS_SUCCESS;
364 }
365 else
366 {
367 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE\n") );
368 //hardcoded for now
369 pMac->scan.countryCodeDefault[0] = 'U';
370 pMac->scan.countryCodeDefault[1] = 'S';
371 pMac->scan.countryCodeDefault[2] = 'I';
372 //status = eHAL_STATUS_SUCCESS;
373 }
374 smsLog( pMac, LOGE, FL(" country Code from nvRam %s\n"), pMac->scan.countryCodeDefault );
375
376 csrGetRegulatoryDomainForCountry(pMac, pMac->scan.countryCodeDefault, &regId);
377
378 WDA_SetRegDomain(pMac, regId);
379 pMac->scan.domainIdDefault = regId;
380 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
381
382 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent,
383 pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN);
384 status = csrInitGetChannels( pMac );
385
386 }while(0);
387
388 return (status);
389}
390
391
392#ifdef WLAN_SOFTAP_FEATURE
393eHalStatus csrSetRegInfo(tHalHandle hHal, tANI_U8 *apCntryCode)
394{
395 eHalStatus status = eHAL_STATUS_SUCCESS;
396 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
397 v_REGDOMAIN_t regId;
398 v_U8_t cntryCodeLength;
399
400 if(NULL == apCntryCode)
401 {
402 smsLog( pMac, LOGW, FL(" Invalid country Code Pointer\n") );
403 return eHAL_STATUS_FAILURE;
404 }
405
406 smsLog( pMac, LOGW, FL(" country Code %s\n"), apCntryCode );
407
408 /* To get correct Regulatory domain from NV table
409 * 2 character Country code should be used
410 * 3rd charater is optional for indoor/outdoor setting */
411 cntryCodeLength = strlen(apCntryCode);
412
413 status = csrGetRegulatoryDomainForCountry(pMac, apCntryCode, &regId);
414 if (status != eHAL_STATUS_SUCCESS)
415 {
416 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %s\n"), apCntryCode );
417 return status;
418 }
419
420 status = WDA_SetRegDomain(hHal, regId);
421 if (status != eHAL_STATUS_SUCCESS)
422 {
423 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %s\n"), apCntryCode );
424 return status;
425 }
426
427 pMac->scan.domainIdDefault = regId;
428 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
429
430 /* Clear CC field */
431 palFillMemory( pMac->hHdd,
432 pMac->scan.countryCodeDefault,
433 WNI_CFG_COUNTRY_CODE_LEN,
434 0 );
435 /* Copy 2 or 3 bytes country code */
436 palCopyMemory( pMac->hHdd, pMac->scan.countryCodeDefault,
437 apCntryCode, cntryCodeLength );
438
439 /* If 2 bytes country code, 3rd byte must be filled with space */
440 if((WNI_CFG_COUNTRY_CODE_LEN - 1) == cntryCodeLength)
441 {
442 palFillMemory( pMac->hHdd,
443 pMac->scan.countryCodeDefault + 2,
444 1,
445 0x20 );
446 }
447
448 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent,
449 pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN);
450 status = csrInitGetChannels( pMac );
451
452 return status;
453}
454
455eHalStatus csrSetChannels(tHalHandle hHal, tCsrConfigParam *pParam )
456{
457 eHalStatus status = eHAL_STATUS_SUCCESS;
458 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
459 tANI_U8 index = 0;
460
461 palCopyMemory( pMac->hHdd, pParam->Csr11dinfo.countryCode,
462 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN );
463
464 for ( index = 0; index < pMac->scan.base20MHzChannels.numChannels ; index++)
465 {
466 pParam->Csr11dinfo.Channels.channelList[index] = pMac->scan.base20MHzChannels.channelList[ index ];
467 pParam->Csr11dinfo.ChnPower[index].firstChannel = pMac->scan.base20MHzChannels.channelList[ index ];
468 pParam->Csr11dinfo.ChnPower[index].numChannels = 1;
469 pParam->Csr11dinfo.ChnPower[index].maxtxPower = pMac->scan.defaultPowerTable[index].pwr;
470 }
471 pParam->Csr11dinfo.Channels.numChannels = pMac->scan.base20MHzChannels.numChannels;
472
473 return status;
474}
475#endif
476
477eHalStatus csrClose(tpAniSirGlobal pMac)
478{
479 eHalStatus status = eHAL_STATUS_SUCCESS;
480
481 csrStop(pMac);
482 csrRoamClose(pMac);
483 csrScanClose(pMac);
484 csrLLClose(&pMac->roam.statsClientReqList);
485 csrLLClose(&pMac->roam.peStatsReqList);
486 csrLLClose(&pMac->roam.roamCmdPendingList);
487
488 /* DeInit Globals */
489 csrRoamDeInitGlobals(pMac);
490
491 return (status);
492}
493
494eHalStatus csrStart(tpAniSirGlobal pMac)
495{
496 eHalStatus status = eHAL_STATUS_SUCCESS;
497 tANI_U32 i;
498
499 do
500 {
501 //save the global vos context
502 pMac->roam.gVosContext = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
503 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
504 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, i );
505
506 status = csrRoamStart(pMac);
507 if(!HAL_STATUS_SUCCESS(status)) break;
508 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE;
509 status = pmcRegisterPowerSaveCheck(pMac, csrCheckPSReady, pMac);
510 if(!HAL_STATUS_SUCCESS(status)) break;
511 pMac->roam.sPendingCommands = 0;
512 csrScanEnable(pMac);
513#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
514 status = csrNeighborRoamInit(pMac);
515#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
516 pMac->roam.tlStatsReqInfo.numClient = 0;
517 pMac->roam.tlStatsReqInfo.periodicity = 0;
518 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
519 //init the link quality indication also
520 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_MIN_IND;
521 if(!HAL_STATUS_SUCCESS(status))
522 {
523 smsLog(pMac, LOGW, " csrStart: Couldn't Init HO control blk \n");
524 break;
525 }
526 }while(0);
527
528#if defined(ANI_LOGDUMP)
529 csrDumpInit(pMac);
530#endif //#if defined(ANI_LOGDUMP)
531
532 return (status);
533}
534
535
536eHalStatus csrStop(tpAniSirGlobal pMac)
537{
538 tANI_U32 sessionId;
539 tANI_U32 i;
540
541 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
542 {
543 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
544 }
545
546 csrScanDisable(pMac);
547 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE;
548 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
549
550 csrLLPurge( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_TRUE );
551
552#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
553 csrNeighborRoamClose(pMac);
554#endif
555 csrScanFlushResult(pMac); //Do we want to do this?
556
557 // deregister from PMC since we register during csrStart()
558 // (ignore status since there is nothing we can do if it fails)
559 (void) pmcDeregisterPowerSaveCheck(pMac, csrCheckPSReady);
560
561 //Reset the domain back to the deault
562 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
563 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE);
564
565 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
566 {
567 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP ,i );
568 pMac->roam.curSubState[i] = eCSR_ROAM_SUBSTATE_NONE;
569 }
570
571 return (eHAL_STATUS_SUCCESS);
572}
573
574
575eHalStatus csrReady(tpAniSirGlobal pMac)
576{
577 eHalStatus status = eHAL_STATUS_SUCCESS;
578
579 csrScanGetSupportedChannels( pMac );
580 //WNI_CFG_VALID_CHANNEL_LIST should be set by this time
581 //use it to init the background scan list
582 csrInitBGScanChannelList(pMac);
583 /* HDD issues the init scan */
584 csrScanStartResultAgingTimer(pMac);
585
586 //Store the AC weights in TL for later use
587 WLANTL_GetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
588
589 status = csrInitChannelList( pMac );
590 if ( ! HAL_STATUS_SUCCESS( status ) )
591 {
592 smsLog( pMac, LOGE, "csrInitChannelList failed during csrReady with status=%d\n",
593 status );
594 }
595
596 return (status);
597}
598
599void csrSetDefaultDot11Mode( tpAniSirGlobal pMac )
600{
601 v_U32_t wniDot11mode = 0;
602
603 wniDot11mode = csrTranslateToWNICfgDot11Mode(pMac,pMac->roam.configParam.uCfgDot11Mode);
604 ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, wniDot11mode, NULL, eANI_BOOLEAN_FALSE);
605}
606
607void csrSetGlobalCfgs( tpAniSirGlobal pMac )
608{
609 ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
610 ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
611 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
612 ((pMac->roam.configParam.Is11hSupportEnabled) ? pMac->roam.configParam.Is11dSupportEnabled : pMac->roam.configParam.Is11dSupportEnabled),
613 NULL, eANI_BOOLEAN_FALSE);
614 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
615 //Enable channel bonding at init; for 2.4 Ghz we will update this CFG at start BSS or join
616 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, WNI_CFG_CHANNEL_BONDING_MODE_ENABLE, NULL, eANI_BOOLEAN_FALSE);
617 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, pMac->roam.configParam.HeartbeatThresh24, NULL, eANI_BOOLEAN_FALSE);
618
619 //Update the operating mode to configured value during initialization,
620 //So that client can advertise full capabilities in Probe request frame.
621 csrSetDefaultDot11Mode( pMac );
622}
623
624
625eHalStatus csrRoamOpen(tpAniSirGlobal pMac)
626{
627 eHalStatus status = eHAL_STATUS_SUCCESS;
628 tANI_U32 i;
629 tCsrRoamSession *pSession;
630
631 do
632 {
633 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
634 {
635 pSession = CSR_GET_SESSION( pMac, i );
636 pSession->roamingTimerInfo.pMac = pMac;
637 pSession->roamingTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
638 }
639
640 pMac->roam.WaitForKeyTimerInfo.pMac = pMac;
641 pMac->roam.WaitForKeyTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
642 status = palTimerAlloc(pMac->hHdd, &pMac->roam.hTimerWaitForKey, csrRoamWaitForKeyTimeOutHandler,
643 &pMac->roam.WaitForKeyTimerInfo);
644 if(!HAL_STATUS_SUCCESS(status))
645 {
646 smsLog(pMac, LOGE, FL("cannot allocate memory for WaitForKey time out timer\n"));
647 break;
648 }
649
650 status = palTimerAlloc(pMac->hHdd, &pMac->roam.tlStatsReqInfo.hTlStatsTimer, csrRoamTlStatsTimerHandler, pMac);
651 if(!HAL_STATUS_SUCCESS(status))
652 {
653 smsLog(pMac, LOGE, FL("cannot allocate memory for summary Statistics timer\n"));
654 return eHAL_STATUS_FAILURE;
655 }
656 }while (0);
657
658 return (status);
659}
660
661
662eHalStatus csrRoamClose(tpAniSirGlobal pMac)
663{
664 tANI_U32 sessionId;
665
666 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
667 {
668 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
669 }
670
671 palTimerStop(pMac->hHdd, pMac->roam.hTimerWaitForKey);
672 palTimerFree(pMac->hHdd, pMac->roam.hTimerWaitForKey);
673
674 palTimerStop(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
675 palTimerFree(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
676
677 return (eHAL_STATUS_SUCCESS);
678}
679
680
681eHalStatus csrRoamStart(tpAniSirGlobal pMac)
682{
683 (void)pMac;
684
685 return (eHAL_STATUS_SUCCESS);
686}
687
688
689void csrRoamStop(tpAniSirGlobal pMac, tANI_U32 sessionId)
690{
691 csrRoamStopRoamingTimer(pMac, sessionId);
692 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
693 csrRoamDeregStatisticsReq(pMac);
694}
695
696eHalStatus csrRoamGetConnectState(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrConnectState *pState)
697{
698 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
699
700 if( pState )
701 {
702 status = eHAL_STATUS_SUCCESS;
703 *pState = pMac->roam.roamSession[sessionId].connectState;
704 }
705 return (status);
706}
707
708
709
710eHalStatus csrRoamCopyConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
711{
712 eHalStatus status = eHAL_STATUS_FAILURE;
713 tANI_U32 size = 0;
714 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
715
716 if(pProfile)
717 {
718 if(pSession->pConnectBssDesc)
719 {
720 do
721 {
722 size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length);
723 if(size)
724 {
725 status = palAllocateMemory(pMac->hHdd, (void **)&pProfile->pBssDesc, size);
726 if(HAL_STATUS_SUCCESS(status))
727 {
728 palCopyMemory(pMac->hHdd, pProfile->pBssDesc, pSession->pConnectBssDesc, size);
729 }
730 else
731 break;
732 }
733 else
734 {
735 pProfile->pBssDesc = NULL;
736 }
737 pProfile->AuthType = pSession->connectedProfile.AuthType;
738 pProfile->EncryptionType = pSession->connectedProfile.EncryptionType;
739 pProfile->mcEncryptionType = pSession->connectedProfile.mcEncryptionType;
740 pProfile->BSSType = pSession->connectedProfile.BSSType;
741 pProfile->operationChannel = pSession->connectedProfile.operationChannel;
742 pProfile->CBMode = pSession->connectedProfile.CBMode;
743 palCopyMemory(pMac->hHdd, &pProfile->bssid, &pSession->connectedProfile.bssid, sizeof(tCsrBssid));
744 palCopyMemory(pMac->hHdd, &pProfile->SSID, &pSession->connectedProfile.SSID, sizeof(tSirMacSSid));
745#ifdef WLAN_FEATURE_VOWIFI_11R
746 if (pSession->connectedProfile.MDID.mdiePresent)
747 {
748 pProfile->MDID.mdiePresent = 1;
749 pProfile->MDID.mobilityDomain = pSession->connectedProfile.MDID.mobilityDomain;
750 }
751 else
752 {
753 pProfile->MDID.mdiePresent = 0;
754 pProfile->MDID.mobilityDomain = 0;
755 }
756#endif
757
758#ifdef FEATURE_WLAN_CCX
759 pProfile->isCCXAssoc = pSession->connectedProfile.isCCXAssoc;
760
761 if (csrIsAuthTypeCCX(pSession->connectedProfile.AuthType))
762 {
763 palCopyMemory( pMac->hHdd, pProfile->ccxCckmInfo.krk,
764 pSession->connectedProfile.ccxCckmInfo.krk, CSR_KRK_KEY_LEN );
765 pProfile->ccxCckmInfo.reassoc_req_num=
766 pSession->connectedProfile.ccxCckmInfo.reassoc_req_num;
767 pProfile->ccxCckmInfo.krk_plumbed =
768 pSession->connectedProfile.ccxCckmInfo.krk_plumbed;
769 }
770#endif
771 }while(0);
772 }
773 }
774
775 return (status);
776}
777
778
779
780eHalStatus csrRoamGetConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
781{
782 eHalStatus status = eHAL_STATUS_FAILURE;
783
784 if(csrIsConnStateConnected(pMac, sessionId))
785 {
786 if(pProfile)
787 {
788 status = csrRoamCopyConnectProfile(pMac, sessionId, pProfile);
789 }
790 }
791
792 return (status);
793}
794
795eHalStatus csrRoamFreeConnectProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile)
796{
797 eHalStatus status = eHAL_STATUS_SUCCESS;
798
799 if(pProfile->pBssDesc)
800 {
801 palFreeMemory(pMac->hHdd, pProfile->pBssDesc);
802 }
803 palZeroMemory(pMac->hHdd, pProfile, sizeof(tCsrRoamConnectedProfile));
804 pProfile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
805 return (status);
806}
807
808
809static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo )
810{
811 eHalStatus status = eHAL_STATUS_SUCCESS;
812
813 if( pConnectedInfo->pbFrames )
814 {
815 palFreeMemory( pMac->hHdd, pConnectedInfo->pbFrames );
816 pConnectedInfo->pbFrames = NULL;
817 }
818 pConnectedInfo->nBeaconLength = 0;
819 pConnectedInfo->nAssocReqLength = 0;
820 pConnectedInfo->nAssocRspLength = 0;
821 pConnectedInfo->staId = 0;
822#ifdef WLAN_FEATURE_VOWIFI_11R
823 pConnectedInfo->nRICRspLength = 0;
824#endif
825#ifdef FEATURE_WLAN_CCX
826 pConnectedInfo->nTspecIeLength = 0;
827#endif
828
829
830 return ( status );
831}
832
833
834
835
836void csrReleaseCommandRoam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
837{
838 csrReinitRoamCmd(pMac, pCommand);
839 csrReleaseCommand( pMac, pCommand );
840}
841
842
843void csrReleaseCommandScan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
844{
845 csrReinitScanCmd(pMac, pCommand);
846 csrReleaseCommand( pMac, pCommand );
847}
848
849
850void csrReleaseCommandWmStatusChange(tpAniSirGlobal pMac, tSmeCmd *pCommand)
851{
852 csrReinitWmStatusChangeCmd(pMac, pCommand);
853 csrReleaseCommand( pMac, pCommand );
854}
855
856
857void csrReinitSetKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
858{
859 palZeroMemory(pMac->hHdd, &pCommand->u.setKeyCmd, sizeof(tSetKeyCmd));
860}
861
862
863void csrReinitRemoveKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
864{
865 palZeroMemory(pMac->hHdd, &pCommand->u.removeKeyCmd, sizeof(tRemoveKeyCmd));
866}
867
868
869void csrReleaseCommandSetKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
870{
871 csrReinitSetKeyCmd(pMac, pCommand);
872 csrReleaseCommand( pMac, pCommand );
873}
874
875void csrReleaseCommandRemoveKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
876{
877 csrReinitRemoveKeyCmd(pMac, pCommand);
878 csrReleaseCommand( pMac, pCommand );
879}
880
881void csrAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
882{
883
884 if( eSmeCsrCommandMask & pCommand->command )
885 {
886 switch (pCommand->command)
887 {
888 case eSmeCommandScan:
889 // We need to inform the requester before droping the scan command
890 smsLog( pMac, LOGW, "%s: Drop scan reason %d callback 0x%X\n",
891 __FUNCTION__, pCommand->u.scanCmd.reason, (unsigned int)pCommand->u.scanCmd.callback);
892 if (NULL != pCommand->u.scanCmd.callback)
893 {
894 smsLog( pMac, LOGW, "%s callback scan requester\n", __FUNCTION__);
895 csrScanCallCallback(pMac, pCommand, eCSR_SCAN_ABORT);
896 }
897 csrReleaseCommandScan( pMac, pCommand );
898 break;
899
900 case eSmeCommandRoam:
901 csrReleaseCommandRoam( pMac, pCommand );
902 break;
903
904 case eSmeCommandWmStatusChange:
905 csrReleaseCommandWmStatusChange( pMac, pCommand );
906 break;
907
908 case eSmeCommandSetKey:
909 csrReleaseCommandSetKey( pMac, pCommand );
910 break;
911
912 case eSmeCommandRemoveKey:
913 csrReleaseCommandRemoveKey( pMac, pCommand );
914 break;
915
916 default:
917 smsLog( pMac, LOGW, " CSR abort standard command %d\n", pCommand->command );
918 csrReleaseCommand( pMac, pCommand );
919 break;
920 }
921 }
922}
923
924
925
926void csrRoamSubstateChange( tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate, tANI_U32 sessionId)
927{
928 smsLog( pMac, LOG1, " CSR RoamSubstate: [ %d <== %d ]\n", NewSubstate, pMac->roam.curSubState[sessionId]);
929
930
931 if(pMac->roam.curSubState[sessionId] == NewSubstate)
932 {
933 return;
934 }
935 pMac->roam.curSubState[sessionId] = NewSubstate;
936}
937
938
939eCsrRoamState csrRoamStateChange( tpAniSirGlobal pMac, eCsrRoamState NewRoamState, tANI_U8 sessionId)
940{
941 eCsrRoamState PreviousState;
942
943 smsLog( pMac, LOG1, "CSR RoamState: [ %d <== %d ]\n", NewRoamState, pMac->roam.curState[sessionId]);
944
945 PreviousState = pMac->roam.curState[sessionId];
946
947 if ( NewRoamState != pMac->roam.curState[sessionId] )
948 {
949 // Whenever we transition OUT of the Roaming state, clear the Roaming substate...
950 if ( CSR_IS_ROAM_JOINING(pMac, sessionId) )
951 {
952 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
953 }
954
955 pMac->roam.curState[sessionId] = NewRoamState;
956 }
957 return( PreviousState );
958}
959
960
961void csrAssignRssiForCategory(tpAniSirGlobal pMac, tANI_U8 catOffset)
962{
963 int i;
964
965 if(catOffset)
966 {
967 pMac->roam.configParam.bCatRssiOffset = catOffset;
968 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
969 {
970 pMac->roam.configParam.RSSICat[CSR_NUM_RSSI_CAT - i - 1] = (int)CSR_BEST_RSSI_VALUE - (int)(i * catOffset);
971 }
972 }
973}
974
975
976static void initConfigParam(tpAniSirGlobal pMac)
977{
978 int i;
979
980 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
981 pMac->roam.configParam.channelBondingMode24GHz = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
982 pMac->roam.configParam.channelBondingMode5GHz = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
983 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_TAURUS;
984 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
985 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
986 pMac->roam.configParam.FragmentationThreshold = eCSR_DOT11_FRAG_THRESH_DEFAULT;
987 pMac->roam.configParam.HeartbeatThresh24 = 40;
988 pMac->roam.configParam.HeartbeatThresh50 = 40;
989 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
990 pMac->roam.configParam.Is11dSupportEnabledOriginal = eANI_BOOLEAN_FALSE;
991 pMac->roam.configParam.Is11eSupportEnabled = eANI_BOOLEAN_TRUE;
992 pMac->roam.configParam.Is11hSupportEnabled = eANI_BOOLEAN_FALSE;
993 pMac->roam.configParam.RTSThreshold = 2346;
994 pMac->roam.configParam.shortSlotTime = eANI_BOOLEAN_TRUE;
995 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
996 pMac->roam.configParam.ProprietaryRatesEnabled = eANI_BOOLEAN_TRUE;
997 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
998 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
999 pMac->roam.configParam.scanAgeTimeNCNPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_NO_PS;
1000 pMac->roam.configParam.scanAgeTimeNCPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_W_PS;
1001 pMac->roam.configParam.scanAgeTimeCNPS = CSR_SCAN_AGING_TIME_CONNECT_NO_PS;
1002 pMac->roam.configParam.scanAgeTimeCPS = CSR_SCAN_AGING_TIME_CONNECT_W_PS;
1003 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1004 {
1005 pMac->roam.configParam.BssPreferValue[i] = i;
1006 }
1007 csrAssignRssiForCategory(pMac, CSR_DEFAULT_RSSI_DB_GAP);
1008 pMac->roam.configParam.nRoamingTime = CSR_DEFAULT_ROAMING_TIME;
1009 pMac->roam.configParam.fEnforce11dChannels = eANI_BOOLEAN_FALSE;
1010 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = eANI_BOOLEAN_FALSE;
1011
1012 pMac->roam.configParam.fEnforceCountryCodeMatch = eANI_BOOLEAN_FALSE;
1013 pMac->roam.configParam.fEnforceDefaultDomain = eANI_BOOLEAN_FALSE;
1014 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
1015 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
1016 pMac->roam.configParam.nPassiveMaxChnTime = CSR_PASSIVE_MAX_CHANNEL_TIME;
1017 pMac->roam.configParam.nPassiveMinChnTime = CSR_PASSIVE_MIN_CHANNEL_TIME;
1018
1019 pMac->roam.configParam.IsIdleScanEnabled = TRUE; //enable the idle scan by default
1020 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
1021 pMac->roam.configParam.statsReqPeriodicity = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
1022 pMac->roam.configParam.statsReqPeriodicityInPS = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
1023
1024#ifdef WLAN_FEATURE_VOWIFI_11R
1025 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
1026#endif
1027
1028#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1029 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
1030 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold = 120;
1031 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold = 125;
1032 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
1033 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
1034 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = 200;
1035 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels = 3;
1036 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[0] = 1;
1037 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[1] = 6;
1038 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[2] = 11;
1039 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; //20 seconds
1040#endif
1041
1042 pMac->roam.configParam.addTSWhenACMIsOff = 0;
1043 pMac->roam.configParam.fScanTwice = eANI_BOOLEAN_FALSE;
1044}
1045
1046eCsrBand csrGetCurrentBand(tHalHandle hHal)
1047{
1048 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1049 return pMac->roam.configParam.bandCapability;
1050}
1051
1052eHalStatus csrSetBand(tHalHandle hHal, eCsrBand eBand)
1053{
1054 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1055 eHalStatus status = eHAL_STATUS_SUCCESS;
1056
1057 if (CSR_IS_PHY_MODE_A_ONLY(pMac) &&
1058 (eBand == eCSR_BAND_24))
1059 {
1060 /* DOT11 mode configured to 11a only and received
1061 request to change the band to 2.4 GHz */
1062 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
1063 "failed to set band cfg80211 = %u, band = %u\n",
1064 pMac->roam.configParam.uCfgDot11Mode, eBand);
1065 return eHAL_STATUS_INVALID_PARAMETER;
1066 }
1067
1068 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1069 CSR_IS_PHY_MODE_G_ONLY(pMac)) &&
1070 (eBand == eCSR_BAND_5G))
1071 {
1072 /* DOT11 mode configured to 11b/11g only and received
1073 request to change the band to 5 GHz */
1074 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
1075 "failed to set band dot11mode = %u, band = %u\n",
1076 pMac->roam.configParam.uCfgDot11Mode, eBand);
1077 return eHAL_STATUS_INVALID_PARAMETER;
1078 }
1079
1080 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1081 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)\n", eBand);
1082 pMac->roam.configParam.eBand = eBand;
1083 pMac->roam.configParam.bandCapability = eBand;
1084 csrScanGetSupportedChannels( pMac );
1085 status = csrInitGetChannels( pMac );
1086 if (eHAL_STATUS_SUCCESS == status)
1087 csrInitChannelList( hHal );
1088 return status;
1089}
1090
1091eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1092{
1093 eHalStatus status = eHAL_STATUS_SUCCESS;
1094
1095 if(pParam)
1096 {
1097 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1098 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1099 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1100 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1101 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1102 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1103
1104 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
1105 pMac->roam.configParam.channelBondingMode24GHz = pParam->channelBondingMode24GHz;
1106 pMac->roam.configParam.channelBondingMode5GHz = pParam->channelBondingMode5GHz;
1107 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1108 pMac->roam.configParam.phyMode = pParam->phyMode;
1109 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1110 pMac->roam.configParam.HeartbeatThresh24 = pParam->HeartbeatThresh24;
1111 pMac->roam.configParam.HeartbeatThresh50 = pParam->HeartbeatThresh50;
1112 pMac->roam.configParam.ProprietaryRatesEnabled = pParam->ProprietaryRatesEnabled;
1113 pMac->roam.configParam.TxRate = pParam->TxRate;
1114 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1115 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1116 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1117 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1118 pMac->roam.configParam.bgScanInterval = pParam->bgScanInterval;
1119
1120 //if HDD passed down non zero values then only update,
1121 //otherwise keep using the defaults
1122 if(pParam->nActiveMaxChnTime)
1123 {
1124 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
1125 }
1126 if(pParam->nActiveMinChnTime)
1127 {
1128 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
1129 }
1130 if(pParam->nPassiveMaxChnTime)
1131 {
1132 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
1133 }
1134 if(pParam->nPassiveMinChnTime)
1135 {
1136 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
1137 }
1138 //if upper layer wants to disable idle scan altogether set it to 0
1139 if(pParam->impsSleepTime)
1140 {
1141 //Change the unit from second to microsecond
1142 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
1143
1144 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1145 {
1146 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1147 }
1148 else
1149 {
1150 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1151 }
1152 }
1153 else
1154 {
1155 pMac->roam.configParam.impsSleepTime = 0;
1156 }
1157 pMac->roam.configParam.eBand = pParam->eBand;
1158#ifdef WLAN_SOFTAP_FEATURE
1159 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1160 pMac->roam.configParam.ProprietaryRatesEnabled);
1161#else
1162 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pMac->roam.configParam.phyMode,
1163 pMac->roam.configParam.ProprietaryRatesEnabled);
1164#endif
1165 //if HDD passed down non zero values for age params, then only update,
1166 //otherwise keep using the defaults
1167 if(pParam->nScanResultAgeCount)
1168 {
1169 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1170 }
1171
1172 if(pParam->scanAgeTimeNCNPS)
1173 {
1174 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1175 }
1176
1177 if(pParam->scanAgeTimeNCPS)
1178 {
1179 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1180 }
1181
1182 if(pParam->scanAgeTimeCNPS)
1183 {
1184 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1185 }
1186 if(pParam->scanAgeTimeCPS)
1187 {
1188 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1189 }
1190
1191 csrAssignRssiForCategory(pMac, pParam->bCatRssiOffset);
1192 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1193 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1194 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1195 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1196 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
1197
1198 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1199 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
1200
1201 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1202 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1203 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1204 //Assign this before calling CsrInit11dInfo
1205 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
1206
1207 if( csrIs11dSupported( pMac ) )
1208 {
1209 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1210 }
1211 else
1212 {
1213 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1214 }
1215#ifdef WLAN_FEATURE_VOWIFI_11R
1216 palCopyMemory( pMac->hHdd, &pMac->roam.configParam.csr11rConfig, &pParam->csr11rConfig, sizeof(tCsr11rConfigParams) );
1217 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d\n", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
1218#endif
1219
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001220#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001221 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001222 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Jeff Johnson295189b2012-06-20 16:38:30 -07001223#endif
1224
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001225#ifdef FEATURE_WLAN_LFR
1226 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
1227#endif
1228
Jeff Johnson295189b2012-06-20 16:38:30 -07001229#ifdef FEATURE_WLAN_CCX
1230 pMac->roam.configParam.isCcxIniFeatureEnabled = pParam->isCcxIniFeatureEnabled;
1231#endif
1232
1233#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1234 palCopyMemory( pMac->hHdd, &pMac->roam.configParam.neighborRoamConfig, &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams) );
1235
1236 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d\n", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
1237 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d\n", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
1238 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d\n", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
1239 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d\n", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
1240 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d\n", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
1241 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d\n", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
1242 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d\n", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
1243
1244 {
1245 int i;
1246 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d\n"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
1247
1248 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1249 {
1250 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1251 }
1252 smsLog( pMac, LOG1, "\n");
1253 }
1254#endif
1255
1256 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
1257 pMac->scan.fValidateList = pParam->fValidateList;
1258 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
1259 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
1260 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
1261 }
1262
1263 return status;
1264}
1265
1266
1267eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1268{
1269 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
1270
1271 if(pParam)
1272 {
1273 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
1274 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
1275 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
1276 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
1277 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
1278 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
1279 pParam->channelBondingMode24GHz = pMac->roam.configParam.channelBondingMode24GHz;
1280 pParam->channelBondingMode5GHz = pMac->roam.configParam.channelBondingMode5GHz;
1281 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
1282 pParam->phyMode = pMac->roam.configParam.phyMode;
1283 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
1284 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
1285 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
1286 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
1287 pParam->TxRate = pMac->roam.configParam.TxRate;
1288 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
1289 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
1290 pParam->bandCapability = pMac->roam.configParam.bandCapability;
1291 pParam->cbChoice = pMac->roam.configParam.cbChoice;
1292 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
1293
1294 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1295 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
1296 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
1297 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
1298
1299 //Change the unit from microsecond to second
1300 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
1301 pParam->eBand = pMac->roam.configParam.eBand;
1302 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
1303 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
1304 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
1305 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
1306 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
1307 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
1308 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
1309 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
1310 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
1311 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
1312 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
1313 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
1314 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
1315
1316 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
1317 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
1318 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
1319 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
1320
1321 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
1322 pParam->fValidateList = pMac->roam.configParam.fValidateList;
1323 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
1324 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
1325 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
1326
1327#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1328 palCopyMemory( pMac->hHdd, &pParam->neighborRoamConfig, &pMac->roam.configParam.neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams) );
1329#endif
1330
1331 csrSetChannels(pMac, pParam);
1332
1333 status = eHAL_STATUS_SUCCESS;
1334 }
1335
1336 return (status);
1337}
1338
1339
1340eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
1341{
1342 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
1343 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1344 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
1345 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
1346
1347 do
1348 {
1349 if(eCSR_BAND_24 == eBand)
1350 {
1351 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
1352 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
1353 }
1354 if(eCSR_BAND_5G == eBand)
1355 {
1356 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
1357 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
1358 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
1359 )
1360 {
1361 break;
1362 }
1363 }
1364 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
1365 {
1366 newPhyMode = eCSR_DOT11_MODE_TAURUS;
1367 }
1368 else if(eCSR_DOT11_MODE_AUTO & phyMode)
1369 {
1370 newPhyMode = eCSR_DOT11_MODE_AUTO;
1371 }
1372 else
1373 {
1374 //Check for dual band and higher capability first
1375 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
1376 {
1377 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
1378 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
1379 }
1380 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
1381 {
1382 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
1383 if(eCSR_BAND_24 == eBand) break;
1384 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
1385 eBand = eCSR_BAND_5G;
1386 }
1387 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
1388 {
1389 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
1390 if(eCSR_BAND_5G == eBand) break;
1391 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
1392 eBand = eCSR_BAND_24;
1393 }
1394 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
1395 {
1396 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
1397 if(eCSR_BAND_5G == eBand) break;
1398 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
1399 eBand = eCSR_BAND_24;
1400 }
1401 else if(eCSR_DOT11_MODE_11n & phyMode)
1402 {
1403 newPhyMode = eCSR_DOT11_MODE_11n;
1404 }
1405 else if(eCSR_DOT11_MODE_abg & phyMode)
1406 {
1407 newPhyMode = eCSR_DOT11_MODE_abg;
1408 }
1409 else if(eCSR_DOT11_MODE_11a & phyMode)
1410 {
1411 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
1412 {
1413 if(eCSR_BAND_ALL == eBand)
1414 {
1415 newPhyMode = eCSR_DOT11_MODE_abg;
1416 }
1417 else
1418 {
1419 //bad setting
1420 break;
1421 }
1422 }
1423 else
1424 {
1425 newPhyMode = eCSR_DOT11_MODE_11a;
1426 eBand = eCSR_BAND_5G;
1427 }
1428 }
1429 else if(eCSR_DOT11_MODE_11g & phyMode)
1430 {
1431 newPhyMode = eCSR_DOT11_MODE_11g;
1432 eBand = eCSR_BAND_24;
1433 }
1434 else if(eCSR_DOT11_MODE_11b & phyMode)
1435 {
1436 newPhyMode = eCSR_DOT11_MODE_11b;
1437 eBand = eCSR_BAND_24;
1438 }
1439 else
1440 {
1441 //We will never be here
1442 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X\n"), phyMode );
1443 newPhyMode = eCSR_DOT11_MODE_AUTO;
1444 }
1445 }
1446
1447 //Done validating
1448 status = eHAL_STATUS_SUCCESS;
1449
1450 //Now we need to check whether a restart is needed.
1451 if(eBand != pMac->roam.configParam.eBand)
1452 {
1453 fRestartNeeded = eANI_BOOLEAN_TRUE;
1454 break;
1455 }
1456 if(newPhyMode != pMac->roam.configParam.phyMode)
1457 {
1458 fRestartNeeded = eANI_BOOLEAN_TRUE;
1459 break;
1460 }
1461
1462 }while(0);
1463
1464 if(HAL_STATUS_SUCCESS(status))
1465 {
1466 pMac->roam.configParam.eBand = eBand;
1467 pMac->roam.configParam.phyMode = newPhyMode;
1468 if(pfRestartNeeded)
1469 {
1470 *pfRestartNeeded = fRestartNeeded;
1471 }
1472 }
1473
1474 return (status);
1475}
1476
1477
1478void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
1479{
1480 tANI_U8 Index;
1481 tANI_U8 cChannels;
1482
1483 // for dual band NICs, don't need to trim the channel list....
1484 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
1485 {
1486 // 2.4 GHz band operation requires the channel list to be trimmed to
1487 // the 2.4 GHz channels only...
1488 if ( CSR_IS_24_BAND_ONLY( pMac ) )
1489 {
1490 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
1491 Index++ )
1492 {
1493 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
1494 {
1495 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
1496 cChannels++;
1497 }
1498 }
1499
1500 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
1501 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
1502 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
1503 // only if we need to.
1504 //
1505 // The amount of memory to clear is the number of channesl that we trimmed
1506 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
1507
1508 if ( pChannelList->numChannels > cChannels )
1509 {
1510 palZeroMemory( pMac->hHdd, &pChannelList->channelList[ cChannels ],
1511 sizeof( pChannelList->channelList[ 0 ] ) * ( pChannelList->numChannels - cChannels ) );
1512
1513 }
1514
1515 pChannelList->numChannels = cChannels;
1516 }
1517 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
1518 {
1519 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
1520 {
1521 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
1522 {
1523 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
1524 cChannels++;
1525 }
1526 }
1527
1528 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
1529 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
1530 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
1531 // only if we need to.
1532 //
1533 // The amount of memory to clear is the number of channesl that we trimmed
1534 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
1535 if ( pChannelList->numChannels > cChannels )
1536 {
1537 palZeroMemory( pMac->hHdd, &pChannelList->channelList[ cChannels ],
1538 sizeof( pChannelList->channelList[ 0 ] ) * ( pChannelList->numChannels - cChannels ) );
1539 }
1540
1541 pChannelList->numChannels = cChannels;
1542 }
1543 }
1544
1545}
1546
1547#ifdef WLAN_SOFTAP_FEATURE
1548#define INFRA_AP_DEFAULT_CHANNEL 6
1549eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
1550{
1551 tANI_U8 index= 0;
1552 eHalStatus status = eHAL_STATUS_FAILURE;
1553 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
1554 {
1555 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
1556 status = eHAL_STATUS_SUCCESS;
1557 break;
1558 }
1559 }
1560 return status;
1561}
1562#endif
1563
1564eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
1565{
1566 eHalStatus status = eHAL_STATUS_SUCCESS;
1567 tANI_U8 num20MHzChannelsFound = 0;
1568 VOS_STATUS vosStatus;
1569 tANI_U8 Index = 0;
1570 tANI_U8 num40MHzChannelsFound = 0;
1571
1572
1573 //TODO: this interface changed to include the 40MHz channel list
1574 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
1575 // Read the scan channel list (including the power limit) from EEPROM
1576 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
1577 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
1578 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
1579 {
1580 smsLog( pMac, LOGE, FL("failed to get channels \n"));
1581 status = eHAL_STATUS_FAILURE;
1582 }
1583 else
1584 {
1585 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
1586 {
1587 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1588 }
1589 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
1590 // Move the channel list to the global data
1591 // structure -- this will be used as the scan list
1592 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
1593 {
1594#ifdef FEATURE_WLAN_INTEGRATED_SOC /* Need to fix this while dealing with NV item */
1595 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
1596#else
1597 pMac->scan.base20MHzChannels.channelList[ Index ] = Index + 1;
1598 pMac->scan.defaultPowerTable[Index].chanId = Index + 1;
1599 pMac->scan.defaultPowerTable[Index].pwr = 25;
1600#endif
1601 }
1602 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
1603 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
1604 {
1605 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1606 }
1607 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
1608 {
1609 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
1610 }
1611 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
1612 }
1613
1614 return (status);
1615}
1616
1617
1618eHalStatus csrInitChannelList( tHalHandle hHal )
1619{
1620 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1621 eHalStatus status = eHAL_STATUS_SUCCESS;
1622
1623 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
1624 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
1625 // Apply the base channel list, power info, and set the Country code...
1626 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent );
1627
1628 return (status);
1629}
1630
1631
1632eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
1633 tCsrUpdateConfigParam *pUpdateConfigParam)
1634{
1635 eHalStatus status = eHAL_STATUS_FAILURE;
1636 tCsr11dinfo *ps11dinfo = NULL;
1637
1638 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
1639 status = CsrInit11dInfo(pMac, ps11dinfo);
1640 return status;
1641}
1642
1643
1644static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
1645{
1646 eHalStatus status = eHAL_STATUS_FAILURE;
1647 tANI_U8 index;
1648 tANI_U32 count=0;
1649 tSirMacChanInfo *pChanInfo;
1650 tSirMacChanInfo *pChanInfoStart;
1651 tANI_BOOLEAN applyConfig = TRUE;
1652
1653 if(!ps11dinfo)
1654 {
1655 return (status);
1656 }
1657
1658 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
1659 {
1660 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
1661 status = palCopyMemory(pMac->hHdd, pMac->scan.base20MHzChannels.channelList,
1662 ps11dinfo->Channels.channelList, ps11dinfo->Channels.numChannels);
1663 if(!HAL_STATUS_SUCCESS(status)) return (status);
1664 }
1665 else
1666 {
1667 //No change
1668 return (eHAL_STATUS_SUCCESS);
1669 }
1670
1671 //legacy maintenance
1672 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeDefault,
1673 ps11dinfo->countryCode, WNI_CFG_COUNTRY_CODE_LEN);
1674 if(!HAL_STATUS_SUCCESS(status)) return (status);
1675
1676 //Tush: at csropen get this initialized with default, during csr reset if this
1677 // already set with some value no need initilaize with default again
1678 if(0 == pMac->scan.countryCodeCurrent[0])
1679 {
1680 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent,
1681 ps11dinfo->countryCode, WNI_CFG_COUNTRY_CODE_LEN);
1682 if(!HAL_STATUS_SUCCESS(status)) return (status);
1683 }
1684
1685 // need to add the max power channel list
1686 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN)))
1687 {
1688 palZeroMemory(pMac->hHdd, pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
1689 pChanInfoStart = pChanInfo;
1690
1691 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
1692 {
1693 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
1694 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
1695 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
1696 pChanInfo++;
1697 count++;
1698 }
1699 if(count)
1700 {
1701 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
1702 }
1703 palFreeMemory(pMac->hHdd, pChanInfoStart);
1704 }
1705
1706 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
1707 if( HAL_STATUS_SUCCESS(status) )
1708 {
1709 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
1710 {
1711 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
1712 {
1713 applyConfig = FALSE;
1714 }
1715 }
1716
1717 if(TRUE == applyConfig)
1718 {
1719 // Apply the base channel list, power info, and set the Country code...
1720 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent );
1721 }
1722
1723 }
1724
1725 return (status);
1726}
1727
1728//pCommand may be NULL
1729//Pass in sessionId in case pCommand is NULL. sessionId is not used in case pCommand is not NULL.
1730void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac, tANI_U32 sessionId, tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
1731{
1732 tListElem *pEntry, *pNextEntry;
1733 tSmeCmd *pDupCommand;
1734 tDblLinkList localList;
1735
1736 vos_mem_zero(&localList, sizeof(tDblLinkList));
1737 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
1738 {
1739 smsLog(pMac, LOGE, FL(" failed to open list"));
1740 return;
1741 }
1742 csrLLLock( &pMac->sme.smeCmdPendingList );
1743 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
1744 while( pEntry )
1745 {
1746 pNextEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
1747 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
1748
1749 // Remove the previous command if..
1750 // - the new roam command is for the same RoamReason...
1751 // - the new roam command is a NewProfileList.
1752 // - the new roam command is a Forced Dissoc
1753 // - the new roam command is from an 802.11 OID (OID_SSID or OID_BSSID).
1754 if (
1755 (pCommand && ( pCommand->sessionId == pDupCommand->sessionId ) &&
1756 ((pCommand->command == pDupCommand->command) &&
1757 (pCommand->u.roamCmd.roamReason == pDupCommand->u.roamCmd.roamReason ||
1758 eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason ||
1759 eCsrHddIssued == pCommand->u.roamCmd.roamReason)))
1760 ||
1761 //below the pCommand is NULL
Jeff Johnson43971f52012-07-17 12:26:56 -07001762 ( (sessionId == pDupCommand->sessionId) &&
1763 (eSmeCommandRoam == pDupCommand->command) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07001764 ((eCsrForcedDisassoc == eRoamReason) ||
1765 (eCsrHddIssued == eRoamReason))
1766 )
1767 )
1768 {
1769 smsLog(pMac, LOGW, FL(" roamReason = %d\n"), pDupCommand->u.roamCmd.roamReason);
1770 // Remove the 'stale' roam command from the pending list...
1771 if(csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK ))
1772 {
1773 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
1774 }
1775 }
1776 pEntry = pNextEntry;
1777 }
1778 csrLLUnlock( &pMac->sme.smeCmdPendingList );
1779
1780 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
1781 {
1782 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
1783 //Tell caller that the command is cancelled
1784 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL, pDupCommand->u.roamCmd.roamId,
1785 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
1786 csrReleaseCommandRoam(pMac, pDupCommand);
1787 }
1788 csrLLClose(&localList);
1789}
1790
1791eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
1792 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
1793{
1794 eHalStatus status = eHAL_STATUS_SUCCESS;
1795#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
1796 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
1797#endif
1798 tCsrRoamSession *pSession;
1799
1800 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
1801 {
1802 pSession = CSR_GET_SESSION( pMac, sessionId );
1803 }
1804 else
1805 {
1806 smsLog(pMac, LOGE, "Session ID:%d is not valid\n", sessionId);
1807 VOS_ASSERT(0);
1808 return eHAL_STATUS_FAILURE;
1809 }
1810
1811 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
1812 {
1813 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d\n", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
1814 }
1815
1816 if ( (pSession == NULL) ||
1817 (eANI_BOOLEAN_FALSE == pSession->sessionActive) )
1818 {
1819 smsLog(pMac, LOG1, "Session ID is not valid\n");
1820 return eHAL_STATUS_FAILURE;
1821 }
1822
1823 if(NULL != pSession->callback)
1824 {
1825 if( pRoamInfo )
1826 {
1827 pRoamInfo->sessionId = (tANI_U8)sessionId;
1828 }
1829
1830 /* avoid holding the global lock when making the roaming callback , original change came
1831 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
1832 is possible on other OS ports where the callback may need to take locks to protect
1833 HDD state
1834 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
1835 that may actually depend on the lock being held */
1836 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
1837 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
1838 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
1839 }
1840 //EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
1841 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
1842#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
1843 palZeroMemory(pMac->hHdd, &connectionStatus, sizeof(vos_event_wlan_status_payload_type));
1844 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2))
1845 {
1846 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
1847 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
1848 if(NULL != pRoamInfo->pBssDesc)
1849 {
1850 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
1851 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
1852 }
1853
1854 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
1855 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
1856 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
1857 palCopyMemory(pMac->hHdd, connectionStatus.ssid, pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
1858 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
1859 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
1860 }
1861
1862 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
1863 {
1864 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
1865 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
1866 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
1867 }
1868
1869 if(eCSR_ROAM_RESULT_FORCED == u2)
1870 {
1871 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
1872 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
1873 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
1874 }
1875
1876 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
1877 {
1878 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
1879 connectionStatus.reason = eCSR_REASON_DISASSOC;
1880 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
1881 }
1882
1883 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
1884 {
1885 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
1886 connectionStatus.reason = eCSR_REASON_DEAUTH;
1887 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
1888 }
1889
1890#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
1891
1892 return (status);
1893}
1894
1895// Returns whether handoff is currently in progress or not
1896tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
1897{
1898#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1899 return csrNeighborRoamIsHandoffInProgress(pMac);
1900#else
1901 return eANI_BOOLEAN_FALSE;
1902#endif
1903
1904}
1905
1906eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
1907 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
1908{
1909 eHalStatus status = eHAL_STATUS_SUCCESS;
1910 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
1911 tANI_U16 reasonCode;
1912 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
1913
1914 //Restore AC weight in case we change it
1915 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
1916 {
1917 smsLog(pMac, LOGE, FL(" restore AC weights (%d-%d-%d-%d)\n"), pMac->roam.ucACWeights[0], pMac->roam.ucACWeights[1],
1918 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
1919 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
1920 }
1921
1922 if ( fMICFailure )
1923 {
1924 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
1925 }
1926 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
1927 {
1928 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
1929 } else
1930 {
1931 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
1932 }
1933
1934#ifdef WLAN_FEATURE_VOWIFI_11R
1935 if ( (csrRoamIsHandoffInProgress(pMac)) &&
1936 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
1937 {
1938 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1939 palCopyMemory(pMac->hHdd, &bssId, pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid, sizeof(tSirMacAddr));
1940
1941 } else
1942#endif
1943 if(pSession->pConnectBssDesc)
1944 {
1945 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
1946 }
1947
1948
1949 smsLog( pMac, LOGE, "CSR Attempting to Disassociate Bssid= %02x-%02x-%02x-%02x-%02x-%02x subState = %d\n",
1950 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
1951 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ], NewSubstate );
1952
1953 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
1954
1955 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
1956
1957 if(HAL_STATUS_SUCCESS(status))
1958 {
1959 csrRoamLinkDown(pMac, sessionId);
1960
1961#ifndef WLAN_MDM_CODE_REDUCTION_OPT
1962 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
1963 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
1964 {
1965 //Tush-QoS: notify QoS module that disassoc happening
1966 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
1967 }
1968#endif
1969 }
1970
1971 return (status);
1972}
1973
1974#ifdef WLAN_SOFTAP_FEATURE
1975
1976
1977
1978/* ---------------------------------------------------------------------------
1979 \fn csrRoamIssueDisassociateStaCmd
1980 \brief csr function that HDD calls to disassociate a associated station
1981 \param sessionId - session Id for Soft AP
1982 \param pPeerMacAddr - MAC of associated station to delete
1983 \param reason - reason code, be one of the tSirMacReasonCodes
1984 \return eHalStatus
1985 ---------------------------------------------------------------------------*/
1986eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
1987 tANI_U32 sessionId,
1988 tANI_U8 *pPeerMacAddr,
1989 tANI_U32 reason)
1990{
1991 eHalStatus status = eHAL_STATUS_SUCCESS;
1992 tSmeCmd *pCommand;
1993
1994 do
1995 {
1996 pCommand = csrGetCommandBuffer( pMac );
1997 if ( !pCommand )
1998 {
1999 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2000 status = eHAL_STATUS_RESOURCES;
2001 break;
2002 }
2003 pCommand->command = eSmeCommandRoam;
2004 pCommand->sessionId = (tANI_U8)sessionId;
2005 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
2006 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2007 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2008 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2009 if( !HAL_STATUS_SUCCESS( status ) )
2010 {
2011 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
2012 csrReleaseCommandRoam( pMac, pCommand );
2013 }
2014 }while(0);
2015
2016 return status;
2017}
2018
2019
2020
2021/* ---------------------------------------------------------------------------
2022 \fn csrRoamIssueDeauthSta
2023 \brief csr function that HDD calls to delete a associated station
2024 \param sessionId - session Id for Soft AP
2025 \param pPeerMacAddr - MAC of associated station to delete
2026 \param reason - reason code, be one of the tSirMacReasonCodes
2027 \return eHalStatus
2028 ---------------------------------------------------------------------------*/
2029eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
2030 tANI_U32 sessionId,
2031 tANI_U8 *pPeerMacAddr,
2032 tANI_U32 reason)
2033{
2034 eHalStatus status = eHAL_STATUS_SUCCESS;
2035 tSmeCmd *pCommand;
2036
2037 do
2038 {
2039 pCommand = csrGetCommandBuffer( pMac );
2040 if ( !pCommand )
2041 {
2042 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2043 status = eHAL_STATUS_RESOURCES;
2044 break;
2045 }
2046 pCommand->command = eSmeCommandRoam;
2047 pCommand->sessionId = (tANI_U8)sessionId;
2048 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
2049 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2050 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2051 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2052 if( !HAL_STATUS_SUCCESS( status ) )
2053 {
2054 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
2055 csrReleaseCommandRoam( pMac, pCommand );
2056 }
2057 }while(0);
2058
2059 return status;
2060}
2061
2062
2063
2064eHalStatus
2065csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
2066 tANI_BOOLEAN bEnable )
2067{
2068 eHalStatus status = eHAL_STATUS_FAILURE;
2069 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2070 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2071
2072 if (!pSession)
2073 {
2074 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found\n");
2075 return (status);
2076 }
2077
2078 if (pSession->pConnectBssDesc)
2079 {
2080 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2081 }
2082 else
2083 {
2084 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found\n");
2085 return (status);
2086 }
2087
2088 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = %02x-%02x-%02x-%02x-%02x-%02x, Enable = %d\n",
2089 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2090 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] , bEnable);
2091
2092 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
2093 return (status);
2094}
2095
2096eHalStatus
2097csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
2098 VOS_MODULE_ID modId, void *pUsrContext,
2099 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
2100{
2101 eHalStatus status = eHAL_STATUS_SUCCESS;
2102 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2103 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2104
2105 if (!pSession)
2106 {
2107 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found\n");
2108 return (status);
2109 }
2110
2111 if(pSession->pConnectBssDesc)
2112 {
2113 palCopyMemory( pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid) );
2114 }
2115 else
2116 {
2117 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found\n");
2118 return (status);
2119 }
2120
2121 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = %02x-%02x-%02x-%02x-%02x-%02x\n",
2122 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2123 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
2124
2125 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2126 return (status);
2127}
2128
2129eHalStatus
2130csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
2131 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
2132{
2133 eHalStatus status = eHAL_STATUS_SUCCESS;
2134 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2135 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2136
2137 if (!pSession)
2138 {
2139 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found\n");
2140 return (status);
2141 }
2142
2143 if(pSession->pConnectBssDesc)
2144 {
2145 palCopyMemory( pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid) );
2146 }
2147 else
2148 {
2149 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found\n");
2150 return (status);
2151 }
2152
2153 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = %02x-%02x-%02x-%02x-%02x-%02x\n",
2154 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2155 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
2156
2157 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2158
2159 return (status);
2160}
2161
2162#endif
2163
2164eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
2165{
2166 eHalStatus status = eHAL_STATUS_SUCCESS;
2167 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2168 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2169
2170 if(pSession->pConnectBssDesc)
2171 {
2172 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2173 }
2174
2175 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= %02x-%02x-%02x-%02x-%02x-%02x\n",
2176 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2177 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
2178
2179 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2180
2181 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DISASSOC_LEAVING_BSS_REASON );
2182
2183 return (status);
2184}
2185
2186
2187
2188eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
2189{
2190 eHalStatus status = eHAL_STATUS_SUCCESS;
2191 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2192 tANI_U32 size;
2193
2194 // If no BSS description was found in this connection (happens with start IBSS), then
2195 // nix the BSS description that we keep around for the connected BSS) and get out...
2196 if(NULL == pBssDesc)
2197 {
2198 csrFreeConnectBssDesc(pMac, sessionId);
2199 }
2200 else
2201 {
2202 size = pBssDesc->length + sizeof( pBssDesc->length );
2203 if(NULL != pSession->pConnectBssDesc)
2204 {
2205 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
2206 {
2207 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
2208 csrFreeConnectBssDesc(pMac, sessionId);
2209 }
2210 }
2211 if(NULL == pSession->pConnectBssDesc)
2212 {
2213 status = palAllocateMemory( pMac->hHdd, (void **)&pSession->pConnectBssDesc, size);
2214 }
2215 if ( HAL_STATUS_SUCCESS(status) && pSession->pConnectBssDesc )
2216 {
2217 palCopyMemory( pMac->hHdd, pSession->pConnectBssDesc, pBssDesc, size );
2218 }
2219 }
2220
2221 return (status);
2222}
2223
2224
2225eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2226 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
2227 tDot11fBeaconIEs *pIes)
2228{
2229 eHalStatus status = eHAL_STATUS_SUCCESS;
2230 eCsrCfgDot11Mode cfgDot11Mode;
2231
2232#if defined(VOSS_ENABLED)
2233 VOS_ASSERT( pIes != NULL );
2234#endif
2235
2236 do
2237 {
2238 palCopyMemory(pMac->hHdd, &pBssConfig->BssCap, &pBssDesc->capabilityInfo, sizeof(tSirMacCapabilityInfo));
2239 //get qos
2240 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
2241 //get SSID
2242 if(pIes->SSID.present)
2243 {
2244 palCopyMemory(pMac->hHdd, &pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
2245 pBssConfig->SSID.length = pIes->SSID.num_ssid;
2246 }
2247 else
2248 pBssConfig->SSID.length = 0;
2249 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
2250 {
2251 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard\n");
2252 //Return failed if profile doesn't have an SSID either.
2253 if(pProfile->SSIDs.numOfSSIDs == 0)
2254 {
2255 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID\n");
2256 status = eHAL_STATUS_FAILURE;
2257 break;
2258 }
2259 }
2260 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
2261 {
2262 pBssConfig->eBand = eCSR_BAND_5G;
2263 }
2264 else
2265 {
2266 pBssConfig->eBand = eCSR_BAND_24;
2267 }
2268 //phymode
2269 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
2270 {
2271 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
2272 }
2273 else
2274 {
2275 smsLog(pMac, LOGW, " Can not find match phy mode\n");
2276 //force it
2277 if(eCSR_BAND_24 == pBssConfig->eBand)
2278 {
2279 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2280 }
2281 else
2282 {
2283 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2284 }
2285 }
2286
2287 //Qos
2288 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
2289 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
2290 {
2291 //Joining BSS is not 11n capable and WMM is disabled on client.
2292 //Disable QoS and WMM
2293 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2294 }
2295
2296 //auth type
2297 switch( pProfile->negotiatedAuthType )
2298 {
2299 default:
2300 case eCSR_AUTH_TYPE_WPA:
2301 case eCSR_AUTH_TYPE_WPA_PSK:
2302 case eCSR_AUTH_TYPE_WPA_NONE:
2303 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2304 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2305 break;
2306
2307 case eCSR_AUTH_TYPE_SHARED_KEY:
2308 pBssConfig->authType = eSIR_SHARED_KEY;
2309 break;
2310
2311 case eCSR_AUTH_TYPE_AUTOSWITCH:
2312 pBssConfig->authType = eSIR_AUTO_SWITCH;
2313 break;
2314 }
2315 //short slot time
2316 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
2317 {
2318 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2319 }
2320 else
2321 {
2322 pBssConfig->uShortSlotTime = 0;
2323 }
2324 if(pBssConfig->BssCap.ibss)
2325 {
2326 //We don't support 11h on IBSS
2327 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2328 }
2329 else
2330 {
2331 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
2332 }
2333 //power constraint
2334 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
2335 //heartbeat
2336 if ( CSR_IS_11A_BSS( pBssDesc ) )
2337 {
2338 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2339 }
2340 else
2341 {
2342 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2343 }
2344 //Join timeout
2345 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
2346 // be 3 x the BeaconInterval.
2347 if ( pBssDesc->beaconInterval )
2348 {
2349 //Make sure it is bigger than the minimal
2350 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(3 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
2351 }
2352 else
2353 {
2354 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
2355 }
2356 //validate CB
2357 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
2358 }while(0);
2359
2360 return (status);
2361}
2362
2363
2364static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2365 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
2366{
2367 eHalStatus status = eHAL_STATUS_SUCCESS;
2368 tANI_U8 operationChannel = 0;
2369 tANI_U8 qAPisEnabled = FALSE;
2370 //SSID
2371 pBssConfig->SSID.length = 0;
2372 if(pProfile->SSIDs.numOfSSIDs)
2373 {
2374 //only use the first one
2375 palCopyMemory(pMac->hHdd, &pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID, sizeof(tSirMacSSid));
2376 }
2377 else
2378 {
2379 //SSID must present
2380 return eHAL_STATUS_FAILURE;
2381 }
2382
2383 //Settomg up the capabilities
2384 if( csrIsBssTypeIBSS(pProfile->BSSType) )
2385 {
2386 pBssConfig->BssCap.ibss = 1;
2387 }
2388 else
2389 {
2390 pBssConfig->BssCap.ess = 1;
2391 }
2392 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
2393 {
2394 pBssConfig->BssCap.privacy = 1;
2395 }
2396
2397 pBssConfig->eBand = pMac->roam.configParam.eBand;
2398 //phymode
2399 if(pProfile->ChannelInfo.ChannelList)
2400 {
2401 operationChannel = pProfile->ChannelInfo.ChannelList[0];
2402 }
2403
2404#ifdef WLAN_SOFTAP_FEATURE
2405 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
2406 &pBssConfig->eBand);
2407#else
2408
2409 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, (eCsrPhyMode)pProfile->phyMode, operationChannel,
2410 &pBssConfig->eBand);
2411#endif
2412 //QOS
2413 //Is this correct to always set to this //***
2414
2415 if ( pBssConfig->BssCap.ess == 1 )
2416 {
2417#ifdef WLAN_SOFTAP_FEATURE
2418 /*For Softap case enable WMM*/
2419 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
2420 qAPisEnabled = TRUE;
2421 }
2422 else
2423#endif
2424 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
2425 qAPisEnabled = TRUE;
2426 } else {
2427 qAPisEnabled = FALSE;
2428 }
2429 } else {
2430 qAPisEnabled = TRUE;
2431 }
2432
2433 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
2434 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
2435 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
2436 )
2437 {
2438 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2439 } else {
2440 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2441 }
2442
2443 //auth type
2444 switch( pProfile->AuthType.authType[0] ) //Take the prefered Auth type.
2445 {
2446 default:
2447 case eCSR_AUTH_TYPE_WPA:
2448 case eCSR_AUTH_TYPE_WPA_PSK:
2449 case eCSR_AUTH_TYPE_WPA_NONE:
2450 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2451 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2452 break;
2453
2454 case eCSR_AUTH_TYPE_SHARED_KEY:
2455 pBssConfig->authType = eSIR_SHARED_KEY;
2456 break;
2457
2458 case eCSR_AUTH_TYPE_AUTOSWITCH:
2459 pBssConfig->authType = eSIR_AUTO_SWITCH;
2460 break;
2461 }
2462 //short slot time
2463 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
2464 {
2465 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2466 }
2467 else
2468 {
2469 pBssConfig->uShortSlotTime = 0;
2470 }
2471 //power constraint. We don't support 11h on IBSS
2472 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2473 pBssConfig->uPowerLimit = 0;
2474 //heartbeat
2475 if ( eCSR_BAND_5G == pBssConfig->eBand )
2476 {
2477 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2478 }
2479 else
2480 {
2481 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2482 }
2483 //Join timeout
2484 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
2485
2486 return (status);
2487}
2488
2489static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
2490{
2491 eHalStatus status = eHAL_STATUS_FAILURE;
2492 tDot11fBeaconIEs *pIes = NULL;
2493
2494 do
2495 {
2496 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
2497 {
2498 //err msg
2499 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
2500 "csrRoamGetQosInfoFromBss() failed\n");
2501
2502 break;
2503 }
2504 //check if the AP is QAP & it supports APSD
2505 if( CSR_IS_QOS_BSS(pIes) )
2506 {
2507 return eHAL_STATUS_SUCCESS;
2508 }
2509 } while (0);
2510
2511 return status;
2512}
2513
2514
2515void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
2516{
2517
2518 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
2519 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
2520 // See !!Note: below in this function...
2521 tANI_U32 PrivacyEnabled = 0;
2522 tANI_U32 RsnEnabled = 0;
2523 tANI_U32 WepDefaultKeyId = 0;
2524 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
2525 tANI_U32 Key0Length = 0;
2526 tANI_U32 Key1Length = 0;
2527 tANI_U32 Key2Length = 0;
2528 tANI_U32 Key3Length = 0;
2529
2530 // Reserve for the biggest key
2531 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
2532 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
2533 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
2534 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
2535
2536 switch ( pProfile->negotiatedUCEncryptionType )
2537 {
2538 case eCSR_ENCRYPT_TYPE_NONE:
2539
2540 // for NO encryption, turn off Privacy and Rsn.
2541 PrivacyEnabled = 0;
2542 RsnEnabled = 0;
2543
2544 // WEP key length and Wep Default Key ID don't matter in this case....
2545
2546 // clear out the WEP keys that may be hanging around.
2547 Key0Length = 0;
2548 Key1Length = 0;
2549 Key2Length = 0;
2550 Key3Length = 0;
2551
2552 break;
2553
2554 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
2555
2556 // Privacy is ON. NO RSN for Wep40 static key.
2557 PrivacyEnabled = 1;
2558 RsnEnabled = 0;
2559
2560 // Set the Wep default key ID.
2561 WepDefaultKeyId = pProfile->Keys.defaultIndex;
2562
2563 // Wep key size if 5 bytes (40 bits).
2564 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
2565
2566 // set encryption keys in the CFG database or clear those that are not present in this profile.
2567 if ( pProfile->Keys.KeyLength[0] )
2568 {
2569 palCopyMemory( pMac->hHdd, Key0, pProfile->Keys.KeyMaterial[0], WNI_CFG_WEP_KEY_LENGTH_5 );
2570 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
2571 }
2572 else
2573 {
2574 Key0Length = 0;
2575 }
2576
2577 if ( pProfile->Keys.KeyLength[1] )
2578 {
2579 palCopyMemory( pMac->hHdd, Key1, pProfile->Keys.KeyMaterial[1], WNI_CFG_WEP_KEY_LENGTH_5 );
2580 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
2581 }
2582 else
2583 {
2584 Key1Length = 0;
2585 }
2586
2587 if ( pProfile->Keys.KeyLength[2] )
2588 {
2589 palCopyMemory( pMac->hHdd, Key2, pProfile->Keys.KeyMaterial[2], WNI_CFG_WEP_KEY_LENGTH_5 );
2590 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
2591 }
2592 else
2593 {
2594 Key2Length = 0;
2595 }
2596
2597 if ( pProfile->Keys.KeyLength[3] )
2598 {
2599 palCopyMemory( pMac->hHdd, Key3, pProfile->Keys.KeyMaterial[3], WNI_CFG_WEP_KEY_LENGTH_5 );
2600 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
2601 }
2602 else
2603 {
2604 Key3Length = 0;
2605 }
2606
2607 break;
2608
2609 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
2610
2611 // Privacy is ON. NO RSN for Wep40 static key.
2612 PrivacyEnabled = 1;
2613 RsnEnabled = 0;
2614
2615 // Set the Wep default key ID.
2616 WepDefaultKeyId = pProfile->Keys.defaultIndex;
2617
2618 // Wep key size if 13 bytes (104 bits).
2619 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
2620
2621 // set encryption keys in the CFG database or clear those that are not present in this profile.
2622 if ( pProfile->Keys.KeyLength[0] )
2623 {
2624 palCopyMemory( pMac->hHdd, Key0, pProfile->Keys.KeyMaterial[ 0 ], WNI_CFG_WEP_KEY_LENGTH_13 );
2625 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
2626 }
2627 else
2628 {
2629 Key0Length = 0;
2630 }
2631
2632 if ( pProfile->Keys.KeyLength[1] )
2633 {
2634 palCopyMemory( pMac->hHdd, Key1, pProfile->Keys.KeyMaterial[ 1 ], WNI_CFG_WEP_KEY_LENGTH_13 );
2635 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
2636 }
2637 else
2638 {
2639 Key1Length = 0;
2640 }
2641
2642 if ( pProfile->Keys.KeyLength[2] )
2643 {
2644 palCopyMemory( pMac->hHdd, Key2, pProfile->Keys.KeyMaterial[ 2 ], WNI_CFG_WEP_KEY_LENGTH_13 );
2645 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
2646 }
2647 else
2648 {
2649 Key2Length = 0;
2650 }
2651
2652 if ( pProfile->Keys.KeyLength[3] )
2653 {
2654 palCopyMemory( pMac->hHdd, Key3, pProfile->Keys.KeyMaterial[ 3 ], WNI_CFG_WEP_KEY_LENGTH_13 );
2655 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
2656 }
2657 else
2658 {
2659 Key3Length = 0;
2660 }
2661
2662 break;
2663
2664 case eCSR_ENCRYPT_TYPE_WEP40:
2665 case eCSR_ENCRYPT_TYPE_WEP104:
2666 case eCSR_ENCRYPT_TYPE_TKIP:
2667 case eCSR_ENCRYPT_TYPE_AES:
2668#ifdef FEATURE_WLAN_WAPI
2669 case eCSR_ENCRYPT_TYPE_WPI:
2670#endif /* FEATURE_WLAN_WAPI */
2671 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
2672 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
2673 PrivacyEnabled = (0 != fPrivacy);
2674
2675 // turn on RSN enabled for WPA associations
2676 RsnEnabled = 1;
2677
2678 // WEP key length and Wep Default Key ID don't matter in this case....
2679
2680 // clear out the static WEP keys that may be hanging around.
2681 Key0Length = 0;
2682 Key1Length = 0;
2683 Key2Length = 0;
2684 Key3Length = 0;
2685
2686 break;
2687
2688 default:
2689 PrivacyEnabled = 0;
2690 RsnEnabled = 0;
2691 break;
2692 }
2693
2694 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
2695 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
2696 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
2697 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
2698 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
2699 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
2700 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
2701 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
2702}
2703
2704
2705static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
2706{
2707 tANI_U32 len = 0;
2708 if(pSSID->length <= WNI_CFG_SSID_LEN)
2709 {
2710 len = pSSID->length;
2711 }
2712 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
2713}
2714
2715
2716eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
2717{
2718 eHalStatus status = eHAL_STATUS_SUCCESS;
2719 tANI_U32 QoSEnabled;
2720 tANI_U32 WmeEnabled;
2721
2722 // set the CFG enable/disable variables based on the qosType being configured...
2723 switch( qosType )
2724 {
2725
2726 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
2727 QoSEnabled = FALSE;
2728 WmeEnabled = TRUE;
2729 break;
2730
2731 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
2732 QoSEnabled = FALSE;
2733 WmeEnabled = TRUE;
2734 break;
2735
2736 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
2737 QoSEnabled = FALSE;
2738 WmeEnabled = TRUE;
2739 break;
2740
2741 case eCSR_MEDIUM_ACCESS_11e_eDCF:
2742 QoSEnabled = TRUE;
2743 WmeEnabled = FALSE;
2744 break;
2745
2746 case eCSR_MEDIUM_ACCESS_11e_HCF:
2747 QoSEnabled = TRUE;
2748 WmeEnabled = FALSE;
2749 break;
2750
2751 default:
2752 case eCSR_MEDIUM_ACCESS_DCF:
2753 QoSEnabled = FALSE;
2754 WmeEnabled = FALSE;
2755 break;
2756
2757 }
2758 //save the WMM setting for later use
2759 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
2760
2761 status = ccmCfgSetInt(pMac, WNI_CFG_QOS_ENABLED, QoSEnabled, NULL, eANI_BOOLEAN_FALSE);
2762 status = ccmCfgSetInt(pMac, WNI_CFG_WME_ENABLED, WmeEnabled, NULL, eANI_BOOLEAN_FALSE);
2763
2764 return (status);
2765}
2766
2767static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
2768 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet)
2769{
2770 eHalStatus status = eHAL_STATUS_FAILURE;
2771 int i;
2772 eCsrCfgDot11Mode cfgDot11Mode;
2773 tANI_U8 *pDstRate;
2774
2775 palZeroMemory(pMac->hHdd, pOpRateSet, sizeof(tSirMacRateSet));
2776 palZeroMemory(pMac->hHdd, pExRateSet, sizeof(tSirMacRateSet));
2777
2778#if defined(VOSS_ENABLED)
2779 VOS_ASSERT( pIes != NULL );
2780#endif
2781
2782 if( NULL != pIes )
2783 {
2784 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
2785
2786 // Originally, we thought that for 11a networks, the 11a rates are always
2787 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
2788 // appear in the Operational Rate set. Consequently, in either case, we
2789 // would blindly put the rates we support into our Operational Rate set
2790 // (including the basic rates, which we have already verified are
2791 // supported earlier in the roaming decision).
2792
2793 // However, it turns out that this is not always the case. Some AP's
2794 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
2795 // too. Now, we're a little more careful:
2796 pDstRate = pOpRateSet->rate;
2797 if(pIes->SuppRates.present)
2798 {
2799 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
2800 {
2801 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
2802 {
2803 *pDstRate++ = pIes->SuppRates.rates[ i ];
2804 pOpRateSet->numRates++;;
2805 }
2806 }
2807 }
2808
2809 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
2810 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
2811 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
2812 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
2813 {
2814 // If there are Extended Rates in the beacon, we will reflect those
2815 // extended rates that we support in out Extended Operational Rate
2816 // set:
2817 pDstRate = pExRateSet->rate;
2818 if(pIes->ExtSuppRates.present)
2819 {
2820 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
2821 {
2822 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) )
2823 {
2824 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
2825 pExRateSet->numRates++;
2826 }
2827 }
2828 }
2829 }
2830 }//Parsing BSSDesc
2831 else
2832 {
2833 smsLog(pMac, LOGE, FL("failed to parse BssDesc\n"));
2834 }
2835 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
2836 return status;
2837}
2838
2839static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
2840 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
2841{
2842 int i;
2843 tANI_U8 *pDstRate;
2844 eCsrCfgDot11Mode cfgDot11Mode;
2845 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
2846 tANI_U32 OperationalRatesLength = 0;
2847 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
2848 tANI_U32 ExtendedOperationalRatesLength = 0;
2849 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
2850 tANI_U32 ProprietaryOperationalRatesLength = 0;
2851 tANI_U32 PropRatesEnable = 0;
2852 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
2853 tANI_U32 MCSRateLength = 0;
2854
2855#if defined(VOSS_ENABLED)
2856 VOS_ASSERT( pIes != NULL );
2857#endif
2858
2859 if( NULL != pIes )
2860 {
2861 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
2862
2863 // Originally, we thought that for 11a networks, the 11a rates are always
2864 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
2865 // appear in the Operational Rate set. Consequently, in either case, we
2866 // would blindly put the rates we support into our Operational Rate set
2867 // (including the basic rates, which we have already verified are
2868 // supported earlier in the roaming decision).
2869
2870 // However, it turns out that this is not always the case. Some AP's
2871 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
2872 // too. Now, we're a little more careful:
2873 pDstRate = OperationalRates;
2874 if(pIes->SuppRates.present)
2875 {
2876 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
2877 {
2878 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
2879 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
2880 {
2881 *pDstRate++ = pIes->SuppRates.rates[ i ];
2882 OperationalRatesLength++;
2883 }
2884 }
2885 }
2886
2887 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
2888 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
2889 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
2890 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
2891 {
2892 // If there are Extended Rates in the beacon, we will reflect those
2893 // extended rates that we support in out Extended Operational Rate
2894 // set:
2895 pDstRate = ExtendedOperationalRates;
2896 if(pIes->ExtSuppRates.present)
2897 {
2898 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
2899 {
2900 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
2901 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
2902 {
2903 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
2904 ExtendedOperationalRatesLength++;
2905 }
2906 }
2907 }
2908 }
2909
2910 // Enable proprietary MAC features if peer node is Airgo node and STA
2911 // user wants to use them
2912 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
2913 {
2914 PropRatesEnable = 1;
2915 }
2916 else
2917 {
2918 PropRatesEnable = 0;
2919 }
2920
2921 // For ANI network companions, we need to populate the proprietary rate
2922 // set with any proprietary rates we found in the beacon, only if user
2923 // allows them...
2924 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
2925 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
2926 {
2927 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
2928 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
2929 {
2930 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
2931 }
2932 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates, pIes->Airgo.PropSuppRates.rates, ProprietaryOperationalRatesLength );
2933 }
2934 else {
2935 // No proprietary modes...
2936 ProprietaryOperationalRatesLength = 0;
2937 }
2938
2939 /* Get MCS Rate */
2940 pDstRate = MCSRateIdxSet;
2941 if ( pIes->HTCaps.present )
2942 {
2943 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
2944 {
2945 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
2946 {
2947 MCSRateLength++;
2948 *pDstRate++ = i;
2949 }
2950 }
2951 }
2952
2953 // Set the operational rate set CFG variables...
2954 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
2955 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
2956 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
2957 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
2958 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
2959 ProprietaryOperationalRates,
2960 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
2961 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
2962 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
2963 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
2964 }//Parsing BSSDesc
2965 else
2966 {
2967 smsLog(pMac, LOGE, FL("failed to parse BssDesc\n"));
2968 }
2969}
2970
2971
2972static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
2973 tCsrRoamProfile *pProfile )
2974{
2975 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
2976 { 8,
2977 { SIR_MAC_RATE_6,
2978 SIR_MAC_RATE_9,
2979 SIR_MAC_RATE_12,
2980 SIR_MAC_RATE_18,
2981 SIR_MAC_RATE_24,
2982 SIR_MAC_RATE_36,
2983 SIR_MAC_RATE_48,
2984 SIR_MAC_RATE_54 } } };
2985
2986 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
2987 { 4,
2988 { SIR_MAC_RATE_1,
2989 SIR_MAC_RATE_2,
2990 SIR_MAC_RATE_5_5,
2991 SIR_MAC_RATE_11 } } };
2992
2993
2994 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
2995 { SIR_MAC_RATE_72,
2996 SIR_MAC_RATE_96,
2997 SIR_MAC_RATE_108 } };
2998 eCsrCfgDot11Mode cfgDot11Mode;
2999 eCsrBand eBand;
3000 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3001 tANI_U32 OperationalRatesLength = 0;
3002 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3003 tANI_U32 ExtendedOperationalRatesLength = 0;
3004 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3005 tANI_U32 ProprietaryOperationalRatesLength = 0;
3006 tANI_U32 PropRatesEnable = 0;
3007 tANI_U8 operationChannel = 0;
3008
3009 if(pProfile->ChannelInfo.ChannelList)
3010 {
3011 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3012 }
3013
3014#ifdef WLAN_SOFTAP_FEATURE
3015 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
3016#else
3017 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, (eCsrPhyMode)pProfile->phyMode, operationChannel, &eBand );
3018#endif
3019 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3020 // networks, the 11b rates appear in the Operational Rate set. In either case,
3021 // we can blindly put the rates we support into our Operational Rate set
3022 // (including the basic rates, which we have already verified are supported
3023 // earlier in the roaming decision).
3024 if ( eCSR_BAND_5G == eBand )
3025 {
3026 // 11a rates into the Operational Rate Set.
3027 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3028 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
3029 palCopyMemory( pMac->hHdd, OperationalRates,
3030 DefaultSupportedRates11a.supportedRateSet.rate,
3031 OperationalRatesLength );
3032
3033 // Nothing in the Extended rate set.
3034 ExtendedOperationalRatesLength = 0;
3035
3036 // populate proprietary rates if user allows them
3037 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3038 {
3039 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3040 sizeof(*DefaultSupportedPropRates.propRate);
3041 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates,
3042 DefaultSupportedPropRates.propRate,
3043 ProprietaryOperationalRatesLength );
3044 }
3045 else
3046 {
3047 // No proprietary modes
3048 ProprietaryOperationalRatesLength = 0;
3049 }
3050 }
3051 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3052 {
3053 // 11b rates into the Operational Rate Set.
3054 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3055 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
3056 palCopyMemory( pMac->hHdd, OperationalRates,
3057 DefaultSupportedRates11b.supportedRateSet.rate,
3058 OperationalRatesLength );
3059 // Nothing in the Extended rate set.
3060 ExtendedOperationalRatesLength = 0;
3061 // No proprietary modes
3062 ProprietaryOperationalRatesLength = 0;
3063 }
3064 else
3065 {
3066 // 11G
3067
3068 // 11b rates into the Operational Rate Set.
3069 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3070 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
3071 palCopyMemory( pMac->hHdd, OperationalRates,
3072 DefaultSupportedRates11b.supportedRateSet.rate,
3073 OperationalRatesLength );
3074
3075 // 11a rates go in the Extended rate set.
3076 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3077 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
3078 palCopyMemory( pMac->hHdd, ExtendedOperationalRates,
3079 DefaultSupportedRates11a.supportedRateSet.rate,
3080 ExtendedOperationalRatesLength );
3081
3082 // populate proprietary rates if user allows them
3083 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3084 {
3085 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3086 sizeof(*DefaultSupportedPropRates.propRate);
3087 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates,
3088 DefaultSupportedPropRates.propRate,
3089 ProprietaryOperationalRatesLength );
3090 }
3091 else
3092 {
3093 // No proprietary modes
3094 ProprietaryOperationalRatesLength = 0;
3095 }
3096 }
3097
3098 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3099 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3100 {
3101 PropRatesEnable = 1;
3102 }
3103 else
3104 {
3105 PropRatesEnable = 0;
3106 }
3107
3108 // Set the operational rate set CFG variables...
3109 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3110 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3111 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3112 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3113 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3114 ProprietaryOperationalRates,
3115 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3116 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3117
3118}
3119
3120void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3121{
3122 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
3123 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3124 tANI_U32 sessionId;
3125 tSmeCmd *pCommand = NULL;
3126
3127 if(NULL == pEntry)
3128 {
3129 smsLog(pMac, LOGW, " CFG_CNF with active list empty\n");
3130 return;
3131 }
3132 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3133 sessionId = pCommand->sessionId;
3134
3135 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3136 {
3137 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3138 }
3139}
3140
3141
3142//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3143tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3144{
3145 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3146 {
3147 return (WNI_CFG_PHY_MODE_11B);
3148 }
3149 else
3150 {
3151 if(eCSR_BAND_24 == band)
3152 return (WNI_CFG_PHY_MODE_11G);
3153 }
3154
3155 return (WNI_CFG_PHY_MODE_11A);
3156}
3157
3158
3159//pIes may be NULL
3160eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3161 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
3162 tDot11fBeaconIEs *pIes)
3163{
3164 eHalStatus status = eHAL_STATUS_SUCCESS;
3165 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3166 tANI_U8 channel = 0;
3167 //Make sure we have the domain info for the BSS we try to connect to.
3168 //Do we need to worry about sequence for OSs that are not Windows??
3169 if(pBssDesc)
3170 {
3171 if(csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
3172 {
3173 //Make sure the 11d info from this BSSDesc can be applied
3174 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
3175 csrApplyCountryInformation( pMac, TRUE );
3176 }
3177 }
3178
3179 //Qos
3180 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3181 //SSID
3182 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3183 //fragment threshold
3184 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3185 //RTS threshold
3186 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3187
3188 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
3189
3190 //Auth type
3191 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
3192 //encryption type
3193 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
3194 //short slot time
3195 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
3196
3197#ifdef WLAN_SOFTAP_FEATURE
3198 //11d
3199 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
3200 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
3201 NULL, eANI_BOOLEAN_FALSE);
3202#endif
3203 /*//11h
3204 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
3205 */
3206 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
3207 //CB
3208 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile))
3209 {
3210 channel = pProfile->operationChannel;
3211 }
3212 else
3213 {
3214 if(pBssDesc)
3215 {
3216 channel = pBssDesc->channelId;
3217 }
3218 }
3219 if(0 != channel)
3220 {
3221 if(CSR_IS_CHANNEL_24GHZ(channel))
3222 {//for now if we are on 2.4 Ghz, CB will be always disabled
3223 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3224 }
3225 else
3226 {
3227 //cfgCb = pBssConfig->cbMode;
3228 cfgCb = pMac->roam.configParam.channelBondingMode5GHz;
3229 }
3230 }
3231 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
3232 //Rate
3233 //Fixed Rate
3234 if(pBssDesc)
3235 {
3236 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
3237 }
3238 else
3239 {
3240 csrSetCfgRateSetFromProfile(pMac, pProfile);
3241 }
3242 //Make this the last CFG to set. The callback will trigger a join_req
3243 //Join time out
3244 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
3245
3246 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
3247
3248 return (status);
3249}
3250
3251
3252
3253eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3254 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3255{
3256 eHalStatus status;
3257 tBssConfigParam *pBssConfig;
3258 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3259
3260 status = palAllocateMemory(pMac->hHdd, (void **)&pBssConfig, sizeof(tBssConfigParam));
3261 if(HAL_STATUS_SUCCESS(status))
3262 {
3263 palZeroMemory(pMac->hHdd, pBssConfig, sizeof(tBssConfigParam));
3264 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
3265 if(HAL_STATUS_SUCCESS(status))
3266 {
3267 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
3268 //For IBSS, we need to prepare some more information
3269 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
3270#ifdef WLAN_SOFTAP_FEATURE
3271 || CSR_IS_INFRA_AP(pProfile)
3272#endif
3273 )
3274 {
3275 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pIes);
3276 }
3277 // If we are in an IBSS, then stop the IBSS...
3278 ////Not worry about WDS connection for now
3279 if ( csrIsConnStateIbss( pMac, sessionId ) )
3280 {
3281 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
3282 }
3283 else
3284 {
3285 // if we are in an Infrastructure association....
3286 if ( csrIsConnStateInfra( pMac, sessionId ) )
3287 {
3288 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
3289 // across SSIDs (roaming to a new SSID)... //
3290 //Not worry about WDS connection for now
3291 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
3292 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
3293 {
3294 // then we need to disassociate from the Infrastructure network...
3295 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
3296 }
3297 else
3298 {
3299 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
3300 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
3301 if ( pBssDesc )
3302 {
3303 // Set parameters for this Bss.
3304 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
3305 }
3306 }
3307 }
3308 else
3309 {
3310 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
3311 // Nothing to stop.
3312 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
3313#ifdef WLAN_SOFTAP_FEATURE
3314 || CSR_IS_INFRA_AP(pProfile)
3315#endif
3316 )
3317 {
3318 // Set parameters for this Bss.
3319 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
3320 }
3321 }
3322 }
3323 }//Success getting BSS config info
3324 palFreeMemory(pMac->hHdd, pBssConfig);
3325 }//Allocate memory
3326
3327 return (status);
3328}
3329
3330
3331eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
3332 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
3333{
3334 eCsrJoinState eRoamState = eCsrContinueRoaming;
3335 eHalStatus status;
3336 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
3337 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
3338 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3339
3340 if( CSR_IS_WDS_STA( pProfile ) )
3341 {
3342 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
3343 if( !HAL_STATUS_SUCCESS( status ) )
3344 {
3345 eRoamState = eCsrStopRoaming;
3346 }
3347 }
3348 else
3349 {
3350 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
3351 {
3352 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
3353 return (eCsrStopRoaming);
3354 }
3355 if ( csrIsInfraBssDesc( pBssDesc ) )
3356 {
3357 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
3358 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
3359 // have changed and handle the changes (without disturbing the current association).
3360
3361 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
3362 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
3363 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
3364 )
3365 {
3366 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
3367 // with Authenticating first. To force this, stop the current association (Disassociate) and
3368 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
3369 // a new Association.
3370 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
3371 {
3372 smsLog(pMac, LOGW, FL(" detect same profile authType = %d encryType = %d\n"), pProfile->AuthType, pProfile->EncryptionType);
3373 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
3374 {
3375 eRoamState = eCsrReassocToSelfNoCapChange;
3376 }
3377 else
3378 {
3379 tBssConfigParam bssConfig;
3380
3381 //The key changes
3382 palZeroMemory(pMac->hHdd, &bssConfig, sizeof(bssConfig));
3383 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
3384 if(HAL_STATUS_SUCCESS(status))
3385 {
3386 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
3387 //Reapply the config including Keys so reassoc is happening.
3388 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, pBssDesc, &bssConfig, pIesLocal);
3389 if(!HAL_STATUS_SUCCESS(status))
3390 {
3391 eRoamState = eCsrStopRoaming;
3392 }
3393 }
3394 else
3395 {
3396 eRoamState = eCsrStopRoaming;
3397 }
3398 }//same profile
3399 }
3400 else
3401 {
3402 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
3403 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
3404 {
3405 smsLog(pMac, LOGW, FL(" fail to issue disassociate\n"));
3406 eRoamState = eCsrStopRoaming;
3407 }
3408 }
3409 }
3410 else
3411 {
3412 // note: we used to pre-auth here with open authentication networks but that was not working so well.
3413 // we had a lot of join timeouts when testing at Samsung. removing this step helped associations
3414 // work much better.
3415 //
3416 //
3417 // stop the existing network before attempting to join the new network...
3418 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
3419 {
3420 eRoamState = eCsrStopRoaming;
3421 }
3422 }
3423 }//Infra
3424 else
3425 {
3426 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
3427 {
3428 eRoamState = eCsrStopRoaming;
3429 }
3430 }
3431 if( pIesLocal && !pScanResult->pvIes )
3432 {
3433 palFreeMemory(pMac->hHdd, pIesLocal);
3434 }
3435 }
3436
3437 return( eRoamState );
3438}
3439
3440
3441eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
3442 tSirBssDescription *pBssDesc, tANI_U32 roamId)
3443{
3444 eHalStatus status = eHAL_STATUS_SUCCESS;
3445 tCsrRoamInfo roamInfo;
3446
3447 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
3448 roamInfo.pBssDesc = pBssDesc;
3449 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
3450 return (status);
3451}
3452
3453//In case no matching BSS is found, use whatever default we can find
3454static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
3455{
3456 //Need to get all negotiated types in place first
3457 //auth type
3458 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the prefered Auth type.
3459 {
3460 default:
3461 case eCSR_AUTH_TYPE_WPA:
3462 case eCSR_AUTH_TYPE_WPA_PSK:
3463 case eCSR_AUTH_TYPE_WPA_NONE:
3464 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3465 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3466 break;
3467
3468 case eCSR_AUTH_TYPE_SHARED_KEY:
3469 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
3470 break;
3471
3472 case eCSR_AUTH_TYPE_AUTOSWITCH:
3473 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
3474 break;
3475 }
3476 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
3477 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
3478 //In this case, the multicast encryption needs to follow the uncast ones.
3479 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
3480 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
3481}
3482
3483static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
3484{
3485 eHalStatus status;
3486 tCsrScanResult *pScanResult = NULL;
3487 eCsrJoinState eRoamState = eCsrStopRoaming;
3488 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
3489 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
3490 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
3491#ifndef WLAN_MDM_CODE_REDUCTION_OPT
3492 v_U8_t acm_mask = 0;
3493#endif
3494 tANI_U32 sessionId = pCommand->sessionId;
3495 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3496 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
3497 tANI_U8 concurrentChannel = 0;
3498
3499 do
3500 {
3501 // Check for Cardbus eject condition, before trying to Roam to any BSS
3502 //***if( !balIsCardPresent(pAdapter) ) break;
3503
3504 if(NULL != pBSSList)
3505 {
3506 // When handling AP's capability change, continue to associate to
3507 // same BSS and make sure pRoamBssEntry is not Null.
3508 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
3509 {
3510 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
3511 {
3512 //Try the first BSS
3513 pCommand->u.roamCmd.pLastRoamBss = NULL;
3514 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
3515 }
3516 else
3517 {
3518 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
3519 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
3520 {
3521 //Done with all the BSSs
3522 //In this case, will tell HDD the completion
3523 break;
3524 }
3525 else
3526 {
3527 //We need to indicate to HDD that we are done with this one.
3528 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
3529 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
3530 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
3531 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
3532 pRoamInfo = &roamInfo;
3533 }
3534 }
3535 while(pCommand->u.roamCmd.pRoamBssEntry)
3536 {
3537 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
3538
3539 /*If concurrency enabled take the concurrent connected channel first. */
3540 /* Valid multichannel concurrent sessions exempted */
3541 if (vos_concurrent_sessions_running() && !csrIsValidMcConcurrentSession(pMac, sessionId))
3542 {
3543 concurrentChannel =
3544 csrGetConcurrentOperationChannel(pMac);
3545 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
3546 " csr Concurrent Channel = %d", __FUNCTION__, concurrentChannel);
3547
3548 if ((concurrentChannel) &&
3549 (concurrentChannel ==
3550 pScanResult->Result.BssDescriptor.channelId))
3551 {
3552 //make this 0 because we do not want the
3553 //below check to pass as we don't want to
3554 //connect on other channel
3555 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
3556 FL("Concurrent channel match =%d"),
3557 concurrentChannel);
3558 concurrentChannel = 0;
3559
3560 }
3561 }
3562 if ((vos_concurrent_sessions_running()) &&
3563 csrIsAnySessionInConnectState( pMac ))
3564 {
3565 pMac->roam.configParam.concurrencyEnabled = 1;
3566 }
3567
3568 if (!concurrentChannel)
3569 {
3570
3571 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
3572 sessionId, &pScanResult->Result.BssDescriptor,
3573 pCommand->u.roamCmd.roamId)))
3574 {
3575 //Ok to roam this
3576 break;
3577 }
3578 }
3579 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
3580 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
3581 {
3582 //Done with all the BSSs
3583 fDone = eANI_BOOLEAN_TRUE;
3584 break;
3585 }
3586 }
3587 if(fDone)
3588 {
3589 break;
3590 }
3591 }
3592 }
3593 //We have something to roam, tell HDD when it is infra.
3594 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
3595 //For WDS, the indication is eCSR_ROAM_WDS_IND
3596 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
3597 {
3598 if(pRoamInfo)
3599 {
3600 pSession->bRefAssocStartCnt--;
3601 //Complete the last association attemp because a new one is about to be tried
3602 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
3603 eCSR_ROAM_ASSOCIATION_COMPLETION,
3604 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
3605 }
3606 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
3607 if(pScanResult)
3608 {
3609 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
3610
3611 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
3612 {
3613 smsLog(pMac, LOGE, FL(" cannot parse IEs\n"));
3614 fDone = eANI_BOOLEAN_TRUE;
3615 eRoamState = eCsrStopRoaming;
3616 break;
3617 }
3618 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
3619 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
3620 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
3621 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
3622 CSR_IS_QOS_BSS(pIesLocal) &&
3623 CSR_IS_UAPSD_BSS(pIesLocal) )
3624 {
3625#ifndef WLAN_MDM_CODE_REDUCTION_OPT
3626
3627 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
3628 pIesLocal);
3629 pCommand->u.roamCmd.roamProfile.uapsd_mask &= ~(acm_mask);
3630#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
3631
3632 }
3633 else
3634 {
3635 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
3636 }
3637 if( pIesLocal && !pScanResult->Result.pvIes)
3638 {
3639 palFreeMemory(pMac->hHdd, pIesLocal);
3640 }
3641 }
3642 else
3643 {
3644 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
3645 }
3646 roamInfo.pProfile = pProfile;
3647 pSession->bRefAssocStartCnt++;
3648 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
3649 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
3650 }
3651
3652 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
3653 {
3654 // If this is a start IBSS profile, then we need to start the IBSS.
3655 if ( CSR_IS_START_IBSS(pProfile) )
3656 {
3657 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
3658
3659 // Attempt to start this IBSS...
3660 csrRoamAssignDefaultParam( pMac, pCommand );
3661 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
3662 if(HAL_STATUS_SUCCESS(status))
3663 {
3664 if ( fSameIbss )
3665 {
3666 eRoamState = eCsrStartIbssSameIbss;
3667 }
3668 else
3669 {
3670 eRoamState = eCsrContinueRoaming;
3671 }
3672 }
3673 else
3674 {
3675 //it somehow fail need to stop
3676 eRoamState = eCsrStopRoaming;
3677 }
3678 break;
3679 }
3680 else if ( (CSR_IS_WDS_AP(pProfile))
3681#ifdef WLAN_SOFTAP_FEATURE
3682 || (CSR_IS_INFRA_AP(pProfile))
3683#endif
3684 )
3685 {
3686 // Attempt to start this WDS...
3687 csrRoamAssignDefaultParam( pMac, pCommand );
3688 /* For AP WDS, we dont have any BSSDescription */
3689 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
3690 if(HAL_STATUS_SUCCESS(status))
3691 {
3692 eRoamState = eCsrContinueRoaming;
3693 }
3694 else
3695 {
3696 //it somehow fail need to stop
3697 eRoamState = eCsrStopRoaming;
3698 }
3699 }
3700 else
3701 {
3702 //Nothing we can do
3703 smsLog(pMac, LOGW, FL("cannot continue without BSS list\n"));
3704 eRoamState = eCsrStopRoaming;
3705 break;
3706 }
3707 }
3708 else //We have BSS
3709 {
3710 //Need to assign these value because they are used in csrIsSameProfile
3711 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
3712 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType = pScanResult->ucEncryptionType; //Negotiated while building scan result.
3713 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType = pScanResult->mcEncryptionType;
3714 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
3715 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
3716 {
3717 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
3718 {
3719 eRoamState = eCsrStartIbssSameIbss;
3720 break;
3721 }
3722 }
3723 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
3724 {
3725 //trying to connect to the one already connected
3726 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
3727 eRoamState = eCsrReassocToSelfNoCapChange;
3728 break;
3729 }
3730 // Attempt to Join this Bss...
3731 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
3732 break;
3733 }
3734
3735 } while( 0 );
3736
3737 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
3738 {
3739 //Need to indicate association_completion if association_start has been done
3740 if(pSession->bRefAssocStartCnt > 0)
3741 {
3742 pSession->bRefAssocStartCnt--;
3743 //Complete the last association attemp because a new one is about to be tried
3744 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
3745 eCSR_ROAM_ASSOCIATION_COMPLETION,
3746 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
3747 }
3748 }
3749
3750 return( eRoamState );
3751}
3752
3753
3754static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
3755{
3756 eHalStatus status = eHAL_STATUS_SUCCESS;
3757 eCsrJoinState RoamState;
3758 tANI_U32 sessionId = pCommand->sessionId;
3759
3760 smsLog(pMac, LOG2, FL("is called\n"));
3761 //***if( hddIsRadioStateOn( pAdapter ) )
3762 {
3763 // Attept to join a Bss...
3764 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
3765
3766 // if nothing to join..
3767 if ( eCsrStopRoaming == RoamState )
3768 {
3769 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
3770
3771 // and if connected in Infrastructure mode...
3772 if ( csrIsConnStateInfra(pMac, sessionId) )
3773 {
3774 //... then we need to issue a disassociation
3775 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
3776 if(!HAL_STATUS_SUCCESS(status))
3777 {
3778 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d\n"), status);
3779 //roam command is completed by caller in the failed case
3780 fComplete = eANI_BOOLEAN_TRUE;
3781 }
3782 }
3783 else if( csrIsConnStateIbss(pMac, sessionId) )
3784 {
3785 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
3786 if(!HAL_STATUS_SUCCESS(status))
3787 {
3788 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d\n"), status);
3789 //roam command is completed by caller in the failed case
3790 fComplete = eANI_BOOLEAN_TRUE;
3791 }
3792 }
3793#ifdef WLAN_SOFTAP_FEATURE
3794 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
3795 {
3796 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
3797 if(!HAL_STATUS_SUCCESS(status))
3798 {
3799 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d\n"), status);
3800 //roam command is completed by caller in the failed case
3801 fComplete = eANI_BOOLEAN_TRUE;
3802 }
3803 }
3804#endif
3805 else
3806 {
3807 fComplete = eANI_BOOLEAN_TRUE;
3808 }
3809 if(fComplete)
3810 {
3811 // ... otherwise, we can complete the Roam command here.
3812 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
3813 }
3814 }
3815 else if ( eCsrReassocToSelfNoCapChange == RoamState )
3816 {
3817 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
3818 }
3819 else if ( eCsrStartIbssSameIbss == RoamState )
3820 {
3821 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
3822 }
3823 }//hddIsRadioStateOn
3824
3825 return status;
3826}
3827
3828eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
3829{
3830 tANI_U32 sessionId;
3831 tCsrRoamSession *pSession;
3832 tCsrScanResult *pScanResult = NULL;
3833 tSirBssDescription *pBssDesc = NULL;
3834 eHalStatus status = eHAL_STATUS_SUCCESS;
3835
3836 sessionId = pCommand->sessionId;
3837 pSession = CSR_GET_SESSION( pMac, sessionId );
3838
3839 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
3840 {
3841 //the roaming is cancelled. Simply complete the command
3842 smsLog(pMac, LOG1, FL(" Roam command cancelled\n"));
3843 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
3844 return eHAL_STATUS_FAILURE;
3845 }
3846
3847 if (pCommand->u.roamCmd.pRoamBssEntry)
3848 {
3849 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
3850 pBssDesc = &pScanResult->Result.BssDescriptor;
3851 }
3852 else
3853 {
3854 //the roaming is cancelled. Simply complete the command
3855 smsLog(pMac, LOG1, FL(" Roam command cancelled\n"));
3856 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
3857 return eHAL_STATUS_FAILURE;
3858 }
3859
3860 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
3861 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
3862 return status;
3863}
3864
3865
3866eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
3867{
3868 eHalStatus status = eHAL_STATUS_SUCCESS;
3869 tCsrRoamInfo roamInfo;
3870 tANI_U32 sessionId = pCommand->sessionId;
3871 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3872
3873 switch ( pCommand->u.roamCmd.roamReason )
3874 {
3875 case eCsrForcedDisassoc:
3876 csrFreeRoamProfile(pMac, sessionId);
3877 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
3878 break;
3879
3880 case eCsrSmeIssuedDisassocForHandoff:
3881 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
3882#if 0 // TODO : Confirm this change
3883 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
3884#else
3885 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
3886#endif
3887
3888 break;
3889
3890 case eCsrForcedDisassocMICFailure:
3891 csrFreeRoamProfile(pMac, sessionId);
3892 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
3893 break;
3894
3895 case eCsrForcedDeauth:
3896 csrFreeRoamProfile(pMac, sessionId);
3897 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
3898 break;
3899
3900 case eCsrHddIssuedReassocToSameAP:
3901 case eCsrSmeIssuedReassocToSameAP:
3902 {
3903 tDot11fBeaconIEs *pIes = NULL;
3904
3905
3906 if( pSession->pConnectBssDesc )
3907 {
3908 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
3909 if(!HAL_STATUS_SUCCESS(status) )
3910 {
3911 smsLog(pMac, LOGE, FL(" fail to parse IEs\n"));
3912 }
3913 else
3914 {
3915 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
3916 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
3917 pSession->roamingReason = eCsrReassocRoaming;
3918
3919 roamInfo.pBssDesc = pSession->pConnectBssDesc;
3920 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
3921 pSession->bRefAssocStartCnt++;
3922 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
3923 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
3924
3925 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate\n"));
3926 csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
3927 &pCommand->u.roamCmd.roamProfile );
3928 palFreeMemory(pMac->hHdd, pIes);
3929 pIes = NULL;
3930 }
3931 }
3932 break;
3933 }
3934
3935 case eCsrCapsChange:
3936 smsLog(pMac, LOGE, FL("received eCsrCapsChange \n"));
3937 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
3938 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
3939 break;
3940
3941 case eCsrSmeIssuedFTReassoc:
3942 smsLog(pMac, LOGE, FL("received FT Reassoc Req \n"));
3943 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
3944 break;
3945 case eCsrStopBss:
3946 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
3947 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
3948 break;
3949
3950 case eCsrForcedDisassocSta:
3951 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
3952 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
3953 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
3954 pCommand->u.roamCmd.reason);
3955 break;
3956
3957 case eCsrForcedDeauthSta:
3958 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
3959 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
3960 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
3961 pCommand->u.roamCmd.reason);
3962 break;
3963
3964 default:
3965 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
3966
3967 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
3968 {
3969 //Remember the roaming profile
3970 csrFreeRoamProfile(pMac, sessionId);
3971 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pSession->pCurRoamProfile, sizeof(tCsrRoamProfile))))
3972 {
3973 palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile));
3974 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
3975 }
3976 }
3977
3978 //At this point, original uapsd_mask is saved in pCurRoamProfile
3979 //uapsd_mask in the pCommand may change from this point on.
3980
3981 // Attempt to roam with the new scan results (if we need to..)
3982 status = csrRoam( pMac, pCommand );
3983 break;
3984 }
3985
3986 return (status);
3987}
3988
3989
3990void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
3991{
3992 if(pCommand->u.roamCmd.fReleaseBssList)
3993 {
3994 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
3995 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
3996 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
3997 }
3998 if(pCommand->u.roamCmd.fReleaseProfile)
3999 {
4000 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4001 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4002 }
4003 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4004 //Because u.roamCmd is union and share with scanCmd and StatusChange
4005 palZeroMemory(pMac->hHdd, &pCommand->u.roamCmd, sizeof(tRoamCmd));
4006}
4007
4008
4009void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4010{
4011 palZeroMemory(pMac->hHdd, &pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd));
4012}
4013
4014void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4015{
4016 tListElem *pEntry;
4017 tSmeCmd *pCommand;
4018 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
4019
4020 smsLog( pMac, LOG2, "roamQ: Roam Completion ...\n" );
4021
4022 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4023 if ( pEntry )
4024 {
4025 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
4026
4027 // If the head of the queue is Active and it is a ROAM command, remove
4028 // and put this on the Free queue.
4029 if ( eSmeCommandRoam == pCommand->command )
4030 {
4031 //we need to process the result first before removing it from active list because state changes
4032 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4033 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4034 if( fReleaseCommand )
4035 {
4036 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4037 {
4038 csrReleaseCommandRoam( pMac, pCommand );
4039 }
4040 else
4041 {
4042 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d\n",
4043 pCommand->u.roamCmd.roamReason );
4044 }
4045 }
4046 else
4047 {
4048 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d\n",
4049 pCommand->u.roamCmd.roamReason );
4050 }
4051 }
4052 else
4053 {
4054 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ...\n" );
4055 }
4056 }
4057 else
4058 {
4059 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ...\n" );
4060 }
4061
4062 if( fReleaseCommand )
4063 {
4064 smeProcessPendingQueue( pMac );
4065 }
4066}
4067
4068
4069void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4070{
4071 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4072
4073 palZeroMemory( pMac->hHdd, &(pSession->PmkidCandidateInfo[0]), sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED );
4074 pSession->NumPmkidCandidate = 0;
4075}
4076
4077#ifdef FEATURE_WLAN_WAPI
4078void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4079{
4080 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4081 palZeroMemory( pMac->hHdd, &(pSession->BkidCandidateInfo[0]), sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED );
4082 pSession->NumBkidCandidate = 0;
4083}
4084#endif /* FEATURE_WLAN_WAPI */
4085
4086extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4087
4088
4089
4090static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4091 tSirBssDescription *pSirBssDesc,
4092 tDot11fBeaconIEs *pIes)
4093{
4094 eHalStatus status = eHAL_STATUS_SUCCESS;
4095 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4096 tDot11fBeaconIEs *pIesLocal = pIes;
4097
4098 if((eCSR_AUTH_TYPE_WPA == authType) ||
4099 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
4100 (eCSR_AUTH_TYPE_RSN == authType) ||
4101 (eCSR_AUTH_TYPE_RSN_PSK == authType)
4102#if defined WLAN_FEATURE_VOWIFI_11R
4103 ||
4104 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4105 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
4106#endif /* FEATURE_WLAN_WAPI */
4107#ifdef FEATURE_WLAN_WAPI
4108 ||
4109 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4110 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
4111#endif /* FEATURE_WLAN_WAPI */
4112 )
4113 {
4114
4115 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4116 {
4117 smsLog(pMac, LOGE, FL(" cannot parse IEs\n"));
4118 }
4119 if( pIesLocal )
4120 {
4121 tANI_U32 nIeLen;
4122 tANI_U8 *pIeBuf;
4123
4124 if((eCSR_AUTH_TYPE_RSN == authType) ||
4125#if defined WLAN_FEATURE_VOWIFI_11R
4126 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4127 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
4128#endif /* WLAN_FEATURE_VOWIFI_11R */
4129 (eCSR_AUTH_TYPE_RSN_PSK == authType))
4130 {
4131 if(pIesLocal->RSN.present)
4132 {
4133 //Calculate the actual length
4134 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
4135 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
4136 + 2 //akm_suite_count
4137 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
4138 + 2; //reserved
4139 if( pIesLocal->RSN.pmkid_count )
4140 {
4141 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
4142 }
4143 //nIeLen doesn't count EID and length fields
4144 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnRspIE, nIeLen + 2))))
4145 {
4146 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
4147 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4148 //copy upto akm_suites
4149 pIeBuf = pSession->pWpaRsnRspIE + 2;
4150 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.version, 8);
4151 pIeBuf += 8;
4152 if( pIesLocal->RSN.pwise_cipher_suite_count )
4153 {
4154 //copy pwise_cipher_suites
4155 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.pwise_cipher_suites,
4156 pIesLocal->RSN.pwise_cipher_suite_count * 4);
4157 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
4158 }
4159 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
4160 pIeBuf += 2;
4161 if( pIesLocal->RSN.akm_suite_count )
4162 {
4163 //copy akm_suites
4164 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.akm_suites,
4165 pIesLocal->RSN.akm_suite_count * 4);
4166 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
4167 }
4168 //copy the rest
4169 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.akm_suites +
4170 pIesLocal->RSN.akm_suite_count * 4,
4171 2 + pIesLocal->RSN.pmkid_count * 4);
4172 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4173 }
4174 }
4175 }
4176 else if((eCSR_AUTH_TYPE_WPA == authType) ||
4177 (eCSR_AUTH_TYPE_WPA_PSK == authType))
4178 {
4179 if(pIesLocal->WPA.present)
4180 {
4181 //Calculate the actual length
4182 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
4183 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
4184 + 2 //auth_suite_count
4185 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
4186 // The WPA capabilities follows the Auth Suite (two octects)--
4187 // this field is optional, and we always "send" zero, so just
4188 // remove it. This is consistent with our assumptions in the
4189 // frames compiler; c.f. bug 15234:
4190 //nIeLen doesn't count EID and length fields
4191 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnRspIE, nIeLen + 2))))
4192 {
4193 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
4194 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4195 pIeBuf = pSession->pWpaRsnRspIE + 2;
4196 //Copy WPA OUI
4197 palCopyMemory(pMac->hHdd, pIeBuf, &csrWpaOui[1], 4);
4198 pIeBuf += 4;
4199 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WPA.version, 8 +
4200 pIesLocal->WPA.unicast_cipher_count * 4);
4201 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
4202 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WPA.auth_suite_count, 2 +
4203 pIesLocal->WPA.auth_suite_count * 4);
4204 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
4205 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4206 }
4207 }
4208 }
4209#ifdef FEATURE_WLAN_WAPI
4210 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4211 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
4212 {
4213 if(pIesLocal->WAPI.present)
4214 {
4215 //Calculate the actual length
4216 nIeLen = 4 //version + akm_suite_count
4217 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
4218 + 2 //pwise_cipher_suite_count
4219 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
4220 + 6; //gp_cipher_suite + preauth + reserved
4221 if( pIesLocal->WAPI.bkid_count )
4222 {
4223 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
4224 }
4225
4226 //nIeLen doesn't count EID and length fields
4227 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWapiRspIE, nIeLen + 2))))
4228 {
4229 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
4230 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
4231 pIeBuf = pSession->pWapiRspIE + 2;
4232 //copy upto akm_suite_count
4233 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.version, 4);
4234 pIeBuf += 4;
4235 if( pIesLocal->WAPI.akm_suite_count )
4236 {
4237 //copy akm_suites
4238 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.akm_suites,
4239 pIesLocal->WAPI.akm_suite_count * 4);
4240 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
4241 }
4242 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.unicast_cipher_suite_count, 2);
4243 pIeBuf += 2;
4244
4245 if( pIesLocal->WAPI.unicast_cipher_suite_count )
4246 {
4247 //copy pwise_cipher_suites
4248 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.unicast_cipher_suites,
4249 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
4250 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
4251 }
4252 //gp_cipher_suite + preauth + reserved + bkid_count
4253 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.multicast_cipher_suite, 8);
4254 pIeBuf += 8;
4255 if( pIesLocal->WAPI.bkid_count )
4256 {
4257 //copy akm_suites
4258 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.bkid, pIesLocal->WAPI.bkid_count * 4);
4259 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
4260 }
4261 pSession->nWapiRspIeLength = nIeLen + 2;
4262 }
4263
4264 }
4265 }
4266#endif /* FEATURE_WLAN_WAPI */
4267 if( !pIes )
4268 {
4269 //locally allocated
4270 palFreeMemory(pMac->hHdd, pIesLocal);
4271 }
4272 }
4273 }
4274
4275 return (status);
4276}
4277
4278
4279
4280static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
4281{
4282 v_U8_t bACWeights[WLANTL_MAX_AC];
4283 v_U8_t paramBk, paramBe, paramVi, paramVo;
4284 v_BOOL_t fWeightChange = VOS_FALSE;
4285
4286 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
4287 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
4288 //of the higher AC one, make the higher AC has the same weight as the lower AC.
4289 //This doesn't address the case where the lower AC needs a real higher weight
4290 if( pIEs->WMMParams.present )
4291 {
4292 //no change to the lowest ones
4293 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
4294 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
4295 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
4296 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
4297 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
4298 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
4299 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
4300 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
4301 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
4302 {
4303 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
4304 fWeightChange = VOS_TRUE;
4305 }
4306 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
4307 {
4308 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
4309 fWeightChange = VOS_TRUE;
4310 }
4311 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
4312 {
4313 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
4314 fWeightChange = VOS_TRUE;
4315 }
4316 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
4317 {
4318 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
4319 fWeightChange = VOS_TRUE;
4320 }
4321 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
4322 {
4323 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
4324 fWeightChange = VOS_TRUE;
4325 }
4326 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
4327 {
4328 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
4329 fWeightChange = VOS_TRUE;
4330 }
4331 if(fWeightChange)
4332 {
4333 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)\n"), bACWeights[0], bACWeights[1],
4334 bACWeights[2], bACWeights[3]);
4335 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
4336 }
4337 }
4338}
4339
4340#ifdef WLAN_FEATURE_VOWIFI_11R
4341//Returns whether the current association is a 11r assoc or not
4342tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
4343{
4344#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
4345 return csrNeighborRoamIs11rAssoc(pMac);
4346#else
4347 return eANI_BOOLEAN_FALSE;
4348#endif
4349}
4350#endif
4351
4352#ifdef FEATURE_WLAN_CCX
4353//Returns whether the current association is a CCX assoc or not
4354tANI_BOOLEAN csrRoamIsCCXAssoc(tpAniSirGlobal pMac)
4355{
4356#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
4357 return csrNeighborRoamIsCCXAssoc(pMac);
4358#else
4359 return eANI_BOOLEAN_FALSE;
4360#endif
4361}
4362#endif
4363
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004364#ifdef FEATURE_WLAN_LFR
4365//Returns whether "Legacy Fast Roaming" is currently enabled...or not
4366tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac)
4367{
4368 return pMac->roam.configParam.isFastRoamIniFeatureEnabled;
4369}
4370#endif
4371
Jeff Johnson295189b2012-06-20 16:38:30 -07004372//Return true means the command can be release, else not
4373static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
4374 eCsrRoamCompleteResult Result, void *Context )
4375{
4376 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
4377 tSirBssDescription *pSirBssDesc = NULL;
4378 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
4379 tCsrScanResult *pScanResult = NULL;
4380 tCsrRoamInfo roamInfo;
4381 sme_QosAssocInfo assocInfo;
4382 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
4383 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
4384 tDot11fBeaconIEs *pIes = NULL;
4385 tANI_U32 sessionId = pCommand->sessionId;
4386 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4387 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4388 eRoamCmdStatus roamStatus;
4389 eCsrRoamResult roamResult;
4390 eHalStatus status;
4391 tANI_U32 key_timeout_interval = 0;
4392#ifdef WLAN_SOFTAP_FEATURE
4393 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
4394#endif
4395
4396
4397 smsLog( pMac, LOG1, FL("Processing ROAM results...\n"));
4398
4399 switch( Result )
4400 {
4401 case eCsrJoinSuccess:
4402 // reset the IDLE timer
4403 // !!
4404 // !! fall through to the next CASE statement here is intentional !!
4405 // !!
4406 case eCsrReassocSuccess:
4407 if(eCsrReassocSuccess == Result)
4408 {
4409 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
4410 }
4411 else
4412 {
4413 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
4414 }
4415 // Success Join Response from LIM. Tell NDIS we are connected and save the
4416 // Connected state...
4417 smsLog(pMac, LOGW, FL("receives association indication\n"));
4418 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
4419 //always free the memory here
4420 if(pSession->pWpaRsnRspIE)
4421 {
4422 pSession->nWpaRsnRspIeLength = 0;
4423 palFreeMemory(pMac->hHdd, pSession->pWpaRsnRspIE);
4424 pSession->pWpaRsnRspIE = NULL;
4425 }
4426
4427#ifdef FEATURE_WLAN_WAPI
4428 if(pSession->pWapiRspIE)
4429 {
4430 pSession->nWapiRspIeLength = 0;
4431 palFreeMemory(pMac->hHdd, pSession->pWapiRspIE);
4432 pSession->pWapiRspIE = NULL;
4433 }
4434#endif /* FEATURE_WLAN_WAPI */
4435#ifdef FEATURE_WLAN_BTAMP_UT_RF
4436 //Reset counter so no join retry is needed.
4437 pSession->maxRetryCount = 0;
4438 csrRoamStopJoinRetryTimer(pMac, sessionId);
4439#endif
4440 /* This creates problem since we have not saved the connected profile.
4441 So moving this after saving the profile
4442 */
4443 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
4444 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4445 {
4446 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
4447 }
4448 else
4449 {
4450 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
4451 }
4452
4453 //Use the last connected bssdesc for reassoc-ing to the same AP.
4454 //NOTE: What to do when reassoc to a different AP???
4455 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
4456 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
4457 {
4458 pSirBssDesc = pSession->pConnectBssDesc;
4459 if(pSirBssDesc)
4460 {
4461 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
4462 }
4463 }
4464 else
4465 {
4466
4467 if(pCommand->u.roamCmd.pRoamBssEntry)
4468 {
4469 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4470 if(pScanResult != NULL)
4471 {
4472 pSirBssDesc = &pScanResult->Result.BssDescriptor;
4473 //this can be NULL
4474 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
4475 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
4476 }
4477 }
4478 }
4479 if( pSirBssDesc )
4480 {
4481
4482 roamInfo.staId = HAL_STA_INVALID_IDX;
4483
4484 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
4485 //Save WPA/RSN IE
4486 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
4487#ifdef FEATURE_WLAN_CCX
4488 roamInfo.isCCXAssoc = pSession->connectedProfile.isCCXAssoc;
4489#endif
4490
4491 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
4492 // substate change.
4493 // Moving even save profile above so that below mentioned conditon is also met.
4494 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
4495 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
4496
4497 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
4498 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
4499 // will be dropped for the security context may not be set properly.
4500 //
4501 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
4502 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
4503 //
4504 // this reordering was done on titan_prod_usb branch and is being replicated here.
4505 //
4506
4507 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
4508 !pProfile->bWPSAssociation)
4509 {
4510 // Issue the set Context request to LIM to establish the Unicast STA context
4511 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
4512 pProfile->negotiatedUCEncryptionType,
4513 pSirBssDesc, &(pSirBssDesc->bssId),
4514 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
4515 {
4516 smsLog( pMac, LOGE, FL(" Set context for unicast fail\n") );
4517 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
4518 }
4519 // Issue the set Context request to LIM to establish the Broadcast STA context
4520 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
4521 pSirBssDesc, &BroadcastMac,
4522 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
4523 }
4524 else
4525 {
4526 //Need to wait for supplicant authtication
4527 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
4528
4529 //Set the subestate to WaitForKey in case authentiation is needed
4530 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
4531
4532
4533 if(pProfile->bWPSAssociation)
4534 {
4535 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
4536 }
4537 else
4538 {
4539 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
4540 }
4541
4542 //Save sessionId in case of timeout
4543 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
4544 //This time should be long enough for the rest of the process plus setting key
4545 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
4546 {
4547 //Reset our state so nothting is blocked.
4548 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer\n") );
4549 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
4550 }
4551 }
4552
4553 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
4554 assocInfo.pProfile = pProfile;
4555
4556 if(Context)
4557 {
4558 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
4559 tANI_U32 len;
4560
4561 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
4562 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
4563#ifdef WLAN_FEATURE_VOWIFI_11R
4564 len += pJoinRsp->parsedRicRspLen;
4565#endif /* WLAN_FEATURE_VOWIFI_11R */
4566#ifdef FEATURE_WLAN_CCX
4567 len += pJoinRsp->tspecIeLen;
4568#endif
4569 if(len)
4570 {
4571 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
4572 (void **)&pSession->connectedInfo.pbFrames, len)))
4573 {
4574 if(HAL_STATUS_SUCCESS( palCopyMemory(pMac->hHdd,
4575 pSession->connectedInfo.pbFrames, pJoinRsp->frames, len) ))
4576 {
4577 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
4578 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
4579 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
4580#ifdef WLAN_FEATURE_VOWIFI_11R
4581 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
4582#endif /* WLAN_FEATURE_VOWIFI_11R */
4583#ifdef FEATURE_WLAN_CCX
4584 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
4585#endif
4586 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
4587 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
4588 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
4589 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
4590 }
4591 else
4592 {
4593 smsLog(pMac, LOGE, "%s: Copying of memory failed for %d bytes !!!\n",
4594 __FUNCTION__, len);
4595 palFreeMemory( pMac->hHdd, pSession->connectedInfo.pbFrames );
4596 pSession->connectedInfo.pbFrames = NULL;
4597 }
4598 }
4599 }
4600 if(pCommand->u.roamCmd.fReassoc)
4601 {
4602 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
4603 }
4604 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
4605 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
4606 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
4607 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
4608 }
4609 else
4610 {
4611 if(pCommand->u.roamCmd.fReassoc)
4612 {
4613 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
4614 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
4615 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
4616 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
4617 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
4618 }
4619 }
4620#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4621 // Indicate SME-QOS with reassoc success event, only after
4622 // copying the frames
4623 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
4624#endif
4625
4626
4627 roamInfo.pBssDesc = pSirBssDesc;
4628 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4629 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4630#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4631 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
4632#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
4633 pSession->connectedProfile.acm_mask = acm_mask;
4634
4635#ifdef FEATURE_WLAN_UAPSD_FW_TRG_FRAMES
4636 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
4637 //It may be better to let QoS do this????
4638 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
4639 {
4640 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now\n",
4641 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
4642 pmcStartUapsd( pMac, NULL, NULL );
4643 }
4644#endif
4645
4646 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
4647 if( pSession->bRefAssocStartCnt > 0 )
4648 {
4649 pSession->bRefAssocStartCnt--;
4650 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
4651 }
4652
4653 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
4654
4655 // reset the PMKID candidate list
4656 csrResetPMKIDCandidateList( pMac, sessionId );
4657 //Update TL's AC weight base on the current EDCA parameters
4658 //These parameters may change in the course of the connection, that sictuation
4659 //is not taken care here. This change is mainly to address a WIFI WMM test where
4660 //BE has a equal or higher TX priority than VI.
4661 //We only do this for infra link
4662 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
4663 {
4664 csrCheckAndUpdateACWeight(pMac, pIes);
4665 }
4666#ifdef FEATURE_WLAN_WAPI
4667 // reset the BKID candidate list
4668 csrResetBKIDCandidateList( pMac, sessionId );
4669#endif /* FEATURE_WLAN_WAPI */
4670 }
4671 else
4672 {
4673 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc\n");
4674 }
4675
4676 csrScanCancelIdleScan(pMac);
4677 //Not to signal link up because keys are yet to be set.
4678 //The linkup function will overwrite the sub-state that we need to keep at this point.
4679 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
4680 {
4681 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
4682 }
4683
4684 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
4685 //enough to let security and DHCP handshake succeed before entry into BMPS
4686 if (pmcShouldBmpsTimerRun(pMac))
4687 {
4688 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
4689 != eHAL_STATUS_SUCCESS)
4690 {
4691 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
4692 }
4693 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
4694 }
4695
4696 break;
4697
4698
4699 case eCsrStartBssSuccess:
4700 // on the StartBss Response, LIM is returning the Bss Description that we
4701 // are beaconing. Add this Bss Description to our scan results and
4702 // chain the Profile to this Bss Description. On a Start BSS, there was no
4703 // detected Bss description (no partner) so we issued the Start Bss to
4704 // start the Ibss without any Bss description. Lim was kind enough to return
4705 // the Bss Description that we start beaconing for the newly started Ibss.
4706 smsLog(pMac, LOG2, FL("receives start BSS ok indication\n"));
4707 status = eHAL_STATUS_FAILURE;
4708#ifdef WLAN_SOFTAP_FEATURE
4709 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
4710#endif
4711 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
4712 if( CSR_IS_IBSS( pProfile ) )
4713 {
4714 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
4715 }
4716#ifdef WLAN_SOFTAP_FEATURE
4717 else if (CSR_IS_INFRA_AP(pProfile))
4718 {
4719 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
4720 }
4721#endif
4722 else
4723 {
4724 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
4725 }
4726 if( !CSR_IS_WDS_STA( pProfile ) )
4727 {
4728 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
4729#ifdef WLAN_SOFTAP_FEATURE
4730 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
4731#else
4732 pSirBssDesc = (tSirBssDescription *)Context;
4733#endif
4734 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
4735 {
4736 smsLog(pMac, LOG2, FL("cannot parse IBSS IEs\n"));
4737 roamInfo.pBssDesc = pSirBssDesc;
4738 //We need to associate_complete it first, becasue Associate_start already indicated.
4739 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4740 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
4741 break;
4742 }
4743#ifdef WLAN_SOFTAP_FEATURE
4744 if (!CSR_IS_INFRA_AP(pProfile))
4745#endif
4746 {
4747 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes );
4748 }
4749 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
4750 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
4751 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
4752 if(pSirBssDesc)
4753 {
4754 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
4755 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
4756 }
4757 //We are doen with the IEs so free it
4758 palFreeMemory(pMac->hHdd, pIes);
4759
4760#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
4761 {
4762 vos_log_ibss_pkt_type *pIbssLog;
4763 tANI_U32 bi;
4764
4765 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
4766 if(pIbssLog)
4767 {
4768 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
4769 {
4770 //We start the IBSS (didn't find any matched IBSS out there)
4771 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
4772 }
4773 else
4774 {
4775 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
4776 }
4777 if(pSirBssDesc)
4778 {
4779 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pSirBssDesc->bssId, 6);
4780 pIbssLog->operatingChannel = pSirBssDesc->channelId;
4781 }
4782 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
4783 {
4784 //***U8 is not enough for beacon interval
4785 pIbssLog->beaconInterval = (v_U8_t)bi;
4786 }
4787 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
4788 }
4789 }
4790#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
4791 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
4792 //is WPA2-PSK so it won't matter.
4793
4794#ifdef WLAN_SOFTAP_FEATURE
4795 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
4796 {
4797#else
4798 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ))
4799 {
4800#endif
4801 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
4802 csrRoamIssueSetContextReq( pMac, sessionId,
4803 pProfile->negotiatedMCEncryptionType,
4804 pSirBssDesc, &BroadcastMac,
4805 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
4806 }
4807 }
4808 else
4809 {
4810 //Keep the state to eCSR_ROAMING_STATE_JOINING
4811 //Need to send join_req.
4812 if(pCommand->u.roamCmd.pRoamBssEntry)
4813 {
4814 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
4815 {
4816 pSirBssDesc = &pScanResult->Result.BssDescriptor;
4817 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
4818 // Set the roaming substate to 'join attempt'...
4819 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
4820 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes );
4821 }
4822 }
4823 else
4824 {
4825 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc\n" );
4826 VOS_ASSERT( 0 );
4827 }
4828 }
4829 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
4830 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
4831 //trigger the connection start indication in Vista
4832 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
4833 {
4834 roamStatus = eCSR_ROAM_IBSS_IND;
4835 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
4836 if( CSR_IS_WDS( pProfile ) )
4837 {
4838 roamStatus = eCSR_ROAM_WDS_IND;
4839 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
4840 }
4841#ifdef WLAN_SOFTAP_FEATURE
4842 if( CSR_IS_INFRA_AP( pProfile ) )
4843 {
4844 roamStatus = eCSR_ROAM_INFRA_IND;
4845 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
4846 }
4847#endif
4848
4849 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
4850 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
4851 //trigger the connection start indication in Vista
4852 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
4853 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4854 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4855 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
4856 {
4857 //We start the IBSS (didn't find any matched IBSS out there)
4858 roamInfo.pBssDesc = pSirBssDesc;
4859 }
4860#ifdef WLAN_SOFTAP_FEATURE
4861 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
4862#endif
4863 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
4864 }
4865
4866 csrScanCancelIdleScan(pMac);
4867 //Only use this timer for ibss. BAP has its own timer for WDS
4868 if( CSR_IS_IBSS( pProfile) && CSR_INVALID_SCANRESULT_HANDLE != pCommand->u.roamCmd.hBSSList)
4869 {
4870 //start the join IBSS timer
4871 csrRoamStartIbssJoinTimer(pMac, sessionId, CSR_IBSS_JOIN_TIMEOUT_PERIOD); //interval
4872 pSession->ibss_join_pending = TRUE;
4873 }
4874 if( HAL_STATUS_SUCCESS( status ) )
4875 {
4876 //Already sent join_req for the WDS station
4877 fReleaseCommand = eANI_BOOLEAN_FALSE;
4878 }
4879 else if( CSR_IS_WDS_STA( pProfile ) )
4880 {
4881 //need to send stop BSS because we fail to send join_req
4882 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
4883 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4884 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
4885 }
4886
4887 break;
4888
4889 case eCsrStartBssFailure:
4890#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
4891 {
4892 vos_log_ibss_pkt_type *pIbssLog;
4893
4894 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
4895 if(pIbssLog)
4896 {
4897 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
4898 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
4899 }
4900 }
4901#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
4902
4903 roamStatus = eCSR_ROAM_IBSS_IND;
4904 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
4905 if( CSR_IS_WDS( pProfile ) )
4906 {
4907 roamStatus = eCSR_ROAM_WDS_IND;
4908 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
4909 }
4910#ifdef WLAN_SOFTAP_FEATURE
4911 if( CSR_IS_INFRA_AP( pProfile ) )
4912 {
4913 roamStatus = eCSR_ROAM_INFRA_IND;
4914 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
4915 }
4916#endif
4917 if(Context)
4918 {
4919 pSirBssDesc = (tSirBssDescription *)Context;
4920 }
4921 else
4922 {
4923 pSirBssDesc = NULL;
4924 }
4925 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
4926 roamInfo.pBssDesc = pSirBssDesc;
4927 //We need to associate_complete it first, becasue Associate_start already indicated.
4928 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
4929 csrSetDefaultDot11Mode( pMac );
4930 break;
4931
4932 case eCsrSilentlyStopRoaming:
4933 // We are here because we try to start the same IBSS
4934 //No message to PE
4935 // return the roaming state to Joined.
4936 smsLog(pMac, LOGW, FL("receives silently roaming indication\n"));
4937 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
4938 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
4939 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
4940 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4941 if( roamInfo.pBssDesc )
4942 {
4943 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &roamInfo.pBssDesc->bssId, sizeof(tCsrBssid));
4944 }
4945 //Since there is no change in the current state, simply pass back no result otherwise
4946 //HDD may be mistakenly mark to disconnected state.
4947 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4948 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
4949
4950 break;
4951
4952 case eCsrSilentlyStopRoamingSaveState:
4953 //We are here because we try to connect to the same AP
4954 //No message to PE
4955 smsLog(pMac, LOGW, FL("receives silently stop roaming indication\n"));
4956 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
4957
4958 //to aviod resetting the substate to NONE
4959 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
4960 //No need to change substate to wai_for_key because there is no state change
4961 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4962 if( roamInfo.pBssDesc )
4963 {
4964 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &roamInfo.pBssDesc->bssId, sizeof(tCsrBssid));
4965 }
4966
4967 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4968 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4969 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
4970 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
4971 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
4972 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
4973 roamInfo.staId = pSession->connectedInfo.staId;
4974 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
4975#if defined(VOSS_ENABLED)
4976 VOS_ASSERT( roamInfo.staId != 0 );
4977#endif
4978 pSession->bRefAssocStartCnt--;
4979 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4980 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
4981 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
4982 break;
4983
4984 case eCsrReassocFailure:
4985#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4986 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
4987#endif
4988 case eCsrJoinWdsFailure:
4989 smsLog(pMac, LOGW, FL("failed to join WDS\n"));
4990 csrFreeConnectBssDesc(pMac, sessionId);
4991 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
4992 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
4993 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
4994 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
4995 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4996 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4997 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4998 eCSR_ROAM_WDS_IND,
4999 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5000 //Need to issue stop_bss
5001 break;
5002
5003 case eCsrJoinFailure:
5004 case eCsrNothingToJoin:
5005 default:
5006 {
5007 smsLog(pMac, LOGW, FL("receives no association indication\n"));
5008 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
5009 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
5010 {
5011 //do not free for the other profiles as we need to send down stop BSS later
5012 csrFreeConnectBssDesc(pMac, sessionId);
5013 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5014 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5015 csrSetDefaultDot11Mode( pMac );
5016 }
5017
5018 switch( pCommand->u.roamCmd.roamReason )
5019 {
5020 // If this transition is because of an 802.11 OID, then we transition
5021 // back to INIT state so we sit waiting for more OIDs to be issued and
5022 // we don't start the IDLE timer.
5023 case eCsrSmeIssuedAssocToSimilarAP:
5024 case eCsrHddIssued:
5025 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5026 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5027 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5028 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5029 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5030
5031 /* Defeaturize this later if needed */
5032#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5033 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
5034 if (csrRoamIsHandoffInProgress(pMac))
5035 {
5036 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5037 /* Should indicate neighbor roam algorithm about the connect failure here */
5038 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
5039 }
5040 else
5041#endif
5042 {
5043 if(pSession->bRefAssocStartCnt > 0)
5044 {
5045 pSession->bRefAssocStartCnt--;
5046 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5047 eCSR_ROAM_ASSOCIATION_COMPLETION,
5048 eCSR_ROAM_RESULT_FAILURE);
5049 }
5050 }
5051 smsLog(pMac, LOG1, FL(" roam(reason %d) failed\n"), pCommand->u.roamCmd.roamReason);
5052#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5053 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5054#endif
5055 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5056 csrScanStartIdleScan(pMac);
5057#ifdef FEATURE_WLAN_BTAMP_UT_RF
5058 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
5059 //BT activity and not able to recevie WLAN traffic. Retry the join
5060 if( CSR_IS_WDS_STA(pProfile) )
5061 {
5062 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
5063 }
5064#endif
5065 break;
5066
5067 case eCsrHddIssuedReassocToSameAP:
5068 case eCsrSmeIssuedReassocToSameAP:
5069 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5070
5071 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5072#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5073 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5074#endif
5075 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5076 csrScanStartIdleScan(pMac);
5077 break;
5078 case eCsrForcedDisassoc:
5079 case eCsrForcedDeauth:
5080 case eCsrSmeIssuedIbssJoinFailure:
5081 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5082
5083 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
5084 {
5085 // Notify HDD that IBSS join failed
5086 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
5087 }
5088 else
5089 {
5090 csrRoamCallCallback(pMac, sessionId, NULL,
5091 pCommand->u.roamCmd.roamId,
5092 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5093 }
5094#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5095 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5096#endif
5097 csrRoamLinkDown(pMac, sessionId);
5098 csrScanStartIdleScan(pMac);
5099 break;
5100 case eCsrForcedIbssLeave:
5101 csrRoamCallCallback(pMac, sessionId, NULL,
5102 pCommand->u.roamCmd.roamId,
5103 eCSR_ROAM_IBSS_LEAVE,
5104 eCSR_ROAM_RESULT_IBSS_STOP);
5105 break;
5106 case eCsrForcedDisassocMICFailure:
5107 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5108
5109 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
5110#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5111 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
5112#endif
5113 csrScanStartIdleScan(pMac);
5114 break;
5115#ifdef WLAN_SOFTAP_FEATURE
5116 case eCsrStopBss:
5117 csrRoamCallCallback(pMac, sessionId, NULL,
5118 pCommand->u.roamCmd.roamId,
5119 eCSR_ROAM_INFRA_IND,
5120 eCSR_ROAM_RESULT_INFRA_STOPPED);
5121 break;
5122 case eCsrForcedDisassocSta:
5123 case eCsrForcedDeauthSta:
5124 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
5125 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
5126 {
5127 pSession = CSR_GET_SESSION(pMac, sessionId);
5128 if (!pSession)
5129 break;
5130
5131 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
5132 {
5133 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5134 palCopyMemory(pMac->hHdd, roamInfo.peerMac,
5135 pCommand->u.roamCmd.peerMac, sizeof(tSirMacAddr));
5136 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
5137 roamInfo.statusCode = eSIR_SME_SUCCESS;
5138 status = csrRoamCallCallback(pMac, sessionId,
5139 &roamInfo, pCommand->u.roamCmd.roamId,
5140 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
5141 }
5142 }
5143 break;
5144#endif
5145 case eCsrLostLink1:
5146 // if lost link roam1 failed, then issue lost link Scan2 ...
5147 csrScanRequestLostLink2(pMac, sessionId);
5148 break;
5149 case eCsrLostLink2:
5150 // if lost link roam2 failed, then issue lost link scan3 ...
5151 csrScanRequestLostLink3(pMac, sessionId);
5152 break;
5153 case eCsrLostLink3:
5154 default:
5155 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5156
5157 //We are done with one round of lostlink roaming here
5158 csrScanHandleFailedLostlink3(pMac, sessionId);
5159 break;
5160 }
5161
5162 break;
5163 }
5164 }
5165
5166 return ( fReleaseCommand );
5167}
5168
5169
5170eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
5171{
5172 eHalStatus status = eHAL_STATUS_SUCCESS;
5173
5174 return (status);
5175}
5176
5177
5178eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
5179{
5180 eHalStatus status = eHAL_STATUS_SUCCESS;
5181 tANI_U32 size = 0;
5182
5183 do
5184 {
5185 palZeroMemory(pMac->hHdd, pDstProfile, sizeof(tCsrRoamProfile));
5186 if(pSrcProfile->BSSIDs.numOfBSSIDs)
5187 {
5188 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
5189 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->BSSIDs.bssid, size);
5190 if(!HAL_STATUS_SUCCESS(status))
5191 {
5192 break;
5193 }
5194 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
5195 palCopyMemory(pMac->hHdd, pDstProfile->BSSIDs.bssid, pSrcProfile->BSSIDs.bssid, size);
5196 }
5197 if(pSrcProfile->SSIDs.numOfSSIDs)
5198 {
5199 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
5200 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->SSIDs.SSIDList, size);
5201 if(!HAL_STATUS_SUCCESS(status))
5202 {
5203 break;
5204 }
5205 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
5206 palCopyMemory(pMac->hHdd, pDstProfile->SSIDs.SSIDList, pSrcProfile->SSIDs.SSIDList, size);
5207 }
5208 if(pSrcProfile->nWPAReqIELength)
5209 {
5210 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pWPAReqIE, pSrcProfile->nWPAReqIELength);
5211 if(!HAL_STATUS_SUCCESS(status))
5212 {
5213 break;
5214 }
5215 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
5216 palCopyMemory(pMac->hHdd, pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE, pSrcProfile->nWPAReqIELength);
5217 }
5218 if(pSrcProfile->nRSNReqIELength)
5219 {
5220 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pRSNReqIE, pSrcProfile->nRSNReqIELength);
5221 if(!HAL_STATUS_SUCCESS(status))
5222 {
5223 break;
5224 }
5225 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
5226 palCopyMemory(pMac->hHdd, pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE, pSrcProfile->nRSNReqIELength);
5227 }
5228#ifdef FEATURE_WLAN_WAPI
5229 if(pSrcProfile->nWAPIReqIELength)
5230 {
5231 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pWAPIReqIE, pSrcProfile->nWAPIReqIELength);
5232 if(!HAL_STATUS_SUCCESS(status))
5233 {
5234 break;
5235 }
5236 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
5237 palCopyMemory(pMac->hHdd, pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE, pSrcProfile->nWAPIReqIELength);
5238 }
5239#endif /* FEATURE_WLAN_WAPI */
5240
5241 if(pSrcProfile->nAddIEScanLength)
5242 {
5243 status = palAllocateMemory(pMac->hHdd,
5244 (void **)&pDstProfile->pAddIEScan, pSrcProfile->nAddIEScanLength);
5245 if(!HAL_STATUS_SUCCESS(status))
5246 {
5247 break;
5248 }
5249 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
5250 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEScan, pSrcProfile->pAddIEScan,
5251 pSrcProfile->nAddIEScanLength);
5252 }
5253
5254 if(pSrcProfile->nAddIEAssocLength)
5255 {
5256 status = palAllocateMemory(pMac->hHdd,
5257 (void **)&pDstProfile->pAddIEAssoc, pSrcProfile->nAddIEAssocLength);
5258 if(!HAL_STATUS_SUCCESS(status))
5259 {
5260 break;
5261 }
5262 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
5263 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
5264 pSrcProfile->nAddIEAssocLength);
5265 }
5266
5267 if(pSrcProfile->ChannelInfo.ChannelList)
5268 {
5269 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.numOfChannels);
5270 if(!HAL_STATUS_SUCCESS(status))
5271 {
5272 break;
5273 }
5274 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
5275 palCopyMemory(pMac->hHdd, pDstProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.numOfChannels);
5276 }
5277
5278 pDstProfile->AuthType = pSrcProfile->AuthType;
5279 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
5280 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
5281 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
5282 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
5283 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
5284 pDstProfile->BSSType = pSrcProfile->BSSType;
5285 pDstProfile->phyMode = pSrcProfile->phyMode;
5286 pDstProfile->csrPersona = pSrcProfile->csrPersona;
5287
5288#ifdef FEATURE_WLAN_WAPI
5289 if(csrIsProfileWapi(pSrcProfile))
5290 {
5291 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
5292 {
5293 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
5294 }
5295 }
5296#endif /* FEATURE_WLAN_WAPI */
5297 pDstProfile->CBMode = pSrcProfile->CBMode;
5298 /*Save the WPS info*/
5299 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
5300 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
5301
5302 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
5303#ifdef WLAN_SOFTAP_FEATURE
5304 pDstProfile->privacy = pSrcProfile->privacy;
5305 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
5306 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
5307 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
5308 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
5309 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
5310 pDstProfile->protEnabled = pSrcProfile->protEnabled;
5311 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
5312 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
5313 pDstProfile->wps_state = pSrcProfile->wps_state;
5314 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
5315#endif
5316
5317 palCopyMemory(pMac->hHdd, &pDstProfile->Keys, &pSrcProfile->Keys, sizeof(pDstProfile->Keys));
5318
5319#ifdef WLAN_FEATURE_VOWIFI_11R
5320 if (pSrcProfile->MDID.mdiePresent)
5321 {
5322 pDstProfile->MDID.mdiePresent = 1;
5323 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
5324 }
5325#endif
5326
5327 }while(0);
5328
5329 if(!HAL_STATUS_SUCCESS(status))
5330 {
5331 csrReleaseProfile(pMac, pDstProfile);
5332 pDstProfile = NULL;
5333 }
5334
5335 return (status);
5336}
5337
5338eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
5339{
5340 eHalStatus status = eHAL_STATUS_SUCCESS;
5341 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
5342 do
5343 {
5344 palZeroMemory(pMac->hHdd, pDstProfile, sizeof(tCsrRoamProfile));
5345 if(pSrcProfile->bssid)
5346 {
5347 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->BSSIDs.bssid, sizeof(tCsrBssid));
5348 if(!HAL_STATUS_SUCCESS(status))
5349 {
5350 break;
5351 }
5352 pDstProfile->BSSIDs.numOfBSSIDs = 1;
5353 palCopyMemory(pMac->hHdd, pDstProfile->BSSIDs.bssid, pSrcProfile->bssid, sizeof(tCsrBssid));
5354 }
5355 if(pSrcProfile->SSID.ssId)
5356 {
5357 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->SSIDs.SSIDList, sizeof(tCsrSSIDInfo));
5358 if(!HAL_STATUS_SUCCESS(status))
5359 {
5360 break;
5361 }
5362 pDstProfile->SSIDs.numOfSSIDs = 1;
5363 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
5364 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
5365 palCopyMemory(pMac->hHdd, &pDstProfile->SSIDs.SSIDList[0].SSID, &pSrcProfile->SSID, sizeof(tSirMacSSid));
5366 }
5367
5368 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->ChannelInfo.ChannelList, 1);
5369 if(!HAL_STATUS_SUCCESS(status))
5370 {
5371 break;
5372 }
5373 pDstProfile->ChannelInfo.numOfChannels = 1;
5374 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
5375
5376 pDstProfile->AuthType.numEntries = 1;
5377 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
5378 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
5379 pDstProfile->EncryptionType.numEntries = 1;
5380 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
5381 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
5382 pDstProfile->mcEncryptionType.numEntries = 1;
5383 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
5384 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
5385 pDstProfile->BSSType = pSrcProfile->BSSType;
5386 pDstProfile->CBMode = pSrcProfile->CBMode;
5387 palCopyMemory(pMac->hHdd, &pDstProfile->Keys, &pSrcProfile->Keys, sizeof(pDstProfile->Keys));
5388#ifdef WLAN_FEATURE_VOWIFI_11R
5389 if (pSrcProfile->MDID.mdiePresent)
5390 {
5391 pDstProfile->MDID.mdiePresent = 1;
5392 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
5393 }
5394#endif
5395
5396 }while(0);
5397
5398 if(!HAL_STATUS_SUCCESS(status))
5399 {
5400 csrReleaseProfile(pMac, pDstProfile);
5401 pDstProfile = NULL;
5402 }
5403
5404 return (status);
5405}
5406
5407
5408eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5409 tScanResultHandle hBSSList,
5410 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
5411 tANI_BOOLEAN fClearScan)
5412{
5413 eHalStatus status = eHAL_STATUS_SUCCESS;
5414 tSmeCmd *pCommand;
5415
5416 pCommand = csrGetCommandBuffer(pMac);
5417 if(NULL == pCommand)
5418 {
5419 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
5420 status = eHAL_STATUS_RESOURCES;
5421 }
5422 else
5423 {
5424 if( fClearScan )
5425 {
5426 csrScanCancelIdleScan(pMac);
5427 csrScanAbortMacScanNotForConnect(pMac);
5428 }
5429 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
5430 if(NULL == pProfile)
5431 {
5432 //We can roam now
5433 //Since pProfile is NULL, we need to build our own profile, set everything to default
5434 //We can only support open and no encryption
5435 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
5436 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5437 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
5438 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5439 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
5440 }
5441 else
5442 {
5443 //make a copy of the profile
5444 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
5445 if(HAL_STATUS_SUCCESS(status))
5446 {
5447 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
5448 }
5449 }
5450 pCommand->command = eSmeCommandRoam;
5451 pCommand->sessionId = (tANI_U8)sessionId;
5452 pCommand->u.roamCmd.hBSSList = hBSSList;
5453 pCommand->u.roamCmd.roamId = roamId;
5454 pCommand->u.roamCmd.roamReason = reason;
5455 //We need to free the BssList when the command is done
5456 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
5457 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
5458
5459 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
5460 FL("CSR PERSONA=%d"),
5461 pCommand->u.roamCmd.roamProfile.csrPersona);
5462
5463 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
5464 if( !HAL_STATUS_SUCCESS( status ) )
5465 {
5466 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
5467 csrReleaseCommandRoam( pMac, pCommand );
5468 }
5469 }
5470
5471 return (status);
5472}
5473
5474eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5475 tCsrRoamModifyProfileFields *pMmodProfileFields,
5476 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
5477{
5478 eHalStatus status = eHAL_STATUS_SUCCESS;
5479 tSmeCmd *pCommand;
5480
5481 pCommand = csrGetCommandBuffer(pMac);
5482 if(NULL == pCommand)
5483 {
5484 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
5485 status = eHAL_STATUS_RESOURCES;
5486 }
5487 else
5488 {
5489 csrScanCancelIdleScan(pMac);
5490 csrScanAbortMacScanNotForConnect(pMac);
5491 if(pProfile)
5492 {
5493
5494 //This is likely trying to reassoc to different profile
5495 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
5496 //make a copy of the profile
5497 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
5498 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
5499
5500 }
5501 else
5502 {
5503 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
5504 //how to update WPA/WPA2 info in roamProfile??
5505 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
5506
5507 }
5508
5509 if(HAL_STATUS_SUCCESS(status))
5510 {
5511 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
5512 }
5513 pCommand->command = eSmeCommandRoam;
5514 pCommand->sessionId = (tANI_U8)sessionId;
5515 pCommand->u.roamCmd.roamId = roamId;
5516 pCommand->u.roamCmd.roamReason = reason;
5517 //We need to free the BssList when the command is done
5518 //For reassoc there is no BSS list, so the boolean set to false
5519 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
5520 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
5521 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
5522
5523 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
5524 if( !HAL_STATUS_SUCCESS( status ) )
5525 {
5526 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
5527 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5528 csrReleaseCommandRoam( pMac, pCommand );
5529 }
5530 }
5531
5532 return (status);
5533}
5534
5535
5536eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5537 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
5538{
5539 eHalStatus status = eHAL_STATUS_FAILURE;
5540 tScanResultHandle hBSSList;
5541 tANI_U32 roamId = 0;
5542
5543 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
5544 if(HAL_STATUS_SUCCESS(status))
5545 {
5546 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
5547 if(pRoamId)
5548 {
5549 *pRoamId = roamId;
5550 }
5551 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
5552 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
5553 if(!HAL_STATUS_SUCCESS(status))
5554 {
5555 smsLog(pMac, LOGE, FL("failed to start a join process\n"));
5556 csrScanResultPurge(pMac, hBSSList);
5557 }
5558 }
5559
5560 return (status);
5561}
5562
5563
5564eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5565 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
5566{
5567 eHalStatus status = eHAL_STATUS_SUCCESS;
5568 tScanResultHandle hBSSList;
5569 tCsrScanResultFilter *pScanFilter;
5570 tANI_U32 roamId = 0;
5571 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
5572 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5573
5574 if (NULL == pProfile)
5575 {
5576 smsLog(pMac, LOGP, FL("No profile specified"));
5577 return eHAL_STATUS_FAILURE;
5578 }
5579
5580 smsLog(pMac, LOG1, FL("called BSSType = %d authtype = %d encryType = %d\n"),
5581 pProfile->BSSType, pProfile->AuthType.authType[0], pProfile->EncryptionType.encryptionType[0]);
5582
5583 if( CSR_IS_WDS( pProfile ) &&
5584 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
5585 {
5586 return status;
5587 }
5588 csrRoamCancelRoaming(pMac, sessionId);
5589 csrScanRemoveFreshScanCommand(pMac, sessionId);
5590 csrScanCancelIdleScan(pMac);
5591 //Only abort the scan if it is not used for other roam/connect purpose
5592 csrScanAbortMacScan(pMac);
5593
5594#ifdef WLAN_SOFTAP_FEATURE
5595 if (!vos_concurrent_sessions_running() && (VOS_STA_SAP_MODE == pProfile->csrPersona))//In case of AP mode we do not want idle mode scan
5596 {
5597 csrScanDisable(pMac);
5598 }
5599#endif
5600
5601 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
5602 //Check whether ssid changes
5603 if(csrIsConnStateConnected(pMac, sessionId))
5604 {
5605 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
5606 {
5607 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
5608 }
5609 }
5610#ifdef FEATURE_WLAN_BTAMP_UT_RF
5611 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
5612#endif
5613 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
5614 {
5615 smsLog(pMac, LOGW, FL("is called with BSSList\n"));
5616 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
5617 if(pRoamId)
5618 {
5619 roamId = *pRoamId;
5620 }
5621 if(!HAL_STATUS_SUCCESS(status))
5622 {
5623 fCallCallback = eANI_BOOLEAN_TRUE;
5624 }
5625 }
5626 else
5627 {
5628 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
5629 if(HAL_STATUS_SUCCESS(status))
5630 {
5631 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
5632 //Try to connect to any BSS
5633 if(NULL == pProfile)
5634 {
5635 //No encryption
5636 pScanFilter->EncryptionType.numEntries = 1;
5637 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5638 }//we don't have a profile
5639 else
5640 {
5641 //Here is the profile we need to connect to
5642 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
5643 }//We have a profile
5644 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
5645 if(pRoamId)
5646 {
5647 *pRoamId = roamId;
5648 }
5649
5650 if(HAL_STATUS_SUCCESS(status))
5651 {
5652 /*Save the WPS info*/
5653 if(NULL != pProfile)
5654 {
5655 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
5656 }
5657 else
5658 {
5659 pScanFilter->bWPSAssociation = 0;
5660 }
5661
5662 do
5663 {
5664 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
5665#ifdef WLAN_SOFTAP_FEATURE
5666 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
5667#endif
5668 )
5669 {
5670 //This can be start right away
5671 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
5672 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
5673 if(!HAL_STATUS_SUCCESS(status))
5674 {
5675 fCallCallback = eANI_BOOLEAN_TRUE;
5676 }
5677
5678 break;
5679 }
5680 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
5681 smsLog(pMac, LOGE, "************ csrScanGetResult Status ********* %d\n", status);
5682 if(HAL_STATUS_SUCCESS(status))
5683 {
5684
5685 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
5686 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
5687 if(!HAL_STATUS_SUCCESS(status))
5688 {
5689 csrScanResultPurge(pMac, hBSSList);
5690 fCallCallback = eANI_BOOLEAN_TRUE;
5691 }
5692 }//Have scan result
5693 else if(NULL != pProfile)
5694 {
5695 //Check whether it is for start ibss
5696 if(CSR_IS_START_IBSS(pProfile))
5697 {
5698 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
5699 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
5700 if(!HAL_STATUS_SUCCESS(status))
5701 {
5702 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X\n", status);
5703 fCallCallback = eANI_BOOLEAN_TRUE;
5704 }
5705 }
5706 else
5707 {
5708 //scan for this SSID
5709 status = csrScanForSSID(pMac, sessionId, pProfile, roamId);
5710 if(!HAL_STATUS_SUCCESS(status))
5711 {
5712 fCallCallback = eANI_BOOLEAN_TRUE;
5713 }
5714 }
5715 }
5716 else
5717 {
5718 fCallCallback = eANI_BOOLEAN_TRUE;
5719 }
5720 } while (0);
5721 if(NULL != pProfile)
5722 {
5723 //we need to free memory for filter if profile exists
5724 csrFreeScanFilter(pMac, pScanFilter);
5725 }
5726 }//Got the scan filter from profile
5727
5728 palFreeMemory(pMac->hHdd, pScanFilter);
5729 }//allocated memory for pScanFilter
5730 }//No Bsslist coming in
5731 //tell the caller if we fail to trigger a join request
5732 if( fCallCallback )
5733 {
5734 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
5735 }
5736
5737 return (status);
5738}
5739
5740eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5741 tCsrRoamModifyProfileFields modProfileFields,
5742 tANI_U32 *pRoamId)
5743{
5744 eHalStatus status = eHAL_STATUS_SUCCESS;
5745 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
5746 tANI_U32 roamId = 0;
5747 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5748
5749 if (NULL == pProfile)
5750 {
5751 smsLog(pMac, LOGP, FL("No profile specified"));
5752 return eHAL_STATUS_FAILURE;
5753 }
5754
5755 smsLog(pMac, LOG1, FL("called BSSType = %d authtype = %d encryType = %d\n"), pProfile->BSSType, pProfile->AuthType.authType[0], pProfile->EncryptionType.encryptionType[0]);
5756 csrRoamCancelRoaming(pMac, sessionId);
5757 csrScanRemoveFreshScanCommand(pMac, sessionId);
5758 csrScanCancelIdleScan(pMac);
5759 csrScanAbortMacScanNotForConnect(pMac);
5760 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
5761
5762 if(csrIsConnStateConnected(pMac, sessionId))
5763 {
5764 if(pProfile)
5765 {
5766 if(pProfile->SSIDs.numOfSSIDs &&
5767 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
5768 {
5769 fCallCallback = eANI_BOOLEAN_FALSE;
5770 }
5771 else
5772 {
5773 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile\n"));
5774 }
5775 }
5776 else if(!palEqualMemory(pMac->hHdd, &modProfileFields,
5777 &pSession->connectedProfile.modifyProfileFields,
5778 sizeof(tCsrRoamModifyProfileFields)))
5779 {
5780 fCallCallback = eANI_BOOLEAN_FALSE;
5781 }
5782 else
5783 {
5784 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
5785 "in tCsrRoamModifyProfileFields got modified\n"));
5786 }
5787 }
5788 else
5789 {
5790 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc\n"));
5791 }
5792
5793 if(!fCallCallback)
5794 {
5795 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
5796 if(pRoamId)
5797 {
5798 *pRoamId = roamId;
5799 }
5800
5801
5802 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
5803 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
5804
5805 }
5806 else
5807 {
5808 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
5809 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
5810 }
5811
5812 return status;
5813}
5814
5815eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
5816{
5817 eHalStatus status = eHAL_STATUS_FAILURE;
5818 tScanResultHandle hBSSList = NULL;
5819 tCsrScanResultFilter *pScanFilter = NULL;
5820 tANI_U32 roamId;
5821 tCsrRoamProfile *pProfile = NULL;
5822 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5823
5824 do
5825 {
5826 if(pSession->pCurRoamProfile)
5827 {
5828 csrScanCancelIdleScan(pMac);
5829 csrScanAbortMacScanNotForConnect(pMac);
5830 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
5831 status = palAllocateMemory(pMac->hHdd, (void **)&pProfile, sizeof(tCsrRoamProfile));
5832 if(!HAL_STATUS_SUCCESS(status))
5833 break;
5834 palZeroMemory(pMac->hHdd, pProfile, sizeof(tCsrRoamProfile));
5835 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
5836 if(!HAL_STATUS_SUCCESS(status))
5837 break;
5838 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
5839 if(!HAL_STATUS_SUCCESS(status))
5840 {
5841 break;
5842 }
5843 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
5844 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
5845 if(!HAL_STATUS_SUCCESS(status))
5846 {
5847 break;
5848 }
5849 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
5850 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
5851 if(HAL_STATUS_SUCCESS(status))
5852 {
5853 //we want to put the last connected BSS to the very beginning, if possible
5854 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
5855 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
5856 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
5857 if(!HAL_STATUS_SUCCESS(status))
5858 {
5859 csrScanResultPurge(pMac, hBSSList);
5860 break;
5861 }
5862 }
5863 else
5864 {
5865 //Do a scan on this profile
5866 //scan for this SSID only in case the AP suppresses SSID
5867 status = csrScanForSSID(pMac, sessionId, pProfile, roamId);
5868 if(!HAL_STATUS_SUCCESS(status))
5869 {
5870 break;
5871 }
5872 }
5873 }//We have a profile
5874 else
5875 {
5876 smsLog(pMac, LOGW, FL("cannot find a roaming profile\n"));
5877 break;
5878 }
5879 }while(0);
5880 if(pScanFilter)
5881 {
5882 csrFreeScanFilter(pMac, pScanFilter);
5883 palFreeMemory(pMac->hHdd, pScanFilter);
5884 }
5885 if(NULL != pProfile)
5886 {
5887 csrReleaseProfile(pMac, pProfile);
5888 palFreeMemory(pMac->hHdd, pProfile);
5889 }
5890
5891 return (status);
5892}
5893
5894eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
5895{
5896 eHalStatus status = eHAL_STATUS_FAILURE;
5897
5898 if(csrIsConnStateConnected(pMac, sessionId))
5899 {
5900 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
5901 if(HAL_STATUS_SUCCESS(status))
5902 {
5903 status = csrRoamJoinLastProfile(pMac, sessionId);
5904 }
5905 }
5906
5907 return (status);
5908}
5909
5910
5911eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
5912{
5913 eHalStatus status = eHAL_STATUS_FAILURE;
5914
5915 smsLog(pMac, LOGW, FL("is called\n"));
5916 csrRoamCancelRoaming(pMac, sessionId);
5917 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
5918 if(csrIsConnStateDisconnected(pMac, sessionId))
5919 {
5920 status = csrRoamJoinLastProfile(pMac, sessionId);
5921 }
5922
5923 return (status);
5924}
5925
5926
5927eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
5928{
5929 eHalStatus status = eHAL_STATUS_SUCCESS;
5930 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
5931 eCsrRoamSubState NewSubstate;
5932 tANI_U32 sessionId = pCommand->sessionId;
5933
5934 // change state to 'Roaming'...
5935 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
5936
5937 if ( csrIsConnStateIbss( pMac, sessionId ) )
5938 {
5939 // If we are in an IBSS, then stop the IBSS...
5940 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
5941 fComplete = (!HAL_STATUS_SUCCESS(status));
5942 }
5943 else if ( csrIsConnStateInfra( pMac, sessionId ) )
5944 {
5945 smsLog(pMac, LOGE, FL(" restore AC weights (%d-%d-%d-%d)\n"), pMac->roam.ucACWeights[0], pMac->roam.ucACWeights[1],
5946 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
5947 //Restore AC weight in case we change it
5948 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
5949 // in Infrasturcture, we need to disassociate from the Infrastructure network...
5950 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
5951 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
5952 {
5953 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
5954 }
5955 if( fDisassoc )
5956 {
5957 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
5958 }
5959 else
5960 {
5961 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
5962 }
5963 fComplete = (!HAL_STATUS_SUCCESS(status));
5964 }
5965 else if ( csrIsConnStateWds( pMac, sessionId ) )
5966 {
5967 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
5968 {
5969 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
5970 fComplete = (!HAL_STATUS_SUCCESS(status));
5971 }
5972 //This has to be WDS station
5973 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
5974 {
5975
5976 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
5977 if( fDisassoc )
5978 {
5979 status = csrRoamIssueDisassociate( pMac, sessionId,
5980 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
5981 fComplete = (!HAL_STATUS_SUCCESS(status));
5982 }
5983 }
5984 } else {
5985 // we got a dis-assoc request while not connected to any peer
5986 // just complete the command
5987 fComplete = eANI_BOOLEAN_TRUE;
5988 status = eHAL_STATUS_FAILURE;
5989 }
5990 if(fComplete)
5991 {
5992 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
5993 }
5994
5995 if(HAL_STATUS_SUCCESS(status))
5996 {
5997 if ( csrIsConnStateInfra( pMac, sessionId ) )
5998 {
5999 //Set the state to disconnect here
6000 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
6001 }
6002 }
6003 return (status);
6004}
6005
6006
6007/* This is been removed from latest code base */
6008/*
6009static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
6010{
6011 eHalStatus status;
6012 tANI_U32 sessionId = pCommand->sessionId;
6013
6014 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
6015 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6016
6017 return ( status );
6018}
6019*/
6020
6021
6022eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
6023{
6024 eHalStatus status = eHAL_STATUS_SUCCESS;
6025 tSmeCmd *pCommand;
6026 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
6027
6028 do
6029 {
6030 smsLog( pMac, LOGE, FL(" reason = %d\n"), reason );
6031 pCommand = csrGetCommandBuffer( pMac );
6032 if ( !pCommand )
6033 {
6034 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
6035 status = eHAL_STATUS_RESOURCES;
6036 break;
6037 }
6038 //Change the substate in case it is wait-for-key
6039 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
6040 {
6041 csrRoamStopWaitForKeyTimer( pMac );
6042 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6043 }
6044 pCommand->command = eSmeCommandRoam;
6045 pCommand->sessionId = (tANI_U8)sessionId;
6046 switch ( reason )
6047 {
6048 case eCSR_DISCONNECT_REASON_MIC_ERROR:
6049 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
6050 break;
6051
6052 case eCSR_DISCONNECT_REASON_DEAUTH:
6053 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
6054 break;
6055
6056 case eCSR_DISCONNECT_REASON_HANDOFF:
6057 fHighPriority = eANI_BOOLEAN_TRUE;
6058 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
6059 break;
6060
6061 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
6062 case eCSR_DISCONNECT_REASON_DISASSOC:
6063 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
6064 break;
6065
6066 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
6067 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
6068 break;
6069
6070 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
6071 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
6072 break;
6073
6074 default:
6075 break;
6076 }
6077 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6078 if( !HAL_STATUS_SUCCESS( status ) )
6079 {
6080 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
6081 csrReleaseCommandRoam( pMac, pCommand );
6082 }
6083 } while( 0 );
6084
6085 return( status );
6086}
6087
6088
6089eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
6090{
6091 eHalStatus status = eHAL_STATUS_SUCCESS;
6092 tSmeCmd *pCommand;
6093
6094 pCommand = csrGetCommandBuffer( pMac );
6095 if ( NULL != pCommand )
6096 {
6097 //Change the substate in case it is wait-for-key
6098 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
6099 {
6100 csrRoamStopWaitForKeyTimer( pMac );
6101 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6102 }
6103 pCommand->command = eSmeCommandRoam;
6104 pCommand->sessionId = (tANI_U8)sessionId;
6105 pCommand->u.roamCmd.roamReason = eCsrStopBss;
6106 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6107 if( !HAL_STATUS_SUCCESS( status ) )
6108 {
6109 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
6110 csrReleaseCommandRoam( pMac, pCommand );
6111 }
6112 }
6113 else
6114 {
6115 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
6116 status = eHAL_STATUS_RESOURCES;
6117 }
6118
6119 return ( status );
6120}
6121
6122
6123eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
6124{
6125 eHalStatus status = eHAL_STATUS_SUCCESS;
6126 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
6127#ifdef FEATURE_WLAN_BTAMP_UT_RF
6128 //Stop te retry
6129 pSession->maxRetryCount = 0;
6130 csrRoamStopJoinRetryTimer(pMac, sessionId);
6131#endif
6132 //Not to call cancel roaming here
6133 //Only issue disconnect when necessary
6134 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
6135 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
6136 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
6137
6138 {
6139 smsLog(pMac, LOG2, FL("called\n"));
6140 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
6141 }
6142
6143 return (status);
6144}
6145
6146
6147eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
6148{
6149 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
6150
6151 csrRoamCancelRoaming(pMac, sessionId);
6152 pSession->ibss_join_pending = FALSE;
6153 csrRoamStopIbssJoinTimer(pMac, sessionId);
6154 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
6155
6156 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
6157}
6158
6159
6160eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6161 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
6162{
6163 eHalStatus status = eHAL_STATUS_SUCCESS;
6164 tDot11fBeaconIEs *pIesTemp = pIes;
6165 tANI_U8 index;
6166 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
6167 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
6168
6169 palZeroMemory(pMac->hHdd, &pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile));
6170 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
6171 pConnectProfile->AuthInfo = pProfile->AuthType;
6172 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
6173 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
6174 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
6175 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
6176 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
6177 pConnectProfile->BSSType = pProfile->BSSType;
6178 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
6179 pConnectProfile->operationChannel = pSirBssDesc->channelId;
6180 palCopyMemory(pMac->hHdd, &pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
6181 //Save bssid
6182 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
6183#ifdef WLAN_FEATURE_VOWIFI_11R
6184 if (pSirBssDesc->mdiePresent)
6185 {
6186 pConnectProfile->MDID.mdiePresent = 1;
6187 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
6188 }
6189#endif
6190#ifdef FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006191 if ((csrIsProfileCCX(pProfile) ||
6192 ((pIesTemp->CCXVersion.present)
6193 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
6194 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
6195 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
6196 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
6197 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
6198 && (!(csrIsProfile11r( pProfile )))
6199 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07006200 {
6201 pConnectProfile->isCCXAssoc = 1;
6202 }
6203#endif
6204 //save ssid
6205 if( NULL == pIesTemp )
6206 {
6207 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
6208 }
6209 if(HAL_STATUS_SUCCESS(status))
6210 {
6211 if(pIesTemp->SSID.present)
6212 {
6213 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
6214 palCopyMemory(pMac->hHdd, pConnectProfile->SSID.ssId,
6215 pIesTemp->SSID.ssid, pIesTemp->SSID.num_ssid);
6216 }
6217
6218 //Save the bss desc
6219 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
6220
6221 if( CSR_IS_QOS_BSS(pIesTemp) )
6222 {
6223 pConnectProfile->qap = TRUE;
6224 }
6225 else
6226 {
6227 pConnectProfile->qap = FALSE;
6228 }
6229
6230 if ( NULL == pIes )
6231 {
6232 //Free memory if it allocated locally
6233 palFreeMemory(pMac->hHdd, pIesTemp);
6234 }
6235 }
6236 //Save Qos connection
6237 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
6238
6239 if(!HAL_STATUS_SUCCESS(status))
6240 {
6241 csrFreeConnectBssDesc(pMac, sessionId);
6242 }
6243 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
6244 {
6245 if((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
6246 palEqualMemory(pMac->hHdd, pProfile->SSIDs.SSIDList[index].SSID.ssId,
6247 pConnectProfile->SSID.ssId, pConnectProfile->SSID.length))
6248 {
6249 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
6250 break;
6251 }
6252 pConnectProfile->handoffPermitted = FALSE;
6253 }
6254
6255 return (status);
6256}
6257
6258
6259
6260static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
6261{
6262 tListElem *pEntry = NULL;
6263 tSmeCmd *pCommand = NULL;
6264
6265 //The head of the active list is the request we sent
6266 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
6267 if(pEntry)
6268 {
6269 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6270 }
6271
6272 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
6273 {
6274 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
6275 {
6276#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6277 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
6278#endif
6279 }
6280 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
6281 }
6282 else
6283 {
6284 tANI_U32 roamId = 0;
6285 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
6286
6287 //The head of the active list is the request we sent
6288 //Try to get back the same profile and roam again
6289 if(pCommand)
6290 {
6291 roamId = pCommand->u.roamCmd.roamId;
6292 }
6293
6294 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
6295 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
6296 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08lX [%d]\n", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
6297#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
6298 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
6299 if (csrRoamIsHandoffInProgress(pMac))
6300 {
6301 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6302 /* Should indicate neighbor roam algorithm about the connect failure here */
6303 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
6304 }
6305#endif
6306 if (pCommand)
6307 {
6308 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
6309 {
6310 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6311 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
6312 csrRoamReissueRoamCommand(pMac);
6313 }
6314 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
6315 {
6316 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6317 }
6318 else
6319 {
6320 csrRoam(pMac, pCommand);
6321 }
6322 }
6323 else
6324 {
6325 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6326 }
6327 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
6328}
6329
6330
6331eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
6332 tDot11fBeaconIEs *pIes,
6333 tCsrRoamProfile *pProfile, tANI_U32 roamId )
6334{
6335 eHalStatus status;
6336
6337 smsLog( pMac, LOG1, "Attempting to Join Bssid= %02x-%02x-%02x-%02x-%02x-%02x\n",
6338 pSirBssDesc->bssId[ 0 ],pSirBssDesc->bssId[ 1 ],pSirBssDesc->bssId[ 2 ],
6339 pSirBssDesc->bssId[ 3 ],pSirBssDesc->bssId[ 4 ],pSirBssDesc->bssId[ 5 ] );
6340
6341 // Set the roaming substate to 'join attempt'...
6342 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
6343
6344 // attempt to Join this BSS...
6345 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes );
6346
6347 return (status);
6348}
6349
6350
6351static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
6352 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
6353{
6354 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
6355
6356 // Set the roaming substate to 'join attempt'...
6357 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
6358
6359 smsLog(pMac, LOGE, FL(" calling csrSendSmeReassocReqMsg\n"));
6360
6361 // attempt to Join this BSS...
6362 return csrSendSmeReassocReqMsg( pMac, sessionId, pSirBssDesc, pIes, pProfile );
6363}
6364
6365
6366
6367void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
6368{
6369 tListElem *pEntry;
6370 tSmeCmd *pCommand;
6371 tCsrRoamInfo roamInfo;
6372 tANI_U32 sessionId;
6373 tCsrRoamSession *pSession;
6374
6375 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
6376 if(pEntry)
6377 {
6378 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6379 if ( eSmeCommandRoam == pCommand->command )
6380 {
6381 sessionId = pCommand->sessionId;
6382 pSession = CSR_GET_SESSION( pMac, sessionId );
6383 if( pCommand->u.roamCmd.fStopWds )
6384 {
6385 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
6386 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
6387 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6388 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
6389#ifdef WLAN_SOFTAP_FEATURE
6390 if (CSR_IS_WDS(&pSession->connectedProfile)){
6391#endif
6392 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
6393 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6394 eCSR_ROAM_WDS_IND,
6395 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
6396#ifdef WLAN_SOFTAP_FEATURE
6397 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
6398 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
6399 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6400 eCSR_ROAM_INFRA_IND,
6401 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
6402 }
6403
6404#endif
6405
6406
6407 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
6408 {
6409 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated\n");
6410 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6411 }
6412 }
6413 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
6414 {
6415 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated\n");
6416 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6417 }
6418 }
6419 else
6420 {
6421 smsLog(pMac, LOGW, " Command is not roaming after disassociated\n");
6422 }
6423 }
6424 else
6425 {
6426 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available\n");
6427 }
6428}
6429
6430
6431tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
6432{
6433 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
6434 tListElem *pEntry;
6435 tSmeCmd *pCommand = NULL;
6436
6437 //alwasy lock active list before locking pending list
6438 csrLLLock( &pMac->sme.smeCmdActiveList );
6439 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
6440 if(pEntry)
6441 {
6442 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6443 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
6444 {
6445 fRet = eANI_BOOLEAN_TRUE;
6446 }
6447 }
6448 if(eANI_BOOLEAN_FALSE == fRet)
6449 {
6450 csrLLLock(&pMac->sme.smeCmdPendingList);
6451 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
6452 while(pEntry)
6453 {
6454 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6455 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
6456 {
6457 fRet = eANI_BOOLEAN_TRUE;
6458 break;
6459 }
6460 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
6461 }
6462 csrLLUnlock(&pMac->sme.smeCmdPendingList);
6463 }
6464 csrLLUnlock( &pMac->sme.smeCmdActiveList );
6465
6466 return (fRet);
6467}
6468
6469
6470tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
6471{
6472 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
6473 tANI_U32 i;
6474
6475 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
6476 {
6477 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
6478 {
6479 break;
6480 }
6481 }
6482
6483 return ( fRet );
6484}
6485
6486
6487tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
6488{
6489 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
6490
6491 //alwasy lock active list before locking pending list
6492 csrLLLock( &pMac->sme.smeCmdActiveList );
6493 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
6494 if(eANI_BOOLEAN_FALSE == fRet)
6495 {
6496 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
6497 }
6498 csrLLUnlock( &pMac->sme.smeCmdActiveList );
6499
6500 return (fRet);
6501}
6502
6503
6504tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
6505{
6506 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
6507 tListElem *pEntry;
6508 tCsrCmd *pCommand;
6509
6510 //alwasy lock active list before locking pending list
6511 csrLLLock( &pMac->sme.smeCmdActiveList );
6512 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
6513 if( pEntry )
6514 {
6515 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
6516 if( ( eCsrRoamCommandScan == pCommand->command ) &&
6517 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
6518 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
6519 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
6520 {
6521 fRet = eANI_BOOLEAN_TRUE;
6522 }
6523 }
6524 csrLLUnlock( &pMac->sme.smeCmdActiveList );
6525
6526 return (fRet);
6527}
6528
6529eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
6530{
6531 eHalStatus status = eHAL_STATUS_SUCCESS;
6532 tSmeCmd *pCommand = NULL;
6533 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
6534 tANI_BOOLEAN fRemoveCmd = FALSE;
6535 tListElem *pEntry;
6536
6537 // Delete the old assoc command. All is setup for reassoc to be serialized
6538 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6539 if ( pEntry )
6540 {
6541 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6542 if ( !pCommand )
6543 {
6544 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
6545 return eHAL_STATUS_RESOURCES;
6546 }
6547 if ( eSmeCommandRoam == pCommand->command )
6548 {
6549 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
6550 {
6551 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
6552 }
6553 else
6554 {
6555 smsLog( pMac, LOGE, FL(" Unexpected active roam command present \n") );
6556 }
6557 if (fRemoveCmd == FALSE)
6558 {
6559 // Implies we did not get the serialized assoc command we
6560 // were expecting
6561 pCommand = NULL;
6562 }
6563 }
6564 }
6565
6566 if(NULL == pCommand)
6567 {
6568 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command\n") );
6569 return eHAL_STATUS_RESOURCES;
6570 }
6571
6572 do
6573 {
6574 //Change the substate in case it is wait-for-key
6575 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
6576 {
6577 csrRoamStopWaitForKeyTimer( pMac );
6578 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
6579 }
6580 pCommand->command = eSmeCommandRoam;
6581 pCommand->sessionId = (tANI_U8)sessionId;
6582 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
6583
6584 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6585 if( !HAL_STATUS_SUCCESS( status ) )
6586 {
6587 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
6588 csrReleaseCommandRoam( pMac, pCommand );
6589 }
6590 } while( 0 );
6591
6592
6593 return( status );
6594}
6595static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
6596{
6597 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
6598 tCsrScanResult *pScanResult = NULL;
6599 tSirBssDescription *pBssDesc = NULL;
6600 tSmeCmd *pCommand = NULL;
6601 tANI_U32 sessionId;
6602 tCsrRoamSession *pSession;
6603
6604 if(NULL == pEntry)
6605 {
6606 smsLog(pMac, LOGW, " CFG_CNF with active list empty\n");
6607 return;
6608 }
6609 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6610 sessionId = pCommand->sessionId;
6611 pSession = CSR_GET_SESSION( pMac, sessionId );
6612 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
6613 {
6614 //the roaming is cancelled. Simply complete the command
6615 smsLog(pMac, LOGW, FL(" Roam command cancelled\n"));
6616 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
6617 }
6618 else
6619 {
6620 if ( CCM_IS_RESULT_SUCCESS(result) )
6621 {
6622 smsLog(pMac, LOG2, "Cfg sequence complete\n");
6623 // Successfully set the configuration parameters for the new Bss. Attempt to
6624 // join the roaming Bss.
6625 if(pCommand->u.roamCmd.pRoamBssEntry)
6626 {
6627 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
6628 pBssDesc = &pScanResult->Result.BssDescriptor;
6629 }
6630 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
6631 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
6632#ifdef WLAN_SOFTAP_FEATURE
6633 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
6634#endif
6635 )
6636 {
6637 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
6638 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
6639 pBssDesc, pCommand->u.roamCmd.roamId )))
6640 {
6641 smsLog(pMac, LOGW, " CSR start BSS failed\n");
6642 //We need to complete the command
6643 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
6644 }
6645 }
6646 else
6647 {
6648 if (!pCommand->u.roamCmd.pRoamBssEntry)
6649 {
6650 smsLog(pMac, LOGW, " pRoamBssEntry is NULL\n");
6651 //We need to complete the command
6652 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
6653 return;
6654 }
6655 // If we are roaming TO an Infrastructure BSS...
6656 VOS_ASSERT(pScanResult != NULL);
6657 if ( csrIsInfraBssDesc( pBssDesc ) )
6658 {
6659 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
6660
6661 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
6662 {
6663 // ..and currently in an Infrastructure connection....
6664 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
6665 {
6666 // ...and the SSIDs are equal, then we Reassoc.
6667 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
6668 pIesLocal ) )
6669 // ..and currently in an infrastructure connection
6670 {
6671 // then issue a Reassoc.
6672 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
6673 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
6674 &pCommand->u.roamCmd.roamProfile );
6675 }
6676 else
6677 {
6678
6679 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
6680 // previously associated AP.
6681 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
6682 pIesLocal,
6683 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
6684 {
6685 //try something else
6686 csrRoam( pMac, pCommand );
6687 }
6688 }
6689 }
6690 else
6691 {
6692 eHalStatus status = eHAL_STATUS_SUCCESS;
6693
6694 /* We need to come with other way to figure out that this is because of HO in BMP
6695 The below API will be only available for Android as it uses a different HO algorithm */
6696 /* Reassoc request will be used only for CCX and 11r handoff whereas other legacy roaming should
6697 * use join request */
6698#ifdef WLAN_FEATURE_VOWIFI_11R
6699 if (csrRoamIsHandoffInProgress(pMac) &&
6700 csrRoamIs11rAssoc(pMac))
6701 {
6702 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
6703 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
6704 }
6705 else
6706#endif
6707
6708#ifdef FEATURE_WLAN_CCX
6709 if (csrRoamIsHandoffInProgress(pMac) &&
6710 csrRoamIsCCXAssoc(pMac))
6711 {
6712 // Now serialize the reassoc command.
6713 status = csrRoamIssueReassociateCmd(pMac, sessionId);
6714 }
6715 else
6716#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006717#ifdef FEATURE_WLAN_LFR
6718 if (csrRoamIsHandoffInProgress(pMac) &&
6719 csrRoamIsFastRoamEnabled(pMac))
6720 {
6721 // Now serialize the reassoc command.
6722 status = csrRoamIssueReassociateCmd(pMac, sessionId);
6723 }
6724 else
6725#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006726 // else we are not connected and attempting to Join. Issue the
6727 // Join request.
6728 {
6729 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
6730 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
6731 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
6732 }
6733 if(!HAL_STATUS_SUCCESS(status))
6734 {
6735 //try something else
6736 csrRoam( pMac, pCommand );
6737 }
6738 }
6739 if( !pScanResult->Result.pvIes )
6740 {
6741 //Locally allocated
6742 palFreeMemory(pMac->hHdd, pIesLocal);
6743 }
6744 }
6745 }//if ( csrIsInfraBssDesc( pBssDesc ) )
6746 else
6747 {
6748 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description\n"));
6749 }
6750 }//else
6751 }//if ( WNI_CFG_SUCCESS == result )
6752 else
6753 {
6754 // In the event the configuration failed, for infra let the roam processor
6755 //attempt to join something else...
6756 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
6757 {
6758 csrRoam(pMac, pCommand);
6759 }
6760 else
6761 {
6762 //We need to complete the command
6763 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
6764 {
6765 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
6766 }
6767 else
6768 {
6769 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6770 }
6771 }
6772 }
6773 }//we have active entry
6774}
6775
6776
6777static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
6778{
6779 //No one is sending eWNI_SME_AUTH_REQ to PE.
6780 smsLog(pMac, LOGW, FL("is no-op\n"));
6781 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
6782 {
6783 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful\n" );
6784 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
6785 // join the new one...
6786 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
6787
6788 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
6789 }
6790 else {
6791 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08lX [%d]\n", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
6792 /***profHandleLostLinkAfterReset(pAdapter);
6793 // In the event the authenticate fails, let the roam processor attempt to join something else...
6794 roamRoam( pAdapter );***/
6795 }
6796}
6797
6798
6799static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
6800{
6801 eCsrRoamCompleteResult result;
6802 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
6803 tCsrRoamInfo roamInfo;
6804 tANI_U32 roamId = 0;
6805
6806 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
6807 {
6808 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful\n" );
6809 result = eCsrReassocSuccess;
6810
6811 /* Defeaturize this part later if needed */
6812#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
6813 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
6814 * we need the response contents while processing the result in csrRoamProcessResults() */
6815 if (csrRoamIsHandoffInProgress(pMac))
6816 {
6817 /* Need to dig more on indicating events to SME QoS module */
6818 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
6819 csrRoamComplete( pMac, result, pSmeJoinRsp);
6820 }
6821 else
6822#endif
6823 {
6824 csrRoamComplete( pMac, result, NULL );
6825 }
6826 }
6827 /* Should we handle this similar to handling the join failure? Is it ok
6828 * to call csrRoamComplete() with state as CsrJoinFailure */
6829 else
6830 {
6831 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08lX [%d]\n", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
6832 result = eCsrReassocFailure;
6833#ifdef WLAN_FEATURE_VOWIFI_11R
6834 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
6835 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode))
6836 {
6837 // Inform HDD to turn off FT flag in HDD
6838 if (pNeighborRoamInfo)
6839 {
6840 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
6841 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
6842 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
6843 }
6844 }
6845#endif
6846 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
6847 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
6848 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
6849 //The disassoc rsp message will remove the command from active list
6850 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
6851 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
6852 {
6853 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
6854 }
6855 }
6856}
6857
6858
6859static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
6860{
6861
6862#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
6863 {
6864 vos_log_ibss_pkt_type *pIbssLog;
6865
6866 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
6867 if(pIbssLog)
6868 {
6869 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
6870 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
6871 {
6872 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
6873 }
6874 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
6875 }
6876 }
6877#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
6878
6879 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
6880 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
6881 {
6882 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6883 }
6884 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
6885 {
6886 csrRoamReissueRoamCommand(pMac);
6887 }
6888}
6889
6890
6891void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
6892{
6893 tSirResultCodes statusCode;
6894#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
6895 tScanResultHandle hBSSList;
6896 tANI_BOOLEAN fCallCallback, fRemoveCmd;
6897 eHalStatus status;
6898 tCsrRoamInfo roamInfo;
6899 tCsrScanResultFilter *pScanFilter = NULL;
6900 tANI_U32 roamId = 0;
6901 tCsrRoamProfile *pCurRoamProfile = NULL;
6902 tListElem *pEntry = NULL;
6903 tSmeCmd *pCommand = NULL;
6904#endif
6905 tANI_U32 sessionId;
6906 tCsrRoamSession *pSession;
6907 tSirSmeDisassocRsp SmeDisassocRsp;
6908
6909 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
6910 sessionId = SmeDisassocRsp.sessionId;
6911 statusCode = SmeDisassocRsp.statusCode;
6912
6913 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d\n", sessionId);
6914
6915 if ( csrIsConnStateInfra( pMac, sessionId ) )
6916 {
6917 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
6918 }
6919
6920 pSession = CSR_GET_SESSION( pMac, sessionId );
6921 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
6922 {
6923 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6924 }
6925 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
6926 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
6927 {
6928 if ( eSIR_SME_SUCCESS == statusCode )
6929 {
6930 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully\n" );
6931 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
6932 }
6933 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6934 }
6935
6936 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
6937 {
6938 smsLog( pMac, LOGE, "CSR SmeDisassocReq due to HO\n" );
6939#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
6940 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6941 if ( pEntry )
6942 {
6943 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6944
6945 // If the head of the queue is Active and it is a ROAM command, remove
6946 // and put this on the Free queue.
6947 if ( eSmeCommandRoam == pCommand->command )
6948 {
6949 //we need to process the result first before removing it from active list because state changes
6950 //still happening insides roamQProcessRoamResults so no other roam command should be issued
6951 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
6952 if(pCommand->u.roamCmd.fReleaseProfile)
6953 {
6954 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
6955 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6956 }
6957
6958 if( fRemoveCmd )
6959 {
6960 csrReleaseCommandRoam( pMac, pCommand );
6961 }
6962 else
6963 {
6964 smsLog( pMac, LOGE, " ********csrRoamRoamingStateDisassocRspProcessor fail to remove cmd reason %d\n",
6965 pCommand->u.roamCmd.roamReason );
6966 }
6967 }
6968 else
6969 {
6970 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ...\n" );
6971 }
6972 }
6973 else
6974 {
6975 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ...\n" );
6976 }
6977
6978 //notify HDD for handoff, providing the BSSID too
6979 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
6980
6981 palCopyMemory(pMac->hHdd, roamInfo.bssid, pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid, sizeof(tSirMacAddr));
6982
6983 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
6984
6985 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
6986 if(HAL_STATUS_SUCCESS(status))
6987 {
6988 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
6989 status = csrRoamPrepareFilterFromProfile(pMac, &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
6990 if(!HAL_STATUS_SUCCESS(status))
6991 {
6992 smsLog(pMac, LOGE, FL(" csrRoamPrepareFilterFromProfile fail to create scan filter\n"));
6993 }
6994
6995 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6996 if(HAL_STATUS_SUCCESS(status))
6997 {
6998 //copy over the connected profile to apply the same for this connection as well
6999 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pCurRoamProfile, sizeof(tCsrRoamProfile))))
7000 {
7001 palZeroMemory(pMac->hHdd, pCurRoamProfile, sizeof(tCsrRoamProfile));
7002 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
7003 }
7004 //make sure to put it at the head of the cmd queue
7005 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
7006 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
7007 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
7008 if(!HAL_STATUS_SUCCESS(status))
7009 {
7010 //msg
7011 fCallCallback = eANI_BOOLEAN_TRUE;
7012 }
7013 /* Notify sub-modules like QoS etc. that handoff happening */
7014 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
7015 palFreeMemory(pMac->hHdd, pCurRoamProfile);
7016 }
7017 else
7018 {
7019 //msg
7020 smsLog( pMac, LOGE,"csrRoamRoamingStateDisassocRspProcessor: csrScanGetResult failed");
7021 // should have asserted, sending up roam complete instead. Let upper layer
7022 // decide what to do next
7023 csrCallRoamingCompletionCallback(pMac, pSession, &roamInfo, 0, eCSR_ROAM_RESULT_FAILURE);
7024 }
7025 }
7026 else
7027 {
7028 smsLog(pMac, LOGE, FL(" fail to allocate memory for scan filter\n"));
7029 csrCallRoamingCompletionCallback(pMac, pSession, &roamInfo, 0, eCSR_ROAM_RESULT_FAILURE);
7030 }
7031 if( pScanFilter )
7032 {
7033 csrFreeScanFilter(pMac, pScanFilter);
7034 palFreeMemory( pMac->hHdd, pScanFilter );
7035 }
7036
7037
7038#endif
7039 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
7040 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
7041 {
7042 // Disassoc due to Reassoc failure falls into this codepath....
7043 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7044 }
7045 else
7046 {
7047 if ( eSIR_SME_SUCCESS == statusCode )
7048 {
7049 // Successfully disassociated from the 'old' Bss...
7050 //
7051 // We get Disassociate response in three conditions.
7052 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
7053 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
7054 // Infrastructure network.
7055 // - Third is where we are doing an Infra to Infra roam between networks with different
7056 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
7057
7058 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully\n" );
7059 }
7060 else
7061 {
7062 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08lX\n", statusCode );
7063 }
7064 //We are not done yet. Get the data and continue roaming
7065 csrRoamReissueRoamCommand(pMac);
7066 }
7067
7068}
7069
7070
7071static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
7072{
7073 tSirResultCodes statusCode;
7074
7075 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
7076 smsLog(pMac, LOGW, FL("is no-op\n"));
7077 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
7078 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
7079 {
7080 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7081 }
7082 else
7083 {
7084 if ( eSIR_SME_SUCCESS == statusCode )
7085 {
7086 // Successfully deauth from the 'old' Bss...
7087 //
7088 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully\n" );
7089 }
7090 else
7091 {
7092 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08lX\n", statusCode );
7093 }
7094 //We are not done yet. Get the data and continue roaming
7095 csrRoamReissueRoamCommand(pMac);
7096 }
7097}
7098
7099
7100static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
7101{
7102 eCsrRoamCompleteResult result;
7103
7104 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
7105 {
7106 smsLog( pMac, LOGW, "SmeStartBssReq Successful\n" );
7107 result = eCsrStartBssSuccess;
7108 }
7109 else
7110 {
7111 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08lX\n", pSmeStartBssRsp->statusCode );
7112 //Let csrRoamComplete decide what to do
7113 result = eCsrStartBssFailure;
7114 }
7115#ifdef WLAN_SOFTAP_FEATURE
7116 csrRoamComplete( pMac, result, pSmeStartBssRsp);
7117#else
7118 csrRoamComplete( pMac, result, &pSmeStartBssRsp->bssDescription );
7119#endif
7120}
7121
7122
7123/*
7124 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
7125 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
7126 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
7127 For the messages where sender allocates memory for specific structures, then it can be
7128 cast accordingly.
7129*/
7130void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
7131{
7132 tSirSmeRsp *pSmeRsp;
7133 tSmeIbssPeerInd *pIbssPeerInd;
7134 tCsrRoamInfo roamInfo;
7135 // TODO Session Id need to be acquired in this function
7136 tANI_U32 sessionId = 0;
7137
7138 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
7139
7140 smsLog( pMac, LOG2, "Message %d[0x%04X] received in substate %d\n",
7141 pSmeRsp->messageType, pSmeRsp->messageType,
7142 pMac->roam.curSubState[pSmeRsp->sessionId] );
7143#if defined ANI_PRODUCT_TYPE_AP
7144 pSmeRsp->messageType = pal_be16_to_cpu(pSmeRsp->messageType);
7145 pSmeRsp->length = pal_be16_to_cpu(pSmeRsp->length);
7146 pSmeRsp->statusCode = pal_be32_to_cpu(pSmeRsp->statusCode);
7147#else
7148 pSmeRsp->messageType = (pSmeRsp->messageType);
7149 pSmeRsp->length = (pSmeRsp->length);
7150 pSmeRsp->statusCode = (pSmeRsp->statusCode);
7151#endif
7152 switch (pSmeRsp->messageType)
7153 {
7154
7155 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
7156 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
7157 {
7158 //We sent a JOIN_REQ
7159 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
7160 }
7161 break;
7162
7163 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
7164 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
7165 {
7166 //We sent a AUTH_REQ
7167 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
7168 }
7169 break;
7170
7171 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
7172 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
7173 {
7174 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
7175 }
7176 break;
7177
7178 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
7179 {
7180 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
7181 }
7182 break;
7183
7184 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
7185 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
7186 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
7187 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
7188 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
7189 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
7190//HO
7191 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
7192 {
7193 smsLog(pMac, LOGE, FL("eWNI_SME_DISASSOC_RSP subState = %d\n"), pMac->roam.curSubState[pSmeRsp->sessionId]);
7194 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
7195 }
7196 break;
7197
7198 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
7199 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
7200 {
7201 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
7202 }
7203 break;
7204
7205 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
7206 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
7207 {
7208 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
7209 }
7210 break;
7211
7212 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
7213 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
7214 {
7215 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
7216 }
7217
7218 break;
7219
7220 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
7221 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
7222 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
7223 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state\n");
7224 palZeroMemory( pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo) );
7225 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
7226 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
7227 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
7228 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
7229 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
7230 eCSR_ROAM_CONNECT_STATUS_UPDATE,
7231 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
7232 break;
7233
7234 default:
7235 smsLog( pMac, LOG1, "Unexpected message type = %d[0x%X] received in substate %d\n",
7236 pSmeRsp->messageType, pSmeRsp->messageType,
7237 pMac->roam.curSubState[pSmeRsp->sessionId] );
7238
7239 //If we are connected, check the link status change
7240 if(!csrIsConnStateDisconnected(pMac, sessionId))
7241 {
7242 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
7243 }
7244 break;
7245 }
7246}
7247
7248
7249void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
7250{
7251 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
7252
7253 switch (pSirMsg->messageType)
7254 {
7255 case eWNI_SME_GET_STATISTICS_RSP:
7256 smsLog( pMac, LOGW, FL("Stats rsp from PE\n"));
7257 csrRoamStatsRspProcessor( pMac, pSirMsg );
7258 break;
7259#ifdef WLAN_SOFTAP_FEATURE
7260 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
7261 {
7262 tCsrRoamSession *pSession;
7263 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
7264 tCsrRoamInfo roamInfo;
7265 tCsrRoamInfo *pRoamInfo = NULL;
7266 tANI_U32 sessionId;
7267 eHalStatus status;
7268
7269 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer \n"));
7270
7271 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
7272 pRoamInfo = &roamInfo;
7273
7274 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
7275 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
7276 pSession = CSR_GET_SESSION(pMac, sessionId);
7277
7278 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
7279 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
7280
7281 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
7282 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
7283 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
7284
7285 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
7286 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
7287
7288 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr, sizeof(tSirMacAddr));
7289 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pUpperLayerAssocCnf->bssId, sizeof(tCsrBssid));
7290
7291 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
7292
7293 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
7294 {
7295 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
7296 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
7297 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
7298 }
7299 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
7300 {
7301 vos_sleep( 100 );
7302 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
7303 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
7304 }
7305
7306
7307 }
7308 break;
7309#endif
7310
7311 default:
7312 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
7313 break;
7314 }
7315
7316}
7317
7318
7319eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
7320 tSirBssDescription *pBssDescription,
7321 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
7322 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
7323 tANI_U8 keyId, tANI_U16 keyLength,
7324 tANI_U8 *pKey, tANI_U8 paeRole )
7325{
7326 eHalStatus status = eHAL_STATUS_SUCCESS;
7327 tAniEdType edType;
7328
7329 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
7330 {
7331 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
7332 }
7333
7334 edType = csrTranslateEncryptTypeToEdType( EncryptType );
7335
7336 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
7337 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
7338 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
7339 addKey )
7340 {
7341 tCsrRoamSetKey setKey;
7342
7343 setKey.encType = EncryptType;
7344 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
7345 palCopyMemory( pMac->hHdd, &setKey.peerMac, bssId, sizeof(tCsrBssid) );
7346 setKey.paeRole = paeRole; //0 for supplicant
7347 setKey.keyId = keyId; // Kye index
7348 setKey.keyLength = keyLength;
7349 if( keyLength )
7350 {
7351 palCopyMemory( pMac->hHdd, setKey.Key, pKey, keyLength );
7352 }
7353 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
7354 }
7355
7356 return (status);
7357}
7358
7359
7360static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
7361 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
7362{
7363 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
7364 tSmeCmd *pCommand = NULL;
7365#ifdef FEATURE_WLAN_CCX
7366 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7367#endif /* FEATURE_WLAN_CCX */
7368
7369 do
7370 {
7371 pCommand = csrGetCommandBuffer(pMac);
7372 if(NULL == pCommand)
7373 {
7374 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
7375 status = eHAL_STATUS_RESOURCES;
7376 break;
7377 }
7378 pCommand->command = eSmeCommandSetKey;
7379 pCommand->sessionId = (tANI_U8)sessionId;
7380 // validate the key length, Adjust if too long...
7381 // for static WEP the keys are not set thru' SetContextReq
7382 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
7383 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
7384 {
7385 //KeyLength maybe 0 for static WEP
7386 if( pSetKey->keyLength )
7387 {
7388 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
7389 {
7390 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7391 break;
7392 }
7393
7394 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
7395 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WEP40_KEY_LEN );
7396 }
7397 }
7398 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
7399 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
7400 {
7401 //KeyLength maybe 0 for static WEP
7402 if( pSetKey->keyLength )
7403 {
7404 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
7405 {
7406 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7407 break;
7408 }
7409
7410 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
7411 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WEP104_KEY_LEN );
7412 }
7413 }
7414 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
7415 {
7416 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
7417 {
7418 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7419 break;
7420 }
7421 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
7422 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_TKIP_KEY_LEN );
7423 }
7424 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
7425 {
7426 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
7427 {
7428 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7429 break;
7430 }
7431 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
7432 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN );
7433 }
7434#ifdef FEATURE_WLAN_WAPI
7435 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
7436 {
7437 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
7438 {
7439 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7440 break;
7441 }
7442 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
7443 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WAPI_KEY_LEN );
7444 }
7445#endif /* FEATURE_WLAN_WAPI */
7446#ifdef FEATURE_WLAN_CCX
7447 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
7448 {
7449 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
7450 {
7451 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7452 break;
7453 }
7454 palCopyMemory( pMac->hHdd, pSession->ccxCckmInfo.krk, pSetKey->Key, CSR_KRK_KEY_LEN );
7455 pSession->ccxCckmInfo.reassoc_req_num=1;
7456 pSession->ccxCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
7457 status = eHAL_STATUS_SUCCESS;
7458 break;
7459 }
7460#endif /* FEATURE_WLAN_CCX */
7461#ifdef WLAN_FEATURE_11W
7462 //Check for 11w BIP
7463 else if ( eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType )
7464 {
7465 tANI_U16 count = 0;
7466 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
7467 {
7468 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7469 break;
7470 }
7471 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
7472 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN );
7473 }
7474#endif
7475 status = eHAL_STATUS_SUCCESS;
7476 pCommand->u.setKeyCmd.roamId = roamId;
7477 pCommand->u.setKeyCmd.encType = pSetKey->encType;
7478 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
7479 palCopyMemory( pMac->hHdd, &pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac, sizeof(tCsrBssid) );
7480 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
7481 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
7482 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN );
7483 //Always put set key to the head of the Q because it is the only thing to get executed in case of WT_KEY state
7484
7485 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
7486 if( !HAL_STATUS_SUCCESS( status ) )
7487 {
7488 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
7489 }
7490 } while (0);
7491
7492 // Free the command if there has been a failure, or it is a
7493 // "local" operation like the set CCX CCKM KRK key.
7494 if( (!HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ))
7495#ifdef FEATURE_WLAN_CCX
7496 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
7497#endif /* FEATURE_WLAN_CCX */
7498 )
7499 {
7500 csrReleaseCommandSetKey( pMac, pCommand );
7501 }
7502
7503 return( status );
7504}
7505
7506
7507eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
7508 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
7509{
7510 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
7511 tSmeCmd *pCommand = NULL;
7512 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
7513
7514 do
7515 {
7516 if( !csrIsSetKeyAllowed(pMac, sessionId) )
7517 {
7518 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key\n") );
7519 status = eHAL_STATUS_CSR_WRONG_STATE;
7520 break;
7521 }
7522 pCommand = csrGetCommandBuffer(pMac);
7523 if(NULL == pCommand)
7524 {
7525 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
7526 status = eHAL_STATUS_RESOURCES;
7527 break;
7528 }
7529 pCommand->command = eSmeCommandRemoveKey;
7530 pCommand->sessionId = (tANI_U8)sessionId;
7531 pCommand->u.removeKeyCmd.roamId = roamId;
7532 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
7533 palCopyMemory( pMac->hHdd, &pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac, sizeof(tSirMacAddr) );
7534 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
7535 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7536 {
7537 //in this case, put it to the end of the Q incase there is a set key pending.
7538 fImediate = eANI_BOOLEAN_FALSE;
7539 }
7540
7541 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac=%02x, %02x, %02x, %02x, %02x, %02x\n"),
7542 pRemoveKey->encType, pRemoveKey->keyId,
7543 pCommand->u.removeKeyCmd.peerMac[0],
7544 pCommand->u.removeKeyCmd.peerMac[1],
7545 pCommand->u.removeKeyCmd.peerMac[2],
7546 pCommand->u.removeKeyCmd.peerMac[3],
7547 pCommand->u.removeKeyCmd.peerMac[4],
7548 pCommand->u.removeKeyCmd.peerMac[5]);
7549
7550 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
7551 if( !HAL_STATUS_SUCCESS( status ) )
7552 {
7553 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
7554 break;
7555 }
7556 } while (0);
7557
7558 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
7559 {
7560 csrReleaseCommandRemoveKey( pMac, pCommand );
7561 }
7562
7563 return (status );
7564}
7565
7566
7567eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
7568{
7569 eHalStatus status;
7570 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
7571 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
7572 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
7573 tANI_U32 sessionId = pCommand->sessionId;
7574
7575#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7576 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7577 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
7578
7579 if(eCSR_ENCRYPT_TYPE_NONE != edType)
7580 {
7581 palZeroMemory(pMac->hHdd, &setKeyEvent, sizeof(vos_event_wlan_security_payload_type));
7582 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
7583 {
7584 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
7585 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
7586 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
7587 }
7588 else
7589 {
7590 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
7591 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
7592 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
7593 }
7594 palCopyMemory( pMac->hHdd, setKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
7595 if(CSR_IS_ENC_TYPE_STATIC(edType))
7596 {
7597 tANI_U32 defKeyId;
7598
7599 //It has to be static WEP here
7600 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
7601 {
7602 setKeyEvent.keyId = (v_U8_t)defKeyId;
7603 }
7604 }
7605 else
7606 {
7607 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
7608 }
7609 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
7610 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
7611 }
7612#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
7613
7614 if( csrIsSetKeyAllowed(pMac, sessionId) )
7615 {
7616 status = csrSendMBSetContextReqMsg( pMac, sessionId,
7617 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
7618 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
7619 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
7620 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
7621 pCommand->u.setKeyCmd.keyRsc);
7622 }
7623 else
7624 {
7625 smsLog( pMac, LOGW, FL(" cannot process not connected\n") );
7626 //Set this status so the error handling take care of the case.
7627 status = eHAL_STATUS_CSR_WRONG_STATE;
7628 }
7629 if( !HAL_STATUS_SUCCESS(status) )
7630 {
7631 smsLog( pMac, LOGE, FL(" error status %d\n"), status );
7632 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
7633
7634#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7635 if(eCSR_ENCRYPT_TYPE_NONE != edType)
7636 {
7637 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
7638 {
7639 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
7640 }
7641 else
7642 {
7643 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
7644 }
7645 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
7646 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
7647 }
7648#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
7649
7650 }
7651
7652 return ( status );
7653}
7654
7655
7656eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
7657{
7658 eHalStatus status;
7659 tpSirSmeRemoveKeyReq pMsg = NULL;
7660 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
7661 tANI_U8 *p;
7662 tANI_U32 sessionId = pCommand->sessionId;
7663
7664#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7665 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7666 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
7667
7668 palZeroMemory(pMac->hHdd, &removeKeyEvent, sizeof(vos_event_wlan_security_payload_type));
7669 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
7670 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
7671 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
7672 palCopyMemory( pMac->hHdd, removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
7673 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
7674 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
7675 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
7676#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
7677
7678 if( csrIsSetKeyAllowed(pMac, sessionId) )
7679 {
7680 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, wMsgLen );
7681 }
7682 else
7683 {
7684 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key\n") );
7685 //Set the error status so error handling kicks in below
7686 status = eHAL_STATUS_CSR_WRONG_STATE;
7687 }
7688 if( HAL_STATUS_SUCCESS( status ) )
7689 {
7690 palZeroMemory(pMac->hHdd, pMsg, wMsgLen);
7691 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
7692 pMsg->length = pal_cpu_to_be16(wMsgLen);
7693
7694 pMsg->sessionId = (tANI_U8)sessionId;
7695 pMsg->transactionId = 0;
7696 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
7697 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
7698 // bssId - copy from session Info
7699 palCopyMemory( pMac->hHdd, p, &pMac->roam.roamSession[sessionId].connectedProfile.bssid, sizeof(tSirMacAddr) );
7700 p += sizeof(tSirMacAddr);
7701 // peerMacAddr
7702 palCopyMemory( pMac->hHdd, p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr) );
7703 p += sizeof(tSirMacAddr);
7704 // edType
7705 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
7706 p++;
7707 // weptype
7708 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
7709 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
7710 {
7711 *p = (tANI_U8)eSIR_WEP_STATIC;
7712 }
7713 else
7714 {
7715 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
7716 }
7717 p++;
7718 //keyid
7719 *p = pCommand->u.removeKeyCmd.keyId;
7720 p++;
7721 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
7722
7723 status = palSendMBMessage(pMac->hHdd, pMsg);
7724 }
7725
7726 if( !HAL_STATUS_SUCCESS( status ) )
7727 {
7728 smsLog( pMac, LOGE, FL(" error status \n"), status );
7729
7730#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7731 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
7732 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;;
7733 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
7734#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
7735
7736 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
7737 }
7738
7739 return ( status );
7740}
7741
7742
7743
7744eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
7745{
7746 eHalStatus status;
7747
7748 if( !csrIsSetKeyAllowed(pMac, sessionId) )
7749 {
7750 status = eHAL_STATUS_CSR_WRONG_STATE;
7751 }
7752 else
7753 {
7754 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
7755 }
7756
7757 return ( status );
7758}
7759
7760
7761/*
7762 Prepare a filter base on a profile for parsing the scan results.
7763 Upon successful return, caller MUST call csrFreeScanFilter on
7764 pScanFilter when it is done with the filter.
7765*/
7766eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
7767 tCsrScanResultFilter *pScanFilter)
7768{
7769 eHalStatus status = eHAL_STATUS_SUCCESS;
7770 tANI_U32 size = 0;
7771 tANI_U8 index = 0;
7772
7773 do
7774 {
7775 if(pProfile->BSSIDs.numOfBSSIDs)
7776 {
7777 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
7778 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->BSSIDs.bssid, size);
7779 if(!HAL_STATUS_SUCCESS(status))
7780 {
7781 break;
7782 }
7783 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
7784 palCopyMemory(pMac->hHdd, pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
7785 }
7786 if(pProfile->SSIDs.numOfSSIDs)
7787 {
7788 if( !CSR_IS_WDS_STA( pProfile ) )
7789 {
7790 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
7791 }
7792 else
7793 {
7794 //For WDS station
7795 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
7796 pScanFilter->SSIDs.numOfSSIDs = 1;
7797 }
7798 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
7799 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->SSIDs.SSIDList, size);
7800 if(!HAL_STATUS_SUCCESS(status))
7801 {
7802 break;
7803 }
7804 palCopyMemory(pMac->hHdd, pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList, size);
7805 }
7806 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
7807 {
7808 pScanFilter->ChannelInfo.numOfChannels = 0;
7809 pScanFilter->ChannelInfo.ChannelList = NULL;
7810 }
7811 else if(pProfile->ChannelInfo.numOfChannels)
7812 {
7813 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->ChannelInfo.ChannelList, sizeof(*pScanFilter->ChannelInfo.ChannelList) * pProfile->ChannelInfo.numOfChannels);
7814 pScanFilter->ChannelInfo.numOfChannels = 0;
7815 if(HAL_STATUS_SUCCESS(status))
7816 {
7817 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
7818 {
7819 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
7820 {
7821 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
7822 = pProfile->ChannelInfo.ChannelList[index];
7823 pScanFilter->ChannelInfo.numOfChannels++;
7824 }
7825 else
7826 {
7827 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid\n"), pProfile->ChannelInfo.ChannelList[index]);
7828 }
7829
7830 }
7831 }
7832 else
7833 {
7834 break;
7835 }
7836
7837 }
7838 else
7839 {
7840 smsLog(pMac, LOGW, FL("Channel list empty\n"));
7841 status = eHAL_STATUS_FAILURE;
7842 break;
7843 }
7844 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
7845 pScanFilter->authType = pProfile->AuthType;
7846 pScanFilter->EncryptionType = pProfile->EncryptionType;
7847 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
7848 pScanFilter->BSSType = pProfile->BSSType;
7849 pScanFilter->phyMode = pProfile->phyMode;
7850#ifdef FEATURE_WLAN_WAPI
7851 //check if user asked for WAPI with 11n or auto mode, in that case modify
7852 //the phymode to 11g
7853 if(csrIsProfileWapi(pProfile))
7854 {
7855 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
7856 {
7857 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
7858 }
7859 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
7860 {
7861 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
7862 }
7863 if(!pScanFilter->phyMode)
7864 {
7865 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
7866 }
7867 }
7868#endif /* FEATURE_WLAN_WAPI */
7869
7870 /*Save the WPS info*/
7871 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
7872
7873 if( pProfile->countryCode[0] )
7874 {
7875 //This causes the matching function to use countryCode as one of the criteria.
7876 palCopyMemory( pMac->hHdd, pScanFilter->countryCode, pProfile->countryCode,
7877 WNI_CFG_COUNTRY_CODE_LEN );
7878 }
7879#ifdef WLAN_FEATURE_VOWIFI_11R
7880 if (pProfile->MDID.mdiePresent)
7881 {
7882 pScanFilter->MDID.mdiePresent = 1;
7883 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
7884 }
7885#endif
7886
7887 }while(0);
7888
7889 if(!HAL_STATUS_SUCCESS(status))
7890 {
7891 csrFreeScanFilter(pMac, pScanFilter);
7892 }
7893
7894 return(status);
7895}
7896
7897
7898tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
7899 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
7900{
7901 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
7902 tSmeCmd *pCommand;
7903
7904 do
7905 {
7906 // Validate the type is ok...
7907 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
7908 pCommand = csrGetCommandBuffer( pMac );
7909 if ( !pCommand )
7910 {
7911 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
7912 break;
7913 }
7914 //Change the substate in case it is waiting for key
7915 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7916 {
7917 csrRoamStopWaitForKeyTimer( pMac );
7918 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7919 }
7920 pCommand->command = eSmeCommandWmStatusChange;
7921 pCommand->sessionId = (tANI_U8)sessionId;
7922 pCommand->u.wmStatusChangeCmd.Type = Type;
7923 if ( eCsrDisassociated == Type )
7924 {
7925 palCopyMemory( pMac->hHdd, &pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg, pSmeRsp,
7926 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ) );
7927 }
7928 else
7929 {
7930 palCopyMemory( pMac->hHdd, &pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg, pSmeRsp,
7931 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ) );
7932 }
7933 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
7934 {
7935 fCommandQueued = eANI_BOOLEAN_TRUE;
7936 }
7937 else
7938 {
7939 smsLog( pMac, LOGE, FL(" fail to send message \n") );
7940 csrReleaseCommandWmStatusChange( pMac, pCommand );
7941 }
7942
7943
7944 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
7945 csrSetDefaultDot11Mode( pMac );
7946
7947 } while( 0 );
7948
7949 return( fCommandQueued );
7950}
7951
7952
7953static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
7954{
7955 v_S7_t rssi = 0;
7956 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
7957 if(pGetRssiReq)
7958 {
7959 if(NULL != pGetRssiReq->pVosContext)
7960 {
7961 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
7962 }
7963 else
7964 {
7965 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL\n"));
7966 return;
7967 }
7968
7969 if(NULL != pGetRssiReq->rssiCallback)
7970 {
7971 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
7972 }
7973 else
7974 {
7975 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL\n"));
7976 return;
7977 }
7978 }
7979 else
7980 {
7981 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL\n"));
7982 }
7983 return;
7984}
7985
7986void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
7987{
7988 tSirSmeAssocInd *pAssocInd;
7989 tSirSmeDisassocInd *pDisassocInd;
7990 tSirSmeDeauthInd *pDeauthInd;
7991 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
7992 tSirSmeNewBssInfo *pNewBss;
7993 tSmeIbssPeerInd *pIbssPeerInd;
7994 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
7995 tSirSmeApNewCaps *pApNewCaps;
7996 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
7997 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
7998 tCsrRoamInfo *pRoamInfo = NULL;
7999 tCsrRoamInfo roamInfo;
8000 eHalStatus status;
8001 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
8002 tCsrRoamSession *pSession = NULL;
8003 tpSirSmeSwitchChannelInd pSwitchChnInd;
8004 tSmeMaxAssocInd *pSmeMaxAssocInd;
8005
8006#if defined ANI_PRODUCT_TYPE_AP
8007 pSirMsg->messageType = pal_be16_to_cpu(pSirMsg->messageType);
8008 pSirMsg->length = pal_be16_to_cpu(pSirMsg->length);
8009 pSirMsg->statusCode = pal_be32_to_cpu(pSirMsg->statusCode);
8010#else
8011 pSirMsg->messageType = (pSirMsg->messageType);
8012 pSirMsg->length = (pSirMsg->length);
8013 pSirMsg->statusCode = (pSirMsg->statusCode);
8014#endif
8015
8016 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
8017
8018 switch( pSirMsg->messageType )
8019 {
8020 case eWNI_SME_ASSOC_IND:
8021 {
8022 tCsrRoamSession *pSession;
8023 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME\n"));
8024 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
8025 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
8026 if( HAL_STATUS_SUCCESS( status ) )
8027 {
8028 pSession = CSR_GET_SESSION(pMac, sessionId);
8029
8030 pRoamInfo = &roamInfo;
8031
8032 // Required for indicating the frames to upper layer
8033 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
8034 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
8035
8036 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
8037 pRoamInfo->beaconLength = pAssocInd->beaconLength;
8038 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8039 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8040
8041 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
8042 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
8043 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
8044
8045 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
8046 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
8047
8048 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
8049 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pAssocInd->bssId, sizeof(tCsrBssid));
8050#ifdef WLAN_SOFTAP_FEATURE
8051 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
8052 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8053#endif
8054 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
8055#ifdef WLAN_SOFTAP_FEATURE
8056 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
8057 {
8058 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
8059 {
8060 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
8061 pSession->pConnectBssDesc,
8062 &(pRoamInfo->peerMac),
8063 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
8064 pRoamInfo->fAuthRequired = FALSE;
8065 }
8066 else
8067 {
8068 pRoamInfo->fAuthRequired = TRUE;
8069 }
8070 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
8071 if (!HAL_STATUS_SUCCESS(status))
8072 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
8073 }
8074#endif
8075 /* Send Association completion message to PE */
8076 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
8077
8078 /* send a message to CSR itself just to avoid the EAPOL frames going
8079 * OTA before association response */
8080
8081 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8082 {
8083 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
8084 }
8085#ifdef WLAN_SOFTAP_FEATURE
8086 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
8087 {
8088 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
8089 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8090 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
8091 }
8092#endif
8093 }
8094 }
8095 break;
8096
8097 case eWNI_SME_DISASSOC_IND:
8098 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC\n"));
8099
8100 // Check if AP dis-associated us because of MIC failure. If so,
8101 // then we need to take action immediately and not wait till the
8102 // the WmStatusChange requests is pushed and processed
8103 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
8104 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDisassocInd->bssId, &sessionId );
8105 if( HAL_STATUS_SUCCESS( status ) )
8106 {
8107 // If we are in neighbor preauth done state then on receiving
8108 // disassoc or deauth we dont roam instead we just disassoc
8109 // from current ap and then go to disconnected state
8110 // This happens for CCX and 11r FT connections ONLY.
8111#ifdef WLAN_FEATURE_VOWIFI_11R
8112 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8113 {
8114 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8115 }
8116#endif
8117#ifdef FEATURE_WLAN_CCX
8118 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8119 {
8120 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8121 }
8122#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008123#ifdef FEATURE_WLAN_LFR
8124 if (csrRoamIsFastRoamEnabled(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8125 {
8126 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8127 }
8128#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008129 pSession = CSR_GET_SESSION( pMac, sessionId );
8130
8131 if ( csrIsConnStateInfra( pMac, sessionId ) )
8132 {
8133 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8134 }
8135
8136#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8137 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
8138#endif
8139 csrRoamLinkDown(pMac, sessionId);
8140 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
8141#ifdef WLAN_SOFTAP_FEATURE
8142 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
8143 {
8144
8145 pRoamInfo = &roamInfo;
8146
8147 pRoamInfo->statusCode = pDisassocInd->statusCode;
8148 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8149
8150 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
8151
8152 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDisassocInd->peerMacAddr, sizeof(tSirMacAddr));
8153 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pDisassocInd->bssId, sizeof(tCsrBssid));
8154
8155 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
8156 }
8157#endif
8158 }
8159 break;
8160
8161 case eWNI_SME_DEAUTH_IND:
8162 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC\n"));
8163 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
8164 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
8165 if( HAL_STATUS_SUCCESS( status ) )
8166 {
8167 // If we are in neighbor preauth done state then on receiving
8168 // disassoc or deauth we dont roam instead we just disassoc
8169 // from current ap and then go to disconnected state
8170 // This happens for CCX and 11r FT connections ONLY.
8171#ifdef WLAN_FEATURE_VOWIFI_11R
8172 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8173 {
8174 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8175 }
8176#endif
8177#ifdef FEATURE_WLAN_CCX
8178 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8179 {
8180 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8181 }
8182#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008183#ifdef FEATURE_WLAN_LFR
8184 if (csrRoamIsFastRoamEnabled(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8185 {
8186 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8187 }
8188#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008189 pSession = CSR_GET_SESSION( pMac, sessionId );
8190
8191 if ( csrIsConnStateInfra( pMac, sessionId ) )
8192 {
8193 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8194 }
8195
8196#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8197 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
8198#endif
8199 csrRoamLinkDown(pMac, sessionId);
8200 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
8201#ifdef WLAN_SOFTAP_FEATURE
8202 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
8203 {
8204
8205 pRoamInfo = &roamInfo;
8206
8207 pRoamInfo->statusCode = pDeauthInd->statusCode;
8208 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8209
8210 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
8211
8212 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDeauthInd->peerMacAddr, sizeof(tSirMacAddr));
8213 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pDeauthInd->bssId, sizeof(tCsrBssid));
8214
8215 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
8216 }
8217#endif
8218 }
8219 break;
8220
8221 case eWNI_SME_SWITCH_CHL_REQ: // in case of STA, the SWITCH_CHANNEL originates from its AP
8222 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME\n"));
8223 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
8224 //Update with the new channel id.
8225 //The channel id is hidden in the statusCode.
8226 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
8227 if( HAL_STATUS_SUCCESS( status ) )
8228 {
8229 pSession = CSR_GET_SESSION( pMac, sessionId );
8230 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
8231 if(pSession->pConnectBssDesc)
8232 {
8233 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
8234 }
8235 }
8236 break;
8237
8238 case eWNI_SME_DEAUTH_RSP:
8239 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME\n"));
8240#ifdef WLAN_SOFTAP_FEATURE
8241 {
8242 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
8243 sessionId = pDeauthRsp->sessionId;
8244 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
8245 {
8246 pSession = CSR_GET_SESSION(pMac, sessionId);
8247
8248 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
8249 {
8250 pRoamInfo = &roamInfo;
8251 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8252 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDeauthRsp->peerMacAddr, sizeof(tSirMacAddr));
8253 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
8254 pRoamInfo->statusCode = pDeauthRsp->statusCode;
8255 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
8256 }
8257 }
8258 }
8259#endif
8260 break;
8261
8262 case eWNI_SME_DISASSOC_RSP:
8263 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME subState = %d\n"), pMac->roam.curSubState[sessionId]);
8264#ifdef WLAN_SOFTAP_FEATURE
8265 {
8266 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
8267 sessionId = pDisassocRsp->sessionId;
8268 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
8269 {
8270 pSession = CSR_GET_SESSION(pMac, sessionId);
8271
8272 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
8273 {
8274 pRoamInfo = &roamInfo;
8275 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8276 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDisassocRsp->peerMacAddr, sizeof(tSirMacAddr));
8277 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
8278 pRoamInfo->statusCode = pDisassocRsp->statusCode;
8279 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
8280 }
8281 }
8282 }
8283#endif
8284 break;
8285
8286 case eWNI_SME_MIC_FAILURE_IND:
8287 {
8288 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
8289 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
8290 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
8291
8292#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8293 {
8294 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8295 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
8296 palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type));
8297 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
8298 secEvent.encryptionModeMulticast =
8299 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8300 secEvent.encryptionModeUnicast =
8301 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8302 secEvent.authMode =
8303 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8304 palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 );
8305 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
8306 }
8307#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
8308
8309 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
8310 if( HAL_STATUS_SUCCESS( status ) )
8311 {
8312 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
8313 roamInfo.u.pMICFailureInfo = &pMicInd->info;
8314 pRoamInfo = &roamInfo;
8315 if(pMicInd->info.multicast)
8316 {
8317 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
8318 }
8319 else
8320 {
8321 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
8322 }
8323 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
8324 }
8325 }
8326 break;
8327
8328#ifdef WLAN_SOFTAP_FEATURE
8329 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
8330 {
8331 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
8332 tCsrRoamInfo roamInfo;
8333
8334 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME\n"));
8335
8336 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
8337 if( HAL_STATUS_SUCCESS( status ) )
8338 {
8339 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
8340 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
8341 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
8342 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
8343 }
8344 }
8345 break;
8346#endif
8347
8348
8349 case eWNI_SME_WM_STATUS_CHANGE_NTF:
8350 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
8351 switch( pStatusChangeMsg->statusChangeCode )
8352 {
8353 case eSIR_SME_IBSS_ACTIVE:
8354 sessionId = csrFindIbssSession( pMac );
8355 if( CSR_SESSION_ID_INVALID != sessionId )
8356 {
8357 pSession = CSR_GET_SESSION( pMac, sessionId );
8358 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
8359 if(pSession->pConnectBssDesc)
8360 {
8361 palCopyMemory(pMac->hHdd, &roamInfo.bssid, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
8362 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
8363 pRoamInfo = &roamInfo;
8364 }
8365 else
8366 {
8367 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty\n");
8368 }
8369 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
8370 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
8371 }
8372 break;
8373
8374 case eSIR_SME_IBSS_INACTIVE:
8375 sessionId = csrFindIbssSession( pMac );
8376 if( CSR_SESSION_ID_INVALID != sessionId )
8377 {
8378 pSession = CSR_GET_SESSION( pMac, sessionId );
8379 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
8380 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
8381 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
8382 }
8383 break;
8384
8385 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
8386 sessionId = csrFindIbssSession( pMac );
8387 if( CSR_SESSION_ID_INVALID != sessionId )
8388 {
8389 pSession = CSR_GET_SESSION( pMac, sessionId );
8390 // update the connection state information
8391 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
8392
8393#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8394 {
8395 vos_log_ibss_pkt_type *pIbssLog;
8396 tANI_U32 bi;
8397
8398 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8399 if(pIbssLog)
8400 {
8401 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
8402 if(pNewBss)
8403 {
8404 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pNewBss->bssId, 6);
8405 if(pNewBss->ssId.length)
8406 {
8407 palCopyMemory(pMac->hHdd, pIbssLog->ssid, pNewBss->ssId.ssId, pNewBss->ssId.length);
8408 }
8409 pIbssLog->operatingChannel = pNewBss->channelNumber;
8410 }
8411 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
8412 {
8413 //***U8 is not enough for beacon interval
8414 pIbssLog->beaconInterval = (v_U8_t)bi;
8415 }
8416 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
8417 }
8418 }
8419#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
8420
8421 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
8422 csrRoamIssueSetContextReq( pMac, sessionId, pSession->connectedProfile.EncryptionType,
8423 pSession->pConnectBssDesc,
8424 &Broadcastaddr,
8425 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
8426 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
8427 roamStatus = eCSR_ROAM_IBSS_IND;
8428 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pNewBss->bssId, sizeof(tCsrBssid));
8429 pRoamInfo = &roamInfo;
8430 //This BSSID is th ereal BSSID, let's save it
8431 if(pSession->pConnectBssDesc)
8432 {
8433 palCopyMemory(pMac->hHdd, pSession->pConnectBssDesc->bssId, &pNewBss->bssId, sizeof(tCsrBssid));
8434 }
8435 // Stop the join IBSS timer in case of join, for
8436 // genuine merge do nothing
8437 if(pSession->ibss_join_pending)
8438 {
8439 pSession->ibss_join_pending = FALSE;
8440 csrRoamStopIbssJoinTimer(pMac, sessionId);
8441 result = eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS;
8442 }
8443 }
8444 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE\n");
8445 break;
8446
8447 // detection by LIM that the capabilities of the associated AP have changed.
8448 case eSIR_SME_AP_CAPS_CHANGED:
8449 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
8450 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED\n");
8451 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
8452 if( HAL_STATUS_SUCCESS( status ) )
8453 {
8454 csrScanForCapabilityChange( pMac, pApNewCaps );
8455 result = eCSR_ROAM_RESULT_CAP_CHANGED;
8456 roamStatus = eCSR_ROAM_GEN_INFO;
8457 }
8458 break;
8459
8460 default:
8461 roamStatus = eCSR_ROAM_FAILED;
8462 result = eCSR_ROAM_RESULT_NONE;
8463 break;
8464
8465 } // end switch on statusChangeCode
8466 if(eCSR_ROAM_RESULT_NONE != result)
8467 {
8468 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
8469 }
8470 break;
8471
8472 case eWNI_SME_IBSS_NEW_PEER_IND:
8473 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
8474
8475#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8476 {
8477 vos_log_ibss_pkt_type *pIbssLog;
8478
8479 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8480 if(pIbssLog)
8481 {
8482 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
8483 palCopyMemory(pMac->hHdd, pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
8484 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
8485 }
8486 }
8487#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
8488
8489 sessionId = csrFindIbssSession( pMac );
8490 if( CSR_SESSION_ID_INVALID != sessionId )
8491 {
8492 pSession = CSR_GET_SESSION( pMac, sessionId );
8493 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
8494 if(pSession->pConnectBssDesc)
8495 {
8496 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
8497 palCopyMemory(pMac->hHdd, &roamInfo.bssid, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
8498 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
8499 {
8500 status = palAllocateMemory(pMac->hHdd, (void **)&roamInfo.pbFrames,
8501 (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd)));
8502 if(HAL_STATUS_SUCCESS(status))
8503 {
8504 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
8505 palCopyMemory(pMac->hHdd, roamInfo.pbFrames, ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
8506 roamInfo.nBeaconLength);
8507 }
8508 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
8509 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8510 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
8511 status = palAllocateMemory(pMac->hHdd, (void **)&roamInfo.pBssDesc,
8512 pSession->pConnectBssDesc->length);
8513 if(HAL_STATUS_SUCCESS(status))
8514 {
8515 palCopyMemory(pMac->hHdd, roamInfo.pBssDesc, pSession->pConnectBssDesc,
8516 pSession->pConnectBssDesc->length);
8517 }
8518 if(HAL_STATUS_SUCCESS(status))
8519 {
8520 pRoamInfo = &roamInfo;
8521 }
8522 else
8523 {
8524 if(roamInfo.pbFrames)
8525 {
8526 palFreeMemory(pMac->hHdd, roamInfo.pbFrames);
8527 }
8528 if(roamInfo.pBssDesc)
8529 {
8530 palFreeMemory(pMac->hHdd, roamInfo.pBssDesc);
8531 }
8532 }
8533 }
8534 else
8535 {
8536 pRoamInfo = &roamInfo;
8537 }
8538 csrRoamIssueSetContextReq( pMac, sessionId, pSession->connectedProfile.EncryptionType,
8539 pSession->pConnectBssDesc,
8540 &(pIbssPeerInd->peerAddr),
8541 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
8542 }
8543 else
8544 {
8545 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty\n");
8546 }
8547 //send up the sec type for the new peer
8548 if (pRoamInfo)
8549 {
8550 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8551 }
8552 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
8553 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
8554 if(pRoamInfo)
8555 {
8556 if(roamInfo.pbFrames)
8557 {
8558 palFreeMemory(pMac->hHdd, roamInfo.pbFrames);
8559 }
8560 if(roamInfo.pBssDesc)
8561 {
8562 palFreeMemory(pMac->hHdd, roamInfo.pBssDesc);
8563 }
8564 }
8565 }
8566 break;
8567
8568 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
8569 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
8570 sessionId = csrFindIbssSession( pMac );
8571 if( CSR_SESSION_ID_INVALID != sessionId )
8572 {
8573
8574#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8575 {
8576 vos_log_ibss_pkt_type *pIbssLog;
8577
8578 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8579 if(pIbssLog)
8580 {
8581 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
8582 if(pIbssPeerInd)
8583 {
8584 palCopyMemory(pMac->hHdd, pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
8585 }
8586 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
8587 }
8588 }
8589#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
8590
8591 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM\n");
8592 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
8593 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8594 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
8595 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
8596 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
8597 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
8598 }
8599 break;
8600
8601 case eWNI_SME_SETCONTEXT_RSP:
8602 {
8603 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
8604 tListElem *pEntry;
8605 tSmeCmd *pCommand;
8606
8607 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
8608 if ( pEntry )
8609 {
8610 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
8611 if ( eSmeCommandSetKey == pCommand->command )
8612 {
8613 sessionId = pCommand->sessionId;
8614 pSession = CSR_GET_SESSION( pMac, sessionId );
8615
8616#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8617 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
8618 {
8619 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
8620 palZeroMemory(pMac->hHdd, &setKeyEvent, sizeof(vos_event_wlan_security_payload_type));
8621 if( pRsp->peerMacAddr[0] & 0x01 )
8622 {
8623 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8624 }
8625 else
8626 {
8627 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8628 }
8629 setKeyEvent.encryptionModeMulticast =
8630 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8631 setKeyEvent.encryptionModeUnicast =
8632 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8633 palCopyMemory( pMac->hHdd, setKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
8634 setKeyEvent.authMode =
8635 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8636 if( eSIR_SUCCESS != pRsp->statusCode )
8637 {
8638 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8639 }
8640 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8641 }
8642#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
8643 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
8644 {
8645 //We are done with authentication, whethere succeed or not
8646 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
8647
8648 csrRoamStopWaitForKeyTimer( pMac );
8649 //We do it here because this linkup function is not called after association
8650 //when a key needs to be set.
8651 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
8652 {
8653 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
8654 }
8655 }
Jeff Johnson43971f52012-07-17 12:26:56 -07008656 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07008657 {
8658 palCopyMemory( pMac, &roamInfo.peerMac, &pRsp->peerMacAddr, sizeof(tCsrBssid) );
8659 //Make sure we install the GTK before indicating to HDD as authenticated
8660 //This is to prevent broadcast packets go out after PTK and before GTK.
8661 if( palEqualMemory( pMac->hHdd, &Broadcastaddr, pRsp->peerMacAddr,
8662 sizeof(tSirMacAddr) ) )
8663 {
8664 result = eCSR_ROAM_RESULT_AUTHENTICATED;
8665 }
8666 else
8667 {
8668 result = eCSR_ROAM_RESULT_NONE;
8669 }
8670 pRoamInfo = &roamInfo;
8671 }
8672 else
8673 {
8674 result = eCSR_ROAM_RESULT_FAILURE;
8675 smsLog( pMac, LOGE, "CSR: Roam Completion setkey command failed(%d) PeerMac %02X-%02X-%02X-%02X-%02X-%02X...\n",
8676 pRsp->statusCode, pRsp->peerMacAddr[0], pRsp->peerMacAddr[1], pRsp->peerMacAddr[2],
8677 pRsp->peerMacAddr[3], pRsp->peerMacAddr[4], pRsp->peerMacAddr[5] );
8678 }
8679 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
8680 eCSR_ROAM_SET_KEY_COMPLETE, result);
8681
8682 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
8683 // can go ahead and initiate the TSPEC if any are pending
8684 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
8685
8686#ifdef FEATURE_WLAN_CCX
8687 //Send Adjacent AP repot to new AP.
8688 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
8689 pSession->isPrevApInfoValid &&
8690 pSession->connectedProfile.isCCXAssoc)
8691 {
8692#ifdef WLAN_FEATURE_VOWIFI
8693 csrCcxSendAdjacentApRepMsg(pMac, pSession);
8694#endif
8695 pSession->isPrevApInfoValid = FALSE;
8696 }
8697#endif
8698
8699 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
8700 {
8701 csrReleaseCommandSetKey( pMac, pCommand );
8702 }
8703 }
8704 else
8705 {
8706 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ...\n" );
8707 }
8708 }
8709 else
8710 {
8711 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ...\n" );
8712 }
8713
8714 smeProcessPendingQueue( pMac );
8715 }
8716 break;
8717
8718 case eWNI_SME_REMOVEKEY_RSP:
8719 {
8720 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
8721 tListElem *pEntry;
8722 tSmeCmd *pCommand;
8723
8724 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
8725 if ( pEntry )
8726 {
8727 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
8728 if ( eSmeCommandRemoveKey == pCommand->command )
8729 {
8730 sessionId = pCommand->sessionId;
8731 pSession = CSR_GET_SESSION( pMac, sessionId );
8732
8733#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8734 {
8735 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
8736 palZeroMemory(pMac->hHdd, &removeKeyEvent, sizeof(vos_event_wlan_security_payload_type));
8737 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
8738 removeKeyEvent.encryptionModeMulticast =
8739 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8740 removeKeyEvent.encryptionModeUnicast =
8741 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8742 palCopyMemory( pMac->hHdd, removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
8743 removeKeyEvent.authMode =
8744 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8745 if( eSIR_SUCCESS != pRsp->statusCode )
8746 {
8747 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8748 }
8749 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8750 }
8751#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
8752
Jeff Johnson43971f52012-07-17 12:26:56 -07008753 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07008754 {
8755 palCopyMemory( pMac, &roamInfo.peerMac, &pRsp->peerMacAddr, sizeof(tCsrBssid) );
8756 result = eCSR_ROAM_RESULT_NONE;
8757 pRoamInfo = &roamInfo;
8758 }
8759 else
8760 {
8761 result = eCSR_ROAM_RESULT_FAILURE;
8762 }
8763 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
8764 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
8765 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
8766 {
8767 csrReleaseCommandRemoveKey( pMac, pCommand );
8768 }
8769 }
8770 else
8771 {
8772 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ...\n" );
8773 }
8774 }
8775 else
8776 {
8777 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ...\n" );
8778 }
8779
8780 smeProcessPendingQueue( pMac );
8781 }
8782 break;
8783
8784 case eWNI_SME_GET_STATISTICS_RSP:
8785 smsLog( pMac, LOGW, FL("Stats rsp from PE\n"));
8786 csrRoamStatsRspProcessor( pMac, pSirMsg );
8787 break;
8788
8789 case eWNI_SME_GET_RSSI_REQ:
8790 smsLog( pMac, LOGW, FL("GetRssiReq from self\n"));
8791 csrUpdateRssi( pMac, pSirMsg );
8792 break;
8793
8794
8795#ifdef WLAN_FEATURE_VOWIFI_11R
8796 case eWNI_SME_FT_PRE_AUTH_RSP:
8797 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
8798 break;
8799#endif
8800
8801 case eWNI_SME_MAX_ASSOC_EXCEEDED:
8802 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
8803 smsLog( pMac, LOG1, FL("send indication that max assoc have been reached and the new peer cannot be accepted\n"));
8804 sessionId = pSmeMaxAssocInd->sessionId;
8805 roamInfo.sessionId = sessionId;
8806 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pSmeMaxAssocInd->peerMac, sizeof(tCsrBssid));
8807 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
8808 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
8809 break;
8810
8811 case eWNI_SME_BTAMP_LOG_LINK_IND:
8812 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread\n"));
8813 btampEstablishLogLinkHdlr( pSirMsg );
8814 break;
8815
8816 default:
8817 break;
8818
8819 } // end switch on message type
8820
8821}
8822
8823
8824void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
8825 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
8826{
8827 if(pSession)
8828 {
8829 if(pSession->bRefAssocStartCnt)
8830 {
8831 pSession->bRefAssocStartCnt--;
8832 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
8833 //Need to call association_completion because there is an assoc_start pending.
8834 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
8835 eCSR_ROAM_ASSOCIATION_COMPLETION,
8836 eCSR_ROAM_RESULT_FAILURE);
8837 }
8838 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
8839 }
8840 else
8841 {
8842 smsLog(pMac, LOGW, FL(" pSession is NULL"));
8843 }
8844}
8845
8846
8847eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
8848{
8849 eHalStatus status = eHAL_STATUS_FAILURE;
8850
8851 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
8852 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
8853 {
8854 status = csrScanRequestLostLink1( pMac, sessionId );
8855 }
8856
8857 return(status);
8858}
8859
8860
8861//return a boolean to indicate whether roaming completed or continue.
8862tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
8863 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
8864{
8865 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
8866 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
8867 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
8868 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8869
8870 //Check whether time is up
8871 if(pSession->fCancelRoaming || fForce ||
8872 ((curTime - pSession->roamingStartTime) > roamTime) ||
8873 eCsrReassocRoaming == pSession->roamingReason ||
8874 eCsrDynamicRoaming == pSession->roamingReason)
8875 {
8876 smsLog(pMac, LOGW, FL(" indicates roaming completion\n"));
8877 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
8878 {
8879 //roaming is cancelled, tell HDD to indicate disconnect
8880 //Because LIM overload deauth_ind for both deauth frame and missed beacon
8881 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
8882 //to be eSIR_BEACON_MISSED
8883 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
8884 {
8885 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
8886 }
8887 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
8888 {
8889 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
8890 }
8891 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
8892 {
8893 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
8894 }
8895 else
8896 {
8897 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
8898 }
8899 }
8900 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
8901 pSession->roamingReason = eCsrNotRoaming;
8902 }
8903 else
8904 {
8905 pSession->roamResult = roamResult;
8906 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
8907 {
8908 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
8909 pSession->roamingReason = eCsrNotRoaming;
8910 }
8911 else
8912 {
8913 fCompleted = eANI_BOOLEAN_FALSE;
8914 }
8915 }
8916
8917 return(fCompleted);
8918}
8919
8920
8921void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
8922{
8923 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8924
8925 if(CSR_IS_ROAMING(pSession))
8926 {
8927 smsLog(pMac, LOGW, " Cancelling roaming\n");
8928 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
8929 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
8930 {
8931 //No need to do anything in here because the handler takes care of it
8932 }
8933 else
8934 {
8935 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
8936 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
8937 //Roaming is stopped after here
8938 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
8939 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
8940 csrScanAbortMacScan(pMac);
8941 csrRoamStopRoamingTimer(pMac, sessionId);
8942 }
8943 }
8944}
8945
8946
8947void csrRoamRoamingTimerHandler(void *pv)
8948{
8949 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
8950 tpAniSirGlobal pMac = pInfo->pMac;
8951 tANI_U32 sessionId = pInfo->sessionId;
8952 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8953
8954 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
8955 {
8956 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
8957 {
8958 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
8959 pSession->roamingReason = eCsrNotRoaming;
8960 }
8961 }
8962}
8963
8964
8965eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
8966{
8967 eHalStatus status;
8968 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8969
8970 smsLog(pMac, LOG1, " csrScanStartRoamingTimer \n ");
8971 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
8972 status = palTimerStart(pMac->hHdd, pSession->hTimerRoaming, interval, eANI_BOOLEAN_FALSE);
8973
8974 return (status);
8975}
8976
8977
8978eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
8979{
8980 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerRoaming));
8981}
8982
8983
8984void csrRoamWaitForKeyTimeOutHandler(void *pv)
8985{
8986 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
8987 tpAniSirGlobal pMac = pInfo->pMac;
8988
8989 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
8990 {
8991 smsLog(pMac, LOGW, " SME pre-auth state timeout. \n ");
8992 //Change the substate so command queue is unblocked.
8993 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, pInfo->sessionId);
8994 }
8995
8996}
8997
8998
8999eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
9000{
9001 eHalStatus status;
9002
9003 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer \n ");
9004 status = palTimerStart(pMac->hHdd, pMac->roam.hTimerWaitForKey, interval, eANI_BOOLEAN_FALSE);
9005
9006 return (status);
9007}
9008
9009
9010eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
9011{
9012 return (palTimerStop(pMac->hHdd, pMac->roam.hTimerWaitForKey));
9013}
9014
9015
9016void csrRoamIbssJoinTimerHandler(void *pv)
9017{
9018 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9019 tpAniSirGlobal pMac = pInfo->pMac;
9020 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE;
9021 tANI_U32 sessionId = pInfo->sessionId;
9022 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9023
9024 pSession->ibss_join_pending = FALSE;
9025 // JEZ100225: As of main/latest "tip", we are no longer doing this. Check on this.
9026 //csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
9027 // Send an IBSS stop request to PE
9028 csrRoamDisconnectInternal(pMac, sessionId, reason);
9029
9030}
9031
9032eHalStatus csrRoamStartIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
9033{
9034 eHalStatus status;
9035 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9036
9037 smsLog(pMac, LOG1, " csrRoamStartIbssJoinTimer \n ");
9038 pSession->ibssJoinTimerInfo.sessionId = (tANI_U8)sessionId;
9039 status = palTimerStart(pMac->hHdd, pSession->hTimerIbssJoining, interval, eANI_BOOLEAN_FALSE);
9040
9041 return (status);
9042}
9043
9044eHalStatus csrRoamStopIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
9045{
9046 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerIbssJoining));
9047}
9048
9049void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
9050 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
9051{
9052 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
9053 tANI_U32 roamId = 0;
9054
9055 if(pCommand)
9056 {
9057 roamId = pCommand->u.roamCmd.roamId;
9058#if defined(VOSS_ENABLED)
9059 VOS_ASSERT( sessionId == pCommand->sessionId );
9060#endif
9061 }
9062
9063 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
9064 {
9065 //if success, force roaming completion
9066 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
9067 }
9068 else
9069 {
9070 VOS_ASSERT((CSR_GET_SESSION( pMac, sessionId ))->bRefAssocStartCnt == 0);
9071 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d\n"), roamResult);
9072 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
9073 }
9074}
9075
9076
9077eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
9078{
9079 eHalStatus status = eHAL_STATUS_SUCCESS;
9080 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
9081 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
9082 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
9083 tCsrRoamInfo *pRoamInfo = NULL;
9084 tCsrRoamInfo roamInfo;
9085 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9086 //Only need to roam for infra station. In this case P2P client will roam as well
9087 tANI_BOOLEAN fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
9088
9089 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
9090 if ( eWNI_SME_DISASSOC_IND == type )
9091 {
9092 result = eCSR_ROAM_RESULT_DISASSOC_IND;
9093 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
9094 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
9095 }
9096 else if ( eWNI_SME_DEAUTH_IND == type )
9097 {
9098 result = eCSR_ROAM_RESULT_DEAUTH_IND;
9099 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
9100 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
9101 }
9102 else
9103 {
9104 smsLog(pMac, LOGW, FL("gets an unknown type (%d)\n"), type);
9105 result = eCSR_ROAM_RESULT_NONE;
9106 }
9107
9108 // call profile lost link routine here
9109#ifdef WLAN_SOFTAP_FEATURE
9110 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
9111#endif
9112 {
9113 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
9114 }
9115
9116 if ( eWNI_SME_DISASSOC_IND == type )
9117 {
9118 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
9119 }
9120 else if ( eWNI_SME_DEAUTH_IND == type )
9121 {
9122 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
9123 }
9124
9125 if(!HAL_STATUS_SUCCESS(status))
9126 {
9127 //If fail to send confirmation to PE, not to trigger roaming
9128 fToRoam = eANI_BOOLEAN_FALSE;
9129 }
9130
9131 //tell HDD to disconnect
9132 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9133 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
9134 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
9135#ifdef WLAN_SOFTAP_FEATURE
9136 if( eWNI_SME_DISASSOC_IND == type)
9137 {
9138 //staMacAddr
9139 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDisassocIndMsg->peerMacAddr, sizeof(tSirMacAddr));
9140 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
9141 }
9142 else if( eWNI_SME_DEAUTH_IND == type )
9143 {
9144 //staMacAddr
9145 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDeauthIndMsg->peerMacAddr, sizeof(tSirMacAddr));
9146 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
9147 }
9148#endif
9149 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)\n"), roamInfo.staId);
9150 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
9151 if(fToRoam)
9152 {
9153 //Only remove the connected BSS in infrastructure mode
9154 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
9155 //Not to do anying for lostlink with WDS
9156 if( pMac->roam.configParam.nRoamingTime )
9157 {
9158 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
9159 ( eWNI_SME_DEAUTH_IND == type ) ?
9160 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
9161 {
9162 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9163 //For IBSS, we need to give some more info to HDD
9164 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
9165 {
9166 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9167 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
9168 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
9169 }
9170 else
9171 {
9172 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
9173 }
9174 pRoamInfo = &roamInfo;
9175 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
9176 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
9177 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
9178 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
9179 }
9180 else
9181 {
9182 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __FUNCTION__, status);
9183 fToRoam = eANI_BOOLEAN_FALSE;
9184 }
9185 }
9186 else
9187 {
9188 //We are told not to roam, indicate lostlink
9189 fToRoam = eANI_BOOLEAN_FALSE;
9190 }
9191 }
9192
9193 if(!fToRoam)
9194 {
9195 if( eWNI_SME_DISASSOC_IND == type)
9196 {
9197 //staMacAddr
9198 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDisassocIndMsg->peerMacAddr, sizeof(tSirMacAddr));
9199 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
9200 }
9201 else if( eWNI_SME_DEAUTH_IND == type )
9202 {
9203 //staMacAddr
9204 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDeauthIndMsg->peerMacAddr, sizeof(tSirMacAddr));
9205 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
9206 }
9207 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
9208
9209 /*No need to start idle scan in case of IBSS/SAP
9210 Still enable idle scan for polling in case concurrent sessions are running */
9211 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
9212 {
9213 csrScanStartIdleScan(pMac);
9214 }
9215 }
9216
9217 return (status);
9218}
9219
9220
9221eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
9222{
9223 eHalStatus status = eHAL_STATUS_SUCCESS;
9224 tListElem *pEntry = NULL;
9225 tSmeCmd *pCommand = NULL;
9226 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9227 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
9228
9229 //Only remove the connected BSS in infrastructure mode
9230 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
9231 if(pMac->roam.configParam.nRoamingTime)
9232 {
9233 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
9234 {
9235 //before starting the lost link logic release the roam command for handoff
9236 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
9237 if(pEntry)
9238 {
9239 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
9240 }
9241 if(pCommand)
9242 {
9243 if (( eSmeCommandRoam == pCommand->command ) &&
9244 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
9245 {
9246 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9247 {
9248 csrReleaseCommandRoam( pMac, pCommand );
9249 }
9250 }
9251 }
9252
9253 smsLog( pMac, LOGW, "Lost link roaming started ...\n");
9254 }
9255 }
9256 else
9257 {
9258 //We are told not to roam, indicate lostlink
9259 status = eHAL_STATUS_FAILURE;
9260 }
9261
9262 return (status);
9263}
9264
9265void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
9266{
9267 tListElem *pEntry;
9268 tSmeCmd *pCommand;
9269
9270 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9271 if ( pEntry )
9272 {
9273 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9274 if ( eSmeCommandWmStatusChange == pCommand->command )
9275 {
9276 // Nothing to process in a Lost Link completion.... It just kicks off a
9277 // roaming sequence.
9278 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9279 {
9280 csrReleaseCommandWmStatusChange( pMac, pCommand );
9281 }
9282 else
9283 {
9284 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command\n");
9285 }
9286
9287 }
9288 else
9289 {
9290 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ...\n" );
9291 }
9292 }
9293 else
9294 {
9295 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ...\n" );
9296 }
9297
9298 smeProcessPendingQueue( pMac );
9299}
9300
9301
9302void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
9303{
9304 eHalStatus status = eHAL_STATUS_FAILURE;
9305 tSirSmeRsp *pSirSmeMsg;
9306 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
9307
9308 switch ( pCommand->u.wmStatusChangeCmd.Type )
9309 {
9310 case eCsrDisassociated:
9311 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
9312 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
9313 break;
9314
9315 case eCsrDeauthenticated:
9316 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
9317 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
9318 break;
9319
9320 default:
9321 smsLog(pMac, LOGW, FL("gets an unknown command %d\n"), pCommand->u.wmStatusChangeCmd.Type);
9322 break;
9323 }
9324 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
9325 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
9326 {
9327 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
9328 {
9329 //This is not good
9330 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command\n"));
9331 }
9332 }
9333
9334 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
9335 // command here since there is nothing else to do.
9336 csrRoamWmStatusChangeComplete( pMac );
9337}
9338
9339
9340//This function returns band and mode information.
9341//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
9342//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
9343#ifdef WLAN_SOFTAP_FEATURE
9344static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
9345 tANI_U8 operationChn, eCsrBand *pBand )
9346#else
9347static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, eCsrPhyMode phyModeIn,
9348 tANI_U8 operationChn, eCsrBand *pBand )
9349#endif
9350{
9351
9352#ifdef WLAN_SOFTAP_FEATURE
9353 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
9354 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
9355 pMac->roam.configParam.ProprietaryRatesEnabled);
9356#else
9357 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(phyModeIn,
9358 pMac->roam.configParam.ProprietaryRatesEnabled);
9359#endif
9360 eCsrBand eBand;
9361
9362 //If the global setting for dot11Mode is set to auto/abg, we overwrite the setting in the profile.
9363#ifdef WLAN_SOFTAP_FEATURE
9364 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
9365 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
9366 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
9367 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
9368#else
9369 if( (eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
9370 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode) ||
9371 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
9372
9373#endif
9374 {
9375 switch( pMac->roam.configParam.uCfgDot11Mode )
9376 {
9377 case eCSR_CFG_DOT11_MODE_11A:
9378 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
9379 eBand = eCSR_BAND_5G;
9380 break;
9381 case eCSR_CFG_DOT11_MODE_11B:
9382 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
9383 eBand = eCSR_BAND_24;
9384 break;
9385 case eCSR_CFG_DOT11_MODE_11G:
9386 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
9387 eBand = eCSR_BAND_24;
9388 break;
9389 case eCSR_CFG_DOT11_MODE_11N:
9390 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
9391 eBand = eCSR_BAND_24;
9392 break;
9393 //case eCSR_CFG_DOT11_MODE_BEST:
9394 // cfgDot11Mode = eCSR_CFG_DOT11_MODE_BEST;
9395 // eBand = eCSR_BAND_24;
9396 // break;
9397 default:
9398 // Global dot11 Mode setting is 11a/b/g.
9399 // use the channel number to determine the Mode setting.
9400 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
9401 {
9402 eBand = pMac->roam.configParam.eBand;
9403 if(eCSR_BAND_24 == eBand)
9404 {
9405 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
9406 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
9407 }
9408 else
9409 {
9410 //prefer 5GHz
9411 eBand = eCSR_BAND_5G;
9412 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
9413 }
9414 }
9415 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
9416 {
9417 // channel is a 2.4GHz channel. Set mode to 11g.
9418 //
9419 // !!LAC - WiFi tests require IBSS networks to start in 11b mode without any change to the
9420 // default parameter settings on the adapter. We use ACU to start an IBSS through creation
9421 // of a startIBSS profile. this startIBSS profile has Auto MACProtocol and the
9422 // adapter property setting for dot11Mode is also AUTO. So in this case, let's start
9423 // the IBSS network in 11b mode instead of 11g mode.
9424 //
9425 // so this is for Auto=profile->MacProtocol && Auto=Global.dot11Mode && profile->channel is < 14,
9426 // then start the IBSS in b mode.
9427 //
9428 // Note: we used to have this start as an 11g IBSS for best performance... now to specify that
9429 // the user will have to set the do11Mode in the property page to 11g to force it.
9430 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
9431 eBand = eCSR_BAND_24;
9432 }
9433 else
9434 {
9435 // else, it's a 5.0GHz channel. Set mode to 11a.
9436 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
9437 eBand = eCSR_BAND_5G;
9438 }
9439 break;
9440 }//switch
9441 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
9442 else
9443 {
9444 //dot11 mode is set, lets pick the band
9445 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
9446 {
9447 // channel is Auto also.
9448 eBand = pMac->roam.configParam.eBand;
9449 if(eCSR_BAND_ALL == eBand)
9450 {
9451 //prefer 5GHz
9452 eBand = eCSR_BAND_5G;
9453 }
9454 }
9455 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
9456 {
9457 eBand = eCSR_BAND_24;
9458 }
9459 else
9460 {
9461 eBand = eCSR_BAND_5G;
9462 }
9463 }
9464 if(pBand)
9465 {
9466 *pBand = eBand;
9467 }
9468
9469 if (operationChn == 14){
9470 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode \n"));
9471 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
9472 }
9473
9474 return( cfgDot11Mode );
9475}
9476
9477
9478eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
9479{
9480 eHalStatus status;
9481 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9482
9483
9484#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9485 {
9486 vos_log_ibss_pkt_type *pIbssLog;
9487
9488 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9489 if(pIbssLog)
9490 {
9491 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
9492 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9493 }
9494 }
9495#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
9496
9497 pSession->ibss_join_pending = FALSE;
9498 csrRoamStopIbssJoinTimer(pMac, sessionId );
9499 // Set the roaming substate to 'stop Bss request'...
9500 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
9501
9502 // attempt to stop the Bss (reason code is ignored...)
9503 status = csrSendMBStopBssReqMsg( pMac, sessionId );
9504
9505 return (status);
9506}
9507
9508
9509//pNumChan is a caller allocated space with the sizeof pChannels
9510eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
9511{
9512
9513 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
9514 (tANI_U8 *)pChannels,
9515 pNumChan));
9516}
9517
9518
9519tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
9520{
9521 tANI_BOOLEAN fValid = FALSE;
9522 tANI_U32 idxValidChannels;
9523 tANI_U32 len = sizeof(pMac->roam.validChannelList);
9524
9525 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
9526 {
9527 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
9528 {
9529 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
9530 {
9531 fValid = TRUE;
9532 break;
9533 }
9534 }
9535 }
9536 pMac->roam.numValidChannels = len;
9537 return fValid;
9538}
9539
9540
9541tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
9542{
9543 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
9544 tANI_U8 i;
9545
9546 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
9547 {
9548 if(channel == pMac->scan.base40MHzChannels.channelList[i])
9549 {
9550 fValid = eANI_BOOLEAN_TRUE;
9551 break;
9552 }
9553 }
9554
9555 return (fValid);
9556}
9557
9558
9559//This function check and validate whether the NIC can do CB (40MHz)
9560static tAniCBSecondaryMode csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
9561{
9562 tAniCBSecondaryMode eRet = eANI_CB_SECONDARY_NONE;
9563 tANI_U8 centerChn;
9564 tANI_U32 ChannelBondingMode;
9565
9566 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
9567 {
9568 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
9569 }
9570 else
9571 {
9572 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
9573 }
9574 //Figure what the other side's CB mode
9575 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
9576 {
9577 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
9578 {
9579 if(pIes->HTInfo.present)
9580 {
9581 if(PHY_DOUBLE_CHANNEL_LOW_PRIMARY == pIes->HTInfo.secondaryChannelOffset)
9582 {
9583 eRet = eANI_CB_SECONDARY_UP;
9584 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
9585 }
9586 else if(PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == pIes->HTInfo.secondaryChannelOffset)
9587 {
9588 eRet = eANI_CB_SECONDARY_DOWN;
9589 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
9590 }
9591 else
9592 {
9593 //PHY_SINGLE_CHANNEL_CENTERED
9594 centerChn = primaryChn;
9595 eRet = eANI_CB_SECONDARY_NONE;
9596 }
9597 if((eANI_CB_SECONDARY_NONE != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
9598 {
9599 smsLog(pMac, LOGW, " Invalid center channel (%d), disable 40MHz mode\n", centerChn);
9600 eRet = eANI_CB_SECONDARY_NONE;
9601 }
9602 }
9603 }
9604 }
9605
9606 return eRet;
9607}
9608
9609tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
9610{
9611 tANI_BOOLEAN fFound = FALSE;
9612 tANI_U32 idx;
9613
9614 for( idx = 0; idx < pCipherList->numEntries; idx++ )
9615 {
9616 if( pCipherList->encryptionType[idx] == encryptionType )
9617 {
9618 fFound = TRUE;
9619 break;
9620 }
9621 }
9622
9623 return fFound;
9624}
9625
9626tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
9627{
9628 tANI_BOOLEAN fFound = FALSE;
9629 tANI_U32 idx;
9630
9631 for( idx = 0; idx < pAuthList->numEntries; idx++ )
9632 {
9633 if( pAuthList->authType[idx] == authType )
9634 {
9635 fFound = TRUE;
9636 break;
9637 }
9638 }
9639
9640 return fFound;
9641}
9642
9643tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
9644{
9645 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
9646 tCsrScanResultFilter *pScanFilter = NULL;
9647 eHalStatus status = eHAL_STATUS_SUCCESS;
9648
9649 if(pProfile1 && pProfile2)
9650 {
9651 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
9652 if(HAL_STATUS_SUCCESS(status))
9653 {
9654 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
9655 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
9656 if(HAL_STATUS_SUCCESS(status))
9657 {
9658 fCheck = eANI_BOOLEAN_FALSE;
9659 do
9660 {
9661 tANI_U32 i;
9662 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
9663 {
9664 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
9665 pScanFilter->SSIDs.SSIDList[i].SSID.length,
9666 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
9667 if ( fCheck ) break;
9668 }
9669 if(!fCheck)
9670 {
9671 break;
9672 }
9673 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
9674 || pProfile2->BSSType != pProfile1->BSSType
9675 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
9676 )
9677 {
9678 fCheck = eANI_BOOLEAN_FALSE;
9679 break;
9680 }
9681#ifdef WLAN_FEATURE_VOWIFI_11R
9682 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
9683 {
9684 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
9685 {
9686 fCheck = eANI_BOOLEAN_FALSE;
9687 break;
9688 }
9689 }
9690#endif
9691 //Match found
9692 fCheck = eANI_BOOLEAN_TRUE;
9693 }while(0);
9694 csrFreeScanFilter(pMac, pScanFilter);
9695 }
9696 palFreeMemory(pMac->hHdd, pScanFilter);
9697 }
9698 }
9699
9700 return (fCheck);
9701}
9702
9703
9704tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
9705{
9706 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
9707 int i;
9708
9709 do
9710 {
9711 //Only check for static WEP
9712 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
9713 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
9714 {
9715 fCheck = eANI_BOOLEAN_TRUE;
9716 break;
9717 }
9718 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
9719 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
9720 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
9721 {
9722 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
9723 if(!palEqualMemory(pMac->hHdd, &pConnProfile->Keys.KeyMaterial[i],
9724 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
9725 {
9726 break;
9727 }
9728 }
9729 if( i == CSR_MAX_NUM_KEY)
9730 {
9731 fCheck = eANI_BOOLEAN_TRUE;
9732 }
9733 }while(0);
9734
9735 return (fCheck);
9736}
9737
9738
9739//IBSS
9740
9741
9742tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
9743{
9744 tANI_U8 channel = 0;
9745 tANI_U32 idx;
9746 tANI_U32 idxValidChannels;
9747 tANI_BOOLEAN fFound = FALSE;
9748 tANI_U32 len = sizeof(pMac->roam.validChannelList);
9749
9750 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
9751 {
9752 channel = pMac->roam.configParam.AdHocChannel5G;
9753 if(!csrRoamIsChannelValid(pMac, channel))
9754 {
9755 channel = 0;
9756 }
9757 }
9758 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
9759 {
9760 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
9761 {
9762 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
9763 {
9764 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
9765 {
9766 fFound = TRUE;
9767 channel = csrStartIbssChannels50[ idx ];
9768 }
9769 }
9770 }
9771
9772 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
9773 if (!fFound)
9774 {
9775 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
9776 {
9777 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idx ]) ) // the max channel# in 11g is 14
9778 {
9779 channel = csrStartIbssChannels50[ idx ];
9780 break;
9781 }
9782 }
9783 }
9784 }//if
9785
9786 return( channel );
9787}
9788
9789
9790tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
9791{
9792 tANI_U8 channel = 1;
9793 tANI_U32 idx;
9794 tANI_U32 idxValidChannels;
9795 tANI_BOOLEAN fFound = FALSE;
9796 tANI_U32 len = sizeof(pMac->roam.validChannelList);
9797
9798 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
9799 {
9800 channel = pMac->roam.configParam.AdHocChannel24;
9801 if(!csrRoamIsChannelValid(pMac, channel))
9802 {
9803 channel = 0;
9804 }
9805 }
9806
9807 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
9808 {
9809 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
9810 {
9811 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
9812 {
9813 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
9814 {
9815 fFound = TRUE;
9816 channel = csrStartIbssChannels24[ idx ];
9817 }
9818 }
9819 }
9820 }
9821
9822 return( channel );
9823}
9824
9825
9826static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
9827 tCsrRoamStartBssParams *pParam )
9828{
9829 eCsrCfgDot11Mode cfgDot11Mode;
9830 eCsrBand eBand;
9831 tANI_U8 channel = 0;
9832 tSirNwType nwType;
9833 tANI_U8 operationChannel = 0;
9834
9835 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
9836 {
9837 operationChannel = pProfile->ChannelInfo.ChannelList[0];
9838 }
9839
9840#ifdef WLAN_SOFTAP_FEATURE
9841 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
9842#else
9843 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, (eCsrPhyMode)pProfile->phyMode, operationChannel, &eBand );
9844#endif
9845
9846#ifdef WLAN_FEATURE_P2P
9847 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
9848 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
9849 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
9850 )
9851 {
9852 /* This should never happen */
9853 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
9854 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B\n"),
9855 pProfile->csrPersona);
9856 VOS_ASSERT(0);
9857 }
9858#endif
9859
9860 switch( cfgDot11Mode )
9861 {
9862 case eCSR_CFG_DOT11_MODE_11G:
9863 nwType = eSIR_11G_NW_TYPE;
9864 break;
9865
9866 case eCSR_CFG_DOT11_MODE_11B:
9867 nwType = eSIR_11B_NW_TYPE;
9868 break;
9869
9870 case eCSR_CFG_DOT11_MODE_11A:
9871 nwType = eSIR_11A_NW_TYPE;
9872 break;
9873
9874 default:
9875 case eCSR_CFG_DOT11_MODE_11N:
9876 case eCSR_CFG_DOT11_MODE_TAURUS:
9877 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
9878 if(eCSR_BAND_24 == eBand)
9879 {
9880 nwType = eSIR_11G_NW_TYPE;
9881 }
9882 else
9883 {
9884 nwType = eSIR_11A_NW_TYPE;
9885 }
9886 break;
9887 }
9888
9889 pParam->extendedRateSet.numRates = 0;
9890
9891 switch ( nwType )
9892 {
9893 default:
9894 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)\n"), nwType);
9895 case eSIR_11A_NW_TYPE:
9896
9897 pParam->operationalRateSet.numRates = 8;
9898
9899 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
9900 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
9901 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
9902 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
9903 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
9904 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
9905 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
9906 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
9907
9908 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
9909 {
9910 channel = csrRoamGetIbssStartChannelNumber50( pMac );
9911 if( 0 == channel &&
9912 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
9913 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
9914 )
9915 {
9916 //We could not find a 5G channel by auto pick, let's try 2.4G channels
9917 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
9918 nwType = eSIR_11B_NW_TYPE;
9919 channel = csrRoamGetIbssStartChannelNumber24( pMac );
9920 pParam->operationalRateSet.numRates = 4;
9921 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
9922 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
9923 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
9924 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
9925 }
9926 }
9927 else
9928 {
9929 channel = operationChannel;
9930 }
9931 break;
9932
9933 case eSIR_11B_NW_TYPE:
9934 pParam->operationalRateSet.numRates = 4;
9935 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
9936 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
9937 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
9938 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
9939
9940 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
9941 {
9942 channel = csrRoamGetIbssStartChannelNumber24( pMac );
9943 }
9944 else
9945 {
9946 channel = operationChannel;
9947 }
9948
9949 break;
9950
9951 case eSIR_11G_NW_TYPE:
9952#ifdef WLAN_FEATURE_P2P
9953 /* For P2P Client and P2P GO, disable 11b rates */
9954 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
9955 (pProfile->csrPersona == VOS_P2P_GO_MODE)
9956 )
9957 {
9958 pParam->operationalRateSet.numRates = 8;
9959
9960 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
9961 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
9962 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
9963 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
9964 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
9965 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
9966 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
9967 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
9968 }
9969 else
9970#endif
9971 {
9972 pParam->operationalRateSet.numRates = 4;
9973
9974 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
9975 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
9976 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
9977 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
9978
9979 pParam->extendedRateSet.numRates = 8;
9980
9981 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
9982 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
9983 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
9984 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
9985 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
9986 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
9987 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
9988 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
9989 }
9990
9991 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
9992 {
9993 channel = csrRoamGetIbssStartChannelNumber24( pMac );
9994 }
9995 else
9996 {
9997 channel = operationChannel;
9998 }
9999
10000 break;
10001 }
10002 pParam->operationChn = channel;
10003 pParam->sirNwType = nwType;
10004}
10005
10006
10007static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
10008 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
10009{
10010
10011 if( pParam )
10012 {
10013 pParam->sirNwType = pBssDesc->nwType;
10014 pParam->cbMode = eANI_CB_SECONDARY_NONE;
10015 pParam->operationChn = pBssDesc->channelId;
10016 palCopyMemory( pMac->hHdd, &pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid) );
10017
10018 if( pIes )
10019 {
10020 if(pIes->SuppRates.present)
10021 {
10022 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
10023 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
10024 {
10025 smsLog(pMac, LOGE, FL("num_rates :%d is more than SIR_MAC_RATESET_EID_MAX, resetting to SIR_MAC_RATESET_EID_MAX\n"),
10026 pIes->SuppRates.num_rates);
10027 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
10028 }
10029 palCopyMemory(pMac->hHdd, pParam->operationalRateSet.rate, pIes->SuppRates.rates,
10030 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
10031 }
10032 if( pIes->SSID.present )
10033 {
10034 pParam->ssId.length = pIes->SSID.num_ssid;
10035 palCopyMemory(pMac->hHdd, pParam->ssId.ssId, pIes->SSID.ssid, pParam->ssId.length);
10036 }
10037 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
10038
10039 }
10040 else
10041 {
10042 pParam->ssId.length = 0;
10043 pParam->operationalRateSet.numRates = 0;
10044 }
10045 }
10046}
10047
10048
10049static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
10050{
10051 tANI_U8 MaxRate = 0;
10052 tANI_U32 i;
10053 tANI_U8 *pRate;
10054
10055 pRate = pSirRateSet->rate;
10056 for ( i = 0; i < pSirRateSet->numRates; i++ )
10057 {
10058 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
10059 }
10060
10061 // Save the max rate in the connected state information...
10062
10063 // modify LastRates variable as well
10064
10065 return;
10066}
10067
10068
10069//this function finds a valid secondary channel for channel bonding with "channel".
10070//Param: channel -- primary channel, caller must validate it
10071// cbChoice -- CB directory
10072//Return: if 0, no secondary channel is found. Otherwise a valid secondary channel.
10073static tANI_U8 csrRoamGetSecondaryChannel(tpAniSirGlobal pMac, tANI_U8 channel, eCsrCBChoice cbChoice)
10074{
10075 tANI_U8 chnUp = 0, chnDown = 0, chnRet = 0;
10076
10077 switch (cbChoice)
10078 {
10079 case eCSR_CB_OFF:
10080 chnUp = 0;
10081 chnDown = 0;
10082 break;
10083 case eCSR_CB_DOWN:
10084 chnUp = 0;
10085 chnDown = channel - CSR_CB_CHANNEL_GAP;
10086 break;
10087 case eCSR_CB_UP:
10088 chnUp = channel + CSR_CB_CHANNEL_GAP;
10089 chnDown = 0;
10090 break;
10091 case eCSR_CB_AUTO:
10092 //consider every other value means auto
10093 default:
10094 chnUp = channel + CSR_CB_CHANNEL_GAP;
10095 chnDown = channel - CSR_CB_CHANNEL_GAP;
10096 break;
10097 }
10098
10099 //if CB_UP or auto, try channel up first
10100 if(chnUp && CSR_IS_SAME_BAND_CHANNELS(chnUp, channel) && csrRoamIsChannelValid(pMac, chnUp))
10101 {
10102 //found a valid up channel for channel bonding
10103 //check whether the center channel is valid
10104 if(csrRoamIsValid40MhzChannel(pMac, channel + CSR_CB_CENTER_CHANNEL_OFFSET))
10105 {
10106 chnRet = chnUp;
10107 }
10108 }
10109 if(chnRet == 0 && chnDown && CSR_IS_SAME_BAND_CHANNELS(chnDown, channel) && csrRoamIsChannelValid(pMac, chnDown))
10110 {
10111 //found a valid down channel for channel bonding
10112 if(csrRoamIsValid40MhzChannel(pMac, channel - CSR_CB_CENTER_CHANNEL_OFFSET))
10113 {
10114 chnRet = chnDown;
10115 }
10116 }
10117
10118 return chnRet;
10119}
10120
10121
10122eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
10123 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
10124{
10125 eHalStatus status = eHAL_STATUS_SUCCESS;
10126 eCsrBand eBand;
10127
10128 // Set the roaming substate to 'Start BSS attempt'...
10129 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
10130
10131#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10132 //Need to figure out whether we need to log WDS???
10133 if( CSR_IS_IBSS( pProfile ) )
10134 {
10135 vos_log_ibss_pkt_type *pIbssLog;
10136
10137 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10138 if(pIbssLog)
10139 {
10140 if(pBssDesc)
10141 {
10142 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
10143 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pBssDesc->bssId, 6);
10144 }
10145 else
10146 {
10147 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
10148 }
10149 palCopyMemory(pMac->hHdd, pIbssLog->ssid, pParam->ssId.ssId,
10150 pParam->ssId.length);
10151 if(pProfile->ChannelInfo.numOfChannels == 0)
10152 {
10153 pIbssLog->channelSetting = AUTO_PICK;
10154 }
10155 else
10156 {
10157 pIbssLog->channelSetting = SPECIFIED;
10158 }
10159 pIbssLog->operatingChannel = pParam->operationChn;
10160 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10161 }
10162 }
10163#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
10164 //Put RSN information in for Starting BSS
10165 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
10166 pParam->pRSNIE = pProfile->pRSNReqIE;
10167
10168
10169#ifdef WLAN_SOFTAP_FEATURE
10170 pParam->privacy = pProfile->privacy;
10171 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
10172 pParam->authType = pProfile->csr80211AuthType;
10173 pParam->beaconInterval = pProfile->beaconInterval;
10174 pParam->dtimPeriod = pProfile->dtimPeriod;
10175 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
10176 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
10177 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
10178 {
10179 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
10180 {
10181 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
10182 }
10183 }
10184
10185 pParam->protEnabled = pProfile->protEnabled;
10186 pParam->obssProtEnabled = pProfile->obssProtEnabled;
10187 pParam->ht_protection = pProfile->cfg_protection;
10188 pParam->wps_state = pProfile->wps_state;
10189#endif
10190
10191
10192#ifdef WLAN_SOFTAP_FEATURE
10193 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
10194 &eBand);
10195#else
10196 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile->operationChannel,
10197 &eBand);
10198#endif
10199 pParam->bssPersona = pProfile->csrPersona;
10200 // When starting an IBSS, start on the channel from the Profile.
10201 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
10202
10203 return (status);
10204}
10205
10206
10207static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
10208 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
10209{
10210 tANI_U8 Channel, SecondChn;
10211 tAniCBSecondaryMode cbMode = eANI_CB_SECONDARY_NONE;
10212 eCsrCBChoice cbChoice;
10213 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
10214
10215 if( pBssDesc )
10216 {
10217 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
10218 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
10219 //The following code has to be do after that.
10220 //For WDS station, use selfMac as the self BSSID
10221 if( CSR_IS_WDS_STA( pProfile ) )
10222 {
10223 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, &pSession->selfMacAddr, sizeof(tCsrBssid));
10224 }
10225 }
10226 else
10227 {
10228 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
10229
10230 //Use the first SSID
10231 if(pProfile->SSIDs.numOfSSIDs)
10232 {
10233 palCopyMemory(pMac->hHdd, &pSession->bssParams.ssId, pProfile->SSIDs.SSIDList, sizeof(tSirMacSSid));
10234 }
10235 //For WDS station, use selfMac as the self BSSID
10236 if( CSR_IS_WDS_STA( pProfile ) )
10237 {
10238 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, &pSession->selfMacAddr, sizeof(tCsrBssid));
10239 }
10240 //Use the first BSSID
10241 else if( pProfile->BSSIDs.numOfBSSIDs )
10242 {
10243 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, pProfile->BSSIDs.bssid, sizeof(tCsrBssid));
10244 }
10245 else
10246 {
10247 palZeroMemory( pMac->hHdd, &pSession->bssParams.bssid, sizeof(tCsrBssid) );
10248 }
10249 }
10250 Channel = pSession->bssParams.operationChn;
10251
10252 //Set operating channel in pProfile which will be used
10253 //in csrRoamSetBssConfigCfg() to determine channel bonding
10254 //mode and will be configured in CFG later
10255 pProfile->operationChannel = Channel;
10256
10257 if(Channel == 0)
10258 {
10259 smsLog(pMac, LOGW, " CSR cannot find a channel to start IBSS\n");
10260 }
10261 else
10262 {
10263
10264 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
10265
10266 if( CSR_IS_START_IBSS( pProfile ) )
10267 {
10268 //TBH: channel bonding is not supported for Libra
10269 if( pProfile->ChannelInfo.ChannelList && eCSR_OPERATING_CHANNEL_AUTO != pProfile->ChannelInfo.ChannelList[0] )
10270 {
10271 Channel = pProfile->ChannelInfo.ChannelList[0];
10272 cbChoice = pProfile->CBMode;
10273 }
10274 else {
10275 cbChoice = pMac->roam.configParam.cbChoice;
10276 }
10277 pSession->bssParams.operationChn = Channel;
10278 //make sure channel is valid
10279 if(!csrRoamIsChannelValid(pMac, Channel))
10280 {
10281 //set Channel to 0 to let lim know this is invalid
10282 //We still send this request down to lim even though we know the channel is wrong because
10283 //lim will response with error and hdd's eWNI_SME_START_BSS_RSP handler will roam other profile (if any)
10284 Channel = 0;
10285 pSession->bssParams.operationChn = 0;
10286 }
10287 else {
10288 tANI_U32 ChannelBondingMode;
10289
10290 if(CSR_IS_CHANNEL_24GHZ(Channel))
10291 {
10292 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
10293 }
10294 else
10295 {
10296 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
10297 }
10298
10299 //now we have a valid channel
10300 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
10301 {
10302 //let's pick a secondard channel
10303 SecondChn = csrRoamGetSecondaryChannel(pMac, Channel, cbChoice);
10304
10305 if(SecondChn > Channel)
10306 {
10307 cbMode = eANI_CB_SECONDARY_UP;
10308 }
10309 else if(SecondChn && SecondChn < Channel)
10310 {
10311 cbMode =eANI_CB_SECONDARY_DOWN;
10312 }
10313 else
10314 {
10315 cbMode = eANI_CB_SECONDARY_NONE;
10316 }
10317 pSession->bssParams.cbMode = cbMode;
10318 }
10319 else
10320 {
10321 pSession->bssParams.cbMode = eANI_CB_SECONDARY_NONE;
10322 }
10323 }
10324 }
10325 }
10326}
10327
10328
10329
10330static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
10331 tANI_BOOLEAN *pfSameIbss )
10332{
10333 eHalStatus status = eHAL_STATUS_SUCCESS;
10334 tANI_BOOLEAN fSameIbss = FALSE;
10335
10336 if ( csrIsConnStateIbss( pMac, sessionId ) )
10337 {
10338 // Check if any profile parameter has changed ? If any profile parameter
10339 // has changed then stop old BSS and start a new one with new parameters
10340 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
10341 {
10342 fSameIbss = TRUE;
10343 }
10344 else
10345 {
10346 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
10347 }
10348 }
10349 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
10350 {
10351 // Disassociate from the connected Infrastructure network...
10352 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
10353 }
10354 else
10355 {
10356 tBssConfigParam *pBssConfig;
10357
10358 status = palAllocateMemory(pMac->hHdd, (void **)&pBssConfig, sizeof(tBssConfigParam));
10359 if(HAL_STATUS_SUCCESS(status))
10360 {
10361 palZeroMemory(pMac->hHdd, pBssConfig, sizeof(tBssConfigParam));
10362 // there is no Bss description before we start an IBSS so we need to adopt
10363 // all Bss configuration parameters from the Profile.
10364 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
10365 if(HAL_STATUS_SUCCESS(status))
10366 {
10367 //save dotMode
10368 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
10369 //Prepare some more parameters for this IBSS
10370 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, NULL);
10371 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
10372 }
10373
10374 palFreeMemory(pMac->hHdd, pBssConfig);
10375 }//Allocate memory
10376 }
10377
10378 if(pfSameIbss)
10379 {
10380 *pfSameIbss = fSameIbss;
10381 }
10382 return( status );
10383}
10384
10385
10386static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
10387 tSirSmeNewBssInfo *pNewBss )
10388{
10389 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
10390
10391 if( pNewBss )
10392 {
10393 // Set the operating channel.
10394 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
10395 // move the BSSId from the BSS description into the connected state information.
10396 palCopyMemory( pMac->hHdd, &pSession->connectedProfile.bssid,
10397 &(pNewBss->bssId), sizeof( tCsrBssid ) );
10398 }
10399
10400 return;
10401}
10402
10403
10404#ifdef FEATURE_WLAN_WAPI
10405eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
10406 tANI_U32 numItems )
10407{
10408 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
10409 tCsrRoamSession *pSession;
10410
10411 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
10412 {
10413 smsLog(pMac, LOGE, FL(" Invalid session ID\n"));
10414 return status;
10415 }
10416 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d\n", numItems);
10417 pSession = CSR_GET_SESSION( pMac, sessionId );
10418 if(numItems <= CSR_MAX_BKID_ALLOWED)
10419 {
10420 status = eHAL_STATUS_SUCCESS;
10421 //numItems may be 0 to clear the cache
10422 pSession->NumBkidCache = (tANI_U16)numItems;
10423 if(numItems && pBKIDCache)
10424 {
10425 status = palCopyMemory( pMac->hHdd, pSession->BkidCacheInfo, pBKIDCache,
10426 sizeof(tBkidCacheInfo) * numItems );
10427 }
10428 }
10429
10430 return (status);
10431}
10432
10433eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
10434 tBkidCacheInfo *pBkidCache)
10435{
10436 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
10437 tCsrRoamSession *pSession;
10438
10439 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
10440 {
10441 smsLog(pMac, LOGE, FL(" Invalid session ID\n"));
10442 return status;
10443 }
10444
10445 pSession = CSR_GET_SESSION( pMac, sessionId );
10446 if(pNum && pBkidCache)
10447 {
10448 if(pSession->NumBkidCache == 0)
10449 {
10450 *pNum = 0;
10451 status = eHAL_STATUS_SUCCESS;
10452 }
10453 else if(*pNum >= pSession->NumBkidCache)
10454 {
10455 if(pSession->NumBkidCache > CSR_MAX_PMKID_ALLOWED)
10456 {
10457 smsLog(pMac, LOGE, FL("NumPmkidCache :%d is more than CSR_MAX_PMKID_ALLOWED, resetting to CSR_MAX_PMKID_ALLOWED\n"),
10458 pSession->NumBkidCache);
10459 pSession->NumBkidCache = CSR_MAX_PMKID_ALLOWED;
10460 }
10461 palCopyMemory( pMac->hHdd, pBkidCache, pSession->BkidCacheInfo,
10462 sizeof(tBkidCacheInfo) * pSession->NumBkidCache );
10463 *pNum = pSession->NumBkidCache;
10464 status = eHAL_STATUS_SUCCESS;
10465 }
10466 }
10467
10468 return (status);
10469
10470}
10471
10472tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
10473{
10474 return (pMac->roam.roamSession[sessionId].NumBkidCache);
10475
10476}
10477#endif /* FEATURE_WLAN_WAPI */
10478
10479eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
10480 tPmkidCacheInfo *pPMKIDCache, tANI_U32 numItems )
10481{
10482 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
10483 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
10484
10485 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d\n", numItems);
10486 if(numItems <= CSR_MAX_PMKID_ALLOWED)
10487 {
10488#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10489 {
10490 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
10491 palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type));
10492 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
10493 secEvent.encryptionModeMulticast =
10494 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10495 secEvent.encryptionModeUnicast =
10496 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
10497 palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 );
10498 secEvent.authMode =
10499 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
10500 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
10501 }
10502#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
10503
10504 status = eHAL_STATUS_SUCCESS;
10505 //numItems may be 0 to clear the cache
10506 pSession->NumPmkidCache = (tANI_U16)numItems;
10507 if(numItems && pPMKIDCache)
10508 {
10509 status = palCopyMemory( pMac->hHdd, pSession->PmkidCacheInfo, pPMKIDCache,
10510 sizeof(tPmkidCacheInfo) * numItems );
10511 }
10512 }
10513
10514 return (status);
10515}
10516
10517
10518tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
10519{
10520 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
10521}
10522
10523
10524eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
10525{
10526 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
10527 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
10528
10529 if(pNum && pPmkidCache)
10530 {
10531 if(pSession->NumPmkidCache == 0)
10532 {
10533 *pNum = 0;
10534 status = eHAL_STATUS_SUCCESS;
10535 }
10536 else if(*pNum >= pSession->NumPmkidCache)
10537 {
10538 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
10539 {
10540 smsLog(pMac, LOGE, FL("NumPmkidCache :%d is more than CSR_MAX_PMKID_ALLOWED, resetting to CSR_MAX_PMKID_ALLOWED\n"),
10541 pSession->NumPmkidCache);
10542 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
10543 }
10544 palCopyMemory( pMac->hHdd, pPmkidCache, pSession->PmkidCacheInfo,
10545 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache );
10546 *pNum = pSession->NumPmkidCache;
10547 status = eHAL_STATUS_SUCCESS;
10548 }
10549 }
10550
10551 return (status);
10552}
10553
10554
10555eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
10556{
10557 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
10558 tANI_U32 len;
10559 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
10560
10561 if(pLen)
10562 {
10563 len = *pLen;
10564 *pLen = pSession->nWpaRsnReqIeLength;
10565 if(pBuf)
10566 {
10567 if(len >= pSession->nWpaRsnReqIeLength)
10568 {
10569 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWpaRsnReqIE, pSession->nWpaRsnReqIeLength);
10570 }
10571 }
10572 }
10573
10574 return (status);
10575}
10576
10577
10578eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
10579{
10580 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
10581 tANI_U32 len;
10582 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
10583
10584 if(pLen)
10585 {
10586 len = *pLen;
10587 *pLen = pSession->nWpaRsnRspIeLength;
10588 if(pBuf)
10589 {
10590 if(len >= pSession->nWpaRsnRspIeLength)
10591 {
10592 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWpaRsnRspIE, pSession->nWpaRsnRspIeLength);
10593 }
10594 }
10595 }
10596
10597 return (status);
10598}
10599
10600#ifdef FEATURE_WLAN_WAPI
10601eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
10602{
10603 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
10604 tANI_U32 len;
10605 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
10606 if(pLen)
10607 {
10608 len = *pLen;
10609 *pLen = pSession->nWapiReqIeLength;
10610 if(pBuf)
10611 {
10612 if(len >= pSession->nWapiReqIeLength)
10613 {
10614 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWapiReqIE, pSession->nWapiReqIeLength);
10615 }
10616 }
10617 }
10618
10619 return (status);
10620}
10621
10622eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
10623{
10624 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
10625 tANI_U32 len;
10626 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
10627
10628 if(pLen)
10629 {
10630 len = *pLen;
10631 *pLen = pSession->nWapiRspIeLength;
10632 if(pBuf)
10633 {
10634 if(len >= pSession->nWapiRspIeLength)
10635 {
10636 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWapiRspIE, pSession->nWapiRspIeLength);
10637 }
10638 }
10639 }
10640
10641 return (status);
10642}
10643#endif /* FEATURE_WLAN_WAPI */
10644
10645eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
10646{
10647 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
10648 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
10649
10650 if(CSR_IS_ROAMING(pSession))
10651 {
10652 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
10653 pSession->fRoaming = eANI_BOOLEAN_FALSE;
10654 }
10655
10656 return (retStatus);
10657}
10658
10659
10660//This function remove the connected BSS from te cached scan result
10661eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
10662 tCsrRoamConnectedProfile *pConnProfile)
10663{
10664 eHalStatus status = eHAL_STATUS_FAILURE;
10665 tCsrScanResultFilter *pScanFilter = NULL;
10666 tListElem *pEntry;
10667 tCsrScanResult *pResult;
10668 tDot11fBeaconIEs *pIes;
10669 tANI_BOOLEAN fMatch;
10670
10671 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
10672 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
10673 {
10674 do
10675 {
10676 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
10677 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
10678 if(!HAL_STATUS_SUCCESS(status)) break;
10679 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
10680 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->BSSIDs.bssid, sizeof(tCsrBssid));
10681 if(!HAL_STATUS_SUCCESS(status)) break;
10682 palCopyMemory(pMac->hHdd, pScanFilter->BSSIDs.bssid, &pConnProfile->bssid, sizeof(tCsrBssid));
10683 pScanFilter->BSSIDs.numOfBSSIDs = 1;
10684 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
10685 {
10686 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->SSIDs.SSIDList, sizeof(tCsrSSIDInfo));
10687 if(!HAL_STATUS_SUCCESS(status)) break;
10688 palCopyMemory(pMac->hHdd, &pScanFilter->SSIDs.SSIDList[0].SSID, &pConnProfile->SSID, sizeof(tSirMacSSid));
10689 }
10690 pScanFilter->authType.numEntries = 1;
10691 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
10692 pScanFilter->BSSType = pConnProfile->BSSType;
10693 pScanFilter->EncryptionType.numEntries = 1;
10694 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
10695 pScanFilter->mcEncryptionType.numEntries = 1;
10696 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
10697 //We ignore the channel for now, BSSID should be enough
10698 pScanFilter->ChannelInfo.numOfChannels = 0;
10699 //Also ignore the following fields
10700 pScanFilter->uapsd_mask = 0;
10701 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
10702 pScanFilter->countryCode[0] = 0;
10703 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
10704
10705 csrLLLock(&pMac->scan.scanResultList);
10706 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
10707 while( pEntry )
10708 {
10709 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
10710 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
10711 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
10712 pScanFilter, NULL, NULL, NULL, &pIes);
10713 //Release the IEs allocated by csrMatchBSS is needed
10714 if( !pResult->Result.pvIes )
10715 {
10716 //need to free the IEs since it is allocated by csrMatchBSS
10717 palFreeMemory(pMac->hHdd, pIes);
10718 }
10719 if(fMatch)
10720 {
10721 //We found the one
10722 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
10723 {
10724 //Free the memory
10725 csrFreeScanResultEntry( pMac, pResult );
10726 }
10727 break;
10728 }
10729 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
10730 }//while
10731 csrLLUnlock(&pMac->scan.scanResultList);
10732 }while(0);
10733 if(pScanFilter)
10734 {
10735 csrFreeScanFilter(pMac, pScanFilter);
10736 palFreeMemory(pMac->hHdd, pScanFilter);
10737 }
10738 }
10739 return (status);
10740}
10741
10742
10743
10744//BT-AMP
10745
10746eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
10747{
10748 eHalStatus status = eHAL_STATUS_SUCCESS;
10749 tANI_U32 sessionId;
10750
10751 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
10752 {
10753 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
10754 {
10755 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
10756 {
10757 //co-exist with IBSS or BT-AMP is not supported
10758 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d\n", sessionId );
10759 status = eHAL_STATUS_CSR_WRONG_STATE;
10760 break;
10761 }
10762 if( csrIsConnStateInfra( pMac, sessionId ) )
10763 {
10764 if( chnId &&
10765 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
10766 {
10767 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)\n",
10768 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
10769 status = eHAL_STATUS_CSR_WRONG_STATE;
10770 break;
10771 }
10772 }
10773 }
10774 }
10775
10776 return ( status );
10777}
10778
10779
10780static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
10781{
10782 eHalStatus status = eHAL_STATUS_SUCCESS;
10783 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
10784 tBssConfigParam bssConfig;
10785
10786 if ( csrIsConnStateIbss( pMac, sessionId ) )
10787 {
10788 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
10789 }
10790 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
10791 {
10792 // Disassociate from the connected Infrastructure network...
10793 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
10794 }
10795 else
10796 {
10797#if defined(VOSS_ENABLED)
10798 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
10799 //Otherwise we need to add code to handle the
10800 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
10801 //send stop_bss to PE, before we can continue.
10802 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
10803#endif
10804 palZeroMemory(pMac->hHdd, &bssConfig, sizeof(tBssConfigParam));
10805 /* Assume HDD provide bssid in profile */
10806 palCopyMemory( pMac->hHdd, &pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0], sizeof(tCsrBssid) );
10807 // there is no Bss description before we start an WDS so we need
10808 // to adopt all Bss configuration parameters from the Profile.
10809 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
10810 if(HAL_STATUS_SUCCESS(status))
10811 {
10812 //Save profile for late use
10813 csrFreeRoamProfile( pMac, sessionId );
10814 if (HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
10815 (void **)&pSession->pCurRoamProfile,
10816 sizeof(tCsrRoamProfile))))
10817 {
10818 palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile));
10819 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
10820 }
10821
10822 //Prepare some more parameters for this WDS
10823 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, NULL);
10824 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
10825 }
10826 }
10827
10828 return( status );
10829}
10830
10831
10832////////////////////Mail box
10833
10834
10835//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
10836//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
10837static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
10838 tSirBssDescription *pBssDescription,
10839 tANI_U8 *pBuf, tANI_U8 uapsdMask)
10840{
10841 tCsrChannelSet channelGroup;
10842 tSirMacCapabilityInfo *pAP_capabilityInfo;
10843 tAniBool fTmp;
10844 tANI_BOOLEAN found = FALSE;
10845 tANI_U32 size = 0;
10846 tANI_U16 i;
10847
10848 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
10849 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
10850 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
10851 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
10852
10853 // 802.11h
10854 //We can do this because it is in HOST CPU order for now.
10855 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
10856
10857 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
10858 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
10859 {
10860 fTmp = (tAniBool)pal_cpu_to_be32(1);
10861 }
10862 else
10863 fTmp = (tAniBool)0;
10864
10865 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
10866 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool) );
10867 pBuf += sizeof(tAniBool);
10868 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
10869 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
10870
10871 // This is required for 11k test VoWiFi Ent: Test 2.
10872 // We need the power capabilities for Assoc Req.
10873 // This macro is provided by the halPhyCfg.h. We pick our
10874 // max and min capability by the halPhy provided macros
10875 *pBuf++ = MAX_STA_PWR_CAP_DBM;
10876
10877 size = sizeof(pMac->roam.validChannelList);
10878 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
10879 {
10880 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
10881 for ( i = 0; i < size; i++)
10882 {
10883 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
10884
10885 }
10886 }
10887 else
10888 {
10889 smsLog(pMac, LOGE, FL("can not find any valid channel\n"));
10890 *pBuf++ = 0; //tSirSupChnl->numChnl
10891 }
10892
10893 //Check whether it is ok to enter UAPSD
10894#ifndef WLAN_MDM_CODE_REDUCTION_OPT
10895 if( btcIsReadyForUapsd(pMac) )
10896#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
10897 {
10898 *pBuf++ = uapsdMask;
10899 }
10900#ifndef WLAN_MDM_CODE_REDUCTION_OPT
10901 else
10902 {
10903 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)\n"), uapsdMask);
10904 *pBuf++ = 0;
10905 }
10906#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
10907
10908
10909 // move the entire BssDescription into the join request.
10910 palCopyMemory( pMac->hHdd, pBuf, pBssDescription,
10911 pBssDescription->length + sizeof( pBssDescription->length ) );
10912
10913 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
10914}
10915
10916
10917/*
10918 * The communication between HDD and LIM is thru mailbox (MB).
10919 * Both sides will access the data structure "tSirSmeJoinReq".
10920 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
10921 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
10922 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
10923 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
10924 */
10925eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
10926 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes )
10927{
10928 eHalStatus status = eHAL_STATUS_SUCCESS;
10929 tSirSmeJoinReq *pMsg;
10930 tANI_U8 *pBuf;
10931 tANI_U16 msgLen, wTmp, ieLen;
10932 tSirMacRateSet OpRateSet;
10933 tSirMacRateSet ExRateSet;
10934 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
10935 tANI_U32 dwTmp;
10936 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
10937
10938 do {
10939 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
10940 pSession->joinFailStatusCode.reasonCode = 0;
10941 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
10942 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
10943 // IE fields, but the length field in the bssDescription needs to be interpreted to
10944 // determine length of the IE fields.
10945 //
10946 // So, take the size of the JoinReq, subtract the size of the bssDescription and
10947 // add in the length from the bssDescription (then add the size of the 'length' field
10948 // itself because that is NOT included in the length field).
10949 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
10950 pBssDescription->length + sizeof( pBssDescription->length ) +
10951 sizeof( tCsrWpaIe ) + sizeof( tCsrWpaAuthIe ) + sizeof( tANI_U16 ); // add in the size of the WPA IE that we may build.
10952
10953 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
10954 if ( !HAL_STATUS_SUCCESS(status) ) break;
10955 palZeroMemory(pMac->hHdd, pMsg, msgLen);
10956 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_JOIN_REQ);
10957 pMsg->length = pal_cpu_to_be16(msgLen);
10958 pBuf = &pMsg->sessionId;
10959
10960 // sessionId
10961 *pBuf = (tANI_U8)sessionId;
10962 pBuf++;
10963
10964 // transactionId
10965 *pBuf = 0;
10966 *( pBuf + 1 ) = 0;
10967 pBuf += sizeof(tANI_U16);
10968
10969 // ssId
10970 if( pIes->SSID.present && pIes->SSID.num_ssid )
10971 {
10972 // ssId len
10973 *pBuf = pIes->SSID.num_ssid;
10974 pBuf++;
10975 palCopyMemory( pMac->hHdd, pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid );
10976 pBuf += pIes->SSID.num_ssid;
10977 }
10978 else
10979 {
10980 *pBuf = 0;
10981 pBuf++;
10982 }
10983
10984 // selfMacAddr
10985 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
10986 pBuf += sizeof(tSirMacAddr);
10987 // bsstype
10988 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
10989 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
10990 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tSirBssType) );
10991 pBuf += sizeof(tSirBssType);
10992 // dot11mode
10993 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
10994 pBuf++;
10995
10996 //Persona
10997 *pBuf = (tANI_U8)pProfile->csrPersona;
10998 pBuf++;
10999
11000 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
11001 FL("CSR PERSONA=%d"), pProfile->csrPersona);
11002
11003 // uapsdPerAcBitmask
11004 *pBuf = pProfile->uapsd_mask;
11005 pBuf++;
11006
11007
11008
11009#if (WNI_POLARIS_FW_PACKAGE == ADVANCED)
11010#endif /*(WNI_POLARIS_FW_PACKAGE == ADVANCED)*/
11011
11012 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
11013 if (HAL_STATUS_SUCCESS(status) )
11014 {
11015 // OperationalRateSet
11016 if (OpRateSet.numRates) {
11017 *pBuf++ = OpRateSet.numRates;
11018 palCopyMemory(pMac->hHdd, pBuf, OpRateSet.rate, OpRateSet.numRates);
11019 pBuf += OpRateSet.numRates;
11020 } else *pBuf++ = 0;
11021 // ExtendedRateSet
11022 if (ExRateSet.numRates) {
11023 *pBuf++ = ExRateSet.numRates;
11024 palCopyMemory(pMac->hHdd, pBuf, ExRateSet.rate, ExRateSet.numRates);
11025 pBuf += ExRateSet.numRates;
11026 } else *pBuf++ = 0;
11027 }
11028 else
11029 {
11030 *pBuf++ = 0;
11031 *pBuf++ = 0;
11032 }
11033
11034 // rsnIE
11035 if ( csrIsProfileWpa( pProfile ) )
11036 {
11037 // Insert the Wpa IE into the join request
11038 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
11039 (tCsrWpaIe *)( wpaRsnIE ) );
11040 }
11041 else if( csrIsProfileRSN( pProfile ) )
11042 {
11043 // Insert the RSN IE into the join request
11044 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11045 (tCsrRSNIe *)( wpaRsnIE ) );
11046 }
11047#ifdef FEATURE_WLAN_WAPI
11048 else if( csrIsProfileWapi( pProfile ) )
11049 {
11050 // Insert the WAPI IE into the join request
11051 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11052 (tCsrWapiIe *)( wpaRsnIE ) );
11053 }
11054#endif /* FEATURE_WLAN_WAPI */
11055
11056 else
11057 {
11058 ieLen = 0;
11059 }
11060 //remember the IE for future use
11061 if( ieLen )
11062 {
11063 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
11064 {
11065 smsLog(pMac, LOGE, FL(" WPA RSN IE length :%d is more than DOT11F_IE_RSN_MAX_LEN, resetting to %d\n"), ieLen, DOT11F_IE_RSN_MAX_LEN);
11066 ieLen = DOT11F_IE_RSN_MAX_LEN;
11067 }
11068#ifdef FEATURE_WLAN_WAPI
11069 if( csrIsProfileWapi( pProfile ) )
11070 {
11071 //Check whether we need to allocate more memory
11072 if(ieLen > pSession->nWapiReqIeLength)
11073 {
11074 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
11075 {
11076 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
11077 }
11078 status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWapiReqIE, ieLen);
11079 if(!HAL_STATUS_SUCCESS(status)) break;
11080 }
11081 pSession->nWapiReqIeLength = ieLen;
11082 palCopyMemory(pMac->hHdd, pSession->pWapiReqIE, wpaRsnIE, ieLen);
11083 wTmp = pal_cpu_to_be16( ieLen );
11084 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11085 pBuf += sizeof(tANI_U16);
11086 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11087 pBuf += ieLen;
11088 }
11089 else//should be WPA/WPA2 otherwise
11090#endif /* FEATURE_WLAN_WAPI */
11091 {
11092 //Check whether we need to allocate more memory
11093 if(ieLen > pSession->nWpaRsnReqIeLength)
11094 {
11095 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
11096 {
11097 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
11098 }
11099 status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnReqIE, ieLen);
11100 if(!HAL_STATUS_SUCCESS(status)) break;
11101 }
11102 pSession->nWpaRsnReqIeLength = ieLen;
11103 palCopyMemory(pMac->hHdd, pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
11104 wTmp = pal_cpu_to_be16( ieLen );
11105 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11106 pBuf += sizeof(tANI_U16);
11107 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11108 pBuf += ieLen;
11109 }
11110 }
11111 else
11112 {
11113 //free whatever old info
11114 pSession->nWpaRsnReqIeLength = 0;
11115 if(pSession->pWpaRsnReqIE)
11116 {
11117 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
11118 pSession->pWpaRsnReqIE = NULL;
11119 }
11120#ifdef FEATURE_WLAN_WAPI
11121 pSession->nWapiReqIeLength = 0;
11122 if(pSession->pWapiReqIE)
11123 {
11124 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
11125 pSession->pWapiReqIE = NULL;
11126 }
11127#endif /* FEATURE_WLAN_WAPI */
11128 //length is two bytes
11129 *pBuf = 0;
11130 *(pBuf + 1) = 0;
11131 pBuf += 2;
11132 }
11133
11134#ifdef FEATURE_WLAN_CCX
11135 // Never include the cckmIE in an Join Request
11136 //length is two bytes
11137 *pBuf = 0;
11138 *(pBuf + 1) = 0;
11139 pBuf += 2;
11140#endif
11141
11142 // addIEScan
11143 if(pProfile->nAddIEScanLength && pProfile->pAddIEScan)
11144 {
11145 ieLen = pProfile->nAddIEScanLength;
11146
11147 if(ieLen > pSession->nAddIEScanLength)
11148 {
11149 if(pSession->pAddIEScan && pSession->nAddIEScanLength)
11150 {
11151 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
11152 }
11153 status = palAllocateMemory(pMac->hHdd,
11154 (void **)&pSession->pAddIEScan, ieLen);
11155 if(!HAL_STATUS_SUCCESS(status)) break;
11156 }
11157 pSession->nAddIEScanLength = ieLen;
11158 palCopyMemory(pMac->hHdd, pSession->pAddIEScan,
11159 pProfile->pAddIEScan, ieLen);
11160 wTmp = pal_cpu_to_be16( ieLen );
11161 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11162 pBuf += sizeof(tANI_U16);
11163 palCopyMemory( pMac->hHdd, pBuf, pProfile->pAddIEScan, ieLen );
11164 pBuf += ieLen;
11165 }
11166 else
11167 {
11168 pSession->nAddIEScanLength = 0;
11169 if(pSession->pAddIEScan)
11170 {
11171 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
11172 pSession->pAddIEScan = NULL;
11173 }
11174 *pBuf = 0;
11175 *(pBuf + 1) = 0;
11176 pBuf += 2;
11177 }
11178
11179 // addIEAssoc
11180 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
11181 {
11182 ieLen = pProfile->nAddIEAssocLength;
11183
11184 if(ieLen > pSession->nAddIEAssocLength)
11185 {
11186 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
11187 {
11188 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
11189 }
11190 status = palAllocateMemory(pMac->hHdd,
11191 (void **)&pSession->pAddIEAssoc, ieLen);
11192 if(!HAL_STATUS_SUCCESS(status)) break;
11193 }
11194 pSession->nAddIEAssocLength = ieLen;
11195 palCopyMemory(pMac->hHdd, pSession->pAddIEAssoc,
11196 pProfile->pAddIEAssoc, ieLen);
11197 wTmp = pal_cpu_to_be16( ieLen );
11198 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11199 pBuf += sizeof(tANI_U16);
11200 palCopyMemory( pMac->hHdd, pBuf, pProfile->pAddIEAssoc, ieLen );
11201 pBuf += ieLen;
11202 }
11203 else
11204 {
11205 pSession->nAddIEAssocLength = 0;
11206 if(pSession->pAddIEAssoc)
11207 {
11208 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
11209 pSession->pAddIEAssoc = NULL;
11210 }
11211 *pBuf = 0;
11212 *(pBuf + 1) = 0;
11213 pBuf += 2;
11214 }
11215
11216 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
11217 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
11218 pBuf += sizeof(tANI_U32);
11219
11220 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
11221 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
11222 pBuf += sizeof(tANI_U32);
11223
11224#ifdef WLAN_FEATURE_VOWIFI_11R
11225 if (csrIsProfile11r( pProfile ) )
11226 {
11227 // is11Rconnection;
11228 dwTmp = pal_cpu_to_be32(TRUE);
11229 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11230 pBuf += sizeof(tAniBool);
11231 }
11232 else
11233 {
11234 // is11Rconnection;
11235 dwTmp = pal_cpu_to_be32(FALSE);
11236 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11237 pBuf += sizeof(tAniBool);
11238 }
11239#endif
11240
11241#ifdef FEATURE_WLAN_CCX
11242 /* A profile can not be both CCX and 11R. But an 802.11R AP
11243 * may be advertising support for CCX as well. So if we are
11244 * associating Open or explicitly CCX then we will get CCX.
11245 * If we are associating explictly 11R only then we will get
11246 * 11R.
11247 */
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011248 if ((csrIsProfileCCX(pProfile) ||
11249 ((pIes->CCXVersion.present)
11250 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
11251 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
11252 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
11253 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
11254 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
11255 && (!(csrIsProfile11r( pProfile )))
11256 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070011257 {
11258 // isCCXconnection;
11259 dwTmp = pal_cpu_to_be32(TRUE);
11260 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11261 pBuf += sizeof(tAniBool);
11262 }
11263 else
11264 {
11265 //isCCXconnection;
11266 dwTmp = pal_cpu_to_be32(FALSE);
11267 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11268 pBuf += sizeof(tAniBool);
11269 }
11270 {
11271 tCCXTspecInfo ccxTspec;
11272 // CCX-Tspec IEs in the ASSOC request is presently not supported
11273 // so nullify the TSPEC parameters
11274 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
11275 palCopyMemory( pMac->hHdd, pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
11276 pBuf += sizeof(tCCXTspecInfo);
11277 }
11278#endif
11279
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011280#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070011281 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011282 if (pMac->roam.configParam.isFastTransitionEnabled
11283#ifdef FEATURE_WLAN_LFR
11284 || csrRoamIsFastRoamEnabled(pMac)
11285#endif
11286 )
Jeff Johnson295189b2012-06-20 16:38:30 -070011287 {
11288 dwTmp = pal_cpu_to_be32(TRUE);
11289 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11290 pBuf += sizeof(tAniBool);
11291 }
11292 else
11293 {
11294 dwTmp = pal_cpu_to_be32(FALSE);
11295 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11296 pBuf += sizeof(tAniBool);
11297 }
11298#endif
11299
Jeff Johnson43971f52012-07-17 12:26:56 -070011300#ifdef FEATURE_WLAN_LFR
11301 if(csrRoamIsFastRoamEnabled(pMac))
11302 {
11303 //legacy fast roaming enabled
11304 dwTmp = pal_cpu_to_be32(TRUE);
11305 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11306 pBuf += sizeof(tAniBool);
11307 }
11308 else
11309 {
11310 dwTmp = pal_cpu_to_be32(FALSE);
11311 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11312 pBuf += sizeof(tAniBool);
11313 }
11314#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011315 //BssDesc
11316 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
11317 (tANI_U8)pProfile->uapsd_mask);
11318
11319 status = palSendMBMessage(pMac->hHdd, pMsg );
11320 if(!HAL_STATUS_SUCCESS(status))
11321 {
11322 break;
11323 }
11324 //Tush-QoS: notify QoS module that join happening
11325 else
11326 {
11327#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11328 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
11329#endif
11330 }
11331 } while( 0 );
11332 return( status );
11333}
11334
11335
11336eHalStatus csrSendSmeReassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
11337 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile )
11338{
11339 eHalStatus status;
11340 tSirSmeReassocReq *pMsg;
11341 tANI_U8 *pBuf;
11342 v_U8_t acm_mask = 0, uapsd_mask;
11343 tANI_U16 msgLen, ieLen, wTmp;
11344 tANI_U32 dwTmp;
11345 tSirMacRateSet OpRateSet;
11346 tSirMacRateSet ExRateSet;
11347 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11348 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
11349
11350 /* To satisfy klockworks */
11351 if (pBssDescription == NULL)
11352 {
11353 smsLog(pMac, LOGE, FL(" pBssDescription is NULL\n"));
11354 return eHAL_STATUS_FAILURE;
11355 }
11356
11357 do {
11358 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
11359 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
11360 // IE fields, but the length field in the bssDescription needs to be interpreted to
11361 // determine length of the IE fields.
11362 //
11363 // So, take the size of the JoinReq, subtract the size of the bssDescription and
11364 // add in the length from the bssDescription (then add the size of the 'length' field
11365 // itself because that is NOT included in the length field).
11366 msgLen = sizeof( tSirSmeReassocReq ) - sizeof( *pBssDescription ) +
11367 pBssDescription->length + sizeof( pBssDescription->length ) +
11368 sizeof( tCsrWpaIe ) + sizeof( tCsrWpaAuthIe ) + sizeof( tANI_U16 ); // add in the size of the WPA IE that we may build.
11369 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
11370 if ( !HAL_STATUS_SUCCESS(status) ) break;
11371 palZeroMemory(pMac->hHdd, pMsg, msgLen);
11372 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REASSOC_REQ);
11373 pMsg->length = pal_cpu_to_be16(msgLen);
11374 pBuf = &pMsg->sessionId;
11375 // sessionId
11376 *pBuf++ = (tANI_U8)sessionId;
11377 // transactionId
11378 *pBuf = 0;
11379 *(pBuf + 1) = 0;
11380 pBuf += sizeof (tANI_U16);
11381 // ssId
11382 if( pIes->SSID.present && pIes->SSID.num_ssid )
11383 {
11384 // ssId len
11385 *pBuf++ = pIes->SSID.num_ssid;
11386 palCopyMemory( pMac->hHdd, pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid );
11387 pBuf += pIes->SSID.num_ssid;
11388 }
11389 else
11390 {
11391 *pBuf++ = 0;
11392 }
11393 // selfMacAddr
11394 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
11395 pBuf += sizeof(tSirMacAddr);
11396 // bsstype
11397 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
11398 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tSirBssType) );
11399 pBuf += sizeof(tSirBssType);
11400 // dot11mode
11401 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
11402 pBuf++;
11403
11404 //Persona
11405 *pBuf = (tANI_U8)pProfile->csrPersona;
11406 pBuf++;
11407
11408 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL, FL("CSR PERSONA=%d\n"), pProfile->csrPersona);
11409
11410 // uapsdPerAcBitmask
11411 *pBuf = pProfile->uapsd_mask;
11412 pBuf++;
11413
11414
11415
11416 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode,
11417 pBssDescription, pIes, &OpRateSet, &ExRateSet);
11418 if (HAL_STATUS_SUCCESS(status) )
11419 {
11420 // OperationalRateSet
11421 if (OpRateSet.numRates)
11422 {
11423 *pBuf++ = OpRateSet.numRates;
11424 palCopyMemory(pMac->hHdd, pBuf, OpRateSet.rate, OpRateSet.numRates);
11425 pBuf += OpRateSet.numRates;
11426 }
11427 else *pBuf++ = 0;
11428 // ExtendedRateSet
11429 if (ExRateSet.numRates)
11430 {
11431 *pBuf++ = ExRateSet.numRates;
11432 palCopyMemory(pMac->hHdd, pBuf, ExRateSet.rate, ExRateSet.numRates);
11433 pBuf += ExRateSet.numRates;
11434 }
11435 else *pBuf++ = 0;
11436 }
11437 else
11438 {
11439 *pBuf++ = 0;
11440 *pBuf++ = 0;
11441 }
11442
11443 // rsnIE
11444 if ( csrIsProfileWpa( pProfile ) )
11445 {
11446 // Insert the Wpa IE into the join request
11447 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
11448 (tCsrWpaIe *)( wpaRsnIE ) );
11449 }
11450 else if( csrIsProfileRSN( pProfile ) )
11451 {
11452 // Insert the RSN IE into the join request
11453 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11454 (tCsrRSNIe *)( wpaRsnIE ) );
11455 }
11456#ifdef FEATURE_WLAN_WAPI
11457 else if( csrIsProfileWapi( pProfile ) )
11458 {
11459 // Insert the WAPI IE into the join request
11460 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11461 (tCsrWapiIe *)( wpaRsnIE) );
11462 }
11463#endif /* FEATURE_WLAN_WAPI */
11464 else
11465 {
11466 ieLen = 0;
11467 }
11468 //remember the IE for future use
11469 if( ieLen )
11470 {
11471 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
11472 {
11473 smsLog(pMac, LOGE, FL(" WPA RSN IE length :%d is more than DOT11F_IE_RSN_MAX_LEN, resetting to %d\n"), ieLen, DOT11F_IE_RSN_MAX_LEN);
11474 ieLen = DOT11F_IE_RSN_MAX_LEN;
11475 }
11476
11477 //Check whether we need to allocate more memory
11478 if(ieLen > pSession->nWpaRsnReqIeLength)
11479 {
11480 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
11481 {
11482 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
11483 }
11484 status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnReqIE, ieLen);
11485 if(!HAL_STATUS_SUCCESS(status)) break;
11486 }
11487 pSession->nWpaRsnReqIeLength = ieLen;
11488 palCopyMemory(pMac->hHdd, pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
11489 wTmp = pal_cpu_to_be16( ieLen );
11490 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11491 pBuf += sizeof(tANI_U16);
11492 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11493 pBuf += ieLen;
11494 }
11495 else
11496 {
11497 //free whatever old info
11498 pSession->nWpaRsnReqIeLength = 0;
11499 if(pSession->pWpaRsnReqIE)
11500 {
11501 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
11502 pSession->pWpaRsnReqIE = NULL;
11503 }
11504 //length is two bytes
11505 *pBuf = 0;
11506 *(pBuf + 1) = 0;
11507 pBuf += 2;
11508 }
11509
11510#ifdef FEATURE_WLAN_CCX
11511 // cckmIE
11512 if( csrIsProfileCCX( pProfile ) )
11513 {
11514 // Insert the CCKM IE into the join request
11515 ieLen = csrConstructCcxCckmIe( pMac,
11516 pSession,
11517 pProfile,
11518 pBssDescription,
11519 pSession->pWpaRsnReqIE,
11520 pSession->nWpaRsnReqIeLength,
11521 (void *)( wpaRsnIE ) );
11522 }
11523 else
11524 {
11525 ieLen = 0;
11526 }
11527 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
11528 if( ieLen )
11529 {
11530 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
11531 wTmp = pal_cpu_to_be16( ieLen );
11532 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11533 pBuf += sizeof(tANI_U16);
11534 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11535 pBuf += ieLen;
11536 }
11537 else
11538 {
11539 //Indicate you have no CCKM IE
11540 //length is two bytes
11541 *pBuf = 0;
11542 *(pBuf + 1) = 0;
11543 pBuf += 2;
11544 }
11545#endif /* FEATURE_WLAN_CCX */
11546
11547 // addIEScan
11548 if(pProfile->nAddIEScanLength && pProfile->pAddIEScan)
11549 {
11550 ieLen = pProfile->nAddIEScanLength;
11551
11552 if(ieLen > pSession->nAddIEScanLength)
11553 {
11554 if(pSession->pAddIEScan && pSession->nAddIEScanLength)
11555 {
11556 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
11557 }
11558 status = palAllocateMemory(pMac->hHdd,
11559 (void **)&pSession->pAddIEScan, ieLen);
11560 if(!HAL_STATUS_SUCCESS(status)) break;
11561 }
11562 pSession->nAddIEScanLength = ieLen;
11563 palCopyMemory(pMac->hHdd, pSession->pAddIEScan,
11564 pProfile->pAddIEScan, ieLen);
11565 wTmp = pal_cpu_to_be16( ieLen );
11566 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11567 pBuf += sizeof(tANI_U16);
11568 palCopyMemory( pMac->hHdd, pBuf, pProfile->pAddIEScan, ieLen );
11569 pBuf += ieLen;
11570 }
11571 else
11572 {
11573 pSession->nAddIEScanLength = 0;
11574 if(pSession->pAddIEScan)
11575 {
11576 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
11577 pSession->pAddIEScan = NULL;
11578 }
11579 *pBuf = 0;
11580 *(pBuf + 1) = 0;
11581 pBuf += 2;
11582 }
11583
11584 // addIEAssoc
11585 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
11586 {
11587 ieLen = pProfile->nAddIEAssocLength;
11588
11589 if(ieLen > pSession->nAddIEAssocLength)
11590 {
11591 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
11592 {
11593 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
11594 }
11595 status = palAllocateMemory(pMac->hHdd,
11596 (void **)&pSession->pAddIEAssoc, ieLen);
11597 if(!HAL_STATUS_SUCCESS(status)) break;
11598 }
11599 pSession->nAddIEAssocLength = ieLen;
11600 palCopyMemory(pMac->hHdd, pSession->pAddIEAssoc,
11601 pProfile->pAddIEAssoc, ieLen);
11602 wTmp = pal_cpu_to_be16( ieLen );
11603 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11604 pBuf += sizeof(tANI_U16);
11605 palCopyMemory( pMac->hHdd, pBuf, pProfile->pAddIEAssoc, ieLen );
11606 pBuf += ieLen;
11607 }
11608 else
11609 {
11610 pSession->nAddIEAssocLength = 0;
11611 if(pSession->pAddIEAssoc)
11612 {
11613 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
11614 pSession->pAddIEAssoc = NULL;
11615 }
11616 *pBuf = 0;
11617 *(pBuf + 1) = 0;
11618 pBuf += 2;
11619 }
11620
11621 //Unmask any AC in reassoc that is ACM-set
11622 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
11623 if( uapsd_mask && ( NULL != pBssDescription ) )
11624 {
11625 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
11626 {
11627#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11628 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
11629#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
11630 uapsd_mask &= ~(acm_mask);
11631 }
11632 else
11633 {
11634 uapsd_mask = 0;
11635 }
11636 }
11637
11638 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
11639 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
11640 pBuf += sizeof(tANI_U32);
11641
11642 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
11643 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
11644 pBuf += sizeof(tANI_U32);
11645
11646#ifdef WLAN_FEATURE_VOWIFI_11R
11647 // is11Rconnection;
11648 dwTmp = csrIsProfile11r( pProfile )? pal_cpu_to_be32(TRUE) : 0;
11649 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11650 pBuf += sizeof(tAniBool);
11651
11652#ifdef FEATURE_WLAN_CCX
11653 //isCCXconnection;
11654 //CCKM profile, ccxversion ie present, not 11r and ini file has CCX enabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011655 dwTmp = ( ((csrIsProfileCCX(pProfile) ||
11656 ((pIes->CCXVersion.present)
11657 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
11658 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
11659 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
11660 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
11661 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
11662 && (!(csrIsProfile11r( pProfile )))
11663 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
11664 ? pal_cpu_to_be32(TRUE) : 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011665 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11666 pBuf += sizeof(tAniBool);
11667#endif // FEATURE_WLAN_CCX
11668#endif // WLAN_FEATURE_VOWIFI_11R
11669
11670#ifdef FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011671 if ((csrIsProfileCCX(pProfile) ||
11672 ((pIes->CCXVersion.present)
11673 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
11674 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
11675 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
11676 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
11677 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
11678 && (!(csrIsProfile11r( pProfile )))
11679 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070011680 {
11681 tCCXTspecInfo ccxTspec;
11682
11683 // CCX Tspec information
11684 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
11685 ccxTspec.numTspecs = sme_QosCCxRetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &ccxTspec.tspec[0]);
11686 *pBuf = ccxTspec.numTspecs;
11687 pBuf += sizeof(tANI_U8);
11688
11689 // Copy the TSPEC information only if present
11690 if (ccxTspec.numTspecs) {
11691 palCopyMemory(pMac->hHdd, pBuf, (void*)&ccxTspec.tspec[0], (ccxTspec.numTspecs*sizeof(tTspecInfo)));
11692 }
11693 pBuf += sizeof(ccxTspec.tspec);
11694 }
11695 else
11696 {
11697 {
11698 tCCXTspecInfo ccxTspec;
11699 // CCX-Tspec IEs in the ASSOC request is presently not supported
11700 // so nullify the TSPEC parameters
11701 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
11702 palCopyMemory( pMac->hHdd, pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
11703 pBuf += sizeof(tCCXTspecInfo);
11704 }
11705 }
11706#endif // FEATURE_WLAN_CCX
11707
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011708#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070011709 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011710 if (pMac->roam.configParam.isFastTransitionEnabled
11711#ifdef FEATURE_WLAN_LFR
11712 || csrRoamIsFastRoamEnabled(pMac)
11713#endif
11714 )
Jeff Johnson295189b2012-06-20 16:38:30 -070011715 {
11716 dwTmp = pal_cpu_to_be32(TRUE);
11717 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11718 pBuf += sizeof(tAniBool);
11719 }
11720 else
11721 {
11722 dwTmp = pal_cpu_to_be32(FALSE);
11723 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11724 pBuf += sizeof(tAniBool);
11725 }
11726#endif
11727
Jeff Johnson43971f52012-07-17 12:26:56 -070011728#ifdef FEATURE_WLAN_LFR
11729 if(csrRoamIsFastRoamEnabled(pMac))
11730 {
11731 //legacy fast roaming enabled
11732 dwTmp = pal_cpu_to_be32(TRUE);
11733 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11734 pBuf += sizeof(tAniBool);
11735 }
11736 else
11737 {
11738 dwTmp = pal_cpu_to_be32(FALSE);
11739 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11740 pBuf += sizeof(tAniBool);
11741 }
11742#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011743 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf, uapsd_mask);
11744
11745#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11746 //Tush-QoS: notify QoS module that reassoc happening
11747 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
11748#endif
11749 status = palSendMBMessage( pMac->hHdd, pMsg );
11750 } while( 0 );
11751
11752 return( status );
11753
11754}
11755
11756
11757//
11758eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
11759{
11760 eHalStatus status = eHAL_STATUS_SUCCESS;
11761 tSirSmeDisassocReq *pMsg;
11762 tANI_U8 *pBuf;
11763 tANI_U16 wTmp;
11764#ifdef WLAN_SOFTAP_FEATURE
11765 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11766 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
11767 return eHAL_STATUS_FAILURE;
11768#endif
11769
11770 do {
11771 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDisassocReq ));
11772 if ( !HAL_STATUS_SUCCESS(status) ) break;
11773 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDisassocReq ));
11774 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
11775 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
11776
11777 pBuf = &pMsg->sessionId;
11778 // sessionId
11779 *pBuf++ = (tANI_U8)sessionId;
11780 // transactionId
11781 *pBuf = 0;
11782 *( pBuf + 1 ) = 0;
11783 pBuf += sizeof(tANI_U16);
11784
11785#ifdef WLAN_SOFTAP_FEATURE
11786 if ( (pSession->pCurRoamProfile != NULL ) &&
11787 ( reasonCode == eSIR_MAC_UNSPEC_FAILURE_REASON ) &&
11788 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) || (CSR_IS_WDS_AP(pSession->pCurRoamProfile))))
11789 {
11790 // Set the bssid address before sending the message to LIM
11791 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pSession->selfMacAddr, sizeof( tSirMacAddr ) );
11792 pBuf = pBuf + sizeof ( tSirMacAddr );
11793
11794 // Set the peer MAC address before sending the message to LIM
11795 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ) ); //perMacAddr is passed as bssId for softAP
11796 pBuf = pBuf + sizeof ( tSirMacAddr );
11797 }
11798 else
11799 {
11800#endif
11801 // Set the peer MAC address before sending the message to LIM
11802 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ) );
11803 pBuf = pBuf + sizeof ( tSirMacAddr );
11804
11805 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ) );
11806 pBuf = pBuf + sizeof ( tSirMacAddr );
11807#ifdef WLAN_SOFTAP_FEATURE
11808 }
11809#endif
11810 if(!HAL_STATUS_SUCCESS(status))
11811 {
11812 palFreeMemory(pMac->hHdd, pMsg);
11813 break;
11814 }
11815
11816 // reasonCode
11817 wTmp = pal_cpu_to_be16(reasonCode);
11818 status = palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11819 if(!HAL_STATUS_SUCCESS(status))
11820 {
11821 palFreeMemory(pMac->hHdd, pMsg);
11822 break;
11823 }
11824 pBuf += sizeof(tANI_U16);
11825
11826 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
11827 Here we should not send the disassoc over the air to the AP */
11828 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
11829#ifdef WLAN_FEATURE_VOWIFI_11R
11830 && csrRoamIs11rAssoc(pMac)
11831#endif
11832 )
11833 {
11834 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
11835 }
11836 pBuf += sizeof(tANI_U8);
11837 status = palSendMBMessage( pMac->hHdd, pMsg );
11838
11839 } while( 0 );
11840
11841 return( status );
11842}
11843
11844#ifdef WLAN_SOFTAP_FEATURE
11845eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
11846{
11847 eHalStatus status = eHAL_STATUS_SUCCESS;
11848 tSirSmeTkipCntrMeasReq *pMsg;
11849 tANI_U8 *pBuf;
11850
11851 do
11852 {
11853 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeTkipCntrMeasReq ));
11854 if ( !HAL_STATUS_SUCCESS(status) ) break;
11855 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeTkipCntrMeasReq ));
11856 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
11857 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
11858
11859 pBuf = &pMsg->sessionId;
11860 // sessionId
11861 *pBuf++ = (tANI_U8)sessionId;
11862 // transactionId
11863 *pBuf = 0;
11864 *( pBuf + 1 ) = 0;
11865 pBuf += sizeof(tANI_U16);
11866 // bssid
11867 status = palCopyMemory( pMac->hHdd, pMsg->bssId, bssId, sizeof( tSirMacAddr ) );
11868 pBuf = pBuf + sizeof ( tSirMacAddr );
11869 // bEnable
11870 *pBuf = (tANI_BOOLEAN)bEnable;
11871 if(!HAL_STATUS_SUCCESS(status))
11872 {
11873 palFreeMemory(pMac->hHdd, pMsg);
11874 break;
11875 }
11876
11877 status = palSendMBMessage( pMac->hHdd, pMsg );
11878
11879 } while( 0 );
11880
11881 return( status );
11882}
11883
11884eHalStatus
11885csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
11886 VOS_MODULE_ID modId, tSirMacAddr bssId,
11887 void *pUsrContext, void *pfnSapEventCallback,
11888 tANI_U8 *pAssocStasBuf )
11889{
11890 eHalStatus status = eHAL_STATUS_SUCCESS;
11891 tSirSmeGetAssocSTAsReq *pMsg;
11892 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
11893 tANI_U32 dwTmp;
11894
11895 do
11896 {
11897 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeGetAssocSTAsReq ) );
11898 if (!HAL_STATUS_SUCCESS(status)) break;
11899 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirSmeGetAssocSTAsReq ) );
11900 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
11901
11902 pBuf = (tANI_U8 *)&pMsg->bssId;
11903 wTmpBuf = pBuf;
11904
11905 // bssId
11906 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr) );
11907 pBuf += sizeof(tSirMacAddr);
11908
11909 // modId
11910 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
11911 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
11912 pBuf += sizeof(tANI_U16);
11913
11914 // pUsrContext
11915 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
11916 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
11917 pBuf += sizeof(tANI_U32);
11918
11919 // pfnSapEventCallback
11920 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
11921 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
11922 pBuf += sizeof(tANI_U32);
11923
11924 // pAssocStasBuf
11925 dwTmp = pal_cpu_to_be32((tANI_U32)pAssocStasBuf);
11926 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
11927 pBuf += sizeof(tANI_U32);
11928
11929 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
11930
11931 status = palSendMBMessage( pMac->hHdd, pMsg );
11932 } while( 0 );
11933
11934 return( status );
11935 }
11936
11937eHalStatus
11938csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
11939 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
11940 {
11941 eHalStatus status = eHAL_STATUS_SUCCESS;
11942 tSirSmeGetWPSPBCSessionsReq *pMsg;
11943 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
11944 tANI_U32 dwTmp;
11945
11946 do
11947 {
11948 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirSmeGetWPSPBCSessionsReq) );
11949 if (!HAL_STATUS_SUCCESS(status)) break;
11950 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ) );
11951 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
11952
11953 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
11954 wTmpBuf = pBuf;
11955
11956 // pUsrContext
11957 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
11958 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
11959 pBuf += sizeof(tANI_U32);
11960
11961 // pSapEventCallback
11962 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
11963 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
11964 pBuf += sizeof(tANI_U32);
11965
11966 // bssId
11967 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr) );
11968 pBuf += sizeof(tSirMacAddr);
11969
11970 // MAC Address of STA in WPS session
11971 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
11972 pBuf += sizeof(v_MACADDR_t);
11973
11974 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
11975
11976 status = palSendMBMessage( pMac->hHdd, pMsg );
11977
11978 } while( 0 );
11979
11980 return( status );
11981}
11982#endif
11983
11984eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
11985{
11986 eHalStatus status = eHAL_STATUS_SUCCESS;
11987 tSirSmeDeauthReq *pMsg;
11988 tANI_U8 *pBuf;
11989 tANI_U16 wTmp;
11990 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11991 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
11992 return eHAL_STATUS_FAILURE;
11993
11994 do {
11995 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDeauthReq ));
11996 if ( !HAL_STATUS_SUCCESS(status) ) break;
11997 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDeauthReq ));
11998 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
11999 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
12000 //sessionId
12001 pBuf = &pMsg->sessionId;
12002 *pBuf++ = (tANI_U8)sessionId;
12003
12004 //tansactionId
12005 *pBuf = 0;
12006 *(pBuf + 1 ) = 0;
12007 pBuf += sizeof(tANI_U16);
12008
12009 if ((pSession->pCurRoamProfile != NULL) && (
12010#ifdef WLAN_SOFTAP_FEATURE
12011 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
12012#endif
12013 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
12014 // Set the BSSID before sending the message to LIM
12015 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pSession->selfMacAddr, sizeof( pMsg->peerMacAddr ) );
12016 pBuf = pBuf + sizeof(tSirMacAddr);
12017 }
12018 else
12019 {
12020 // Set the BSSID before sending the message to LIM
12021 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
12022 pBuf = pBuf + sizeof(tSirMacAddr);
12023
12024 }
12025 if(!HAL_STATUS_SUCCESS(status))
12026 {
12027 palFreeMemory(pMac->hHdd, pMsg);
12028 break;
12029 }
12030 // Set the peer MAC address before sending the message to LIM
12031 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
12032 pBuf = pBuf + sizeof(tSirMacAddr);
12033 if(!HAL_STATUS_SUCCESS(status))
12034 {
12035 palFreeMemory(pMac->hHdd, pMsg);
12036 break;
12037 }
12038 wTmp = pal_cpu_to_be16(reasonCode);
12039 status = palCopyMemory( pMac->hHdd, pBuf, &wTmp,sizeof( tANI_U16 ) );
12040 if(!HAL_STATUS_SUCCESS(status))
12041 {
12042 palFreeMemory(pMac->hHdd, pMsg);
12043 break;
12044 }
12045 status = palSendMBMessage( pMac->hHdd, pMsg );
12046
12047 } while( 0 );
12048
12049 return( status );
12050}
12051
12052
12053eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
12054{
12055 eHalStatus status = eHAL_STATUS_SUCCESS;
12056 tSirSmeDisassocCnf *pMsg;
12057
12058 do {
12059 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDisassocCnf ));
12060 if ( !HAL_STATUS_SUCCESS(status) ) break;
12061 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDisassocCnf ));
12062 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
12063 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12064 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
12065 status = palCopyMemory(pMac->hHdd, pMsg->peerMacAddr, pDisassocInd->peerMacAddr, sizeof(pMsg->peerMacAddr));
12066 if(!HAL_STATUS_SUCCESS(status))
12067 {
12068 palFreeMemory(pMac->hHdd, pMsg);
12069 break;
12070 }
12071//To test reconn
12072 status = palCopyMemory(pMac->hHdd, pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
12073 if(!HAL_STATUS_SUCCESS(status))
12074 {
12075 palFreeMemory(pMac->hHdd, pMsg);
12076 break;
12077 }
12078//To test reconn ends
12079
12080 status = palSendMBMessage( pMac->hHdd, pMsg );
12081
12082 } while( 0 );
12083
12084 return( status );
12085}
12086
12087
12088eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
12089{
12090 eHalStatus status = eHAL_STATUS_SUCCESS;
12091 tSirSmeDeauthCnf *pMsg;
12092
12093 do {
12094 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDeauthCnf ));
12095 if ( !HAL_STATUS_SUCCESS(status) ) break;
12096 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDeauthCnf ));
12097 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
12098 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12099 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
12100 status = palCopyMemory(pMac->hHdd, pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
12101 if(!HAL_STATUS_SUCCESS(status))
12102 {
12103 palFreeMemory(pMac->hHdd, pMsg);
12104 break;
12105 }
12106 status = palCopyMemory(pMac->hHdd, pMsg->peerMacAddr, pDeauthInd->peerMacAddr, sizeof(pMsg->peerMacAddr));
12107 if(!HAL_STATUS_SUCCESS(status))
12108 {
12109 palFreeMemory(pMac->hHdd, pMsg);
12110 break;
12111 }
12112
12113 status = palSendMBMessage( pMac->hHdd, pMsg );
12114
12115 } while( 0 );
12116
12117 return( status );
12118}
12119
12120eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
12121{
12122 eHalStatus status = eHAL_STATUS_SUCCESS;
12123 tSirSmeAssocCnf *pMsg;
12124 tANI_U8 *pBuf;
12125 tSirResultCodes statusCode;
12126 tANI_U16 wTmp;
12127
12128 do {
12129 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeAssocCnf ));
12130 if ( !HAL_STATUS_SUCCESS(status) ) break;
12131 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeAssocCnf ));
12132 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
12133 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
12134
12135 pBuf = (tANI_U8 *)&pMsg->statusCode;
12136 if(HAL_STATUS_SUCCESS(Halstatus))
12137 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12138 else
12139 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
12140 palCopyMemory( pMac->hHdd, pBuf, &statusCode, sizeof(tSirResultCodes) );
12141 pBuf += sizeof(tSirResultCodes);
12142 // bssId
12143 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12144 pBuf += sizeof (tSirMacAddr);
12145 // peerMacAddr
12146 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
12147 pBuf += sizeof (tSirMacAddr);
12148 // aid
12149 wTmp = pal_cpu_to_be16(pAssocInd->aid);
12150 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12151 pBuf += sizeof (tANI_U16);
12152 // alternateBssId
12153 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12154 pBuf += sizeof (tSirMacAddr);
12155 // alternateChannelId
12156 *pBuf = 11;
12157
12158 status = palSendMBMessage( pMac->hHdd, pMsg );
12159 if(!HAL_STATUS_SUCCESS(status))
12160 {
12161 //pMsg is freed by palSendMBMessage
12162 break;
12163 }
12164
12165 } while( 0 );
12166
12167 return( status );
12168}
12169
12170#ifdef WLAN_SOFTAP_FEATURE
12171eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
12172 tpSirSmeAssocInd pAssocInd,
12173 eHalStatus Halstatus,
12174 tANI_U8 sessionId)
12175{
12176 tSirMsgQ msgQ;
12177 eHalStatus status = eHAL_STATUS_SUCCESS;
12178 tSirSmeAssocIndToUpperLayerCnf *pMsg;
12179 tANI_U8 *pBuf;
12180 tSirResultCodes statusCode;
12181 tANI_U16 wTmp;
12182
12183 do {
12184 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ));
12185 if ( !HAL_STATUS_SUCCESS(status) ) break;
12186 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ));
12187 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
12188 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
12189
12190 pMsg->sessionId = sessionId;
12191
12192 pBuf = (tANI_U8 *)&pMsg->statusCode;
12193 if(HAL_STATUS_SUCCESS(Halstatus))
12194 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12195 else
12196 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
12197 palCopyMemory( pMac->hHdd, pBuf, &statusCode, sizeof(tSirResultCodes) );
12198 pBuf += sizeof(tSirResultCodes);
12199 // bssId
12200 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12201 pBuf += sizeof (tSirMacAddr);
12202 // peerMacAddr
12203 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
12204 pBuf += sizeof (tSirMacAddr);
12205 // StaId
12206 wTmp = pal_cpu_to_be16(pAssocInd->staId);
12207 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12208 pBuf += sizeof (tANI_U16);
12209 // alternateBssId
12210 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12211 pBuf += sizeof (tSirMacAddr);
12212 // alternateChannelId
12213 *pBuf = 11;
12214 pBuf += sizeof (tANI_U8);
12215
12216 // Instead of copying roam Info, we just copy only WmmEnabled , RsnIE information
12217 //Wmm
12218 *pBuf = pAssocInd->wmmEnabledSta;
12219 pBuf += sizeof (tANI_U8);
12220
12221 //RSN IE
12222 status = palCopyMemory(pMac->hHdd, (tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
12223 pBuf += sizeof (tSirRSNie);
12224
12225 //Additional IE
12226 status = palCopyMemory(pMac->hHdd, (void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
12227 pBuf += sizeof (tSirAddie);
12228
12229 //reassocReq
12230 *pBuf = pAssocInd->reassocReq;
12231 pBuf += sizeof (tANI_U8);
12232
12233 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
12234 msgQ.bodyptr = pMsg;
12235 msgQ.bodyval = 0;
12236
12237 SysProcessMmhMsg(pMac, &msgQ);
12238
12239 } while( 0 );
12240
12241 return( status );
12242}
12243#endif
12244
12245
12246eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId ,
12247 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
12248 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
12249 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
12250 tANI_U8 *pKeyRsc )
12251{
12252 tSirSmeSetContextReq *pMsg;
12253 tANI_U16 msgLen;
12254 eHalStatus status = eHAL_STATUS_FAILURE;
12255 tAniEdType tmpEdType;
12256 tAniKeyDirection tmpDirection;
12257 tANI_U8 *pBuf;
12258 tANI_U8 *p;
12259 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12260
12261 do {
12262
12263 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
12264
12265 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
12266 // key set. Since we only support upto one key, we always allocate memory for 1 key
12267 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
12268 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
12269 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
12270 ( sizeof( pMsg->keyMaterial.key ) );
12271
12272 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12273 if ( !HAL_STATUS_SUCCESS(status) ) break;
12274 palZeroMemory(pMac->hHdd, pMsg, msgLen);
12275 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
12276 pMsg->length = pal_cpu_to_be16(msgLen);
12277
12278 //sessionId
12279 pBuf = &pMsg->sessionId;
12280 *pBuf = (tANI_U8)sessionId;
12281 pBuf++;
12282 // transactionId
12283 *pBuf = 0;
12284 *(pBuf + 1) = 0;
12285 pBuf += sizeof(tANI_U16);
12286 // peerMacAddr
12287 palCopyMemory( pMac->hHdd, pBuf,
12288 (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr) );
12289
12290 pBuf += sizeof(tSirMacAddr);
12291
12292 // bssId
12293 palCopyMemory( pMac->hHdd, pBuf,
12294 (tANI_U8 *)&pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
12295
12296 pBuf += sizeof(tSirMacAddr);
12297
12298 p = pBuf;
12299
12300 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
12301 // in the tSirKeyMaterial keyMaterial; field).
12302 //
12303 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
12304 // shorter than this max size. Is LIM interpreting this ok ?
12305 p = pal_set_U16( p, pal_cpu_to_be16((tANI_U16)( sizeof( pMsg->keyMaterial.numKeys ) + ( numKeys * sizeof( pMsg->keyMaterial.key ) ) )) );
12306
12307 // set pMsg->keyMaterial.edType
12308 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
12309 palCopyMemory( pMac->hHdd, p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType) );
12310 p += sizeof( pMsg->keyMaterial.edType );
12311
12312 // set the pMsg->keyMaterial.numKeys field
12313 *p = numKeys;
12314 p += sizeof( pMsg->keyMaterial.numKeys );
12315
12316 // set pSirKey->keyId = keyId;
12317 *p = keyId;
12318 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
12319
12320 // set pSirKey->unicast = (tANI_U8)fUnicast;
12321 *p = (tANI_U8)fUnicast;
12322 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
12323
12324 // set pSirKey->keyDirection = aniKeyDirection;
12325 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
12326 palCopyMemory( pMac->hHdd, p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection) );
12327 p += sizeof(tAniKeyDirection);
12328 // pSirKey->keyRsc = ;;
12329 palCopyMemory( pMac->hHdd, p, pKeyRsc, CSR_MAX_RSC_LEN );
12330 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
12331
12332 // set pSirKey->paeRole
12333 *p = paeRole; // 0 is Supplicant
12334 p++;
12335
12336 // set pSirKey->keyLength = keyLength;
12337 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
12338
12339 if ( keyLength && pKey )
12340 {
12341 palCopyMemory( pMac->hHdd, p, pKey, keyLength );
12342 if(keyLength == 16)
12343 {
12344 smsLog(pMac, LOGE, " SME Set keyIdx (%d) encType(%d) key = %02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X\n",
12345 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
12346 pKey[5], pKey[6], pKey[7], pKey[8],
12347 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
12348 }
12349 }
12350
12351 status = palSendMBMessage(pMac->hHdd, pMsg);
12352
12353 } while( 0 );
12354
12355 return( status );
12356}
12357
12358
12359
12360eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
12361 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
12362{
12363 eHalStatus status;
12364 tSirSmeStartBssReq *pMsg;
12365 tANI_U8 *pBuf = NULL;
12366 tANI_U8 *wTmpBuf = NULL;
12367 tANI_U16 msgLen, wTmp;
12368 tANI_U32 dwTmp;
12369 tSirNwType nwType;
12370 tAniCBSecondaryMode cbMode;
12371#ifdef WLAN_SOFTAP_FEATURE
12372 tANI_U32 authType;
12373#endif
12374
12375 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12376 do {
12377 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12378 pSession->joinFailStatusCode.reasonCode = 0;
12379 msgLen = sizeof(tSirSmeStartBssReq);
12380 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12381 if ( !HAL_STATUS_SUCCESS(status) ) break;
12382
12383 palZeroMemory(pMac->hHdd, pMsg, msgLen);
12384 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
12385
12386 pBuf = &pMsg->sessionId;
12387
12388 wTmpBuf = pBuf;
12389
12390 //sessionId
12391 *pBuf = (tANI_U8)sessionId;
12392 pBuf++;
12393 // transactionId
12394 *pBuf = 0;
12395 *(pBuf + 1) = 0;
12396 pBuf += sizeof(tANI_U16);
12397
12398 // bssid
12399 palCopyMemory( pMac->hHdd, pBuf, pParam->bssid, sizeof(tSirMacAddr) );
12400 pBuf += sizeof(tSirMacAddr);
12401 // selfMacAddr
12402 palCopyMemory( pMac->hHdd, pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr) );
12403 pBuf += sizeof(tSirMacAddr);
12404 // beaconInterval
12405 if( pBssDesc && pBssDesc->beaconInterval )
12406 {
12407 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
12408 }
12409#ifdef WLAN_SOFTAP_FEATURE
12410 else if(pParam->beaconInterval)
12411 {
12412 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
12413 }
12414#endif
12415 else
12416 {
12417 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
12418 }
12419 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof( tANI_U16 ) );
12420 pBuf += sizeof(tANI_U16);
12421 // dot11mode
12422 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
12423 pBuf += 1;
12424 // bssType
12425 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
12426 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tSirBssType) );
12427 pBuf += sizeof(tSirBssType);
12428 // ssId
12429 if( pParam->ssId.length )
12430 {
12431 // ssId len
12432 *pBuf = pParam->ssId.length;
12433 pBuf++;
12434 palCopyMemory( pMac->hHdd, pBuf, pParam->ssId.ssId, pParam->ssId.length );
12435 pBuf += pParam->ssId.length;
12436 }
12437 else
12438 {
12439 *pBuf = 0;
12440 pBuf++;
12441 }
12442
12443 // set the channel Id
12444 *pBuf = pParam->operationChn;
12445 pBuf++;
12446 //What should we really do for the cbmode.
12447 cbMode = (tAniCBSecondaryMode)pal_cpu_to_be32(pParam->cbMode);
12448 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&cbMode, sizeof(tAniCBSecondaryMode) );
12449 pBuf += sizeof(tAniCBSecondaryMode);
12450
12451#ifdef WLAN_SOFTAP_FEATURE
12452 // Set privacy
12453 *pBuf = pParam->privacy;
12454 pBuf++;
12455
12456 //Set Uapsd
12457 *pBuf = pParam->ApUapsdEnable;
12458 pBuf++;
12459
12460 //Set SSID hidden
12461 *pBuf = pParam->ssidHidden;
12462 pBuf++;
12463
12464 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
12465 pBuf++;
12466
12467 //Ht protection Enable/Disable
12468 *pBuf = (tANI_U8)pParam->protEnabled;
12469 pBuf++;
12470
12471 //Enable Beacons to Receive for OBSS protection Enable/Disable
12472 *pBuf = (tANI_U8)pParam->obssProtEnabled;
12473 pBuf++;
12474
12475 //set cfg related to protection
12476 wTmp = pal_cpu_to_be16( pParam->ht_protection );
12477 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof( tANI_U16 ) );
12478 pBuf += sizeof(tANI_U16);
12479
12480 // Set Auth type
12481 authType = pal_cpu_to_be32(pParam->authType);
12482 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
12483 pBuf += sizeof(tANI_U32);
12484
12485 // Set DTIM
12486 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
12487 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12488 pBuf += sizeof(tANI_U32);
12489
12490 // Set wps_state
12491 *pBuf = pParam->wps_state;
12492 pBuf++;
12493
12494#endif
12495 //Persona
12496 *pBuf = (tANI_U8)pParam->bssPersona;
12497 pBuf++;
12498
12499
12500
12501 // set RSN IE
12502 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
12503 {
12504 status = eHAL_STATUS_INVALID_PARAMETER;
12505 palFreeMemory( pMac->hHdd, pMsg );
12506 break;
12507 }
12508 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
12509 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12510 pBuf += sizeof(tANI_U16);
12511 if( wTmp )
12512 {
12513 wTmp = pParam->nRSNIELength;
12514 palCopyMemory( pMac->hHdd, pBuf, pParam->pRSNIE, wTmp );
12515 pBuf += wTmp;
12516 }
12517 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
12518 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType) );
12519 pBuf += sizeof(tSirNwType);
12520
12521 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
12522 pBuf++;
12523
12524 palCopyMemory( pMac->hHdd, pBuf, pParam->operationalRateSet.rate, pParam->operationalRateSet.numRates );
12525 pBuf += pParam->operationalRateSet.numRates ;
12526 *pBuf++ = pParam->extendedRateSet.numRates;
12527 if(0 != pParam->extendedRateSet.numRates)
12528 {
12529 palCopyMemory( pMac->hHdd, pBuf, pParam->extendedRateSet.rate, pParam->extendedRateSet.numRates );
12530 pBuf += pParam->extendedRateSet.numRates;
12531 }
12532
12533 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
12534 pMsg->length = pal_cpu_to_be16(msgLen);
12535
12536 status = palSendMBMessage(pMac->hHdd, pMsg);
12537
12538 } while( 0 );
12539
12540 return( status );
12541}
12542
12543
12544eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
12545{
12546 eHalStatus status = eHAL_STATUS_FAILURE;
12547 tSirSmeStopBssReq *pMsg;
12548 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12549 tANI_U8 *pBuf;
12550 tANI_U16 msgLen;
12551
12552 do {
12553 status = palAllocateMemory(pMac, (void **)&pMsg, sizeof(tSirSmeStopBssReq));
12554 if ( !HAL_STATUS_SUCCESS(status) ) break;
12555 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeStopBssReq ));
12556 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
12557 pBuf = &pMsg->sessionId;
12558 //sessionId
12559 *pBuf = (tANI_U8)sessionId;
12560 pBuf++;
12561 // transactionId
12562 *pBuf = 0;
12563 pBuf += sizeof(tANI_U16);
12564 //reason code
12565 *pBuf = 0;
12566 pBuf += sizeof(tSirResultCodes);
12567 // bssid
12568 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
12569 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
12570 {
12571 palCopyMemory( pMac->hHdd, pBuf,(tANI_U8 *)&pSession->selfMacAddr, sizeof(tSirMacAddr) );
12572 }
12573 else
12574 {
12575 palCopyMemory( pMac->hHdd, pBuf,(tANI_U8 *)&pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
12576 }
12577 pBuf += sizeof(tSirMacAddr);
12578 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
12579 pMsg->length = pal_cpu_to_be16(msgLen);
12580
12581 status = palSendMBMessage( pMac->hHdd, pMsg );
12582#if 0
12583 status = palAllocateMemory(pMac, (void **)&pMsg, sizeof(tSirSmeStopBssReq));
12584 if ( !HAL_STATUS_SUCCESS(status) ) break;
12585 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeStopBssReq ));
12586 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
12587 pMsg->reasonCode = 0;
12588 // bssid
12589 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
12590 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
12591 {
12592 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
12593 }
12594 else
12595 {
12596 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
12597 }
12598 palCopyMemory( pMac->hHdd, &pMsg->bssId, pbBssid, sizeof(tSirMacAddr) );
12599 pMsg->transactionId = 0;
12600 pMsg->sessionId = (tANI_U8)sessionId;
12601 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
12602 status = palSendMBMessage( pMac->hHdd, pMsg );
12603#endif
12604 } while( 0 );
12605
12606 return( status );
12607}
12608
12609
12610eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
12611 tCsrRoamModifyProfileFields *pModProfileFields,
12612 tANI_U32 *pRoamId, v_BOOL_t fForce)
12613{
12614
12615 eHalStatus status = eHAL_STATUS_FAILURE;
12616 tANI_U32 roamId = 0;
12617 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12618
12619 if((csrIsConnStateConnected(pMac, sessionId)) &&
12620 (fForce || (!palEqualMemory(pMac->hHdd, &pModProfileFields,
12621 &pSession->connectedProfile.modifyProfileFields,
12622 sizeof(tCsrRoamModifyProfileFields)))) )
12623 {
12624 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
12625 if(pRoamId)
12626 {
12627 *pRoamId = roamId;
12628 }
12629
12630
12631 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
12632 eCsrSmeIssuedReassocToSameAP, roamId,
12633 eANI_BOOLEAN_FALSE);
12634
12635 }
12636
12637 return status;
12638}
12639
12640static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
12641{
12642 eHalStatus status = eHAL_STATUS_SUCCESS;
12643 tCsrRoamInfo roamInfo;
12644
12645 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
12646 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
12647 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
12648 return (status);
12649}
12650
12651eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
12652{
12653 eHalStatus status = eHAL_STATUS_SUCCESS;
12654 tListElem *pEntry = NULL;
12655 tSmeCmd *pCommand = NULL;
12656 tSirSmeAddStaSelfRsp *pRsp;
12657
12658 do
12659 {
12660 if(pMsg == NULL)
12661 {
12662 smsLog(pMac, LOGE, "in %s msg ptr is NULL\n", __FUNCTION__);
12663 status = eHAL_STATUS_FAILURE;
12664 break;
12665 }
12666
12667 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
12668 if(pEntry)
12669 {
12670 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
12671 if(eSmeCommandAddStaSession == pCommand->command)
12672 {
12673 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
12674 smsLog( pMac, LOG1, "Add Sta rsp status = %d\n", pRsp->status );
12675 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
12676
12677 csrRoamSessionOpened(pMac, pCommand->sessionId);
12678
12679 //Remove this command out of the active list
12680 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
12681 {
12682 //Now put this command back on the avilable command list
12683 csrReleaseCommand(pMac, pCommand);
12684 }
12685 smeProcessPendingQueue( pMac );
12686 }
12687 else
12688 {
12689 smsLog(pMac, LOGE, "in %s eWNI_SME_ADD_STA_SELF_RSP Received but NO Add sta session command are ACTIVE ...\n",
12690 __FUNCTION__);
12691 status = eHAL_STATUS_FAILURE;
12692 break;
12693 }
12694 }
12695 else
12696 {
12697 smsLog(pMac, LOGE, "in %s eWNI_SME_ADD_STA_SELF_RSP Received but NO commands are ACTIVE ...\n",
12698 __FUNCTION__);
12699 status = eHAL_STATUS_FAILURE;
12700 break;
12701 }
12702 } while(0);
12703
12704 return status;
12705
12706}
12707
12708eHalStatus csrSendMBAddSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
12709{
12710 tSirSmeAddStaSelfReq *pMsg;
12711 tANI_U16 msgLen;
12712 eHalStatus status = eHAL_STATUS_FAILURE;
12713
12714 do {
12715
12716 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
12717 sizeof( tSirBssType )*/;
12718
12719 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12720 if ( !HAL_STATUS_SUCCESS(status) ) break;
12721
12722 palZeroMemory(pMac->hHdd, pMsg, msgLen);
12723
12724 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
12725 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
12726
12727 // self station address
12728 palCopyMemory( pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr, sizeof(tSirMacAddr) );
12729
12730 smsLog( pMac, LOGE, FL("selfMac=%02x, %02x, %02x, %02x, %02x, %02x\n"),
12731 pMsg->selfMacAddr[0],
12732 pMsg->selfMacAddr[1],
12733 pMsg->selfMacAddr[2],
12734 pMsg->selfMacAddr[3],
12735 pMsg->selfMacAddr[4],
12736 pMsg->selfMacAddr[5]);
12737 status = palSendMBMessage(pMac->hHdd, pMsg);
12738
12739 } while( 0 );
12740
12741 return( status );
12742}
12743
12744eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr sessionMacAddr)
12745{
12746 eHalStatus status = eHAL_STATUS_SUCCESS;
12747 tSmeCmd *pCommand;
12748
12749 pCommand = csrGetCommandBuffer(pMac);
12750 if(NULL == pCommand)
12751 {
12752 status = eHAL_STATUS_RESOURCES;
12753 }
12754 else
12755 {
12756 pCommand->command = eSmeCommandAddStaSession;
12757 pCommand->sessionId = (tANI_U8)sessionId;
12758 palCopyMemory( pMac->hHdd, pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr, sizeof( tSirMacAddr ) );
12759
12760 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
12761 if( !HAL_STATUS_SUCCESS( status ) )
12762 {
12763 //Should be panic??
12764 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
12765 }
12766 }
12767
12768 return (status);
12769}
12770
12771eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
12772{
12773 return csrSendMBAddSelfStaReqMsg( pMac,
12774 pCommand->u.addStaSessionCmd.selfMacAddr );
12775}
12776
12777eHalStatus csrRoamOpenSession( tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext,
12778 tANI_U8 *pSelfMacAddr, tANI_U8 *pbSessionId )
12779{
12780 eHalStatus status = eHAL_STATUS_SUCCESS;
12781 tANI_U32 i;
12782 tCsrRoamSession *pSession;
12783
12784 *pbSessionId = CSR_SESSION_ID_INVALID;
12785 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
12786 {
12787 if( !CSR_IS_SESSION_VALID( pMac, i ) )
12788 {
12789 pSession = CSR_GET_SESSION( pMac, i );
12790 status = eHAL_STATUS_SUCCESS;
12791 pSession->sessionActive = eANI_BOOLEAN_TRUE;
12792 pSession->sessionId = (tANI_U8)i;
12793 pSession->callback = callback;
12794 pSession->pContext = pContext;
12795 palCopyMemory( pMac->hHdd, &pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid) );
12796 *pbSessionId = (tANI_U8)i;
12797
12798 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerRoaming, csrRoamRoamingTimerHandler,
12799 &pSession->roamingTimerInfo);
12800 if(!HAL_STATUS_SUCCESS(status))
12801 {
12802 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer\n"));
12803 break;
12804 }
12805#ifdef FEATURE_WLAN_BTAMP_UT_RF
12806 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerJoinRetry, csrRoamJoinRetryTimerHandler,
12807 &pSession->joinRetryTimerInfo);
12808 if(!HAL_STATUS_SUCCESS(status))
12809 {
12810 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer\n"));
12811 break;
12812 }
12813#endif
12814 pSession->ibssJoinTimerInfo.pMac = pMac;
12815 pSession->ibssJoinTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
12816
12817 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerIbssJoining, csrRoamIbssJoinTimerHandler,
12818 &pSession->ibssJoinTimerInfo);
12819 if(!HAL_STATUS_SUCCESS(status))
12820 {
12821 smsLog(pMac, LOGE, FL("cannot allocate memory for IbssJoining timer\n"));
12822 break;
12823 }
12824 status = csrIssueAddStaForSessionReq ( pMac, i, pSelfMacAddr );
12825 break;
12826 }
12827 }
12828 if( CSR_ROAM_SESSION_MAX == i )
12829 {
12830 //No session is available
12831 status = eHAL_STATUS_RESOURCES;
12832 }
12833
12834 return ( status );
12835}
12836
12837eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
12838{
12839 eHalStatus status = eHAL_STATUS_SUCCESS;
12840 tListElem *pEntry = NULL;
12841 tSmeCmd *pCommand = NULL;
12842 tSirSmeDelStaSelfRsp *pRsp;
12843
12844 do
12845 {
12846 if(pMsg == NULL)
12847 {
12848 smsLog(pMac, LOGE, "in %s msg ptr is NULL\n", __FUNCTION__);
12849 status = eHAL_STATUS_FAILURE;
12850 break;
12851 }
12852
12853 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
12854 if(pEntry)
12855 {
12856 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
12857 if(eSmeCommandDelStaSession == pCommand->command)
12858 {
12859 tANI_U8 sessionId = pCommand->sessionId;
12860
12861 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
12862 smsLog( pMac, LOG1, "Del Sta rsp status = %d\n", pRsp->status );
12863
12864 //This session is done.
12865 csrCleanupSession(pMac, sessionId);
12866
12867 if(pCommand->u.delStaSessionCmd.callback)
12868 {
12869
12870 status = sme_ReleaseGlobalLock( &pMac->sme );
12871 if ( HAL_STATUS_SUCCESS( status ) )
12872 {
12873 pCommand->u.delStaSessionCmd.callback(
12874 pCommand->u.delStaSessionCmd.pContext);
12875 status = sme_AcquireGlobalLock( &pMac->sme );
12876 if (! HAL_STATUS_SUCCESS( status ) )
12877 {
12878 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock\n", __FUNCTION__);
12879 return status;
12880 }
12881 }
12882 else {
12883 smsLog(pMac, LOGE, "%s: Failed to Release Lock\n", __FUNCTION__);
12884 }
12885 }
12886
12887 //Remove this command out of the active list
12888 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
12889 {
12890 //Now put this command back on the avilable command list
12891 csrReleaseCommand(pMac, pCommand);
12892 }
12893 smeProcessPendingQueue( pMac );
12894 }
12895 else
12896 {
12897 smsLog(pMac, LOGE, "in %s eWNI_SME_DEL_STA_SELF_RSP Received but NO Del sta session command are ACTIVE ...\n",
12898 __FUNCTION__);
12899 status = eHAL_STATUS_FAILURE;
12900 break;
12901 }
12902 }
12903 else
12904 {
12905 smsLog(pMac, LOGE, "in %s eWNI_SME_DEL_STA_SELF_RSP Received but NO commands are ACTIVE ...\n",
12906 __FUNCTION__);
12907 status = eHAL_STATUS_FAILURE;
12908 break;
12909 }
12910 } while(0);
12911
12912 return status;
12913
12914}
12915
12916eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
12917{
12918 tSirSmeDelStaSelfReq *pMsg;
12919 tANI_U16 msgLen;
12920 eHalStatus status = eHAL_STATUS_FAILURE;
12921
12922 do {
12923
12924 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
12925 sizeof( tSirBssType )*/;
12926
12927 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12928 if ( !HAL_STATUS_SUCCESS(status) ) break;
12929
12930 palZeroMemory(pMac->hHdd, pMsg, msgLen);
12931
12932 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
12933 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
12934
12935 // self station address
12936 palCopyMemory( pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr, sizeof(tSirMacAddr) );
12937
12938 status = palSendMBMessage(pMac->hHdd, pMsg);
12939
12940 } while( 0 );
12941
12942 return( status );
12943}
12944
12945eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
12946 tSirMacAddr sessionMacAddr,
12947 csrRoamSessionCloseCallback callback,
12948 void *pContext)
12949{
12950 eHalStatus status = eHAL_STATUS_SUCCESS;
12951 tSmeCmd *pCommand;
12952
12953 pCommand = csrGetCommandBuffer(pMac);
12954 if(NULL == pCommand)
12955 {
12956 status = eHAL_STATUS_RESOURCES;
12957 }
12958 else
12959 {
12960 pCommand->command = eSmeCommandDelStaSession;
12961 pCommand->sessionId = (tANI_U8)sessionId;
12962 pCommand->u.delStaSessionCmd.callback = callback;
12963 pCommand->u.delStaSessionCmd.pContext = pContext;
12964 palCopyMemory( pMac->hHdd, pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr, sizeof( tSirMacAddr ) );
12965
12966 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
12967 if( !HAL_STATUS_SUCCESS( status ) )
12968 {
12969 //Should be panic??
12970 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
12971 }
12972 }
12973
12974 return (status);
12975}
12976
12977eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
12978{
12979 return csrSendMBDelSelfStaReqMsg( pMac,
12980 pCommand->u.delStaSessionCmd.selfMacAddr );
12981}
12982
12983static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
12984{
12985 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
12986 tListElem *pEntry, *pNext;
12987 tSmeCmd *pCommand;
12988 tDblLinkList localList;
12989
12990 vos_mem_zero(&localList, sizeof(tDblLinkList));
12991 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
12992 {
12993 smsLog(pMac, LOGE, FL(" failed to open list"));
12994 return;
12995 }
12996
12997 csrLLLock(pList);
12998 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
12999 while(pEntry != NULL)
13000 {
13001 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
13002 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13003 if(pCommand->sessionId == sessionId)
13004 {
13005 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
13006 {
13007 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
13008 }
13009 }
13010 pEntry = pNext;
13011 }
13012 csrLLUnlock(pList);
13013
13014 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
13015 {
13016 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13017 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
13018 }
13019 csrLLClose(&localList);
13020}
13021
13022
13023void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
13024{
13025 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13026 {
13027 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13028
13029 csrRoamStop(pMac, sessionId);
13030 csrFreeConnectBssDesc(pMac, sessionId);
13031 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
13032 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
13033 palTimerFree(pMac->hHdd, pSession->hTimerRoaming);
13034#ifdef FEATURE_WLAN_BTAMP_UT_RF
13035 palTimerFree(pMac->hHdd, pSession->hTimerJoinRetry);
13036#endif
13037 palTimerFree(pMac->hHdd, pSession->hTimerIbssJoining);
13038 purgeSmeSessionCmdList(pMac, sessionId);
13039 purgeCsrSessionCmdList(pMac, sessionId);
13040 csrInitSession(pMac, sessionId);
13041 }
13042}
13043
13044
13045eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
13046 tANI_BOOLEAN fSync,
13047 csrRoamSessionCloseCallback callback,
13048 void *pContext )
13049{
13050 eHalStatus status = eHAL_STATUS_SUCCESS;
13051
13052 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13053 {
13054 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13055 if(fSync)
13056 {
13057 csrCleanupSession(pMac, sessionId);
13058 }
13059 else
13060 {
13061 purgeSmeSessionCmdList(pMac, sessionId);
13062 purgeCsrSessionCmdList(pMac, sessionId);
13063 status = csrIssueDelStaForSessionReq( pMac, sessionId,
13064 pSession->selfMacAddr, callback, pContext);
13065 }
13066 }
13067 else
13068 {
13069 status = eHAL_STATUS_INVALID_PARAMETER;
13070 }
13071
13072 return ( status );
13073}
13074
13075
13076static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
13077{
13078 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13079
13080 pSession->sessionActive = eANI_BOOLEAN_FALSE;
13081 pSession->sessionId = CSR_SESSION_ID_INVALID;
13082 pSession->callback = NULL;
13083 pSession->pContext = NULL;
13084 pSession->ibss_join_pending = FALSE;
13085 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
13086 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
13087 csrFreeRoamProfile( pMac, sessionId );
13088 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
13089 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
13090 csrFreeConnectBssDesc(pMac, sessionId);
13091 csrScanEnable(pMac);
13092 palZeroMemory( pMac->hHdd, &pSession->selfMacAddr, sizeof(tCsrBssid) );
13093 if(pSession->pWpaRsnReqIE)
13094 {
13095 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
13096 pSession->pWpaRsnReqIE = NULL;
13097 }
13098 pSession->nWpaRsnReqIeLength = 0;
13099 if(pSession->pWpaRsnRspIE)
13100 {
13101 palFreeMemory(pMac->hHdd, pSession->pWpaRsnRspIE);
13102 pSession->pWpaRsnRspIE = NULL;
13103 }
13104 pSession->nWpaRsnRspIeLength = 0;
13105#ifdef FEATURE_WLAN_WAPI
13106 if(pSession->pWapiReqIE)
13107 {
13108 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
13109 pSession->pWapiReqIE = NULL;
13110 }
13111 pSession->nWapiReqIeLength = 0;
13112 if(pSession->pWapiRspIE)
13113 {
13114 palFreeMemory(pMac->hHdd, pSession->pWapiRspIE);
13115 pSession->pWapiRspIE = NULL;
13116 }
13117 pSession->nWapiRspIeLength = 0;
13118#endif /* FEATURE_WLAN_WAPI */
13119
13120 if(pSession->pAddIEScan)
13121 {
13122 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
13123 pSession->pAddIEScan = NULL;
13124 }
13125 pSession->nAddIEScanLength = 0;
13126
13127 if(pSession->pAddIEAssoc)
13128 {
13129 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
13130 pSession->pAddIEAssoc = NULL;
13131}
13132 pSession->nAddIEAssocLength = 0;
13133
13134}
13135
13136
13137eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
13138{
13139 eHalStatus status = eHAL_STATUS_FAILURE;
13140 tANI_U32 i;
13141
13142 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13143 {
13144 if( CSR_IS_SESSION_VALID( pMac, i ) )
13145 {
13146 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
13147 {
13148 //Found it
13149 status = eHAL_STATUS_SUCCESS;
13150 *pSessionId = i;
13151 break;
13152 }
13153 }
13154 }
13155
13156 return( status );
13157}
13158
13159
13160//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
13161//session because for IBSS, the bssid changes.
13162static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
13163{
13164 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
13165 tCsrRoamSession *pSession;
13166
13167 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13168 {
13169 if( CSR_IS_SESSION_VALID( pMac, i ) )
13170 {
13171 pSession = CSR_GET_SESSION( pMac, i );
13172 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
13173 {
13174 //Found it
13175 nRet = i;
13176 break;
13177 }
13178 }
13179 }
13180
13181 return (nRet);
13182}
13183
13184static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
13185{
13186 /* Update the current BSS info in ho control block based on connected
13187 profile info from pmac global structure */
13188
13189
13190 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= %02x-%02x-%02x-%02x-%02x-%02x\n",
13191 bssid[ 0 ], bssid[ 1 ], bssid[ 2 ],
13192 bssid[ 3 ], bssid[ 4 ], bssid[ 5 ] );
13193
13194 /* Check for user misconfig of RSSI trigger threshold */
13195 pMac->roam.configParam.vccRssiThreshold =
13196 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
13197 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
13198 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
13199
13200 /* Check for user misconfig of UL MAC Loss trigger threshold */
13201 pMac->roam.configParam.vccUlMacLossThreshold =
13202 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
13203 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
13204
13205#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13206 {
13207 tANI_U32 sessionId = 0;
13208
13209 /* Indicate the neighbor roal algorithm about the connect indication */
13210 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
13211 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
13212 }
13213#endif
13214
13215}
13216
13217
13218static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
13219{
13220 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13221
13222 //Only to handle the case for Handover on infra link
13223 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
13224 {
13225 return;
13226 }
13227
13228
13229 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
13230 csrRoamDeregStatisticsReq(pMac);
13231 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
13232#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13233 /* Indicate the neighbor roal algorithm about the disconnect indication */
13234 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
13235#endif
13236
13237}
13238
13239
13240void csrRoamTlStatsTimerHandler(void *pv)
13241{
13242 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
13243 eHalStatus status;
13244
13245 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
13246
13247#if 0
13248 // TODO Persession .???
13249 //req TL for stats
13250 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
13251 {
13252 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL\n"));
13253 }
13254 else
13255 {
13256 //save in SME
13257 csrRoamSaveStatsFromTl(pMac, tlStats);
13258 }
13259#endif
13260 if(!pMac->roam.tlStatsReqInfo.timerRunning)
13261 {
13262 if(pMac->roam.tlStatsReqInfo.periodicity)
13263 {
13264 //start timer
13265 status = palTimerStart(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer,
13266 pMac->roam.tlStatsReqInfo.periodicity * PAL_TIMER_TO_MS_UNIT, eANI_BOOLEAN_FALSE);
13267 if(!HAL_STATUS_SUCCESS(status))
13268 {
13269 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer\n"));
13270 return;
13271 }
13272 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
13273 }
13274 }
13275}
13276
13277void csrRoamPeStatsTimerHandler(void *pv)
13278{
13279 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
13280 eHalStatus status;
13281 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
13282 VOS_STATUS vosStatus;
13283 tPmcPowerState powerState;
13284
13285 pPeStatsReqListEntry->timerRunning = FALSE;
13286 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
13287 {
13288 // If we entered here, meaning the timer could not be successfully
13289 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
13290
13291 /* Destroy the timer */
13292 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
13293 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13294 {
13295 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer\n"));
13296 }
13297
13298 // Free the entry
13299 palFreeMemory(pMac->hHdd, pPeStatsReqListEntry);
13300 pPeStatsReqListEntry = NULL;
13301 }
13302 else
13303 {
13304 if(!pPeStatsReqListEntry->rspPending)
13305 {
13306 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
13307 pPeStatsReqListEntry->staId);
13308 if(!HAL_STATUS_SUCCESS(status))
13309 {
13310 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE\n"));
13311 }
13312 else
13313 {
13314 pPeStatsReqListEntry->rspPending = TRUE;
13315 }
13316 }
13317
13318 //send down a req
13319 if(pPeStatsReqListEntry->periodicity &&
13320 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
13321 {
13322 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
13323 if(ePMC_FULL_POWER == powerState)
13324 {
13325 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
13326 {
13327 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
13328 }
13329 }
13330 else
13331 {
13332 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
13333 {
13334 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
13335 }
13336 }
13337 //start timer
13338 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
13339 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13340 {
13341 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer\n"));
13342 return;
13343 }
13344
13345 pPeStatsReqListEntry->timerRunning = TRUE;
13346
13347 }
13348
13349 }
13350}
13351
13352void csrRoamStatsClientTimerHandler(void *pv)
13353{
13354 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
13355
13356 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
13357 {
13358#if 0
13359 // TODO Stats fix for multisession
13360 //start the timer
13361 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
13362
13363 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13364 {
13365 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer\n"));
13366
13367 }
13368#endif
13369 }
13370#if 0
13371 //send up the stats report
13372 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
13373 pStaEntry->staId, pStaEntry->pContext);
13374#endif
13375}
13376
13377
13378
13379
13380eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
13381{
13382 tAniGetPEStatsReq *pMsg;
13383 eHalStatus status = eHAL_STATUS_SUCCESS;
13384 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetPEStatsReq));
13385 if ( !HAL_STATUS_SUCCESS(status) )
13386 {
13387 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to allocate mem for stats req \n");
13388 return status;
13389 }
13390 // need to initiate a stats request to PE
13391 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
13392 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
13393 pMsg->staId = staId;
13394 pMsg->statsMask = statsMask;
13395
13396 status = palSendMBMessage(pMac->hHdd, pMsg );
13397
13398 if(!HAL_STATUS_SUCCESS(status))
13399 {
13400 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to send down the stats req \n");
13401 }
13402
13403 return status;
13404}
13405
13406void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
13407{
13408 tAniGetPEStatsRsp *pSmeStatsRsp;
13409 eHalStatus status = eHAL_STATUS_FAILURE;
13410 tListElem *pEntry = NULL;
13411 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
13412 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
13413 tANI_U32 tempMask = 0;
13414 tANI_U8 counter = 0;
13415 tANI_U8 *pStats = NULL;
13416 tANI_U32 length = 0;
13417 v_PVOID_t pvosGCtx;
13418 v_S7_t rssi = 0;
13419 tANI_U32 *pRssi = NULL;
13420
13421 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
13422 if(pSmeStatsRsp->rc)
13423 {
13424 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure\n"));
13425 goto post_update;
13426 }
13427
13428 tempMask = pSmeStatsRsp->statsMask;
13429 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
13430
13431 /* subtract all statistics from this length, and after processing the entire
13432 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
13433 * in this 'stats' message.
13434 */
13435 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
13436
13437 //new stats info from PE, fill up the stats strucutres in PMAC
13438 while(tempMask)
13439 {
13440 if(tempMask & 1)
13441 {
13442 switch(counter)
13443 {
13444 case eCsrSummaryStats:
13445 smsLog( pMac, LOG1, FL("csrRoamStatsRspProcessor:summary stats\n"));
13446 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
13447 pStats, sizeof(tCsrSummaryStatsInfo));
13448 if(!HAL_STATUS_SUCCESS(status))
13449 {
13450 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy summary stats\n"));
13451 }
13452 pStats += sizeof(tCsrSummaryStatsInfo);
13453 length -= sizeof(tCsrSummaryStatsInfo);
13454 break;
13455
13456 case eCsrGlobalClassAStats:
13457 smsLog( pMac, LOG1, FL("csrRoamStatsRspProcessor:ClassA stats\n"));
13458 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classAStatsInfo,
13459 pStats, sizeof(tCsrGlobalClassAStatsInfo));
13460 if(!HAL_STATUS_SUCCESS(status))
13461 {
13462 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassA stats\n"));
13463 }
13464 pStats += sizeof(tCsrGlobalClassAStatsInfo);
13465 length -= sizeof(tCsrGlobalClassAStatsInfo);
13466 break;
13467
13468 case eCsrGlobalClassBStats:
13469 smsLog( pMac, LOG1, FL("csrRoamStatsRspProcessor:ClassB stats\n"));
13470 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classBStatsInfo,
13471 pStats, sizeof(tCsrGlobalClassBStatsInfo));
13472 if(!HAL_STATUS_SUCCESS(status))
13473 {
13474 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassB stats\n"));
13475 }
13476 pStats += sizeof(tCsrGlobalClassBStatsInfo);
13477 length -= sizeof(tCsrGlobalClassBStatsInfo);
13478 break;
13479
13480 case eCsrGlobalClassCStats:
13481 smsLog( pMac, LOG1, FL("csrRoamStatsRspProcessor:ClassC stats\n"));
13482 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classCStatsInfo,
13483 pStats, sizeof(tCsrGlobalClassCStatsInfo));
13484 if(!HAL_STATUS_SUCCESS(status))
13485 {
13486 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassC stats\n"));
13487 }
13488 pStats += sizeof(tCsrGlobalClassCStatsInfo);
13489 length -= sizeof(tCsrGlobalClassCStatsInfo);
13490 break;
13491
13492 case eCsrPerStaStats:
13493 smsLog( pMac, LOG1, FL("csrRoamStatsRspProcessor:PerSta stats\n"));
13494 if( CSR_MAX_STA > pSmeStatsRsp->staId )
13495 {
13496 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
13497 pStats, sizeof(tCsrPerStaStatsInfo));
13498 }
13499 else
13500 {
13501 status = eHAL_STATUS_FAILURE;
13502 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d\n"), pSmeStatsRsp->staId);
13503 VOS_ASSERT( 0 );
13504 }
13505 if(!HAL_STATUS_SUCCESS(status))
13506 {
13507 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats\n"));
13508 }
13509 pStats += sizeof(tCsrPerStaStatsInfo);
13510 length -= sizeof(tCsrPerStaStatsInfo);
13511 break;
13512
13513 default:
13514 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type\n"));
13515 break;
13516
13517 }
13518 }
13519
13520 tempMask >>=1;
13521 counter++;
13522 }
13523 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
13524 if (length != 0)
13525 {
13526 pRssi = (tANI_U32*)pStats;
13527 rssi = (v_S7_t)*pRssi;
13528 }
13529 else
13530 {
13531 /* If riva is not sending rssi, continue to use the hack */
13532 rssi = RSSI_HACK_BMPS;
13533 }
13534 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
13535
13536post_update:
13537 //make sure to update the pe stats req list
13538 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
13539 if(pEntry)
13540 {
13541 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
13542 pPeStaEntry->rspPending = FALSE;
13543
13544 }
13545 //check the one timer cases
13546 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
13547 if(pEntry)
13548 {
13549
13550 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
13551
13552 if(pTempStaEntry->timerExpired)
13553 {
13554 //send up the stats report
13555 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
13556 pTempStaEntry->staId, pTempStaEntry->pContext);
13557 //also remove from the client list
13558 csrRoamRemoveStatListEntry(pMac, pEntry);
13559 pTempStaEntry = NULL;
13560
13561 }
13562 }
13563
13564}
13565
13566tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
13567{
13568 tListElem *pEntry = NULL;
13569 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
13570
13571 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
13572
13573 if(!pEntry)
13574 {
13575 //list empty
13576 smsLog(pMac, LOGW, "csrRoamFindInPeStatsReqList: List empty, no request to PE\n");
13577 return NULL;
13578 }
13579
13580 while( pEntry )
13581 {
13582 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
13583
13584 if(pTempStaEntry->statsMask == statsMask)
13585 {
13586 smsLog(pMac, LOGW, "csrRoamFindInPeStatsReqList: match found\n");
13587 break;
13588 }
13589
13590 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
13591 }
13592
13593 return pEntry;
13594}
13595
13596
13597tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
13598 tANI_BOOLEAN update)
13599{
13600 tListElem *pEntry;
13601 tCsrStatsClientReqInfo *pTempStaEntry;
13602
13603 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
13604
13605 if(!pEntry)
13606 {
13607 //list empty
13608 smsLog(pMac, LOGW, "csrRoamChecknUpdateClientReqList: List empty, no request from "
13609 "upper layer client(s)\n");
13610 return NULL;
13611 }
13612
13613 while( pEntry )
13614 {
13615 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
13616
13617 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
13618 (pTempStaEntry->statsMask == pStaEntry->statsMask))
13619 {
13620 smsLog(pMac, LOGW, "csrRoamChecknUpdateClientReqList: match found\n");
13621 if(update)
13622 {
13623 pTempStaEntry->periodicity = pStaEntry->periodicity;
13624 pTempStaEntry->callback = pStaEntry->callback;
13625 pTempStaEntry->pContext = pStaEntry->pContext;
13626 }
13627 break;
13628 }
13629
13630 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
13631 }
13632
13633 return pEntry;
13634}
13635
13636tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
13637{
13638 tListElem *pEntry;
13639 tCsrStatsClientReqInfo *pTempStaEntry;
13640
13641 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
13642
13643 if(!pEntry)
13644 {
13645 //list empty
13646 smsLog(pMac, LOGW, "csrRoamCheckClientReqList: List empty, no request from "
13647 "upper layer client(s)\n");
13648 return NULL;
13649 }
13650
13651 while( pEntry )
13652 {
13653 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
13654
13655 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
13656 {
13657 smsLog(pMac, LOGW, "csrRoamCheckClientReqList: match found\n");
13658
13659 break;
13660 }
13661
13662 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
13663 }
13664
13665 return pEntry;
13666}
13667
13668
13669eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
13670 csrRoamLinkQualityIndCallback callback,
13671 void *pContext)
13672{
13673 pMac->roam.linkQualityIndInfo.callback = callback;
13674 pMac->roam.linkQualityIndInfo.context = pContext;
13675 if( NULL == callback )
13676 {
13677 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
13678 }
13679 else
13680 {
13681 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
13682
13683 /* do we need to invoke the callback to notify client of initial value ?? */
13684 }
13685 return eHAL_STATUS_SUCCESS;
13686}
13687
13688void csrRoamVccTrigger(tpAniSirGlobal pMac)
13689{
13690 eCsrRoamLinkQualityInd newVccLinkQuality;
13691 tANI_U32 ul_mac_loss = 0;
13692 tANI_U32 ul_mac_loss_trigger_threshold;
13693
13694 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
13695 /*-------------------------------------------------------------------------
13696 Link quality is currently binary based on OBIWAN recommended triggers
13697
13698 Check for a change in link quality and notify client if necessary
13699 -------------------------------------------------------------------------*/
13700 ul_mac_loss_trigger_threshold =
13701 pMac->roam.configParam.vccUlMacLossThreshold;
13702
13703 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
13704
13705 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d\n",
13706 ul_mac_loss_trigger_threshold );
13707
13708 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
13709 {
13710 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR \n");
13711 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
13712 }
13713 else
13714 {
13715 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD\n");
13716 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
13717 }
13718
13719 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
13720 ul_mac_loss);
13721
13722 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
13723 {
13724 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary\n");
13725 if(NULL != pMac->roam.linkQualityIndInfo.callback)
13726 {
13727 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d\n",
13728 newVccLinkQuality );
13729
13730 /* we now invoke the callback once to notify client of initial value */
13731 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
13732 pMac->roam.linkQualityIndInfo.context );
13733 //event: EVENT_WLAN_VCC
13734 }
13735 }
13736
13737 pMac->roam.vccLinkQuality = newVccLinkQuality;
13738
13739
13740}
13741
13742VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
13743 v_U8_t rssiNotification,
13744 void * context)
13745{
13746 tpAniSirGlobal pMac = PMAC_STRUCT( context );
13747 eCsrRoamLinkQualityInd newVccLinkQuality;
13748 // TODO : Session info unavailable
13749 tANI_U32 sessionId = 0;
13750 VOS_STATUS status = VOS_STATUS_SUCCESS;
13751 /*-------------------------------------------------------------------------
13752 Link quality is currently binary based on OBIWAN recommended triggers
13753
13754 Check for a change in link quality and notify client if necessary
13755 -------------------------------------------------------------------------*/
13756 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d\n",
13757 pMac->roam.configParam.vccRssiThreshold);
13758 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
13759 {
13760 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected\n");
13761 return VOS_STATUS_SUCCESS;
13762 }
13763
13764 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
13765 {
13766 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR\n");
13767 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
13768 }
13769 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
13770 {
13771 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD \n");
13772 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
13773 }
13774 else
13775 {
13776 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d\n", rssiNotification);
13777 //Set to this so the code below won't do anything
13778 newVccLinkQuality = pMac->roam.vccLinkQuality;
13779
13780 VOS_ASSERT(0);
13781 }
13782
13783
13784 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
13785 {
13786 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary\n");
13787 if(NULL != pMac->roam.linkQualityIndInfo.callback)
13788 {
13789 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d\n",
13790 newVccLinkQuality);
13791
13792 /* we now invoke the callback once to notify client of initial value */
13793 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
13794 pMac->roam.linkQualityIndInfo.context );
13795 //event: EVENT_WLAN_VCC
13796 }
13797 }
13798
13799 pMac->roam.vccLinkQuality = newVccLinkQuality;
13800
13801 return status;
13802}
13803
13804
13805tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
13806 tDblLinkList *pStaList,
13807 tCsrStatsClientReqInfo *pStaEntry)
13808{
13809 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
13810
13811 eHalStatus status;
13812
13813 //if same entity requested for same set of stats with different periodicity &
13814 // callback update it
13815 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
13816 {
13817
13818 status = palAllocateMemory(pMac->hHdd, (void **)&pNewStaEntry, sizeof(tCsrStatsClientReqInfo));
13819 if (!HAL_STATUS_SUCCESS(status))
13820 {
13821 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
13822 "entry\n");
13823 return NULL;
13824 }
13825
13826
13827 pNewStaEntry->callback = pStaEntry->callback;
13828 pNewStaEntry->pContext = pStaEntry->pContext;
13829 pNewStaEntry->periodicity = pStaEntry->periodicity;
13830 pNewStaEntry->requesterId = pStaEntry->requesterId;
13831 pNewStaEntry->statsMask = pStaEntry->statsMask;
13832 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
13833 pNewStaEntry->pMac = pStaEntry->pMac;
13834 pNewStaEntry->staId = pStaEntry->staId;
13835 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
13836
13837 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
13838 }
13839 return pNewStaEntry;
13840}
13841
13842
13843tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
13844 tDblLinkList *pStaList,
13845 tCsrPeStatsReqInfo *pStaEntry)
13846{
13847 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
13848
13849 eHalStatus status;
13850
13851 status = palAllocateMemory(pMac->hHdd, (void **)&pNewStaEntry, sizeof(tCsrPeStatsReqInfo));
13852 if (!HAL_STATUS_SUCCESS(status))
13853 {
13854 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
13855 "entry\n");
13856 return NULL;
13857 }
13858
13859
13860 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
13861 pNewStaEntry->numClient = pStaEntry->numClient;
13862 pNewStaEntry->periodicity = pStaEntry->periodicity;
13863 pNewStaEntry->statsMask = pStaEntry->statsMask;
13864 pNewStaEntry->pMac = pStaEntry->pMac;
13865 pNewStaEntry->staId = pStaEntry->staId;
13866 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
13867 pNewStaEntry->rspPending = pStaEntry->rspPending;
13868
13869 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
13870
13871 return pNewStaEntry;
13872}
13873
13874
13875eHalStatus csrGetRssi(tpAniSirGlobal pMac,
13876 tCsrRssiCallback callback,
13877 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
13878{
13879 eHalStatus status = eHAL_STATUS_SUCCESS;
13880 vos_msg_t msg;
13881 tANI_U32 sessionId;
13882
13883 tAniGetRssiReq *pMsg;
13884 smsLog(pMac, LOG2, FL("called"));
13885 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetRssiReq));
13886 if ( !HAL_STATUS_SUCCESS(status) )
13887 {
13888 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req \n");
13889 return status;
13890 }
13891
13892 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
13893
13894 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
13895 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
13896 pMsg->sessionId = sessionId;
13897 pMsg->staId = staId;
13898 pMsg->rssiCallback = callback;
13899 pMsg->pDevContext = pContext;
13900 pMsg->pVosContext = pVosContext;
13901
13902 msg.type = eWNI_SME_GET_RSSI_REQ;
13903 msg.bodyptr = pMsg;
13904 msg.reserved = 0;
13905
13906 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
13907 {
13908 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self \n");
13909 palFreeMemory(pMac->hHdd, (void *)pMsg);
13910 status = eHAL_STATUS_FAILURE;
13911 }
13912 smsLog(pMac, LOG2, FL("returned"));
13913 return status;
13914}
13915
13916eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
13917 tANI_U32 statsMask,
13918 tCsrStatsCallback callback,
13919 tANI_U32 periodicity, tANI_BOOLEAN cache,
13920 tANI_U8 staId, void *pContext)
13921{
13922 tCsrStatsClientReqInfo staEntry;
13923 tCsrStatsClientReqInfo *pStaEntry = NULL;
13924 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
13925 tListElem *pEntry = NULL;
13926 tANI_BOOLEAN found = FALSE;
13927 eHalStatus status = eHAL_STATUS_SUCCESS;
13928 tANI_BOOLEAN insertInClientList = FALSE;
13929 VOS_STATUS vosStatus;
13930
13931 if( csrIsAllSessionDisconnected(pMac) )
13932 {
13933 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected\n", pMac->roam.curState);
13934 return eHAL_STATUS_FAILURE;
13935 }
13936
13937 if((!statsMask) && (!callback))
13938 {
13939 //msg
13940 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request\n");
13941 return eHAL_STATUS_FAILURE;
13942 }
13943
13944 //for the search list method for deregister
13945 staEntry.requesterId = requesterId;
13946 staEntry.statsMask = statsMask;
13947 //requester wants to deregister or just an error
13948 if((statsMask) && (!callback))
13949 {
13950 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
13951 if(!pEntry)
13952 {
13953 //msg
13954 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
13955 "find any existing request in statsClientReqList\n");
13956 return eHAL_STATUS_FAILURE;
13957 }
13958 else
13959 {
13960 //clean up & return
13961 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070013962 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070013963 {
Jeff Johnson43971f52012-07-17 12:26:56 -070013964 pStaEntry->pPeStaEntry->numClient--;
13965 //check if we need to delete the entry from peStatsReqList too
13966 if(!pStaEntry->pPeStaEntry->numClient)
13967 {
13968 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
13969 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013970 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070013971
Jeff Johnson295189b2012-06-20 16:38:30 -070013972 //check if we need to stop the tl stats timer too
13973 pMac->roam.tlStatsReqInfo.numClient--;
13974 if(!pMac->roam.tlStatsReqInfo.numClient)
13975 {
13976 if(pMac->roam.tlStatsReqInfo.timerRunning)
13977 {
13978 status = palTimerStop(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
13979 if(!HAL_STATUS_SUCCESS(status))
13980 {
13981 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer\n"));
13982 return eHAL_STATUS_FAILURE;
13983 }
13984 }
13985 pMac->roam.tlStatsReqInfo.periodicity = 0;
13986 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
13987 }
13988 vos_timer_stop( &pStaEntry->timer );
13989
13990 // Destroy the vos timer...
13991 vosStatus = vos_timer_destroy( &pStaEntry->timer );
13992 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13993 {
13994 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer\n"));
13995 }
13996
13997 csrRoamRemoveStatListEntry(pMac, pEntry);
13998 pStaEntry = NULL;
13999 return eHAL_STATUS_SUCCESS;
14000 }
14001 }
14002
14003 if(cache && !periodicity)
14004 {
14005 //return the cached stats
14006 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
14007 }
14008 else
14009 {
14010 //add the request in the client req list
14011 staEntry.callback = callback;
14012 staEntry.pContext = pContext;
14013 staEntry.periodicity = periodicity;
14014 staEntry.pPeStaEntry = NULL;
14015 staEntry.staId = staId;
14016 staEntry.pMac = pMac;
14017 staEntry.timerExpired = FALSE;
14018
14019
14020
14021 //if periodic report requested with non cached result from PE/TL
14022 if(periodicity)
14023 {
14024
14025 //if looking for stats from PE
14026 if(statsMask & ~(1 << eCsrGlobalClassDStats))
14027 {
14028
14029 //check if same request made already & waiting for rsp
14030 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
14031 periodicity, &found, staId);
14032 if(!pPeStaEntry)
14033 {
14034 //bail out, maxed out on number of req for PE
14035 return eHAL_STATUS_FAILURE;
14036 }
14037 else
14038 {
14039 staEntry.pPeStaEntry = pPeStaEntry;
14040 }
14041
14042 }
14043 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
14044 if(statsMask & (1 << eCsrGlobalClassDStats))
14045 {
14046 if(cache && pMac->roam.tlStatsReqInfo.numClient)
14047 {
14048 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL\n"));
14049 }
14050 else
14051 {
14052
14053 //update periodicity
14054 if(pMac->roam.tlStatsReqInfo.periodicity)
14055 {
14056 pMac->roam.tlStatsReqInfo.periodicity =
14057 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
14058 }
14059 else
14060 {
14061 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
14062 }
14063 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
14064 {
14065 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
14066 }
14067
14068 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14069 {
14070#if 0
14071 // TODO Session Specific info connectedInfo
14072 //req TL for class D stats
14073 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
14074 {
14075 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL\n"));
14076 }
14077 else
14078 {
14079 //save in SME
14080 csrRoamSaveStatsFromTl(pMac, tlStats);
14081 }
14082#endif
14083 if(pMac->roam.tlStatsReqInfo.periodicity)
14084 {
14085 //start timer
14086 status = palTimerStart(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14087 pMac->roam.tlStatsReqInfo.periodicity * PAL_TIMER_TO_MS_UNIT, eANI_BOOLEAN_FALSE);
14088 if(!HAL_STATUS_SUCCESS(status))
14089 {
14090 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer\n"));
14091 return eHAL_STATUS_FAILURE;
14092 }
14093 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14094 }
14095 }
14096 }
14097 pMac->roam.tlStatsReqInfo.numClient++;
14098 }
14099
14100 insertInClientList = TRUE;
14101 }
14102 //if one time report requested with non cached result from PE/TL
14103 else if(!cache && !periodicity)
14104 {
14105 if(statsMask & ~(1 << eCsrGlobalClassDStats))
14106 {
14107 //send down a req
14108 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
14109 if(!HAL_STATUS_SUCCESS(status))
14110 {
14111 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE\n"));
14112 }
14113 //so that when the stats rsp comes back from PE we respond to upper layer
14114 //right away
14115 staEntry.timerExpired = TRUE;
14116 insertInClientList = TRUE;
14117
14118 }
14119 if(statsMask & (1 << eCsrGlobalClassDStats))
14120 {
14121#if 0
14122 // TODO : Per Session info connectedInfo
14123 //req TL for class D stats
14124 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
14125 {
14126 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL\n"));
14127 }
14128 else
14129 {
14130 //save in SME
14131 csrRoamSaveStatsFromTl(pMac, tlStats);
14132 }
14133#endif
14134
14135 }
14136 //if looking for stats from TL only
14137 if(!insertInClientList)
14138 {
14139 //return the stats
14140 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
14141 }
14142
14143 }
14144
14145 if(insertInClientList)
14146 {
14147 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
14148 if(!pStaEntry)
14149 {
14150 //msg
14151 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList\n");
14152 return eHAL_STATUS_FAILURE;
14153 }
14154 //Init & start timer if needed
14155 if(periodicity)
14156 {
14157 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
14158 csrRoamStatsClientTimerHandler, pStaEntry );
14159 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14160 {
14161 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer\n"));
14162 return eHAL_STATUS_FAILURE;
14163 }
14164 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
14165 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14166 {
14167 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer\n"));
14168 return eHAL_STATUS_FAILURE;
14169 }
14170
14171 }
14172
14173 }
14174
14175 }
14176 return eHAL_STATUS_SUCCESS;
14177}
14178
14179
14180tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
14181 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
14182{
14183 tANI_BOOLEAN found = FALSE;
14184 eHalStatus status = eHAL_STATUS_SUCCESS;
14185 tCsrPeStatsReqInfo staEntry;
14186 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
14187 tListElem *pStaEntry = NULL;
14188 VOS_STATUS vosStatus;
14189 tPmcPowerState powerState;
14190 *pFound = FALSE;
14191
14192 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
14193 if(pStaEntry)
14194 {
14195 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
14196 if(pTempStaEntry->periodicity)
14197 {
14198 pTempStaEntry->periodicity =
14199 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
14200 }
14201 else
14202 {
14203 pTempStaEntry->periodicity = periodicity;
14204 }
14205
14206 pTempStaEntry->numClient++;
14207 found = TRUE;
14208 }
14209 else
14210 {
14211 palZeroMemory(pMac->hHdd, &staEntry, sizeof(tCsrPeStatsReqInfo));
14212 staEntry.numClient = 1;
14213 staEntry.periodicity = periodicity;
14214 staEntry.pMac = pMac;
14215 staEntry.rspPending = FALSE;
14216 staEntry.staId = staId;
14217 staEntry.statsMask = statsMask;
14218 staEntry.timerRunning = FALSE;
14219 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
14220 if(!pTempStaEntry)
14221 {
14222 //msg
14223 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList\n");
14224 return NULL;
14225 }
14226 }
14227
14228 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
14229 if(ePMC_FULL_POWER == powerState)
14230 {
14231 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
14232 {
14233 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
14234 }
14235 }
14236 else
14237 {
14238 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
14239 {
14240 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
14241 }
14242 }
14243 if(!pTempStaEntry->timerRunning)
14244 {
14245 //send down a req in case of one time req, for periodic ones wait for timer to expire
14246 if(!pTempStaEntry->rspPending &&
14247 !pTempStaEntry->periodicity)
14248 {
14249 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
14250 if(!HAL_STATUS_SUCCESS(status))
14251 {
14252 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE\n"));
14253 }
14254 else
14255 {
14256 pTempStaEntry->rspPending = TRUE;
14257 }
14258 }
14259 if(pTempStaEntry->periodicity)
14260 {
14261 if(!found)
14262 {
14263
14264 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
14265 csrRoamPeStatsTimerHandler, pTempStaEntry );
14266 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14267 {
14268 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer\n"));
14269 return NULL;
14270 }
14271
14272 }
14273 //start timer
14274 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d\n", pTempStaEntry->periodicity);
14275
14276 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
14277 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14278 {
14279 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer\n"));
14280 return NULL;
14281 }
14282 pTempStaEntry->timerRunning = TRUE;
14283 }
14284 }
14285
14286 *pFound = found;
14287 return pTempStaEntry;
14288}
14289
14290
14291/*
14292 pStaEntry is no longer invalid upon the return of this function.
14293*/
14294static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
14295{
14296 if(pEntry)
14297 {
14298 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
14299 {
14300 palFreeMemory(pMac->hHdd, GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
14301 }
14302 }
14303}
14304
14305
14306void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
14307{
14308 tListElem *pEntry;
14309 tCsrPeStatsReqInfo *pTempStaEntry;
14310 VOS_STATUS vosStatus;
14311 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
14312
14313 if(!pEntry)
14314 {
14315 //list empty
14316 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: List empty, no stats req for PE\n");
14317 return;
14318 }
14319
14320 while( pEntry )
14321 {
14322 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
14323
14324 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
14325 {
14326 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: match found\n");
14327 if(pTempStaEntry->timerRunning)
14328 {
14329 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
14330 /* If we are not able to stop the timer here, just remove
14331 * the entry from the linked list. Destroy the timer object
14332 * and free the memory in the timer CB
14333 */
14334 if( vosStatus == VOS_STATUS_SUCCESS )
14335 {
14336 /* the timer is successfully stopped */
14337 pTempStaEntry->timerRunning = FALSE;
14338
14339 /* Destroy the timer */
14340 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
14341 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14342 {
14343 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer\n"));
14344 }
14345 }
14346 else
14347 {
14348 // the timer could not be stopped. Hence destroy and free the
14349 // memory for the PE stat entry in the timer CB.
14350 pTempStaEntry->timerStopFailed = TRUE;
14351 }
14352 }
14353
14354 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
14355 {
14356 // Only free the memory if we could stop the timer successfully
14357 if(!pTempStaEntry->timerStopFailed)
14358 {
14359 palFreeMemory(pMac->hHdd, pTempStaEntry);
14360 pTempStaEntry = NULL;
14361 }
14362 break;
14363 }
14364
14365 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
14366 }
14367 }
14368
14369 return;
14370}
14371
14372
14373void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE tlStats)
14374{
14375
14376 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = tlStats.rxBcntCRCok;
14377 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = tlStats.rxBCBcnt;
14378 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = tlStats.rxBCFcnt;
14379 pMac->roam.classDStatsInfo.rx_byte_cnt = tlStats.rxBcnt;
14380 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = tlStats.rxMCBcnt;
14381 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = tlStats.rxMCFcnt;
14382 pMac->roam.classDStatsInfo.rx_rate = tlStats.rxRate;
14383 //?? need per AC
14384 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = tlStats.rxUCBcnt;
14385 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = tlStats.rxUCFcnt;
14386 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = tlStats.txBCBcnt;
14387 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = tlStats.txBCFcnt;
14388 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = tlStats.txMCBcnt;
14389 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = tlStats.txMCFcnt;
14390 //?? need per AC
14391 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = tlStats.txUCBcnt;
14392 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = tlStats.txUCFcnt;
14393
14394}
14395
14396
14397void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
14398 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
14399{
14400 tANI_U8 stats[500];
14401 tANI_U8 *pStats = NULL;
14402 tANI_U32 tempMask = 0;
14403 tANI_U8 counter = 0;
14404 eHalStatus status = eHAL_STATUS_FAILURE;
14405
14406 if(!callback)
14407 {
14408 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report callback NULL\n"));
14409 return;
14410 }
14411 if(!statsMask)
14412 {
14413 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report statsMask is 0\n"));
14414 return;
14415 }
14416
14417 pStats = stats;
14418
14419 tempMask = statsMask;
14420
14421 while(tempMask)
14422 {
14423 if(tempMask & 1)
14424 {
14425 //new stats info from PE, fill up the stats strucutres in PMAC
14426 switch(counter)
14427 {
14428 case eCsrSummaryStats:
14429 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:summary stats\n"));
14430 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
14431 sizeof(tCsrSummaryStatsInfo));
14432 if(!HAL_STATUS_SUCCESS(status))
14433 {
14434 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy summary stats\n"));
14435 }
14436 pStats += sizeof(tCsrSummaryStatsInfo);
14437 break;
14438
14439 case eCsrGlobalClassAStats:
14440 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:ClassA stats\n"));
14441 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
14442 sizeof(tCsrGlobalClassAStatsInfo));
14443 if(!HAL_STATUS_SUCCESS(status))
14444 {
14445 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassA stats\n"));
14446 }
14447 pStats += sizeof(tCsrGlobalClassAStatsInfo);
14448
14449 break;
14450
14451 case eCsrGlobalClassBStats:
14452 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:ClassB stats\n"));
14453 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
14454 sizeof(tCsrGlobalClassBStatsInfo));
14455 if(!HAL_STATUS_SUCCESS(status))
14456 {
14457 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassB stats\n"));
14458 }
14459 pStats += sizeof(tCsrGlobalClassBStatsInfo);
14460
14461 break;
14462
14463 case eCsrGlobalClassCStats:
14464 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:ClassC stats\n"));
14465 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
14466 sizeof(tCsrGlobalClassCStatsInfo));
14467 if(!HAL_STATUS_SUCCESS(status))
14468 {
14469 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassC stats\n"));
14470 }
14471 pStats += sizeof(tCsrGlobalClassCStatsInfo);
14472
14473 break;
14474
14475 case eCsrGlobalClassDStats:
14476 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:ClassD stats\n"));
14477 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
14478 sizeof(tCsrGlobalClassDStatsInfo));
14479 if(!HAL_STATUS_SUCCESS(status))
14480 {
14481 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassD stats\n"));
14482 }
14483 pStats += sizeof(tCsrGlobalClassDStatsInfo);
14484
14485 break;
14486
14487 case eCsrPerStaStats:
14488 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:PerSta stats\n"));
14489 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
14490 sizeof(tCsrPerStaStatsInfo));
14491 if(!HAL_STATUS_SUCCESS(status))
14492 {
14493 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy PerSta stats\n"));
14494 }
14495 pStats += sizeof(tCsrPerStaStatsInfo);
14496
14497 break;
14498
14499 default:
14500 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:unknown stats type\n"));
14501 break;
14502
14503 }
14504 }
14505
14506 tempMask >>=1;
14507 counter++;
14508 }
14509
14510 callback(stats, pContext );
14511
14512}
14513
14514
14515
14516eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
14517{
14518 tListElem *pEntry = NULL;
14519 tListElem *pPrevEntry = NULL;
14520 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
14521 eHalStatus status = eHAL_STATUS_SUCCESS;
14522 VOS_STATUS vosStatus;
14523 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
14524
14525 if(!pEntry)
14526 {
14527 //list empty
14528 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
14529 "upper layer client(s)\n");
14530 return status;
14531 }
14532
14533 while( pEntry )
14534 {
14535 if(pPrevEntry)
14536 {
14537 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
14538 //send up the stats report
14539 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
14540 pTempStaEntry->staId, pTempStaEntry->pContext);
14541 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
14542 }
14543
14544 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
14545
14546 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
14547 {
14548 pTempStaEntry->pPeStaEntry->numClient--;
14549 //check if we need to delete the entry from peStatsReqList too
14550 if(!pTempStaEntry->pPeStaEntry->numClient)
14551 {
14552 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
14553 }
14554 }
14555
14556 //check if we need to stop the tl stats timer too
14557 pMac->roam.tlStatsReqInfo.numClient--;
14558 if(!pMac->roam.tlStatsReqInfo.numClient)
14559 {
14560 if(pMac->roam.tlStatsReqInfo.timerRunning)
14561 {
14562 status = palTimerStop(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
14563 if(!HAL_STATUS_SUCCESS(status))
14564 {
14565 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer\n"));
14566 //we will continue
14567 }
14568 }
14569 pMac->roam.tlStatsReqInfo.periodicity = 0;
14570 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14571 }
14572
14573 if (pTempStaEntry->periodicity)
14574 {
14575 //While creating StaEntry in csrGetStatistics,
14576 //Initializing and starting timer only when periodicity is set.
14577 //So Stop and Destroy timer only when periodicity is set.
14578
14579
14580 vos_timer_stop( &pTempStaEntry->timer );
14581
14582 // Destroy the vos timer...
14583 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
14584 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14585 {
14586 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer\n"));
14587 }
14588 }
14589
14590
14591 pPrevEntry = pEntry;
14592 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14593 }
14594 //the last one
14595 if(pPrevEntry)
14596 {
14597 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
14598 //send up the stats report
14599 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
14600 pTempStaEntry->staId, pTempStaEntry->pContext);
14601 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
14602 }
14603
14604 return status;
14605
14606}
14607
14608
14609eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
14610 tRequestFullPowerReason *pReason,
14611 tANI_BOOLEAN *pfNeedPower )
14612{
14613 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
14614 tRequestFullPowerReason reason = eSME_REASON_OTHER;
14615 tPmcState pmcState;
14616 eHalStatus status = eHAL_STATUS_SUCCESS;
14617 // TODO : Session info unavailable
14618 tANI_U32 sessionId = 0;
14619
14620 if( pfNeedPower )
14621 {
14622 *pfNeedPower = eANI_BOOLEAN_FALSE;
14623 }
14624 //We only handle CSR commands
14625 if( !(eSmeCsrCommandMask & pCommand->command) )
14626 {
14627 return eHAL_STATUS_SUCCESS;
14628 }
14629
14630 //Check PMC state first
14631 pmcState = pmcGetPmcState( pMac );
14632
14633 switch( pmcState )
14634 {
14635 case REQUEST_IMPS:
14636 case IMPS:
14637 if( eSmeCommandScan == pCommand->command )
14638 {
14639 switch( pCommand->u.scanCmd.reason )
14640 {
14641 case eCsrScanGetResult:
14642 case eCsrScanBGScanAbort:
14643 case eCsrScanBGScanEnable:
14644 case eCsrScanGetScanChnInfo:
14645 //Internal process, no need for full power
14646 fNeedFullPower = eANI_BOOLEAN_FALSE;
14647 break;
14648
14649 default:
14650 //Other scans are real scan, ask for power
14651 fNeedFullPower = eANI_BOOLEAN_TRUE;
14652 break;
14653 } //switch
14654 }
14655 else
14656 {
14657 //ask for power for roam and status change
14658 fNeedFullPower = eANI_BOOLEAN_TRUE;
14659 }
14660 break;
14661
14662 case REQUEST_BMPS:
14663 case BMPS:
14664 case REQUEST_START_UAPSD:
14665 case UAPSD:
14666 //We treat WOWL same as BMPS
14667 case REQUEST_ENTER_WOWL:
14668 case WOWL:
14669 if( eSmeCommandRoam == pCommand->command )
14670 {
14671 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
14672 tCsrScanResult *pScanResult;
14673 tListElem *pEntry;
14674
14675 switch ( pCommand->u.roamCmd.roamReason )
14676 {
14677 case eCsrForcedDisassoc:
14678 case eCsrForcedDisassocMICFailure:
14679 reason = eSME_LINK_DISCONNECTED_BY_HDD;
14680 fNeedFullPower = eANI_BOOLEAN_TRUE;
14681 break;
14682 case eCsrSmeIssuedDisassocForHandoff:
14683 case eCsrForcedDeauth:
14684 case eCsrHddIssuedReassocToSameAP:
14685 case eCsrSmeIssuedReassocToSameAP:
14686 fNeedFullPower = eANI_BOOLEAN_TRUE;
14687 break;
14688
14689 case eCsrCapsChange:
14690 fNeedFullPower = eANI_BOOLEAN_TRUE;
14691 break;
14692
14693 default:
14694 //Check whether the profile is already connected. If so, no need for full power
14695 //Note: IBSS is ignored for now because we don't support powersave in IBSS
14696 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
14697 {
14698 //Only need to check the first one
14699 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
14700 if( pEntry )
14701 {
14702 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
14703#if 0
14704 // TODO : Session Specific info pConnectBssDesc
14705 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
14706 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
14707 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
14708 {
14709 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
14710 // with Authenticating first. To force this, stop the current association (Disassociate) and
14711 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
14712 // a new Association.
14713 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
14714 {
14715 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
14716 {
14717 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
14718 //No need for full power
14719 //Set the flag so the code later can avoid to do the above
14720 //check again.
14721 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
14722 break;
14723 }
14724 }
14725 }
14726#endif
14727 }
14728 }
14729 //If we are here, full power is needed
14730 fNeedFullPower = eANI_BOOLEAN_TRUE;
14731 break;
14732 }
14733 }
14734 else if( eSmeCommandWmStatusChange == pCommand->command )
14735 {
14736 //need full power for all
14737 fNeedFullPower = eANI_BOOLEAN_TRUE;
14738 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
14739 }
14740 break;
14741
14742 case REQUEST_STOP_UAPSD:
14743 case REQUEST_EXIT_WOWL:
14744 if( eSmeCommandRoam == pCommand->command )
14745 {
14746 fNeedFullPower = eANI_BOOLEAN_TRUE;
14747 switch ( pCommand->u.roamCmd.roamReason )
14748 {
14749 case eCsrForcedDisassoc:
14750 case eCsrForcedDisassocMICFailure:
14751 reason = eSME_LINK_DISCONNECTED_BY_HDD;
14752 break;
14753 default:
14754 break;
14755 }
14756 }
14757 break;
14758
14759 case STOPPED:
14760 case REQUEST_STANDBY:
14761 case STANDBY:
14762 case LOW_POWER:
14763 //We are not supposed to do anything
14764 smsLog( pMac, LOGE, FL( " cannot process because PMC is in stopped/standby state %d\n" ), pmcState );
14765 status = eHAL_STATUS_FAILURE;
14766 break;
14767
14768 case FULL_POWER:
14769 case REQUEST_FULL_POWER:
14770 default:
14771 //No need to ask for full power. This has to be FULL_POWER state
14772 break;
14773
14774 } //switch
14775
14776 if( pReason )
14777 {
14778 *pReason = reason;
14779 }
14780 if( pfNeedPower )
14781 {
14782 *pfNeedPower = fNeedFullPower;
14783 }
14784
14785 return ( status );
14786}
14787
14788
14789static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14790{
14791 eHalStatus status = eHAL_STATUS_SUCCESS;
14792 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
14793 tRequestFullPowerReason reason = eSME_REASON_OTHER;
14794
14795 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
14796
14797 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
14798 {
14799 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
14800 }
14801
14802 return ( status );
14803}
14804
14805
14806tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
14807{
14808 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
14809
14810 if( pCmd )
14811 {
14812 pMac->roam.sPendingCommands++;
14813 }
14814
14815 return ( pCmd );
14816}
14817
14818
14819void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
14820{
14821 if (pMac->roam.sPendingCommands > 0)
14822 {
14823 //All command allocated through csrGetCommandBuffer need to
14824 //decrement the pending count when releasing.
14825 pMac->roam.sPendingCommands--;
14826 smeReleaseCommand( pMac, pCommand );
14827 }
14828 else
14829 {
14830 smsLog(pMac, LOGE, FL( "no pending commands"));
14831 VOS_ASSERT(0);
14832 }
14833}
14834
14835
14836//Return SUCCESS is the command is queued, failed
14837eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
14838{
14839 eHalStatus status;
14840
14841 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
14842 {
14843 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
14844 pCommand->u.scanCmd.reason);
14845 return eHAL_STATUS_CSR_WRONG_STATE;
14846 }
14847
14848 //We can call request full power first before putting the command into pending Q
14849 //because we are holding SME lock at this point.
14850 status = csrRequestFullPower( pMac, pCommand );
14851 if( HAL_STATUS_SUCCESS( status ) )
14852 {
14853 tANI_BOOLEAN fNoCmdPending;
14854
14855 //make sure roamCmdPendingList is not empty first
14856 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
14857 if( fNoCmdPending )
14858 {
14859 smePushCommand( pMac, pCommand, fHighPriority );
14860 }
14861 else
14862 {
14863 //Other commands are waiting for PMC callback, queue the new command to the pending Q
14864 //no list lock is needed since SME lock is held
14865 if( !fHighPriority )
14866 {
14867 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
14868 }
14869 else {
14870 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
14871 }
14872 }
14873 }
14874 else if( eHAL_STATUS_PMC_PENDING == status )
14875 {
14876 //no list lock is needed since SME lock is held
14877 if( !fHighPriority )
14878 {
14879 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
14880 }
14881 else {
14882 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
14883 }
14884 //Let caller know the command is queue
14885 status = eHAL_STATUS_SUCCESS;
14886 }
14887 else
14888 {
14889 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
14890 //release the command.
14891 smsLog( pMac, LOGE, FL( " cannot queue command %d\n" ), pCommand->command );
14892 }
14893
14894 return ( status );
14895
14896}
14897
14898#ifdef WLAN_SOFTAP_FEATURE
14899eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
14900{
14901 eHalStatus status = eHAL_STATUS_SUCCESS;
14902 tSirUpdateAPWPSIEsReq *pMsg;
14903 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
14904
14905 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14906 if (NULL == pSession)
14907 {
14908 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
14909 return eHAL_STATUS_FAILURE;
14910 }
14911
14912
14913 do
14914 {
14915 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirUpdateAPWPSIEsReq) );
14916 if (!HAL_STATUS_SUCCESS(status)) break;
14917 palZeroMemory( pMac->hHdd, pMsg, sizeof(tSirUpdateAPWPSIEsReq) );
14918 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
14919
14920 pBuf = (tANI_U8 *)&pMsg->transactionId;
14921 wTmpBuf = pBuf;
14922
14923 // transactionId
14924 *pBuf = 0;
14925 *( pBuf + 1 ) = 0;
14926 pBuf += sizeof(tANI_U16);
14927
14928 // bssId
14929 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
14930 pBuf += sizeof(tSirMacAddr);
14931
14932 //sessionId
14933 *pBuf++ = (tANI_U8)sessionId;
14934
14935 // APWPSIEs
14936 palCopyMemory( pMac->hHdd, (tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
14937 pBuf += sizeof(tSirAPWPSIEs);
14938
14939 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
14940
14941 status = palSendMBMessage(pMac->hHdd, pMsg);
14942
14943 } while( 0 );
14944
14945 return ( status );
14946}
14947
14948eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
14949{
14950 eHalStatus status = eHAL_STATUS_SUCCESS;
14951 tSirUpdateAPWPARSNIEsReq *pMsg;
14952 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
14953
14954 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14955 if (NULL == pSession)
14956 {
14957 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
14958 return eHAL_STATUS_FAILURE;
14959 }
14960
14961 do
14962 {
14963 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirUpdateAPWPARSNIEsReq) );
14964 if (!HAL_STATUS_SUCCESS(status)) break;
14965 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ) );
14966 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
14967
14968 pBuf = (tANI_U8 *)&pMsg->transactionId;
14969 wTmpBuf = pBuf;
14970
14971 // transactionId
14972 *pBuf = 0;
14973 *( pBuf + 1 ) = 0;
14974 pBuf += sizeof(tANI_U16);
14975
14976 // bssId
14977 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
14978 pBuf += sizeof(tSirMacAddr);
14979
14980 // sessionId
14981 *pBuf++ = (tANI_U8)sessionId;
14982
14983 // APWPARSNIEs
14984 palCopyMemory( pMac->hHdd, (tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
14985 pBuf += sizeof(tSirRSNie);
14986
14987 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
14988
14989 status = palSendMBMessage(pMac->hHdd, pMsg);
14990
14991 } while( 0 );
14992
14993 return ( status );
14994}
14995
14996#endif //#ifdef WLAN_SOFTAP_FEATURE
14997
14998#ifdef WLAN_FEATURE_VOWIFI_11R
14999//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
15000eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
15001{
15002 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
15003 tpSirFTPreAuthReq pftPreAuthReq;
15004 tANI_U16 auth_req_len = 0;
15005 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15006
15007 auth_req_len = sizeof(tSirFTPreAuthReq);
15008 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
15009 if (pftPreAuthReq == NULL)
15010 {
15011 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
15012 return eHAL_STATUS_RESOURCES;
15013 }
15014
15015 // Save the SME Session ID here. We need it while processing the preauth response
15016 pMac->ft.ftSmeContext.smeSessionId = sessionId;
15017
15018 vos_mem_zero(pftPreAuthReq, auth_req_len);
15019
15020 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
15021 sizeof(pBssDescription->length) + pBssDescription->length);
15022
15023 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
15024
15025 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
15026
15027
15028 palCopyMemory(pMac->hHdd, (void *)&pftPreAuthReq->currbssId, (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
15029
15030 palCopyMemory(pMac->hHdd, (void *)&pftPreAuthReq->preAuthbssId, (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
15031
15032
15033#ifdef WLAN_FEATURE_VOWIFI_11R
15034 if (csrRoamIs11rAssoc(pMac))
15035 {
15036 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
15037 palCopyMemory(pMac->hHdd, pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
15038 pMac->ft.ftSmeContext.auth_ft_ies_length);
15039 }
15040 else
15041#endif
15042 {
15043 pftPreAuthReq->ft_ies_length = 0;
15044 }
15045
15046 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription, pBssDescription->length);
15047
15048 pftPreAuthReq->length = pal_cpu_to_be16(sizeof(tSirFTPreAuthReq) + sizeof(pBssDescription->length) +
15049 pBssDescription->length);
15050
15051 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
15052}
15053
15054/*--------------------------------------------------------------------------
15055 * This will receive and process the FT Pre Auth Rsp from the current
15056 * associated ap.
15057 *
15058 * This will invoke the hdd call back. This is so that hdd can now
15059 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
15060 ------------------------------------------------------------------------*/
15061void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
15062{
15063 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
15064 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015065#ifdef FEATURE_WLAN_LFR
15066 tCsrRoamInfo roamInfo;
15067#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015068
15069#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
15070 smsLog( pMac, LOGE, FL("Preauth response status code %d"), pFTPreAuthRsp->status);
15071#endif
15072
15073#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
15074 csrNeighborRoamPreauthRspHandler(pMac, (VOS_STATUS)pFTPreAuthRsp->status);
15075#endif
15076
15077 /* The below function calls/timers should be invoked only if the pre-auth is successful */
15078 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
15079 return;
15080
15081 // Implies a success
15082 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
15083
15084 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
15085 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
15086 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
15087
15088 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
15089 * actual transition from the current to handoff AP is triggered */
15090 status = palTimerStart(pMac->hHdd, pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
15091 60 * PAL_TIMER_TO_MS_UNIT,
15092 eANI_BOOLEAN_FALSE);
15093 if (eHAL_STATUS_SUCCESS != status)
15094 {
15095 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d\n"), status);
15096 return;
15097 }
15098
15099 // Save the received response
15100 palCopyMemory(pMac->hHdd, (void *)&pMac->ft.ftSmeContext.preAuthbssId, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
15101 if (csrRoamIs11rAssoc(pMac))
15102 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
15103 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
15104
15105 // Currently we dont do anything special for CCX connection.
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015106
15107#ifdef FEATURE_WLAN_LFR
15108 // If Legacy Fast Roaming is enabled, signal the supplicant
15109 // So he can send us a PMK-ID for this candidate AP.
15110 if (csrRoamIsFastRoamEnabled(pMac))
15111 {
15112 // Save the bssid from the received response
15113 palCopyMemory(pMac->hHdd, (void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
15114 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
15115 }
15116
15117#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015118
15119 // Done with it, init it.
15120 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
15121}
15122#endif
15123#ifdef FEATURE_WLAN_BTAMP_UT_RF
15124void csrRoamJoinRetryTimerHandler(void *pv)
15125{
15126 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
15127 tpAniSirGlobal pMac = pInfo->pMac;
15128 tANI_U32 sessionId = pInfo->sessionId;
15129 tCsrRoamSession *pSession;
15130
15131 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
15132 {
15133 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d\n" ), sessionId );
15134 pSession = CSR_GET_SESSION( pMac, sessionId );
15135 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
15136 {
15137 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
15138 {
15139 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile\n" ) );
15140 }
15141 }
15142 }
15143}
15144
15145eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
15146{
15147 eHalStatus status = eHAL_STATUS_FAILURE;
15148 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15149
15150 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
15151 {
15152 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left\n "), sessionId, pSession->maxRetryCount);
15153 pSession->maxRetryCount--;
15154 pSession->joinRetryTimerInfo.pMac = pMac;
15155 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
15156 status = palTimerStart(pMac->hHdd, pSession->hTimerJoinRetry, interval, eANI_BOOLEAN_FALSE);
15157 if(!HAL_STATUS_SUCCESS(status))
15158 {
15159 smsLog(pMac, LOGE, FL(" fail to start timer status %s \n "), status);
15160 }
15161 }
15162 else
15163 {
15164 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)\n "),
15165 pSession->maxRetryCount);
15166 }
15167
15168 return (status);
15169}
15170
15171eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
15172{
15173 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer \n ");
15174 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
15175 {
15176 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerJoinRetry));
15177 }
15178
15179 return eHAL_STATUS_SUCCESS;
15180}
15181#endif
15182
15183
15184/*
15185 pBuf points to the beginning of the message
15186 LIM packs disassoc rsp as below,
15187 messageType - 2 bytes
15188 messageLength - 2 bytes
15189 sessionId - 1 byte
15190 transactionId - 2 bytes (tANI_U16)
15191 reasonCode - 4 bytes (sizeof(tSirResultCodes))
15192 peerMacAddr - 6 bytes
15193 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
15194*/
15195static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
15196{
15197 if(pBuf && pRsp)
15198 {
15199 pBuf += 4; //skip type and length
15200 pRsp->sessionId = *pBuf++;
15201 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
15202 pBuf += 2;
15203 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
15204 pBuf += 4;
15205 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
15206 }
15207}
15208
Jeff Johnsond13512a2012-07-17 11:42:19 -070015209eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
15210{
15211 static uNvTables nvTables;
15212 eHalStatus status = eHAL_STATUS_SUCCESS;
15213 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
15214
15215 /* read the country code from NV and use it */
15216 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
15217 {
15218 palCopyMemory( pMac->hHdd, pCountry,
15219 nvTables.defaultCountryTable.countryCode,
15220 WNI_CFG_COUNTRY_CODE_LEN );
15221 return status;
15222 }
15223 else
15224 {
15225 palCopyMemory( pMac->hHdd, pCountry,
15226 "XXX",
15227 WNI_CFG_COUNTRY_CODE_LEN );
15228 status = eHAL_STATUS_FAILURE;
15229 return status;
15230 }
15231}
15232
15233eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
15234{
15235 palCopyMemory( pMac->hHdd, pCountry,
15236 pMac->scan.countryCode11d,
15237 WNI_CFG_COUNTRY_CODE_LEN );
15238 return eHAL_STATUS_SUCCESS;
15239}