blob: e70f999100953d9efd0f251cd8751346db6fc992 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
42/** ------------------------------------------------------------------------- *
43 ------------------------------------------------------------------------- *
Jeff Johnsone7245742012-09-05 17:12:55 -070044
Jeff Johnson295189b2012-06-20 16:38:30 -070045
46 \file csrApiRoam.c
47
48 Implementation for the Common Roaming interfaces.
49
50 Copyright (C) 2008 Qualcomm, Incorporated
51
52
53 ========================================================================== */
Jeff Johnson295189b2012-06-20 16:38:30 -070054/*===========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070055 EDIT HISTORY FOR FILE
56
Jeff Johnson295189b2012-06-20 16:38:30 -070057 This section contains comments describing changes made to the module.
58 Notice that changes are listed in reverse chronological order.
59
Jeff Johnson295189b2012-06-20 16:38:30 -070060 when who what, where, why
61---------- --- --------------------------------------------------------
6206/03/10 js Added support to hostapd driven
63 * deauth/disassoc/mic failure
Jeff Johnson295189b2012-06-20 16:38:30 -070064===========================================================================*/
Jeff Johnson295189b2012-06-20 16:38:30 -070065#include "aniGlobal.h" //for tpAniSirGlobal
66#include "wlan_qct_wda.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070067#include "halMsgApi.h" //for HAL_STA_INVALID_IDX.
Jeff Johnsone7245742012-09-05 17:12:55 -070068#include "limUtils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070069#include "palApi.h"
70#include "csrInsideApi.h"
71#include "smsDebug.h"
72#include "logDump.h"
73#include "smeQosInternal.h"
74#include "wlan_qct_tl.h"
75#include "smeInside.h"
76#include "vos_diag_core_event.h"
77#include "vos_diag_core_log.h"
78#include "csrApi.h"
79#include "pmc.h"
80#include "vos_nvitem.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070081#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
82#include "csrNeighborRoam.h"
83#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
Jeff Johnson295189b2012-06-20 16:38:30 -070084#ifdef FEATURE_WLAN_CCX
85#include "csrCcx.h"
86#endif /* FEATURE_WLAN_CCX */
Jeff Johnson295189b2012-06-20 16:38:30 -070087#define CSR_NUM_IBSS_START_CHANNELS_50 4
88#define CSR_NUM_IBSS_START_CHANNELS_24 3
89#define CSR_DEF_IBSS_START_CHANNEL_50 36
90#define CSR_DEF_IBSS_START_CHANNEL_24 1
91#define CSR_IBSS_JOIN_TIMEOUT_PERIOD ( 1 * PAL_TIMER_TO_SEC_UNIT ) // 1 second
Srikant Kuppa2062aaf2012-12-27 17:36:41 -080092#define CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD ( 5 * PAL_TIMER_TO_SEC_UNIT ) // 5 seconds, for WPA, WPA2, CCKM
Jeff Johnson295189b2012-06-20 16:38:30 -070093#define CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD ( 120 * PAL_TIMER_TO_SEC_UNIT ) // 120 seconds, for WPS
94/*---------------------------------------------------------------------------
95 OBIWAN recommends [8 10]% : pick 9%
96---------------------------------------------------------------------------*/
97#define CSR_VCC_UL_MAC_LOSS_THRESHOLD 9
Jeff Johnson295189b2012-06-20 16:38:30 -070098/*---------------------------------------------------------------------------
99 OBIWAN recommends -85dBm
100---------------------------------------------------------------------------*/
101#define CSR_VCC_RSSI_THRESHOLD 80
102#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD 500 //ms
103#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS 2000 //ms
104#define CSR_MIN_TL_STAT_QUERY_PERIOD 500 //ms
105#define CSR_DIAG_LOG_STAT_PERIOD 3000 //ms
Jeff Johnson295189b2012-06-20 16:38:30 -0700106//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)
Jeff Johnson295189b2012-06-20 16:38:30 -0700111//Flag to send/do not send disassoc frame over the air
112#define CSR_DONT_SEND_DISASSOC_OVER_THE_AIR 1
Jeff Johnson295189b2012-06-20 16:38:30 -0700113#define RSSI_HACK_BMPS (-40)
Jeff Johnsone7245742012-09-05 17:12:55 -0700114#define MAX_CB_VALUE_IN_INI (2)
115
Jeff Johnson295189b2012-06-20 16:38:30 -0700116/*--------------------------------------------------------------------------
117 Static Type declarations
118 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800119static tCsrRoamSession csrRoamRoamSession[CSR_ROAM_SESSION_MAX];
Srinivas Girigowdade697412013-02-14 16:31:48 -0800120#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
121static const char KR_3[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
122 36, 40, 44, 48, 52, 56, 60, 64, 100, 104,
123 108, 112, 116, 120, 124, 149, 153, 157, 161};
124static const char KR_24[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
125 36, 40, 44, 48, 52, 56, 60, 64, 100, 104,
126 108, 112, 116, 120, 124, 149, 153, 157, 161};
127static const char KR_25[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
128 36, 40, 44, 48, 149, 153, 157, 161};
129#endif
130
Jeff Johnson295189b2012-06-20 16:38:30 -0700131/*--------------------------------------------------------------------------
132 Type declarations
133 ------------------------------------------------------------------------*/
134#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700135int diagAuthTypeFromCSRType(eCsrAuthType authType)
136{
137 int n = AUTH_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700138 switch(authType)
139 {
140 case eCSR_AUTH_TYPE_SHARED_KEY:
141 n = AUTH_SHARED;
142 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700143 case eCSR_AUTH_TYPE_WPA:
144 n = AUTH_WPA_EAP;
145 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700146 case eCSR_AUTH_TYPE_WPA_PSK:
147 n = AUTH_WPA_PSK;
148 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700149 case eCSR_AUTH_TYPE_RSN:
150 n = AUTH_WPA2_EAP;
151 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700152 case eCSR_AUTH_TYPE_RSN_PSK:
153 n = AUTH_WPA2_PSK;
154 break;
155#ifdef FEATURE_WLAN_WAPI
156 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
157 n = AUTH_WAPI_CERT;
158 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700159 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
160 n = AUTH_WAPI_PSK;
161 break;
162#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -0700163 default:
164 break;
165 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700166 return (n);
167}
Jeff Johnson295189b2012-06-20 16:38:30 -0700168int diagEncTypeFromCSRType(eCsrEncryptionType encType)
169{
170 int n = ENC_MODE_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700171 switch(encType)
172 {
173 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
174 case eCSR_ENCRYPT_TYPE_WEP40:
175 n = ENC_MODE_WEP40;
176 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700177 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
178 case eCSR_ENCRYPT_TYPE_WEP104:
179 n = ENC_MODE_WEP104;
180 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700181 case eCSR_ENCRYPT_TYPE_TKIP:
182 n = ENC_MODE_TKIP;
183 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700184 case eCSR_ENCRYPT_TYPE_AES:
185 n = ENC_MODE_AES;
186 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700187#ifdef FEATURE_WLAN_WAPI
188 case eCSR_ENCRYPT_TYPE_WPI:
189 n = ENC_MODE_SMS4;
190 break;
191#endif /* FEATURE_WLAN_WAPI */
192 default:
193 break;
194 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700195 return (n);
196}
Jeff Johnson295189b2012-06-20 16:38:30 -0700197#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700198static const tANI_U8 csrStartIbssChannels50[ CSR_NUM_IBSS_START_CHANNELS_50 ] = { 36, 40, 44, 48};
199static const tANI_U8 csrStartIbssChannels24[ CSR_NUM_IBSS_START_CHANNELS_24 ] = { 1, 6, 11 };
Jeff Johnson295189b2012-06-20 16:38:30 -0700200static void initConfigParam(tpAniSirGlobal pMac);
201static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
202 eCsrRoamCompleteResult Result, void *Context );
203static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId,
204 tCsrRoamProfile *pProfile,
205 tANI_BOOLEAN *pfSameIbss );
206static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirSmeNewBssInfo *pNewBss );
207static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -0700208 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes);
209static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700210eHalStatus csrInitGetChannels(tpAniSirGlobal pMac);
211static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result );
212eHalStatus csrRoamOpen(tpAniSirGlobal pMac);
213eHalStatus csrRoamClose(tpAniSirGlobal pMac);
214void csrRoamMICErrorTimerHandler(void *pv);
215void csrRoamTKIPCounterMeasureTimerHandler(void *pv);
216tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2);
217
218static eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval);
219static eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId);
220static void csrRoamRoamingTimerHandler(void *pv);
221eHalStatus csrRoamStartIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval);
222eHalStatus csrRoamStopIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId);
223static void csrRoamIbssJoinTimerHandler(void *pv);
224eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval);
225eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac);
226static void csrRoamWaitForKeyTimeOutHandler(void *pv);
227
228static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnsone7245742012-09-05 17:12:55 -0700229static eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700230static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo );
231eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
232 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
233 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
234 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
235 tANI_U8 *pKeyRsc );
236static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
237 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes,
238 tCsrRoamProfile *pProfile );
239void csrRoamStatisticsTimerHandler(void *pv);
240void csrRoamStatsGlobalClassDTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700241static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid);
242VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
243 v_U8_t rssiNotification,
244 void * context);
245static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId);
246void csrRoamVccTrigger(tpAniSirGlobal pMac);
247eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId);
248/*
249 pStaEntry is no longer invalid upon the return of this function.
250*/
251static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700252static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,tANI_U8 operationChn, eCsrBand *pBand );
Jeff Johnson295189b2012-06-20 16:38:30 -0700253static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700254tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
255 tDblLinkList *pStaList,
256 tCsrStatsClientReqInfo *pStaEntry);
257void csrRoamStatsClientTimerHandler(void *pv);
258tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
259 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId);
260void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
261 tCsrStatsCallback callback, tANI_U8 staId, void *pContext);
Jeff Johnsone7245742012-09-05 17:12:55 -0700262void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats);
Jeff Johnson295189b2012-06-20 16:38:30 -0700263void csrRoamTlStatsTimerHandler(void *pv);
264void csrRoamPeStatsTimerHandler(void *pv);
265tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
266void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry);
267tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
268eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac);
269static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac );
270static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc );
271static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId );
272static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
273 tCsrRoamSetKey *pSetKey, tANI_U32 roamId );
274//static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand );
275static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
276void csrRoamReissueRoamCommand(tpAniSirGlobal pMac);
277#ifdef FEATURE_WLAN_BTAMP_UT_RF
278void csrRoamJoinRetryTimerHandler(void *pv);
279#endif
280extern void SysProcessMmhMsg(tpAniSirGlobal pMac, tSirMsgQ* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700281extern void btampEstablishLogLinkHdlr(void* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700282static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700283void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand);
Jeff Johnson295189b2012-06-20 16:38:30 -0700284
285//Initialize global variables
286static void csrRoamInitGlobals(tpAniSirGlobal pMac)
287{
288 if(pMac)
289 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800290 vos_mem_zero(&csrRoamRoamSession, sizeof(csrRoamRoamSession));
291 pMac->roam.roamSession = csrRoamRoamSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700292 }
293 return;
294}
295
Jeff Johnson295189b2012-06-20 16:38:30 -0700296static void csrRoamDeInitGlobals(tpAniSirGlobal pMac)
297{
298 if(pMac)
299 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800300 pMac->roam.roamSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700301 }
302 return;
303}
Jeff Johnson295189b2012-06-20 16:38:30 -0700304eHalStatus csrOpen(tpAniSirGlobal pMac)
305{
306 eHalStatus status = eHAL_STATUS_SUCCESS;
307 static uNvTables nvTables;
308 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700309 v_REGDOMAIN_t regId;
310 tANI_U32 i;
311
312 do
313 {
314 /* Initialize CSR Roam Globals */
315 csrRoamInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700316 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
317 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i);
318
319 initConfigParam(pMac);
320 if(!HAL_STATUS_SUCCESS((status = csrScanOpen(pMac))))
321 break;
322 if(!HAL_STATUS_SUCCESS((status = csrRoamOpen(pMac))))
323 break;
324 pMac->roam.nextRoamId = 1; //Must not be 0
325 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.statsClientReqList)))
326 break;
327 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.peStatsReqList)))
328 break;
329 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.roamCmdPendingList)))
330 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700331 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
332 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
333 {
334 palCopyMemory( pMac->hHdd, pMac->scan.countryCodeDefault,
335 nvTables.defaultCountryTable.countryCode, WNI_CFG_COUNTRY_CODE_LEN );
336 status = eHAL_STATUS_SUCCESS;
337 }
338 else
339 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800340 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700341 //hardcoded for now
342 pMac->scan.countryCodeDefault[0] = 'U';
343 pMac->scan.countryCodeDefault[1] = 'S';
344 pMac->scan.countryCodeDefault[2] = 'I';
345 //status = eHAL_STATUS_SUCCESS;
346 }
Madan Mohan Koyyalamudi8b7f1e62012-10-05 14:56:51 -0700347 smsLog( pMac, LOG1, FL(" country Code from nvRam %s"), pMac->scan.countryCodeDefault );
Jeff Johnson295189b2012-06-20 16:38:30 -0700348 csrGetRegulatoryDomainForCountry(pMac, pMac->scan.countryCodeDefault, &regId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700349 WDA_SetRegDomain(pMac, regId);
350 pMac->scan.domainIdDefault = regId;
351 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700352 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent,
353 pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN);
354 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700355 }while(0);
356
357 return (status);
358}
359
Jeff Johnson295189b2012-06-20 16:38:30 -0700360eHalStatus csrSetRegInfo(tHalHandle hHal, tANI_U8 *apCntryCode)
361{
362 eHalStatus status = eHAL_STATUS_SUCCESS;
363 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
364 v_REGDOMAIN_t regId;
365 v_U8_t cntryCodeLength;
Jeff Johnson295189b2012-06-20 16:38:30 -0700366 if(NULL == apCntryCode)
367 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800368 smsLog( pMac, LOGW, FL(" Invalid country Code Pointer") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700369 return eHAL_STATUS_FAILURE;
370 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800371 smsLog( pMac, LOGW, FL(" country Code %s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700372 /* To get correct Regulatory domain from NV table
373 * 2 character Country code should be used
374 * 3rd charater is optional for indoor/outdoor setting */
375 cntryCodeLength = strlen(apCntryCode);
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700376
377 if (cntryCodeLength > WNI_CFG_COUNTRY_CODE_LEN)
378 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800379 smsLog( pMac, LOGW, FL(" Invalid Country Code Length") );
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700380 return eHAL_STATUS_FAILURE;
381 }
382
Jeff Johnson295189b2012-06-20 16:38:30 -0700383 status = csrGetRegulatoryDomainForCountry(pMac, apCntryCode, &regId);
384 if (status != eHAL_STATUS_SUCCESS)
385 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800386 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700387 return status;
388 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700389 status = WDA_SetRegDomain(hHal, regId);
390 if (status != eHAL_STATUS_SUCCESS)
391 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800392 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700393 return status;
394 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700395 pMac->scan.domainIdDefault = regId;
396 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700397 /* Clear CC field */
398 palFillMemory( pMac->hHdd,
399 pMac->scan.countryCodeDefault,
400 WNI_CFG_COUNTRY_CODE_LEN,
401 0 );
402 /* Copy 2 or 3 bytes country code */
403 palCopyMemory( pMac->hHdd, pMac->scan.countryCodeDefault,
404 apCntryCode, cntryCodeLength );
Jeff Johnson295189b2012-06-20 16:38:30 -0700405 /* If 2 bytes country code, 3rd byte must be filled with space */
406 if((WNI_CFG_COUNTRY_CODE_LEN - 1) == cntryCodeLength)
407 {
408 palFillMemory( pMac->hHdd,
409 pMac->scan.countryCodeDefault + 2,
410 1,
411 0x20 );
412 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700413 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent,
414 pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN);
415 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700416 return status;
417}
Jeff Johnson295189b2012-06-20 16:38:30 -0700418eHalStatus csrSetChannels(tHalHandle hHal, tCsrConfigParam *pParam )
419{
420 eHalStatus status = eHAL_STATUS_SUCCESS;
421 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
422 tANI_U8 index = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700423 palCopyMemory( pMac->hHdd, pParam->Csr11dinfo.countryCode,
424 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN );
Jeff Johnson295189b2012-06-20 16:38:30 -0700425 for ( index = 0; index < pMac->scan.base20MHzChannels.numChannels ; index++)
426 {
427 pParam->Csr11dinfo.Channels.channelList[index] = pMac->scan.base20MHzChannels.channelList[ index ];
428 pParam->Csr11dinfo.ChnPower[index].firstChannel = pMac->scan.base20MHzChannels.channelList[ index ];
429 pParam->Csr11dinfo.ChnPower[index].numChannels = 1;
430 pParam->Csr11dinfo.ChnPower[index].maxtxPower = pMac->scan.defaultPowerTable[index].pwr;
431 }
432 pParam->Csr11dinfo.Channels.numChannels = pMac->scan.base20MHzChannels.numChannels;
433
434 return status;
435}
Jeff Johnson295189b2012-06-20 16:38:30 -0700436eHalStatus csrClose(tpAniSirGlobal pMac)
437{
438 eHalStatus status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800439
Jeff Johnson295189b2012-06-20 16:38:30 -0700440 csrStop(pMac);
441 csrRoamClose(pMac);
442 csrScanClose(pMac);
443 csrLLClose(&pMac->roam.statsClientReqList);
444 csrLLClose(&pMac->roam.peStatsReqList);
445 csrLLClose(&pMac->roam.roamCmdPendingList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700446 /* DeInit Globals */
447 csrRoamDeInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700448 return (status);
449}
Jeff Johnson295189b2012-06-20 16:38:30 -0700450eHalStatus csrStart(tpAniSirGlobal pMac)
451{
452 eHalStatus status = eHAL_STATUS_SUCCESS;
453 tANI_U32 i;
454
455 do
456 {
457 //save the global vos context
458 pMac->roam.gVosContext = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
459 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
460 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, i );
461
462 status = csrRoamStart(pMac);
463 if(!HAL_STATUS_SUCCESS(status)) break;
464 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE;
465 status = pmcRegisterPowerSaveCheck(pMac, csrCheckPSReady, pMac);
466 if(!HAL_STATUS_SUCCESS(status)) break;
467 pMac->roam.sPendingCommands = 0;
468 csrScanEnable(pMac);
469#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
470 status = csrNeighborRoamInit(pMac);
471#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
472 pMac->roam.tlStatsReqInfo.numClient = 0;
473 pMac->roam.tlStatsReqInfo.periodicity = 0;
474 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
475 //init the link quality indication also
476 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_MIN_IND;
477 if(!HAL_STATUS_SUCCESS(status))
478 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800479 smsLog(pMac, LOGW, " csrStart: Couldn't Init HO control blk ");
Jeff Johnson295189b2012-06-20 16:38:30 -0700480 break;
481 }
482 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700483#if defined(ANI_LOGDUMP)
484 csrDumpInit(pMac);
485#endif //#if defined(ANI_LOGDUMP)
Jeff Johnson295189b2012-06-20 16:38:30 -0700486 return (status);
487}
488
Jeff Johnson295189b2012-06-20 16:38:30 -0700489eHalStatus csrStop(tpAniSirGlobal pMac)
490{
491 tANI_U32 sessionId;
492 tANI_U32 i;
493
494 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
495 {
496 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
497 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700498 csrScanDisable(pMac);
499 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE;
500 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700501 csrLLPurge( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_TRUE );
502
503#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
504 csrNeighborRoamClose(pMac);
505#endif
506 csrScanFlushResult(pMac); //Do we want to do this?
Jeff Johnson295189b2012-06-20 16:38:30 -0700507 // deregister from PMC since we register during csrStart()
508 // (ignore status since there is nothing we can do if it fails)
509 (void) pmcDeregisterPowerSaveCheck(pMac, csrCheckPSReady);
Jeff Johnson295189b2012-06-20 16:38:30 -0700510 //Reset the domain back to the deault
511 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800512 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700513
514 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
515 {
516 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP ,i );
517 pMac->roam.curSubState[i] = eCSR_ROAM_SUBSTATE_NONE;
518 }
519
520 return (eHAL_STATUS_SUCCESS);
521}
522
Jeff Johnson295189b2012-06-20 16:38:30 -0700523eHalStatus csrReady(tpAniSirGlobal pMac)
524{
525 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700526 csrScanGetSupportedChannels( pMac );
527 //WNI_CFG_VALID_CHANNEL_LIST should be set by this time
528 //use it to init the background scan list
529 csrInitBGScanChannelList(pMac);
530 /* HDD issues the init scan */
531 csrScanStartResultAgingTimer(pMac);
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -0800532 /* If the gScanAgingTime is set to '0' then scan results aging timeout
533 based on timer feature is not enabled*/
534 if(0 != pMac->scan.scanResultCfgAgingTime )
535 {
536 csrScanStartResultCfgAgingTimer(pMac);
537 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700538 //Store the AC weights in TL for later use
539 WLANTL_GetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
Jeff Johnson295189b2012-06-20 16:38:30 -0700540 status = csrInitChannelList( pMac );
541 if ( ! HAL_STATUS_SUCCESS( status ) )
542 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800543 smsLog( pMac, LOGE, "csrInitChannelList failed during csrReady with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700544 status );
545 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700546 return (status);
547}
Jeff Johnson295189b2012-06-20 16:38:30 -0700548void csrSetDefaultDot11Mode( tpAniSirGlobal pMac )
549{
550 v_U32_t wniDot11mode = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700551 wniDot11mode = csrTranslateToWNICfgDot11Mode(pMac,pMac->roam.configParam.uCfgDot11Mode);
552 ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, wniDot11mode, NULL, eANI_BOOLEAN_FALSE);
553}
Jeff Johnson295189b2012-06-20 16:38:30 -0700554void csrSetGlobalCfgs( tpAniSirGlobal pMac )
555{
Jeff Johnsone7245742012-09-05 17:12:55 -0700556
Jeff Johnson295189b2012-06-20 16:38:30 -0700557 ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
558 ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
559 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
560 ((pMac->roam.configParam.Is11hSupportEnabled) ? pMac->roam.configParam.Is11dSupportEnabled : pMac->roam.configParam.Is11dSupportEnabled),
561 NULL, eANI_BOOLEAN_FALSE);
562 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnsone7245742012-09-05 17:12:55 -0700563 /* For now we will just use the 5GHz CB mode ini parameter to decide whether CB supported or not in Probes when there is no session
564 * Once session is established we will use the session related params stored in PE session for CB mode
565 */
566 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, !!(pMac->roam.configParam.channelBondingMode5GHz), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700567 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, pMac->roam.configParam.HeartbeatThresh24, NULL, eANI_BOOLEAN_FALSE);
568
569 //Update the operating mode to configured value during initialization,
570 //So that client can advertise full capabilities in Probe request frame.
571 csrSetDefaultDot11Mode( pMac );
572}
573
Jeff Johnson295189b2012-06-20 16:38:30 -0700574eHalStatus csrRoamOpen(tpAniSirGlobal pMac)
575{
576 eHalStatus status = eHAL_STATUS_SUCCESS;
577 tANI_U32 i;
578 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700579 do
580 {
581 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
582 {
583 pSession = CSR_GET_SESSION( pMac, i );
584 pSession->roamingTimerInfo.pMac = pMac;
585 pSession->roamingTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
586 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700587 pMac->roam.WaitForKeyTimerInfo.pMac = pMac;
588 pMac->roam.WaitForKeyTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
589 status = palTimerAlloc(pMac->hHdd, &pMac->roam.hTimerWaitForKey, csrRoamWaitForKeyTimeOutHandler,
590 &pMac->roam.WaitForKeyTimerInfo);
591 if(!HAL_STATUS_SUCCESS(status))
592 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800593 smsLog(pMac, LOGE, FL("cannot allocate memory for WaitForKey time out timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700594 break;
595 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700596 status = palTimerAlloc(pMac->hHdd, &pMac->roam.tlStatsReqInfo.hTlStatsTimer, csrRoamTlStatsTimerHandler, pMac);
597 if(!HAL_STATUS_SUCCESS(status))
598 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800599 smsLog(pMac, LOGE, FL("cannot allocate memory for summary Statistics timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700600 return eHAL_STATUS_FAILURE;
601 }
602 }while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700603 return (status);
604}
605
Jeff Johnson295189b2012-06-20 16:38:30 -0700606eHalStatus csrRoamClose(tpAniSirGlobal pMac)
607{
608 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700609 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
610 {
611 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
612 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700613 palTimerStop(pMac->hHdd, pMac->roam.hTimerWaitForKey);
614 palTimerFree(pMac->hHdd, pMac->roam.hTimerWaitForKey);
Jeff Johnson295189b2012-06-20 16:38:30 -0700615 palTimerStop(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
616 palTimerFree(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700617 return (eHAL_STATUS_SUCCESS);
618}
619
Jeff Johnson295189b2012-06-20 16:38:30 -0700620eHalStatus csrRoamStart(tpAniSirGlobal pMac)
621{
622 (void)pMac;
Jeff Johnson295189b2012-06-20 16:38:30 -0700623 return (eHAL_STATUS_SUCCESS);
624}
625
Jeff Johnson295189b2012-06-20 16:38:30 -0700626void csrRoamStop(tpAniSirGlobal pMac, tANI_U32 sessionId)
627{
628 csrRoamStopRoamingTimer(pMac, sessionId);
629 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
630 csrRoamDeregStatisticsReq(pMac);
631}
Jeff Johnson295189b2012-06-20 16:38:30 -0700632eHalStatus csrRoamGetConnectState(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrConnectState *pState)
633{
634 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Srinivas Girigowdac84c57c2013-02-19 17:41:56 -0800635 if ( CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700636 {
637 status = eHAL_STATUS_SUCCESS;
638 *pState = pMac->roam.roamSession[sessionId].connectState;
639 }
640 return (status);
641}
642
Jeff Johnson295189b2012-06-20 16:38:30 -0700643eHalStatus csrRoamCopyConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
644{
645 eHalStatus status = eHAL_STATUS_FAILURE;
646 tANI_U32 size = 0;
647 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -0700648
649 if(!pSession)
650 {
651 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
652 return eHAL_STATUS_FAILURE;
653 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700654
655 if(pProfile)
656 {
657 if(pSession->pConnectBssDesc)
658 {
659 do
660 {
661 size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length);
662 if(size)
663 {
664 status = palAllocateMemory(pMac->hHdd, (void **)&pProfile->pBssDesc, size);
665 if(HAL_STATUS_SUCCESS(status))
666 {
667 palCopyMemory(pMac->hHdd, pProfile->pBssDesc, pSession->pConnectBssDesc, size);
668 }
669 else
670 break;
671 }
672 else
673 {
674 pProfile->pBssDesc = NULL;
675 }
676 pProfile->AuthType = pSession->connectedProfile.AuthType;
677 pProfile->EncryptionType = pSession->connectedProfile.EncryptionType;
678 pProfile->mcEncryptionType = pSession->connectedProfile.mcEncryptionType;
679 pProfile->BSSType = pSession->connectedProfile.BSSType;
680 pProfile->operationChannel = pSession->connectedProfile.operationChannel;
681 pProfile->CBMode = pSession->connectedProfile.CBMode;
682 palCopyMemory(pMac->hHdd, &pProfile->bssid, &pSession->connectedProfile.bssid, sizeof(tCsrBssid));
683 palCopyMemory(pMac->hHdd, &pProfile->SSID, &pSession->connectedProfile.SSID, sizeof(tSirMacSSid));
684#ifdef WLAN_FEATURE_VOWIFI_11R
685 if (pSession->connectedProfile.MDID.mdiePresent)
686 {
687 pProfile->MDID.mdiePresent = 1;
688 pProfile->MDID.mobilityDomain = pSession->connectedProfile.MDID.mobilityDomain;
689 }
690 else
691 {
692 pProfile->MDID.mdiePresent = 0;
693 pProfile->MDID.mobilityDomain = 0;
694 }
695#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700696#ifdef FEATURE_WLAN_CCX
697 pProfile->isCCXAssoc = pSession->connectedProfile.isCCXAssoc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700698 if (csrIsAuthTypeCCX(pSession->connectedProfile.AuthType))
699 {
700 palCopyMemory( pMac->hHdd, pProfile->ccxCckmInfo.krk,
701 pSession->connectedProfile.ccxCckmInfo.krk, CSR_KRK_KEY_LEN );
702 pProfile->ccxCckmInfo.reassoc_req_num=
703 pSession->connectedProfile.ccxCckmInfo.reassoc_req_num;
704 pProfile->ccxCckmInfo.krk_plumbed =
705 pSession->connectedProfile.ccxCckmInfo.krk_plumbed;
706 }
707#endif
708 }while(0);
709 }
710 }
711
712 return (status);
713}
714
Jeff Johnson295189b2012-06-20 16:38:30 -0700715eHalStatus csrRoamGetConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
716{
717 eHalStatus status = eHAL_STATUS_FAILURE;
718
719 if(csrIsConnStateConnected(pMac, sessionId))
720 {
721 if(pProfile)
722 {
723 status = csrRoamCopyConnectProfile(pMac, sessionId, pProfile);
724 }
725 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700726 return (status);
727}
Jeff Johnson295189b2012-06-20 16:38:30 -0700728eHalStatus csrRoamFreeConnectProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile)
729{
730 eHalStatus status = eHAL_STATUS_SUCCESS;
731
732 if(pProfile->pBssDesc)
733 {
734 palFreeMemory(pMac->hHdd, pProfile->pBssDesc);
735 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700736 if(pProfile->pAddIEAssoc)
737 {
738 palFreeMemory(pMac->hHdd, pProfile->pAddIEAssoc);
739 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700740 palZeroMemory(pMac->hHdd, pProfile, sizeof(tCsrRoamConnectedProfile));
741 pProfile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
742 return (status);
743}
744
Jeff Johnson295189b2012-06-20 16:38:30 -0700745static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo )
746{
747 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700748 if( pConnectedInfo->pbFrames )
749 {
750 palFreeMemory( pMac->hHdd, pConnectedInfo->pbFrames );
751 pConnectedInfo->pbFrames = NULL;
752 }
753 pConnectedInfo->nBeaconLength = 0;
754 pConnectedInfo->nAssocReqLength = 0;
755 pConnectedInfo->nAssocRspLength = 0;
756 pConnectedInfo->staId = 0;
757#ifdef WLAN_FEATURE_VOWIFI_11R
758 pConnectedInfo->nRICRspLength = 0;
759#endif
760#ifdef FEATURE_WLAN_CCX
761 pConnectedInfo->nTspecIeLength = 0;
762#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700763 return ( status );
764}
765
Jeff Johnson295189b2012-06-20 16:38:30 -0700766
767
Jeff Johnsone7245742012-09-05 17:12:55 -0700768
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700769void csrReleaseCommandPreauth(tpAniSirGlobal pMac, tSmeCmd *pCommand)
770{
771 csrReinitPreauthCmd(pMac, pCommand);
772 csrReleaseCommand( pMac, pCommand );
773}
774
Jeff Johnson295189b2012-06-20 16:38:30 -0700775void csrReleaseCommandRoam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
776{
777 csrReinitRoamCmd(pMac, pCommand);
778 csrReleaseCommand( pMac, pCommand );
779}
780
Jeff Johnson295189b2012-06-20 16:38:30 -0700781void csrReleaseCommandScan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
782{
783 csrReinitScanCmd(pMac, pCommand);
784 csrReleaseCommand( pMac, pCommand );
785}
786
Jeff Johnson295189b2012-06-20 16:38:30 -0700787void csrReleaseCommandWmStatusChange(tpAniSirGlobal pMac, tSmeCmd *pCommand)
788{
789 csrReinitWmStatusChangeCmd(pMac, pCommand);
790 csrReleaseCommand( pMac, pCommand );
791}
792
Jeff Johnson295189b2012-06-20 16:38:30 -0700793void csrReinitSetKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
794{
795 palZeroMemory(pMac->hHdd, &pCommand->u.setKeyCmd, sizeof(tSetKeyCmd));
796}
797
Jeff Johnson295189b2012-06-20 16:38:30 -0700798void csrReinitRemoveKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
799{
800 palZeroMemory(pMac->hHdd, &pCommand->u.removeKeyCmd, sizeof(tRemoveKeyCmd));
801}
802
Jeff Johnson295189b2012-06-20 16:38:30 -0700803void csrReleaseCommandSetKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
804{
805 csrReinitSetKeyCmd(pMac, pCommand);
806 csrReleaseCommand( pMac, pCommand );
807}
Jeff Johnson295189b2012-06-20 16:38:30 -0700808void csrReleaseCommandRemoveKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
809{
810 csrReinitRemoveKeyCmd(pMac, pCommand);
811 csrReleaseCommand( pMac, pCommand );
812}
Jeff Johnson295189b2012-06-20 16:38:30 -0700813void csrAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
814{
815
816 if( eSmeCsrCommandMask & pCommand->command )
817 {
818 switch (pCommand->command)
819 {
820 case eSmeCommandScan:
Jeff Johnson1250df42012-12-10 14:31:52 -0800821 // We need to inform the requester before dropping the scan command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800822 smsLog( pMac, LOGW, "%s: Drop scan reason %d callback 0x%X",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700823 __func__, pCommand->u.scanCmd.reason, (unsigned int)pCommand->u.scanCmd.callback);
Jeff Johnson295189b2012-06-20 16:38:30 -0700824 if (NULL != pCommand->u.scanCmd.callback)
825 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800826 smsLog( pMac, LOGW, "%s callback scan requester", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700827 csrScanCallCallback(pMac, pCommand, eCSR_SCAN_ABORT);
828 }
829 csrReleaseCommandScan( pMac, pCommand );
830 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700831 case eSmeCommandRoam:
832 csrReleaseCommandRoam( pMac, pCommand );
833 break;
834
835 case eSmeCommandWmStatusChange:
836 csrReleaseCommandWmStatusChange( pMac, pCommand );
837 break;
838
839 case eSmeCommandSetKey:
840 csrReleaseCommandSetKey( pMac, pCommand );
841 break;
842
843 case eSmeCommandRemoveKey:
844 csrReleaseCommandRemoveKey( pMac, pCommand );
845 break;
846
847 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800848 smsLog( pMac, LOGW, " CSR abort standard command %d", pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -0700849 csrReleaseCommand( pMac, pCommand );
850 break;
851 }
852 }
853}
854
Jeff Johnson295189b2012-06-20 16:38:30 -0700855void csrRoamSubstateChange( tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate, tANI_U32 sessionId)
856{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800857 smsLog( pMac, LOG1, " CSR RoamSubstate: [ %d <== %d ]", NewSubstate, pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700858
Jeff Johnson295189b2012-06-20 16:38:30 -0700859 if(pMac->roam.curSubState[sessionId] == NewSubstate)
860 {
861 return;
Jeff Johnsone7245742012-09-05 17:12:55 -0700862 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700863 pMac->roam.curSubState[sessionId] = NewSubstate;
864}
865
Jeff Johnson295189b2012-06-20 16:38:30 -0700866eCsrRoamState csrRoamStateChange( tpAniSirGlobal pMac, eCsrRoamState NewRoamState, tANI_U8 sessionId)
867{
868 eCsrRoamState PreviousState;
869
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800870 smsLog( pMac, LOG1, "CSR RoamState: [ %d <== %d ]", NewRoamState, pMac->roam.curState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700871
872 PreviousState = pMac->roam.curState[sessionId];
873
874 if ( NewRoamState != pMac->roam.curState[sessionId] )
875 {
876 // Whenever we transition OUT of the Roaming state, clear the Roaming substate...
877 if ( CSR_IS_ROAM_JOINING(pMac, sessionId) )
878 {
879 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
880 }
881
882 pMac->roam.curState[sessionId] = NewRoamState;
883 }
884 return( PreviousState );
885}
886
Jeff Johnson295189b2012-06-20 16:38:30 -0700887void csrAssignRssiForCategory(tpAniSirGlobal pMac, tANI_U8 catOffset)
888{
889 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -0700890 if(catOffset)
891 {
892 pMac->roam.configParam.bCatRssiOffset = catOffset;
893 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
894 {
895 pMac->roam.configParam.RSSICat[CSR_NUM_RSSI_CAT - i - 1] = (int)CSR_BEST_RSSI_VALUE - (int)(i * catOffset);
896 }
897 }
898}
899
Jeff Johnson295189b2012-06-20 16:38:30 -0700900static void initConfigParam(tpAniSirGlobal pMac)
901{
902 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -0700903 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
904 pMac->roam.configParam.channelBondingMode24GHz = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
905 pMac->roam.configParam.channelBondingMode5GHz = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700906
Jeff Johnson295189b2012-06-20 16:38:30 -0700907 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_TAURUS;
908 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
909 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
910 pMac->roam.configParam.FragmentationThreshold = eCSR_DOT11_FRAG_THRESH_DEFAULT;
911 pMac->roam.configParam.HeartbeatThresh24 = 40;
912 pMac->roam.configParam.HeartbeatThresh50 = 40;
913 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
914 pMac->roam.configParam.Is11dSupportEnabledOriginal = eANI_BOOLEAN_FALSE;
915 pMac->roam.configParam.Is11eSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700916 pMac->roam.configParam.Is11hSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700917 pMac->roam.configParam.RTSThreshold = 2346;
918 pMac->roam.configParam.shortSlotTime = eANI_BOOLEAN_TRUE;
919 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
920 pMac->roam.configParam.ProprietaryRatesEnabled = eANI_BOOLEAN_TRUE;
921 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
922 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
923 pMac->roam.configParam.scanAgeTimeNCNPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_NO_PS;
924 pMac->roam.configParam.scanAgeTimeNCPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_W_PS;
925 pMac->roam.configParam.scanAgeTimeCNPS = CSR_SCAN_AGING_TIME_CONNECT_NO_PS;
926 pMac->roam.configParam.scanAgeTimeCPS = CSR_SCAN_AGING_TIME_CONNECT_W_PS;
927 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
928 {
929 pMac->roam.configParam.BssPreferValue[i] = i;
930 }
931 csrAssignRssiForCategory(pMac, CSR_DEFAULT_RSSI_DB_GAP);
932 pMac->roam.configParam.nRoamingTime = CSR_DEFAULT_ROAMING_TIME;
933 pMac->roam.configParam.fEnforce11dChannels = eANI_BOOLEAN_FALSE;
934 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700935 pMac->roam.configParam.fEnforceCountryCodeMatch = eANI_BOOLEAN_FALSE;
936 pMac->roam.configParam.fEnforceDefaultDomain = eANI_BOOLEAN_FALSE;
937 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
938 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
939 pMac->roam.configParam.nPassiveMaxChnTime = CSR_PASSIVE_MAX_CHANNEL_TIME;
940 pMac->roam.configParam.nPassiveMinChnTime = CSR_PASSIVE_MIN_CHANNEL_TIME;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -0800941 pMac->roam.configParam.nActiveMaxChnTimeBtc = CSR_ACTIVE_MAX_CHANNEL_TIME_BTC;
942 pMac->roam.configParam.nActiveMinChnTimeBtc = CSR_ACTIVE_MIN_CHANNEL_TIME_BTC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700943#ifdef WLAN_AP_STA_CONCURRENCY
944 pMac->roam.configParam.nActiveMaxChnTimeConc = CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
945 pMac->roam.configParam.nActiveMinChnTimeConc = CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
946 pMac->roam.configParam.nPassiveMaxChnTimeConc = CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
947 pMac->roam.configParam.nPassiveMinChnTimeConc = CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
948 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Vinay Malekal05fdc812012-12-17 13:04:30 -0800949 pMac->roam.configParam.nNumChanCombinedConc = CSR_NUM_CHAN_COMBINED_CONC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700950#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700951 pMac->roam.configParam.IsIdleScanEnabled = TRUE; //enable the idle scan by default
952 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
953 pMac->roam.configParam.statsReqPeriodicity = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
954 pMac->roam.configParam.statsReqPeriodicityInPS = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700955#ifdef WLAN_FEATURE_VOWIFI_11R
956 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
957#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700958#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
959 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
960 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold = 120;
961 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold = 125;
962 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
963 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
964 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = 200;
965 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels = 3;
966 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[0] = 1;
967 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[1] = 6;
968 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[2] = 11;
969 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; //20 seconds
Srinivas Girigowdade697412013-02-14 16:31:48 -0800970 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700971#endif
Jeff Johnsone7245742012-09-05 17:12:55 -0700972#ifdef WLAN_FEATURE_11AC
973 pMac->roam.configParam.nVhtChannelWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
974#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700975
976 pMac->roam.configParam.addTSWhenACMIsOff = 0;
977 pMac->roam.configParam.fScanTwice = eANI_BOOLEAN_FALSE;
Mohit Khanna349bc392012-09-11 17:24:52 -0700978
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -0700979 //Remove this code once SLM_Sessionization is supported
980 //BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnsone7245742012-09-05 17:12:55 -0700981 pMac->roam.configParam.doBMPSWorkaround = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700982
Jeff Johnsone7245742012-09-05 17:12:55 -0700983}
Jeff Johnson295189b2012-06-20 16:38:30 -0700984eCsrBand csrGetCurrentBand(tHalHandle hHal)
985{
986 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
987 return pMac->roam.configParam.bandCapability;
988}
Srinivas Girigowdade697412013-02-14 16:31:48 -0800989
990#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
991tANI_BOOLEAN csrIsChannelInCountryValidList(tpAniSirGlobal pMac, tANI_U8 channel)
992{
993 /* Get country code from CFG */
994 tANI_U8 *pCountryCode = pMac->scan.countryCodeCurrent;
995 tANI_U8 i = 0;
996 v_BOOL_t retVal = FALSE;
997 tANI_U8 *pCountryValidChannelList = pMac->roam.neighborRoamInfo.cfgParams.countryChannelInfo.countryValidChannelList.ChannelList;
998 tANI_U8 *pNumChannels = &pMac->roam.neighborRoamInfo.cfgParams.countryChannelInfo.countryValidChannelList.numOfChannels;
999
1000 /* Compare against KR valid list */
1001 if ((0 == strncmp(pCountryCode, "KR", 2)) &&
1002 (NULL != pCountryValidChannelList))
1003 {
1004 for (i = 0; i <(*pNumChannels); i++)
1005 {
1006 if (channel == pCountryValidChannelList[i])
1007 {
1008 retVal = TRUE;
1009 break;
1010 }
1011 }
1012 }
1013 else
1014 {
1015 retVal = csrRoamIsChannelValid(pMac, channel);
1016 }
1017
1018 return retVal;
1019}
1020
1021void csr_SetRevision(tpAniSirGlobal pMac, tANI_U8 revision)
1022{
1023 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1024 pNeighborRoamInfo->cfgParams.countryChannelInfo.revision = revision;
1025}
1026
1027/*
1028 This function flushes the roam scan cache and creates fresh cache
1029 based on the input channel list
1030*/
1031eHalStatus csrFlushAndCreateBgScanRoamChannelList(tpAniSirGlobal pMac,
1032 const tANI_U8 *pChannelList,
1033 const tANI_U8 numChannels)
1034{
1035 eHalStatus status = eHAL_STATUS_SUCCESS;
1036 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1037
1038 /* Free up the memory first (if required) */
1039 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1040 {
1041 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
1042 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
1043 }
1044 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1045
1046 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
1047 vos_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1048
1049 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1050 {
1051 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1052 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1053 return eHAL_STATUS_RESOURCES;
1054 }
1055
1056 /* Update the roam global structure */
1057 palCopyMemory(pMac->hHdd, pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
1058 pChannelList,
1059 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1060 return status;
1061}
1062
1063/* This function modifies the bgscan channel list set via config ini or
1064 runtime, whenever the band changes.
1065 if the band is auto, then no operation is performed on the channel list
1066 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1067 if the band is 5G, then make sure channel list contains only 5G valid channels
1068*/
1069eHalStatus csrUpdateBgScanConfigIniChannelList(tpAniSirGlobal pMac,
1070 eCsrBand eBand)
1071{
1072 eHalStatus status = eHAL_STATUS_SUCCESS;
1073 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1074 tANI_U8 outNumChannels = 0;
1075 tANI_U8 inNumChannels = 0;
1076 tANI_U8 *inPtr = NULL;
1077 tANI_U8 i = 0;
1078 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1079
1080 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1081
1082 {
1083 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1084 "No update required for channel list "
1085 "either cfg.ini channel list is not set up or "
1086 "auto band (Band %d)", eBand);
1087 return status;
1088 }
1089
1090 inNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
1091 inPtr = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
1092 if (eCSR_BAND_24 == eBand)
1093 {
1094 for (i = 0; i < inNumChannels; i++)
1095 {
1096 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrIsChannelInCountryValidList(pMac, inPtr[i]))
1097 {
1098 ChannelList[outNumChannels++] = inPtr[i];
1099 }
1100 }
1101 csrFlushAndCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
1102 }
1103 else if (eCSR_BAND_5G == eBand)
1104 {
1105 for (i = 0; i < inNumChannels; i++)
1106 {
1107 /* Add 5G Non-DFS channel */
1108 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
1109 csrIsChannelInCountryValidList(pMac, inPtr[i]) &&
1110 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1111 {
1112 ChannelList[outNumChannels++] = inPtr[i];
1113 }
1114 }
1115 csrFlushAndCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
1116 }
1117 else if (eCSR_BAND_ALL == eBand)
1118 {
1119 for (i = 0; i < inNumChannels; i++)
1120 {
1121 if (csrIsChannelInCountryValidList(pMac, inPtr[i]) &&
1122 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1123 {
1124 ChannelList[outNumChannels++] = inPtr[i];
1125 }
1126 }
1127 csrFlushAndCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
1128 }
1129 else
1130 {
1131 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1132 "Invalid band, No operation carried out (Band %d)", eBand);
1133 status = eHAL_STATUS_INVALID_PARAMETER;
1134 }
1135
1136 return status;
1137}
1138
1139/*
1140 This function initializes the valid channel list based on country code
1141*/
1142eHalStatus csrInitCountryValidChannelList(tpAniSirGlobal pMac,
1143 tANI_U8 Revision)
1144{
1145 eHalStatus status = eHAL_STATUS_SUCCESS;
1146 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1147 tANI_U8 *pOutChannelList = pNeighborRoamInfo->cfgParams.countryChannelInfo.countryValidChannelList.ChannelList;
1148 tANI_U8 *pNumChannels = &pNeighborRoamInfo->cfgParams.countryChannelInfo.countryValidChannelList.numOfChannels;
1149 const tANI_U8 *pChannelList = NULL;
1150
1151 if (SME_KR_3 == Revision)
1152 {
1153 pChannelList = KR_3;
1154 *pNumChannels = sizeof(KR_3)/sizeof(KR_3[0]);
1155 }
1156 else if (SME_KR_24 == Revision)
1157 {
1158 pChannelList = KR_24;
1159 *pNumChannels = sizeof(KR_24)/sizeof(KR_24[0]);
1160 }
1161 else if (SME_KR_25 == Revision)
1162 {
1163 pChannelList = KR_25;
1164 *pNumChannels = sizeof(KR_25)/sizeof(KR_25[0]);
1165 }
1166 else
1167 return eHAL_STATUS_INVALID_PARAMETER;
1168
1169 /* Free up the memory first */
1170 if (NULL != pOutChannelList)
1171 {
1172 vos_mem_free(pOutChannelList);
1173 pOutChannelList = NULL;
1174 }
1175
1176 pOutChannelList = vos_mem_malloc(*pNumChannels);
1177
1178 if (NULL == pOutChannelList)
1179 {
1180 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1181 *pNumChannels = 0;
1182 return eHAL_STATUS_RESOURCES;
1183 }
1184
1185 /* Update the roam global structure */
1186 palCopyMemory(pMac->hHdd, pOutChannelList, pChannelList, *pNumChannels);
1187 return status;
1188}
1189
1190#endif
1191
Jeff Johnson295189b2012-06-20 16:38:30 -07001192eHalStatus csrSetBand(tHalHandle hHal, eCsrBand eBand)
1193{
1194 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1195 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001196 if (CSR_IS_PHY_MODE_A_ONLY(pMac) &&
1197 (eBand == eCSR_BAND_24))
1198 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001199 /* DOT11 mode configured to 11a only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001200 request to change the band to 2.4 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001201 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001202 "failed to set band cfg80211 = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001203 pMac->roam.configParam.uCfgDot11Mode, eBand);
1204 return eHAL_STATUS_INVALID_PARAMETER;
1205 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001206 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1207 CSR_IS_PHY_MODE_G_ONLY(pMac)) &&
1208 (eBand == eCSR_BAND_5G))
1209 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001210 /* DOT11 mode configured to 11b/11g only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001211 request to change the band to 5 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001212 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001213 "failed to set band dot11mode = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001214 pMac->roam.configParam.uCfgDot11Mode, eBand);
1215 return eHAL_STATUS_INVALID_PARAMETER;
1216 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001217 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001218 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001219 pMac->roam.configParam.eBand = eBand;
1220 pMac->roam.configParam.bandCapability = eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001221 csrScanGetSupportedChannels( pMac );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001222#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1223 csrUpdateBgScanConfigIniChannelList( pMac, eBand );
1224#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001225 status = csrInitGetChannels( pMac );
1226 if (eHAL_STATUS_SUCCESS == status)
1227 csrInitChannelList( hHal );
1228 return status;
1229}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001230
1231
Jeff Johnsone7245742012-09-05 17:12:55 -07001232/* The funcns csrConvertCBIniValueToPhyCBState and csrConvertPhyCBStateToIniValue have been
1233 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1234 * Ideally we should have kept the ini value and enum value same and representing the same
1235 * cb values as in 11n standard i.e.
1236 * Set to 1 (SCA) if the secondary channel is above the primary channel
1237 * Set to 3 (SCB) if the secondary channel is below the primary channel
1238 * Set to 0 (SCN) if no secondary channel is present
1239 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1240 * 0 - secondary none
1241 * 1 - secondary LOW
1242 * 2 - secondary HIGH
1243 * and convert to enum value used within the driver in csrChangeDefaultConfigParam using this funcn
1244 * The enum values are as follows:
1245 * PHY_SINGLE_CHANNEL_CENTERED = 0
1246 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1247 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1248 */
1249ePhyChanBondState csrConvertCBIniValueToPhyCBState(v_U32_t cbIniValue)
1250{
1251
1252 ePhyChanBondState phyCbState;
1253 switch (cbIniValue) {
1254 // secondary none
1255 case 0:
1256 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1257 break;
1258 // secondary LOW
1259 case 1:
1260 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1261 break;
1262 // secondary HIGH
1263 case 2:
1264 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1265 break;
1266#ifdef WLAN_FEATURE_11AC
1267 case 3:
1268 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
1269 break;
1270 case 4:
1271 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1272 break;
1273 case 5:
1274 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1275 break;
1276 case 6:
1277 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1278 break;
1279 case 7:
1280 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
1281 break;
1282 case 8:
1283 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1284 break;
1285 case 9:
1286 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
1287 break;
1288#endif
1289 default:
1290 // If an invalid value is passed, disable CHANNEL BONDING
1291 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1292 break;
1293 }
1294 return phyCbState;
1295}
1296
1297v_U32_t csrConvertPhyCBStateToIniValue(ePhyChanBondState phyCbState)
1298{
1299
1300 v_U32_t cbIniValue;
1301 switch (phyCbState) {
1302 // secondary none
1303 case PHY_SINGLE_CHANNEL_CENTERED:
1304 cbIniValue = 0;
1305 break;
1306 // secondary LOW
1307 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
1308 cbIniValue = 1;
1309 break;
1310 // secondary HIGH
1311 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
1312 cbIniValue = 2;
1313 break;
1314#ifdef WLAN_FEATURE_11AC
1315 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1316 cbIniValue = 3;
1317 break;
1318 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
1319 cbIniValue = 4;
1320 break;
1321 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1322 cbIniValue = 5;
1323 break;
1324 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
1325 cbIniValue = 6;
1326 break;
1327 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
1328 cbIniValue = 7;
1329 break;
1330 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
1331 cbIniValue = 8;
1332 break;
1333 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
1334 cbIniValue = 9;
1335 break;
1336#endif
1337 default:
1338 // return some invalid value
1339 cbIniValue = 10;
1340 break;
1341 }
1342 return cbIniValue;
1343}
Jeff Johnson295189b2012-06-20 16:38:30 -07001344
1345eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1346{
1347 eHalStatus status = eHAL_STATUS_SUCCESS;
1348
1349 if(pParam)
1350 {
1351 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1352 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1353 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1354 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1355 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1356 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1357
1358 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
Mohit Khanna7ed53f02012-09-11 17:52:10 -07001359 pMac->roam.configParam.fAllowMCCGODiffBI = pParam->fAllowMCCGODiffBI;
1360
Jeff Johnsone7245742012-09-05 17:12:55 -07001361 /* channelBondingMode5GHz plays a dual role right now
1362 * INFRA STA will use this non zero value as CB enabled and SOFTAP will use this non-zero value to determine the secondary channel offset
1363 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1364 */
1365 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
1366 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001367 smsLog( pMac, LOGW, "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED", pParam->channelBondingMode24GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001368 }
1369 pMac->roam.configParam.channelBondingMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode24GHz);
1370 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
1371 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001372 smsLog( pMac, LOGW, "Invalid CB value from ini in 5GHz band %d, CB DISABLED", pParam->channelBondingMode5GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001373 }
1374 pMac->roam.configParam.channelBondingMode5GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001375 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1376 pMac->roam.configParam.phyMode = pParam->phyMode;
1377 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1378 pMac->roam.configParam.HeartbeatThresh24 = pParam->HeartbeatThresh24;
1379 pMac->roam.configParam.HeartbeatThresh50 = pParam->HeartbeatThresh50;
1380 pMac->roam.configParam.ProprietaryRatesEnabled = pParam->ProprietaryRatesEnabled;
1381 pMac->roam.configParam.TxRate = pParam->TxRate;
1382 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1383 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1384 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1385 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1386 pMac->roam.configParam.bgScanInterval = pParam->bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07001387 //if HDD passed down non zero values then only update,
1388 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001389 if (pParam->nActiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001390 {
1391 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
1392 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001393 if (pParam->nActiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001394 {
1395 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
1396 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001397 if (pParam->nPassiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001398 {
1399 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
1400 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001401 if (pParam->nPassiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001402 {
1403 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
1404 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001405 if (pParam->nActiveMaxChnTimeBtc)
1406 {
1407 pMac->roam.configParam.nActiveMaxChnTimeBtc = pParam->nActiveMaxChnTimeBtc;
1408 }
1409 if (pParam->nActiveMinChnTimeBtc)
1410 {
1411 pMac->roam.configParam.nActiveMinChnTimeBtc = pParam->nActiveMinChnTimeBtc;
1412 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001413#ifdef WLAN_AP_STA_CONCURRENCY
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001414 if (pParam->nActiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001415 {
1416 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1417 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001418 if (pParam->nActiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001419 {
1420 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1421 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001422 if (pParam->nPassiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001423 {
1424 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1425 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001426 if (pParam->nPassiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001427 {
1428 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1429 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001430 if (pParam->nRestTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001431 {
1432 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1433 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001434 if (pParam->nNumChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -08001435 {
1436 pMac->roam.configParam.nNumChanCombinedConc = pParam->nNumChanCombinedConc;
1437 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001438#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001439 //if upper layer wants to disable idle scan altogether set it to 0
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001440 if (pParam->impsSleepTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001441 {
1442 //Change the unit from second to microsecond
1443 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001444 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1445 {
1446 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1447 }
1448 else
1449 {
1450 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1451 }
1452 }
1453 else
1454 {
1455 pMac->roam.configParam.impsSleepTime = 0;
1456 }
1457 pMac->roam.configParam.eBand = pParam->eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001458 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1459 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07001460 //if HDD passed down non zero values for age params, then only update,
1461 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001462 if (pParam->nScanResultAgeCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07001463 {
1464 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1465 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001466 if(pParam->scanAgeTimeNCNPS)
1467 {
1468 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1469 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001470 if(pParam->scanAgeTimeNCPS)
1471 {
1472 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1473 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001474 if(pParam->scanAgeTimeCNPS)
1475 {
1476 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1477 }
1478 if(pParam->scanAgeTimeCPS)
1479 {
1480 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1481 }
1482
1483 csrAssignRssiForCategory(pMac, pParam->bCatRssiOffset);
1484 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1485 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1486 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1487 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1488 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001489 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1490 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001491 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1492 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1493 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1494 //Assign this before calling CsrInit11dInfo
1495 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001496 if( csrIs11dSupported( pMac ) )
1497 {
1498 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1499 }
1500 else
1501 {
1502 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1503 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001504
1505 /* Initialize the power + channel information if 11h is enabled.
1506 If 11d is enabled this information has already been initialized */
1507 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1508 {
1509 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1510 }
1511
1512
Jeff Johnson295189b2012-06-20 16:38:30 -07001513#ifdef WLAN_FEATURE_VOWIFI_11R
1514 palCopyMemory( pMac->hHdd, &pMac->roam.configParam.csr11rConfig, &pParam->csr11rConfig, sizeof(tCsr11rConfigParams) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001515 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07001516#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001517#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001518 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001519 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001520 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001521 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d",
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001522 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001523 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Jeff Johnson295189b2012-06-20 16:38:30 -07001524#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001525#ifdef FEATURE_WLAN_LFR
1526 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
1527#endif
1528
Jeff Johnson295189b2012-06-20 16:38:30 -07001529#ifdef FEATURE_WLAN_CCX
1530 pMac->roam.configParam.isCcxIniFeatureEnabled = pParam->isCcxIniFeatureEnabled;
1531#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001532#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1533 palCopyMemory( pMac->hHdd, &pMac->roam.configParam.neighborRoamConfig, &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001534 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
1535 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
1536 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
1537 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
1538 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
1539 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
1540 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
1541 smsLog( pMac, LOG1, "nEmptyScanRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07001542 {
1543 int i;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001544 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07001545 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1546 {
1547 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1548 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001549 smsLog( pMac, LOG1, "");
Jeff Johnson295189b2012-06-20 16:38:30 -07001550 }
1551#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001552 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
1553 pMac->scan.fValidateList = pParam->fValidateList;
1554 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
1555 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08001556 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001557 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001558 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
1559 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
1560 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
1561 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
1562 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
1563 * single session
1564 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001565 //Remove this code once SLM_Sessionization is supported
1566 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07001567 pMac->roam.configParam.doBMPSWorkaround = 0;
1568
Jeff Johnsone7245742012-09-05 17:12:55 -07001569#ifdef WLAN_FEATURE_11AC
1570 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001571 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001572 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Jeff Johnsone7245742012-09-05 17:12:55 -07001573#endif
Madan Mohan Koyyalamudi3f65e312012-11-06 15:31:12 -08001574 pMac->scan.fIgnore_chan165 = pParam->fIgnore_chan165;
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001575 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001576 }
1577
1578 return status;
1579}
1580
Jeff Johnson295189b2012-06-20 16:38:30 -07001581eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1582{
1583 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001584 if(pParam)
1585 {
1586 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
1587 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
1588 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
1589 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
1590 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
1591 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07001592 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
1593 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001594 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
1595 pParam->phyMode = pMac->roam.configParam.phyMode;
1596 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
1597 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
1598 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
1599 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
1600 pParam->TxRate = pMac->roam.configParam.TxRate;
1601 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
1602 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
1603 pParam->bandCapability = pMac->roam.configParam.bandCapability;
1604 pParam->cbChoice = pMac->roam.configParam.cbChoice;
1605 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07001606 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1607 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
1608 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
1609 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001610#ifdef WLAN_AP_STA_CONCURRENCY
1611 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
1612 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
1613 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
1614 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
1615 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08001616 pParam->nNumChanCombinedConc = pMac->roam.configParam.nNumChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001617#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001618 //Change the unit from microsecond to second
1619 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
1620 pParam->eBand = pMac->roam.configParam.eBand;
1621 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
1622 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
1623 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
1624 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
1625 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
1626 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
1627 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
1628 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
1629 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
1630 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
1631 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
1632 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
1633 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001634 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
1635 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
1636 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
1637 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001638 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
1639 pParam->fValidateList = pMac->roam.configParam.fValidateList;
1640 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
1641 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
Madan Mohan Koyyalamudi3f65e312012-11-06 15:31:12 -08001642 pParam->fIgnore_chan165= pMac->scan.fIgnore_chan165;
Jeff Johnson295189b2012-06-20 16:38:30 -07001643 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001644 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08001645 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08001646 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08001647 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001648
1649#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1650 palCopyMemory( pMac->hHdd, &pParam->neighborRoamConfig, &pMac->roam.configParam.neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams) );
1651#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001652#ifdef WLAN_FEATURE_11AC
1653 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001654 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001655 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Jeff Johnsone7245742012-09-05 17:12:55 -07001656#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001657
1658 csrSetChannels(pMac, pParam);
1659
1660 status = eHAL_STATUS_SUCCESS;
1661 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001662 return (status);
1663}
1664
Jeff Johnson295189b2012-06-20 16:38:30 -07001665eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
1666{
1667 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
1668 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1669 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
1670 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001671 do
1672 {
1673 if(eCSR_BAND_24 == eBand)
1674 {
1675 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
1676 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
1677 }
1678 if(eCSR_BAND_5G == eBand)
1679 {
1680 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
1681 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
1682 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
1683 )
1684 {
1685 break;
1686 }
1687 }
1688 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
1689 {
1690 newPhyMode = eCSR_DOT11_MODE_TAURUS;
1691 }
1692 else if(eCSR_DOT11_MODE_AUTO & phyMode)
1693 {
1694 newPhyMode = eCSR_DOT11_MODE_AUTO;
1695 }
1696 else
1697 {
1698 //Check for dual band and higher capability first
1699 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
1700 {
1701 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
1702 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
1703 }
1704 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
1705 {
1706 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
1707 if(eCSR_BAND_24 == eBand) break;
1708 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
1709 eBand = eCSR_BAND_5G;
1710 }
1711 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
1712 {
1713 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
1714 if(eCSR_BAND_5G == eBand) break;
1715 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
1716 eBand = eCSR_BAND_24;
1717 }
1718 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
1719 {
1720 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
1721 if(eCSR_BAND_5G == eBand) break;
1722 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
1723 eBand = eCSR_BAND_24;
1724 }
1725 else if(eCSR_DOT11_MODE_11n & phyMode)
1726 {
1727 newPhyMode = eCSR_DOT11_MODE_11n;
1728 }
1729 else if(eCSR_DOT11_MODE_abg & phyMode)
1730 {
1731 newPhyMode = eCSR_DOT11_MODE_abg;
1732 }
1733 else if(eCSR_DOT11_MODE_11a & phyMode)
1734 {
1735 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
1736 {
1737 if(eCSR_BAND_ALL == eBand)
1738 {
1739 newPhyMode = eCSR_DOT11_MODE_abg;
1740 }
1741 else
1742 {
1743 //bad setting
1744 break;
1745 }
1746 }
1747 else
1748 {
1749 newPhyMode = eCSR_DOT11_MODE_11a;
1750 eBand = eCSR_BAND_5G;
1751 }
1752 }
1753 else if(eCSR_DOT11_MODE_11g & phyMode)
1754 {
1755 newPhyMode = eCSR_DOT11_MODE_11g;
1756 eBand = eCSR_BAND_24;
1757 }
1758 else if(eCSR_DOT11_MODE_11b & phyMode)
1759 {
1760 newPhyMode = eCSR_DOT11_MODE_11b;
1761 eBand = eCSR_BAND_24;
1762 }
1763 else
1764 {
1765 //We will never be here
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001766 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X"), phyMode );
Jeff Johnson295189b2012-06-20 16:38:30 -07001767 newPhyMode = eCSR_DOT11_MODE_AUTO;
1768 }
1769 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001770 //Done validating
1771 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001772 //Now we need to check whether a restart is needed.
1773 if(eBand != pMac->roam.configParam.eBand)
1774 {
1775 fRestartNeeded = eANI_BOOLEAN_TRUE;
1776 break;
1777 }
1778 if(newPhyMode != pMac->roam.configParam.phyMode)
1779 {
1780 fRestartNeeded = eANI_BOOLEAN_TRUE;
1781 break;
1782 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001783 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001784 if(HAL_STATUS_SUCCESS(status))
1785 {
1786 pMac->roam.configParam.eBand = eBand;
1787 pMac->roam.configParam.phyMode = newPhyMode;
1788 if(pfRestartNeeded)
1789 {
1790 *pfRestartNeeded = fRestartNeeded;
1791 }
1792 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001793 return (status);
1794}
1795
Jeff Johnson295189b2012-06-20 16:38:30 -07001796void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
1797{
1798 tANI_U8 Index;
1799 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07001800 // for dual band NICs, don't need to trim the channel list....
1801 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
1802 {
1803 // 2.4 GHz band operation requires the channel list to be trimmed to
1804 // the 2.4 GHz channels only...
1805 if ( CSR_IS_24_BAND_ONLY( pMac ) )
1806 {
1807 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
1808 Index++ )
1809 {
1810 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
1811 {
1812 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
1813 cChannels++;
1814 }
1815 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001816 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
1817 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
1818 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
1819 // only if we need to.
1820 //
1821 // The amount of memory to clear is the number of channesl that we trimmed
1822 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
1823
1824 if ( pChannelList->numChannels > cChannels )
1825 {
1826 palZeroMemory( pMac->hHdd, &pChannelList->channelList[ cChannels ],
1827 sizeof( pChannelList->channelList[ 0 ] ) * ( pChannelList->numChannels - cChannels ) );
1828
1829 }
1830
1831 pChannelList->numChannels = cChannels;
1832 }
1833 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
1834 {
1835 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
1836 {
1837 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
1838 {
1839 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
1840 cChannels++;
1841 }
1842 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001843 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
1844 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
1845 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
1846 // only if we need to.
1847 //
1848 // The amount of memory to clear is the number of channesl that we trimmed
1849 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
1850 if ( pChannelList->numChannels > cChannels )
1851 {
1852 palZeroMemory( pMac->hHdd, &pChannelList->channelList[ cChannels ],
1853 sizeof( pChannelList->channelList[ 0 ] ) * ( pChannelList->numChannels - cChannels ) );
1854 }
1855
1856 pChannelList->numChannels = cChannels;
1857 }
1858 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001859}
Jeff Johnson295189b2012-06-20 16:38:30 -07001860#define INFRA_AP_DEFAULT_CHANNEL 6
1861eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
1862{
1863 tANI_U8 index= 0;
1864 eHalStatus status = eHAL_STATUS_FAILURE;
1865 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
1866 {
1867 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
1868 status = eHAL_STATUS_SUCCESS;
1869 break;
1870 }
1871 }
1872 return status;
1873}
Jeff Johnson295189b2012-06-20 16:38:30 -07001874eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
1875{
1876 eHalStatus status = eHAL_STATUS_SUCCESS;
1877 tANI_U8 num20MHzChannelsFound = 0;
1878 VOS_STATUS vosStatus;
1879 tANI_U8 Index = 0;
1880 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001881
Jeff Johnson295189b2012-06-20 16:38:30 -07001882
1883 //TODO: this interface changed to include the 40MHz channel list
1884 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
1885 // Read the scan channel list (including the power limit) from EEPROM
1886 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
1887 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
1888 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
1889 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001890 smsLog( pMac, LOGE, FL("failed to get channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07001891 status = eHAL_STATUS_FAILURE;
1892 }
1893 else
1894 {
1895 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
1896 {
1897 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1898 }
1899 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
1900 // Move the channel list to the global data
1901 // structure -- this will be used as the scan list
1902 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
1903 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001904 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07001905 }
1906 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
1907 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
1908 {
1909 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1910 }
1911 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
1912 {
1913 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
1914 }
1915 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
1916 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001917 return (status);
1918}
1919
Jeff Johnson295189b2012-06-20 16:38:30 -07001920eHalStatus csrInitChannelList( tHalHandle hHal )
1921{
1922 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1923 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001924 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
1925 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08001926 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
1927 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001928 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08001929 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07001930
1931 return (status);
1932}
Jeff Johnson295189b2012-06-20 16:38:30 -07001933eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
1934 tCsrUpdateConfigParam *pUpdateConfigParam)
1935{
1936 eHalStatus status = eHAL_STATUS_FAILURE;
1937 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001938 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
1939 status = CsrInit11dInfo(pMac, ps11dinfo);
1940 return status;
1941}
1942
Jeff Johnson295189b2012-06-20 16:38:30 -07001943static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
1944{
1945 eHalStatus status = eHAL_STATUS_FAILURE;
1946 tANI_U8 index;
1947 tANI_U32 count=0;
1948 tSirMacChanInfo *pChanInfo;
1949 tSirMacChanInfo *pChanInfoStart;
1950 tANI_BOOLEAN applyConfig = TRUE;
1951
1952 if(!ps11dinfo)
1953 {
1954 return (status);
1955 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001956 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
1957 {
1958 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
1959 status = palCopyMemory(pMac->hHdd, pMac->scan.base20MHzChannels.channelList,
1960 ps11dinfo->Channels.channelList, ps11dinfo->Channels.numChannels);
1961 if(!HAL_STATUS_SUCCESS(status)) return (status);
1962 }
1963 else
1964 {
1965 //No change
1966 return (eHAL_STATUS_SUCCESS);
1967 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001968 //legacy maintenance
1969 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeDefault,
1970 ps11dinfo->countryCode, WNI_CFG_COUNTRY_CODE_LEN);
1971 if(!HAL_STATUS_SUCCESS(status)) return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001972 //Tush: at csropen get this initialized with default, during csr reset if this
1973 // already set with some value no need initilaize with default again
1974 if(0 == pMac->scan.countryCodeCurrent[0])
1975 {
1976 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent,
1977 ps11dinfo->countryCode, WNI_CFG_COUNTRY_CODE_LEN);
1978 if(!HAL_STATUS_SUCCESS(status)) return (status);
1979 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001980 // need to add the max power channel list
1981 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN)))
1982 {
1983 palZeroMemory(pMac->hHdd, pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
1984 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07001985 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
1986 {
1987 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
1988 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
1989 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
1990 pChanInfo++;
1991 count++;
1992 }
1993 if(count)
1994 {
1995 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
1996 }
1997 palFreeMemory(pMac->hHdd, pChanInfoStart);
1998 }
1999 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2000 if( HAL_STATUS_SUCCESS(status) )
2001 {
2002 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2003 {
2004 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2005 {
2006 applyConfig = FALSE;
2007 }
2008 }
2009
2010 if(TRUE == applyConfig)
2011 {
2012 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002013 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002014 }
2015
2016 }
2017 return (status);
2018}
2019/* Initialize the Channel + Power List in the local cache and in the CFG */
2020eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2021{
2022 tANI_U8 index;
2023 tANI_U32 count=0;
2024 tSirMacChanInfo *pChanInfo;
2025 tSirMacChanInfo *pChanInfoStart;
2026
2027 if(!ps11dinfo || !pMac)
2028 {
2029 return eHAL_STATUS_FAILURE;
2030 }
2031
2032 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN)))
2033 {
2034 palZeroMemory(pMac->hHdd, pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2035 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002036
2037 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2038 {
2039 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2040 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2041 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2042 pChanInfo++;
2043 count++;
2044 }
2045 if(count)
2046 {
2047 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2048 }
2049 palFreeMemory(pMac->hHdd, pChanInfoStart);
2050 }
2051
Jeff Johnsone7245742012-09-05 17:12:55 -07002052 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002053}
2054
2055//pCommand may be NULL
2056//Pass in sessionId in case pCommand is NULL. sessionId is not used in case pCommand is not NULL.
2057void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac, tANI_U32 sessionId, tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
2058{
2059 tListElem *pEntry, *pNextEntry;
2060 tSmeCmd *pDupCommand;
2061 tDblLinkList localList;
2062
2063 vos_mem_zero(&localList, sizeof(tDblLinkList));
2064 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
2065 {
2066 smsLog(pMac, LOGE, FL(" failed to open list"));
2067 return;
2068 }
2069 csrLLLock( &pMac->sme.smeCmdPendingList );
2070 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
2071 while( pEntry )
2072 {
2073 pNextEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
2074 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07002075 // Remove the previous command if..
2076 // - the new roam command is for the same RoamReason...
2077 // - the new roam command is a NewProfileList.
2078 // - the new roam command is a Forced Dissoc
2079 // - the new roam command is from an 802.11 OID (OID_SSID or OID_BSSID).
2080 if (
2081 (pCommand && ( pCommand->sessionId == pDupCommand->sessionId ) &&
2082 ((pCommand->command == pDupCommand->command) &&
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002083 /* This peermac check is requried for Softap/GO scenarios
2084 * For STA scenario below OR check will suffice as pCommand will
2085 * always be NULL for STA scenarios
2086 */
2087 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac, pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002088 (pCommand->u.roamCmd.roamReason == pDupCommand->u.roamCmd.roamReason ||
2089 eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason ||
2090 eCsrHddIssued == pCommand->u.roamCmd.roamReason)))
2091 ||
2092 //below the pCommand is NULL
Jeff Johnson43971f52012-07-17 12:26:56 -07002093 ( (sessionId == pDupCommand->sessionId) &&
2094 (eSmeCommandRoam == pDupCommand->command) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002095 ((eCsrForcedDisassoc == eRoamReason) ||
2096 (eCsrHddIssued == eRoamReason))
2097 )
2098 )
2099 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002100 smsLog(pMac, LOGW, FL(" roamReason = %d"), pDupCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07002101 // Remove the 'stale' roam command from the pending list...
2102 if(csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK ))
2103 {
2104 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
2105 }
2106 }
2107 pEntry = pNextEntry;
2108 }
2109 csrLLUnlock( &pMac->sme.smeCmdPendingList );
2110
2111 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
2112 {
2113 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
2114 //Tell caller that the command is cancelled
2115 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL, pDupCommand->u.roamCmd.roamId,
2116 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
2117 csrReleaseCommandRoam(pMac, pDupCommand);
2118 }
2119 csrLLClose(&localList);
2120}
Jeff Johnson295189b2012-06-20 16:38:30 -07002121eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2122 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2123{
2124 eHalStatus status = eHAL_STATUS_SUCCESS;
2125#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2126 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2127#endif
2128 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07002129 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2130 {
2131 pSession = CSR_GET_SESSION( pMac, sessionId );
2132 }
2133 else
2134 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002135 smsLog(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002136 VOS_ASSERT(0);
2137 return eHAL_STATUS_FAILURE;
2138 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002139 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
2140 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002141 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002142 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002143 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2144 /*
2145 * Decrement bRefAssocStartCnt for FT reassoc failure.
2146 * Reason: For FT reassoc failures, we first call
2147 * csrRoamCallCallback before notifying a failed roam
2148 * completion through csrRoamComplete. The latter in
2149 * turn calls csrRoamProcessResults which tries to
2150 * once again call csrRoamCallCallback if bRefAssocStartCnt
2151 * is non-zero. Since this is redundant for FT reassoc
2152 * failure, decrement bRefAssocStartCnt.
2153 */
2154 pSession->bRefAssocStartCnt--;
2155 }
2156
Jeff Johnson295189b2012-06-20 16:38:30 -07002157 if ( (pSession == NULL) ||
2158 (eANI_BOOLEAN_FALSE == pSession->sessionActive) )
2159 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002160 smsLog(pMac, LOG1, "Session ID is not valid");
Jeff Johnson295189b2012-06-20 16:38:30 -07002161 return eHAL_STATUS_FAILURE;
2162 }
2163
2164 if(NULL != pSession->callback)
2165 {
2166 if( pRoamInfo )
2167 {
2168 pRoamInfo->sessionId = (tANI_U8)sessionId;
2169 }
2170
2171 /* avoid holding the global lock when making the roaming callback , original change came
2172 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2173 is possible on other OS ports where the callback may need to take locks to protect
2174 HDD state
2175 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2176 that may actually depend on the lock being held */
2177 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2178 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2179 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2180 }
2181 //EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
2182 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
2183#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2184 palZeroMemory(pMac->hHdd, &connectionStatus, sizeof(vos_event_wlan_status_payload_type));
2185 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2))
2186 {
2187 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2188 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2189 if(NULL != pRoamInfo->pBssDesc)
2190 {
2191 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2192 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2193 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002194 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2195 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2196 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
2197 palCopyMemory(pMac->hHdd, connectionStatus.ssid, pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
2198 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
2199 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2200 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002201 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2202 {
2203 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2204 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
2205 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2206 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002207 if(eCSR_ROAM_RESULT_FORCED == u2)
2208 {
2209 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2210 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
2211 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2212 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002213 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2214 {
2215 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2216 connectionStatus.reason = eCSR_REASON_DISASSOC;
2217 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2218 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002219 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2220 {
2221 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2222 connectionStatus.reason = eCSR_REASON_DEAUTH;
2223 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2224 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002225#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2226
2227 return (status);
2228}
Jeff Johnson295189b2012-06-20 16:38:30 -07002229// Returns whether handoff is currently in progress or not
2230tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2231{
2232#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2233 return csrNeighborRoamIsHandoffInProgress(pMac);
2234#else
2235 return eANI_BOOLEAN_FALSE;
2236#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002237}
Jeff Johnson295189b2012-06-20 16:38:30 -07002238eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2239 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2240{
2241 eHalStatus status = eHAL_STATUS_SUCCESS;
2242 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2243 tANI_U16 reasonCode;
2244 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002245
2246 if(!pSession)
2247 {
2248 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2249 return eHAL_STATUS_FAILURE;
2250 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002251
2252 //Restore AC weight in case we change it
2253 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2254 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002255 smsLog(pMac, LOG1, FL(" restore AC weights (%d-%d-%d-%d)"), pMac->roam.ucACWeights[0], pMac->roam.ucACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07002256 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2257 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2258 }
2259
2260 if ( fMICFailure )
2261 {
2262 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2263 }
2264 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2265 {
2266 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002267 }
2268 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002269 {
2270 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2271 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002272#ifdef WLAN_FEATURE_VOWIFI_11R
2273 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2274 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2275 {
2276 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2277 palCopyMemory(pMac->hHdd, &bssId, pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid, sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002278 }
2279 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002280#endif
2281 if(pSession->pConnectBssDesc)
2282 {
2283 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2284 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002285
Jeff Johnson295189b2012-06-20 16:38:30 -07002286
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002287 smsLog( pMac, LOG2, "CSR Attempting to Disassociate Bssid=%02x-%02x-%02x-%02x-%02x-%02x"
2288 "subState = %d reason=%d", bssId[ 0 ], bssId[ 1 ], bssId[ 2 ], bssId[ 3 ],
2289 bssId[ 4 ], bssId[ 5 ], NewSubstate, reasonCode);
2290
Jeff Johnson295189b2012-06-20 16:38:30 -07002291 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2292
2293 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2294
2295 if(HAL_STATUS_SUCCESS(status))
2296 {
2297 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002298#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2299 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2300 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2301 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002302 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07002303 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
2304 }
2305#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002306 }
2307 else
2308 {
2309 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
2310 }
2311
Jeff Johnson295189b2012-06-20 16:38:30 -07002312 return (status);
2313}
Jeff Johnson295189b2012-06-20 16:38:30 -07002314
Jeff Johnson295189b2012-06-20 16:38:30 -07002315/* ---------------------------------------------------------------------------
2316 \fn csrRoamIssueDisassociateStaCmd
2317 \brief csr function that HDD calls to disassociate a associated station
2318 \param sessionId - session Id for Soft AP
2319 \param pPeerMacAddr - MAC of associated station to delete
2320 \param reason - reason code, be one of the tSirMacReasonCodes
2321 \return eHalStatus
2322 ---------------------------------------------------------------------------*/
2323eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
2324 tANI_U32 sessionId,
2325 tANI_U8 *pPeerMacAddr,
2326 tANI_U32 reason)
2327{
2328 eHalStatus status = eHAL_STATUS_SUCCESS;
2329 tSmeCmd *pCommand;
2330
2331 do
2332 {
2333 pCommand = csrGetCommandBuffer( pMac );
2334 if ( !pCommand )
2335 {
2336 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2337 status = eHAL_STATUS_RESOURCES;
2338 break;
2339 }
2340 pCommand->command = eSmeCommandRoam;
2341 pCommand->sessionId = (tANI_U8)sessionId;
2342 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
2343 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2344 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2345 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2346 if( !HAL_STATUS_SUCCESS( status ) )
2347 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002348 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002349 csrReleaseCommandRoam( pMac, pCommand );
2350 }
2351 }while(0);
2352
2353 return status;
2354}
2355
2356
Jeff Johnson295189b2012-06-20 16:38:30 -07002357/* ---------------------------------------------------------------------------
2358 \fn csrRoamIssueDeauthSta
2359 \brief csr function that HDD calls to delete a associated station
2360 \param sessionId - session Id for Soft AP
2361 \param pPeerMacAddr - MAC of associated station to delete
2362 \param reason - reason code, be one of the tSirMacReasonCodes
2363 \return eHalStatus
2364 ---------------------------------------------------------------------------*/
2365eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
2366 tANI_U32 sessionId,
2367 tANI_U8 *pPeerMacAddr,
2368 tANI_U32 reason)
2369{
2370 eHalStatus status = eHAL_STATUS_SUCCESS;
2371 tSmeCmd *pCommand;
2372
2373 do
2374 {
2375 pCommand = csrGetCommandBuffer( pMac );
2376 if ( !pCommand )
2377 {
2378 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2379 status = eHAL_STATUS_RESOURCES;
2380 break;
2381 }
2382 pCommand->command = eSmeCommandRoam;
2383 pCommand->sessionId = (tANI_U8)sessionId;
2384 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
2385 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2386 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2387 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2388 if( !HAL_STATUS_SUCCESS( status ) )
2389 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002390 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002391 csrReleaseCommandRoam( pMac, pCommand );
2392 }
2393 }while(0);
2394
2395 return status;
2396}
Jeff Johnson295189b2012-06-20 16:38:30 -07002397eHalStatus
2398csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
2399 tANI_BOOLEAN bEnable )
2400{
2401 eHalStatus status = eHAL_STATUS_FAILURE;
2402 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2403 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002404 if (!pSession)
2405 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002406 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002407 return (status);
2408 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002409 if (pSession->pConnectBssDesc)
2410 {
2411 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2412 }
2413 else
2414 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002415 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002416 return (status);
2417 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002418 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = %02x-%02x-%02x-%02x-%02x-%02x, Enable = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002419 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2420 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] , bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002421 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
2422 return (status);
2423}
Jeff Johnson295189b2012-06-20 16:38:30 -07002424eHalStatus
2425csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
2426 VOS_MODULE_ID modId, void *pUsrContext,
2427 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
2428{
2429 eHalStatus status = eHAL_STATUS_SUCCESS;
2430 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2431 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002432 if (!pSession)
2433 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002434 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002435 return (status);
2436 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002437 if(pSession->pConnectBssDesc)
2438 {
2439 palCopyMemory( pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid) );
2440 }
2441 else
2442 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002443 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002444 return (status);
2445 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002446 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07002447 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2448 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002449 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2450 return (status);
2451}
Jeff Johnson295189b2012-06-20 16:38:30 -07002452eHalStatus
2453csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
2454 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
2455{
2456 eHalStatus status = eHAL_STATUS_SUCCESS;
2457 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2458 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2459
2460 if (!pSession)
2461 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002462 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002463 return (status);
2464 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002465 if(pSession->pConnectBssDesc)
2466 {
2467 palCopyMemory( pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid) );
2468 }
2469 else
2470 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002471 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002472 return (status);
2473 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002474 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07002475 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2476 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
2477
2478 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2479
2480 return (status);
2481}
Jeff Johnson295189b2012-06-20 16:38:30 -07002482eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
2483{
2484 eHalStatus status = eHAL_STATUS_SUCCESS;
2485 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2486 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002487
2488 if (!pSession)
2489 {
2490 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2491 return eHAL_STATUS_FAILURE;
2492 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002493
2494 if(pSession->pConnectBssDesc)
2495 {
2496 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2497 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002498 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07002499 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2500 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002501 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2502
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302503 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002504 if(!HAL_STATUS_SUCCESS(status))
2505 {
2506 smsLog(pMac, LOGW, FL("csrSendMBDeauthReqMsg failed with status %d"), status);
2507 }
2508
Jeff Johnson295189b2012-06-20 16:38:30 -07002509 return (status);
2510}
2511
Jeff Johnson295189b2012-06-20 16:38:30 -07002512eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
2513{
2514 eHalStatus status = eHAL_STATUS_SUCCESS;
2515 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2516 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002517
2518 if(!pSession)
2519 {
2520 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2521 return eHAL_STATUS_FAILURE;
2522 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002523
2524 // If no BSS description was found in this connection (happens with start IBSS), then
2525 // nix the BSS description that we keep around for the connected BSS) and get out...
2526 if(NULL == pBssDesc)
2527 {
2528 csrFreeConnectBssDesc(pMac, sessionId);
2529 }
2530 else
2531 {
2532 size = pBssDesc->length + sizeof( pBssDesc->length );
2533 if(NULL != pSession->pConnectBssDesc)
2534 {
2535 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
2536 {
2537 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
2538 csrFreeConnectBssDesc(pMac, sessionId);
2539 }
2540 }
2541 if(NULL == pSession->pConnectBssDesc)
2542 {
2543 status = palAllocateMemory( pMac->hHdd, (void **)&pSession->pConnectBssDesc, size);
2544 }
2545 if ( HAL_STATUS_SUCCESS(status) && pSession->pConnectBssDesc )
2546 {
2547 palCopyMemory( pMac->hHdd, pSession->pConnectBssDesc, pBssDesc, size );
2548 }
2549 }
2550
2551 return (status);
2552}
2553
Jeff Johnson295189b2012-06-20 16:38:30 -07002554eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2555 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
2556 tDot11fBeaconIEs *pIes)
2557{
2558 eHalStatus status = eHAL_STATUS_SUCCESS;
2559 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002560 VOS_ASSERT( pIes != NULL );
Jeff Johnsone7245742012-09-05 17:12:55 -07002561
Jeff Johnson295189b2012-06-20 16:38:30 -07002562 do
2563 {
2564 palCopyMemory(pMac->hHdd, &pBssConfig->BssCap, &pBssDesc->capabilityInfo, sizeof(tSirMacCapabilityInfo));
2565 //get qos
2566 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
2567 //get SSID
2568 if(pIes->SSID.present)
2569 {
2570 palCopyMemory(pMac->hHdd, &pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
2571 pBssConfig->SSID.length = pIes->SSID.num_ssid;
2572 }
2573 else
2574 pBssConfig->SSID.length = 0;
2575 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
2576 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002577 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07002578 //Return failed if profile doesn't have an SSID either.
2579 if(pProfile->SSIDs.numOfSSIDs == 0)
2580 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002581 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07002582 status = eHAL_STATUS_FAILURE;
2583 break;
2584 }
2585 }
2586 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
2587 {
2588 pBssConfig->eBand = eCSR_BAND_5G;
2589 }
2590 else
2591 {
2592 pBssConfig->eBand = eCSR_BAND_24;
2593 }
2594 //phymode
2595 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
2596 {
2597 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
2598 }
2599 else
2600 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002601 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07002602 //force it
2603 if(eCSR_BAND_24 == pBssConfig->eBand)
2604 {
2605 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2606 }
2607 else
2608 {
2609 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2610 }
2611 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002612 //Qos
2613 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
2614 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
2615 {
2616 //Joining BSS is not 11n capable and WMM is disabled on client.
2617 //Disable QoS and WMM
2618 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2619 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302620
2621 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05302622 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302623 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
2624 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
2625 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
2626 {
2627 //Joining BSS is 11n capable and WMM is disabled on AP.
2628 //Assume all HT AP's are QOS AP's and enable WMM
2629 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2630 }
2631
Jeff Johnson295189b2012-06-20 16:38:30 -07002632 //auth type
2633 switch( pProfile->negotiatedAuthType )
2634 {
2635 default:
2636 case eCSR_AUTH_TYPE_WPA:
2637 case eCSR_AUTH_TYPE_WPA_PSK:
2638 case eCSR_AUTH_TYPE_WPA_NONE:
2639 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2640 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2641 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002642 case eCSR_AUTH_TYPE_SHARED_KEY:
2643 pBssConfig->authType = eSIR_SHARED_KEY;
2644 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002645 case eCSR_AUTH_TYPE_AUTOSWITCH:
2646 pBssConfig->authType = eSIR_AUTO_SWITCH;
2647 break;
2648 }
2649 //short slot time
2650 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
2651 {
2652 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2653 }
2654 else
2655 {
2656 pBssConfig->uShortSlotTime = 0;
2657 }
2658 if(pBssConfig->BssCap.ibss)
2659 {
2660 //We don't support 11h on IBSS
2661 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2662 }
2663 else
2664 {
2665 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
2666 }
2667 //power constraint
2668 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
2669 //heartbeat
2670 if ( CSR_IS_11A_BSS( pBssDesc ) )
2671 {
2672 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2673 }
2674 else
2675 {
2676 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2677 }
2678 //Join timeout
2679 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07002680 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07002681 if ( pBssDesc->beaconInterval )
2682 {
2683 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07002684 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002685 }
2686 else
2687 {
2688 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
2689 }
2690 //validate CB
2691 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
2692 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002693 return (status);
2694}
2695
Jeff Johnson295189b2012-06-20 16:38:30 -07002696static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2697 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
2698{
2699 eHalStatus status = eHAL_STATUS_SUCCESS;
2700 tANI_U8 operationChannel = 0;
2701 tANI_U8 qAPisEnabled = FALSE;
2702 //SSID
2703 pBssConfig->SSID.length = 0;
2704 if(pProfile->SSIDs.numOfSSIDs)
2705 {
2706 //only use the first one
2707 palCopyMemory(pMac->hHdd, &pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID, sizeof(tSirMacSSid));
2708 }
2709 else
2710 {
2711 //SSID must present
2712 return eHAL_STATUS_FAILURE;
2713 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002714 //Settomg up the capabilities
2715 if( csrIsBssTypeIBSS(pProfile->BSSType) )
2716 {
2717 pBssConfig->BssCap.ibss = 1;
2718 }
2719 else
2720 {
2721 pBssConfig->BssCap.ess = 1;
2722 }
2723 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
2724 {
2725 pBssConfig->BssCap.privacy = 1;
2726 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002727 pBssConfig->eBand = pMac->roam.configParam.eBand;
2728 //phymode
2729 if(pProfile->ChannelInfo.ChannelList)
2730 {
2731 operationChannel = pProfile->ChannelInfo.ChannelList[0];
2732 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002733 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
2734 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07002735 //QOS
2736 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07002737 if ( pBssConfig->BssCap.ess == 1 )
2738 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002739 /*For Softap case enable WMM*/
2740 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
2741 qAPisEnabled = TRUE;
2742 }
2743 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002744 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
2745 qAPisEnabled = TRUE;
2746 } else {
2747 qAPisEnabled = FALSE;
2748 }
2749 } else {
2750 qAPisEnabled = TRUE;
2751 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002752 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
2753 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
2754 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
2755 )
2756 {
2757 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2758 } else {
2759 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2760 }
2761
2762 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08002763 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07002764 {
2765 default:
2766 case eCSR_AUTH_TYPE_WPA:
2767 case eCSR_AUTH_TYPE_WPA_PSK:
2768 case eCSR_AUTH_TYPE_WPA_NONE:
2769 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2770 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2771 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002772 case eCSR_AUTH_TYPE_SHARED_KEY:
2773 pBssConfig->authType = eSIR_SHARED_KEY;
2774 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002775 case eCSR_AUTH_TYPE_AUTOSWITCH:
2776 pBssConfig->authType = eSIR_AUTO_SWITCH;
2777 break;
2778 }
2779 //short slot time
2780 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
2781 {
2782 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2783 }
2784 else
2785 {
2786 pBssConfig->uShortSlotTime = 0;
2787 }
2788 //power constraint. We don't support 11h on IBSS
2789 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2790 pBssConfig->uPowerLimit = 0;
2791 //heartbeat
2792 if ( eCSR_BAND_5G == pBssConfig->eBand )
2793 {
2794 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2795 }
2796 else
2797 {
2798 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2799 }
2800 //Join timeout
2801 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07002802
Jeff Johnson295189b2012-06-20 16:38:30 -07002803 return (status);
2804}
Jeff Johnson295189b2012-06-20 16:38:30 -07002805static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
2806{
2807 eHalStatus status = eHAL_STATUS_FAILURE;
2808 tDot11fBeaconIEs *pIes = NULL;
2809
2810 do
2811 {
2812 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
2813 {
2814 //err msg
2815 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002816 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07002817 break;
2818 }
2819 //check if the AP is QAP & it supports APSD
2820 if( CSR_IS_QOS_BSS(pIes) )
2821 {
2822 return eHAL_STATUS_SUCCESS;
2823 }
2824 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002825 return status;
2826}
2827
Jeff Johnson295189b2012-06-20 16:38:30 -07002828void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
2829{
Jeff Johnson295189b2012-06-20 16:38:30 -07002830 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
2831 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
2832 // See !!Note: below in this function...
2833 tANI_U32 PrivacyEnabled = 0;
2834 tANI_U32 RsnEnabled = 0;
2835 tANI_U32 WepDefaultKeyId = 0;
2836 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
2837 tANI_U32 Key0Length = 0;
2838 tANI_U32 Key1Length = 0;
2839 tANI_U32 Key2Length = 0;
2840 tANI_U32 Key3Length = 0;
2841
2842 // Reserve for the biggest key
2843 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
2844 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
2845 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
2846 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
2847
2848 switch ( pProfile->negotiatedUCEncryptionType )
2849 {
2850 case eCSR_ENCRYPT_TYPE_NONE:
2851
2852 // for NO encryption, turn off Privacy and Rsn.
2853 PrivacyEnabled = 0;
2854 RsnEnabled = 0;
2855
2856 // WEP key length and Wep Default Key ID don't matter in this case....
2857
2858 // clear out the WEP keys that may be hanging around.
2859 Key0Length = 0;
2860 Key1Length = 0;
2861 Key2Length = 0;
2862 Key3Length = 0;
2863
2864 break;
2865
2866 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
2867
2868 // Privacy is ON. NO RSN for Wep40 static key.
2869 PrivacyEnabled = 1;
2870 RsnEnabled = 0;
2871
2872 // Set the Wep default key ID.
2873 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07002874 // Wep key size if 5 bytes (40 bits).
2875 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
2876
2877 // set encryption keys in the CFG database or clear those that are not present in this profile.
2878 if ( pProfile->Keys.KeyLength[0] )
2879 {
2880 palCopyMemory( pMac->hHdd, Key0, pProfile->Keys.KeyMaterial[0], WNI_CFG_WEP_KEY_LENGTH_5 );
2881 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
2882 }
2883 else
2884 {
2885 Key0Length = 0;
2886 }
2887
2888 if ( pProfile->Keys.KeyLength[1] )
2889 {
2890 palCopyMemory( pMac->hHdd, Key1, pProfile->Keys.KeyMaterial[1], WNI_CFG_WEP_KEY_LENGTH_5 );
2891 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
2892 }
2893 else
2894 {
2895 Key1Length = 0;
2896 }
2897
2898 if ( pProfile->Keys.KeyLength[2] )
2899 {
2900 palCopyMemory( pMac->hHdd, Key2, pProfile->Keys.KeyMaterial[2], WNI_CFG_WEP_KEY_LENGTH_5 );
2901 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
2902 }
2903 else
2904 {
2905 Key2Length = 0;
2906 }
2907
2908 if ( pProfile->Keys.KeyLength[3] )
2909 {
2910 palCopyMemory( pMac->hHdd, Key3, pProfile->Keys.KeyMaterial[3], WNI_CFG_WEP_KEY_LENGTH_5 );
2911 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
2912 }
2913 else
2914 {
2915 Key3Length = 0;
2916 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002917 break;
2918
2919 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
2920
2921 // Privacy is ON. NO RSN for Wep40 static key.
2922 PrivacyEnabled = 1;
2923 RsnEnabled = 0;
2924
2925 // Set the Wep default key ID.
2926 WepDefaultKeyId = pProfile->Keys.defaultIndex;
2927
2928 // Wep key size if 13 bytes (104 bits).
2929 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
2930
2931 // set encryption keys in the CFG database or clear those that are not present in this profile.
2932 if ( pProfile->Keys.KeyLength[0] )
2933 {
2934 palCopyMemory( pMac->hHdd, Key0, pProfile->Keys.KeyMaterial[ 0 ], WNI_CFG_WEP_KEY_LENGTH_13 );
2935 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
2936 }
2937 else
2938 {
2939 Key0Length = 0;
2940 }
2941
2942 if ( pProfile->Keys.KeyLength[1] )
2943 {
2944 palCopyMemory( pMac->hHdd, Key1, pProfile->Keys.KeyMaterial[ 1 ], WNI_CFG_WEP_KEY_LENGTH_13 );
2945 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
2946 }
2947 else
2948 {
2949 Key1Length = 0;
2950 }
2951
2952 if ( pProfile->Keys.KeyLength[2] )
2953 {
2954 palCopyMemory( pMac->hHdd, Key2, pProfile->Keys.KeyMaterial[ 2 ], WNI_CFG_WEP_KEY_LENGTH_13 );
2955 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
2956 }
2957 else
2958 {
2959 Key2Length = 0;
2960 }
2961
2962 if ( pProfile->Keys.KeyLength[3] )
2963 {
2964 palCopyMemory( pMac->hHdd, Key3, pProfile->Keys.KeyMaterial[ 3 ], WNI_CFG_WEP_KEY_LENGTH_13 );
2965 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
2966 }
2967 else
2968 {
2969 Key3Length = 0;
2970 }
2971
2972 break;
2973
2974 case eCSR_ENCRYPT_TYPE_WEP40:
2975 case eCSR_ENCRYPT_TYPE_WEP104:
2976 case eCSR_ENCRYPT_TYPE_TKIP:
2977 case eCSR_ENCRYPT_TYPE_AES:
2978#ifdef FEATURE_WLAN_WAPI
2979 case eCSR_ENCRYPT_TYPE_WPI:
2980#endif /* FEATURE_WLAN_WAPI */
2981 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
2982 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
2983 PrivacyEnabled = (0 != fPrivacy);
2984
2985 // turn on RSN enabled for WPA associations
2986 RsnEnabled = 1;
2987
2988 // WEP key length and Wep Default Key ID don't matter in this case....
2989
2990 // clear out the static WEP keys that may be hanging around.
2991 Key0Length = 0;
2992 Key1Length = 0;
2993 Key2Length = 0;
2994 Key3Length = 0;
2995
2996 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002997 default:
2998 PrivacyEnabled = 0;
2999 RsnEnabled = 0;
3000 break;
3001 }
3002
3003 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3004 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3005 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3006 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3007 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3008 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3009 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3010 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3011}
3012
Jeff Johnson295189b2012-06-20 16:38:30 -07003013static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3014{
3015 tANI_U32 len = 0;
3016 if(pSSID->length <= WNI_CFG_SSID_LEN)
3017 {
3018 len = pSSID->length;
3019 }
3020 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3021}
3022
Jeff Johnson295189b2012-06-20 16:38:30 -07003023eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3024{
3025 eHalStatus status = eHAL_STATUS_SUCCESS;
3026 tANI_U32 QoSEnabled;
3027 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003028 // set the CFG enable/disable variables based on the qosType being configured...
3029 switch( qosType )
3030 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003031 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3032 QoSEnabled = FALSE;
3033 WmeEnabled = TRUE;
3034 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003035 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3036 QoSEnabled = FALSE;
3037 WmeEnabled = TRUE;
3038 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003039 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3040 QoSEnabled = FALSE;
3041 WmeEnabled = TRUE;
3042 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003043 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3044 QoSEnabled = TRUE;
3045 WmeEnabled = FALSE;
3046 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003047 case eCSR_MEDIUM_ACCESS_11e_HCF:
3048 QoSEnabled = TRUE;
3049 WmeEnabled = FALSE;
3050 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003051 default:
3052 case eCSR_MEDIUM_ACCESS_DCF:
3053 QoSEnabled = FALSE;
3054 WmeEnabled = FALSE;
3055 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003056 }
3057 //save the WMM setting for later use
3058 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003059 status = ccmCfgSetInt(pMac, WNI_CFG_QOS_ENABLED, QoSEnabled, NULL, eANI_BOOLEAN_FALSE);
3060 status = ccmCfgSetInt(pMac, WNI_CFG_WME_ENABLED, WmeEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003061 return (status);
3062}
Jeff Johnson295189b2012-06-20 16:38:30 -07003063static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
3064 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet)
3065{
3066 eHalStatus status = eHAL_STATUS_FAILURE;
3067 int i;
3068 eCsrCfgDot11Mode cfgDot11Mode;
3069 tANI_U8 *pDstRate;
Jeff Johnson295189b2012-06-20 16:38:30 -07003070 palZeroMemory(pMac->hHdd, pOpRateSet, sizeof(tSirMacRateSet));
3071 palZeroMemory(pMac->hHdd, pExRateSet, sizeof(tSirMacRateSet));
Jeff Johnson295189b2012-06-20 16:38:30 -07003072 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003073
3074 if( NULL != pIes )
3075 {
3076 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003077 // Originally, we thought that for 11a networks, the 11a rates are always
3078 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3079 // appear in the Operational Rate set. Consequently, in either case, we
3080 // would blindly put the rates we support into our Operational Rate set
3081 // (including the basic rates, which we have already verified are
3082 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003083 // However, it turns out that this is not always the case. Some AP's
3084 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3085 // too. Now, we're a little more careful:
3086 pDstRate = pOpRateSet->rate;
3087 if(pIes->SuppRates.present)
3088 {
3089 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3090 {
3091 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3092 {
3093 *pDstRate++ = pIes->SuppRates.rates[ i ];
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003094 pOpRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003095 }
3096 }
3097 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003098 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3099 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3100 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3101 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3102 {
3103 // If there are Extended Rates in the beacon, we will reflect those
3104 // extended rates that we support in out Extended Operational Rate
3105 // set:
3106 pDstRate = pExRateSet->rate;
3107 if(pIes->ExtSuppRates.present)
3108 {
3109 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3110 {
3111 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) )
3112 {
3113 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3114 pExRateSet->numRates++;
3115 }
3116 }
3117 }
3118 }
3119 }//Parsing BSSDesc
3120 else
3121 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003122 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003123 }
3124 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3125 return status;
3126}
3127
3128static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3129 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3130{
3131 int i;
3132 tANI_U8 *pDstRate;
3133 eCsrCfgDot11Mode cfgDot11Mode;
3134 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3135 tANI_U32 OperationalRatesLength = 0;
3136 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3137 tANI_U32 ExtendedOperationalRatesLength = 0;
3138 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3139 tANI_U32 ProprietaryOperationalRatesLength = 0;
3140 tANI_U32 PropRatesEnable = 0;
3141 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3142 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003143 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003144 if( NULL != pIes )
3145 {
3146 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003147 // Originally, we thought that for 11a networks, the 11a rates are always
3148 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3149 // appear in the Operational Rate set. Consequently, in either case, we
3150 // would blindly put the rates we support into our Operational Rate set
3151 // (including the basic rates, which we have already verified are
3152 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003153 // However, it turns out that this is not always the case. Some AP's
3154 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3155 // too. Now, we're a little more careful:
3156 pDstRate = OperationalRates;
3157 if(pIes->SuppRates.present)
3158 {
3159 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3160 {
3161 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3162 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3163 {
3164 *pDstRate++ = pIes->SuppRates.rates[ i ];
3165 OperationalRatesLength++;
3166 }
3167 }
3168 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003169 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3170 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3171 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3172 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3173 {
3174 // If there are Extended Rates in the beacon, we will reflect those
3175 // extended rates that we support in out Extended Operational Rate
3176 // set:
3177 pDstRate = ExtendedOperationalRates;
3178 if(pIes->ExtSuppRates.present)
3179 {
3180 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3181 {
3182 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3183 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3184 {
3185 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3186 ExtendedOperationalRatesLength++;
3187 }
3188 }
3189 }
3190 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003191 // Enable proprietary MAC features if peer node is Airgo node and STA
3192 // user wants to use them
3193 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3194 {
3195 PropRatesEnable = 1;
3196 }
3197 else
3198 {
3199 PropRatesEnable = 0;
3200 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003201 // For ANI network companions, we need to populate the proprietary rate
3202 // set with any proprietary rates we found in the beacon, only if user
3203 // allows them...
3204 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3205 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3206 {
3207 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3208 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3209 {
3210 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3211 }
3212 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates, pIes->Airgo.PropSuppRates.rates, ProprietaryOperationalRatesLength );
3213 }
3214 else {
3215 // No proprietary modes...
3216 ProprietaryOperationalRatesLength = 0;
3217 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003218 /* Get MCS Rate */
3219 pDstRate = MCSRateIdxSet;
3220 if ( pIes->HTCaps.present )
3221 {
3222 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3223 {
3224 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3225 {
3226 MCSRateLength++;
3227 *pDstRate++ = i;
3228 }
3229 }
3230 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003231 // Set the operational rate set CFG variables...
3232 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3233 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3234 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3235 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3236 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3237 ProprietaryOperationalRates,
3238 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3239 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3240 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3241 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3242 }//Parsing BSSDesc
3243 else
3244 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003245 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003246 }
3247}
3248
Jeff Johnson295189b2012-06-20 16:38:30 -07003249static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3250 tCsrRoamProfile *pProfile )
3251{
3252 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3253 { 8,
3254 { SIR_MAC_RATE_6,
3255 SIR_MAC_RATE_9,
3256 SIR_MAC_RATE_12,
3257 SIR_MAC_RATE_18,
3258 SIR_MAC_RATE_24,
3259 SIR_MAC_RATE_36,
3260 SIR_MAC_RATE_48,
3261 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003262 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3263 { 4,
3264 { SIR_MAC_RATE_1,
3265 SIR_MAC_RATE_2,
3266 SIR_MAC_RATE_5_5,
3267 SIR_MAC_RATE_11 } } };
3268
3269
3270 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3271 { SIR_MAC_RATE_72,
3272 SIR_MAC_RATE_96,
3273 SIR_MAC_RATE_108 } };
3274 eCsrCfgDot11Mode cfgDot11Mode;
3275 eCsrBand eBand;
3276 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3277 tANI_U32 OperationalRatesLength = 0;
3278 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3279 tANI_U32 ExtendedOperationalRatesLength = 0;
3280 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3281 tANI_U32 ProprietaryOperationalRatesLength = 0;
3282 tANI_U32 PropRatesEnable = 0;
3283 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003284 if(pProfile->ChannelInfo.ChannelList)
3285 {
3286 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3287 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003288 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07003289 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3290 // networks, the 11b rates appear in the Operational Rate set. In either case,
3291 // we can blindly put the rates we support into our Operational Rate set
3292 // (including the basic rates, which we have already verified are supported
3293 // earlier in the roaming decision).
3294 if ( eCSR_BAND_5G == eBand )
3295 {
3296 // 11a rates into the Operational Rate Set.
3297 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3298 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
3299 palCopyMemory( pMac->hHdd, OperationalRates,
3300 DefaultSupportedRates11a.supportedRateSet.rate,
3301 OperationalRatesLength );
3302
3303 // Nothing in the Extended rate set.
3304 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003305 // populate proprietary rates if user allows them
3306 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3307 {
3308 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3309 sizeof(*DefaultSupportedPropRates.propRate);
3310 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates,
3311 DefaultSupportedPropRates.propRate,
3312 ProprietaryOperationalRatesLength );
3313 }
3314 else
3315 {
3316 // No proprietary modes
3317 ProprietaryOperationalRatesLength = 0;
3318 }
3319 }
3320 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3321 {
3322 // 11b rates into the Operational Rate Set.
3323 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3324 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
3325 palCopyMemory( pMac->hHdd, OperationalRates,
3326 DefaultSupportedRates11b.supportedRateSet.rate,
3327 OperationalRatesLength );
3328 // Nothing in the Extended rate set.
3329 ExtendedOperationalRatesLength = 0;
3330 // No proprietary modes
3331 ProprietaryOperationalRatesLength = 0;
3332 }
3333 else
3334 {
3335 // 11G
3336
3337 // 11b rates into the Operational Rate Set.
3338 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3339 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
3340 palCopyMemory( pMac->hHdd, OperationalRates,
3341 DefaultSupportedRates11b.supportedRateSet.rate,
3342 OperationalRatesLength );
3343
3344 // 11a rates go in the Extended rate set.
3345 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3346 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
3347 palCopyMemory( pMac->hHdd, ExtendedOperationalRates,
3348 DefaultSupportedRates11a.supportedRateSet.rate,
3349 ExtendedOperationalRatesLength );
3350
3351 // populate proprietary rates if user allows them
3352 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3353 {
3354 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3355 sizeof(*DefaultSupportedPropRates.propRate);
3356 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates,
3357 DefaultSupportedPropRates.propRate,
3358 ProprietaryOperationalRatesLength );
3359 }
3360 else
3361 {
3362 // No proprietary modes
3363 ProprietaryOperationalRatesLength = 0;
3364 }
3365 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003366 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3367 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3368 {
3369 PropRatesEnable = 1;
3370 }
3371 else
3372 {
3373 PropRatesEnable = 0;
3374 }
3375
3376 // Set the operational rate set CFG variables...
3377 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3378 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3379 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3380 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3381 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3382 ProprietaryOperationalRates,
3383 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3384 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003385}
Jeff Johnson295189b2012-06-20 16:38:30 -07003386void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3387{
3388 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07003389
Jeff Johnson295189b2012-06-20 16:38:30 -07003390 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3391 tANI_U32 sessionId;
3392 tSmeCmd *pCommand = NULL;
3393
3394 if(NULL == pEntry)
3395 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003396 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07003397 return;
3398 }
3399 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3400 sessionId = pCommand->sessionId;
3401
3402 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3403 {
3404 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3405 }
3406}
3407
Jeff Johnson295189b2012-06-20 16:38:30 -07003408//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3409tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3410{
3411 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3412 {
3413 return (WNI_CFG_PHY_MODE_11B);
3414 }
3415 else
3416 {
3417 if(eCSR_BAND_24 == band)
3418 return (WNI_CFG_PHY_MODE_11G);
3419 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003420 return (WNI_CFG_PHY_MODE_11A);
3421}
Jeff Johnson295189b2012-06-20 16:38:30 -07003422
Jeff Johnsone7245742012-09-05 17:12:55 -07003423
3424#ifdef WLAN_FEATURE_11AC
3425ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
3426{
3427 switch ( aniCBMode )
3428 {
3429 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
3430 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
3431 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
3432 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3433 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
3434 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
3435 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
3436 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3437 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003438 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07003439 return PHY_SINGLE_CHANNEL_CENTERED;
3440 }
3441}
3442#endif
3443
Jeff Johnson295189b2012-06-20 16:38:30 -07003444//pIes may be NULL
3445eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3446 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
3447 tDot11fBeaconIEs *pIes)
3448{
3449 eHalStatus status = eHAL_STATUS_SUCCESS;
3450 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3451 tANI_U8 channel = 0;
3452 //Make sure we have the domain info for the BSS we try to connect to.
3453 //Do we need to worry about sequence for OSs that are not Windows??
3454 if(pBssDesc)
3455 {
3456 if(csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
3457 {
3458 //Make sure the 11d info from this BSSDesc can be applied
3459 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
3460 csrApplyCountryInformation( pMac, TRUE );
3461 }
Kiran4a17ebe2013-01-31 10:43:43 -08003462 if ((csrIs11dSupported (pMac)) && pIes)
3463 {
3464 if (!pIes->Country.present)
3465 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
3466 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003467 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003468 //Qos
3469 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3470 //SSID
3471 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3472 //fragment threshold
3473 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3474 //RTS threshold
3475 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3476
3477 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
3478
3479 //Auth type
3480 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
3481 //encryption type
3482 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
3483 //short slot time
3484 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003485 //11d
3486 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
3487 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
3488 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003489 /*//11h
3490 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
3491 */
3492 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
3493 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07003494
Jeff Johnson295189b2012-06-20 16:38:30 -07003495 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile))
3496 {
3497 channel = pProfile->operationChannel;
3498 }
3499 else
3500 {
3501 if(pBssDesc)
3502 {
3503 channel = pBssDesc->channelId;
3504 }
3505 }
3506 if(0 != channel)
3507 {
3508 if(CSR_IS_CHANNEL_24GHZ(channel))
3509 {//for now if we are on 2.4 Ghz, CB will be always disabled
3510 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3511 }
3512 else
3513 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003514 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003515 }
3516 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003517#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08003518 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
3519 // in function csrConvertCBIniValueToPhyCBState()
3520 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
3521 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07003522 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003523 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003524 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003525 }
3526 else
3527 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003528 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003529 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003530 }
3531 else
3532#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003533 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
3534 //Rate
3535 //Fixed Rate
3536 if(pBssDesc)
3537 {
3538 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
3539 }
3540 else
3541 {
3542 csrSetCfgRateSetFromProfile(pMac, pProfile);
3543 }
3544 //Make this the last CFG to set. The callback will trigger a join_req
3545 //Join time out
3546 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
3547
3548 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003549 return (status);
3550}
3551
Jeff Johnson295189b2012-06-20 16:38:30 -07003552eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3553 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3554{
3555 eHalStatus status;
3556 tBssConfigParam *pBssConfig;
3557 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003558
3559 if(!pSession)
3560 {
3561 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3562 return eHAL_STATUS_FAILURE;
3563 }
3564
Jeff Johnson295189b2012-06-20 16:38:30 -07003565 status = palAllocateMemory(pMac->hHdd, (void **)&pBssConfig, sizeof(tBssConfigParam));
3566 if(HAL_STATUS_SUCCESS(status))
3567 {
3568 palZeroMemory(pMac->hHdd, pBssConfig, sizeof(tBssConfigParam));
3569 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
3570 if(HAL_STATUS_SUCCESS(status))
3571 {
3572 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003573 /* This will allow to pass cbMode during join req */
3574 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003575 //For IBSS, we need to prepare some more information
3576 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003577 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003578 )
3579 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003580 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07003581 }
3582 // If we are in an IBSS, then stop the IBSS...
3583 ////Not worry about WDS connection for now
3584 if ( csrIsConnStateIbss( pMac, sessionId ) )
3585 {
3586 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
3587 }
3588 else
3589 {
3590 // if we are in an Infrastructure association....
3591 if ( csrIsConnStateInfra( pMac, sessionId ) )
3592 {
3593 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
3594 // across SSIDs (roaming to a new SSID)... //
3595 //Not worry about WDS connection for now
3596 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
3597 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
3598 {
3599 // then we need to disassociate from the Infrastructure network...
3600 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
3601 }
3602 else
3603 {
3604 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
3605 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
3606 if ( pBssDesc )
3607 {
3608 // Set parameters for this Bss.
3609 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
3610 }
3611 }
3612 }
3613 else
3614 {
3615 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
3616 // Nothing to stop.
3617 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003618 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003619 )
3620 {
3621 // Set parameters for this Bss.
3622 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
3623 }
3624 }
3625 }
3626 }//Success getting BSS config info
3627 palFreeMemory(pMac->hHdd, pBssConfig);
3628 }//Allocate memory
3629
3630 return (status);
3631}
3632
Jeff Johnson295189b2012-06-20 16:38:30 -07003633eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
3634 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
3635{
3636 eCsrJoinState eRoamState = eCsrContinueRoaming;
3637 eHalStatus status;
3638 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
3639 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
3640 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003641
3642 if(!pSession)
3643 {
3644 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3645 return (eCsrStopRoaming);
3646 }
3647
Jeff Johnson295189b2012-06-20 16:38:30 -07003648 if( CSR_IS_WDS_STA( pProfile ) )
3649 {
3650 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
3651 if( !HAL_STATUS_SUCCESS( status ) )
3652 {
3653 eRoamState = eCsrStopRoaming;
3654 }
3655 }
3656 else
3657 {
3658 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
3659 {
3660 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
3661 return (eCsrStopRoaming);
3662 }
3663 if ( csrIsInfraBssDesc( pBssDesc ) )
3664 {
3665 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
3666 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
3667 // have changed and handle the changes (without disturbing the current association).
3668
3669 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
3670 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
3671 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
3672 )
3673 {
3674 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
3675 // with Authenticating first. To force this, stop the current association (Disassociate) and
3676 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
3677 // a new Association.
3678 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
3679 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003680 smsLog(pMac, LOGW, FL(" detect same profile authType = %d encryType = %d"), pProfile->AuthType, pProfile->EncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003681 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
3682 {
3683 eRoamState = eCsrReassocToSelfNoCapChange;
3684 }
3685 else
3686 {
3687 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07003688 //The key changes
3689 palZeroMemory(pMac->hHdd, &bssConfig, sizeof(bssConfig));
3690 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
3691 if(HAL_STATUS_SUCCESS(status))
3692 {
3693 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003694 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003695 //Reapply the config including Keys so reassoc is happening.
3696 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, pBssDesc, &bssConfig, pIesLocal);
3697 if(!HAL_STATUS_SUCCESS(status))
3698 {
3699 eRoamState = eCsrStopRoaming;
3700 }
3701 }
3702 else
3703 {
3704 eRoamState = eCsrStopRoaming;
3705 }
3706 }//same profile
3707 }
3708 else
3709 {
3710 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
3711 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
3712 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003713 smsLog(pMac, LOGW, FL(" fail to issue disassociate"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003714 eRoamState = eCsrStopRoaming;
3715 }
3716 }
3717 }
3718 else
3719 {
3720 // note: we used to pre-auth here with open authentication networks but that was not working so well.
3721 // we had a lot of join timeouts when testing at Samsung. removing this step helped associations
3722 // work much better.
3723 //
3724 //
3725 // stop the existing network before attempting to join the new network...
3726 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
3727 {
3728 eRoamState = eCsrStopRoaming;
3729 }
3730 }
3731 }//Infra
3732 else
3733 {
3734 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
3735 {
3736 eRoamState = eCsrStopRoaming;
3737 }
3738 }
3739 if( pIesLocal && !pScanResult->pvIes )
3740 {
3741 palFreeMemory(pMac->hHdd, pIesLocal);
3742 }
3743 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003744 return( eRoamState );
3745}
3746
Jeff Johnson295189b2012-06-20 16:38:30 -07003747eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
3748 tSirBssDescription *pBssDesc, tANI_U32 roamId)
3749{
3750 eHalStatus status = eHAL_STATUS_SUCCESS;
3751 tCsrRoamInfo roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07003752 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
3753 roamInfo.pBssDesc = pBssDesc;
3754 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
3755 return (status);
3756}
Jeff Johnson295189b2012-06-20 16:38:30 -07003757//In case no matching BSS is found, use whatever default we can find
3758static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
3759{
3760 //Need to get all negotiated types in place first
3761 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003762 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003763 {
3764 default:
3765 case eCSR_AUTH_TYPE_WPA:
3766 case eCSR_AUTH_TYPE_WPA_PSK:
3767 case eCSR_AUTH_TYPE_WPA_NONE:
3768 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3769 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3770 break;
3771
3772 case eCSR_AUTH_TYPE_SHARED_KEY:
3773 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
3774 break;
3775
3776 case eCSR_AUTH_TYPE_AUTOSWITCH:
3777 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
3778 break;
3779 }
3780 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
3781 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
3782 //In this case, the multicast encryption needs to follow the uncast ones.
3783 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
3784 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
3785}
3786
3787static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
3788{
3789 eHalStatus status;
3790 tCsrScanResult *pScanResult = NULL;
3791 eCsrJoinState eRoamState = eCsrStopRoaming;
3792 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
3793 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
3794 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
3795#ifndef WLAN_MDM_CODE_REDUCTION_OPT
3796 v_U8_t acm_mask = 0;
3797#endif
3798 tANI_U32 sessionId = pCommand->sessionId;
3799 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3800 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
3801 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07003802
3803 if(!pSession)
3804 {
3805 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3806 return (eCsrStopRoaming);
3807 }
3808
Jeff Johnson295189b2012-06-20 16:38:30 -07003809 do
3810 {
3811 // Check for Cardbus eject condition, before trying to Roam to any BSS
3812 //***if( !balIsCardPresent(pAdapter) ) break;
3813
3814 if(NULL != pBSSList)
3815 {
3816 // When handling AP's capability change, continue to associate to
3817 // same BSS and make sure pRoamBssEntry is not Null.
3818 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
3819 {
3820 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
3821 {
3822 //Try the first BSS
3823 pCommand->u.roamCmd.pLastRoamBss = NULL;
3824 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
3825 }
3826 else
3827 {
3828 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
3829 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
3830 {
3831 //Done with all the BSSs
3832 //In this case, will tell HDD the completion
3833 break;
3834 }
3835 else
3836 {
3837 //We need to indicate to HDD that we are done with this one.
3838 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
3839 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
3840 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
3841 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
3842 pRoamInfo = &roamInfo;
3843 }
3844 }
3845 while(pCommand->u.roamCmd.pRoamBssEntry)
3846 {
3847 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07003848 /*If concurrency enabled take the concurrent connected channel first. */
3849 /* Valid multichannel concurrent sessions exempted */
Jeff Johnsone7245742012-09-05 17:12:55 -07003850 if (vos_concurrent_sessions_running() &&
3851 !csrIsValidMcConcurrentSession(pMac, sessionId, &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07003852 {
3853 concurrentChannel =
3854 csrGetConcurrentOperationChannel(pMac);
3855 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003856 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07003857 if ((concurrentChannel) &&
3858 (concurrentChannel ==
3859 pScanResult->Result.BssDescriptor.channelId))
3860 {
3861 //make this 0 because we do not want the
3862 //below check to pass as we don't want to
3863 //connect on other channel
3864 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
3865 FL("Concurrent channel match =%d"),
3866 concurrentChannel);
3867 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003868 }
3869 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003870
3871 if (!concurrentChannel)
3872 {
3873
3874 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
3875 sessionId, &pScanResult->Result.BssDescriptor,
3876 pCommand->u.roamCmd.roamId)))
3877 {
3878 //Ok to roam this
3879 break;
3880 }
3881 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003882 else
3883 {
3884 eRoamState = eCsrStopRoamingDueToConcurrency;
3885 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003886 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
3887 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
3888 {
3889 //Done with all the BSSs
3890 fDone = eANI_BOOLEAN_TRUE;
3891 break;
3892 }
3893 }
3894 if(fDone)
3895 {
3896 break;
3897 }
3898 }
3899 }
3900 //We have something to roam, tell HDD when it is infra.
3901 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
3902 //For WDS, the indication is eCSR_ROAM_WDS_IND
3903 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
3904 {
3905 if(pRoamInfo)
3906 {
3907 pSession->bRefAssocStartCnt--;
3908 //Complete the last association attemp because a new one is about to be tried
3909 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
3910 eCSR_ROAM_ASSOCIATION_COMPLETION,
3911 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
3912 }
3913 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
3914 if(pScanResult)
3915 {
3916 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07003917 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
3918 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003919 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003920 fDone = eANI_BOOLEAN_TRUE;
3921 eRoamState = eCsrStopRoaming;
3922 break;
3923 }
3924 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
3925 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
3926 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
3927 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
3928 CSR_IS_QOS_BSS(pIesLocal) &&
3929 CSR_IS_UAPSD_BSS(pIesLocal) )
3930 {
3931#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07003932 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
3933 pIesLocal);
3934 pCommand->u.roamCmd.roamProfile.uapsd_mask &= ~(acm_mask);
3935#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07003936 }
3937 else
3938 {
3939 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
3940 }
3941 if( pIesLocal && !pScanResult->Result.pvIes)
3942 {
3943 palFreeMemory(pMac->hHdd, pIesLocal);
3944 }
3945 }
3946 else
3947 {
3948 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
3949 }
3950 roamInfo.pProfile = pProfile;
3951 pSession->bRefAssocStartCnt++;
3952 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
3953 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
3954 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003955 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
3956 {
3957 // If this is a start IBSS profile, then we need to start the IBSS.
3958 if ( CSR_IS_START_IBSS(pProfile) )
3959 {
3960 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003961 // Attempt to start this IBSS...
3962 csrRoamAssignDefaultParam( pMac, pCommand );
3963 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
3964 if(HAL_STATUS_SUCCESS(status))
3965 {
3966 if ( fSameIbss )
3967 {
3968 eRoamState = eCsrStartIbssSameIbss;
3969 }
3970 else
3971 {
3972 eRoamState = eCsrContinueRoaming;
3973 }
3974 }
3975 else
3976 {
3977 //it somehow fail need to stop
3978 eRoamState = eCsrStopRoaming;
3979 }
3980 break;
3981 }
3982 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07003983 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07003984 )
3985 {
3986 // Attempt to start this WDS...
3987 csrRoamAssignDefaultParam( pMac, pCommand );
3988 /* For AP WDS, we dont have any BSSDescription */
3989 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
3990 if(HAL_STATUS_SUCCESS(status))
3991 {
3992 eRoamState = eCsrContinueRoaming;
3993 }
3994 else
3995 {
3996 //it somehow fail need to stop
3997 eRoamState = eCsrStopRoaming;
3998 }
3999 }
4000 else
4001 {
4002 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004003 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004004 eRoamState = eCsrStopRoaming;
4005 break;
4006 }
4007 }
4008 else //We have BSS
4009 {
4010 //Need to assign these value because they are used in csrIsSameProfile
4011 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4012 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType = pScanResult->ucEncryptionType; //Negotiated while building scan result.
4013 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType = pScanResult->mcEncryptionType;
4014 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4015 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4016 {
4017 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4018 {
4019 eRoamState = eCsrStartIbssSameIbss;
4020 break;
4021 }
4022 }
4023 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4024 {
4025 //trying to connect to the one already connected
4026 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4027 eRoamState = eCsrReassocToSelfNoCapChange;
4028 break;
4029 }
4030 // Attempt to Join this Bss...
4031 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4032 break;
4033 }
4034
4035 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004036 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4037 {
4038 //Need to indicate association_completion if association_start has been done
4039 if(pSession->bRefAssocStartCnt > 0)
4040 {
4041 pSession->bRefAssocStartCnt--;
4042 //Complete the last association attemp because a new one is about to be tried
4043 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4044 eCSR_ROAM_ASSOCIATION_COMPLETION,
4045 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4046 }
4047 }
4048
4049 return( eRoamState );
4050}
4051
Jeff Johnson295189b2012-06-20 16:38:30 -07004052static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4053{
4054 eHalStatus status = eHAL_STATUS_SUCCESS;
4055 eCsrJoinState RoamState;
4056 tANI_U32 sessionId = pCommand->sessionId;
4057
Jeff Johnson295189b2012-06-20 16:38:30 -07004058 //***if( hddIsRadioStateOn( pAdapter ) )
4059 {
4060 // Attept to join a Bss...
4061 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004062
Jeff Johnson295189b2012-06-20 16:38:30 -07004063 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004064 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004065 {
4066 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004067 // and if connected in Infrastructure mode...
4068 if ( csrIsConnStateInfra(pMac, sessionId) )
4069 {
4070 //... then we need to issue a disassociation
4071 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4072 if(!HAL_STATUS_SUCCESS(status))
4073 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004074 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004075 //roam command is completed by caller in the failed case
4076 fComplete = eANI_BOOLEAN_TRUE;
4077 }
4078 }
4079 else if( csrIsConnStateIbss(pMac, sessionId) )
4080 {
4081 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4082 if(!HAL_STATUS_SUCCESS(status))
4083 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004084 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004085 //roam command is completed by caller in the failed case
4086 fComplete = eANI_BOOLEAN_TRUE;
4087 }
4088 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004089 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4090 {
4091 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4092 if(!HAL_STATUS_SUCCESS(status))
4093 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004094 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004095 //roam command is completed by caller in the failed case
4096 fComplete = eANI_BOOLEAN_TRUE;
4097 }
4098 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004099 else
4100 {
4101 fComplete = eANI_BOOLEAN_TRUE;
4102 }
4103 if(fComplete)
4104 {
4105 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004106 if(eCsrStopRoamingDueToConcurrency == RoamState)
4107 {
4108 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4109 }
4110 else
4111 {
4112 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4113 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004114 }
4115 }
4116 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4117 {
4118 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4119 }
4120 else if ( eCsrStartIbssSameIbss == RoamState )
4121 {
4122 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4123 }
4124 }//hddIsRadioStateOn
4125
4126 return status;
4127}
Jeff Johnson295189b2012-06-20 16:38:30 -07004128eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4129{
4130 tANI_U32 sessionId;
4131 tCsrRoamSession *pSession;
4132 tCsrScanResult *pScanResult = NULL;
4133 tSirBssDescription *pBssDesc = NULL;
4134 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004135 sessionId = pCommand->sessionId;
4136 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004137
4138 if(!pSession)
4139 {
4140 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4141 return eHAL_STATUS_FAILURE;
4142 }
4143
Jeff Johnson295189b2012-06-20 16:38:30 -07004144 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4145 {
4146 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004147 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004148 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4149 return eHAL_STATUS_FAILURE;
4150 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004151 if (pCommand->u.roamCmd.pRoamBssEntry)
4152 {
4153 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4154 pBssDesc = &pScanResult->Result.BssDescriptor;
4155 }
4156 else
4157 {
4158 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004159 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004160 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4161 return eHAL_STATUS_FAILURE;
4162 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004163 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4164 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4165 return status;
4166}
4167
Jeff Johnson295189b2012-06-20 16:38:30 -07004168eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4169{
4170 eHalStatus status = eHAL_STATUS_SUCCESS;
4171 tCsrRoamInfo roamInfo;
4172 tANI_U32 sessionId = pCommand->sessionId;
4173 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004174
4175 if(!pSession)
4176 {
4177 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4178 return eHAL_STATUS_FAILURE;
4179 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004180
4181 switch ( pCommand->u.roamCmd.roamReason )
4182 {
4183 case eCsrForcedDisassoc:
4184 csrFreeRoamProfile(pMac, sessionId);
4185 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4186 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004187 case eCsrSmeIssuedDisassocForHandoff:
4188 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4189#if 0 // TODO : Confirm this change
4190 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4191#else
4192 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4193#endif
4194
4195 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004196 case eCsrForcedDisassocMICFailure:
4197 csrFreeRoamProfile(pMac, sessionId);
4198 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
4199 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004200 case eCsrForcedDeauth:
4201 csrFreeRoamProfile(pMac, sessionId);
4202 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
4203 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004204 case eCsrHddIssuedReassocToSameAP:
4205 case eCsrSmeIssuedReassocToSameAP:
4206 {
4207 tDot11fBeaconIEs *pIes = NULL;
4208
Jeff Johnson295189b2012-06-20 16:38:30 -07004209 if( pSession->pConnectBssDesc )
4210 {
4211 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4212 if(!HAL_STATUS_SUCCESS(status) )
4213 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004214 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004215 }
4216 else
4217 {
4218 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4219 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4220 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004221 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4222 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4223 pSession->bRefAssocStartCnt++;
4224 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4225 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4226
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004227 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004228 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4229 &pCommand->u.roamCmd.roamProfile );
4230 if(!HAL_STATUS_SUCCESS(status))
4231 {
4232 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08004233 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004234 }
4235
Jeff Johnson295189b2012-06-20 16:38:30 -07004236 palFreeMemory(pMac->hHdd, pIes);
4237 pIes = NULL;
4238 }
4239 }
4240 break;
4241 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004242 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004243 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004244 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4245 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4246 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004247 case eCsrSmeIssuedFTReassoc:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004248 smsLog(pMac, LOGE, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004249 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4250 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004251
Jeff Johnson295189b2012-06-20 16:38:30 -07004252 case eCsrStopBss:
4253 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4254 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4255 break;
4256
4257 case eCsrForcedDisassocSta:
4258 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4259 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4260 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4261 pCommand->u.roamCmd.reason);
4262 break;
4263
4264 case eCsrForcedDeauthSta:
4265 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4266 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4267 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4268 pCommand->u.roamCmd.reason);
4269 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004270
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004271 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08004272 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004273 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4274 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004275 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004276
4277 default:
4278 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4279
4280 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4281 {
4282 //Remember the roaming profile
4283 csrFreeRoamProfile(pMac, sessionId);
4284 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pSession->pCurRoamProfile, sizeof(tCsrRoamProfile))))
4285 {
4286 palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile));
4287 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4288 }
4289 }
4290
4291 //At this point, original uapsd_mask is saved in pCurRoamProfile
4292 //uapsd_mask in the pCommand may change from this point on.
4293
4294 // Attempt to roam with the new scan results (if we need to..)
4295 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004296 if(!HAL_STATUS_SUCCESS(status))
4297 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004298 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004299 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004300 break;
4301 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004302 return (status);
4303}
4304
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004305void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4306{
4307 pCommand->u.roamCmd.pLastRoamBss = NULL;
4308 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4309 //Because u.roamCmd is union and share with scanCmd and StatusChange
4310 palZeroMemory(pMac->hHdd, &pCommand->u.roamCmd, sizeof(tRoamCmd));
4311}
4312
Jeff Johnson295189b2012-06-20 16:38:30 -07004313void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4314{
4315 if(pCommand->u.roamCmd.fReleaseBssList)
4316 {
4317 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4318 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4319 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4320 }
4321 if(pCommand->u.roamCmd.fReleaseProfile)
4322 {
4323 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4324 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4325 }
4326 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4327 //Because u.roamCmd is union and share with scanCmd and StatusChange
4328 palZeroMemory(pMac->hHdd, &pCommand->u.roamCmd, sizeof(tRoamCmd));
4329}
4330
Jeff Johnson295189b2012-06-20 16:38:30 -07004331void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4332{
4333 palZeroMemory(pMac->hHdd, &pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd));
4334}
Jeff Johnson295189b2012-06-20 16:38:30 -07004335void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4336{
4337 tListElem *pEntry;
4338 tSmeCmd *pCommand;
4339 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004340 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004341 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4342 if ( pEntry )
4343 {
4344 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004345 // If the head of the queue is Active and it is a ROAM command, remove
4346 // and put this on the Free queue.
4347 if ( eSmeCommandRoam == pCommand->command )
4348 {
4349 //we need to process the result first before removing it from active list because state changes
4350 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4351 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4352 if( fReleaseCommand )
4353 {
4354 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4355 {
4356 csrReleaseCommandRoam( pMac, pCommand );
4357 }
4358 else
4359 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004360 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004361 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004362 }
4363 }
4364 else
4365 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004366 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004367 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004368 }
4369 }
4370 else
4371 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004372 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004373 }
4374 }
4375 else
4376 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004377 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004378 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004379 if( fReleaseCommand )
4380 {
4381 smeProcessPendingQueue( pMac );
4382 }
4383}
4384
Jeff Johnson295189b2012-06-20 16:38:30 -07004385void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4386{
4387 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004388 if(!pSession)
4389 {
4390 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4391 return;
4392 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004393 palZeroMemory( pMac->hHdd, &(pSession->PmkidCandidateInfo[0]), sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED );
4394 pSession->NumPmkidCandidate = 0;
4395}
Jeff Johnson295189b2012-06-20 16:38:30 -07004396#ifdef FEATURE_WLAN_WAPI
4397void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4398{
4399 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004400 if(!pSession)
4401 {
4402 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4403 return;
4404 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004405 palZeroMemory( pMac->hHdd, &(pSession->BkidCandidateInfo[0]), sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED );
4406 pSession->NumBkidCandidate = 0;
4407}
4408#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004409extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4410
Jeff Johnson295189b2012-06-20 16:38:30 -07004411static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4412 tSirBssDescription *pSirBssDesc,
4413 tDot11fBeaconIEs *pIes)
4414{
4415 eHalStatus status = eHAL_STATUS_SUCCESS;
4416 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4417 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004418
4419 if(!pSession)
4420 {
4421 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4422 return eHAL_STATUS_FAILURE;
4423 }
4424
Jeff Johnson295189b2012-06-20 16:38:30 -07004425 if((eCSR_AUTH_TYPE_WPA == authType) ||
4426 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
4427 (eCSR_AUTH_TYPE_RSN == authType) ||
4428 (eCSR_AUTH_TYPE_RSN_PSK == authType)
4429#if defined WLAN_FEATURE_VOWIFI_11R
4430 ||
4431 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4432 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
4433#endif /* FEATURE_WLAN_WAPI */
4434#ifdef FEATURE_WLAN_WAPI
4435 ||
4436 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4437 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
4438#endif /* FEATURE_WLAN_WAPI */
4439 )
4440 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004441 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4442 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004443 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004444 }
4445 if( pIesLocal )
4446 {
4447 tANI_U32 nIeLen;
4448 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07004449 if((eCSR_AUTH_TYPE_RSN == authType) ||
4450#if defined WLAN_FEATURE_VOWIFI_11R
4451 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4452 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
4453#endif /* WLAN_FEATURE_VOWIFI_11R */
4454 (eCSR_AUTH_TYPE_RSN_PSK == authType))
4455 {
4456 if(pIesLocal->RSN.present)
4457 {
4458 //Calculate the actual length
4459 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
4460 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
4461 + 2 //akm_suite_count
4462 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
4463 + 2; //reserved
4464 if( pIesLocal->RSN.pmkid_count )
4465 {
4466 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
4467 }
4468 //nIeLen doesn't count EID and length fields
4469 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnRspIE, nIeLen + 2))))
4470 {
4471 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
4472 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4473 //copy upto akm_suites
4474 pIeBuf = pSession->pWpaRsnRspIE + 2;
4475 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.version, 8);
4476 pIeBuf += 8;
4477 if( pIesLocal->RSN.pwise_cipher_suite_count )
4478 {
4479 //copy pwise_cipher_suites
4480 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.pwise_cipher_suites,
4481 pIesLocal->RSN.pwise_cipher_suite_count * 4);
4482 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
4483 }
4484 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
4485 pIeBuf += 2;
4486 if( pIesLocal->RSN.akm_suite_count )
4487 {
4488 //copy akm_suites
4489 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.akm_suites,
4490 pIesLocal->RSN.akm_suite_count * 4);
4491 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
4492 }
4493 //copy the rest
4494 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.akm_suites +
4495 pIesLocal->RSN.akm_suite_count * 4,
4496 2 + pIesLocal->RSN.pmkid_count * 4);
4497 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4498 }
4499 }
4500 }
4501 else if((eCSR_AUTH_TYPE_WPA == authType) ||
4502 (eCSR_AUTH_TYPE_WPA_PSK == authType))
4503 {
4504 if(pIesLocal->WPA.present)
4505 {
4506 //Calculate the actual length
4507 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
4508 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
4509 + 2 //auth_suite_count
4510 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
4511 // The WPA capabilities follows the Auth Suite (two octects)--
4512 // this field is optional, and we always "send" zero, so just
4513 // remove it. This is consistent with our assumptions in the
4514 // frames compiler; c.f. bug 15234:
4515 //nIeLen doesn't count EID and length fields
4516 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnRspIE, nIeLen + 2))))
4517 {
4518 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
4519 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4520 pIeBuf = pSession->pWpaRsnRspIE + 2;
4521 //Copy WPA OUI
4522 palCopyMemory(pMac->hHdd, pIeBuf, &csrWpaOui[1], 4);
4523 pIeBuf += 4;
4524 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WPA.version, 8 +
4525 pIesLocal->WPA.unicast_cipher_count * 4);
4526 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
4527 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WPA.auth_suite_count, 2 +
4528 pIesLocal->WPA.auth_suite_count * 4);
4529 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
4530 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4531 }
4532 }
4533 }
4534#ifdef FEATURE_WLAN_WAPI
4535 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4536 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
4537 {
4538 if(pIesLocal->WAPI.present)
4539 {
4540 //Calculate the actual length
4541 nIeLen = 4 //version + akm_suite_count
4542 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
4543 + 2 //pwise_cipher_suite_count
4544 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
4545 + 6; //gp_cipher_suite + preauth + reserved
4546 if( pIesLocal->WAPI.bkid_count )
4547 {
4548 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
4549 }
4550
4551 //nIeLen doesn't count EID and length fields
4552 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWapiRspIE, nIeLen + 2))))
4553 {
4554 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
4555 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
4556 pIeBuf = pSession->pWapiRspIE + 2;
4557 //copy upto akm_suite_count
4558 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.version, 4);
4559 pIeBuf += 4;
4560 if( pIesLocal->WAPI.akm_suite_count )
4561 {
4562 //copy akm_suites
4563 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.akm_suites,
4564 pIesLocal->WAPI.akm_suite_count * 4);
4565 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
4566 }
4567 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.unicast_cipher_suite_count, 2);
4568 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004569 if( pIesLocal->WAPI.unicast_cipher_suite_count )
4570 {
4571 //copy pwise_cipher_suites
4572 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.unicast_cipher_suites,
4573 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
4574 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
4575 }
4576 //gp_cipher_suite + preauth + reserved + bkid_count
4577 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.multicast_cipher_suite, 8);
4578 pIeBuf += 8;
4579 if( pIesLocal->WAPI.bkid_count )
4580 {
4581 //copy akm_suites
4582 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.bkid, pIesLocal->WAPI.bkid_count * 4);
4583 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
4584 }
4585 pSession->nWapiRspIeLength = nIeLen + 2;
4586 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004587 }
4588 }
4589#endif /* FEATURE_WLAN_WAPI */
4590 if( !pIes )
4591 {
4592 //locally allocated
4593 palFreeMemory(pMac->hHdd, pIesLocal);
4594 }
4595 }
4596 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004597 return (status);
4598}
4599
Jeff Johnson295189b2012-06-20 16:38:30 -07004600static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
4601{
4602 v_U8_t bACWeights[WLANTL_MAX_AC];
4603 v_U8_t paramBk, paramBe, paramVi, paramVo;
4604 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004605 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
4606 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
4607 //of the higher AC one, make the higher AC has the same weight as the lower AC.
4608 //This doesn't address the case where the lower AC needs a real higher weight
4609 if( pIEs->WMMParams.present )
4610 {
4611 //no change to the lowest ones
4612 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
4613 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
4614 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
4615 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
4616 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
4617 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
4618 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
4619 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
4620 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
4621 {
4622 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
4623 fWeightChange = VOS_TRUE;
4624 }
4625 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
4626 {
4627 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
4628 fWeightChange = VOS_TRUE;
4629 }
4630 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
4631 {
4632 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
4633 fWeightChange = VOS_TRUE;
4634 }
4635 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
4636 {
4637 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
4638 fWeightChange = VOS_TRUE;
4639 }
4640 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
4641 {
4642 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
4643 fWeightChange = VOS_TRUE;
4644 }
4645 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
4646 {
4647 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
4648 fWeightChange = VOS_TRUE;
4649 }
4650 if(fWeightChange)
4651 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004652 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07004653 bACWeights[2], bACWeights[3]);
4654 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
4655 }
4656 }
4657}
Jeff Johnson295189b2012-06-20 16:38:30 -07004658#ifdef WLAN_FEATURE_VOWIFI_11R
4659//Returns whether the current association is a 11r assoc or not
4660tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
4661{
4662#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
4663 return csrNeighborRoamIs11rAssoc(pMac);
4664#else
4665 return eANI_BOOLEAN_FALSE;
4666#endif
4667}
4668#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004669#ifdef FEATURE_WLAN_CCX
4670//Returns whether the current association is a CCX assoc or not
4671tANI_BOOLEAN csrRoamIsCCXAssoc(tpAniSirGlobal pMac)
4672{
4673#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
4674 return csrNeighborRoamIsCCXAssoc(pMac);
4675#else
4676 return eANI_BOOLEAN_FALSE;
4677#endif
4678}
4679#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004680#ifdef FEATURE_WLAN_LFR
4681//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304682tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004683{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304684 tCsrRoamSession *pSession = NULL;
4685
4686 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
4687 {
4688 pSession = CSR_GET_SESSION( pMac, sessionId );
4689 if (NULL != pSession->pCurRoamProfile)
4690 {
4691 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
4692 {
4693 return eANI_BOOLEAN_FALSE;
4694 }
4695 }
4696 }
4697
Madan Mohan Koyyalamudi9ce36ec2012-10-15 16:03:17 -07004698 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07004699 (!csrIsConcurrentSessionRunning(pMac)));
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004700}
4701#endif
4702
Jeff Johnson295189b2012-06-20 16:38:30 -07004703//Return true means the command can be release, else not
4704static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
4705 eCsrRoamCompleteResult Result, void *Context )
4706{
4707 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
4708 tSirBssDescription *pSirBssDesc = NULL;
4709 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
4710 tCsrScanResult *pScanResult = NULL;
4711 tCsrRoamInfo roamInfo;
4712 sme_QosAssocInfo assocInfo;
4713 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
4714 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
4715 tDot11fBeaconIEs *pIes = NULL;
4716 tANI_U32 sessionId = pCommand->sessionId;
4717 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4718 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4719 eRoamCmdStatus roamStatus;
4720 eCsrRoamResult roamResult;
4721 eHalStatus status;
4722 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004723 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004724
Jeff Johnson32d95a32012-09-10 13:15:23 -07004725 if(!pSession)
4726 {
4727 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4728 return eANI_BOOLEAN_FALSE;
4729 }
4730
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004731 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07004732 switch( Result )
4733 {
4734 case eCsrJoinSuccess:
4735 // reset the IDLE timer
4736 // !!
4737 // !! fall through to the next CASE statement here is intentional !!
4738 // !!
4739 case eCsrReassocSuccess:
4740 if(eCsrReassocSuccess == Result)
4741 {
4742 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
4743 }
4744 else
4745 {
4746 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
4747 }
4748 // Success Join Response from LIM. Tell NDIS we are connected and save the
4749 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004750 smsLog(pMac, LOGW, FL("receives association indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004751 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
4752 //always free the memory here
4753 if(pSession->pWpaRsnRspIE)
4754 {
4755 pSession->nWpaRsnRspIeLength = 0;
4756 palFreeMemory(pMac->hHdd, pSession->pWpaRsnRspIE);
4757 pSession->pWpaRsnRspIE = NULL;
4758 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004759#ifdef FEATURE_WLAN_WAPI
4760 if(pSession->pWapiRspIE)
4761 {
4762 pSession->nWapiRspIeLength = 0;
4763 palFreeMemory(pMac->hHdd, pSession->pWapiRspIE);
4764 pSession->pWapiRspIE = NULL;
4765 }
4766#endif /* FEATURE_WLAN_WAPI */
4767#ifdef FEATURE_WLAN_BTAMP_UT_RF
4768 //Reset counter so no join retry is needed.
4769 pSession->maxRetryCount = 0;
4770 csrRoamStopJoinRetryTimer(pMac, sessionId);
4771#endif
4772 /* This creates problem since we have not saved the connected profile.
4773 So moving this after saving the profile
4774 */
4775 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
4776 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4777 {
4778 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
4779 }
4780 else
4781 {
4782 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
4783 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004784 //Use the last connected bssdesc for reassoc-ing to the same AP.
4785 //NOTE: What to do when reassoc to a different AP???
4786 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
4787 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
4788 {
4789 pSirBssDesc = pSession->pConnectBssDesc;
4790 if(pSirBssDesc)
4791 {
4792 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
4793 }
4794 }
4795 else
4796 {
4797
4798 if(pCommand->u.roamCmd.pRoamBssEntry)
4799 {
4800 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4801 if(pScanResult != NULL)
4802 {
4803 pSirBssDesc = &pScanResult->Result.BssDescriptor;
4804 //this can be NULL
4805 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
4806 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
4807 }
4808 }
4809 }
4810 if( pSirBssDesc )
4811 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004812 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07004813 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
4814 //Save WPA/RSN IE
4815 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
4816#ifdef FEATURE_WLAN_CCX
4817 roamInfo.isCCXAssoc = pSession->connectedProfile.isCCXAssoc;
4818#endif
4819
4820 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
4821 // substate change.
4822 // Moving even save profile above so that below mentioned conditon is also met.
4823 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
4824 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07004825 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
4826 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
4827 // will be dropped for the security context may not be set properly.
4828 //
4829 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
4830 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
4831 //
4832 // this reordering was done on titan_prod_usb branch and is being replicated here.
4833 //
4834
4835 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
4836 !pProfile->bWPSAssociation)
4837 {
4838 // Issue the set Context request to LIM to establish the Unicast STA context
4839 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
4840 pProfile->negotiatedUCEncryptionType,
4841 pSirBssDesc, &(pSirBssDesc->bssId),
4842 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
4843 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004844 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07004845 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
4846 }
4847 // Issue the set Context request to LIM to establish the Broadcast STA context
4848 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
4849 pSirBssDesc, &BroadcastMac,
4850 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
4851 }
4852 else
4853 {
4854 //Need to wait for supplicant authtication
4855 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004856 //Set the subestate to WaitForKey in case authentiation is needed
4857 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
4858
Jeff Johnson295189b2012-06-20 16:38:30 -07004859 if(pProfile->bWPSAssociation)
4860 {
4861 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
4862 }
4863 else
4864 {
4865 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
4866 }
4867
4868 //Save sessionId in case of timeout
4869 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
4870 //This time should be long enough for the rest of the process plus setting key
4871 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
4872 {
4873 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004874 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07004875 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
4876 }
4877 }
4878
4879 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
4880 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004881 if(Context)
4882 {
4883 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
4884 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07004885 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
4886 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
4887#ifdef WLAN_FEATURE_VOWIFI_11R
4888 len += pJoinRsp->parsedRicRspLen;
4889#endif /* WLAN_FEATURE_VOWIFI_11R */
4890#ifdef FEATURE_WLAN_CCX
4891 len += pJoinRsp->tspecIeLen;
4892#endif
4893 if(len)
4894 {
4895 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
4896 (void **)&pSession->connectedInfo.pbFrames, len)))
4897 {
4898 if(HAL_STATUS_SUCCESS( palCopyMemory(pMac->hHdd,
4899 pSession->connectedInfo.pbFrames, pJoinRsp->frames, len) ))
4900 {
4901 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
4902 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
4903 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
4904#ifdef WLAN_FEATURE_VOWIFI_11R
4905 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
4906#endif /* WLAN_FEATURE_VOWIFI_11R */
4907#ifdef FEATURE_WLAN_CCX
4908 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
4909#endif
4910 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
4911 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
4912 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
4913 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
4914 }
4915 else
4916 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004917 smsLog(pMac, LOGE, "%s: Copying of memory failed for %d bytes !!!",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004918 __func__, len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004919 palFreeMemory( pMac->hHdd, pSession->connectedInfo.pbFrames );
4920 pSession->connectedInfo.pbFrames = NULL;
4921 }
4922 }
4923 }
4924 if(pCommand->u.roamCmd.fReassoc)
4925 {
4926 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
4927 }
4928 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
4929 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
4930 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
4931 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
4932 }
4933 else
4934 {
4935 if(pCommand->u.roamCmd.fReassoc)
4936 {
4937 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
4938 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
4939 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
4940 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
4941 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
4942 }
4943 }
4944#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4945 // Indicate SME-QOS with reassoc success event, only after
4946 // copying the frames
4947 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
4948#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004949 roamInfo.pBssDesc = pSirBssDesc;
4950 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4951 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4952#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4953 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
4954#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
4955 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07004956 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
4957 //It may be better to let QoS do this????
4958 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
4959 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004960 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07004961 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
4962 pmcStartUapsd( pMac, NULL, NULL );
4963 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004964 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
4965 if( pSession->bRefAssocStartCnt > 0 )
4966 {
4967 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07004968 //Remove this code once SLM_Sessionization is supported
4969 //BMPS_WORKAROUND_NOT_NEEDED
4970 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07004971 {
4972 pMac->roam.configParam.doBMPSWorkaround = 1;
4973 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004974 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
4975 }
4976
4977 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004978 // reset the PMKID candidate list
4979 csrResetPMKIDCandidateList( pMac, sessionId );
4980 //Update TL's AC weight base on the current EDCA parameters
4981 //These parameters may change in the course of the connection, that sictuation
4982 //is not taken care here. This change is mainly to address a WIFI WMM test where
4983 //BE has a equal or higher TX priority than VI.
4984 //We only do this for infra link
4985 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
4986 {
4987 csrCheckAndUpdateACWeight(pMac, pIes);
4988 }
4989#ifdef FEATURE_WLAN_WAPI
4990 // reset the BKID candidate list
4991 csrResetBKIDCandidateList( pMac, sessionId );
4992#endif /* FEATURE_WLAN_WAPI */
4993 }
4994 else
4995 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004996 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07004997 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004998 csrScanCancelIdleScan(pMac);
4999 //Not to signal link up because keys are yet to be set.
5000 //The linkup function will overwrite the sub-state that we need to keep at this point.
5001 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5002 {
5003 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5004 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005005 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5006 //enough to let security and DHCP handshake succeed before entry into BMPS
5007 if (pmcShouldBmpsTimerRun(pMac))
5008 {
5009 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5010 != eHAL_STATUS_SUCCESS)
5011 {
5012 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5013 }
5014 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5015 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005016 break;
5017
Jeff Johnson295189b2012-06-20 16:38:30 -07005018 case eCsrStartBssSuccess:
5019 // on the StartBss Response, LIM is returning the Bss Description that we
5020 // are beaconing. Add this Bss Description to our scan results and
5021 // chain the Profile to this Bss Description. On a Start BSS, there was no
5022 // detected Bss description (no partner) so we issued the Start Bss to
5023 // start the Ibss without any Bss description. Lim was kind enough to return
5024 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005025 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005026 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005027 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Jeff Johnson295189b2012-06-20 16:38:30 -07005028 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5029 if( CSR_IS_IBSS( pProfile ) )
5030 {
5031 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5032 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005033 else if (CSR_IS_INFRA_AP(pProfile))
5034 {
5035 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5036 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005037 else
5038 {
5039 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5040 }
5041 if( !CSR_IS_WDS_STA( pProfile ) )
5042 {
5043 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005044 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005045 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5046 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005047 smsLog(pMac, LOG2, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005048 roamInfo.pBssDesc = pSirBssDesc;
5049 //We need to associate_complete it first, becasue Associate_start already indicated.
5050 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5051 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5052 break;
5053 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005054 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005055 {
5056 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes );
5057 }
5058 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5059 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5060 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5061 if(pSirBssDesc)
5062 {
5063 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5064 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
5065 }
5066 //We are doen with the IEs so free it
5067 palFreeMemory(pMac->hHdd, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005068#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5069 {
5070 vos_log_ibss_pkt_type *pIbssLog;
5071 tANI_U32 bi;
5072
5073 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5074 if(pIbssLog)
5075 {
5076 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5077 {
5078 //We start the IBSS (didn't find any matched IBSS out there)
5079 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
5080 }
5081 else
5082 {
5083 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
5084 }
5085 if(pSirBssDesc)
5086 {
5087 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pSirBssDesc->bssId, 6);
5088 pIbssLog->operatingChannel = pSirBssDesc->channelId;
5089 }
5090 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
5091 {
5092 //***U8 is not enough for beacon interval
5093 pIbssLog->beaconInterval = (v_U8_t)bi;
5094 }
5095 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5096 }
5097 }
5098#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5099 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
5100 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07005101 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
5102 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005103 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
5104 csrRoamIssueSetContextReq( pMac, sessionId,
5105 pProfile->negotiatedMCEncryptionType,
5106 pSirBssDesc, &BroadcastMac,
5107 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5108 }
5109 }
5110 else
5111 {
5112 //Keep the state to eCSR_ROAMING_STATE_JOINING
5113 //Need to send join_req.
5114 if(pCommand->u.roamCmd.pRoamBssEntry)
5115 {
5116 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
5117 {
5118 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5119 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5120 // Set the roaming substate to 'join attempt'...
5121 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08005122 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005123 }
5124 }
5125 else
5126 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005127 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07005128 VOS_ASSERT( 0 );
5129 }
5130 }
5131 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5132 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5133 //trigger the connection start indication in Vista
5134 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
5135 {
5136 roamStatus = eCSR_ROAM_IBSS_IND;
5137 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5138 if( CSR_IS_WDS( pProfile ) )
5139 {
5140 roamStatus = eCSR_ROAM_WDS_IND;
5141 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5142 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005143 if( CSR_IS_INFRA_AP( pProfile ) )
5144 {
5145 roamStatus = eCSR_ROAM_INFRA_IND;
5146 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
5147 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005148
5149 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5150 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5151 //trigger the connection start indication in Vista
5152 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5153 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5154 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5155 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5156 {
5157 //We start the IBSS (didn't find any matched IBSS out there)
5158 roamInfo.pBssDesc = pSirBssDesc;
5159 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005160 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005161 //Remove this code once SLM_Sessionization is supported
5162 //BMPS_WORKAROUND_NOT_NEEDED
5163 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005164 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005165 {
5166 pMac->roam.configParam.doBMPSWorkaround = 1;
5167 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005168
Jeff Johnson295189b2012-06-20 16:38:30 -07005169 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5170 }
5171
5172 csrScanCancelIdleScan(pMac);
5173 //Only use this timer for ibss. BAP has its own timer for WDS
5174 if( CSR_IS_IBSS( pProfile) && CSR_INVALID_SCANRESULT_HANDLE != pCommand->u.roamCmd.hBSSList)
5175 {
5176 //start the join IBSS timer
5177 csrRoamStartIbssJoinTimer(pMac, sessionId, CSR_IBSS_JOIN_TIMEOUT_PERIOD); //interval
5178 pSession->ibss_join_pending = TRUE;
5179 }
5180 if( HAL_STATUS_SUCCESS( status ) )
5181 {
5182 //Already sent join_req for the WDS station
5183 fReleaseCommand = eANI_BOOLEAN_FALSE;
5184 }
5185 else if( CSR_IS_WDS_STA( pProfile ) )
5186 {
5187 //need to send stop BSS because we fail to send join_req
5188 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5189 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5190 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5191 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005192 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005193 case eCsrStartBssFailure:
5194#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5195 {
5196 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005197 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5198 if(pIbssLog)
5199 {
5200 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5201 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5202 }
5203 }
5204#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005205 roamStatus = eCSR_ROAM_IBSS_IND;
5206 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5207 if( CSR_IS_WDS( pProfile ) )
5208 {
5209 roamStatus = eCSR_ROAM_WDS_IND;
5210 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5211 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005212 if( CSR_IS_INFRA_AP( pProfile ) )
5213 {
5214 roamStatus = eCSR_ROAM_INFRA_IND;
5215 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5216 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005217 if(Context)
5218 {
5219 pSirBssDesc = (tSirBssDescription *)Context;
5220 }
5221 else
5222 {
5223 pSirBssDesc = NULL;
5224 }
5225 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5226 roamInfo.pBssDesc = pSirBssDesc;
5227 //We need to associate_complete it first, becasue Associate_start already indicated.
5228 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5229 csrSetDefaultDot11Mode( pMac );
5230 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005231 case eCsrSilentlyStopRoaming:
5232 // We are here because we try to start the same IBSS
5233 //No message to PE
5234 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005235 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005236 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5237 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5238 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5239 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5240 if( roamInfo.pBssDesc )
5241 {
5242 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &roamInfo.pBssDesc->bssId, sizeof(tCsrBssid));
5243 }
5244 //Since there is no change in the current state, simply pass back no result otherwise
5245 //HDD may be mistakenly mark to disconnected state.
5246 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5247 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005248 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005249 case eCsrSilentlyStopRoamingSaveState:
5250 //We are here because we try to connect to the same AP
5251 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005252 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005253 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
5254
5255 //to aviod resetting the substate to NONE
5256 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5257 //No need to change substate to wai_for_key because there is no state change
5258 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5259 if( roamInfo.pBssDesc )
5260 {
5261 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &roamInfo.pBssDesc->bssId, sizeof(tCsrBssid));
5262 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005263 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5264 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5265 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5266 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5267 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5268 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5269 roamInfo.staId = pSession->connectedInfo.staId;
5270 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005271 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005272 pSession->bRefAssocStartCnt--;
5273 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5274 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5275 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5276 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005277 case eCsrReassocFailure:
5278#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5279 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5280#endif
5281 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005282 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005283 csrFreeConnectBssDesc(pMac, sessionId);
5284 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5285 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5286 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5287 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5288 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5289 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5290 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5291 eCSR_ROAM_WDS_IND,
5292 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5293 //Need to issue stop_bss
5294 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005295 case eCsrJoinFailure:
5296 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07005297 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07005298 default:
5299 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005300 smsLog(pMac, LOGW, FL("receives no association indication"));
5301 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07005302 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07005303 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
5304 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
5305 {
5306 //do not free for the other profiles as we need to send down stop BSS later
5307 csrFreeConnectBssDesc(pMac, sessionId);
5308 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5309 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5310 csrSetDefaultDot11Mode( pMac );
5311 }
5312
5313 switch( pCommand->u.roamCmd.roamReason )
5314 {
5315 // If this transition is because of an 802.11 OID, then we transition
5316 // back to INIT state so we sit waiting for more OIDs to be issued and
5317 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07005318 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005319 case eCsrSmeIssuedAssocToSimilarAP:
5320 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08005321 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07005322 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5323 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5324 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5325 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5326 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005327 /* Defeaturize this later if needed */
5328#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5329 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
5330 if (csrRoamIsHandoffInProgress(pMac))
5331 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005332 /* Should indicate neighbor roam algorithm about the connect failure here */
5333 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
5334 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005335#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005336 if(pSession->bRefAssocStartCnt > 0)
5337 {
5338 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07005339 if(eCsrJoinFailureDueToConcurrency == Result)
5340 {
5341 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5342 eCSR_ROAM_ASSOCIATION_COMPLETION,
5343 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
5344 }
5345 else
5346 {
5347 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005348 eCSR_ROAM_ASSOCIATION_COMPLETION,
5349 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07005350 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005351 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005352 else
5353 {
5354 /* bRefAssocStartCnt is not incremented when
5355 * eRoamState == eCsrStopRoamingDueToConcurrency
5356 * in csrRoamJoinNextBss API. so handle this in
5357 * else case by sending assoc failure
5358 */
5359 csrRoamCallCallback(pMac, sessionId, NULL,
5360 pCommand->u.scanCmd.roamId,
5361 eCSR_ROAM_ASSOCIATION_FAILURE,
5362 eCSR_ROAM_RESULT_FAILURE);
5363 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005364 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07005365#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5366 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5367#endif
5368 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5369 csrScanStartIdleScan(pMac);
5370#ifdef FEATURE_WLAN_BTAMP_UT_RF
5371 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
5372 //BT activity and not able to recevie WLAN traffic. Retry the join
5373 if( CSR_IS_WDS_STA(pProfile) )
5374 {
5375 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
5376 }
5377#endif
5378 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005379 case eCsrHddIssuedReassocToSameAP:
5380 case eCsrSmeIssuedReassocToSameAP:
5381 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5382
5383 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5384#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5385 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5386#endif
5387 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5388 csrScanStartIdleScan(pMac);
5389 break;
5390 case eCsrForcedDisassoc:
5391 case eCsrForcedDeauth:
5392 case eCsrSmeIssuedIbssJoinFailure:
5393 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5394
5395 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
5396 {
5397 // Notify HDD that IBSS join failed
5398 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
5399 }
5400 else
5401 {
5402 csrRoamCallCallback(pMac, sessionId, NULL,
5403 pCommand->u.roamCmd.roamId,
5404 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5405 }
5406#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5407 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5408#endif
5409 csrRoamLinkDown(pMac, sessionId);
5410 csrScanStartIdleScan(pMac);
5411 break;
5412 case eCsrForcedIbssLeave:
5413 csrRoamCallCallback(pMac, sessionId, NULL,
5414 pCommand->u.roamCmd.roamId,
5415 eCSR_ROAM_IBSS_LEAVE,
5416 eCSR_ROAM_RESULT_IBSS_STOP);
5417 break;
5418 case eCsrForcedDisassocMICFailure:
5419 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5420
5421 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
5422#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5423 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
5424#endif
5425 csrScanStartIdleScan(pMac);
5426 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005427 case eCsrStopBss:
5428 csrRoamCallCallback(pMac, sessionId, NULL,
5429 pCommand->u.roamCmd.roamId,
5430 eCSR_ROAM_INFRA_IND,
5431 eCSR_ROAM_RESULT_INFRA_STOPPED);
5432 break;
5433 case eCsrForcedDisassocSta:
5434 case eCsrForcedDeauthSta:
5435 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
5436 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
5437 {
5438 pSession = CSR_GET_SESSION(pMac, sessionId);
5439 if (!pSession)
5440 break;
5441
5442 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
5443 {
5444 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5445 palCopyMemory(pMac->hHdd, roamInfo.peerMac,
5446 pCommand->u.roamCmd.peerMac, sizeof(tSirMacAddr));
5447 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
5448 roamInfo.statusCode = eSIR_SME_SUCCESS;
5449 status = csrRoamCallCallback(pMac, sessionId,
5450 &roamInfo, pCommand->u.roamCmd.roamId,
5451 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
5452 }
5453 }
5454 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005455 case eCsrLostLink1:
5456 // if lost link roam1 failed, then issue lost link Scan2 ...
5457 csrScanRequestLostLink2(pMac, sessionId);
5458 break;
5459 case eCsrLostLink2:
5460 // if lost link roam2 failed, then issue lost link scan3 ...
5461 csrScanRequestLostLink3(pMac, sessionId);
5462 break;
5463 case eCsrLostLink3:
5464 default:
5465 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5466
5467 //We are done with one round of lostlink roaming here
5468 csrScanHandleFailedLostlink3(pMac, sessionId);
5469 break;
5470 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005471 break;
5472 }
5473 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005474 return ( fReleaseCommand );
5475}
5476
Jeff Johnson295189b2012-06-20 16:38:30 -07005477eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
5478{
5479 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005480 return (status);
5481}
5482
Jeff Johnson295189b2012-06-20 16:38:30 -07005483eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
5484{
5485 eHalStatus status = eHAL_STATUS_SUCCESS;
5486 tANI_U32 size = 0;
5487
5488 do
5489 {
5490 palZeroMemory(pMac->hHdd, pDstProfile, sizeof(tCsrRoamProfile));
5491 if(pSrcProfile->BSSIDs.numOfBSSIDs)
5492 {
5493 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
5494 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->BSSIDs.bssid, size);
5495 if(!HAL_STATUS_SUCCESS(status))
5496 {
5497 break;
5498 }
5499 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
5500 palCopyMemory(pMac->hHdd, pDstProfile->BSSIDs.bssid, pSrcProfile->BSSIDs.bssid, size);
5501 }
5502 if(pSrcProfile->SSIDs.numOfSSIDs)
5503 {
5504 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
5505 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->SSIDs.SSIDList, size);
5506 if(!HAL_STATUS_SUCCESS(status))
5507 {
5508 break;
5509 }
5510 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
5511 palCopyMemory(pMac->hHdd, pDstProfile->SSIDs.SSIDList, pSrcProfile->SSIDs.SSIDList, size);
5512 }
5513 if(pSrcProfile->nWPAReqIELength)
5514 {
5515 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pWPAReqIE, pSrcProfile->nWPAReqIELength);
5516 if(!HAL_STATUS_SUCCESS(status))
5517 {
5518 break;
5519 }
5520 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
5521 palCopyMemory(pMac->hHdd, pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE, pSrcProfile->nWPAReqIELength);
5522 }
5523 if(pSrcProfile->nRSNReqIELength)
5524 {
5525 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pRSNReqIE, pSrcProfile->nRSNReqIELength);
5526 if(!HAL_STATUS_SUCCESS(status))
5527 {
5528 break;
5529 }
5530 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
5531 palCopyMemory(pMac->hHdd, pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE, pSrcProfile->nRSNReqIELength);
5532 }
5533#ifdef FEATURE_WLAN_WAPI
5534 if(pSrcProfile->nWAPIReqIELength)
5535 {
5536 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pWAPIReqIE, pSrcProfile->nWAPIReqIELength);
5537 if(!HAL_STATUS_SUCCESS(status))
5538 {
5539 break;
5540 }
5541 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
5542 palCopyMemory(pMac->hHdd, pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE, pSrcProfile->nWAPIReqIELength);
5543 }
5544#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07005545 if(pSrcProfile->nAddIEScanLength)
5546 {
5547 status = palAllocateMemory(pMac->hHdd,
5548 (void **)&pDstProfile->pAddIEScan, pSrcProfile->nAddIEScanLength);
5549 if(!HAL_STATUS_SUCCESS(status))
5550 {
5551 break;
5552 }
5553 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
5554 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEScan, pSrcProfile->pAddIEScan,
5555 pSrcProfile->nAddIEScanLength);
5556 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005557 if(pSrcProfile->nAddIEAssocLength)
5558 {
5559 status = palAllocateMemory(pMac->hHdd,
5560 (void **)&pDstProfile->pAddIEAssoc, pSrcProfile->nAddIEAssocLength);
5561 if(!HAL_STATUS_SUCCESS(status))
5562 {
5563 break;
5564 }
5565 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
5566 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
5567 pSrcProfile->nAddIEAssocLength);
5568 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005569 if(pSrcProfile->ChannelInfo.ChannelList)
5570 {
5571 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.numOfChannels);
5572 if(!HAL_STATUS_SUCCESS(status))
5573 {
5574 break;
5575 }
5576 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
5577 palCopyMemory(pMac->hHdd, pDstProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.numOfChannels);
5578 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005579 pDstProfile->AuthType = pSrcProfile->AuthType;
5580 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
5581 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
5582 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
5583 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
5584 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
5585 pDstProfile->BSSType = pSrcProfile->BSSType;
5586 pDstProfile->phyMode = pSrcProfile->phyMode;
5587 pDstProfile->csrPersona = pSrcProfile->csrPersona;
5588
5589#ifdef FEATURE_WLAN_WAPI
5590 if(csrIsProfileWapi(pSrcProfile))
5591 {
5592 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
5593 {
5594 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
5595 }
5596 }
5597#endif /* FEATURE_WLAN_WAPI */
5598 pDstProfile->CBMode = pSrcProfile->CBMode;
5599 /*Save the WPS info*/
5600 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
5601 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005602 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07005603 pDstProfile->privacy = pSrcProfile->privacy;
5604 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
5605 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
5606 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
5607 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
5608 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
5609 pDstProfile->protEnabled = pSrcProfile->protEnabled;
5610 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
5611 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
5612 pDstProfile->wps_state = pSrcProfile->wps_state;
5613 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Jeff Johnson295189b2012-06-20 16:38:30 -07005614 palCopyMemory(pMac->hHdd, &pDstProfile->Keys, &pSrcProfile->Keys, sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07005615#ifdef WLAN_FEATURE_VOWIFI_11R
5616 if (pSrcProfile->MDID.mdiePresent)
5617 {
5618 pDstProfile->MDID.mdiePresent = 1;
5619 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
5620 }
5621#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005622 }while(0);
5623
5624 if(!HAL_STATUS_SUCCESS(status))
5625 {
5626 csrReleaseProfile(pMac, pDstProfile);
5627 pDstProfile = NULL;
5628 }
5629
5630 return (status);
5631}
Jeff Johnson295189b2012-06-20 16:38:30 -07005632eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
5633{
5634 eHalStatus status = eHAL_STATUS_SUCCESS;
5635 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
5636 do
5637 {
5638 palZeroMemory(pMac->hHdd, pDstProfile, sizeof(tCsrRoamProfile));
5639 if(pSrcProfile->bssid)
5640 {
5641 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->BSSIDs.bssid, sizeof(tCsrBssid));
5642 if(!HAL_STATUS_SUCCESS(status))
5643 {
5644 break;
5645 }
5646 pDstProfile->BSSIDs.numOfBSSIDs = 1;
5647 palCopyMemory(pMac->hHdd, pDstProfile->BSSIDs.bssid, pSrcProfile->bssid, sizeof(tCsrBssid));
5648 }
5649 if(pSrcProfile->SSID.ssId)
5650 {
5651 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->SSIDs.SSIDList, sizeof(tCsrSSIDInfo));
5652 if(!HAL_STATUS_SUCCESS(status))
5653 {
5654 break;
5655 }
5656 pDstProfile->SSIDs.numOfSSIDs = 1;
5657 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
5658 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
5659 palCopyMemory(pMac->hHdd, &pDstProfile->SSIDs.SSIDList[0].SSID, &pSrcProfile->SSID, sizeof(tSirMacSSid));
5660 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07005661 if(pSrcProfile->nAddIEAssocLength)
5662 {
5663 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pAddIEAssoc, pSrcProfile->nAddIEAssocLength);
5664 if(!HAL_STATUS_SUCCESS(status))
5665 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005666 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07005667 break;
5668 }
5669 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
5670 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
5671 pSrcProfile->nAddIEAssocLength);
5672 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005673 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->ChannelInfo.ChannelList, 1);
5674 if(!HAL_STATUS_SUCCESS(status))
5675 {
5676 break;
5677 }
5678 pDstProfile->ChannelInfo.numOfChannels = 1;
5679 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07005680 pDstProfile->AuthType.numEntries = 1;
5681 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
5682 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
5683 pDstProfile->EncryptionType.numEntries = 1;
5684 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
5685 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
5686 pDstProfile->mcEncryptionType.numEntries = 1;
5687 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
5688 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
5689 pDstProfile->BSSType = pSrcProfile->BSSType;
5690 pDstProfile->CBMode = pSrcProfile->CBMode;
5691 palCopyMemory(pMac->hHdd, &pDstProfile->Keys, &pSrcProfile->Keys, sizeof(pDstProfile->Keys));
5692#ifdef WLAN_FEATURE_VOWIFI_11R
5693 if (pSrcProfile->MDID.mdiePresent)
5694 {
5695 pDstProfile->MDID.mdiePresent = 1;
5696 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
5697 }
5698#endif
5699
5700 }while(0);
5701
5702 if(!HAL_STATUS_SUCCESS(status))
5703 {
5704 csrReleaseProfile(pMac, pDstProfile);
5705 pDstProfile = NULL;
5706 }
5707
5708 return (status);
5709}
5710
Jeff Johnson295189b2012-06-20 16:38:30 -07005711eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5712 tScanResultHandle hBSSList,
5713 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
5714 tANI_BOOLEAN fClearScan)
5715{
5716 eHalStatus status = eHAL_STATUS_SUCCESS;
5717 tSmeCmd *pCommand;
5718
5719 pCommand = csrGetCommandBuffer(pMac);
5720 if(NULL == pCommand)
5721 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005722 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005723 status = eHAL_STATUS_RESOURCES;
5724 }
5725 else
5726 {
5727 if( fClearScan )
5728 {
5729 csrScanCancelIdleScan(pMac);
5730 csrScanAbortMacScanNotForConnect(pMac);
5731 }
5732 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
5733 if(NULL == pProfile)
5734 {
5735 //We can roam now
5736 //Since pProfile is NULL, we need to build our own profile, set everything to default
5737 //We can only support open and no encryption
5738 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
5739 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5740 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
5741 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5742 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
5743 }
5744 else
5745 {
5746 //make a copy of the profile
5747 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
5748 if(HAL_STATUS_SUCCESS(status))
5749 {
5750 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
5751 }
5752 }
5753 pCommand->command = eSmeCommandRoam;
5754 pCommand->sessionId = (tANI_U8)sessionId;
5755 pCommand->u.roamCmd.hBSSList = hBSSList;
5756 pCommand->u.roamCmd.roamId = roamId;
5757 pCommand->u.roamCmd.roamReason = reason;
5758 //We need to free the BssList when the command is done
5759 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
5760 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005761 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
5762 FL("CSR PERSONA=%d"),
5763 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07005764 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
5765 if( !HAL_STATUS_SUCCESS( status ) )
5766 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005767 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005768 csrReleaseCommandRoam( pMac, pCommand );
5769 }
5770 }
5771
5772 return (status);
5773}
Jeff Johnson295189b2012-06-20 16:38:30 -07005774eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5775 tCsrRoamModifyProfileFields *pMmodProfileFields,
5776 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
5777{
5778 eHalStatus status = eHAL_STATUS_SUCCESS;
5779 tSmeCmd *pCommand;
5780
5781 pCommand = csrGetCommandBuffer(pMac);
5782 if(NULL == pCommand)
5783 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005784 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005785 status = eHAL_STATUS_RESOURCES;
5786 }
5787 else
5788 {
5789 csrScanCancelIdleScan(pMac);
5790 csrScanAbortMacScanNotForConnect(pMac);
5791 if(pProfile)
5792 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005793 //This is likely trying to reassoc to different profile
5794 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
5795 //make a copy of the profile
5796 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
5797 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005798 }
5799 else
5800 {
5801 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
5802 //how to update WPA/WPA2 info in roamProfile??
5803 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005804 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005805 if(HAL_STATUS_SUCCESS(status))
5806 {
5807 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
5808 }
5809 pCommand->command = eSmeCommandRoam;
5810 pCommand->sessionId = (tANI_U8)sessionId;
5811 pCommand->u.roamCmd.roamId = roamId;
5812 pCommand->u.roamCmd.roamReason = reason;
5813 //We need to free the BssList when the command is done
5814 //For reassoc there is no BSS list, so the boolean set to false
5815 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
5816 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
5817 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005818 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
5819 if( !HAL_STATUS_SUCCESS( status ) )
5820 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005821 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07005822 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5823 csrReleaseCommandRoam( pMac, pCommand );
5824 }
5825 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005826 return (status);
5827}
5828
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005829eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
5830 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
5831// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
5832{
5833 eHalStatus status = eHAL_STATUS_SUCCESS;
5834 tSmeCmd *pCommand;
5835
5836 pCommand = csrGetCommandBuffer(pMac);
5837 if(NULL == pCommand)
5838 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005839 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005840 status = eHAL_STATUS_RESOURCES;
5841 }
5842 else
5843 {
5844 if(pBssDescription)
5845 {
5846 //copy over the parameters we need later
5847 pCommand->command = eSmeCommandRoam;
5848 pCommand->sessionId = (tANI_U8)sessionId;
5849 pCommand->u.roamCmd.roamReason = reason;
5850 //this is the important parameter
5851 //in this case we are using this field for the "next" BSS
5852 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
5853 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
5854 if( !HAL_STATUS_SUCCESS( status ) )
5855 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005856 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005857 csrReleaseCommandPreauth( pMac, pCommand );
5858 }
5859 }
5860 else
5861 {
5862 //Return failure
5863 status = eHAL_STATUS_RESOURCES;
5864 }
5865 }
5866 return (status);
5867}
5868
5869eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
5870{
5871 tListElem *pEntry;
5872 tSmeCmd *pCommand;
5873 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
5874 if ( pEntry )
5875 {
5876 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
5877 if ( (eSmeCommandRoam == pCommand->command) &&
5878 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
5879 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08005880 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005881 pCommand->command, pCommand->u.roamCmd.roamReason);
5882 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
5883 csrReleaseCommandPreauth( pMac, pCommand );
5884 }
5885 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005886 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005887 pCommand->command, pCommand->u.roamCmd.roamReason);
5888 }
5889 }
5890 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005891 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005892 }
5893 smeProcessPendingQueue( pMac );
5894 return eHAL_STATUS_SUCCESS;
5895}
5896
Jeff Johnson295189b2012-06-20 16:38:30 -07005897eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5898 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
5899{
5900 eHalStatus status = eHAL_STATUS_FAILURE;
5901 tScanResultHandle hBSSList;
5902 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005903 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
5904 if(HAL_STATUS_SUCCESS(status))
5905 {
5906 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
5907 if(pRoamId)
5908 {
5909 *pRoamId = roamId;
5910 }
5911 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
5912 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
5913 if(!HAL_STATUS_SUCCESS(status))
5914 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005915 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005916 csrScanResultPurge(pMac, hBSSList);
5917 }
5918 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005919 return (status);
5920}
5921
Jeff Johnson295189b2012-06-20 16:38:30 -07005922eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5923 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
5924{
5925 eHalStatus status = eHAL_STATUS_SUCCESS;
5926 tScanResultHandle hBSSList;
5927 tCsrScanResultFilter *pScanFilter;
5928 tANI_U32 roamId = 0;
5929 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
5930 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005931 if (NULL == pProfile)
5932 {
5933 smsLog(pMac, LOGP, FL("No profile specified"));
5934 return eHAL_STATUS_FAILURE;
5935 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005936 smsLog(pMac, LOG1, FL("called BSSType = %d authtype = %d encryType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005937 pProfile->BSSType, pProfile->AuthType.authType[0], pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005938 if( CSR_IS_WDS( pProfile ) &&
5939 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
5940 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005941 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005942 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07005943 return status;
5944 }
5945 csrRoamCancelRoaming(pMac, sessionId);
5946 csrScanRemoveFreshScanCommand(pMac, sessionId);
5947 csrScanCancelIdleScan(pMac);
5948 //Only abort the scan if it is not used for other roam/connect purpose
5949 csrScanAbortMacScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07005950 if (!vos_concurrent_sessions_running() && (VOS_STA_SAP_MODE == pProfile->csrPersona))//In case of AP mode we do not want idle mode scan
5951 {
5952 csrScanDisable(pMac);
5953 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005954 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
5955 //Check whether ssid changes
5956 if(csrIsConnStateConnected(pMac, sessionId))
5957 {
5958 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
5959 {
5960 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
5961 }
5962 }
5963#ifdef FEATURE_WLAN_BTAMP_UT_RF
5964 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
5965#endif
5966 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
5967 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005968 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005969 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
5970 if(pRoamId)
5971 {
5972 roamId = *pRoamId;
5973 }
5974 if(!HAL_STATUS_SUCCESS(status))
5975 {
5976 fCallCallback = eANI_BOOLEAN_TRUE;
5977 }
5978 }
5979 else
5980 {
5981 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
5982 if(HAL_STATUS_SUCCESS(status))
5983 {
5984 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
5985 //Try to connect to any BSS
5986 if(NULL == pProfile)
5987 {
5988 //No encryption
5989 pScanFilter->EncryptionType.numEntries = 1;
5990 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5991 }//we don't have a profile
5992 else
5993 {
5994 //Here is the profile we need to connect to
5995 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
5996 }//We have a profile
5997 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
5998 if(pRoamId)
5999 {
6000 *pRoamId = roamId;
6001 }
6002
6003 if(HAL_STATUS_SUCCESS(status))
6004 {
6005 /*Save the WPS info*/
6006 if(NULL != pProfile)
6007 {
6008 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
6009 }
6010 else
6011 {
6012 pScanFilter->bWPSAssociation = 0;
6013 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006014 do
6015 {
6016 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006017 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006018 )
6019 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006020 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07006021 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6022 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6023 if(!HAL_STATUS_SUCCESS(status))
6024 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006025 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006026 fCallCallback = eANI_BOOLEAN_TRUE;
6027 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006028 else
6029 {
6030 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
6031 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006032 break;
6033 }
6034 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006035 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006036 if(HAL_STATUS_SUCCESS(status))
6037 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006038 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6039 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6040 if(!HAL_STATUS_SUCCESS(status))
6041 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006042 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006043 csrScanResultPurge(pMac, hBSSList);
6044 fCallCallback = eANI_BOOLEAN_TRUE;
6045 }
6046 }//Have scan result
6047 else if(NULL != pProfile)
6048 {
6049 //Check whether it is for start ibss
6050 if(CSR_IS_START_IBSS(pProfile))
6051 {
6052 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6053 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6054 if(!HAL_STATUS_SUCCESS(status))
6055 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006056 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006057 fCallCallback = eANI_BOOLEAN_TRUE;
6058 }
6059 }
6060 else
6061 {
6062 //scan for this SSID
6063 status = csrScanForSSID(pMac, sessionId, pProfile, roamId);
6064 if(!HAL_STATUS_SUCCESS(status))
6065 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006066 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006067 fCallCallback = eANI_BOOLEAN_TRUE;
6068 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006069 else
6070 {
6071 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
6072 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006073 }
6074 }
6075 else
6076 {
6077 fCallCallback = eANI_BOOLEAN_TRUE;
6078 }
6079 } while (0);
6080 if(NULL != pProfile)
6081 {
6082 //we need to free memory for filter if profile exists
6083 csrFreeScanFilter(pMac, pScanFilter);
6084 }
6085 }//Got the scan filter from profile
6086
6087 palFreeMemory(pMac->hHdd, pScanFilter);
6088 }//allocated memory for pScanFilter
6089 }//No Bsslist coming in
6090 //tell the caller if we fail to trigger a join request
6091 if( fCallCallback )
6092 {
6093 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6094 }
6095
6096 return (status);
6097}
Jeff Johnson295189b2012-06-20 16:38:30 -07006098eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6099 tCsrRoamModifyProfileFields modProfileFields,
6100 tANI_U32 *pRoamId)
6101{
6102 eHalStatus status = eHAL_STATUS_SUCCESS;
6103 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
6104 tANI_U32 roamId = 0;
6105 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006106 if (NULL == pProfile)
6107 {
6108 smsLog(pMac, LOGP, FL("No profile specified"));
6109 return eHAL_STATUS_FAILURE;
6110 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006111 smsLog(pMac, LOG1, FL("called BSSType = %d authtype = %d encryType = %d"), pProfile->BSSType, pProfile->AuthType.authType[0], pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006112 csrRoamCancelRoaming(pMac, sessionId);
6113 csrScanRemoveFreshScanCommand(pMac, sessionId);
6114 csrScanCancelIdleScan(pMac);
6115 csrScanAbortMacScanNotForConnect(pMac);
6116 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07006117 if(csrIsConnStateConnected(pMac, sessionId))
6118 {
6119 if(pProfile)
6120 {
6121 if(pProfile->SSIDs.numOfSSIDs &&
6122 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6123 {
6124 fCallCallback = eANI_BOOLEAN_FALSE;
6125 }
6126 else
6127 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006128 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006129 }
6130 }
6131 else if(!palEqualMemory(pMac->hHdd, &modProfileFields,
6132 &pSession->connectedProfile.modifyProfileFields,
6133 sizeof(tCsrRoamModifyProfileFields)))
6134 {
6135 fCallCallback = eANI_BOOLEAN_FALSE;
6136 }
6137 else
6138 {
6139 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006140 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006141 }
6142 }
6143 else
6144 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006145 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006146 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006147 if(!fCallCallback)
6148 {
6149 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6150 if(pRoamId)
6151 {
6152 *pRoamId = roamId;
6153 }
6154
Jeff Johnson295189b2012-06-20 16:38:30 -07006155 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6156 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006157 }
6158 else
6159 {
6160 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6161 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6162 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006163 return status;
6164}
Jeff Johnson295189b2012-06-20 16:38:30 -07006165eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6166{
6167 eHalStatus status = eHAL_STATUS_FAILURE;
6168 tScanResultHandle hBSSList = NULL;
6169 tCsrScanResultFilter *pScanFilter = NULL;
6170 tANI_U32 roamId;
6171 tCsrRoamProfile *pProfile = NULL;
6172 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006173
6174 if(!pSession)
6175 {
6176 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6177 return eHAL_STATUS_FAILURE;
6178 }
6179
Jeff Johnson295189b2012-06-20 16:38:30 -07006180 do
6181 {
6182 if(pSession->pCurRoamProfile)
6183 {
6184 csrScanCancelIdleScan(pMac);
6185 csrScanAbortMacScanNotForConnect(pMac);
6186 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
6187 status = palAllocateMemory(pMac->hHdd, (void **)&pProfile, sizeof(tCsrRoamProfile));
6188 if(!HAL_STATUS_SUCCESS(status))
6189 break;
6190 palZeroMemory(pMac->hHdd, pProfile, sizeof(tCsrRoamProfile));
6191 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
6192 if(!HAL_STATUS_SUCCESS(status))
6193 break;
6194 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
6195 if(!HAL_STATUS_SUCCESS(status))
6196 {
6197 break;
6198 }
6199 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
6200 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6201 if(!HAL_STATUS_SUCCESS(status))
6202 {
6203 break;
6204 }
6205 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6206 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6207 if(HAL_STATUS_SUCCESS(status))
6208 {
6209 //we want to put the last connected BSS to the very beginning, if possible
6210 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
6211 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6212 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6213 if(!HAL_STATUS_SUCCESS(status))
6214 {
6215 csrScanResultPurge(pMac, hBSSList);
6216 break;
6217 }
6218 }
6219 else
6220 {
6221 //Do a scan on this profile
6222 //scan for this SSID only in case the AP suppresses SSID
6223 status = csrScanForSSID(pMac, sessionId, pProfile, roamId);
6224 if(!HAL_STATUS_SUCCESS(status))
6225 {
6226 break;
6227 }
6228 }
6229 }//We have a profile
6230 else
6231 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006232 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006233 break;
6234 }
6235 }while(0);
6236 if(pScanFilter)
6237 {
6238 csrFreeScanFilter(pMac, pScanFilter);
6239 palFreeMemory(pMac->hHdd, pScanFilter);
6240 }
6241 if(NULL != pProfile)
6242 {
6243 csrReleaseProfile(pMac, pProfile);
6244 palFreeMemory(pMac->hHdd, pProfile);
6245 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006246 return (status);
6247}
Jeff Johnson295189b2012-06-20 16:38:30 -07006248eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
6249{
6250 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006251 if(csrIsConnStateConnected(pMac, sessionId))
6252 {
6253 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6254 if(HAL_STATUS_SUCCESS(status))
6255 {
6256 status = csrRoamJoinLastProfile(pMac, sessionId);
6257 }
6258 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006259 return (status);
6260}
6261
Jeff Johnson295189b2012-06-20 16:38:30 -07006262eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6263{
6264 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006265 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006266 csrRoamCancelRoaming(pMac, sessionId);
6267 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6268 if(csrIsConnStateDisconnected(pMac, sessionId))
6269 {
6270 status = csrRoamJoinLastProfile(pMac, sessionId);
6271 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006272 return (status);
6273}
6274
Jeff Johnson295189b2012-06-20 16:38:30 -07006275eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
6276{
6277 eHalStatus status = eHAL_STATUS_SUCCESS;
6278 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
6279 eCsrRoamSubState NewSubstate;
6280 tANI_U32 sessionId = pCommand->sessionId;
6281
6282 // change state to 'Roaming'...
6283 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
6284
6285 if ( csrIsConnStateIbss( pMac, sessionId ) )
6286 {
6287 // If we are in an IBSS, then stop the IBSS...
6288 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6289 fComplete = (!HAL_STATUS_SUCCESS(status));
6290 }
6291 else if ( csrIsConnStateInfra( pMac, sessionId ) )
6292 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006293 smsLog(pMac, LOG1, FL(" restore AC weights (%d-%d-%d-%d)"), pMac->roam.ucACWeights[0], pMac->roam.ucACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07006294 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
6295 //Restore AC weight in case we change it
6296 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
6297 // in Infrasturcture, we need to disassociate from the Infrastructure network...
6298 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
6299 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
6300 {
6301 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
6302 }
6303 if( fDisassoc )
6304 {
6305 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
6306 }
6307 else
6308 {
6309 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
6310 }
6311 fComplete = (!HAL_STATUS_SUCCESS(status));
6312 }
6313 else if ( csrIsConnStateWds( pMac, sessionId ) )
6314 {
6315 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
6316 {
6317 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6318 fComplete = (!HAL_STATUS_SUCCESS(status));
6319 }
6320 //This has to be WDS station
6321 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
6322 {
6323
6324 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6325 if( fDisassoc )
6326 {
6327 status = csrRoamIssueDisassociate( pMac, sessionId,
6328 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
6329 fComplete = (!HAL_STATUS_SUCCESS(status));
6330 }
6331 }
6332 } else {
6333 // we got a dis-assoc request while not connected to any peer
6334 // just complete the command
6335 fComplete = eANI_BOOLEAN_TRUE;
6336 status = eHAL_STATUS_FAILURE;
6337 }
6338 if(fComplete)
6339 {
6340 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6341 }
6342
6343 if(HAL_STATUS_SUCCESS(status))
6344 {
6345 if ( csrIsConnStateInfra( pMac, sessionId ) )
6346 {
6347 //Set the state to disconnect here
6348 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
6349 }
6350 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006351 else
6352 {
6353 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
6354 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006355 return (status);
6356}
6357
Jeff Johnson295189b2012-06-20 16:38:30 -07006358/* This is been removed from latest code base */
6359/*
6360static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
6361{
6362 eHalStatus status;
6363 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07006364 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
6365 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006366 return ( status );
6367}
6368*/
6369
Jeff Johnson295189b2012-06-20 16:38:30 -07006370eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
6371{
6372 eHalStatus status = eHAL_STATUS_SUCCESS;
6373 tSmeCmd *pCommand;
6374 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006375 do
6376 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006377 smsLog( pMac, LOG1, FL(" reason = %d"), reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07006378 pCommand = csrGetCommandBuffer( pMac );
6379 if ( !pCommand )
6380 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006381 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006382 status = eHAL_STATUS_RESOURCES;
6383 break;
6384 }
6385 //Change the substate in case it is wait-for-key
6386 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
6387 {
6388 csrRoamStopWaitForKeyTimer( pMac );
6389 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6390 }
6391 pCommand->command = eSmeCommandRoam;
6392 pCommand->sessionId = (tANI_U8)sessionId;
6393 switch ( reason )
6394 {
6395 case eCSR_DISCONNECT_REASON_MIC_ERROR:
6396 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
6397 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006398 case eCSR_DISCONNECT_REASON_DEAUTH:
6399 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
6400 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006401 case eCSR_DISCONNECT_REASON_HANDOFF:
6402 fHighPriority = eANI_BOOLEAN_TRUE;
6403 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
6404 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006405 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
6406 case eCSR_DISCONNECT_REASON_DISASSOC:
6407 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
6408 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006409 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
6410 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
6411 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006412 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
6413 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
6414 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006415 default:
6416 break;
6417 }
6418 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6419 if( !HAL_STATUS_SUCCESS( status ) )
6420 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006421 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006422 csrReleaseCommandRoam( pMac, pCommand );
6423 }
6424 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006425 return( status );
6426}
6427
Jeff Johnson295189b2012-06-20 16:38:30 -07006428eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
6429{
6430 eHalStatus status = eHAL_STATUS_SUCCESS;
6431 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07006432 pCommand = csrGetCommandBuffer( pMac );
6433 if ( NULL != pCommand )
6434 {
6435 //Change the substate in case it is wait-for-key
6436 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
6437 {
6438 csrRoamStopWaitForKeyTimer( pMac );
6439 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6440 }
6441 pCommand->command = eSmeCommandRoam;
6442 pCommand->sessionId = (tANI_U8)sessionId;
6443 pCommand->u.roamCmd.roamReason = eCsrStopBss;
6444 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6445 if( !HAL_STATUS_SUCCESS( status ) )
6446 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006447 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006448 csrReleaseCommandRoam( pMac, pCommand );
6449 }
6450 }
6451 else
6452 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006453 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006454 status = eHAL_STATUS_RESOURCES;
6455 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006456 return ( status );
6457}
6458
Jeff Johnson295189b2012-06-20 16:38:30 -07006459eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
6460{
6461 eHalStatus status = eHAL_STATUS_SUCCESS;
6462 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006463
6464 if(!pSession)
6465 {
6466 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6467 return eHAL_STATUS_FAILURE;
6468 }
6469
Jeff Johnson295189b2012-06-20 16:38:30 -07006470#ifdef FEATURE_WLAN_BTAMP_UT_RF
6471 //Stop te retry
6472 pSession->maxRetryCount = 0;
6473 csrRoamStopJoinRetryTimer(pMac, sessionId);
6474#endif
6475 //Not to call cancel roaming here
6476 //Only issue disconnect when necessary
6477 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
6478 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
6479 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
6480
6481 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006482 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006483 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
6484 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006485 return (status);
6486}
6487
Jeff Johnson295189b2012-06-20 16:38:30 -07006488eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
6489{
6490 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006491
6492 if(!pSession)
6493 {
6494 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6495 return eHAL_STATUS_FAILURE;
6496 }
6497
Jeff Johnson295189b2012-06-20 16:38:30 -07006498 csrRoamCancelRoaming(pMac, sessionId);
6499 pSession->ibss_join_pending = FALSE;
6500 csrRoamStopIbssJoinTimer(pMac, sessionId);
6501 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
6502
6503 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
6504}
6505
Jeff Johnson295189b2012-06-20 16:38:30 -07006506eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6507 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
6508{
6509 eHalStatus status = eHAL_STATUS_SUCCESS;
6510 tDot11fBeaconIEs *pIesTemp = pIes;
6511 tANI_U8 index;
6512 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
6513 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07006514
6515 if(!pSession)
6516 {
6517 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6518 return eHAL_STATUS_FAILURE;
6519 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006520
6521 palZeroMemory(pMac->hHdd, &pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile));
6522 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
6523 pConnectProfile->AuthInfo = pProfile->AuthType;
6524 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
6525 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
6526 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
6527 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
6528 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
6529 pConnectProfile->BSSType = pProfile->BSSType;
6530 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
6531 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07006532 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
6533
Jeff Johnson295189b2012-06-20 16:38:30 -07006534 palCopyMemory(pMac->hHdd, &pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006535 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
6536 if(pProfile->nAddIEAssocLength)
6537 {
6538 status = palAllocateMemory(pMac->hHdd,
6539 (void **)&pConnectProfile->pAddIEAssoc, pProfile->nAddIEAssocLength);
6540 if(!HAL_STATUS_SUCCESS(status))
6541 {
6542 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
6543 return eHAL_STATUS_FAILURE;
6544 }
6545 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
6546 palCopyMemory(pMac->hHdd, pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
6547 pProfile->nAddIEAssocLength);
6548 }
6549
Jeff Johnson295189b2012-06-20 16:38:30 -07006550 //Save bssid
6551 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
6552#ifdef WLAN_FEATURE_VOWIFI_11R
6553 if (pSirBssDesc->mdiePresent)
6554 {
6555 pConnectProfile->MDID.mdiePresent = 1;
6556 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
6557 }
6558#endif
6559#ifdef FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006560 if ((csrIsProfileCCX(pProfile) ||
6561 ((pIesTemp->CCXVersion.present)
6562 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
6563 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
6564 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
6565 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Saurabh Gupta775073c2013-02-14 13:31:36 +05306566 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006567 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07006568 {
6569 pConnectProfile->isCCXAssoc = 1;
6570 }
6571#endif
6572 //save ssid
6573 if( NULL == pIesTemp )
6574 {
6575 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
6576 }
6577 if(HAL_STATUS_SUCCESS(status))
6578 {
6579 if(pIesTemp->SSID.present)
6580 {
6581 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
6582 palCopyMemory(pMac->hHdd, pConnectProfile->SSID.ssId,
6583 pIesTemp->SSID.ssid, pIesTemp->SSID.num_ssid);
6584 }
6585
6586 //Save the bss desc
6587 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05306588
6589 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07006590 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05306591 //Some HT AP's dont send WMM IE so in that case we assume all HT Ap's are Qos Enabled AP's
Jeff Johnson295189b2012-06-20 16:38:30 -07006592 pConnectProfile->qap = TRUE;
6593 }
6594 else
6595 {
6596 pConnectProfile->qap = FALSE;
6597 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006598 if ( NULL == pIes )
6599 {
6600 //Free memory if it allocated locally
6601 palFreeMemory(pMac->hHdd, pIesTemp);
6602 }
6603 }
6604 //Save Qos connection
6605 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
6606
6607 if(!HAL_STATUS_SUCCESS(status))
6608 {
6609 csrFreeConnectBssDesc(pMac, sessionId);
6610 }
6611 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
6612 {
6613 if((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
6614 palEqualMemory(pMac->hHdd, pProfile->SSIDs.SSIDList[index].SSID.ssId,
6615 pConnectProfile->SSID.ssId, pConnectProfile->SSID.length))
6616 {
6617 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
6618 break;
6619 }
6620 pConnectProfile->handoffPermitted = FALSE;
6621 }
6622
6623 return (status);
6624}
6625
Jeff Johnson295189b2012-06-20 16:38:30 -07006626static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
6627{
6628 tListElem *pEntry = NULL;
6629 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006630 //The head of the active list is the request we sent
6631 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
6632 if(pEntry)
6633 {
6634 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6635 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006636 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
6637 {
6638 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
6639 {
6640#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6641 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
6642#endif
6643 }
6644 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
6645 }
6646 else
6647 {
6648 tANI_U32 roamId = 0;
6649 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006650 if(!pSession)
6651 {
6652 smsLog(pMac, LOGE, FL(" session %d not found "), pSmeJoinRsp->sessionId);
6653 return;
6654 }
6655
Jeff Johnson295189b2012-06-20 16:38:30 -07006656
6657 //The head of the active list is the request we sent
6658 //Try to get back the same profile and roam again
6659 if(pCommand)
6660 {
6661 roamId = pCommand->u.roamCmd.roamId;
6662 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006663 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
6664 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006665 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08lX [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07006666#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
6667 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
6668 if (csrRoamIsHandoffInProgress(pMac))
6669 {
6670 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6671 /* Should indicate neighbor roam algorithm about the connect failure here */
6672 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
6673 }
6674#endif
6675 if (pCommand)
6676 {
6677 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
6678 {
6679 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6680 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
6681 csrRoamReissueRoamCommand(pMac);
6682 }
6683 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
6684 {
6685 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6686 }
6687 else
6688 {
6689 csrRoam(pMac, pCommand);
6690 }
6691 }
6692 else
6693 {
6694 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6695 }
6696 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
6697}
6698
Jeff Johnson295189b2012-06-20 16:38:30 -07006699eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
6700 tDot11fBeaconIEs *pIes,
6701 tCsrRoamProfile *pProfile, tANI_U32 roamId )
6702{
6703 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006704 smsLog( pMac, LOG1, "Attempting to Join Bssid= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07006705 pSirBssDesc->bssId[ 0 ],pSirBssDesc->bssId[ 1 ],pSirBssDesc->bssId[ 2 ],
6706 pSirBssDesc->bssId[ 3 ],pSirBssDesc->bssId[ 4 ],pSirBssDesc->bssId[ 5 ] );
6707
6708 // Set the roaming substate to 'join attempt'...
6709 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006710 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08006711 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006712 return (status);
6713}
6714
Jeff Johnson295189b2012-06-20 16:38:30 -07006715static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
6716 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
6717{
6718 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006719 // Set the roaming substate to 'join attempt'...
6720 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
6721
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006722 smsLog(pMac, LOGE, FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006723
6724 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08006725 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07006726}
6727
Jeff Johnson295189b2012-06-20 16:38:30 -07006728void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
6729{
6730 tListElem *pEntry;
6731 tSmeCmd *pCommand;
6732 tCsrRoamInfo roamInfo;
6733 tANI_U32 sessionId;
6734 tCsrRoamSession *pSession;
6735
6736 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
6737 if(pEntry)
6738 {
6739 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6740 if ( eSmeCommandRoam == pCommand->command )
6741 {
6742 sessionId = pCommand->sessionId;
6743 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006744
6745 if(!pSession)
6746 {
6747 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6748 return;
6749 }
6750
Jeff Johnson295189b2012-06-20 16:38:30 -07006751 if( pCommand->u.roamCmd.fStopWds )
6752 {
6753 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
6754 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
6755 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6756 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07006757 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07006758 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
6759 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6760 eCSR_ROAM_WDS_IND,
6761 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07006762 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
6763 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
6764 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6765 eCSR_ROAM_INFRA_IND,
6766 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
6767 }
6768
Jeff Johnson295189b2012-06-20 16:38:30 -07006769
Jeff Johnson295189b2012-06-20 16:38:30 -07006770 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
6771 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006772 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07006773 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6774 }
6775 }
6776 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
6777 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006778 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07006779 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6780 }
6781 }
6782 else
6783 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006784 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07006785 }
6786 }
6787 else
6788 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006789 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07006790 }
6791}
6792
Jeff Johnson295189b2012-06-20 16:38:30 -07006793tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
6794{
6795 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
6796 tListElem *pEntry;
6797 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006798 //alwasy lock active list before locking pending list
6799 csrLLLock( &pMac->sme.smeCmdActiveList );
6800 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
6801 if(pEntry)
6802 {
6803 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6804 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
6805 {
6806 fRet = eANI_BOOLEAN_TRUE;
6807 }
6808 }
6809 if(eANI_BOOLEAN_FALSE == fRet)
6810 {
6811 csrLLLock(&pMac->sme.smeCmdPendingList);
6812 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
6813 while(pEntry)
6814 {
6815 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6816 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
6817 {
6818 fRet = eANI_BOOLEAN_TRUE;
6819 break;
6820 }
6821 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
6822 }
6823 csrLLUnlock(&pMac->sme.smeCmdPendingList);
6824 }
6825 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07006826 return (fRet);
6827}
6828
Jeff Johnson295189b2012-06-20 16:38:30 -07006829tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
6830{
6831 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
6832 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07006833 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
6834 {
6835 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
6836 {
6837 break;
6838 }
6839 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006840 return ( fRet );
6841}
6842
Jeff Johnson295189b2012-06-20 16:38:30 -07006843tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
6844{
6845 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006846 //alwasy lock active list before locking pending list
6847 csrLLLock( &pMac->sme.smeCmdActiveList );
6848 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
6849 if(eANI_BOOLEAN_FALSE == fRet)
6850 {
6851 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
6852 }
6853 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07006854 return (fRet);
6855}
6856
Jeff Johnson295189b2012-06-20 16:38:30 -07006857tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
6858{
6859 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
6860 tListElem *pEntry;
6861 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07006862 //alwasy lock active list before locking pending list
6863 csrLLLock( &pMac->sme.smeCmdActiveList );
6864 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
6865 if( pEntry )
6866 {
6867 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
6868 if( ( eCsrRoamCommandScan == pCommand->command ) &&
6869 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
6870 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
6871 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
6872 {
6873 fRet = eANI_BOOLEAN_TRUE;
6874 }
6875 }
6876 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07006877 return (fRet);
6878}
Jeff Johnson295189b2012-06-20 16:38:30 -07006879eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
6880{
6881 eHalStatus status = eHAL_STATUS_SUCCESS;
6882 tSmeCmd *pCommand = NULL;
6883 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
6884 tANI_BOOLEAN fRemoveCmd = FALSE;
6885 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07006886 // Delete the old assoc command. All is setup for reassoc to be serialized
6887 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6888 if ( pEntry )
6889 {
6890 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6891 if ( !pCommand )
6892 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006893 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006894 return eHAL_STATUS_RESOURCES;
6895 }
6896 if ( eSmeCommandRoam == pCommand->command )
6897 {
6898 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
6899 {
6900 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
6901 }
6902 else
6903 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006904 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006905 }
6906 if (fRemoveCmd == FALSE)
6907 {
6908 // Implies we did not get the serialized assoc command we
6909 // were expecting
6910 pCommand = NULL;
6911 }
6912 }
6913 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006914 if(NULL == pCommand)
6915 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006916 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006917 return eHAL_STATUS_RESOURCES;
6918 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006919 do
6920 {
6921 //Change the substate in case it is wait-for-key
6922 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
6923 {
6924 csrRoamStopWaitForKeyTimer( pMac );
6925 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
6926 }
6927 pCommand->command = eSmeCommandRoam;
6928 pCommand->sessionId = (tANI_U8)sessionId;
6929 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07006930 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6931 if( !HAL_STATUS_SUCCESS( status ) )
6932 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006933 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006934 csrReleaseCommandRoam( pMac, pCommand );
6935 }
6936 } while( 0 );
6937
Jeff Johnson295189b2012-06-20 16:38:30 -07006938 return( status );
6939}
6940static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
6941{
6942 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
6943 tCsrScanResult *pScanResult = NULL;
6944 tSirBssDescription *pBssDesc = NULL;
6945 tSmeCmd *pCommand = NULL;
6946 tANI_U32 sessionId;
6947 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07006948 if(NULL == pEntry)
6949 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006950 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07006951 return;
6952 }
6953 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6954 sessionId = pCommand->sessionId;
6955 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006956
6957 if(!pSession)
6958 {
6959 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6960 return;
6961 }
6962
Jeff Johnson295189b2012-06-20 16:38:30 -07006963 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
6964 {
6965 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006966 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006967 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
6968 }
6969 else
6970 {
6971 if ( CCM_IS_RESULT_SUCCESS(result) )
6972 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006973 smsLog(pMac, LOG2, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07006974 // Successfully set the configuration parameters for the new Bss. Attempt to
6975 // join the roaming Bss.
6976 if(pCommand->u.roamCmd.pRoamBssEntry)
6977 {
6978 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
6979 pBssDesc = &pScanResult->Result.BssDescriptor;
6980 }
6981 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
6982 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07006983 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07006984 )
6985 {
6986 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
6987 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
6988 pBssDesc, pCommand->u.roamCmd.roamId )))
6989 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006990 smsLog(pMac, LOGW, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07006991 //We need to complete the command
6992 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
6993 }
6994 }
6995 else
6996 {
6997 if (!pCommand->u.roamCmd.pRoamBssEntry)
6998 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006999 smsLog(pMac, LOGW, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07007000 //We need to complete the command
7001 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
7002 return;
7003 }
7004 // If we are roaming TO an Infrastructure BSS...
7005 VOS_ASSERT(pScanResult != NULL);
7006 if ( csrIsInfraBssDesc( pBssDesc ) )
7007 {
7008 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07007009 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
7010 {
7011 // ..and currently in an Infrastructure connection....
7012 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
7013 {
7014 // ...and the SSIDs are equal, then we Reassoc.
7015 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
7016 pIesLocal ) )
7017 // ..and currently in an infrastructure connection
7018 {
7019 // then issue a Reassoc.
7020 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
7021 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
7022 &pCommand->u.roamCmd.roamProfile );
7023 }
7024 else
7025 {
7026
7027 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
7028 // previously associated AP.
7029 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7030 pIesLocal,
7031 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
7032 {
7033 //try something else
7034 csrRoam( pMac, pCommand );
7035 }
7036 }
7037 }
7038 else
7039 {
7040 eHalStatus status = eHAL_STATUS_SUCCESS;
7041
7042 /* We need to come with other way to figure out that this is because of HO in BMP
7043 The below API will be only available for Android as it uses a different HO algorithm */
7044 /* Reassoc request will be used only for CCX and 11r handoff whereas other legacy roaming should
7045 * use join request */
7046#ifdef WLAN_FEATURE_VOWIFI_11R
7047 if (csrRoamIsHandoffInProgress(pMac) &&
7048 csrRoamIs11rAssoc(pMac))
7049 {
7050 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
7051 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
7052 }
7053 else
7054#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007055#ifdef FEATURE_WLAN_CCX
7056 if (csrRoamIsHandoffInProgress(pMac) &&
7057 csrRoamIsCCXAssoc(pMac))
7058 {
7059 // Now serialize the reassoc command.
7060 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7061 }
7062 else
7063#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007064#ifdef FEATURE_WLAN_LFR
7065 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05307066 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007067 {
7068 // Now serialize the reassoc command.
7069 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7070 }
7071 else
7072#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007073 // else we are not connected and attempting to Join. Issue the
7074 // Join request.
7075 {
7076 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7077 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
7078 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
7079 }
7080 if(!HAL_STATUS_SUCCESS(status))
7081 {
7082 //try something else
7083 csrRoam( pMac, pCommand );
7084 }
7085 }
7086 if( !pScanResult->Result.pvIes )
7087 {
7088 //Locally allocated
7089 palFreeMemory(pMac->hHdd, pIesLocal);
7090 }
7091 }
7092 }//if ( csrIsInfraBssDesc( pBssDesc ) )
7093 else
7094 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007095 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007096 }
7097 }//else
7098 }//if ( WNI_CFG_SUCCESS == result )
7099 else
7100 {
7101 // In the event the configuration failed, for infra let the roam processor
7102 //attempt to join something else...
7103 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
7104 {
7105 csrRoam(pMac, pCommand);
7106 }
7107 else
7108 {
7109 //We need to complete the command
7110 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
7111 {
7112 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7113 }
7114 else
7115 {
7116 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7117 }
7118 }
7119 }
7120 }//we have active entry
7121}
7122
Jeff Johnson295189b2012-06-20 16:38:30 -07007123static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
7124{
7125 //No one is sending eWNI_SME_AUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007126 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007127 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
7128 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007129 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007130 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
7131 // join the new one...
7132 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07007133 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
7134 }
7135 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007136 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08lX [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007137 /***profHandleLostLinkAfterReset(pAdapter);
7138 // In the event the authenticate fails, let the roam processor attempt to join something else...
7139 roamRoam( pAdapter );***/
7140 }
7141}
7142
Jeff Johnson295189b2012-06-20 16:38:30 -07007143static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
7144{
7145 eCsrRoamCompleteResult result;
7146 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7147 tCsrRoamInfo roamInfo;
7148 tANI_U32 roamId = 0;
7149
7150 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7151 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007152 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007153 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07007154 /* Defeaturize this part later if needed */
7155#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7156 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
7157 * we need the response contents while processing the result in csrRoamProcessResults() */
7158 if (csrRoamIsHandoffInProgress(pMac))
7159 {
7160 /* Need to dig more on indicating events to SME QoS module */
7161 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7162 csrRoamComplete( pMac, result, pSmeJoinRsp);
7163 }
7164 else
7165#endif
7166 {
7167 csrRoamComplete( pMac, result, NULL );
7168 }
7169 }
7170 /* Should we handle this similar to handling the join failure? Is it ok
7171 * to call csrRoamComplete() with state as CsrJoinFailure */
7172 else
7173 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007174 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08lX [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007175 result = eCsrReassocFailure;
7176#ifdef WLAN_FEATURE_VOWIFI_11R
7177 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
7178 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode))
7179 {
7180 // Inform HDD to turn off FT flag in HDD
7181 if (pNeighborRoamInfo)
7182 {
7183 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7184 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
7185 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07007186 /*
7187 * Since the above callback sends a disconnect
7188 * to HDD, we should clean-up our state
7189 * machine as well to be in sync with the upper
7190 * layers. There is no need to send a disassoc
7191 * since: 1) we will never reassoc to the current
7192 * AP in LFR, and 2) there is no need to issue a
7193 * disassoc to the AP with which we were trying
7194 * to reassoc.
7195 */
7196 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7197 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007198 }
7199 }
7200#endif
7201 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
7202 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
7203 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
7204 //The disassoc rsp message will remove the command from active list
7205 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
7206 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
7207 {
7208 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7209 }
7210 }
7211}
7212
Jeff Johnson295189b2012-06-20 16:38:30 -07007213static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
7214{
Jeff Johnson295189b2012-06-20 16:38:30 -07007215#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7216 {
7217 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07007218 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
7219 if(pIbssLog)
7220 {
7221 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
7222 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
7223 {
7224 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
7225 }
7226 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
7227 }
7228 }
7229#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007230 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7231 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
7232 {
7233 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7234 }
7235 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
7236 {
7237 csrRoamReissueRoamCommand(pMac);
7238 }
7239}
7240
Jeff Johnson295189b2012-06-20 16:38:30 -07007241void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
7242{
7243 tSirResultCodes statusCode;
7244#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7245 tScanResultHandle hBSSList;
7246 tANI_BOOLEAN fCallCallback, fRemoveCmd;
7247 eHalStatus status;
7248 tCsrRoamInfo roamInfo;
7249 tCsrScanResultFilter *pScanFilter = NULL;
7250 tANI_U32 roamId = 0;
7251 tCsrRoamProfile *pCurRoamProfile = NULL;
7252 tListElem *pEntry = NULL;
7253 tSmeCmd *pCommand = NULL;
7254#endif
7255 tANI_U32 sessionId;
7256 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07007257
Jeff Johnson295189b2012-06-20 16:38:30 -07007258 tSirSmeDisassocRsp SmeDisassocRsp;
7259
7260 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
7261 sessionId = SmeDisassocRsp.sessionId;
7262 statusCode = SmeDisassocRsp.statusCode;
7263
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007264 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007265
7266 if ( csrIsConnStateInfra( pMac, sessionId ) )
7267 {
7268 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7269 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007270 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007271
7272 if(!pSession)
7273 {
7274 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7275 return;
7276 }
7277
Jeff Johnson295189b2012-06-20 16:38:30 -07007278 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
7279 {
7280 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7281 }
7282 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
7283 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
7284 {
7285 if ( eSIR_SME_SUCCESS == statusCode )
7286 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007287 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007288 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
7289 }
7290 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7291 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007292 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
7293 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007294 smsLog( pMac, LOGE, "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007295#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007296 /*
7297 * First ensure if the roam profile is in the scan cache.
7298 * If not, post a reassoc failure and disconnect.
7299 */
7300 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
7301 if(HAL_STATUS_SUCCESS(status))
7302 {
7303 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
7304 status = csrRoamPrepareFilterFromProfile(pMac,
7305 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
7306 if(!HAL_STATUS_SUCCESS(status))
7307 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007308 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007309 __func__, status);
7310 goto POST_ROAM_FAILURE;
7311 }
7312 else
7313 {
7314 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7315 if (!HAL_STATUS_SUCCESS(status))
7316 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007317 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007318 __func__, status);
7319 goto POST_ROAM_FAILURE;
7320 }
7321 }
7322 }
7323 else
7324 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007325 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007326 __func__, status);
7327 goto POST_ROAM_FAILURE;
7328 }
7329
7330 /*
7331 * After ensuring that the roam profile is in the scan result list,
7332 * dequeue the command from the active list.
7333 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007334 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7335 if ( pEntry )
7336 {
7337 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007338 /* If the head of the queue is Active and it is a ROAM command, remove
7339 * and put this on the Free queue.
7340 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007341 if ( eSmeCommandRoam == pCommand->command )
7342 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007343
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007344 /*
7345 * we need to process the result first before removing it from active list
7346 * because state changes still happening insides roamQProcessRoamResults so
7347 * no other roam command should be issued.
7348 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007349 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7350 if(pCommand->u.roamCmd.fReleaseProfile)
7351 {
7352 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
7353 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
7354 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007355 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07007356 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07007357 else
7358 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007359 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007360 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07007361 }
7362 }
7363 else
7364 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007365 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007366 }
7367 }
7368 else
7369 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007370 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007371 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007372
7373 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07007374 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
7375
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007376 palCopyMemory(pMac->hHdd, roamInfo.bssid,
7377 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
7378 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07007379
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007380 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
7381 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007382
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007383 /* Copy the connected profile to apply the same for this connection as well */
7384 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
7385 (void **)&pCurRoamProfile, sizeof(tCsrRoamProfile))))
Jeff Johnson295189b2012-06-20 16:38:30 -07007386 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007387 palZeroMemory(pMac->hHdd, pCurRoamProfile, sizeof(tCsrRoamProfile));
7388 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
7389 //make sure to put it at the head of the cmd queue
7390 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
7391 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
7392 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
7393
Jeff Johnson295189b2012-06-20 16:38:30 -07007394 if(!HAL_STATUS_SUCCESS(status))
7395 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007396 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007397 __func__, status);
7398 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007399 }
7400
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007401 /* Notify sub-modules like QoS etc. that handoff happening */
7402 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08007403 csrReleaseProfile(pMac, pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007404 palFreeMemory(pMac->hHdd, pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07007405 csrFreeScanFilter(pMac, pScanFilter);
7406 palFreeMemory( pMac->hHdd, pScanFilter );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007407 return;
7408 }
7409
7410POST_ROAM_FAILURE:
7411 if (pScanFilter)
7412 {
7413 csrFreeScanFilter(pMac, pScanFilter);
7414 palFreeMemory( pMac->hHdd, pScanFilter );
7415 }
7416 if (pCurRoamProfile)
7417 palFreeMemory(pMac->hHdd, pCurRoamProfile);
7418
7419 /* Inform the upper layers that the reassoc failed */
7420 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7421 csrRoamCallCallback(pMac, sessionId,
7422 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
7423
7424 /*
7425 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
7426 * Upon success, we would re-enter this routine after receiving the disassoc
7427 * response and will fall into the reassoc fail sub-state. And, eventually
7428 * call csrRoamComplete which would remove the roam command from SME active
7429 * queue.
7430 */
7431 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
7432 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
7433 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007434 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007435 __func__, status);
7436 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07007437 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007438#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07007439
Jeff Johnson295189b2012-06-20 16:38:30 -07007440 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
7441 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
7442 {
7443 // Disassoc due to Reassoc failure falls into this codepath....
7444 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7445 }
7446 else
7447 {
7448 if ( eSIR_SME_SUCCESS == statusCode )
7449 {
7450 // Successfully disassociated from the 'old' Bss...
7451 //
7452 // We get Disassociate response in three conditions.
7453 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
7454 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
7455 // Infrastructure network.
7456 // - Third is where we are doing an Infra to Infra roam between networks with different
7457 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
7458
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007459 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007460 }
7461 else
7462 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007463 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08lX", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007464 }
7465 //We are not done yet. Get the data and continue roaming
7466 csrRoamReissueRoamCommand(pMac);
7467 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007468}
7469
Jeff Johnson295189b2012-06-20 16:38:30 -07007470static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
7471{
7472 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007473 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007474 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007475 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
7476 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
7477 {
7478 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7479 }
7480 else
7481 {
7482 if ( eSIR_SME_SUCCESS == statusCode )
7483 {
7484 // Successfully deauth from the 'old' Bss...
7485 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007486 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007487 }
7488 else
7489 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007490 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08lX", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007491 }
7492 //We are not done yet. Get the data and continue roaming
7493 csrRoamReissueRoamCommand(pMac);
7494 }
7495}
7496
Jeff Johnson295189b2012-06-20 16:38:30 -07007497static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
7498{
7499 eCsrRoamCompleteResult result;
7500
7501 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
7502 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007503 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007504 result = eCsrStartBssSuccess;
7505 }
7506 else
7507 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007508 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08lX", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007509 //Let csrRoamComplete decide what to do
7510 result = eCsrStartBssFailure;
7511 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007512 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007513}
7514
Jeff Johnson295189b2012-06-20 16:38:30 -07007515/*
7516 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
7517 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
7518 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
7519 For the messages where sender allocates memory for specific structures, then it can be
7520 cast accordingly.
7521*/
7522void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
7523{
7524 tSirSmeRsp *pSmeRsp;
7525 tSmeIbssPeerInd *pIbssPeerInd;
7526 tCsrRoamInfo roamInfo;
7527 // TODO Session Id need to be acquired in this function
7528 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007529 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007530 smsLog( pMac, LOG2, "Message %d[0x%04X] received in substate %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007531 pSmeRsp->messageType, pSmeRsp->messageType,
7532 pMac->roam.curSubState[pSmeRsp->sessionId] );
Jeff Johnson295189b2012-06-20 16:38:30 -07007533 pSmeRsp->messageType = (pSmeRsp->messageType);
7534 pSmeRsp->length = (pSmeRsp->length);
7535 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007536 switch (pSmeRsp->messageType)
7537 {
7538
7539 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
7540 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
7541 {
7542 //We sent a JOIN_REQ
7543 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
7544 }
7545 break;
7546
7547 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
7548 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
7549 {
7550 //We sent a AUTH_REQ
7551 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
7552 }
7553 break;
7554
7555 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
7556 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
7557 {
7558 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
7559 }
7560 break;
7561
7562 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
7563 {
7564 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
7565 }
7566 break;
7567
7568 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
7569 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
7570 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
7571 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
7572 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
7573 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
7574//HO
7575 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
7576 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007577 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %d"), pMac->roam.curSubState[pSmeRsp->sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007578 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
7579 }
7580 break;
7581
7582 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
7583 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
7584 {
7585 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
7586 }
7587 break;
7588
7589 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
7590 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
7591 {
7592 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
7593 }
7594 break;
7595
7596 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
7597 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
7598 {
7599 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
7600 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007601 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007602 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
7603 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
7604 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007605 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Jeff Johnson295189b2012-06-20 16:38:30 -07007606 palZeroMemory( pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo) );
7607 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
7608 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
7609 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
7610 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
7611 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
7612 eCSR_ROAM_CONNECT_STATUS_UPDATE,
7613 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
7614 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007615 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007616 smsLog( pMac, LOG1, "Unexpected message type = %d[0x%X] received in substate %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007617 pSmeRsp->messageType, pSmeRsp->messageType,
7618 pMac->roam.curSubState[pSmeRsp->sessionId] );
7619
7620 //If we are connected, check the link status change
7621 if(!csrIsConnStateDisconnected(pMac, sessionId))
7622 {
7623 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
7624 }
7625 break;
7626 }
7627}
7628
Jeff Johnson295189b2012-06-20 16:38:30 -07007629void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
7630{
7631 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07007632 switch (pSirMsg->messageType)
7633 {
7634 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007635 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007636 csrRoamStatsRspProcessor( pMac, pSirMsg );
7637 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007638 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
7639 {
7640 tCsrRoamSession *pSession;
7641 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
7642 tCsrRoamInfo roamInfo;
7643 tCsrRoamInfo *pRoamInfo = NULL;
7644 tANI_U32 sessionId;
7645 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007646 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Jeff Johnson295189b2012-06-20 16:38:30 -07007647 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
7648 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07007649 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
7650 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
7651 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07007652
7653 if(!pSession)
7654 {
7655 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7656 return;
7657 }
7658
Jeff Johnson295189b2012-06-20 16:38:30 -07007659 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
7660 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07007661 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
7662 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
7663 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07007664 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
7665 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07007666 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr, sizeof(tSirMacAddr));
7667 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pUpperLayerAssocCnf->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07007668 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07007669 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
7670 {
7671 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
7672 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
7673 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
7674 }
7675 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
7676 {
7677 vos_sleep( 100 );
7678 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
7679 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
7680 }
7681
Jeff Johnson295189b2012-06-20 16:38:30 -07007682 }
7683 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007684 default:
7685 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
7686 break;
7687 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007688}
7689
Jeff Johnson295189b2012-06-20 16:38:30 -07007690eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
7691 tSirBssDescription *pBssDescription,
7692 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
7693 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
7694 tANI_U8 keyId, tANI_U16 keyLength,
7695 tANI_U8 *pKey, tANI_U8 paeRole )
7696{
7697 eHalStatus status = eHAL_STATUS_SUCCESS;
7698 tAniEdType edType;
7699
7700 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
7701 {
7702 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
7703 }
7704
7705 edType = csrTranslateEncryptTypeToEdType( EncryptType );
7706
7707 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
7708 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
7709 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
7710 addKey )
7711 {
7712 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07007713 setKey.encType = EncryptType;
7714 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
7715 palCopyMemory( pMac->hHdd, &setKey.peerMac, bssId, sizeof(tCsrBssid) );
7716 setKey.paeRole = paeRole; //0 for supplicant
7717 setKey.keyId = keyId; // Kye index
7718 setKey.keyLength = keyLength;
7719 if( keyLength )
7720 {
7721 palCopyMemory( pMac->hHdd, setKey.Key, pKey, keyLength );
7722 }
7723 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
7724 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007725 return (status);
7726}
7727
Jeff Johnson295189b2012-06-20 16:38:30 -07007728static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
7729 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
7730{
7731 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
7732 tSmeCmd *pCommand = NULL;
7733#ifdef FEATURE_WLAN_CCX
7734 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7735#endif /* FEATURE_WLAN_CCX */
7736
7737 do
7738 {
7739 pCommand = csrGetCommandBuffer(pMac);
7740 if(NULL == pCommand)
7741 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007742 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007743 status = eHAL_STATUS_RESOURCES;
7744 break;
7745 }
7746 pCommand->command = eSmeCommandSetKey;
7747 pCommand->sessionId = (tANI_U8)sessionId;
7748 // validate the key length, Adjust if too long...
7749 // for static WEP the keys are not set thru' SetContextReq
7750 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
7751 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
7752 {
7753 //KeyLength maybe 0 for static WEP
7754 if( pSetKey->keyLength )
7755 {
7756 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
7757 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007758 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07007759 break;
7760 }
7761
7762 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
7763 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WEP40_KEY_LEN );
7764 }
7765 }
7766 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
7767 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
7768 {
7769 //KeyLength maybe 0 for static WEP
7770 if( pSetKey->keyLength )
7771 {
7772 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
7773 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007774 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07007775 break;
7776 }
7777
7778 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
7779 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WEP104_KEY_LEN );
7780 }
7781 }
7782 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
7783 {
7784 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
7785 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007786 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07007787 break;
7788 }
7789 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
7790 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_TKIP_KEY_LEN );
7791 }
7792 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
7793 {
7794 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
7795 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007796 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07007797 break;
7798 }
7799 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
7800 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN );
7801 }
7802#ifdef FEATURE_WLAN_WAPI
7803 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
7804 {
7805 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
7806 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007807 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07007808 break;
7809 }
7810 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
7811 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WAPI_KEY_LEN );
7812 }
7813#endif /* FEATURE_WLAN_WAPI */
7814#ifdef FEATURE_WLAN_CCX
7815 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
7816 {
7817 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
7818 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007819 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07007820 break;
7821 }
7822 palCopyMemory( pMac->hHdd, pSession->ccxCckmInfo.krk, pSetKey->Key, CSR_KRK_KEY_LEN );
7823 pSession->ccxCckmInfo.reassoc_req_num=1;
7824 pSession->ccxCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
7825 status = eHAL_STATUS_SUCCESS;
7826 break;
7827 }
7828#endif /* FEATURE_WLAN_CCX */
Jeff Johnsone7245742012-09-05 17:12:55 -07007829
Jeff Johnson295189b2012-06-20 16:38:30 -07007830#ifdef WLAN_FEATURE_11W
7831 //Check for 11w BIP
7832 else if ( eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType )
7833 {
7834 tANI_U16 count = 0;
7835 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
7836 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007837 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07007838 break;
7839 }
7840 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
7841 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN );
7842 }
7843#endif
7844 status = eHAL_STATUS_SUCCESS;
7845 pCommand->u.setKeyCmd.roamId = roamId;
7846 pCommand->u.setKeyCmd.encType = pSetKey->encType;
7847 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
7848 palCopyMemory( pMac->hHdd, &pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac, sizeof(tCsrBssid) );
7849 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
7850 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
7851 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN );
7852 //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
7853
7854 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
7855 if( !HAL_STATUS_SUCCESS( status ) )
7856 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007857 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007858 }
7859 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007860 // Free the command if there has been a failure, or it is a
7861 // "local" operation like the set CCX CCKM KRK key.
7862 if( (!HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ))
7863#ifdef FEATURE_WLAN_CCX
7864 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
7865#endif /* FEATURE_WLAN_CCX */
7866 )
7867 {
7868 csrReleaseCommandSetKey( pMac, pCommand );
7869 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007870 return( status );
7871}
7872
Jeff Johnson295189b2012-06-20 16:38:30 -07007873eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
7874 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
7875{
7876 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
7877 tSmeCmd *pCommand = NULL;
7878 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007879 do
7880 {
7881 if( !csrIsSetKeyAllowed(pMac, sessionId) )
7882 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007883 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007884 status = eHAL_STATUS_CSR_WRONG_STATE;
7885 break;
7886 }
7887 pCommand = csrGetCommandBuffer(pMac);
7888 if(NULL == pCommand)
7889 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007890 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007891 status = eHAL_STATUS_RESOURCES;
7892 break;
7893 }
7894 pCommand->command = eSmeCommandRemoveKey;
7895 pCommand->sessionId = (tANI_U8)sessionId;
7896 pCommand->u.removeKeyCmd.roamId = roamId;
7897 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
7898 palCopyMemory( pMac->hHdd, &pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac, sizeof(tSirMacAddr) );
7899 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
7900 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7901 {
7902 //in this case, put it to the end of the Q incase there is a set key pending.
7903 fImediate = eANI_BOOLEAN_FALSE;
7904 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007905 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac=%02x, %02x, %02x, %02x, %02x, %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007906 pRemoveKey->encType, pRemoveKey->keyId,
7907 pCommand->u.removeKeyCmd.peerMac[0],
7908 pCommand->u.removeKeyCmd.peerMac[1],
7909 pCommand->u.removeKeyCmd.peerMac[2],
7910 pCommand->u.removeKeyCmd.peerMac[3],
7911 pCommand->u.removeKeyCmd.peerMac[4],
7912 pCommand->u.removeKeyCmd.peerMac[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007913 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
7914 if( !HAL_STATUS_SUCCESS( status ) )
7915 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007916 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007917 break;
7918 }
7919 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007920 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
7921 {
7922 csrReleaseCommandRemoveKey( pMac, pCommand );
7923 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007924 return (status );
7925}
7926
Jeff Johnson295189b2012-06-20 16:38:30 -07007927eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
7928{
7929 eHalStatus status;
7930 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
7931 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
7932 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
7933 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007934#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7935 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7936 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07007937 if(eCSR_ENCRYPT_TYPE_NONE != edType)
7938 {
7939 palZeroMemory(pMac->hHdd, &setKeyEvent, sizeof(vos_event_wlan_security_payload_type));
7940 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
7941 {
7942 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
7943 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
7944 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
7945 }
7946 else
7947 {
7948 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
7949 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
7950 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
7951 }
7952 palCopyMemory( pMac->hHdd, setKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
7953 if(CSR_IS_ENC_TYPE_STATIC(edType))
7954 {
7955 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007956 //It has to be static WEP here
7957 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
7958 {
7959 setKeyEvent.keyId = (v_U8_t)defKeyId;
7960 }
7961 }
7962 else
7963 {
7964 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
7965 }
7966 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
7967 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
7968 }
7969#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007970 if( csrIsSetKeyAllowed(pMac, sessionId) )
7971 {
7972 status = csrSendMBSetContextReqMsg( pMac, sessionId,
7973 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
7974 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
7975 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
7976 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
7977 pCommand->u.setKeyCmd.keyRsc);
7978 }
7979 else
7980 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007981 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007982 //Set this status so the error handling take care of the case.
7983 status = eHAL_STATUS_CSR_WRONG_STATE;
7984 }
7985 if( !HAL_STATUS_SUCCESS(status) )
7986 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007987 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007988 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007989#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7990 if(eCSR_ENCRYPT_TYPE_NONE != edType)
7991 {
7992 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
7993 {
7994 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
7995 }
7996 else
7997 {
7998 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
7999 }
8000 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8001 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8002 }
8003#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008004 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008005 return ( status );
8006}
8007
Jeff Johnson295189b2012-06-20 16:38:30 -07008008eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8009{
8010 eHalStatus status;
8011 tpSirSmeRemoveKeyReq pMsg = NULL;
8012 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
8013 tANI_U8 *p;
8014 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008015#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8016 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8017 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07008018 palZeroMemory(pMac->hHdd, &removeKeyEvent, sizeof(vos_event_wlan_security_payload_type));
8019 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
8020 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8021 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8022 palCopyMemory( pMac->hHdd, removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
8023 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
8024 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8025 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8026#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008027 if( csrIsSetKeyAllowed(pMac, sessionId) )
8028 {
8029 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, wMsgLen );
8030 }
8031 else
8032 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008033 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008034 //Set the error status so error handling kicks in below
8035 status = eHAL_STATUS_CSR_WRONG_STATE;
8036 }
8037 if( HAL_STATUS_SUCCESS( status ) )
8038 {
8039 palZeroMemory(pMac->hHdd, pMsg, wMsgLen);
8040 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
8041 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008042 pMsg->sessionId = (tANI_U8)sessionId;
8043 pMsg->transactionId = 0;
8044 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
8045 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
8046 // bssId - copy from session Info
8047 palCopyMemory( pMac->hHdd, p, &pMac->roam.roamSession[sessionId].connectedProfile.bssid, sizeof(tSirMacAddr) );
8048 p += sizeof(tSirMacAddr);
8049 // peerMacAddr
8050 palCopyMemory( pMac->hHdd, p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr) );
8051 p += sizeof(tSirMacAddr);
8052 // edType
8053 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
8054 p++;
8055 // weptype
8056 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
8057 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
8058 {
8059 *p = (tANI_U8)eSIR_WEP_STATIC;
8060 }
8061 else
8062 {
8063 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
8064 }
8065 p++;
8066 //keyid
8067 *p = pCommand->u.removeKeyCmd.keyId;
8068 p++;
8069 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008070 status = palSendMBMessage(pMac->hHdd, pMsg);
8071 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008072 if( !HAL_STATUS_SUCCESS( status ) )
8073 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008074 smsLog( pMac, LOGE, FL(" error status "), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008075#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8076 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07008077 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008078 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8079#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008080 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
8081 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008082 return ( status );
8083}
8084
Jeff Johnson295189b2012-06-20 16:38:30 -07008085eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8086{
8087 eHalStatus status;
8088
8089 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8090 {
8091 status = eHAL_STATUS_CSR_WRONG_STATE;
8092 }
8093 else
8094 {
8095 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
8096 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008097 return ( status );
8098}
8099
Jeff Johnson295189b2012-06-20 16:38:30 -07008100/*
8101 Prepare a filter base on a profile for parsing the scan results.
8102 Upon successful return, caller MUST call csrFreeScanFilter on
8103 pScanFilter when it is done with the filter.
8104*/
8105eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
8106 tCsrScanResultFilter *pScanFilter)
8107{
8108 eHalStatus status = eHAL_STATUS_SUCCESS;
8109 tANI_U32 size = 0;
8110 tANI_U8 index = 0;
8111
8112 do
8113 {
8114 if(pProfile->BSSIDs.numOfBSSIDs)
8115 {
8116 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
8117 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->BSSIDs.bssid, size);
8118 if(!HAL_STATUS_SUCCESS(status))
8119 {
8120 break;
8121 }
8122 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
8123 palCopyMemory(pMac->hHdd, pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
8124 }
8125 if(pProfile->SSIDs.numOfSSIDs)
8126 {
8127 if( !CSR_IS_WDS_STA( pProfile ) )
8128 {
8129 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
8130 }
8131 else
8132 {
8133 //For WDS station
8134 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
8135 pScanFilter->SSIDs.numOfSSIDs = 1;
8136 }
8137 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
8138 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->SSIDs.SSIDList, size);
8139 if(!HAL_STATUS_SUCCESS(status))
8140 {
8141 break;
8142 }
8143 palCopyMemory(pMac->hHdd, pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList, size);
8144 }
8145 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
8146 {
8147 pScanFilter->ChannelInfo.numOfChannels = 0;
8148 pScanFilter->ChannelInfo.ChannelList = NULL;
8149 }
8150 else if(pProfile->ChannelInfo.numOfChannels)
8151 {
8152 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->ChannelInfo.ChannelList, sizeof(*pScanFilter->ChannelInfo.ChannelList) * pProfile->ChannelInfo.numOfChannels);
8153 pScanFilter->ChannelInfo.numOfChannels = 0;
8154 if(HAL_STATUS_SUCCESS(status))
8155 {
8156 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
8157 {
8158 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
8159 {
8160 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
8161 = pProfile->ChannelInfo.ChannelList[index];
8162 pScanFilter->ChannelInfo.numOfChannels++;
8163 }
8164 else
8165 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008166 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008167 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008168 }
8169 }
8170 else
8171 {
8172 break;
8173 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008174 }
8175 else
8176 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008177 smsLog(pMac, LOGW, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008178 status = eHAL_STATUS_FAILURE;
8179 break;
8180 }
8181 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
8182 pScanFilter->authType = pProfile->AuthType;
8183 pScanFilter->EncryptionType = pProfile->EncryptionType;
8184 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
8185 pScanFilter->BSSType = pProfile->BSSType;
8186 pScanFilter->phyMode = pProfile->phyMode;
8187#ifdef FEATURE_WLAN_WAPI
8188 //check if user asked for WAPI with 11n or auto mode, in that case modify
8189 //the phymode to 11g
8190 if(csrIsProfileWapi(pProfile))
8191 {
8192 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
8193 {
8194 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
8195 }
8196 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
8197 {
8198 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
8199 }
8200 if(!pScanFilter->phyMode)
8201 {
8202 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
8203 }
8204 }
8205#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07008206 /*Save the WPS info*/
8207 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07008208 if( pProfile->countryCode[0] )
8209 {
8210 //This causes the matching function to use countryCode as one of the criteria.
8211 palCopyMemory( pMac->hHdd, pScanFilter->countryCode, pProfile->countryCode,
8212 WNI_CFG_COUNTRY_CODE_LEN );
8213 }
8214#ifdef WLAN_FEATURE_VOWIFI_11R
8215 if (pProfile->MDID.mdiePresent)
8216 {
8217 pScanFilter->MDID.mdiePresent = 1;
8218 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
8219 }
8220#endif
8221
8222 }while(0);
8223
8224 if(!HAL_STATUS_SUCCESS(status))
8225 {
8226 csrFreeScanFilter(pMac, pScanFilter);
8227 }
8228
8229 return(status);
8230}
8231
Jeff Johnson295189b2012-06-20 16:38:30 -07008232tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
8233 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
8234{
8235 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
8236 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008237 do
8238 {
8239 // Validate the type is ok...
8240 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
8241 pCommand = csrGetCommandBuffer( pMac );
8242 if ( !pCommand )
8243 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008244 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008245 break;
8246 }
8247 //Change the substate in case it is waiting for key
8248 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8249 {
8250 csrRoamStopWaitForKeyTimer( pMac );
8251 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
8252 }
8253 pCommand->command = eSmeCommandWmStatusChange;
8254 pCommand->sessionId = (tANI_U8)sessionId;
8255 pCommand->u.wmStatusChangeCmd.Type = Type;
8256 if ( eCsrDisassociated == Type )
8257 {
8258 palCopyMemory( pMac->hHdd, &pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg, pSmeRsp,
8259 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ) );
8260 }
8261 else
8262 {
8263 palCopyMemory( pMac->hHdd, &pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg, pSmeRsp,
8264 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ) );
8265 }
8266 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
8267 {
8268 fCommandQueued = eANI_BOOLEAN_TRUE;
8269 }
8270 else
8271 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008272 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008273 csrReleaseCommandWmStatusChange( pMac, pCommand );
8274 }
8275
Jeff Johnson295189b2012-06-20 16:38:30 -07008276 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
8277 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07008278 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07008279 return( fCommandQueued );
8280}
8281
Jeff Johnson295189b2012-06-20 16:38:30 -07008282static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
8283{
8284 v_S7_t rssi = 0;
8285 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
8286 if(pGetRssiReq)
8287 {
8288 if(NULL != pGetRssiReq->pVosContext)
8289 {
8290 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
8291 }
8292 else
8293 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008294 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008295 return;
8296 }
8297
8298 if(NULL != pGetRssiReq->rssiCallback)
8299 {
8300 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
8301 }
8302 else
8303 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008304 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008305 return;
8306 }
8307 }
8308 else
8309 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008310 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008311 }
8312 return;
8313}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008314#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
8315void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
8316{
8317 v_S7_t rssi = 0;
8318 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
8319
8320 /* Get roam Rssi request is backed up and passed back to the response,
8321 Extract the request message to fetch callback */
8322 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
8323 if(pRoamRssiRsp)
8324 {
8325 rssi = pRoamRssiRsp->rssi;
8326 if((reqBkp) && (NULL != reqBkp->rssiCallback))
8327 {
8328 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
8329 reqBkp->rssiCallback = NULL;
8330 vos_mem_free(reqBkp);
8331 }
8332 else
8333 {
8334 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
8335 if (NULL != reqBkp)
8336 {
8337 vos_mem_free(reqBkp);
8338 }
8339 }
8340 }
8341 else
8342 {
8343 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
8344 }
8345 return;
8346}
8347#endif
8348
Jeff Johnsone7245742012-09-05 17:12:55 -07008349static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
8350{
8351 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
8352 if(pTlRssiInd)
8353 {
8354 if(NULL != pTlRssiInd->tlCallback)
8355 {
8356 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08008357 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07008358 }
8359 else
8360 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008361 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07008362 }
8363 }
8364 else
8365 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008366 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07008367 }
8368 return;
8369}
Jeff Johnson295189b2012-06-20 16:38:30 -07008370
8371void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
8372{
8373 tSirSmeAssocInd *pAssocInd;
8374 tSirSmeDisassocInd *pDisassocInd;
8375 tSirSmeDeauthInd *pDeauthInd;
8376 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
8377 tSirSmeNewBssInfo *pNewBss;
8378 tSmeIbssPeerInd *pIbssPeerInd;
8379 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
8380 tSirSmeApNewCaps *pApNewCaps;
8381 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
8382 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
8383 tCsrRoamInfo *pRoamInfo = NULL;
8384 tCsrRoamInfo roamInfo;
8385 eHalStatus status;
8386 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
8387 tCsrRoamSession *pSession = NULL;
8388 tpSirSmeSwitchChannelInd pSwitchChnInd;
8389 tSmeMaxAssocInd *pSmeMaxAssocInd;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08008390 tSmeCmd pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008391 pSirMsg->messageType = (pSirMsg->messageType);
8392 pSirMsg->length = (pSirMsg->length);
8393 pSirMsg->statusCode = (pSirMsg->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008394 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07008395 switch( pSirMsg->messageType )
8396 {
8397 case eWNI_SME_ASSOC_IND:
8398 {
8399 tCsrRoamSession *pSession;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008400 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008401 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
8402 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
8403 if( HAL_STATUS_SUCCESS( status ) )
8404 {
8405 pSession = CSR_GET_SESSION(pMac, sessionId);
8406
Jeff Johnson32d95a32012-09-10 13:15:23 -07008407 if(!pSession)
8408 {
8409 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8410 return;
8411 }
8412
Jeff Johnson295189b2012-06-20 16:38:30 -07008413 pRoamInfo = &roamInfo;
8414
8415 // Required for indicating the frames to upper layer
8416 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
8417 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
8418
8419 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
8420 pRoamInfo->beaconLength = pAssocInd->beaconLength;
8421 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8422 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8423
8424 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
8425 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
8426 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
8427
8428 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
8429 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008430 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
8431 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pAssocInd->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008432 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
8433 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07008434 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07008435 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
8436 {
8437 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
8438 {
8439 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
8440 pSession->pConnectBssDesc,
8441 &(pRoamInfo->peerMac),
8442 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
8443 pRoamInfo->fAuthRequired = FALSE;
8444 }
8445 else
8446 {
8447 pRoamInfo->fAuthRequired = TRUE;
8448 }
8449 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
8450 if (!HAL_STATUS_SUCCESS(status))
8451 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
8452 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008453 /* Send Association completion message to PE */
8454 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
8455
8456 /* send a message to CSR itself just to avoid the EAPOL frames going
8457 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07008458 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8459 {
8460 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
8461 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008462 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
8463 {
8464 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
8465 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8466 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
8467 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008468 }
8469 }
8470 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008471 case eWNI_SME_DISASSOC_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008472 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008473 // Check if AP dis-associated us because of MIC failure. If so,
8474 // then we need to take action immediately and not wait till the
8475 // the WmStatusChange requests is pushed and processed
8476 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
8477 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDisassocInd->bssId, &sessionId );
8478 if( HAL_STATUS_SUCCESS( status ) )
8479 {
8480 // If we are in neighbor preauth done state then on receiving
8481 // disassoc or deauth we dont roam instead we just disassoc
8482 // from current ap and then go to disconnected state
8483 // This happens for CCX and 11r FT connections ONLY.
8484#ifdef WLAN_FEATURE_VOWIFI_11R
8485 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8486 {
8487 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8488 }
8489#endif
8490#ifdef FEATURE_WLAN_CCX
8491 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8492 {
8493 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8494 }
8495#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008496#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308497 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008498 {
8499 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8500 }
8501#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008502 pSession = CSR_GET_SESSION( pMac, sessionId );
8503
Jeff Johnson32d95a32012-09-10 13:15:23 -07008504 if(!pSession)
8505 {
8506 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8507 return;
8508 }
8509
Jeff Johnson295189b2012-06-20 16:38:30 -07008510 if ( csrIsConnStateInfra( pMac, sessionId ) )
8511 {
8512 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8513 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008514#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8515 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
8516#endif
8517 csrRoamLinkDown(pMac, sessionId);
8518 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07008519 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
8520 {
8521
8522 pRoamInfo = &roamInfo;
8523
8524 pRoamInfo->statusCode = pDisassocInd->statusCode;
8525 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8526
8527 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
8528
8529 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDisassocInd->peerMacAddr, sizeof(tSirMacAddr));
8530 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pDisassocInd->bssId, sizeof(tCsrBssid));
8531
8532 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08008533
8534 /*
8535 * STA/P2P client got disassociated so remove any pending deauth
8536 * commands in sme pending list
8537 */
8538 pCommand.command = eSmeCommandRoam;
8539 pCommand.sessionId = (tANI_U8)sessionId;
8540 pCommand.u.roamCmd.roamReason = eCsrForcedDeauthSta;
8541 vos_mem_copy(pCommand.u.roamCmd.peerMac, pDisassocInd->peerMacAddr, sizeof(tSirMacAddr));
8542 csrRoamRemoveDuplicateCommand(pMac, sessionId, &pCommand, eCsrForcedDeauthSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07008543 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008544 }
8545 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008546 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008547 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008548 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
8549 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
8550 if( HAL_STATUS_SUCCESS( status ) )
8551 {
8552 // If we are in neighbor preauth done state then on receiving
8553 // disassoc or deauth we dont roam instead we just disassoc
8554 // from current ap and then go to disconnected state
8555 // This happens for CCX and 11r FT connections ONLY.
8556#ifdef WLAN_FEATURE_VOWIFI_11R
8557 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8558 {
8559 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8560 }
8561#endif
8562#ifdef FEATURE_WLAN_CCX
8563 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8564 {
8565 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8566 }
8567#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008568#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308569 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008570 {
8571 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8572 }
8573#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008574 pSession = CSR_GET_SESSION( pMac, sessionId );
8575
Jeff Johnson32d95a32012-09-10 13:15:23 -07008576 if(!pSession)
8577 {
8578 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8579 return;
8580 }
8581
Jeff Johnson295189b2012-06-20 16:38:30 -07008582 if ( csrIsConnStateInfra( pMac, sessionId ) )
8583 {
8584 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8585 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008586#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8587 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
8588#endif
8589 csrRoamLinkDown(pMac, sessionId);
8590 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07008591 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
8592 {
8593
8594 pRoamInfo = &roamInfo;
8595
8596 pRoamInfo->statusCode = pDeauthInd->statusCode;
8597 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8598
8599 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
8600
8601 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDeauthInd->peerMacAddr, sizeof(tSirMacAddr));
8602 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pDeauthInd->bssId, sizeof(tCsrBssid));
8603
8604 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
8605 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008606 }
8607 break;
8608
8609 case eWNI_SME_SWITCH_CHL_REQ: // in case of STA, the SWITCH_CHANNEL originates from its AP
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008610 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008611 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
8612 //Update with the new channel id.
8613 //The channel id is hidden in the statusCode.
8614 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
8615 if( HAL_STATUS_SUCCESS( status ) )
8616 {
8617 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008618 if(!pSession)
8619 {
8620 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8621 return;
8622 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008623 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
8624 if(pSession->pConnectBssDesc)
8625 {
8626 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
8627 }
8628 }
8629 break;
8630
8631 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008632 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008633 {
8634 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
8635 sessionId = pDeauthRsp->sessionId;
8636 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
8637 {
8638 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008639 if(!pSession)
8640 {
8641 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8642 return;
8643 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008644 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
8645 {
8646 pRoamInfo = &roamInfo;
8647 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8648 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDeauthRsp->peerMacAddr, sizeof(tSirMacAddr));
8649 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
8650 pRoamInfo->statusCode = pDeauthRsp->statusCode;
8651 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
8652 }
8653 }
8654 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008655 break;
8656
8657 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07008658 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008659 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07008660 {
8661 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
8662 sessionId = pDisassocRsp->sessionId;
8663 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
8664 {
8665 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008666 if(!pSession)
8667 {
8668 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8669 return;
8670 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008671 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
8672 {
8673 pRoamInfo = &roamInfo;
8674 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8675 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDisassocRsp->peerMacAddr, sizeof(tSirMacAddr));
8676 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
8677 pRoamInfo->statusCode = pDisassocRsp->statusCode;
8678 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
8679 }
8680 }
8681 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008682 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008683 case eWNI_SME_MIC_FAILURE_IND:
8684 {
8685 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
8686 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
8687 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Jeff Johnson295189b2012-06-20 16:38:30 -07008688#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8689 {
8690 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008691 if(!pSession)
8692 {
8693 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8694 return;
8695 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008696 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
8697 palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type));
8698 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
8699 secEvent.encryptionModeMulticast =
8700 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8701 secEvent.encryptionModeUnicast =
8702 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8703 secEvent.authMode =
8704 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8705 palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 );
8706 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
8707 }
8708#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008709 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
8710 if( HAL_STATUS_SUCCESS( status ) )
8711 {
8712 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
8713 roamInfo.u.pMICFailureInfo = &pMicInd->info;
8714 pRoamInfo = &roamInfo;
8715 if(pMicInd->info.multicast)
8716 {
8717 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
8718 }
8719 else
8720 {
8721 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
8722 }
8723 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
8724 }
8725 }
8726 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008727 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
8728 {
8729 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
8730 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008731 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008732
8733 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
8734 if( HAL_STATUS_SUCCESS( status ) )
8735 {
8736 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
8737 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
8738 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
8739 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
8740 }
8741 }
8742 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008743
Jeff Johnson295189b2012-06-20 16:38:30 -07008744 case eWNI_SME_WM_STATUS_CHANGE_NTF:
8745 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
8746 switch( pStatusChangeMsg->statusChangeCode )
8747 {
8748 case eSIR_SME_IBSS_ACTIVE:
8749 sessionId = csrFindIbssSession( pMac );
8750 if( CSR_SESSION_ID_INVALID != sessionId )
8751 {
8752 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008753 if(!pSession)
8754 {
8755 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8756 return;
8757 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008758 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
8759 if(pSession->pConnectBssDesc)
8760 {
8761 palCopyMemory(pMac->hHdd, &roamInfo.bssid, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
8762 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
8763 pRoamInfo = &roamInfo;
8764 }
8765 else
8766 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008767 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07008768 }
8769 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
8770 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
8771 }
8772 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008773 case eSIR_SME_IBSS_INACTIVE:
8774 sessionId = csrFindIbssSession( pMac );
8775 if( CSR_SESSION_ID_INVALID != sessionId )
8776 {
8777 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008778 if(!pSession)
8779 {
8780 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8781 return;
8782 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008783 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
8784 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
8785 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
8786 }
8787 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008788 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
8789 sessionId = csrFindIbssSession( pMac );
8790 if( CSR_SESSION_ID_INVALID != sessionId )
8791 {
8792 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008793 if(!pSession)
8794 {
8795 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8796 return;
8797 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008798 // update the connection state information
8799 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008800#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8801 {
8802 vos_log_ibss_pkt_type *pIbssLog;
8803 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07008804 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8805 if(pIbssLog)
8806 {
8807 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
8808 if(pNewBss)
8809 {
8810 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pNewBss->bssId, 6);
8811 if(pNewBss->ssId.length)
8812 {
8813 palCopyMemory(pMac->hHdd, pIbssLog->ssid, pNewBss->ssId.ssId, pNewBss->ssId.length);
8814 }
8815 pIbssLog->operatingChannel = pNewBss->channelNumber;
8816 }
8817 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
8818 {
8819 //***U8 is not enough for beacon interval
8820 pIbssLog->beaconInterval = (v_U8_t)bi;
8821 }
8822 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
8823 }
8824 }
8825#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008826 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
8827 csrRoamIssueSetContextReq( pMac, sessionId, pSession->connectedProfile.EncryptionType,
8828 pSession->pConnectBssDesc,
8829 &Broadcastaddr,
8830 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
8831 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
8832 roamStatus = eCSR_ROAM_IBSS_IND;
8833 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pNewBss->bssId, sizeof(tCsrBssid));
8834 pRoamInfo = &roamInfo;
8835 //This BSSID is th ereal BSSID, let's save it
8836 if(pSession->pConnectBssDesc)
8837 {
8838 palCopyMemory(pMac->hHdd, pSession->pConnectBssDesc->bssId, &pNewBss->bssId, sizeof(tCsrBssid));
8839 }
8840 // Stop the join IBSS timer in case of join, for
8841 // genuine merge do nothing
8842 if(pSession->ibss_join_pending)
8843 {
8844 pSession->ibss_join_pending = FALSE;
8845 csrRoamStopIbssJoinTimer(pMac, sessionId);
8846 result = eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS;
8847 }
8848 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008849 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07008850 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008851 // detection by LIM that the capabilities of the associated AP have changed.
8852 case eSIR_SME_AP_CAPS_CHANGED:
8853 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008854 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -07008855 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
8856 if( HAL_STATUS_SUCCESS( status ) )
8857 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08008858 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
8859 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
8860 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
8861 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
8862 )
8863 {
8864 csrScanForCapabilityChange( pMac, pApNewCaps );
8865 result = eCSR_ROAM_RESULT_CAP_CHANGED;
8866 roamStatus = eCSR_ROAM_GEN_INFO;
8867 }
8868 else
8869 {
8870 smsLog(pMac, LOGW,
8871 "Skipping csrScanForCapabilityChange as "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008872 "CSR is in state %d and sub-state %d",
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08008873 pMac->roam.curState[sessionId],
8874 pMac->roam.curSubState[sessionId]);
8875 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008876 }
8877 break;
8878
8879 default:
8880 roamStatus = eCSR_ROAM_FAILED;
8881 result = eCSR_ROAM_RESULT_NONE;
8882 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008883 } // end switch on statusChangeCode
8884 if(eCSR_ROAM_RESULT_NONE != result)
8885 {
8886 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
8887 }
8888 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008889 case eWNI_SME_IBSS_NEW_PEER_IND:
8890 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07008891#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8892 {
8893 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07008894 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8895 if(pIbssLog)
8896 {
8897 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
8898 palCopyMemory(pMac->hHdd, pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
8899 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
8900 }
8901 }
8902#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008903 sessionId = csrFindIbssSession( pMac );
8904 if( CSR_SESSION_ID_INVALID != sessionId )
8905 {
8906 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008907
8908 if(!pSession)
8909 {
8910 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8911 return;
8912 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008913 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
8914 if(pSession->pConnectBssDesc)
8915 {
8916 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
8917 palCopyMemory(pMac->hHdd, &roamInfo.bssid, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
8918 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
8919 {
8920 status = palAllocateMemory(pMac->hHdd, (void **)&roamInfo.pbFrames,
8921 (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd)));
8922 if(HAL_STATUS_SUCCESS(status))
8923 {
8924 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
8925 palCopyMemory(pMac->hHdd, roamInfo.pbFrames, ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
8926 roamInfo.nBeaconLength);
8927 }
8928 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
8929 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8930 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
8931 status = palAllocateMemory(pMac->hHdd, (void **)&roamInfo.pBssDesc,
8932 pSession->pConnectBssDesc->length);
8933 if(HAL_STATUS_SUCCESS(status))
8934 {
8935 palCopyMemory(pMac->hHdd, roamInfo.pBssDesc, pSession->pConnectBssDesc,
8936 pSession->pConnectBssDesc->length);
8937 }
8938 if(HAL_STATUS_SUCCESS(status))
8939 {
8940 pRoamInfo = &roamInfo;
8941 }
8942 else
8943 {
8944 if(roamInfo.pbFrames)
8945 {
8946 palFreeMemory(pMac->hHdd, roamInfo.pbFrames);
8947 }
8948 if(roamInfo.pBssDesc)
8949 {
8950 palFreeMemory(pMac->hHdd, roamInfo.pBssDesc);
8951 }
8952 }
8953 }
8954 else
8955 {
8956 pRoamInfo = &roamInfo;
8957 }
8958 csrRoamIssueSetContextReq( pMac, sessionId, pSession->connectedProfile.EncryptionType,
8959 pSession->pConnectBssDesc,
8960 &(pIbssPeerInd->peerAddr),
8961 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
8962 }
8963 else
8964 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008965 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07008966 }
8967 //send up the sec type for the new peer
8968 if (pRoamInfo)
8969 {
8970 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8971 }
8972 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
8973 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
8974 if(pRoamInfo)
8975 {
8976 if(roamInfo.pbFrames)
8977 {
8978 palFreeMemory(pMac->hHdd, roamInfo.pbFrames);
8979 }
8980 if(roamInfo.pBssDesc)
8981 {
8982 palFreeMemory(pMac->hHdd, roamInfo.pBssDesc);
8983 }
8984 }
8985 }
8986 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008987 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
8988 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
8989 sessionId = csrFindIbssSession( pMac );
8990 if( CSR_SESSION_ID_INVALID != sessionId )
8991 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008992#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8993 {
8994 vos_log_ibss_pkt_type *pIbssLog;
8995
8996 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8997 if(pIbssLog)
8998 {
8999 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
9000 if(pIbssPeerInd)
9001 {
9002 palCopyMemory(pMac->hHdd, pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
9003 }
9004 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9005 }
9006 }
9007#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009008 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009009 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9010 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9011 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
9012 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
9013 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9014 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
9015 }
9016 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009017 case eWNI_SME_SETCONTEXT_RSP:
9018 {
9019 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
9020 tListElem *pEntry;
9021 tSmeCmd *pCommand;
9022
9023 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9024 if ( pEntry )
9025 {
9026 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9027 if ( eSmeCommandSetKey == pCommand->command )
9028 {
9029 sessionId = pCommand->sessionId;
9030 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009031
9032 if(!pSession)
9033 {
9034 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9035 return;
9036 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009037
9038#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9039 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
9040 {
9041 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
9042 palZeroMemory(pMac->hHdd, &setKeyEvent, sizeof(vos_event_wlan_security_payload_type));
9043 if( pRsp->peerMacAddr[0] & 0x01 )
9044 {
9045 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
9046 }
9047 else
9048 {
9049 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
9050 }
9051 setKeyEvent.encryptionModeMulticast =
9052 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9053 setKeyEvent.encryptionModeUnicast =
9054 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9055 palCopyMemory( pMac->hHdd, setKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
9056 setKeyEvent.authMode =
9057 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9058 if( eSIR_SUCCESS != pRsp->statusCode )
9059 {
9060 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9061 }
9062 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9063 }
9064#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
9065 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
9066 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009067 csrRoamStopWaitForKeyTimer( pMac );
9068
Jeff Johnson295189b2012-06-20 16:38:30 -07009069 //We are done with authentication, whethere succeed or not
9070 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009071 //We do it here because this linkup function is not called after association
9072 //when a key needs to be set.
9073 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
9074 {
9075 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9076 }
9077 }
Jeff Johnson43971f52012-07-17 12:26:56 -07009078 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009079 {
9080 palCopyMemory( pMac, &roamInfo.peerMac, &pRsp->peerMacAddr, sizeof(tCsrBssid) );
Jeff Johnsone7245742012-09-05 17:12:55 -07009081 //Make sure we install the GTK before indicating to HDD as authenticated
9082 //This is to prevent broadcast packets go out after PTK and before GTK.
9083 if( palEqualMemory( pMac->hHdd, &Broadcastaddr, pRsp->peerMacAddr,
9084 sizeof(tSirMacAddr) ) )
9085 {
Yathish9f22e662012-12-10 14:21:35 -08009086#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
9087 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
9088 {
9089 tpSirSetActiveModeSetBncFilterReq pMsg;
9090 palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tSirSetActiveModeSetBncFilterReq));
9091 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
9092 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
9093 pMsg->seesionId = sessionId;
9094 status = palSendMBMessage(pMac->hHdd, pMsg );
9095 }
9096#endif
9097 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -07009098 }
9099 else
9100 {
9101 result = eCSR_ROAM_RESULT_NONE;
9102 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009103 pRoamInfo = &roamInfo;
9104 }
9105 else
9106 {
9107 result = eCSR_ROAM_RESULT_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009108 smsLog( pMac, LOGE, "CSR: Roam Completion setkey command failed(%d) PeerMac %02X-%02X-%02X-%02X-%02X-%02X...",
Jeff Johnson295189b2012-06-20 16:38:30 -07009109 pRsp->statusCode, pRsp->peerMacAddr[0], pRsp->peerMacAddr[1], pRsp->peerMacAddr[2],
9110 pRsp->peerMacAddr[3], pRsp->peerMacAddr[4], pRsp->peerMacAddr[5] );
9111 }
9112 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9113 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -07009114 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
9115 // can go ahead and initiate the TSPEC if any are pending
9116 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009117#ifdef FEATURE_WLAN_CCX
9118 //Send Adjacent AP repot to new AP.
9119 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
9120 pSession->isPrevApInfoValid &&
9121 pSession->connectedProfile.isCCXAssoc)
9122 {
9123#ifdef WLAN_FEATURE_VOWIFI
9124 csrCcxSendAdjacentApRepMsg(pMac, pSession);
9125#endif
9126 pSession->isPrevApInfoValid = FALSE;
9127 }
9128#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009129 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9130 {
9131 csrReleaseCommandSetKey( pMac, pCommand );
9132 }
9133 }
9134 else
9135 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009136 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009137 }
9138 }
9139 else
9140 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009141 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009142 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009143 smeProcessPendingQueue( pMac );
9144 }
9145 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009146 case eWNI_SME_REMOVEKEY_RSP:
9147 {
9148 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
9149 tListElem *pEntry;
9150 tSmeCmd *pCommand;
9151
9152 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9153 if ( pEntry )
9154 {
9155 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9156 if ( eSmeCommandRemoveKey == pCommand->command )
9157 {
9158 sessionId = pCommand->sessionId;
9159 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009160
9161 if(!pSession)
9162 {
9163 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9164 return;
9165 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009166#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9167 {
9168 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
9169 palZeroMemory(pMac->hHdd, &removeKeyEvent, sizeof(vos_event_wlan_security_payload_type));
9170 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
9171 removeKeyEvent.encryptionModeMulticast =
9172 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9173 removeKeyEvent.encryptionModeUnicast =
9174 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9175 palCopyMemory( pMac->hHdd, removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
9176 removeKeyEvent.authMode =
9177 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9178 if( eSIR_SUCCESS != pRsp->statusCode )
9179 {
9180 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9181 }
9182 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9183 }
9184#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -07009185 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009186 {
9187 palCopyMemory( pMac, &roamInfo.peerMac, &pRsp->peerMacAddr, sizeof(tCsrBssid) );
9188 result = eCSR_ROAM_RESULT_NONE;
9189 pRoamInfo = &roamInfo;
9190 }
9191 else
9192 {
9193 result = eCSR_ROAM_RESULT_FAILURE;
9194 }
9195 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9196 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
9197 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9198 {
9199 csrReleaseCommandRemoveKey( pMac, pCommand );
9200 }
9201 }
9202 else
9203 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009204 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009205 }
9206 }
9207 else
9208 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009209 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009210 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009211 smeProcessPendingQueue( pMac );
9212 }
9213 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009214 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009215 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009216 csrRoamStatsRspProcessor( pMac, pSirMsg );
9217 break;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009218#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
9219 case eWNI_SME_GET_ROAM_RSSI_RSP:
9220 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
9221 csrRoamRssiRspProcessor( pMac, pSirMsg );
9222 break;
9223#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009224 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009225 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009226 csrUpdateRssi( pMac, pSirMsg );
9227 break;
9228
Jeff Johnson295189b2012-06-20 16:38:30 -07009229#ifdef WLAN_FEATURE_VOWIFI_11R
9230 case eWNI_SME_FT_PRE_AUTH_RSP:
9231 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
9232 break;
9233#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009234 case eWNI_SME_MAX_ASSOC_EXCEEDED:
9235 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009236 smsLog( pMac, LOG1, FL("send indication that max assoc have been reached and the new peer cannot be accepted"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009237 sessionId = pSmeMaxAssocInd->sessionId;
9238 roamInfo.sessionId = sessionId;
9239 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pSmeMaxAssocInd->peerMac, sizeof(tCsrBssid));
9240 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9241 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
9242 break;
9243
9244 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009245 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009246 btampEstablishLogLinkHdlr( pSirMsg );
9247 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07009248 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009249 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009250 csrRoamRssiIndHdlr( pMac, pSirMsg );
9251 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009252
9253 default:
9254 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009255 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -07009256}
9257
Jeff Johnson295189b2012-06-20 16:38:30 -07009258void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
9259 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
9260{
9261 if(pSession)
9262 {
9263 if(pSession->bRefAssocStartCnt)
9264 {
9265 pSession->bRefAssocStartCnt--;
9266 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
9267 //Need to call association_completion because there is an assoc_start pending.
9268 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
9269 eCSR_ROAM_ASSOCIATION_COMPLETION,
9270 eCSR_ROAM_RESULT_FAILURE);
9271 }
9272 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
9273 }
9274 else
9275 {
9276 smsLog(pMac, LOGW, FL(" pSession is NULL"));
9277 }
9278}
9279
9280
9281eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
9282{
9283 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009284 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
9285 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
9286 {
9287 status = csrScanRequestLostLink1( pMac, sessionId );
9288 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009289 return(status);
9290}
9291
Jeff Johnson295189b2012-06-20 16:38:30 -07009292//return a boolean to indicate whether roaming completed or continue.
9293tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
9294 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
9295{
9296 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
9297 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
9298 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
9299 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009300 if(!pSession)
9301 {
9302 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9303 return eANI_BOOLEAN_FALSE;
9304 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009305 //Check whether time is up
9306 if(pSession->fCancelRoaming || fForce ||
9307 ((curTime - pSession->roamingStartTime) > roamTime) ||
9308 eCsrReassocRoaming == pSession->roamingReason ||
9309 eCsrDynamicRoaming == pSession->roamingReason)
9310 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009311 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009312 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
9313 {
9314 //roaming is cancelled, tell HDD to indicate disconnect
9315 //Because LIM overload deauth_ind for both deauth frame and missed beacon
9316 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
9317 //to be eSIR_BEACON_MISSED
9318 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
9319 {
9320 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
9321 }
9322 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
9323 {
9324 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
9325 }
9326 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
9327 {
9328 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
9329 }
9330 else
9331 {
9332 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
9333 }
9334 }
9335 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
9336 pSession->roamingReason = eCsrNotRoaming;
9337 }
9338 else
9339 {
9340 pSession->roamResult = roamResult;
9341 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
9342 {
9343 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
9344 pSession->roamingReason = eCsrNotRoaming;
9345 }
9346 else
9347 {
9348 fCompleted = eANI_BOOLEAN_FALSE;
9349 }
9350 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009351 return(fCompleted);
9352}
9353
Jeff Johnson295189b2012-06-20 16:38:30 -07009354void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
9355{
9356 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009357
9358 if(!pSession)
9359 {
9360 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9361 return;
9362 }
9363
Jeff Johnson295189b2012-06-20 16:38:30 -07009364 if(CSR_IS_ROAMING(pSession))
9365 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009366 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -07009367 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
9368 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
9369 {
9370 //No need to do anything in here because the handler takes care of it
9371 }
9372 else
9373 {
9374 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
9375 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
9376 //Roaming is stopped after here
9377 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
9378 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
9379 csrScanAbortMacScan(pMac);
9380 csrRoamStopRoamingTimer(pMac, sessionId);
9381 }
9382 }
9383}
9384
Jeff Johnson295189b2012-06-20 16:38:30 -07009385void csrRoamRoamingTimerHandler(void *pv)
9386{
9387 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9388 tpAniSirGlobal pMac = pInfo->pMac;
9389 tANI_U32 sessionId = pInfo->sessionId;
9390 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009391
9392 if(!pSession)
9393 {
9394 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9395 return;
9396 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009397
9398 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
9399 {
9400 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
9401 {
9402 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
9403 pSession->roamingReason = eCsrNotRoaming;
9404 }
9405 }
9406}
9407
Jeff Johnson295189b2012-06-20 16:38:30 -07009408eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
9409{
9410 eHalStatus status;
9411 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009412
9413 if(!pSession)
9414 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009415 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009416 return eHAL_STATUS_FAILURE;
9417 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009418
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009419 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -07009420 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
9421 status = palTimerStart(pMac->hHdd, pSession->hTimerRoaming, interval, eANI_BOOLEAN_FALSE);
9422
9423 return (status);
9424}
9425
Jeff Johnson295189b2012-06-20 16:38:30 -07009426eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
9427{
9428 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerRoaming));
9429}
9430
Jeff Johnson295189b2012-06-20 16:38:30 -07009431void csrRoamWaitForKeyTimeOutHandler(void *pv)
9432{
9433 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9434 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009435 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
9436
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009437 smsLog(pMac, LOGW, "WaitForKey timer expired in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009438 pMac->roam.neighborRoamInfo.neighborRoamState,
9439 pMac->roam.curSubState[pInfo->sessionId]);
9440
Jeff Johnson295189b2012-06-20 16:38:30 -07009441 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
9442 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009443#ifdef FEATURE_WLAN_LFR
9444 if (csrNeighborRoamIsHandoffInProgress(pMac))
9445 {
9446 /*
9447 * Enable heartbeat timer when hand-off is in progress
9448 * and Key Wait timer expired.
9449 */
9450 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009451 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009452 pMac->roam.configParam.HeartbeatThresh24);
9453 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
9454 pMac->roam.configParam.HeartbeatThresh24,
9455 NULL, eANI_BOOLEAN_FALSE);
9456 }
9457#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009458 smsLog(pMac, LOGW, " SME pre-auth state timeout. ");
Jeff Johnson295189b2012-06-20 16:38:30 -07009459 //Change the substate so command queue is unblocked.
9460 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, pInfo->sessionId);
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009461 if (pSession)
9462 {
9463 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
9464 {
9465 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9466 smeProcessPendingQueue(pMac);
9467 }
9468 else
9469 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009470 smsLog(pMac, LOGW, "%s: could not post link up",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009471 __func__);
9472 }
9473 }
9474 else
9475 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009476 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009477 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009478 }
9479
9480}
9481
Jeff Johnson295189b2012-06-20 16:38:30 -07009482eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
9483{
9484 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009485#ifdef FEATURE_WLAN_LFR
9486 if (csrNeighborRoamIsHandoffInProgress(pMac))
9487 {
9488 /* Disable heartbeat timer when hand-off is in progress */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009489 smsLog(pMac, LOG2, "%s: disabling HB timer in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009490 __func__,
9491 pMac->roam.neighborRoamInfo.neighborRoamState,
9492 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
9493 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
9494 }
9495#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009496 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -07009497 status = palTimerStart(pMac->hHdd, pMac->roam.hTimerWaitForKey, interval, eANI_BOOLEAN_FALSE);
9498
9499 return (status);
9500}
9501
Jeff Johnson295189b2012-06-20 16:38:30 -07009502eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
9503{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009504 smsLog(pMac, LOG2, "WaitForKey timer stopped in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009505 pMac->roam.neighborRoamInfo.neighborRoamState,
9506 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
9507#ifdef FEATURE_WLAN_LFR
9508 if (csrNeighborRoamIsHandoffInProgress(pMac))
9509 {
9510 /*
9511 * Enable heartbeat timer when hand-off is in progress
9512 * and Key Wait timer got stopped for some reason
9513 */
9514 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009515 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009516 pMac->roam.configParam.HeartbeatThresh24);
9517 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
9518 pMac->roam.configParam.HeartbeatThresh24,
9519 NULL, eANI_BOOLEAN_FALSE);
9520 }
9521#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009522 return (palTimerStop(pMac->hHdd, pMac->roam.hTimerWaitForKey));
9523}
9524
Jeff Johnson295189b2012-06-20 16:38:30 -07009525void csrRoamIbssJoinTimerHandler(void *pv)
9526{
9527 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9528 tpAniSirGlobal pMac = pInfo->pMac;
9529 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE;
9530 tANI_U32 sessionId = pInfo->sessionId;
9531 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009532
9533 if(!pSession)
9534 {
9535 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9536 return;
9537 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009538
9539 pSession->ibss_join_pending = FALSE;
9540 // JEZ100225: As of main/latest "tip", we are no longer doing this. Check on this.
9541 //csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
9542 // Send an IBSS stop request to PE
9543 csrRoamDisconnectInternal(pMac, sessionId, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07009544}
Jeff Johnson295189b2012-06-20 16:38:30 -07009545eHalStatus csrRoamStartIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
9546{
9547 eHalStatus status;
9548 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009549
9550 if(!pSession)
9551 {
9552 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9553 return eHAL_STATUS_FAILURE;
9554 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009555
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009556 smsLog(pMac, LOG1, " csrRoamStartIbssJoinTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -07009557 pSession->ibssJoinTimerInfo.sessionId = (tANI_U8)sessionId;
9558 status = palTimerStart(pMac->hHdd, pSession->hTimerIbssJoining, interval, eANI_BOOLEAN_FALSE);
9559
9560 return (status);
9561}
Jeff Johnson295189b2012-06-20 16:38:30 -07009562eHalStatus csrRoamStopIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
9563{
9564 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerIbssJoining));
9565}
Jeff Johnson295189b2012-06-20 16:38:30 -07009566void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
9567 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
9568{
9569 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
9570 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009571 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9572 /* To silence the KW tool Null chaeck is added */
9573 if(!pSession)
9574 {
9575 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9576 return;
9577 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009578
9579 if(pCommand)
9580 {
9581 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009582 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009583 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009584 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
9585 {
9586 //if success, force roaming completion
9587 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
9588 }
9589 else
9590 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009591 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009592 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07009593 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
9594 }
9595}
9596
Jeff Johnson295189b2012-06-20 16:38:30 -07009597eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
9598{
9599 eHalStatus status = eHAL_STATUS_SUCCESS;
9600 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
9601 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
9602 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
9603 tCsrRoamInfo *pRoamInfo = NULL;
9604 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009605 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -07009606 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009607 /* To silence the KW tool Null chaeck is added */
9608 if(!pSession)
9609 {
9610 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9611 return eHAL_STATUS_FAILURE;
9612 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009613 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009614 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07009615 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
9616 if ( eWNI_SME_DISASSOC_IND == type )
9617 {
9618 result = eCSR_ROAM_RESULT_DISASSOC_IND;
9619 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
9620 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -07009621 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07009622 }
9623 else if ( eWNI_SME_DEAUTH_IND == type )
9624 {
9625 result = eCSR_ROAM_RESULT_DEAUTH_IND;
9626 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
9627 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -08009628 /* Convert into proper reason code */
9629 pSession->joinFailStatusCode.reasonCode =
9630 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
Agarwal Ashish838f1f32013-03-11 20:54:52 +05309631 0 : pDeauthIndMsg->reasonCode;
9632 /* cfg layer expects 0 as reason code if
9633 the driver dosent know the reason code
9634 eSIR_BEACON_MISSED is defined as locally */
Jeff Johnson295189b2012-06-20 16:38:30 -07009635 }
9636 else
9637 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009638 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009639 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -07009640 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07009641 }
9642
9643 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -07009644 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07009645 {
9646 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
9647 }
9648
9649 if ( eWNI_SME_DISASSOC_IND == type )
9650 {
9651 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
9652 }
9653 else if ( eWNI_SME_DEAUTH_IND == type )
9654 {
9655 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
9656 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009657 if(!HAL_STATUS_SUCCESS(status))
9658 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009659 //If fail to send confirmation to PE, not to trigger roaming
9660 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009661 }
9662
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009663 //prepare to tell HDD to disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -07009664 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9665 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
9666 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07009667 if( eWNI_SME_DISASSOC_IND == type)
9668 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009669 //staMacAddr
9670 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDisassocIndMsg->peerMacAddr, sizeof(tSirMacAddr));
9671 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
9672 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009673 else if( eWNI_SME_DEAUTH_IND == type )
9674 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009675 //staMacAddr
9676 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDeauthIndMsg->peerMacAddr, sizeof(tSirMacAddr));
9677 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
9678 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009679 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009680
9681 /* See if we can possibly roam. If so, start the roaming process and notify HDD
9682 that we are roaming. But if we cannot possibly roam, or if we are unable to
9683 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -07009684 if(fToRoam)
9685 {
9686 //Only remove the connected BSS in infrastructure mode
9687 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
9688 //Not to do anying for lostlink with WDS
9689 if( pMac->roam.configParam.nRoamingTime )
9690 {
9691 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
9692 ( eWNI_SME_DEAUTH_IND == type ) ?
9693 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
9694 {
9695 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9696 //For IBSS, we need to give some more info to HDD
9697 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
9698 {
9699 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9700 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
9701 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
9702 }
9703 else
9704 {
9705 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
9706 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009707 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009708 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
9709 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
9710 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
9711 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
9712 }
9713 else
9714 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009715 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07009716 fToRoam = eANI_BOOLEAN_FALSE;
9717 }
9718 }
9719 else
9720 {
9721 //We are told not to roam, indicate lostlink
9722 fToRoam = eANI_BOOLEAN_FALSE;
9723 }
9724 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009725 if(!fToRoam)
9726 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -07009727 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009728 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009729 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009730 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
9731 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
9732 * csrRoamCheckForLinkStatusChange API.
9733 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009734 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
9735 }
9736
9737 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -07009738 Still enable idle scan for polling in case concurrent sessions are running */
9739 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
9740 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009741 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07009742 }
9743 }
9744
9745 return (status);
9746}
9747
Jeff Johnson295189b2012-06-20 16:38:30 -07009748eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
9749{
9750 eHalStatus status = eHAL_STATUS_SUCCESS;
9751 tListElem *pEntry = NULL;
9752 tSmeCmd *pCommand = NULL;
9753 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009754
9755 if(!pSession)
9756 {
9757 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9758 return eHAL_STATUS_FAILURE;
9759 }
9760
Jeff Johnson295189b2012-06-20 16:38:30 -07009761 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009762 //Only remove the connected BSS in infrastructure mode
9763 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
9764 if(pMac->roam.configParam.nRoamingTime)
9765 {
9766 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
9767 {
9768 //before starting the lost link logic release the roam command for handoff
9769 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
9770 if(pEntry)
9771 {
9772 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
9773 }
9774 if(pCommand)
9775 {
9776 if (( eSmeCommandRoam == pCommand->command ) &&
9777 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
9778 {
9779 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9780 {
9781 csrReleaseCommandRoam( pMac, pCommand );
9782 }
9783 }
9784 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009785 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -07009786 }
9787 }
9788 else
9789 {
9790 //We are told not to roam, indicate lostlink
9791 status = eHAL_STATUS_FAILURE;
9792 }
9793
9794 return (status);
9795}
Jeff Johnson295189b2012-06-20 16:38:30 -07009796void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
9797{
9798 tListElem *pEntry;
9799 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07009800 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9801 if ( pEntry )
9802 {
9803 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9804 if ( eSmeCommandWmStatusChange == pCommand->command )
9805 {
9806 // Nothing to process in a Lost Link completion.... It just kicks off a
9807 // roaming sequence.
9808 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9809 {
9810 csrReleaseCommandWmStatusChange( pMac, pCommand );
9811 }
9812 else
9813 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009814 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -07009815 }
9816
9817 }
9818 else
9819 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009820 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009821 }
9822 }
9823 else
9824 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009825 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009826 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009827 smeProcessPendingQueue( pMac );
9828}
9829
Jeff Johnson295189b2012-06-20 16:38:30 -07009830void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
9831{
9832 eHalStatus status = eHAL_STATUS_FAILURE;
9833 tSirSmeRsp *pSirSmeMsg;
9834 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009835
9836 if(!pSession)
9837 {
9838 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
9839 return;
9840 }
9841
Jeff Johnson295189b2012-06-20 16:38:30 -07009842 switch ( pCommand->u.wmStatusChangeCmd.Type )
9843 {
9844 case eCsrDisassociated:
9845 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
9846 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
9847 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009848 case eCsrDeauthenticated:
9849 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
9850 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
9851 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009852 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009853 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009854 break;
9855 }
9856 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
9857 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
9858 {
9859 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
9860 {
9861 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009862 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009863 }
9864 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009865 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
9866 // command here since there is nothing else to do.
9867 csrRoamWmStatusChangeComplete( pMac );
9868}
9869
Jeff Johnson295189b2012-06-20 16:38:30 -07009870//This function returns band and mode information.
9871//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
9872//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -07009873static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
9874 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -07009875{
Jeff Johnson295189b2012-06-20 16:38:30 -07009876 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
9877 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
9878 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07009879 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07009880
Jeff Johnson295189b2012-06-20 16:38:30 -07009881 //If the global setting for dot11Mode is set to auto/abg, we overwrite the setting in the profile.
Jeff Johnson295189b2012-06-20 16:38:30 -07009882 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
9883 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
9884 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
9885 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009886 {
9887 switch( pMac->roam.configParam.uCfgDot11Mode )
9888 {
9889 case eCSR_CFG_DOT11_MODE_11A:
9890 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
9891 eBand = eCSR_BAND_5G;
9892 break;
9893 case eCSR_CFG_DOT11_MODE_11B:
9894 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
9895 eBand = eCSR_BAND_24;
9896 break;
9897 case eCSR_CFG_DOT11_MODE_11G:
9898 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
9899 eBand = eCSR_BAND_24;
9900 break;
9901 case eCSR_CFG_DOT11_MODE_11N:
9902 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
9903 eBand = eCSR_BAND_24;
9904 break;
9905 //case eCSR_CFG_DOT11_MODE_BEST:
9906 // cfgDot11Mode = eCSR_CFG_DOT11_MODE_BEST;
9907 // eBand = eCSR_BAND_24;
9908 // break;
9909 default:
9910 // Global dot11 Mode setting is 11a/b/g.
9911 // use the channel number to determine the Mode setting.
9912 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
9913 {
9914 eBand = pMac->roam.configParam.eBand;
9915 if(eCSR_BAND_24 == eBand)
9916 {
9917 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
9918 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
9919 }
9920 else
9921 {
9922 //prefer 5GHz
9923 eBand = eCSR_BAND_5G;
9924 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
9925 }
9926 }
9927 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
9928 {
9929 // channel is a 2.4GHz channel. Set mode to 11g.
9930 //
9931 // !!LAC - WiFi tests require IBSS networks to start in 11b mode without any change to the
9932 // default parameter settings on the adapter. We use ACU to start an IBSS through creation
9933 // of a startIBSS profile. this startIBSS profile has Auto MACProtocol and the
9934 // adapter property setting for dot11Mode is also AUTO. So in this case, let's start
9935 // the IBSS network in 11b mode instead of 11g mode.
9936 //
9937 // so this is for Auto=profile->MacProtocol && Auto=Global.dot11Mode && profile->channel is < 14,
9938 // then start the IBSS in b mode.
9939 //
9940 // Note: we used to have this start as an 11g IBSS for best performance... now to specify that
9941 // the user will have to set the do11Mode in the property page to 11g to force it.
9942 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
9943 eBand = eCSR_BAND_24;
9944 }
9945 else
9946 {
9947 // else, it's a 5.0GHz channel. Set mode to 11a.
9948 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
9949 eBand = eCSR_BAND_5G;
9950 }
9951 break;
9952 }//switch
9953 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
9954 else
9955 {
9956 //dot11 mode is set, lets pick the band
9957 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
9958 {
9959 // channel is Auto also.
9960 eBand = pMac->roam.configParam.eBand;
9961 if(eCSR_BAND_ALL == eBand)
9962 {
9963 //prefer 5GHz
9964 eBand = eCSR_BAND_5G;
9965 }
9966 }
9967 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
9968 {
9969 eBand = eCSR_BAND_24;
9970 }
9971 else
9972 {
9973 eBand = eCSR_BAND_5G;
9974 }
9975 }
9976 if(pBand)
9977 {
9978 *pBand = eBand;
9979 }
9980
9981 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009982 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -07009983 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
9984 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -07009985
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -08009986 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
9987 if( (!CSR_IS_11n_ALLOWED(pProfile->EncryptionType.encryptionType[0] ) || ((pProfile->privacy == 1) && (pProfile->EncryptionType.encryptionType[0] == eCSR_ENCRYPT_TYPE_NONE)) ) &&
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -07009988 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -07009989#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -07009990 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -07009991#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -07009992 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
9993 {
9994 //We cannot do 11n here
9995 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
9996 {
9997 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
9998 }
9999 else
10000 {
10001 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10002 }
10003 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010004 return( cfgDot11Mode );
10005}
10006
Jeff Johnson295189b2012-06-20 16:38:30 -070010007eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
10008{
10009 eHalStatus status;
10010 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010011
10012 if(!pSession)
10013 {
10014 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10015 return eHAL_STATUS_FAILURE;
10016 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010017
10018#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10019 {
10020 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010021 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10022 if(pIbssLog)
10023 {
10024 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
10025 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10026 }
10027 }
10028#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010029 pSession->ibss_join_pending = FALSE;
10030 csrRoamStopIbssJoinTimer(pMac, sessionId );
10031 // Set the roaming substate to 'stop Bss request'...
10032 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
10033
10034 // attempt to stop the Bss (reason code is ignored...)
10035 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080010036 if(!HAL_STATUS_SUCCESS(status))
10037 {
10038 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
10039 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010040 return (status);
10041}
10042
Jeff Johnson295189b2012-06-20 16:38:30 -070010043//pNumChan is a caller allocated space with the sizeof pChannels
10044eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
10045{
10046
10047 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
10048 (tANI_U8 *)pChannels,
10049 pNumChan));
10050}
10051
Kiran4a17ebe2013-01-31 10:43:43 -080010052tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
10053{
10054 tANI_U32 cfgLength = 0;
10055 tANI_U16 cfgId = 0;
10056 tPowerdBm maxTxPwr = 0;
10057 tANI_U8 *pCountryInfo = NULL;
10058 eHalStatus status;
10059 tANI_U8 count = 0;
10060 tANI_U8 firstChannel;
10061 tANI_U8 maxChannels;
10062
10063 if (CSR_IS_CHANNEL_5GHZ(channel))
10064 {
10065 cfgId = WNI_CFG_MAX_TX_POWER_5;
10066 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
10067 }
10068 else if (CSR_IS_CHANNEL_24GHZ(channel))
10069 {
10070 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
10071 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
10072 }
10073 else
10074 return maxTxPwr;
10075
10076 status = palAllocateMemory(pMac->hHdd, (void **)&pCountryInfo, cfgLength);
10077 if (status != eHAL_STATUS_SUCCESS)
10078 {
10079 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10080 FL("%s: palAllocateMemory() failed, status = %d"),
10081 __FUNCTION__, status);
10082 goto error;
10083 }
10084 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
10085 if (status != eHAL_STATUS_SUCCESS)
10086 {
10087 goto error;
10088 }
10089 /* Identify the channel and maxtxpower */
10090 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
10091 {
10092 firstChannel = pCountryInfo[count++];
10093 maxChannels = pCountryInfo[count++];
10094 maxTxPwr = pCountryInfo[count++];
10095
10096 if ((channel >= firstChannel) &&
10097 (channel < (firstChannel + maxChannels)))
10098 {
10099 break;
10100 }
10101 }
10102
10103error:
10104 if (NULL != pCountryInfo)
10105 palFreeMemory(pMac->hHdd, pCountryInfo);
10106
10107 return maxTxPwr;
10108}
10109
10110
Jeff Johnson295189b2012-06-20 16:38:30 -070010111tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
10112{
10113 tANI_BOOLEAN fValid = FALSE;
10114 tANI_U32 idxValidChannels;
10115 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10116
10117 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
10118 {
10119 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
10120 {
10121 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
10122 {
10123 fValid = TRUE;
10124 break;
10125 }
10126 }
10127 }
10128 pMac->roam.numValidChannels = len;
10129 return fValid;
10130}
10131
Jeff Johnson295189b2012-06-20 16:38:30 -070010132tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
10133{
10134 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
10135 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010136 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
10137 {
10138 if(channel == pMac->scan.base40MHzChannels.channelList[i])
10139 {
10140 fValid = eANI_BOOLEAN_TRUE;
10141 break;
10142 }
10143 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010144 return (fValid);
10145}
10146
Jeff Johnson295189b2012-06-20 16:38:30 -070010147//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070010148 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070010149{
Jeff Johnsone7245742012-09-05 17:12:55 -070010150 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010151 tANI_U8 centerChn;
10152 tANI_U32 ChannelBondingMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010153 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
10154 {
10155 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
10156 }
10157 else
10158 {
10159 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
10160 }
10161 //Figure what the other side's CB mode
10162 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
10163 {
10164 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
10165 {
10166 if(pIes->HTInfo.present)
10167 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010168 /* This is called during INFRA STA/CLIENT and should use the merged value of
10169 * supported channel width and recommended tx width as per standard
10170 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010171 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070010172 pIes->HTCaps.supportedChannelWidthSet,
10173 pIes->HTInfo.recommendedTxWidthSet,
10174 pIes->HTInfo.secondaryChannelOffset);
10175
10176 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
10177 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010178 else
Jeff Johnsone7245742012-09-05 17:12:55 -070010179 eRet = PHY_SINGLE_CHANNEL_CENTERED;
10180 switch (eRet) {
10181 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
10182 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
10183 break;
10184 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
10185 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
10186 break;
10187 case PHY_SINGLE_CHANNEL_CENTERED:
10188 default:
10189 centerChn = primaryChn;
10190 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010191 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010192 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070010193 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010194 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Jeff Johnsone7245742012-09-05 17:12:55 -070010195 //eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010196 }
10197 }
10198 }
10199 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010200 return eRet;
10201}
Jeff Johnson295189b2012-06-20 16:38:30 -070010202tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
10203{
10204 tANI_BOOLEAN fFound = FALSE;
10205 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010206 for( idx = 0; idx < pCipherList->numEntries; idx++ )
10207 {
10208 if( pCipherList->encryptionType[idx] == encryptionType )
10209 {
10210 fFound = TRUE;
10211 break;
10212 }
10213 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010214 return fFound;
10215}
Jeff Johnson295189b2012-06-20 16:38:30 -070010216tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
10217{
10218 tANI_BOOLEAN fFound = FALSE;
10219 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010220 for( idx = 0; idx < pAuthList->numEntries; idx++ )
10221 {
10222 if( pAuthList->authType[idx] == authType )
10223 {
10224 fFound = TRUE;
10225 break;
10226 }
10227 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010228 return fFound;
10229}
Jeff Johnson295189b2012-06-20 16:38:30 -070010230tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
10231{
10232 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
10233 tCsrScanResultFilter *pScanFilter = NULL;
10234 eHalStatus status = eHAL_STATUS_SUCCESS;
10235
10236 if(pProfile1 && pProfile2)
10237 {
10238 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
10239 if(HAL_STATUS_SUCCESS(status))
10240 {
10241 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
10242 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
10243 if(HAL_STATUS_SUCCESS(status))
10244 {
10245 fCheck = eANI_BOOLEAN_FALSE;
10246 do
10247 {
10248 tANI_U32 i;
10249 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
10250 {
10251 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
10252 pScanFilter->SSIDs.SSIDList[i].SSID.length,
10253 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
10254 if ( fCheck ) break;
10255 }
10256 if(!fCheck)
10257 {
10258 break;
10259 }
10260 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
10261 || pProfile2->BSSType != pProfile1->BSSType
10262 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
10263 )
10264 {
10265 fCheck = eANI_BOOLEAN_FALSE;
10266 break;
10267 }
10268#ifdef WLAN_FEATURE_VOWIFI_11R
10269 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
10270 {
10271 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
10272 {
10273 fCheck = eANI_BOOLEAN_FALSE;
10274 break;
10275 }
10276 }
10277#endif
10278 //Match found
10279 fCheck = eANI_BOOLEAN_TRUE;
10280 }while(0);
10281 csrFreeScanFilter(pMac, pScanFilter);
10282 }
10283 palFreeMemory(pMac->hHdd, pScanFilter);
10284 }
10285 }
10286
10287 return (fCheck);
10288}
10289
Jeff Johnson295189b2012-06-20 16:38:30 -070010290tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
10291{
10292 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
10293 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010294 do
10295 {
10296 //Only check for static WEP
10297 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
10298 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
10299 {
10300 fCheck = eANI_BOOLEAN_TRUE;
10301 break;
10302 }
10303 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
10304 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
10305 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
10306 {
10307 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
10308 if(!palEqualMemory(pMac->hHdd, &pConnProfile->Keys.KeyMaterial[i],
10309 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
10310 {
10311 break;
10312 }
10313 }
10314 if( i == CSR_MAX_NUM_KEY)
10315 {
10316 fCheck = eANI_BOOLEAN_TRUE;
10317 }
10318 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010319 return (fCheck);
10320}
10321
Jeff Johnson295189b2012-06-20 16:38:30 -070010322//IBSS
10323
Jeff Johnson295189b2012-06-20 16:38:30 -070010324tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
10325{
10326 tANI_U8 channel = 0;
10327 tANI_U32 idx;
10328 tANI_U32 idxValidChannels;
10329 tANI_BOOLEAN fFound = FALSE;
10330 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10331
10332 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
10333 {
10334 channel = pMac->roam.configParam.AdHocChannel5G;
10335 if(!csrRoamIsChannelValid(pMac, channel))
10336 {
10337 channel = 0;
10338 }
10339 }
10340 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
10341 {
10342 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
10343 {
10344 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
10345 {
10346 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
10347 {
10348 fFound = TRUE;
10349 channel = csrStartIbssChannels50[ idx ];
10350 }
10351 }
10352 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010353 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
10354 if (!fFound)
10355 {
10356 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
10357 {
10358 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idx ]) ) // the max channel# in 11g is 14
10359 {
10360 channel = csrStartIbssChannels50[ idx ];
10361 break;
10362 }
10363 }
10364 }
10365 }//if
10366
10367 return( channel );
10368}
10369
Jeff Johnson295189b2012-06-20 16:38:30 -070010370tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
10371{
10372 tANI_U8 channel = 1;
10373 tANI_U32 idx;
10374 tANI_U32 idxValidChannels;
10375 tANI_BOOLEAN fFound = FALSE;
10376 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10377
10378 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
10379 {
10380 channel = pMac->roam.configParam.AdHocChannel24;
10381 if(!csrRoamIsChannelValid(pMac, channel))
10382 {
10383 channel = 0;
10384 }
10385 }
10386
10387 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
10388 {
10389 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
10390 {
10391 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
10392 {
10393 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
10394 {
10395 fFound = TRUE;
10396 channel = csrStartIbssChannels24[ idx ];
10397 }
10398 }
10399 }
10400 }
10401
10402 return( channel );
10403}
10404
Jeff Johnson295189b2012-06-20 16:38:30 -070010405static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10406 tCsrRoamStartBssParams *pParam )
10407{
10408 eCsrCfgDot11Mode cfgDot11Mode;
10409 eCsrBand eBand;
10410 tANI_U8 channel = 0;
10411 tSirNwType nwType;
10412 tANI_U8 operationChannel = 0;
10413
10414 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
10415 {
10416 operationChannel = pProfile->ChannelInfo.ChannelList[0];
10417 }
10418
Jeff Johnson295189b2012-06-20 16:38:30 -070010419 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070010420
Jeff Johnson295189b2012-06-20 16:38:30 -070010421 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
10422 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
10423 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
10424 )
10425 {
10426 /* This should never happen */
10427 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010428 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070010429 pProfile->csrPersona);
10430 VOS_ASSERT(0);
10431 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010432 switch( cfgDot11Mode )
10433 {
10434 case eCSR_CFG_DOT11_MODE_11G:
10435 nwType = eSIR_11G_NW_TYPE;
10436 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010437 case eCSR_CFG_DOT11_MODE_11B:
10438 nwType = eSIR_11B_NW_TYPE;
10439 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010440 case eCSR_CFG_DOT11_MODE_11A:
10441 nwType = eSIR_11A_NW_TYPE;
10442 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010443 default:
10444 case eCSR_CFG_DOT11_MODE_11N:
10445 case eCSR_CFG_DOT11_MODE_TAURUS:
10446 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
10447 if(eCSR_BAND_24 == eBand)
10448 {
10449 nwType = eSIR_11G_NW_TYPE;
10450 }
10451 else
10452 {
10453 nwType = eSIR_11A_NW_TYPE;
10454 }
10455 break;
10456 }
10457
10458 pParam->extendedRateSet.numRates = 0;
10459
10460 switch ( nwType )
10461 {
10462 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010463 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070010464 case eSIR_11A_NW_TYPE:
10465
10466 pParam->operationalRateSet.numRates = 8;
10467
10468 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
10469 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
10470 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
10471 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
10472 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
10473 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
10474 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
10475 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
10476
10477 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10478 {
10479 channel = csrRoamGetIbssStartChannelNumber50( pMac );
10480 if( 0 == channel &&
10481 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
10482 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
10483 )
10484 {
10485 //We could not find a 5G channel by auto pick, let's try 2.4G channels
10486 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
10487 nwType = eSIR_11B_NW_TYPE;
10488 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10489 pParam->operationalRateSet.numRates = 4;
10490 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10491 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10492 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10493 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
10494 }
10495 }
10496 else
10497 {
10498 channel = operationChannel;
10499 }
10500 break;
10501
10502 case eSIR_11B_NW_TYPE:
10503 pParam->operationalRateSet.numRates = 4;
10504 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10505 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10506 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10507 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070010508 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10509 {
10510 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10511 }
10512 else
10513 {
10514 channel = operationChannel;
10515 }
10516
10517 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010518 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070010519 /* For P2P Client and P2P GO, disable 11b rates */
10520 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
10521 (pProfile->csrPersona == VOS_P2P_GO_MODE)
10522 )
10523 {
10524 pParam->operationalRateSet.numRates = 8;
10525
10526 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
10527 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
10528 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
10529 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
10530 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
10531 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
10532 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
10533 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
10534 }
10535 else
Jeff Johnson295189b2012-06-20 16:38:30 -070010536 {
10537 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070010538 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10539 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10540 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10541 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
10542
10543 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070010544 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
10545 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
10546 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
10547 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
10548 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
10549 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
10550 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
10551 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
10552 }
10553
10554 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10555 {
10556 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10557 }
10558 else
10559 {
10560 channel = operationChannel;
10561 }
10562
10563 break;
10564 }
10565 pParam->operationChn = channel;
10566 pParam->sirNwType = nwType;
10567}
10568
Jeff Johnson295189b2012-06-20 16:38:30 -070010569static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
10570 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
10571{
10572
10573 if( pParam )
10574 {
10575 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070010576 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010577 pParam->operationChn = pBssDesc->channelId;
10578 palCopyMemory( pMac->hHdd, &pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid) );
10579
10580 if( pIes )
10581 {
10582 if(pIes->SuppRates.present)
10583 {
10584 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
10585 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
10586 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010587 smsLog(pMac, LOGE, FL("num_rates :%d is more than SIR_MAC_RATESET_EID_MAX, resetting to SIR_MAC_RATESET_EID_MAX"),
Jeff Johnson295189b2012-06-20 16:38:30 -070010588 pIes->SuppRates.num_rates);
10589 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
10590 }
10591 palCopyMemory(pMac->hHdd, pParam->operationalRateSet.rate, pIes->SuppRates.rates,
10592 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
10593 }
10594 if( pIes->SSID.present )
10595 {
10596 pParam->ssId.length = pIes->SSID.num_ssid;
10597 palCopyMemory(pMac->hHdd, pParam->ssId.ssId, pIes->SSID.ssid, pParam->ssId.length);
10598 }
10599 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070010600 }
10601 else
10602 {
10603 pParam->ssId.length = 0;
10604 pParam->operationalRateSet.numRates = 0;
10605 }
10606 }
10607}
10608
Jeff Johnson295189b2012-06-20 16:38:30 -070010609static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
10610{
10611 tANI_U8 MaxRate = 0;
10612 tANI_U32 i;
10613 tANI_U8 *pRate;
10614
10615 pRate = pSirRateSet->rate;
10616 for ( i = 0; i < pSirRateSet->numRates; i++ )
10617 {
10618 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
10619 }
10620
10621 // Save the max rate in the connected state information...
10622
10623 // modify LastRates variable as well
10624
10625 return;
10626}
10627
Jeff Johnson295189b2012-06-20 16:38:30 -070010628//this function finds a valid secondary channel for channel bonding with "channel".
10629//Param: channel -- primary channel, caller must validate it
10630// cbChoice -- CB directory
10631//Return: if 0, no secondary channel is found. Otherwise a valid secondary channel.
10632static tANI_U8 csrRoamGetSecondaryChannel(tpAniSirGlobal pMac, tANI_U8 channel, eCsrCBChoice cbChoice)
10633{
10634 tANI_U8 chnUp = 0, chnDown = 0, chnRet = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010635 switch (cbChoice)
10636 {
10637 case eCSR_CB_OFF:
10638 chnUp = 0;
10639 chnDown = 0;
10640 break;
10641 case eCSR_CB_DOWN:
10642 chnUp = 0;
10643 chnDown = channel - CSR_CB_CHANNEL_GAP;
10644 break;
10645 case eCSR_CB_UP:
10646 chnUp = channel + CSR_CB_CHANNEL_GAP;
10647 chnDown = 0;
10648 break;
10649 case eCSR_CB_AUTO:
10650 //consider every other value means auto
10651 default:
10652 chnUp = channel + CSR_CB_CHANNEL_GAP;
10653 chnDown = channel - CSR_CB_CHANNEL_GAP;
10654 break;
10655 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010656 //if CB_UP or auto, try channel up first
10657 if(chnUp && CSR_IS_SAME_BAND_CHANNELS(chnUp, channel) && csrRoamIsChannelValid(pMac, chnUp))
10658 {
10659 //found a valid up channel for channel bonding
10660 //check whether the center channel is valid
10661 if(csrRoamIsValid40MhzChannel(pMac, channel + CSR_CB_CENTER_CHANNEL_OFFSET))
10662 {
10663 chnRet = chnUp;
10664 }
10665 }
10666 if(chnRet == 0 && chnDown && CSR_IS_SAME_BAND_CHANNELS(chnDown, channel) && csrRoamIsChannelValid(pMac, chnDown))
10667 {
10668 //found a valid down channel for channel bonding
10669 if(csrRoamIsValid40MhzChannel(pMac, channel - CSR_CB_CENTER_CHANNEL_OFFSET))
10670 {
10671 chnRet = chnDown;
10672 }
10673 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010674 return chnRet;
10675}
10676
Jeff Johnson295189b2012-06-20 16:38:30 -070010677eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
10678 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
10679{
10680 eHalStatus status = eHAL_STATUS_SUCCESS;
10681 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010682 // Set the roaming substate to 'Start BSS attempt'...
10683 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010684#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10685 //Need to figure out whether we need to log WDS???
10686 if( CSR_IS_IBSS( pProfile ) )
10687 {
10688 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010689 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10690 if(pIbssLog)
10691 {
10692 if(pBssDesc)
10693 {
10694 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
10695 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pBssDesc->bssId, 6);
10696 }
10697 else
10698 {
10699 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
10700 }
10701 palCopyMemory(pMac->hHdd, pIbssLog->ssid, pParam->ssId.ssId,
10702 pParam->ssId.length);
10703 if(pProfile->ChannelInfo.numOfChannels == 0)
10704 {
10705 pIbssLog->channelSetting = AUTO_PICK;
10706 }
10707 else
10708 {
10709 pIbssLog->channelSetting = SPECIFIED;
10710 }
10711 pIbssLog->operatingChannel = pParam->operationChn;
10712 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10713 }
10714 }
10715#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
10716 //Put RSN information in for Starting BSS
10717 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
10718 pParam->pRSNIE = pProfile->pRSNReqIE;
10719
Jeff Johnson295189b2012-06-20 16:38:30 -070010720 pParam->privacy = pProfile->privacy;
10721 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
10722 pParam->authType = pProfile->csr80211AuthType;
10723 pParam->beaconInterval = pProfile->beaconInterval;
10724 pParam->dtimPeriod = pProfile->dtimPeriod;
10725 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
10726 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
10727 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
10728 {
10729 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
10730 {
10731 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
10732 }
10733 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010734 pParam->protEnabled = pProfile->protEnabled;
10735 pParam->obssProtEnabled = pProfile->obssProtEnabled;
10736 pParam->ht_protection = pProfile->cfg_protection;
10737 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080010738
Jeff Johnson295189b2012-06-20 16:38:30 -070010739 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
10740 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070010741 pParam->bssPersona = pProfile->csrPersona;
10742 // When starting an IBSS, start on the channel from the Profile.
10743 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070010744 return (status);
10745}
10746
Jeff Johnson295189b2012-06-20 16:38:30 -070010747static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070010748 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070010749{
10750 tANI_U8 Channel, SecondChn;
Jeff Johnsone7245742012-09-05 17:12:55 -070010751 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010752 eCsrCBChoice cbChoice;
10753 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010754
10755 if(!pSession)
10756 {
10757 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10758 return;
10759 }
10760
Jeff Johnson295189b2012-06-20 16:38:30 -070010761 if( pBssDesc )
10762 {
10763 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
10764 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
10765 //The following code has to be do after that.
10766 //For WDS station, use selfMac as the self BSSID
10767 if( CSR_IS_WDS_STA( pProfile ) )
10768 {
10769 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, &pSession->selfMacAddr, sizeof(tCsrBssid));
10770 }
10771 }
10772 else
10773 {
10774 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070010775 //Use the first SSID
10776 if(pProfile->SSIDs.numOfSSIDs)
10777 {
10778 palCopyMemory(pMac->hHdd, &pSession->bssParams.ssId, pProfile->SSIDs.SSIDList, sizeof(tSirMacSSid));
10779 }
10780 //For WDS station, use selfMac as the self BSSID
10781 if( CSR_IS_WDS_STA( pProfile ) )
10782 {
10783 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, &pSession->selfMacAddr, sizeof(tCsrBssid));
10784 }
10785 //Use the first BSSID
10786 else if( pProfile->BSSIDs.numOfBSSIDs )
10787 {
10788 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, pProfile->BSSIDs.bssid, sizeof(tCsrBssid));
10789 }
10790 else
10791 {
10792 palZeroMemory( pMac->hHdd, &pSession->bssParams.bssid, sizeof(tCsrBssid) );
10793 }
10794 }
10795 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070010796 //Set operating channel in pProfile which will be used
10797 //in csrRoamSetBssConfigCfg() to determine channel bonding
10798 //mode and will be configured in CFG later
10799 pProfile->operationChannel = Channel;
10800
10801 if(Channel == 0)
10802 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010803 smsLog(pMac, LOGW, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070010804 }
10805 else
10806 {
10807
10808 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Jeff Johnsone7245742012-09-05 17:12:55 -070010809 if (CSR_IS_INFRA_AP(pProfile))
10810 {
10811 if(CSR_IS_CHANNEL_24GHZ(Channel))
10812 {
10813 cbMode = pMac->roam.configParam.channelBondingMode24GHz;
10814 }
10815 else
10816 {
10817 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
10818 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010819 smsLog(pMac, LOG1, "##softap cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070010820 pBssConfig->cbMode = cbMode;
10821 pSession->bssParams.cbMode = cbMode;
10822 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010823
10824 if( CSR_IS_START_IBSS( pProfile ) )
10825 {
10826 //TBH: channel bonding is not supported for Libra
10827 if( pProfile->ChannelInfo.ChannelList && eCSR_OPERATING_CHANNEL_AUTO != pProfile->ChannelInfo.ChannelList[0] )
10828 {
10829 Channel = pProfile->ChannelInfo.ChannelList[0];
10830 cbChoice = pProfile->CBMode;
10831 }
10832 else {
10833 cbChoice = pMac->roam.configParam.cbChoice;
10834 }
10835 pSession->bssParams.operationChn = Channel;
10836 //make sure channel is valid
10837 if(!csrRoamIsChannelValid(pMac, Channel))
10838 {
10839 //set Channel to 0 to let lim know this is invalid
10840 //We still send this request down to lim even though we know the channel is wrong because
10841 //lim will response with error and hdd's eWNI_SME_START_BSS_RSP handler will roam other profile (if any)
10842 Channel = 0;
10843 pSession->bssParams.operationChn = 0;
10844 }
10845 else {
10846 tANI_U32 ChannelBondingMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010847 if(CSR_IS_CHANNEL_24GHZ(Channel))
10848 {
10849 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
10850 }
10851 else
10852 {
10853 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
10854 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010855 //now we have a valid channel
10856 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
10857 {
10858 //let's pick a secondard channel
10859 SecondChn = csrRoamGetSecondaryChannel(pMac, Channel, cbChoice);
Jeff Johnson295189b2012-06-20 16:38:30 -070010860 if(SecondChn > Channel)
10861 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010862 cbMode = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010863 }
10864 else if(SecondChn && SecondChn < Channel)
10865 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010866 cbMode = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010867 }
10868 else
10869 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010870 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010871 }
10872 pSession->bssParams.cbMode = cbMode;
10873 }
10874 else
10875 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010876 pSession->bssParams.cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010877 }
10878 }
10879 }
10880 }
10881}
10882
Jeff Johnson295189b2012-06-20 16:38:30 -070010883static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
10884 tANI_BOOLEAN *pfSameIbss )
10885{
10886 eHalStatus status = eHAL_STATUS_SUCCESS;
10887 tANI_BOOLEAN fSameIbss = FALSE;
10888
10889 if ( csrIsConnStateIbss( pMac, sessionId ) )
10890 {
10891 // Check if any profile parameter has changed ? If any profile parameter
10892 // has changed then stop old BSS and start a new one with new parameters
10893 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
10894 {
10895 fSameIbss = TRUE;
10896 }
10897 else
10898 {
10899 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
10900 }
10901 }
10902 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
10903 {
10904 // Disassociate from the connected Infrastructure network...
10905 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
10906 }
10907 else
10908 {
10909 tBssConfigParam *pBssConfig;
10910
10911 status = palAllocateMemory(pMac->hHdd, (void **)&pBssConfig, sizeof(tBssConfigParam));
10912 if(HAL_STATUS_SUCCESS(status))
10913 {
10914 palZeroMemory(pMac->hHdd, pBssConfig, sizeof(tBssConfigParam));
10915 // there is no Bss description before we start an IBSS so we need to adopt
10916 // all Bss configuration parameters from the Profile.
10917 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
10918 if(HAL_STATUS_SUCCESS(status))
10919 {
10920 //save dotMode
10921 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
10922 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070010923 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070010924 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
10925 }
10926
10927 palFreeMemory(pMac->hHdd, pBssConfig);
10928 }//Allocate memory
10929 }
10930
10931 if(pfSameIbss)
10932 {
10933 *pfSameIbss = fSameIbss;
10934 }
10935 return( status );
10936}
10937
Jeff Johnson295189b2012-06-20 16:38:30 -070010938static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
10939 tSirSmeNewBssInfo *pNewBss )
10940{
10941 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010942
10943 if(!pSession)
10944 {
10945 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10946 return;
10947 }
10948
Jeff Johnson295189b2012-06-20 16:38:30 -070010949 if( pNewBss )
10950 {
10951 // Set the operating channel.
10952 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
10953 // move the BSSId from the BSS description into the connected state information.
10954 palCopyMemory( pMac->hHdd, &pSession->connectedProfile.bssid,
10955 &(pNewBss->bssId), sizeof( tCsrBssid ) );
10956 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010957 return;
10958}
10959
Jeff Johnson295189b2012-06-20 16:38:30 -070010960#ifdef FEATURE_WLAN_WAPI
10961eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
10962 tANI_U32 numItems )
10963{
10964 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
10965 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070010966 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
10967 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010968 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010969 return status;
10970 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010971 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070010972 pSession = CSR_GET_SESSION( pMac, sessionId );
10973 if(numItems <= CSR_MAX_BKID_ALLOWED)
10974 {
10975 status = eHAL_STATUS_SUCCESS;
10976 //numItems may be 0 to clear the cache
10977 pSession->NumBkidCache = (tANI_U16)numItems;
10978 if(numItems && pBKIDCache)
10979 {
10980 status = palCopyMemory( pMac->hHdd, pSession->BkidCacheInfo, pBKIDCache,
10981 sizeof(tBkidCacheInfo) * numItems );
10982 }
10983 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010984 return (status);
10985}
Jeff Johnson295189b2012-06-20 16:38:30 -070010986eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
10987 tBkidCacheInfo *pBkidCache)
10988{
10989 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
10990 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070010991 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
10992 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010993 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010994 return status;
10995 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010996 pSession = CSR_GET_SESSION( pMac, sessionId );
10997 if(pNum && pBkidCache)
10998 {
10999 if(pSession->NumBkidCache == 0)
11000 {
11001 *pNum = 0;
11002 status = eHAL_STATUS_SUCCESS;
11003 }
11004 else if(*pNum >= pSession->NumBkidCache)
11005 {
11006 if(pSession->NumBkidCache > CSR_MAX_PMKID_ALLOWED)
11007 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011008 smsLog(pMac, LOGE, FL("NumPmkidCache :%d is more than CSR_MAX_PMKID_ALLOWED, resetting to CSR_MAX_PMKID_ALLOWED"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011009 pSession->NumBkidCache);
11010 pSession->NumBkidCache = CSR_MAX_PMKID_ALLOWED;
11011 }
11012 palCopyMemory( pMac->hHdd, pBkidCache, pSession->BkidCacheInfo,
11013 sizeof(tBkidCacheInfo) * pSession->NumBkidCache );
11014 *pNum = pSession->NumBkidCache;
11015 status = eHAL_STATUS_SUCCESS;
11016 }
11017 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011018 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070011019}
Jeff Johnson295189b2012-06-20 16:38:30 -070011020tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11021{
11022 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011023}
11024#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011025eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
11026 tPmkidCacheInfo *pPMKIDCache, tANI_U32 numItems )
11027{
11028 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11029 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011030
11031 if(!pSession)
11032 {
11033 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11034 return eHAL_STATUS_FAILURE;
11035 }
11036
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011037 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011038 if(numItems <= CSR_MAX_PMKID_ALLOWED)
11039 {
11040#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11041 {
11042 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
11043 palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type));
11044 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
11045 secEvent.encryptionModeMulticast =
11046 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
11047 secEvent.encryptionModeUnicast =
11048 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
11049 palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 );
11050 secEvent.authMode =
11051 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
11052 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
11053 }
11054#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011055 status = eHAL_STATUS_SUCCESS;
11056 //numItems may be 0 to clear the cache
11057 pSession->NumPmkidCache = (tANI_U16)numItems;
11058 if(numItems && pPMKIDCache)
11059 {
11060 status = palCopyMemory( pMac->hHdd, pSession->PmkidCacheInfo, pPMKIDCache,
11061 sizeof(tPmkidCacheInfo) * numItems );
11062 }
11063 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011064 return (status);
11065}
11066
Jeff Johnson295189b2012-06-20 16:38:30 -070011067tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11068{
11069 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
11070}
11071
Jeff Johnson295189b2012-06-20 16:38:30 -070011072eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
11073{
11074 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11075 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011076
11077 if(!pSession)
11078 {
11079 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11080 return eHAL_STATUS_FAILURE;
11081 }
11082
Jeff Johnson295189b2012-06-20 16:38:30 -070011083 if(pNum && pPmkidCache)
11084 {
11085 if(pSession->NumPmkidCache == 0)
11086 {
11087 *pNum = 0;
11088 status = eHAL_STATUS_SUCCESS;
11089 }
11090 else if(*pNum >= pSession->NumPmkidCache)
11091 {
11092 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
11093 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011094 smsLog(pMac, LOGE, FL("NumPmkidCache :%d is more than CSR_MAX_PMKID_ALLOWED, resetting to CSR_MAX_PMKID_ALLOWED"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011095 pSession->NumPmkidCache);
11096 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
11097 }
11098 palCopyMemory( pMac->hHdd, pPmkidCache, pSession->PmkidCacheInfo,
11099 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache );
11100 *pNum = pSession->NumPmkidCache;
11101 status = eHAL_STATUS_SUCCESS;
11102 }
11103 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011104 return (status);
11105}
11106
Jeff Johnson295189b2012-06-20 16:38:30 -070011107eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11108{
11109 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11110 tANI_U32 len;
11111 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011112
11113 if(!pSession)
11114 {
11115 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11116 return eHAL_STATUS_FAILURE;
11117 }
11118
Jeff Johnson295189b2012-06-20 16:38:30 -070011119 if(pLen)
11120 {
11121 len = *pLen;
11122 *pLen = pSession->nWpaRsnReqIeLength;
11123 if(pBuf)
11124 {
11125 if(len >= pSession->nWpaRsnReqIeLength)
11126 {
11127 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWpaRsnReqIE, pSession->nWpaRsnReqIeLength);
11128 }
11129 }
11130 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011131 return (status);
11132}
11133
Jeff Johnson295189b2012-06-20 16:38:30 -070011134eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11135{
11136 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11137 tANI_U32 len;
11138 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011139
11140 if(!pSession)
11141 {
11142 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11143 return eHAL_STATUS_FAILURE;
11144 }
11145
Jeff Johnson295189b2012-06-20 16:38:30 -070011146 if(pLen)
11147 {
11148 len = *pLen;
11149 *pLen = pSession->nWpaRsnRspIeLength;
11150 if(pBuf)
11151 {
11152 if(len >= pSession->nWpaRsnRspIeLength)
11153 {
11154 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWpaRsnRspIE, pSession->nWpaRsnRspIeLength);
11155 }
11156 }
11157 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011158 return (status);
11159}
Jeff Johnson295189b2012-06-20 16:38:30 -070011160#ifdef FEATURE_WLAN_WAPI
11161eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11162{
11163 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11164 tANI_U32 len;
11165 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011166
11167 if(!pSession)
11168 {
11169 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11170 return eHAL_STATUS_FAILURE;
11171 }
11172
Jeff Johnson295189b2012-06-20 16:38:30 -070011173 if(pLen)
11174 {
11175 len = *pLen;
11176 *pLen = pSession->nWapiReqIeLength;
11177 if(pBuf)
11178 {
11179 if(len >= pSession->nWapiReqIeLength)
11180 {
11181 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWapiReqIE, pSession->nWapiReqIeLength);
11182 }
11183 }
11184 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011185 return (status);
11186}
Jeff Johnson295189b2012-06-20 16:38:30 -070011187eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11188{
11189 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11190 tANI_U32 len;
11191 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011192
11193 if(!pSession)
11194 {
11195 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11196 return eHAL_STATUS_FAILURE;
11197 }
11198
Jeff Johnson295189b2012-06-20 16:38:30 -070011199 if(pLen)
11200 {
11201 len = *pLen;
11202 *pLen = pSession->nWapiRspIeLength;
11203 if(pBuf)
11204 {
11205 if(len >= pSession->nWapiRspIeLength)
11206 {
11207 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWapiRspIE, pSession->nWapiRspIeLength);
11208 }
11209 }
11210 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011211 return (status);
11212}
11213#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011214eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
11215{
11216 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
11217 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011218
11219 if(!pSession)
11220 {
11221 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11222 return (retStatus);
11223 }
11224
Jeff Johnson295189b2012-06-20 16:38:30 -070011225 if(CSR_IS_ROAMING(pSession))
11226 {
11227 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
11228 pSession->fRoaming = eANI_BOOLEAN_FALSE;
11229 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011230 return (retStatus);
11231}
11232
Jeff Johnson295189b2012-06-20 16:38:30 -070011233//This function remove the connected BSS from te cached scan result
11234eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
11235 tCsrRoamConnectedProfile *pConnProfile)
11236{
11237 eHalStatus status = eHAL_STATUS_FAILURE;
11238 tCsrScanResultFilter *pScanFilter = NULL;
11239 tListElem *pEntry;
11240 tCsrScanResult *pResult;
11241 tDot11fBeaconIEs *pIes;
11242 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070011243 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
11244 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
11245 {
11246 do
11247 {
11248 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
11249 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
11250 if(!HAL_STATUS_SUCCESS(status)) break;
11251 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
11252 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->BSSIDs.bssid, sizeof(tCsrBssid));
11253 if(!HAL_STATUS_SUCCESS(status)) break;
11254 palCopyMemory(pMac->hHdd, pScanFilter->BSSIDs.bssid, &pConnProfile->bssid, sizeof(tCsrBssid));
11255 pScanFilter->BSSIDs.numOfBSSIDs = 1;
11256 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
11257 {
11258 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->SSIDs.SSIDList, sizeof(tCsrSSIDInfo));
11259 if(!HAL_STATUS_SUCCESS(status)) break;
11260 palCopyMemory(pMac->hHdd, &pScanFilter->SSIDs.SSIDList[0].SSID, &pConnProfile->SSID, sizeof(tSirMacSSid));
11261 }
11262 pScanFilter->authType.numEntries = 1;
11263 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
11264 pScanFilter->BSSType = pConnProfile->BSSType;
11265 pScanFilter->EncryptionType.numEntries = 1;
11266 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
11267 pScanFilter->mcEncryptionType.numEntries = 1;
11268 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
11269 //We ignore the channel for now, BSSID should be enough
11270 pScanFilter->ChannelInfo.numOfChannels = 0;
11271 //Also ignore the following fields
11272 pScanFilter->uapsd_mask = 0;
11273 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
11274 pScanFilter->countryCode[0] = 0;
11275 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011276 csrLLLock(&pMac->scan.scanResultList);
11277 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
11278 while( pEntry )
11279 {
11280 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
11281 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
11282 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
11283 pScanFilter, NULL, NULL, NULL, &pIes);
11284 //Release the IEs allocated by csrMatchBSS is needed
11285 if( !pResult->Result.pvIes )
11286 {
11287 //need to free the IEs since it is allocated by csrMatchBSS
11288 palFreeMemory(pMac->hHdd, pIes);
11289 }
11290 if(fMatch)
11291 {
11292 //We found the one
11293 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
11294 {
11295 //Free the memory
11296 csrFreeScanResultEntry( pMac, pResult );
11297 }
11298 break;
11299 }
11300 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
11301 }//while
11302 csrLLUnlock(&pMac->scan.scanResultList);
11303 }while(0);
11304 if(pScanFilter)
11305 {
11306 csrFreeScanFilter(pMac, pScanFilter);
11307 palFreeMemory(pMac->hHdd, pScanFilter);
11308 }
11309 }
11310 return (status);
11311}
11312
Jeff Johnson295189b2012-06-20 16:38:30 -070011313//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070011314eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
11315{
11316 eHalStatus status = eHAL_STATUS_SUCCESS;
11317 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011318 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
11319 {
11320 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
11321 {
11322 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
11323 {
11324 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011325 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011326 status = eHAL_STATUS_CSR_WRONG_STATE;
11327 break;
11328 }
11329 if( csrIsConnStateInfra( pMac, sessionId ) )
11330 {
11331 if( chnId &&
11332 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
11333 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011334 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011335 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
11336 status = eHAL_STATUS_CSR_WRONG_STATE;
11337 break;
11338 }
11339 }
11340 }
11341 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011342 return ( status );
11343}
11344
Jeff Johnson295189b2012-06-20 16:38:30 -070011345static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
11346{
11347 eHalStatus status = eHAL_STATUS_SUCCESS;
11348 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11349 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070011350
11351 if(!pSession)
11352 {
11353 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11354 return eHAL_STATUS_FAILURE;
11355 }
11356
Jeff Johnson295189b2012-06-20 16:38:30 -070011357 if ( csrIsConnStateIbss( pMac, sessionId ) )
11358 {
11359 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11360 }
11361 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11362 {
11363 // Disassociate from the connected Infrastructure network...
11364 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11365 }
11366 else
11367 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011368 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
11369 //Otherwise we need to add code to handle the
11370 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
11371 //send stop_bss to PE, before we can continue.
11372 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070011373 palZeroMemory(pMac->hHdd, &bssConfig, sizeof(tBssConfigParam));
11374 /* Assume HDD provide bssid in profile */
11375 palCopyMemory( pMac->hHdd, &pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0], sizeof(tCsrBssid) );
11376 // there is no Bss description before we start an WDS so we need
11377 // to adopt all Bss configuration parameters from the Profile.
11378 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
11379 if(HAL_STATUS_SUCCESS(status))
11380 {
11381 //Save profile for late use
11382 csrFreeRoamProfile( pMac, sessionId );
11383 if (HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
11384 (void **)&pSession->pCurRoamProfile,
11385 sizeof(tCsrRoamProfile))))
11386 {
11387 palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile));
11388 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
11389 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011390 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070011391 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070011392 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
11393 }
11394 }
11395
11396 return( status );
11397}
11398
Jeff Johnson295189b2012-06-20 16:38:30 -070011399////////////////////Mail box
11400
Jeff Johnson295189b2012-06-20 16:38:30 -070011401//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
11402//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
11403static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
11404 tSirBssDescription *pBssDescription,
11405 tANI_U8 *pBuf, tANI_U8 uapsdMask)
11406{
11407 tCsrChannelSet channelGroup;
11408 tSirMacCapabilityInfo *pAP_capabilityInfo;
11409 tAniBool fTmp;
11410 tANI_BOOLEAN found = FALSE;
11411 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080011412 tANI_S8 pwrLimit = 0;
11413 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011414 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
11415 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
11416 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
11417 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070011418 // 802.11h
11419 //We can do this because it is in HOST CPU order for now.
11420 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080011421 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
11422 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
11423 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011424 fTmp = (tAniBool)pal_cpu_to_be32(1);
11425 }
11426 else
11427 fTmp = (tAniBool)0;
11428
11429 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
11430 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool) );
11431 pBuf += sizeof(tAniBool);
11432 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080011433 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070011434 // This is required for 11k test VoWiFi Ent: Test 2.
11435 // We need the power capabilities for Assoc Req.
11436 // This macro is provided by the halPhyCfg.h. We pick our
11437 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080011438 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
11439 if (0 != pwrLimit)
11440 {
11441 *pBuf++ = pwrLimit;
11442 }
11443 else
11444 {
11445 *pBuf++ = MAX_STA_PWR_CAP_DBM;
11446 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011447 size = sizeof(pMac->roam.validChannelList);
11448 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
11449 {
11450 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
11451 for ( i = 0; i < size; i++)
11452 {
11453 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
11454
11455 }
11456 }
11457 else
11458 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011459 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011460 *pBuf++ = 0; //tSirSupChnl->numChnl
11461 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011462 //Check whether it is ok to enter UAPSD
11463#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11464 if( btcIsReadyForUapsd(pMac) )
11465#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
11466 {
11467 *pBuf++ = uapsdMask;
11468 }
11469#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11470 else
11471 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011472 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070011473 *pBuf++ = 0;
11474 }
11475#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
11476
Jeff Johnson295189b2012-06-20 16:38:30 -070011477 // move the entire BssDescription into the join request.
11478 palCopyMemory( pMac->hHdd, pBuf, pBssDescription,
11479 pBssDescription->length + sizeof( pBssDescription->length ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070011480 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
11481}
11482
Jeff Johnson295189b2012-06-20 16:38:30 -070011483/*
11484 * The communication between HDD and LIM is thru mailbox (MB).
11485 * Both sides will access the data structure "tSirSmeJoinReq".
11486 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
11487 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
11488 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
11489 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
11490 */
11491eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011492 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011493{
11494 eHalStatus status = eHAL_STATUS_SUCCESS;
11495 tSirSmeJoinReq *pMsg;
11496 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011497 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070011498 tANI_U16 msgLen, wTmp, ieLen;
11499 tSirMacRateSet OpRateSet;
11500 tSirMacRateSet ExRateSet;
11501 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11502 tANI_U32 dwTmp;
11503 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Jeff Johnson32d95a32012-09-10 13:15:23 -070011504
11505 if(!pSession)
11506 {
11507 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11508 return eHAL_STATUS_FAILURE;
11509 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011510 /* To satisfy klockworks */
11511 if (NULL == pBssDescription)
11512 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011513 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011514 return eHAL_STATUS_FAILURE;
11515 }
11516
Jeff Johnson295189b2012-06-20 16:38:30 -070011517 do {
11518 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
11519 pSession->joinFailStatusCode.reasonCode = 0;
11520 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
11521 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
11522 // IE fields, but the length field in the bssDescription needs to be interpreted to
11523 // determine length of the IE fields.
11524 //
11525 // So, take the size of the JoinReq, subtract the size of the bssDescription and
11526 // add in the length from the bssDescription (then add the size of the 'length' field
11527 // itself because that is NOT included in the length field).
11528 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
11529 pBssDescription->length + sizeof( pBssDescription->length ) +
11530 sizeof( tCsrWpaIe ) + sizeof( tCsrWpaAuthIe ) + sizeof( tANI_U16 ); // add in the size of the WPA IE that we may build.
Jeff Johnson295189b2012-06-20 16:38:30 -070011531 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
11532 if ( !HAL_STATUS_SUCCESS(status) ) break;
11533 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011534 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011535 pMsg->length = pal_cpu_to_be16(msgLen);
11536 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011537 // sessionId
11538 *pBuf = (tANI_U8)sessionId;
11539 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011540 // transactionId
11541 *pBuf = 0;
11542 *( pBuf + 1 ) = 0;
11543 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070011544 // ssId
11545 if( pIes->SSID.present && pIes->SSID.num_ssid )
11546 {
11547 // ssId len
11548 *pBuf = pIes->SSID.num_ssid;
11549 pBuf++;
11550 palCopyMemory( pMac->hHdd, pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid );
11551 pBuf += pIes->SSID.num_ssid;
11552 }
11553 else
11554 {
11555 *pBuf = 0;
11556 pBuf++;
11557 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011558 // selfMacAddr
11559 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
11560 pBuf += sizeof(tSirMacAddr);
11561 // bsstype
11562 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
11563 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
11564 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tSirBssType) );
11565 pBuf += sizeof(tSirBssType);
11566 // dot11mode
11567 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
11568 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011569 //Persona
11570 *pBuf = (tANI_U8)pProfile->csrPersona;
11571 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070011572 //CBMode
11573 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
11574 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011575
11576 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070011577 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
11578
Jeff Johnson295189b2012-06-20 16:38:30 -070011579 // uapsdPerAcBitmask
11580 *pBuf = pProfile->uapsd_mask;
11581 pBuf++;
11582
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011583
11584
Jeff Johnson295189b2012-06-20 16:38:30 -070011585 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011586 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011587 {
11588 // OperationalRateSet
11589 if (OpRateSet.numRates) {
11590 *pBuf++ = OpRateSet.numRates;
11591 palCopyMemory(pMac->hHdd, pBuf, OpRateSet.rate, OpRateSet.numRates);
11592 pBuf += OpRateSet.numRates;
11593 } else *pBuf++ = 0;
11594 // ExtendedRateSet
11595 if (ExRateSet.numRates) {
11596 *pBuf++ = ExRateSet.numRates;
11597 palCopyMemory(pMac->hHdd, pBuf, ExRateSet.rate, ExRateSet.numRates);
11598 pBuf += ExRateSet.numRates;
11599 } else *pBuf++ = 0;
11600 }
11601 else
11602 {
11603 *pBuf++ = 0;
11604 *pBuf++ = 0;
11605 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011606 // rsnIE
11607 if ( csrIsProfileWpa( pProfile ) )
11608 {
11609 // Insert the Wpa IE into the join request
11610 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
11611 (tCsrWpaIe *)( wpaRsnIE ) );
11612 }
11613 else if( csrIsProfileRSN( pProfile ) )
11614 {
11615 // Insert the RSN IE into the join request
11616 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11617 (tCsrRSNIe *)( wpaRsnIE ) );
11618 }
11619#ifdef FEATURE_WLAN_WAPI
11620 else if( csrIsProfileWapi( pProfile ) )
11621 {
11622 // Insert the WAPI IE into the join request
11623 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11624 (tCsrWapiIe *)( wpaRsnIE ) );
11625 }
11626#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011627 else
11628 {
11629 ieLen = 0;
11630 }
11631 //remember the IE for future use
11632 if( ieLen )
11633 {
11634 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
11635 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011636 smsLog(pMac, LOGE, FL(" WPA RSN IE length :%d is more than DOT11F_IE_RSN_MAX_LEN, resetting to %d"), ieLen, DOT11F_IE_RSN_MAX_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070011637 ieLen = DOT11F_IE_RSN_MAX_LEN;
11638 }
11639#ifdef FEATURE_WLAN_WAPI
11640 if( csrIsProfileWapi( pProfile ) )
11641 {
11642 //Check whether we need to allocate more memory
11643 if(ieLen > pSession->nWapiReqIeLength)
11644 {
11645 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
11646 {
11647 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
11648 }
11649 status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWapiReqIE, ieLen);
11650 if(!HAL_STATUS_SUCCESS(status)) break;
11651 }
11652 pSession->nWapiReqIeLength = ieLen;
11653 palCopyMemory(pMac->hHdd, pSession->pWapiReqIE, wpaRsnIE, ieLen);
11654 wTmp = pal_cpu_to_be16( ieLen );
11655 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11656 pBuf += sizeof(tANI_U16);
11657 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11658 pBuf += ieLen;
11659 }
11660 else//should be WPA/WPA2 otherwise
11661#endif /* FEATURE_WLAN_WAPI */
11662 {
11663 //Check whether we need to allocate more memory
11664 if(ieLen > pSession->nWpaRsnReqIeLength)
11665 {
11666 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
11667 {
11668 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
11669 }
11670 status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnReqIE, ieLen);
11671 if(!HAL_STATUS_SUCCESS(status)) break;
11672 }
11673 pSession->nWpaRsnReqIeLength = ieLen;
11674 palCopyMemory(pMac->hHdd, pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
11675 wTmp = pal_cpu_to_be16( ieLen );
11676 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11677 pBuf += sizeof(tANI_U16);
11678 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11679 pBuf += ieLen;
11680 }
11681 }
11682 else
11683 {
11684 //free whatever old info
11685 pSession->nWpaRsnReqIeLength = 0;
11686 if(pSession->pWpaRsnReqIE)
11687 {
11688 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
11689 pSession->pWpaRsnReqIE = NULL;
11690 }
11691#ifdef FEATURE_WLAN_WAPI
11692 pSession->nWapiReqIeLength = 0;
11693 if(pSession->pWapiReqIE)
11694 {
11695 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
11696 pSession->pWapiReqIE = NULL;
11697 }
11698#endif /* FEATURE_WLAN_WAPI */
11699 //length is two bytes
11700 *pBuf = 0;
11701 *(pBuf + 1) = 0;
11702 pBuf += 2;
11703 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011704#ifdef FEATURE_WLAN_CCX
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011705 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011706 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011707 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070011708 //length is two bytes
11709 *pBuf = 0;
11710 *(pBuf + 1) = 0;
11711 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011712 }
11713 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011714 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011715 // cckmIE
11716 if( csrIsProfileCCX( pProfile ) )
11717 {
11718 // Insert the CCKM IE into the join request
11719 ieLen = csrConstructCcxCckmIe( pMac,
11720 pSession,
11721 pProfile,
11722 pBssDescription,
11723 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070011724 pSession->nWpaRsnReqIeLength,
11725 (void *)( wpaRsnIE ) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011726 }
11727 else
11728 {
11729 ieLen = 0;
11730 }
11731 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
11732 if( ieLen )
11733 {
11734 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
11735 wTmp = pal_cpu_to_be16( ieLen );
11736 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11737 pBuf += sizeof(tANI_U16);
11738 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11739 pBuf += ieLen;
11740 }
11741 else
11742 {
11743 //Indicate you have no CCKM IE
11744 //length is two bytes
11745 *pBuf = 0;
11746 *(pBuf + 1) = 0;
11747 pBuf += 2;
11748 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011749 }
11750#endif /* FEATURE_WLAN_CCX */
Jeff Johnson295189b2012-06-20 16:38:30 -070011751 // addIEScan
11752 if(pProfile->nAddIEScanLength && pProfile->pAddIEScan)
11753 {
11754 ieLen = pProfile->nAddIEScanLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070011755 if(ieLen > pSession->nAddIEScanLength)
11756 {
11757 if(pSession->pAddIEScan && pSession->nAddIEScanLength)
11758 {
11759 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
11760 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011761 status = palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070011762 (void **)&pSession->pAddIEScan, ieLen);
11763 if(!HAL_STATUS_SUCCESS(status)) break;
11764 }
11765 pSession->nAddIEScanLength = ieLen;
11766 palCopyMemory(pMac->hHdd, pSession->pAddIEScan,
11767 pProfile->pAddIEScan, ieLen);
11768 wTmp = pal_cpu_to_be16( ieLen );
11769 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11770 pBuf += sizeof(tANI_U16);
11771 palCopyMemory( pMac->hHdd, pBuf, pProfile->pAddIEScan, ieLen );
11772 pBuf += ieLen;
11773 }
11774 else
11775 {
11776 pSession->nAddIEScanLength = 0;
11777 if(pSession->pAddIEScan)
11778 {
11779 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
11780 pSession->pAddIEScan = NULL;
11781 }
11782 *pBuf = 0;
11783 *(pBuf + 1) = 0;
11784 pBuf += 2;
11785 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011786 // addIEAssoc
11787 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
11788 {
11789 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070011790 if(ieLen > pSession->nAddIEAssocLength)
11791 {
11792 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
11793 {
11794 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
11795 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011796 status = palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070011797 (void **)&pSession->pAddIEAssoc, ieLen);
11798 if(!HAL_STATUS_SUCCESS(status)) break;
11799 }
11800 pSession->nAddIEAssocLength = ieLen;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011801 palCopyMemory(pMac->hHdd, pSession->pAddIEAssoc,
Jeff Johnson295189b2012-06-20 16:38:30 -070011802 pProfile->pAddIEAssoc, ieLen);
11803 wTmp = pal_cpu_to_be16( ieLen );
11804 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11805 pBuf += sizeof(tANI_U16);
11806 palCopyMemory( pMac->hHdd, pBuf, pProfile->pAddIEAssoc, ieLen );
11807 pBuf += ieLen;
11808 }
11809 else
11810 {
11811 pSession->nAddIEAssocLength = 0;
11812 if(pSession->pAddIEAssoc)
11813 {
11814 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
11815 pSession->pAddIEAssoc = NULL;
11816 }
11817 *pBuf = 0;
11818 *(pBuf + 1) = 0;
11819 pBuf += 2;
11820 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011821
11822 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011823 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011824 //Unmask any AC in reassoc that is ACM-set
11825 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
11826 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011827 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011828 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
11829 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011830#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011831 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070011832#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011833 uapsd_mask &= ~(acm_mask);
11834 }
11835 else
11836 {
11837 uapsd_mask = 0;
11838 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011839 }
11840 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011841
Jeff Johnson295189b2012-06-20 16:38:30 -070011842 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
11843 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011844 pBuf += sizeof(tANI_U32);
11845
Jeff Johnson295189b2012-06-20 16:38:30 -070011846 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
11847 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011848 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070011849#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011850 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053011851 if (csrIsProfile11r( pProfile )
11852#ifdef FEATURE_WLAN_CCX
11853 && !((pIes->CCXVersion.present) && (pMac->roam.configParam.isCcxIniFeatureEnabled))
11854#endif
11855 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011856 {
11857 // is11Rconnection;
11858 dwTmp = pal_cpu_to_be32(TRUE);
11859 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11860 pBuf += sizeof(tAniBool);
11861 }
11862 else
11863 {
11864 // is11Rconnection;
11865 dwTmp = pal_cpu_to_be32(FALSE);
11866 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11867 pBuf += sizeof(tAniBool);
11868 }
11869#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011870#ifdef FEATURE_WLAN_CCX
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011871 /* A profile can not be both CCX and 11R. But an 802.11R AP
11872 * may be advertising support for CCX as well. So if we are
11873 * associating Open or explicitly CCX then we will get CCX.
11874 * If we are associating explictly 11R only then we will get
11875 * 11R.
11876 */
11877 if ((csrIsProfileCCX(pProfile) ||
11878 ((pIes->CCXVersion.present)
11879 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011880 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
11881 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
11882 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011883 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011884 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
11885 {
11886 // isCCXconnection;
11887 dwTmp = pal_cpu_to_be32(TRUE);
11888 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11889 pBuf += sizeof(tAniBool);
11890 }
11891 else
11892 {
11893 //isCCXconnection;
11894 dwTmp = pal_cpu_to_be32(FALSE);
11895 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11896 pBuf += sizeof(tAniBool);
11897 }
11898
11899 if (eWNI_SME_JOIN_REQ == messageType)
11900 {
11901 tCCXTspecInfo ccxTspec;
11902 // CCX-Tspec IEs in the ASSOC request is presently not supported
11903 // so nullify the TSPEC parameters
11904 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
11905 palCopyMemory( pMac->hHdd, pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
11906 pBuf += sizeof(tCCXTspecInfo);
11907 }
11908 else if (eWNI_SME_REASSOC_REQ == messageType)
11909 {
11910 if ((csrIsProfileCCX(pProfile) ||
11911 ((pIes->CCXVersion.present)
11912 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011913 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
11914 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
11915 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011916 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011917 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070011918 {
11919 tCCXTspecInfo ccxTspec;
Jeff Johnson295189b2012-06-20 16:38:30 -070011920 // CCX Tspec information
11921 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
11922 ccxTspec.numTspecs = sme_QosCCxRetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &ccxTspec.tspec[0]);
11923 *pBuf = ccxTspec.numTspecs;
11924 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070011925 // Copy the TSPEC information only if present
11926 if (ccxTspec.numTspecs) {
11927 palCopyMemory(pMac->hHdd, pBuf, (void*)&ccxTspec.tspec[0], (ccxTspec.numTspecs*sizeof(tTspecInfo)));
11928 }
11929 pBuf += sizeof(ccxTspec.tspec);
11930 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011931 else
Jeff Johnson295189b2012-06-20 16:38:30 -070011932 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011933 tCCXTspecInfo ccxTspec;
11934 // CCX-Tspec IEs in the ASSOC request is presently not supported
11935 // so nullify the TSPEC parameters
11936 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
11937 palCopyMemory( pMac->hHdd, pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
11938 pBuf += sizeof(tCCXTspecInfo);
11939 }
11940 }
11941#endif // FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011942#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070011943 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011944 if (pMac->roam.configParam.isFastTransitionEnabled
11945#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053011946 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011947#endif
11948 )
Jeff Johnson295189b2012-06-20 16:38:30 -070011949 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011950 dwTmp = pal_cpu_to_be32(TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011951 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011952 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070011953 }
11954 else
11955 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011956 dwTmp = pal_cpu_to_be32(FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011957 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011958 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070011959 }
11960#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070011961#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053011962 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070011963 {
11964 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011965 dwTmp = pal_cpu_to_be32(TRUE);
Jeff Johnson43971f52012-07-17 12:26:56 -070011966 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011967 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070011968 }
11969 else
11970 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011971 dwTmp = pal_cpu_to_be32(FALSE);
Jeff Johnson43971f52012-07-17 12:26:56 -070011972 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011973 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070011974 }
11975#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011976
11977 // txLdpcIniFeatureEnabled
11978 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
11979 pBuf++;
11980
Kiran4a17ebe2013-01-31 10:43:43 -080011981 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
11982 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
11983 {
11984 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
11985 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
11986 csrApplyPower2Current(pMac);
11987 }
11988
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080011989#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080011990 // txBFIniFeatureEnabled
11991 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
11992 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080011993
11994 // txBFCsnValue
11995 *pBuf = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
11996 pBuf++;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080011997#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011998 //BssDesc
11999 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
12000 (tANI_U8)pProfile->uapsd_mask);
12001 status = palSendMBMessage(pMac->hHdd, pMsg );
12002 if(!HAL_STATUS_SUCCESS(status))
12003 {
12004 break;
12005 }
12006 else
12007 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012008#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012009 if (eWNI_SME_JOIN_REQ == messageType)
12010 {
12011 //Tush-QoS: notify QoS module that join happening
12012 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
12013 }
12014 else if (eWNI_SME_REASSOC_REQ == messageType)
12015 {
12016 //Tush-QoS: notify QoS module that reassoc happening
12017 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
12018 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012019#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012020 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012021 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012022 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070012023}
12024
Jeff Johnson295189b2012-06-20 16:38:30 -070012025//
12026eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12027{
12028 eHalStatus status = eHAL_STATUS_SUCCESS;
12029 tSirSmeDisassocReq *pMsg;
12030 tANI_U8 *pBuf;
12031 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012032 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12033 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12034 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012035 do {
12036 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDisassocReq ));
12037 if ( !HAL_STATUS_SUCCESS(status) ) break;
12038 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDisassocReq ));
12039 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
12040 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012041 pBuf = &pMsg->sessionId;
12042 // sessionId
12043 *pBuf++ = (tANI_U8)sessionId;
12044 // transactionId
12045 *pBuf = 0;
12046 *( pBuf + 1 ) = 0;
12047 pBuf += sizeof(tANI_U16);
12048
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053012049 if ( (pSession->pCurRoamProfile != NULL) &&
12050 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
12051 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012052 {
12053 // Set the bssid address before sending the message to LIM
12054 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pSession->selfMacAddr, sizeof( tSirMacAddr ) );
12055 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012056 // Set the peer MAC address before sending the message to LIM
12057 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ) ); //perMacAddr is passed as bssId for softAP
12058 pBuf = pBuf + sizeof ( tSirMacAddr );
12059 }
12060 else
12061 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012062 // Set the peer MAC address before sending the message to LIM
12063 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ) );
12064 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012065 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ) );
12066 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012067 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012068 if(!HAL_STATUS_SUCCESS(status))
12069 {
12070 palFreeMemory(pMac->hHdd, pMsg);
12071 break;
12072 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012073 // reasonCode
12074 wTmp = pal_cpu_to_be16(reasonCode);
12075 status = palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12076 if(!HAL_STATUS_SUCCESS(status))
12077 {
12078 palFreeMemory(pMac->hHdd, pMsg);
12079 break;
12080 }
12081 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012082 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
12083 Here we should not send the disassoc over the air to the AP */
12084 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
12085#ifdef WLAN_FEATURE_VOWIFI_11R
12086 && csrRoamIs11rAssoc(pMac)
12087#endif
12088 )
12089 {
12090 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
12091 }
12092 pBuf += sizeof(tANI_U8);
12093 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012094 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012095 return( status );
12096}
Jeff Johnson295189b2012-06-20 16:38:30 -070012097eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
12098{
12099 eHalStatus status = eHAL_STATUS_SUCCESS;
12100 tSirSmeTkipCntrMeasReq *pMsg;
12101 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012102 do
12103 {
12104 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeTkipCntrMeasReq ));
12105 if ( !HAL_STATUS_SUCCESS(status) ) break;
12106 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeTkipCntrMeasReq ));
12107 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
12108 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012109 pBuf = &pMsg->sessionId;
12110 // sessionId
12111 *pBuf++ = (tANI_U8)sessionId;
12112 // transactionId
12113 *pBuf = 0;
12114 *( pBuf + 1 ) = 0;
12115 pBuf += sizeof(tANI_U16);
12116 // bssid
12117 status = palCopyMemory( pMac->hHdd, pMsg->bssId, bssId, sizeof( tSirMacAddr ) );
12118 pBuf = pBuf + sizeof ( tSirMacAddr );
12119 // bEnable
12120 *pBuf = (tANI_BOOLEAN)bEnable;
12121 if(!HAL_STATUS_SUCCESS(status))
12122 {
12123 palFreeMemory(pMac->hHdd, pMsg);
12124 break;
12125 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012126 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012127 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012128 return( status );
12129}
Jeff Johnson295189b2012-06-20 16:38:30 -070012130eHalStatus
12131csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
12132 VOS_MODULE_ID modId, tSirMacAddr bssId,
12133 void *pUsrContext, void *pfnSapEventCallback,
12134 tANI_U8 *pAssocStasBuf )
12135{
12136 eHalStatus status = eHAL_STATUS_SUCCESS;
12137 tSirSmeGetAssocSTAsReq *pMsg;
12138 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
12139 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012140 do
12141 {
12142 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeGetAssocSTAsReq ) );
12143 if (!HAL_STATUS_SUCCESS(status)) break;
12144 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirSmeGetAssocSTAsReq ) );
12145 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012146 pBuf = (tANI_U8 *)&pMsg->bssId;
12147 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012148 // bssId
12149 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr) );
12150 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012151 // modId
12152 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
12153 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
12154 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012155 // pUsrContext
12156 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
12157 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12158 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012159 // pfnSapEventCallback
12160 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
12161 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12162 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012163 // pAssocStasBuf
12164 dwTmp = pal_cpu_to_be32((tANI_U32)pAssocStasBuf);
12165 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12166 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012167 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070012168 status = palSendMBMessage( pMac->hHdd, pMsg );
12169 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012170 return( status );
12171 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012172eHalStatus
12173csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
12174 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
12175 {
12176 eHalStatus status = eHAL_STATUS_SUCCESS;
12177 tSirSmeGetWPSPBCSessionsReq *pMsg;
12178 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
12179 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012180 do
12181 {
12182 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirSmeGetWPSPBCSessionsReq) );
12183 if (!HAL_STATUS_SUCCESS(status)) break;
12184 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ) );
12185 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012186 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
12187 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012188 // pUsrContext
12189 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
12190 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12191 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012192 // pSapEventCallback
12193 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
12194 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12195 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012196 // bssId
12197 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr) );
12198 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012199 // MAC Address of STA in WPS session
12200 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
12201 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070012202 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070012203 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012204 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012205 return( status );
12206}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012207
12208eHalStatus
12209csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
12210{
12211 tpSirChangeBIParams pMsg;
12212 tANI_U16 len = 0;
12213 eHalStatus status = eHAL_STATUS_SUCCESS;
12214 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12215
12216 if(!pSession)
12217 {
12218 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12219 return eHAL_STATUS_FAILURE;
12220 }
12221
12222 //NO need to update the Beacon Params if update beacon parameter flag is not set
12223 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
12224 return eHAL_STATUS_SUCCESS;
12225
12226 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
12227
12228 /* Create the message and send to lim */
12229 len = sizeof(tSirChangeBIParams);
12230 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, len );
12231 if(HAL_STATUS_SUCCESS(status))
12232 {
12233 palZeroMemory(pMac->hHdd, pMsg, sizeof(tSirChangeBIParams) );
12234 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
12235 pMsg->length = len;
12236
12237 // bssId
12238 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012239 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= %02x-%02x-%02x-%02x-%02x-%02x "),
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012240 pMsg->bssId[ 0 ], pMsg->bssId[ 1 ], pMsg->bssId[ 2 ],
12241 pMsg->bssId[ 3 ], pMsg->bssId[ 4 ], pMsg->bssId[ 5 ] );
12242 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012243 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012244 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
12245 status = palSendMBMessage(pMac->hHdd, pMsg);
12246 }
12247 return status;
12248}
12249
Jeff Johnson295189b2012-06-20 16:38:30 -070012250eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12251{
12252 eHalStatus status = eHAL_STATUS_SUCCESS;
12253 tSirSmeDeauthReq *pMsg;
12254 tANI_U8 *pBuf;
12255 tANI_U16 wTmp;
12256 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12257 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12258 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012259 do {
12260 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDeauthReq ));
12261 if ( !HAL_STATUS_SUCCESS(status) ) break;
12262 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDeauthReq ));
12263 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
12264 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
12265 //sessionId
12266 pBuf = &pMsg->sessionId;
12267 *pBuf++ = (tANI_U8)sessionId;
12268
12269 //tansactionId
12270 *pBuf = 0;
12271 *(pBuf + 1 ) = 0;
12272 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012273 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070012274 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070012275 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
12276 // Set the BSSID before sending the message to LIM
12277 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pSession->selfMacAddr, sizeof( pMsg->peerMacAddr ) );
12278 pBuf = pBuf + sizeof(tSirMacAddr);
12279 }
12280 else
12281 {
12282 // Set the BSSID before sending the message to LIM
12283 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
12284 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012285 }
12286 if(!HAL_STATUS_SUCCESS(status))
12287 {
12288 palFreeMemory(pMac->hHdd, pMsg);
12289 break;
12290 }
12291 // Set the peer MAC address before sending the message to LIM
12292 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
12293 pBuf = pBuf + sizeof(tSirMacAddr);
12294 if(!HAL_STATUS_SUCCESS(status))
12295 {
12296 palFreeMemory(pMac->hHdd, pMsg);
12297 break;
12298 }
12299 wTmp = pal_cpu_to_be16(reasonCode);
12300 status = palCopyMemory( pMac->hHdd, pBuf, &wTmp,sizeof( tANI_U16 ) );
12301 if(!HAL_STATUS_SUCCESS(status))
12302 {
12303 palFreeMemory(pMac->hHdd, pMsg);
12304 break;
12305 }
12306 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012307 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012308 return( status );
12309}
12310
Jeff Johnson295189b2012-06-20 16:38:30 -070012311eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
12312{
12313 eHalStatus status = eHAL_STATUS_SUCCESS;
12314 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070012315 do {
12316 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDisassocCnf ));
12317 if ( !HAL_STATUS_SUCCESS(status) ) break;
12318 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDisassocCnf ));
12319 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
12320 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12321 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
12322 status = palCopyMemory(pMac->hHdd, pMsg->peerMacAddr, pDisassocInd->peerMacAddr, sizeof(pMsg->peerMacAddr));
12323 if(!HAL_STATUS_SUCCESS(status))
12324 {
12325 palFreeMemory(pMac->hHdd, pMsg);
12326 break;
12327 }
12328//To test reconn
12329 status = palCopyMemory(pMac->hHdd, pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
12330 if(!HAL_STATUS_SUCCESS(status))
12331 {
12332 palFreeMemory(pMac->hHdd, pMsg);
12333 break;
12334 }
12335//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070012336 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012337 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012338 return( status );
12339}
12340
Jeff Johnson295189b2012-06-20 16:38:30 -070012341eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
12342{
12343 eHalStatus status = eHAL_STATUS_SUCCESS;
12344 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070012345 do {
12346 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDeauthCnf ));
12347 if ( !HAL_STATUS_SUCCESS(status) ) break;
12348 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDeauthCnf ));
12349 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
12350 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12351 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
12352 status = palCopyMemory(pMac->hHdd, pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
12353 if(!HAL_STATUS_SUCCESS(status))
12354 {
12355 palFreeMemory(pMac->hHdd, pMsg);
12356 break;
12357 }
12358 status = palCopyMemory(pMac->hHdd, pMsg->peerMacAddr, pDeauthInd->peerMacAddr, sizeof(pMsg->peerMacAddr));
12359 if(!HAL_STATUS_SUCCESS(status))
12360 {
12361 palFreeMemory(pMac->hHdd, pMsg);
12362 break;
12363 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012364 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012365 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012366 return( status );
12367}
Jeff Johnson295189b2012-06-20 16:38:30 -070012368eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
12369{
12370 eHalStatus status = eHAL_STATUS_SUCCESS;
12371 tSirSmeAssocCnf *pMsg;
12372 tANI_U8 *pBuf;
12373 tSirResultCodes statusCode;
12374 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012375 do {
12376 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeAssocCnf ));
12377 if ( !HAL_STATUS_SUCCESS(status) ) break;
12378 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeAssocCnf ));
12379 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
12380 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012381 pBuf = (tANI_U8 *)&pMsg->statusCode;
12382 if(HAL_STATUS_SUCCESS(Halstatus))
12383 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12384 else
12385 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
12386 palCopyMemory( pMac->hHdd, pBuf, &statusCode, sizeof(tSirResultCodes) );
12387 pBuf += sizeof(tSirResultCodes);
12388 // bssId
12389 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12390 pBuf += sizeof (tSirMacAddr);
12391 // peerMacAddr
12392 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
12393 pBuf += sizeof (tSirMacAddr);
12394 // aid
12395 wTmp = pal_cpu_to_be16(pAssocInd->aid);
12396 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12397 pBuf += sizeof (tANI_U16);
12398 // alternateBssId
12399 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12400 pBuf += sizeof (tSirMacAddr);
12401 // alternateChannelId
12402 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070012403 status = palSendMBMessage( pMac->hHdd, pMsg );
12404 if(!HAL_STATUS_SUCCESS(status))
12405 {
12406 //pMsg is freed by palSendMBMessage
12407 break;
12408 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012409 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012410 return( status );
12411}
Jeff Johnson295189b2012-06-20 16:38:30 -070012412eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
12413 tpSirSmeAssocInd pAssocInd,
12414 eHalStatus Halstatus,
12415 tANI_U8 sessionId)
12416{
12417 tSirMsgQ msgQ;
12418 eHalStatus status = eHAL_STATUS_SUCCESS;
12419 tSirSmeAssocIndToUpperLayerCnf *pMsg;
12420 tANI_U8 *pBuf;
12421 tSirResultCodes statusCode;
12422 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012423 do {
12424 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ));
12425 if ( !HAL_STATUS_SUCCESS(status) ) break;
12426 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ));
Jeff Johnsone7245742012-09-05 17:12:55 -070012427
Jeff Johnson295189b2012-06-20 16:38:30 -070012428 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
12429 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
12430
12431 pMsg->sessionId = sessionId;
12432
12433 pBuf = (tANI_U8 *)&pMsg->statusCode;
12434 if(HAL_STATUS_SUCCESS(Halstatus))
12435 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12436 else
12437 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
12438 palCopyMemory( pMac->hHdd, pBuf, &statusCode, sizeof(tSirResultCodes) );
12439 pBuf += sizeof(tSirResultCodes);
12440 // bssId
12441 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12442 pBuf += sizeof (tSirMacAddr);
12443 // peerMacAddr
12444 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
12445 pBuf += sizeof (tSirMacAddr);
12446 // StaId
12447 wTmp = pal_cpu_to_be16(pAssocInd->staId);
12448 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12449 pBuf += sizeof (tANI_U16);
12450 // alternateBssId
12451 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12452 pBuf += sizeof (tSirMacAddr);
12453 // alternateChannelId
12454 *pBuf = 11;
12455 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012456 // Instead of copying roam Info, we just copy only WmmEnabled , RsnIE information
12457 //Wmm
12458 *pBuf = pAssocInd->wmmEnabledSta;
12459 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012460 //RSN IE
12461 status = palCopyMemory(pMac->hHdd, (tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
12462 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070012463 //Additional IE
12464 status = palCopyMemory(pMac->hHdd, (void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
12465 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070012466 //reassocReq
12467 *pBuf = pAssocInd->reassocReq;
12468 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012469 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
12470 msgQ.bodyptr = pMsg;
12471 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012472 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012473 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012474 return( status );
12475}
Jeff Johnson295189b2012-06-20 16:38:30 -070012476
Jeff Johnson295189b2012-06-20 16:38:30 -070012477eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId ,
12478 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
12479 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
12480 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
12481 tANI_U8 *pKeyRsc )
12482{
12483 tSirSmeSetContextReq *pMsg;
12484 tANI_U16 msgLen;
12485 eHalStatus status = eHAL_STATUS_FAILURE;
12486 tAniEdType tmpEdType;
12487 tAniKeyDirection tmpDirection;
12488 tANI_U8 *pBuf;
12489 tANI_U8 *p;
12490 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012491 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070012492 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012493 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
12494 // key set. Since we only support upto one key, we always allocate memory for 1 key
12495 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
12496 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
12497 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
12498 ( sizeof( pMsg->keyMaterial.key ) );
12499
12500 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12501 if ( !HAL_STATUS_SUCCESS(status) ) break;
12502 palZeroMemory(pMac->hHdd, pMsg, msgLen);
12503 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
12504 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012505 //sessionId
12506 pBuf = &pMsg->sessionId;
12507 *pBuf = (tANI_U8)sessionId;
12508 pBuf++;
12509 // transactionId
12510 *pBuf = 0;
12511 *(pBuf + 1) = 0;
12512 pBuf += sizeof(tANI_U16);
12513 // peerMacAddr
12514 palCopyMemory( pMac->hHdd, pBuf,
12515 (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr) );
12516
12517 pBuf += sizeof(tSirMacAddr);
12518
12519 // bssId
12520 palCopyMemory( pMac->hHdd, pBuf,
12521 (tANI_U8 *)&pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
12522
12523 pBuf += sizeof(tSirMacAddr);
12524
12525 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012526 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
12527 // in the tSirKeyMaterial keyMaterial; field).
12528 //
12529 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
12530 // shorter than this max size. Is LIM interpreting this ok ?
12531 p = pal_set_U16( p, pal_cpu_to_be16((tANI_U16)( sizeof( pMsg->keyMaterial.numKeys ) + ( numKeys * sizeof( pMsg->keyMaterial.key ) ) )) );
Jeff Johnson295189b2012-06-20 16:38:30 -070012532 // set pMsg->keyMaterial.edType
12533 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
12534 palCopyMemory( pMac->hHdd, p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType) );
12535 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070012536 // set the pMsg->keyMaterial.numKeys field
12537 *p = numKeys;
12538 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070012539 // set pSirKey->keyId = keyId;
12540 *p = keyId;
12541 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012542 // set pSirKey->unicast = (tANI_U8)fUnicast;
12543 *p = (tANI_U8)fUnicast;
12544 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070012545 // set pSirKey->keyDirection = aniKeyDirection;
12546 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
12547 palCopyMemory( pMac->hHdd, p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection) );
12548 p += sizeof(tAniKeyDirection);
12549 // pSirKey->keyRsc = ;;
12550 palCopyMemory( pMac->hHdd, p, pKeyRsc, CSR_MAX_RSC_LEN );
12551 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070012552 // set pSirKey->paeRole
12553 *p = paeRole; // 0 is Supplicant
12554 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012555 // set pSirKey->keyLength = keyLength;
12556 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070012557 if ( keyLength && pKey )
12558 {
12559 palCopyMemory( pMac->hHdd, p, pKey, keyLength );
12560 if(keyLength == 16)
12561 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012562 smsLog(pMac, LOG1, " SME Set keyIdx (%d) encType(%d) key = %02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X",
Jeff Johnson295189b2012-06-20 16:38:30 -070012563 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
12564 pKey[5], pKey[6], pKey[7], pKey[8],
12565 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
12566 }
12567 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012568 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012569 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012570 return( status );
12571}
12572
Jeff Johnson295189b2012-06-20 16:38:30 -070012573eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
12574 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
12575{
12576 eHalStatus status;
12577 tSirSmeStartBssReq *pMsg;
12578 tANI_U8 *pBuf = NULL;
12579 tANI_U8 *wTmpBuf = NULL;
12580 tANI_U16 msgLen, wTmp;
12581 tANI_U32 dwTmp;
12582 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070012583 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012584 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070012585 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012586
12587 if(!pSession)
12588 {
12589 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12590 return eHAL_STATUS_FAILURE;
12591 }
12592
Jeff Johnson295189b2012-06-20 16:38:30 -070012593 do {
12594 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12595 pSession->joinFailStatusCode.reasonCode = 0;
12596 msgLen = sizeof(tSirSmeStartBssReq);
12597 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12598 if ( !HAL_STATUS_SUCCESS(status) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012599 palZeroMemory(pMac->hHdd, pMsg, msgLen);
12600 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012601 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012602 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012603 //sessionId
12604 *pBuf = (tANI_U8)sessionId;
12605 pBuf++;
12606 // transactionId
12607 *pBuf = 0;
12608 *(pBuf + 1) = 0;
12609 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012610 // bssid
12611 palCopyMemory( pMac->hHdd, pBuf, pParam->bssid, sizeof(tSirMacAddr) );
12612 pBuf += sizeof(tSirMacAddr);
12613 // selfMacAddr
12614 palCopyMemory( pMac->hHdd, pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr) );
12615 pBuf += sizeof(tSirMacAddr);
12616 // beaconInterval
12617 if( pBssDesc && pBssDesc->beaconInterval )
12618 {
12619 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
12620 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012621 else if(pParam->beaconInterval)
12622 {
12623 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
12624 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012625 else
12626 {
12627 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
12628 }
Jeff Johnsone7245742012-09-05 17:12:55 -070012629 if(csrIsconcurrentsessionValid (pMac, sessionId,
12630 pParam->bssPersona)
12631 == eHAL_STATUS_SUCCESS )
12632 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012633 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070012634 pParam->bssPersona);
12635 //Update the beacon Interval
12636 pParam->beaconInterval = wTmp;
12637 }
12638 else
12639 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012640 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070012641 status = eHAL_STATUS_FAILURE;
12642 return status;
12643 }
12644
Jeff Johnson295189b2012-06-20 16:38:30 -070012645 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof( tANI_U16 ) );
12646 pBuf += sizeof(tANI_U16);
12647 // dot11mode
12648 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
12649 pBuf += 1;
12650 // bssType
12651 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
12652 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tSirBssType) );
12653 pBuf += sizeof(tSirBssType);
12654 // ssId
12655 if( pParam->ssId.length )
12656 {
12657 // ssId len
12658 *pBuf = pParam->ssId.length;
12659 pBuf++;
12660 palCopyMemory( pMac->hHdd, pBuf, pParam->ssId.ssId, pParam->ssId.length );
12661 pBuf += pParam->ssId.length;
12662 }
12663 else
12664 {
12665 *pBuf = 0;
12666 pBuf++;
12667 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012668 // set the channel Id
12669 *pBuf = pParam->operationChn;
12670 pBuf++;
12671 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070012672 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
12673 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState) );
12674 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070012675
Jeff Johnson295189b2012-06-20 16:38:30 -070012676 // Set privacy
12677 *pBuf = pParam->privacy;
12678 pBuf++;
12679
12680 //Set Uapsd
12681 *pBuf = pParam->ApUapsdEnable;
12682 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012683 //Set SSID hidden
12684 *pBuf = pParam->ssidHidden;
12685 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012686 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
12687 pBuf++;
12688
12689 //Ht protection Enable/Disable
12690 *pBuf = (tANI_U8)pParam->protEnabled;
12691 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012692 //Enable Beacons to Receive for OBSS protection Enable/Disable
12693 *pBuf = (tANI_U8)pParam->obssProtEnabled;
12694 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012695 //set cfg related to protection
12696 wTmp = pal_cpu_to_be16( pParam->ht_protection );
12697 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof( tANI_U16 ) );
12698 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012699 // Set Auth type
12700 authType = pal_cpu_to_be32(pParam->authType);
12701 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
12702 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012703 // Set DTIM
12704 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
12705 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12706 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012707 // Set wps_state
12708 *pBuf = pParam->wps_state;
12709 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012710 //Persona
12711 *pBuf = (tANI_U8)pParam->bssPersona;
12712 pBuf++;
12713
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080012714 //txLdpcIniFeatureEnabled
12715 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
12716 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070012717
Jeff Johnson295189b2012-06-20 16:38:30 -070012718
12719 // set RSN IE
12720 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
12721 {
12722 status = eHAL_STATUS_INVALID_PARAMETER;
12723 palFreeMemory( pMac->hHdd, pMsg );
12724 break;
12725 }
12726 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
12727 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12728 pBuf += sizeof(tANI_U16);
12729 if( wTmp )
12730 {
12731 wTmp = pParam->nRSNIELength;
12732 palCopyMemory( pMac->hHdd, pBuf, pParam->pRSNIE, wTmp );
12733 pBuf += wTmp;
12734 }
12735 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
12736 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType) );
12737 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012738 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
12739 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012740 palCopyMemory( pMac->hHdd, pBuf, pParam->operationalRateSet.rate, pParam->operationalRateSet.numRates );
12741 pBuf += pParam->operationalRateSet.numRates ;
12742 *pBuf++ = pParam->extendedRateSet.numRates;
12743 if(0 != pParam->extendedRateSet.numRates)
12744 {
12745 palCopyMemory( pMac->hHdd, pBuf, pParam->extendedRateSet.rate, pParam->extendedRateSet.numRates );
12746 pBuf += pParam->extendedRateSet.numRates;
12747 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012748 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
12749 pMsg->length = pal_cpu_to_be16(msgLen);
12750
12751 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012752 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012753 return( status );
12754}
12755
Jeff Johnson295189b2012-06-20 16:38:30 -070012756eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
12757{
12758 eHalStatus status = eHAL_STATUS_FAILURE;
12759 tSirSmeStopBssReq *pMsg;
12760 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12761 tANI_U8 *pBuf;
12762 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012763
12764 if(!pSession)
12765 {
12766 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12767 return eHAL_STATUS_FAILURE;
12768 }
12769
Jeff Johnson295189b2012-06-20 16:38:30 -070012770 do {
12771 status = palAllocateMemory(pMac, (void **)&pMsg, sizeof(tSirSmeStopBssReq));
12772 if ( !HAL_STATUS_SUCCESS(status) ) break;
12773 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeStopBssReq ));
12774 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
12775 pBuf = &pMsg->sessionId;
12776 //sessionId
12777 *pBuf = (tANI_U8)sessionId;
12778 pBuf++;
12779 // transactionId
12780 *pBuf = 0;
12781 pBuf += sizeof(tANI_U16);
12782 //reason code
12783 *pBuf = 0;
12784 pBuf += sizeof(tSirResultCodes);
12785 // bssid
12786 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
12787 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
12788 {
12789 palCopyMemory( pMac->hHdd, pBuf,(tANI_U8 *)&pSession->selfMacAddr, sizeof(tSirMacAddr) );
12790 }
12791 else
12792 {
12793 palCopyMemory( pMac->hHdd, pBuf,(tANI_U8 *)&pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
12794 }
12795 pBuf += sizeof(tSirMacAddr);
12796 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
12797 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012798 status = palSendMBMessage( pMac->hHdd, pMsg );
12799#if 0
12800 status = palAllocateMemory(pMac, (void **)&pMsg, sizeof(tSirSmeStopBssReq));
12801 if ( !HAL_STATUS_SUCCESS(status) ) break;
12802 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeStopBssReq ));
12803 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
12804 pMsg->reasonCode = 0;
12805 // bssid
12806 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
12807 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
12808 {
12809 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
12810 }
12811 else
12812 {
12813 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
12814 }
12815 palCopyMemory( pMac->hHdd, &pMsg->bssId, pbBssid, sizeof(tSirMacAddr) );
12816 pMsg->transactionId = 0;
12817 pMsg->sessionId = (tANI_U8)sessionId;
12818 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
12819 status = palSendMBMessage( pMac->hHdd, pMsg );
12820#endif
12821 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012822 return( status );
12823}
12824
Jeff Johnson295189b2012-06-20 16:38:30 -070012825eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
12826 tCsrRoamModifyProfileFields *pModProfileFields,
12827 tANI_U32 *pRoamId, v_BOOL_t fForce)
12828{
Jeff Johnson295189b2012-06-20 16:38:30 -070012829 eHalStatus status = eHAL_STATUS_FAILURE;
12830 tANI_U32 roamId = 0;
12831 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012832 if((csrIsConnStateConnected(pMac, sessionId)) &&
12833 (fForce || (!palEqualMemory(pMac->hHdd, &pModProfileFields,
12834 &pSession->connectedProfile.modifyProfileFields,
12835 sizeof(tCsrRoamModifyProfileFields)))) )
12836 {
12837 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
12838 if(pRoamId)
12839 {
12840 *pRoamId = roamId;
12841 }
12842
Jeff Johnson295189b2012-06-20 16:38:30 -070012843 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
12844 eCsrSmeIssuedReassocToSameAP, roamId,
12845 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012846 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012847 return status;
12848}
Jeff Johnson295189b2012-06-20 16:38:30 -070012849static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
12850{
12851 eHalStatus status = eHAL_STATUS_SUCCESS;
12852 tCsrRoamInfo roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070012853 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
12854 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
12855 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
12856 return (status);
12857}
Jeff Johnson295189b2012-06-20 16:38:30 -070012858eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
12859{
12860 eHalStatus status = eHAL_STATUS_SUCCESS;
12861 tListElem *pEntry = NULL;
12862 tSmeCmd *pCommand = NULL;
12863 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012864 do
12865 {
12866 if(pMsg == NULL)
12867 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012868 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012869 status = eHAL_STATUS_FAILURE;
12870 break;
12871 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012872 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
12873 if(pEntry)
12874 {
12875 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
12876 if(eSmeCommandAddStaSession == pCommand->command)
12877 {
12878 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012879 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070012880 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070012881 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070012882 //Remove this command out of the active list
12883 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
12884 {
12885 //Now put this command back on the avilable command list
12886 csrReleaseCommand(pMac, pCommand);
12887 }
12888 smeProcessPendingQueue( pMac );
12889 }
12890 else
12891 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012892 smsLog(pMac, LOGE, "in %s eWNI_SME_ADD_STA_SELF_RSP Received but NO Add sta session command are ACTIVE ...",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012893 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012894 status = eHAL_STATUS_FAILURE;
12895 break;
12896 }
12897 }
12898 else
12899 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012900 smsLog(pMac, LOGE, "in %s eWNI_SME_ADD_STA_SELF_RSP Received but NO commands are ACTIVE ...",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012901 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012902 status = eHAL_STATUS_FAILURE;
12903 break;
12904 }
12905 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012906 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012907}
Jeff Johnson295189b2012-06-20 16:38:30 -070012908eHalStatus csrSendMBAddSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
12909{
12910 tSirSmeAddStaSelfReq *pMsg;
12911 tANI_U16 msgLen;
12912 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012913 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070012914 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
12915 sizeof( tSirBssType )*/;
Jeff Johnson295189b2012-06-20 16:38:30 -070012916 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12917 if ( !HAL_STATUS_SUCCESS(status) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012918 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012919 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
12920 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012921 // self station address
12922 palCopyMemory( pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr, sizeof(tSirMacAddr) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012923 smsLog( pMac, LOG1, FL("selfMac=%02x, %02x, %02x, %02x, %02x, %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -070012924 pMsg->selfMacAddr[0],
12925 pMsg->selfMacAddr[1],
12926 pMsg->selfMacAddr[2],
12927 pMsg->selfMacAddr[3],
12928 pMsg->selfMacAddr[4],
12929 pMsg->selfMacAddr[5]);
12930 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012931 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012932 return( status );
12933}
Jeff Johnson295189b2012-06-20 16:38:30 -070012934eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr sessionMacAddr)
12935{
12936 eHalStatus status = eHAL_STATUS_SUCCESS;
12937 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070012938 pCommand = csrGetCommandBuffer(pMac);
12939 if(NULL == pCommand)
12940 {
12941 status = eHAL_STATUS_RESOURCES;
12942 }
12943 else
12944 {
12945 pCommand->command = eSmeCommandAddStaSession;
12946 pCommand->sessionId = (tANI_U8)sessionId;
12947 palCopyMemory( pMac->hHdd, pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr, sizeof( tSirMacAddr ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070012948 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
12949 if( !HAL_STATUS_SUCCESS( status ) )
12950 {
12951 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012952 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070012953 }
12954 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012955 return (status);
12956}
Jeff Johnson295189b2012-06-20 16:38:30 -070012957eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
12958{
12959 return csrSendMBAddSelfStaReqMsg( pMac,
12960 pCommand->u.addStaSessionCmd.selfMacAddr );
12961}
Jeff Johnson295189b2012-06-20 16:38:30 -070012962eHalStatus csrRoamOpenSession( tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext,
12963 tANI_U8 *pSelfMacAddr, tANI_U8 *pbSessionId )
12964{
12965 eHalStatus status = eHAL_STATUS_SUCCESS;
12966 tANI_U32 i;
12967 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070012968 *pbSessionId = CSR_SESSION_ID_INVALID;
12969 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
12970 {
12971 if( !CSR_IS_SESSION_VALID( pMac, i ) )
12972 {
12973 pSession = CSR_GET_SESSION( pMac, i );
12974 status = eHAL_STATUS_SUCCESS;
12975 pSession->sessionActive = eANI_BOOLEAN_TRUE;
12976 pSession->sessionId = (tANI_U8)i;
12977 pSession->callback = callback;
12978 pSession->pContext = pContext;
12979 palCopyMemory( pMac->hHdd, &pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid) );
12980 *pbSessionId = (tANI_U8)i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012981 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerRoaming, csrRoamRoamingTimerHandler,
12982 &pSession->roamingTimerInfo);
12983 if(!HAL_STATUS_SUCCESS(status))
12984 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012985 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012986 break;
12987 }
12988#ifdef FEATURE_WLAN_BTAMP_UT_RF
12989 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerJoinRetry, csrRoamJoinRetryTimerHandler,
12990 &pSession->joinRetryTimerInfo);
12991 if(!HAL_STATUS_SUCCESS(status))
12992 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012993 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012994 break;
12995 }
12996#endif
12997 pSession->ibssJoinTimerInfo.pMac = pMac;
12998 pSession->ibssJoinTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Jeff Johnson295189b2012-06-20 16:38:30 -070012999 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerIbssJoining, csrRoamIbssJoinTimerHandler,
13000 &pSession->ibssJoinTimerInfo);
13001 if(!HAL_STATUS_SUCCESS(status))
13002 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013003 smsLog(pMac, LOGE, FL("cannot allocate memory for IbssJoining timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013004 break;
13005 }
13006 status = csrIssueAddStaForSessionReq ( pMac, i, pSelfMacAddr );
13007 break;
13008 }
13009 }
13010 if( CSR_ROAM_SESSION_MAX == i )
13011 {
13012 //No session is available
13013 status = eHAL_STATUS_RESOURCES;
13014 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013015 return ( status );
13016}
Jeff Johnson295189b2012-06-20 16:38:30 -070013017eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13018{
13019 eHalStatus status = eHAL_STATUS_SUCCESS;
13020 tListElem *pEntry = NULL;
13021 tSmeCmd *pCommand = NULL;
13022 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013023 do
13024 {
13025 if(pMsg == NULL)
13026 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013027 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013028 status = eHAL_STATUS_FAILURE;
13029 break;
13030 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013031 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
13032 if(pEntry)
13033 {
13034 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13035 if(eSmeCommandDelStaSession == pCommand->command)
13036 {
13037 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013038 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013039 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013040 //This session is done.
13041 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013042 if(pCommand->u.delStaSessionCmd.callback)
13043 {
13044
13045 status = sme_ReleaseGlobalLock( &pMac->sme );
13046 if ( HAL_STATUS_SUCCESS( status ) )
13047 {
13048 pCommand->u.delStaSessionCmd.callback(
13049 pCommand->u.delStaSessionCmd.pContext);
13050 status = sme_AcquireGlobalLock( &pMac->sme );
13051 if (! HAL_STATUS_SUCCESS( status ) )
13052 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013053 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013054 return status;
13055 }
13056 }
13057 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013058 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013059 }
13060 }
13061
13062 //Remove this command out of the active list
13063 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
13064 {
13065 //Now put this command back on the avilable command list
13066 csrReleaseCommand(pMac, pCommand);
13067 }
13068 smeProcessPendingQueue( pMac );
13069 }
13070 else
13071 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013072 smsLog(pMac, LOGE, "in %s eWNI_SME_DEL_STA_SELF_RSP Received but NO Del sta session command are ACTIVE ...",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013073 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013074 status = eHAL_STATUS_FAILURE;
13075 break;
13076 }
13077 }
13078 else
13079 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013080 smsLog(pMac, LOGE, "in %s eWNI_SME_DEL_STA_SELF_RSP Received but NO commands are ACTIVE ...",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013081 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013082 status = eHAL_STATUS_FAILURE;
13083 break;
13084 }
13085 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013086 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013087}
Jeff Johnson295189b2012-06-20 16:38:30 -070013088eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
13089{
13090 tSirSmeDelStaSelfReq *pMsg;
13091 tANI_U16 msgLen;
13092 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013093 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013094 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
13095 sizeof( tSirBssType )*/;
Jeff Johnson295189b2012-06-20 16:38:30 -070013096 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
13097 if ( !HAL_STATUS_SUCCESS(status) ) break;
13098
13099 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013100 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
13101 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013102 // self station address
13103 palCopyMemory( pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr, sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013104 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013105 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013106 return( status );
13107}
Jeff Johnson295189b2012-06-20 16:38:30 -070013108eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
13109 tSirMacAddr sessionMacAddr,
13110 csrRoamSessionCloseCallback callback,
13111 void *pContext)
13112{
13113 eHalStatus status = eHAL_STATUS_SUCCESS;
13114 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070013115 pCommand = csrGetCommandBuffer(pMac);
13116 if(NULL == pCommand)
13117 {
13118 status = eHAL_STATUS_RESOURCES;
13119 }
13120 else
13121 {
13122 pCommand->command = eSmeCommandDelStaSession;
13123 pCommand->sessionId = (tANI_U8)sessionId;
13124 pCommand->u.delStaSessionCmd.callback = callback;
13125 pCommand->u.delStaSessionCmd.pContext = pContext;
13126 palCopyMemory( pMac->hHdd, pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr, sizeof( tSirMacAddr ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013127 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
13128 if( !HAL_STATUS_SUCCESS( status ) )
13129 {
13130 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013131 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013132 }
13133 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013134 return (status);
13135}
Jeff Johnson295189b2012-06-20 16:38:30 -070013136eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
13137{
13138 return csrSendMBDelSelfStaReqMsg( pMac,
13139 pCommand->u.delStaSessionCmd.selfMacAddr );
13140}
Jeff Johnson295189b2012-06-20 16:38:30 -070013141static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
13142{
13143 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
13144 tListElem *pEntry, *pNext;
13145 tSmeCmd *pCommand;
13146 tDblLinkList localList;
13147
13148 vos_mem_zero(&localList, sizeof(tDblLinkList));
13149 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
13150 {
13151 smsLog(pMac, LOGE, FL(" failed to open list"));
13152 return;
13153 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013154 csrLLLock(pList);
13155 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
13156 while(pEntry != NULL)
13157 {
13158 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
13159 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13160 if(pCommand->sessionId == sessionId)
13161 {
13162 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
13163 {
13164 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
13165 }
13166 }
13167 pEntry = pNext;
13168 }
13169 csrLLUnlock(pList);
13170
13171 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
13172 {
13173 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13174 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
13175 }
13176 csrLLClose(&localList);
13177}
13178
Jeff Johnson295189b2012-06-20 16:38:30 -070013179void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
13180{
13181 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13182 {
13183 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013184 csrRoamStop(pMac, sessionId);
13185 csrFreeConnectBssDesc(pMac, sessionId);
13186 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
13187 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
13188 palTimerFree(pMac->hHdd, pSession->hTimerRoaming);
13189#ifdef FEATURE_WLAN_BTAMP_UT_RF
13190 palTimerFree(pMac->hHdd, pSession->hTimerJoinRetry);
13191#endif
13192 palTimerFree(pMac->hHdd, pSession->hTimerIbssJoining);
13193 purgeSmeSessionCmdList(pMac, sessionId);
13194 purgeCsrSessionCmdList(pMac, sessionId);
13195 csrInitSession(pMac, sessionId);
13196 }
13197}
13198
Jeff Johnson295189b2012-06-20 16:38:30 -070013199eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
13200 tANI_BOOLEAN fSync,
13201 csrRoamSessionCloseCallback callback,
13202 void *pContext )
13203{
13204 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013205 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13206 {
13207 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13208 if(fSync)
13209 {
13210 csrCleanupSession(pMac, sessionId);
13211 }
13212 else
13213 {
13214 purgeSmeSessionCmdList(pMac, sessionId);
13215 purgeCsrSessionCmdList(pMac, sessionId);
13216 status = csrIssueDelStaForSessionReq( pMac, sessionId,
13217 pSession->selfMacAddr, callback, pContext);
13218 }
13219 }
13220 else
13221 {
13222 status = eHAL_STATUS_INVALID_PARAMETER;
13223 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013224 return ( status );
13225}
13226
Jeff Johnson295189b2012-06-20 16:38:30 -070013227static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
13228{
13229 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013230
13231 if(!pSession)
13232 {
13233 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13234 return;
13235 }
13236
Jeff Johnson295189b2012-06-20 16:38:30 -070013237 pSession->sessionActive = eANI_BOOLEAN_FALSE;
13238 pSession->sessionId = CSR_SESSION_ID_INVALID;
13239 pSession->callback = NULL;
13240 pSession->pContext = NULL;
13241 pSession->ibss_join_pending = FALSE;
13242 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
13243 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
13244 csrFreeRoamProfile( pMac, sessionId );
13245 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
13246 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
13247 csrFreeConnectBssDesc(pMac, sessionId);
13248 csrScanEnable(pMac);
13249 palZeroMemory( pMac->hHdd, &pSession->selfMacAddr, sizeof(tCsrBssid) );
13250 if(pSession->pWpaRsnReqIE)
13251 {
13252 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
13253 pSession->pWpaRsnReqIE = NULL;
13254 }
13255 pSession->nWpaRsnReqIeLength = 0;
13256 if(pSession->pWpaRsnRspIE)
13257 {
13258 palFreeMemory(pMac->hHdd, pSession->pWpaRsnRspIE);
13259 pSession->pWpaRsnRspIE = NULL;
13260 }
13261 pSession->nWpaRsnRspIeLength = 0;
13262#ifdef FEATURE_WLAN_WAPI
13263 if(pSession->pWapiReqIE)
13264 {
13265 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
13266 pSession->pWapiReqIE = NULL;
13267 }
13268 pSession->nWapiReqIeLength = 0;
13269 if(pSession->pWapiRspIE)
13270 {
13271 palFreeMemory(pMac->hHdd, pSession->pWapiRspIE);
13272 pSession->pWapiRspIE = NULL;
13273 }
13274 pSession->nWapiRspIeLength = 0;
13275#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070013276 if(pSession->pAddIEScan)
13277 {
13278 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
13279 pSession->pAddIEScan = NULL;
13280 }
13281 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013282 if(pSession->pAddIEAssoc)
13283 {
13284 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
13285 pSession->pAddIEAssoc = NULL;
13286}
13287 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013288}
13289
Jeff Johnson295189b2012-06-20 16:38:30 -070013290eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
13291{
13292 eHalStatus status = eHAL_STATUS_FAILURE;
13293 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070013294 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13295 {
13296 if( CSR_IS_SESSION_VALID( pMac, i ) )
13297 {
13298 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
13299 {
13300 //Found it
13301 status = eHAL_STATUS_SUCCESS;
13302 *pSessionId = i;
13303 break;
13304 }
13305 }
13306 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013307 return( status );
13308}
13309
Jeff Johnson295189b2012-06-20 16:38:30 -070013310//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
13311//session because for IBSS, the bssid changes.
13312static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
13313{
13314 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
13315 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070013316 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13317 {
13318 if( CSR_IS_SESSION_VALID( pMac, i ) )
13319 {
13320 pSession = CSR_GET_SESSION( pMac, i );
13321 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
13322 {
13323 //Found it
13324 nRet = i;
13325 break;
13326 }
13327 }
13328 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013329 return (nRet);
13330}
Jeff Johnson295189b2012-06-20 16:38:30 -070013331static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
13332{
13333 /* Update the current BSS info in ho control block based on connected
13334 profile info from pmac global structure */
13335
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013336 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -070013337 bssid[ 0 ], bssid[ 1 ], bssid[ 2 ],
13338 bssid[ 3 ], bssid[ 4 ], bssid[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -070013339 /* Check for user misconfig of RSSI trigger threshold */
13340 pMac->roam.configParam.vccRssiThreshold =
13341 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
13342 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
13343 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070013344 /* Check for user misconfig of UL MAC Loss trigger threshold */
13345 pMac->roam.configParam.vccUlMacLossThreshold =
13346 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
13347 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070013348#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13349 {
13350 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013351 /* Indicate the neighbor roal algorithm about the connect indication */
13352 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
13353 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
13354 }
13355#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013356}
13357
Jeff Johnson295189b2012-06-20 16:38:30 -070013358static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
13359{
13360 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013361
13362 if(!pSession)
13363 {
13364 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13365 return;
13366 }
13367
Jeff Johnson295189b2012-06-20 16:38:30 -070013368 //Only to handle the case for Handover on infra link
13369 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
13370 {
13371 return;
13372 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013373 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
13374 csrRoamDeregStatisticsReq(pMac);
13375 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
13376#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13377 /* Indicate the neighbor roal algorithm about the disconnect indication */
13378 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
13379#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070013380
13381 //Remove this code once SLM_Sessionization is supported
13382 //BMPS_WORKAROUND_NOT_NEEDED
13383 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070013384 csrIsInfraApStarted( pMac ) &&
13385 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070013386 {
13387 pMac->roam.configParam.doBMPSWorkaround = 0;
13388 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013389}
13390
Jeff Johnson295189b2012-06-20 16:38:30 -070013391void csrRoamTlStatsTimerHandler(void *pv)
13392{
13393 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
13394 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013395 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
13396
Jeff Johnsone7245742012-09-05 17:12:55 -070013397 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
13398
Jeff Johnson295189b2012-06-20 16:38:30 -070013399#if 0
13400 // TODO Persession .???
13401 //req TL for stats
13402 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
13403 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013404 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013405 }
13406 else
13407 {
13408 //save in SME
13409 csrRoamSaveStatsFromTl(pMac, tlStats);
13410 }
13411#endif
13412 if(!pMac->roam.tlStatsReqInfo.timerRunning)
13413 {
13414 if(pMac->roam.tlStatsReqInfo.periodicity)
13415 {
13416 //start timer
13417 status = palTimerStart(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer,
13418 pMac->roam.tlStatsReqInfo.periodicity * PAL_TIMER_TO_MS_UNIT, eANI_BOOLEAN_FALSE);
13419 if(!HAL_STATUS_SUCCESS(status))
13420 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013421 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013422 return;
13423 }
13424 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
13425 }
13426 }
13427}
Jeff Johnson295189b2012-06-20 16:38:30 -070013428void csrRoamPeStatsTimerHandler(void *pv)
13429{
13430 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
13431 eHalStatus status;
13432 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
13433 VOS_STATUS vosStatus;
13434 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070013435 pPeStatsReqListEntry->timerRunning = FALSE;
13436 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
13437 {
13438 // If we entered here, meaning the timer could not be successfully
13439 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
13440
13441 /* Destroy the timer */
13442 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
13443 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13444 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013445 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013446 }
13447
13448 // Free the entry
13449 palFreeMemory(pMac->hHdd, pPeStatsReqListEntry);
13450 pPeStatsReqListEntry = NULL;
13451 }
13452 else
13453 {
13454 if(!pPeStatsReqListEntry->rspPending)
13455 {
13456 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
13457 pPeStatsReqListEntry->staId);
13458 if(!HAL_STATUS_SUCCESS(status))
13459 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013460 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013461 }
13462 else
13463 {
13464 pPeStatsReqListEntry->rspPending = TRUE;
13465 }
13466 }
13467
13468 //send down a req
13469 if(pPeStatsReqListEntry->periodicity &&
13470 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
13471 {
13472 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
13473 if(ePMC_FULL_POWER == powerState)
13474 {
13475 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
13476 {
13477 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
13478 }
13479 }
13480 else
13481 {
13482 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
13483 {
13484 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
13485 }
13486 }
13487 //start timer
13488 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
13489 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13490 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013491 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013492 return;
13493 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013494 pPeStatsReqListEntry->timerRunning = TRUE;
13495
13496 }
13497
13498 }
13499}
Jeff Johnson295189b2012-06-20 16:38:30 -070013500void csrRoamStatsClientTimerHandler(void *pv)
13501{
13502 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070013503 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
13504 {
13505#if 0
13506 // TODO Stats fix for multisession
13507 //start the timer
13508 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
13509
13510 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13511 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013512 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013513 }
13514#endif
13515 }
13516#if 0
13517 //send up the stats report
13518 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
13519 pStaEntry->staId, pStaEntry->pContext);
13520#endif
13521}
13522
13523
13524
Jeff Johnson295189b2012-06-20 16:38:30 -070013525eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
13526{
13527 tAniGetPEStatsReq *pMsg;
13528 eHalStatus status = eHAL_STATUS_SUCCESS;
13529 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetPEStatsReq));
13530 if ( !HAL_STATUS_SUCCESS(status) )
13531 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013532 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to allocate mem for stats req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070013533 return status;
13534 }
13535 // need to initiate a stats request to PE
13536 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
13537 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
13538 pMsg->staId = staId;
13539 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070013540 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013541 if(!HAL_STATUS_SUCCESS(status))
13542 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013543 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to send down the stats req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070013544 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013545 return status;
13546}
Jeff Johnson295189b2012-06-20 16:38:30 -070013547void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
13548{
13549 tAniGetPEStatsRsp *pSmeStatsRsp;
13550 eHalStatus status = eHAL_STATUS_FAILURE;
13551 tListElem *pEntry = NULL;
13552 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
13553 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
13554 tANI_U32 tempMask = 0;
13555 tANI_U8 counter = 0;
13556 tANI_U8 *pStats = NULL;
13557 tANI_U32 length = 0;
13558 v_PVOID_t pvosGCtx;
13559 v_S7_t rssi = 0;
13560 tANI_U32 *pRssi = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013561 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
13562 if(pSmeStatsRsp->rc)
13563 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013564 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013565 goto post_update;
13566 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013567 tempMask = pSmeStatsRsp->statsMask;
13568 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070013569 /* subtract all statistics from this length, and after processing the entire
13570 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
13571 * in this 'stats' message.
13572 */
13573 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070013574 //new stats info from PE, fill up the stats strucutres in PMAC
13575 while(tempMask)
13576 {
13577 if(tempMask & 1)
13578 {
13579 switch(counter)
13580 {
13581 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013582 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013583 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
13584 pStats, sizeof(tCsrSummaryStatsInfo));
13585 if(!HAL_STATUS_SUCCESS(status))
13586 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013587 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013588 }
13589 pStats += sizeof(tCsrSummaryStatsInfo);
13590 length -= sizeof(tCsrSummaryStatsInfo);
13591 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013592 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013593 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013594 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classAStatsInfo,
13595 pStats, sizeof(tCsrGlobalClassAStatsInfo));
13596 if(!HAL_STATUS_SUCCESS(status))
13597 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013598 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013599 }
13600 pStats += sizeof(tCsrGlobalClassAStatsInfo);
13601 length -= sizeof(tCsrGlobalClassAStatsInfo);
13602 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013603 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013604 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013605 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classBStatsInfo,
13606 pStats, sizeof(tCsrGlobalClassBStatsInfo));
13607 if(!HAL_STATUS_SUCCESS(status))
13608 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013609 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013610 }
13611 pStats += sizeof(tCsrGlobalClassBStatsInfo);
13612 length -= sizeof(tCsrGlobalClassBStatsInfo);
13613 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013614 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013615 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013616 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classCStatsInfo,
13617 pStats, sizeof(tCsrGlobalClassCStatsInfo));
13618 if(!HAL_STATUS_SUCCESS(status))
13619 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013620 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013621 }
13622 pStats += sizeof(tCsrGlobalClassCStatsInfo);
13623 length -= sizeof(tCsrGlobalClassCStatsInfo);
13624 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013625 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013626 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013627 if( CSR_MAX_STA > pSmeStatsRsp->staId )
13628 {
13629 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
13630 pStats, sizeof(tCsrPerStaStatsInfo));
13631 }
13632 else
13633 {
13634 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013635 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013636 VOS_ASSERT( 0 );
13637 }
13638 if(!HAL_STATUS_SUCCESS(status))
13639 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013640 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013641 }
13642 pStats += sizeof(tCsrPerStaStatsInfo);
13643 length -= sizeof(tCsrPerStaStatsInfo);
13644 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013645 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013646 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013647 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013648 }
13649 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013650 tempMask >>=1;
13651 counter++;
13652 }
13653 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
13654 if (length != 0)
13655 {
13656 pRssi = (tANI_U32*)pStats;
13657 rssi = (v_S7_t)*pRssi;
13658 }
13659 else
13660 {
13661 /* If riva is not sending rssi, continue to use the hack */
13662 rssi = RSSI_HACK_BMPS;
13663 }
13664 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Jeff Johnson295189b2012-06-20 16:38:30 -070013665post_update:
13666 //make sure to update the pe stats req list
13667 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
13668 if(pEntry)
13669 {
13670 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
13671 pPeStaEntry->rspPending = FALSE;
13672
13673 }
13674 //check the one timer cases
13675 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
13676 if(pEntry)
13677 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013678 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013679 if(pTempStaEntry->timerExpired)
13680 {
13681 //send up the stats report
13682 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
13683 pTempStaEntry->staId, pTempStaEntry->pContext);
13684 //also remove from the client list
13685 csrRoamRemoveStatListEntry(pMac, pEntry);
13686 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013687 }
13688 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013689}
Jeff Johnson295189b2012-06-20 16:38:30 -070013690tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
13691{
13692 tListElem *pEntry = NULL;
13693 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013694 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070013695 if(!pEntry)
13696 {
13697 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013698 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070013699 return NULL;
13700 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013701 while( pEntry )
13702 {
13703 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013704 if(pTempStaEntry->statsMask == statsMask)
13705 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013706 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070013707 break;
13708 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013709 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
13710 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013711 return pEntry;
13712}
13713
Jeff Johnson295189b2012-06-20 16:38:30 -070013714tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
13715 tANI_BOOLEAN update)
13716{
13717 tListElem *pEntry;
13718 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070013719 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070013720 if(!pEntry)
13721 {
13722 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070013723 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013724 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070013725 return NULL;
13726 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013727 while( pEntry )
13728 {
13729 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013730 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
13731 (pTempStaEntry->statsMask == pStaEntry->statsMask))
13732 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013733 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070013734 if(update)
13735 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013736 pTempStaEntry->periodicity = pStaEntry->periodicity;
13737 pTempStaEntry->callback = pStaEntry->callback;
13738 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070013739 }
13740 break;
13741 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013742 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
13743 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013744 return pEntry;
13745}
Jeff Johnson295189b2012-06-20 16:38:30 -070013746tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
13747{
13748 tListElem *pEntry;
13749 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070013750 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070013751 if(!pEntry)
13752 {
13753 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070013754 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013755 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070013756 return NULL;
13757 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013758 while( pEntry )
13759 {
13760 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013761 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
13762 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013763 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070013764 break;
13765 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013766 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
13767 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013768 return pEntry;
13769}
Jeff Johnson295189b2012-06-20 16:38:30 -070013770eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
13771 csrRoamLinkQualityIndCallback callback,
13772 void *pContext)
13773{
13774 pMac->roam.linkQualityIndInfo.callback = callback;
13775 pMac->roam.linkQualityIndInfo.context = pContext;
13776 if( NULL == callback )
13777 {
13778 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
13779 }
13780 else
13781 {
13782 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070013783 /* do we need to invoke the callback to notify client of initial value ?? */
13784 }
13785 return eHAL_STATUS_SUCCESS;
13786}
Jeff Johnson295189b2012-06-20 16:38:30 -070013787void csrRoamVccTrigger(tpAniSirGlobal pMac)
13788{
13789 eCsrRoamLinkQualityInd newVccLinkQuality;
13790 tANI_U32 ul_mac_loss = 0;
13791 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070013792 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
13793 /*-------------------------------------------------------------------------
13794 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070013795 Check for a change in link quality and notify client if necessary
13796 -------------------------------------------------------------------------*/
13797 ul_mac_loss_trigger_threshold =
13798 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070013799 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013800 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070013801 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070013802 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
13803 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013804 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070013805 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
13806 }
13807 else
13808 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013809 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070013810 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
13811 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013812 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
13813 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070013814 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
13815 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013816 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070013817 if(NULL != pMac->roam.linkQualityIndInfo.callback)
13818 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013819 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070013820 newVccLinkQuality );
13821
13822 /* we now invoke the callback once to notify client of initial value */
13823 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
13824 pMac->roam.linkQualityIndInfo.context );
13825 //event: EVENT_WLAN_VCC
13826 }
13827 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013828 pMac->roam.vccLinkQuality = newVccLinkQuality;
13829
Jeff Johnson295189b2012-06-20 16:38:30 -070013830}
Jeff Johnson295189b2012-06-20 16:38:30 -070013831VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
13832 v_U8_t rssiNotification,
13833 void * context)
13834{
13835 tpAniSirGlobal pMac = PMAC_STRUCT( context );
13836 eCsrRoamLinkQualityInd newVccLinkQuality;
13837 // TODO : Session info unavailable
13838 tANI_U32 sessionId = 0;
13839 VOS_STATUS status = VOS_STATUS_SUCCESS;
13840 /*-------------------------------------------------------------------------
13841 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070013842 Check for a change in link quality and notify client if necessary
13843 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013844 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070013845 pMac->roam.configParam.vccRssiThreshold);
13846 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
13847 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013848 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070013849 return VOS_STATUS_SUCCESS;
13850 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013851 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
13852 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013853 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070013854 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
13855 }
13856 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
13857 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013858 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070013859 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
13860 }
13861 else
13862 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013863 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070013864 //Set to this so the code below won't do anything
13865 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070013866 VOS_ASSERT(0);
13867 }
13868
Jeff Johnson295189b2012-06-20 16:38:30 -070013869 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
13870 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013871 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070013872 if(NULL != pMac->roam.linkQualityIndInfo.callback)
13873 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013874 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070013875 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070013876 /* we now invoke the callback once to notify client of initial value */
13877 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
13878 pMac->roam.linkQualityIndInfo.context );
13879 //event: EVENT_WLAN_VCC
13880 }
13881 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013882 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070013883 return status;
13884}
Jeff Johnson295189b2012-06-20 16:38:30 -070013885tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
13886 tDblLinkList *pStaList,
13887 tCsrStatsClientReqInfo *pStaEntry)
13888{
13889 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013890 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013891 //if same entity requested for same set of stats with different periodicity &
13892 // callback update it
13893 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
13894 {
13895
13896 status = palAllocateMemory(pMac->hHdd, (void **)&pNewStaEntry, sizeof(tCsrStatsClientReqInfo));
13897 if (!HAL_STATUS_SUCCESS(status))
13898 {
13899 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013900 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070013901 return NULL;
13902 }
13903
Jeff Johnson295189b2012-06-20 16:38:30 -070013904 pNewStaEntry->callback = pStaEntry->callback;
13905 pNewStaEntry->pContext = pStaEntry->pContext;
13906 pNewStaEntry->periodicity = pStaEntry->periodicity;
13907 pNewStaEntry->requesterId = pStaEntry->requesterId;
13908 pNewStaEntry->statsMask = pStaEntry->statsMask;
13909 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
13910 pNewStaEntry->pMac = pStaEntry->pMac;
13911 pNewStaEntry->staId = pStaEntry->staId;
13912 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
13913
13914 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
13915 }
13916 return pNewStaEntry;
13917}
13918
Jeff Johnson295189b2012-06-20 16:38:30 -070013919tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
13920 tDblLinkList *pStaList,
13921 tCsrPeStatsReqInfo *pStaEntry)
13922{
13923 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013924 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013925 status = palAllocateMemory(pMac->hHdd, (void **)&pNewStaEntry, sizeof(tCsrPeStatsReqInfo));
13926 if (!HAL_STATUS_SUCCESS(status))
13927 {
13928 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013929 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070013930 return NULL;
13931 }
13932
Jeff Johnson295189b2012-06-20 16:38:30 -070013933 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
13934 pNewStaEntry->numClient = pStaEntry->numClient;
13935 pNewStaEntry->periodicity = pStaEntry->periodicity;
13936 pNewStaEntry->statsMask = pStaEntry->statsMask;
13937 pNewStaEntry->pMac = pStaEntry->pMac;
13938 pNewStaEntry->staId = pStaEntry->staId;
13939 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
13940 pNewStaEntry->rspPending = pStaEntry->rspPending;
13941
13942 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070013943 return pNewStaEntry;
13944}
Jeff Johnson295189b2012-06-20 16:38:30 -070013945eHalStatus csrGetRssi(tpAniSirGlobal pMac,
13946 tCsrRssiCallback callback,
13947 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
13948{
13949 eHalStatus status = eHAL_STATUS_SUCCESS;
13950 vos_msg_t msg;
13951 tANI_U32 sessionId;
13952
13953 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013954 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013955 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetRssiReq));
13956 if ( !HAL_STATUS_SUCCESS(status) )
13957 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013958 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070013959 return status;
13960 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013961 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
13962
13963 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
13964 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
13965 pMsg->sessionId = sessionId;
13966 pMsg->staId = staId;
13967 pMsg->rssiCallback = callback;
13968 pMsg->pDevContext = pContext;
13969 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070013970 msg.type = eWNI_SME_GET_RSSI_REQ;
13971 msg.bodyptr = pMsg;
13972 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013973 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
13974 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013975 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Jeff Johnson295189b2012-06-20 16:38:30 -070013976 palFreeMemory(pMac->hHdd, (void *)pMsg);
13977 status = eHAL_STATUS_FAILURE;
13978 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013979 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013980 return status;
13981}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080013982
13983#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
13984eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
13985 tCsrRssiCallback callback,
13986 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
13987{
13988 eHalStatus status = eHAL_STATUS_SUCCESS;
13989 tAniGetRssiReq *pMsg;
13990
13991 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetRssiReq));
13992 if ( !HAL_STATUS_SUCCESS(status) )
13993 {
13994 smsLog(pMac, LOGE, " csrGetRoamRssi: failed to allocate mem for req");
13995 return status;
13996 }
13997 // need to initiate a stats request to PE
13998 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
13999 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
14000 pMsg->staId = staId;
14001 pMsg->rssiCallback = callback;
14002 pMsg->pDevContext = pContext;
14003 pMsg->pVosContext = pVosContext;
14004 status = palSendMBMessage(pMac->hHdd, pMsg );
14005 if(!HAL_STATUS_SUCCESS(status))
14006 {
14007 smsLog(pMac, LOG1, " csrGetRoamRssi: failed to send down the stats req");
14008 palFreeMemory(pMac->hHdd, (void *)pMsg);
14009 status = eHAL_STATUS_FAILURE;
14010 }
14011 return status;
14012}
14013#endif
14014
Jeff Johnson295189b2012-06-20 16:38:30 -070014015eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
14016 tANI_U32 statsMask,
14017 tCsrStatsCallback callback,
14018 tANI_U32 periodicity, tANI_BOOLEAN cache,
14019 tANI_U8 staId, void *pContext)
14020{
14021 tCsrStatsClientReqInfo staEntry;
14022 tCsrStatsClientReqInfo *pStaEntry = NULL;
14023 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
14024 tListElem *pEntry = NULL;
14025 tANI_BOOLEAN found = FALSE;
14026 eHalStatus status = eHAL_STATUS_SUCCESS;
14027 tANI_BOOLEAN insertInClientList = FALSE;
14028 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070014029 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070014030
14031 if( csrIsAllSessionDisconnected(pMac) )
14032 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014033 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070014034 return eHAL_STATUS_FAILURE;
14035 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014036 if((!statsMask) && (!callback))
14037 {
14038 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014039 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070014040 return eHAL_STATUS_FAILURE;
14041 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014042 //for the search list method for deregister
14043 staEntry.requesterId = requesterId;
14044 staEntry.statsMask = statsMask;
14045 //requester wants to deregister or just an error
14046 if((statsMask) && (!callback))
14047 {
14048 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
14049 if(!pEntry)
14050 {
14051 //msg
14052 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014053 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070014054 return eHAL_STATUS_FAILURE;
14055 }
14056 else
14057 {
14058 //clean up & return
14059 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070014060 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070014061 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014062 pStaEntry->pPeStaEntry->numClient--;
14063 //check if we need to delete the entry from peStatsReqList too
14064 if(!pStaEntry->pPeStaEntry->numClient)
14065 {
14066 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
14067 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014068 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070014069
Jeff Johnson295189b2012-06-20 16:38:30 -070014070 //check if we need to stop the tl stats timer too
14071 pMac->roam.tlStatsReqInfo.numClient--;
14072 if(!pMac->roam.tlStatsReqInfo.numClient)
14073 {
14074 if(pMac->roam.tlStatsReqInfo.timerRunning)
14075 {
14076 status = palTimerStop(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
14077 if(!HAL_STATUS_SUCCESS(status))
14078 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014079 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014080 return eHAL_STATUS_FAILURE;
14081 }
14082 }
14083 pMac->roam.tlStatsReqInfo.periodicity = 0;
14084 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14085 }
14086 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070014087 // Destroy the vos timer...
14088 vosStatus = vos_timer_destroy( &pStaEntry->timer );
14089 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14090 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014091 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014092 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014093 csrRoamRemoveStatListEntry(pMac, pEntry);
14094 pStaEntry = NULL;
14095 return eHAL_STATUS_SUCCESS;
14096 }
14097 }
14098
14099 if(cache && !periodicity)
14100 {
14101 //return the cached stats
14102 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
14103 }
14104 else
14105 {
14106 //add the request in the client req list
14107 staEntry.callback = callback;
14108 staEntry.pContext = pContext;
14109 staEntry.periodicity = periodicity;
14110 staEntry.pPeStaEntry = NULL;
14111 staEntry.staId = staId;
14112 staEntry.pMac = pMac;
14113 staEntry.timerExpired = FALSE;
14114
14115
Jeff Johnson295189b2012-06-20 16:38:30 -070014116 //if periodic report requested with non cached result from PE/TL
14117 if(periodicity)
14118 {
14119
14120 //if looking for stats from PE
14121 if(statsMask & ~(1 << eCsrGlobalClassDStats))
14122 {
14123
14124 //check if same request made already & waiting for rsp
14125 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
14126 periodicity, &found, staId);
14127 if(!pPeStaEntry)
14128 {
14129 //bail out, maxed out on number of req for PE
14130 return eHAL_STATUS_FAILURE;
14131 }
14132 else
14133 {
14134 staEntry.pPeStaEntry = pPeStaEntry;
14135 }
14136
14137 }
14138 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
14139 if(statsMask & (1 << eCsrGlobalClassDStats))
14140 {
14141 if(cache && pMac->roam.tlStatsReqInfo.numClient)
14142 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014143 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014144 }
14145 else
14146 {
14147
14148 //update periodicity
14149 if(pMac->roam.tlStatsReqInfo.periodicity)
14150 {
14151 pMac->roam.tlStatsReqInfo.periodicity =
14152 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
14153 }
14154 else
14155 {
14156 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
14157 }
14158 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
14159 {
14160 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
14161 }
14162
14163 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14164 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014165 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
14166 if(NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014167 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014168 //req TL for class D stats
14169 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
14170 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014171 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070014172 }
14173 else
14174 {
14175 //save in SME
14176 csrRoamSaveStatsFromTl(pMac, pTlStats);
14177 }
14178 vos_mem_free(pTlStats);
14179 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014180 }
14181 else
14182 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014183 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014184 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014185
Jeff Johnson295189b2012-06-20 16:38:30 -070014186 if(pMac->roam.tlStatsReqInfo.periodicity)
14187 {
14188 //start timer
14189 status = palTimerStart(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14190 pMac->roam.tlStatsReqInfo.periodicity * PAL_TIMER_TO_MS_UNIT, eANI_BOOLEAN_FALSE);
14191 if(!HAL_STATUS_SUCCESS(status))
14192 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014193 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014194 return eHAL_STATUS_FAILURE;
14195 }
14196 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14197 }
14198 }
14199 }
14200 pMac->roam.tlStatsReqInfo.numClient++;
14201 }
14202
14203 insertInClientList = TRUE;
14204 }
14205 //if one time report requested with non cached result from PE/TL
14206 else if(!cache && !periodicity)
14207 {
14208 if(statsMask & ~(1 << eCsrGlobalClassDStats))
14209 {
14210 //send down a req
14211 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
14212 if(!HAL_STATUS_SUCCESS(status))
14213 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014214 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014215 }
14216 //so that when the stats rsp comes back from PE we respond to upper layer
14217 //right away
14218 staEntry.timerExpired = TRUE;
14219 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014220 }
14221 if(statsMask & (1 << eCsrGlobalClassDStats))
14222 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014223 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
14224 if(NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014225 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014226 //req TL for class D stats
14227 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
14228 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014229 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070014230 }
14231 else
14232 {
14233 //save in SME
14234 csrRoamSaveStatsFromTl(pMac, pTlStats);
14235 }
14236 vos_mem_free(pTlStats);
14237 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014238 }
14239 else
14240 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014241 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014242 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014243
14244 }
14245 //if looking for stats from TL only
14246 if(!insertInClientList)
14247 {
14248 //return the stats
14249 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
14250 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014251 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014252 if(insertInClientList)
14253 {
14254 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
14255 if(!pStaEntry)
14256 {
14257 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014258 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070014259 return eHAL_STATUS_FAILURE;
14260 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014261 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070014262 //Init & start timer if needed
14263 if(periodicity)
14264 {
14265 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
14266 csrRoamStatsClientTimerHandler, pStaEntry );
14267 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14268 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014269 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014270 return eHAL_STATUS_FAILURE;
14271 }
14272 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
14273 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14274 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014275 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014276 return eHAL_STATUS_FAILURE;
14277 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014278 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014279 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014280 }
14281 return eHAL_STATUS_SUCCESS;
14282}
14283
Jeff Johnson295189b2012-06-20 16:38:30 -070014284tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
14285 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
14286{
14287 tANI_BOOLEAN found = FALSE;
14288 eHalStatus status = eHAL_STATUS_SUCCESS;
14289 tCsrPeStatsReqInfo staEntry;
14290 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
14291 tListElem *pStaEntry = NULL;
14292 VOS_STATUS vosStatus;
14293 tPmcPowerState powerState;
14294 *pFound = FALSE;
14295
14296 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
14297 if(pStaEntry)
14298 {
14299 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
14300 if(pTempStaEntry->periodicity)
14301 {
14302 pTempStaEntry->periodicity =
14303 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
14304 }
14305 else
14306 {
14307 pTempStaEntry->periodicity = periodicity;
14308 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014309 pTempStaEntry->numClient++;
14310 found = TRUE;
14311 }
14312 else
14313 {
14314 palZeroMemory(pMac->hHdd, &staEntry, sizeof(tCsrPeStatsReqInfo));
14315 staEntry.numClient = 1;
14316 staEntry.periodicity = periodicity;
14317 staEntry.pMac = pMac;
14318 staEntry.rspPending = FALSE;
14319 staEntry.staId = staId;
14320 staEntry.statsMask = statsMask;
14321 staEntry.timerRunning = FALSE;
14322 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
14323 if(!pTempStaEntry)
14324 {
14325 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014326 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070014327 return NULL;
14328 }
14329 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014330 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
14331 if(ePMC_FULL_POWER == powerState)
14332 {
14333 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
14334 {
14335 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
14336 }
14337 }
14338 else
14339 {
14340 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
14341 {
14342 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
14343 }
14344 }
14345 if(!pTempStaEntry->timerRunning)
14346 {
14347 //send down a req in case of one time req, for periodic ones wait for timer to expire
14348 if(!pTempStaEntry->rspPending &&
14349 !pTempStaEntry->periodicity)
14350 {
14351 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
14352 if(!HAL_STATUS_SUCCESS(status))
14353 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014354 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014355 }
14356 else
14357 {
14358 pTempStaEntry->rspPending = TRUE;
14359 }
14360 }
14361 if(pTempStaEntry->periodicity)
14362 {
14363 if(!found)
14364 {
14365
14366 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
14367 csrRoamPeStatsTimerHandler, pTempStaEntry );
14368 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14369 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014370 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014371 return NULL;
14372 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014373 }
14374 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014375 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070014376 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
14377 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14378 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014379 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014380 return NULL;
14381 }
14382 pTempStaEntry->timerRunning = TRUE;
14383 }
14384 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014385 *pFound = found;
14386 return pTempStaEntry;
14387}
14388
Jeff Johnson295189b2012-06-20 16:38:30 -070014389/*
14390 pStaEntry is no longer invalid upon the return of this function.
14391*/
14392static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
14393{
14394 if(pEntry)
14395 {
14396 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
14397 {
14398 palFreeMemory(pMac->hHdd, GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070014399 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014400 }
14401 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014402
14403void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
14404{
14405 tListElem *pEntry;
14406 tCsrPeStatsReqInfo *pTempStaEntry;
14407 VOS_STATUS vosStatus;
14408 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014409 if(!pEntry)
14410 {
14411 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014412 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: List empty, no stats req for PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070014413 return;
14414 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014415 while( pEntry )
14416 {
14417 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014418 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
14419 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014420 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014421 if(pTempStaEntry->timerRunning)
14422 {
14423 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
14424 /* If we are not able to stop the timer here, just remove
14425 * the entry from the linked list. Destroy the timer object
14426 * and free the memory in the timer CB
14427 */
14428 if( vosStatus == VOS_STATUS_SUCCESS )
14429 {
14430 /* the timer is successfully stopped */
14431 pTempStaEntry->timerRunning = FALSE;
14432
14433 /* Destroy the timer */
14434 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
14435 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14436 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014437 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014438 }
14439 }
14440 else
14441 {
14442 // the timer could not be stopped. Hence destroy and free the
14443 // memory for the PE stat entry in the timer CB.
14444 pTempStaEntry->timerStopFailed = TRUE;
14445 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014446 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014447
14448 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
14449 {
14450 // Only free the memory if we could stop the timer successfully
14451 if(!pTempStaEntry->timerStopFailed)
14452 {
14453 palFreeMemory(pMac->hHdd, pTempStaEntry);
14454 pTempStaEntry = NULL;
14455 }
14456 break;
14457 }
14458
14459 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
14460 }
14461 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014462 return;
14463}
14464
14465
Jeff Johnsone7245742012-09-05 17:12:55 -070014466void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014467{
14468
Jeff Johnsone7245742012-09-05 17:12:55 -070014469 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
14470 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
14471 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
14472 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
14473 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
14474 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
14475 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070014476 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070014477 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
14478 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
14479 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
14480 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
14481 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
14482 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070014483 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070014484 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
14485 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070014486
14487}
14488
Jeff Johnson295189b2012-06-20 16:38:30 -070014489void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
14490 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
14491{
14492 tANI_U8 stats[500];
14493 tANI_U8 *pStats = NULL;
14494 tANI_U32 tempMask = 0;
14495 tANI_U8 counter = 0;
14496 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014497 if(!callback)
14498 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014499 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014500 return;
14501 }
14502 if(!statsMask)
14503 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014504 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014505 return;
14506 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014507 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070014508 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070014509 while(tempMask)
14510 {
14511 if(tempMask & 1)
14512 {
14513 //new stats info from PE, fill up the stats strucutres in PMAC
14514 switch(counter)
14515 {
14516 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014517 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014518 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
14519 sizeof(tCsrSummaryStatsInfo));
14520 if(!HAL_STATUS_SUCCESS(status))
14521 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014522 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014523 }
14524 pStats += sizeof(tCsrSummaryStatsInfo);
14525 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014526 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014527 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014528 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
14529 sizeof(tCsrGlobalClassAStatsInfo));
14530 if(!HAL_STATUS_SUCCESS(status))
14531 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014532 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014533 }
14534 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070014535 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014536 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014537 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014538 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
14539 sizeof(tCsrGlobalClassBStatsInfo));
14540 if(!HAL_STATUS_SUCCESS(status))
14541 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014542 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014543 }
14544 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070014545 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014546 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014547 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014548 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
14549 sizeof(tCsrGlobalClassCStatsInfo));
14550 if(!HAL_STATUS_SUCCESS(status))
14551 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014552 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014553 }
14554 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070014555 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014556 case eCsrGlobalClassDStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014557 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassD stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014558 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
14559 sizeof(tCsrGlobalClassDStatsInfo));
14560 if(!HAL_STATUS_SUCCESS(status))
14561 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014562 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassD stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014563 }
14564 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070014565 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014566 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014567 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014568 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
14569 sizeof(tCsrPerStaStatsInfo));
14570 if(!HAL_STATUS_SUCCESS(status))
14571 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014572 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014573 }
14574 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070014575 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014576 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014577 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014578 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014579 }
14580 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014581 tempMask >>=1;
14582 counter++;
14583 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014584 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070014585}
14586
Jeff Johnson295189b2012-06-20 16:38:30 -070014587eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
14588{
14589 tListElem *pEntry = NULL;
14590 tListElem *pPrevEntry = NULL;
14591 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
14592 eHalStatus status = eHAL_STATUS_SUCCESS;
14593 VOS_STATUS vosStatus;
14594 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014595 if(!pEntry)
14596 {
14597 //list empty
14598 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014599 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014600 return status;
14601 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014602 while( pEntry )
14603 {
14604 if(pPrevEntry)
14605 {
14606 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
14607 //send up the stats report
14608 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
14609 pTempStaEntry->staId, pTempStaEntry->pContext);
14610 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
14611 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014612 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014613 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
14614 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014615 pTempStaEntry->pPeStaEntry->numClient--;
14616 //check if we need to delete the entry from peStatsReqList too
14617 if(!pTempStaEntry->pPeStaEntry->numClient)
14618 {
14619 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
14620 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014621 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014622 //check if we need to stop the tl stats timer too
14623 pMac->roam.tlStatsReqInfo.numClient--;
14624 if(!pMac->roam.tlStatsReqInfo.numClient)
14625 {
14626 if(pMac->roam.tlStatsReqInfo.timerRunning)
14627 {
14628 status = palTimerStop(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
14629 if(!HAL_STATUS_SUCCESS(status))
14630 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014631 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014632 //we will continue
14633 }
14634 }
14635 pMac->roam.tlStatsReqInfo.periodicity = 0;
14636 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14637 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014638 if (pTempStaEntry->periodicity)
14639 {
14640 //While creating StaEntry in csrGetStatistics,
14641 //Initializing and starting timer only when periodicity is set.
14642 //So Stop and Destroy timer only when periodicity is set.
14643
Jeff Johnsone7245742012-09-05 17:12:55 -070014644 vos_timer_stop( &pTempStaEntry->timer );
14645 // Destroy the vos timer...
14646 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
14647 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14648 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014649 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070014650 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014651 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014652
Jeff Johnson295189b2012-06-20 16:38:30 -070014653
14654 pPrevEntry = pEntry;
14655 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14656 }
14657 //the last one
14658 if(pPrevEntry)
14659 {
14660 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
14661 //send up the stats report
14662 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
14663 pTempStaEntry->staId, pTempStaEntry->pContext);
14664 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
14665 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014666 return status;
14667
14668}
14669
Jeff Johnson295189b2012-06-20 16:38:30 -070014670eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
14671 tRequestFullPowerReason *pReason,
14672 tANI_BOOLEAN *pfNeedPower )
14673{
14674 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
14675 tRequestFullPowerReason reason = eSME_REASON_OTHER;
14676 tPmcState pmcState;
14677 eHalStatus status = eHAL_STATUS_SUCCESS;
14678 // TODO : Session info unavailable
14679 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014680 if( pfNeedPower )
14681 {
14682 *pfNeedPower = eANI_BOOLEAN_FALSE;
14683 }
14684 //We only handle CSR commands
14685 if( !(eSmeCsrCommandMask & pCommand->command) )
14686 {
14687 return eHAL_STATUS_SUCCESS;
14688 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014689 //Check PMC state first
14690 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070014691 switch( pmcState )
14692 {
14693 case REQUEST_IMPS:
14694 case IMPS:
14695 if( eSmeCommandScan == pCommand->command )
14696 {
14697 switch( pCommand->u.scanCmd.reason )
14698 {
14699 case eCsrScanGetResult:
14700 case eCsrScanBGScanAbort:
14701 case eCsrScanBGScanEnable:
14702 case eCsrScanGetScanChnInfo:
14703 //Internal process, no need for full power
14704 fNeedFullPower = eANI_BOOLEAN_FALSE;
14705 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014706 default:
14707 //Other scans are real scan, ask for power
14708 fNeedFullPower = eANI_BOOLEAN_TRUE;
14709 break;
14710 } //switch
14711 }
14712 else
14713 {
14714 //ask for power for roam and status change
14715 fNeedFullPower = eANI_BOOLEAN_TRUE;
14716 }
14717 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014718 case REQUEST_BMPS:
14719 case BMPS:
14720 case REQUEST_START_UAPSD:
14721 case UAPSD:
14722 //We treat WOWL same as BMPS
14723 case REQUEST_ENTER_WOWL:
14724 case WOWL:
14725 if( eSmeCommandRoam == pCommand->command )
14726 {
14727 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
14728 tCsrScanResult *pScanResult;
14729 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014730 switch ( pCommand->u.roamCmd.roamReason )
14731 {
14732 case eCsrForcedDisassoc:
14733 case eCsrForcedDisassocMICFailure:
14734 reason = eSME_LINK_DISCONNECTED_BY_HDD;
14735 fNeedFullPower = eANI_BOOLEAN_TRUE;
14736 break;
14737 case eCsrSmeIssuedDisassocForHandoff:
14738 case eCsrForcedDeauth:
14739 case eCsrHddIssuedReassocToSameAP:
14740 case eCsrSmeIssuedReassocToSameAP:
14741 fNeedFullPower = eANI_BOOLEAN_TRUE;
14742 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014743 case eCsrCapsChange:
14744 fNeedFullPower = eANI_BOOLEAN_TRUE;
14745 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014746 default:
14747 //Check whether the profile is already connected. If so, no need for full power
14748 //Note: IBSS is ignored for now because we don't support powersave in IBSS
14749 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
14750 {
14751 //Only need to check the first one
14752 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
14753 if( pEntry )
14754 {
14755 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
14756#if 0
14757 // TODO : Session Specific info pConnectBssDesc
14758 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
14759 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
14760 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
14761 {
14762 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
14763 // with Authenticating first. To force this, stop the current association (Disassociate) and
14764 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
14765 // a new Association.
14766 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
14767 {
14768 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
14769 {
14770 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
14771 //No need for full power
14772 //Set the flag so the code later can avoid to do the above
14773 //check again.
14774 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
14775 break;
14776 }
14777 }
14778 }
14779#endif
14780 }
14781 }
14782 //If we are here, full power is needed
14783 fNeedFullPower = eANI_BOOLEAN_TRUE;
14784 break;
14785 }
14786 }
14787 else if( eSmeCommandWmStatusChange == pCommand->command )
14788 {
14789 //need full power for all
14790 fNeedFullPower = eANI_BOOLEAN_TRUE;
14791 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
14792 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014793#ifdef FEATURE_WLAN_TDLS
14794 else if( eSmeCommandTdlsAddPeer == pCommand->command )
14795 {
14796 //TDLS link is getting established. need full power
14797 fNeedFullPower = eANI_BOOLEAN_TRUE;
14798 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
14799 }
14800#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014801 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014802 case REQUEST_STOP_UAPSD:
14803 case REQUEST_EXIT_WOWL:
14804 if( eSmeCommandRoam == pCommand->command )
14805 {
14806 fNeedFullPower = eANI_BOOLEAN_TRUE;
14807 switch ( pCommand->u.roamCmd.roamReason )
14808 {
14809 case eCsrForcedDisassoc:
14810 case eCsrForcedDisassocMICFailure:
14811 reason = eSME_LINK_DISCONNECTED_BY_HDD;
14812 break;
14813 default:
14814 break;
14815 }
14816 }
14817 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014818 case STOPPED:
14819 case REQUEST_STANDBY:
14820 case STANDBY:
14821 case LOW_POWER:
14822 //We are not supposed to do anything
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014823 smsLog( pMac, LOGE, FL( " cannot process because PMC is in stopped/standby state %d" ), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070014824 status = eHAL_STATUS_FAILURE;
14825 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014826 case FULL_POWER:
14827 case REQUEST_FULL_POWER:
14828 default:
14829 //No need to ask for full power. This has to be FULL_POWER state
14830 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014831 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070014832 if( pReason )
14833 {
14834 *pReason = reason;
14835 }
14836 if( pfNeedPower )
14837 {
14838 *pfNeedPower = fNeedFullPower;
14839 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014840 return ( status );
14841}
14842
Jeff Johnson295189b2012-06-20 16:38:30 -070014843static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14844{
14845 eHalStatus status = eHAL_STATUS_SUCCESS;
14846 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
14847 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070014848 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070014849 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
14850 {
14851 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
14852 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014853 return ( status );
14854}
14855
Jeff Johnson295189b2012-06-20 16:38:30 -070014856tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
14857{
14858 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070014859 if( pCmd )
14860 {
14861 pMac->roam.sPendingCommands++;
14862 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014863 return ( pCmd );
14864}
14865
Jeff Johnson295189b2012-06-20 16:38:30 -070014866void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
14867{
14868 if (pMac->roam.sPendingCommands > 0)
14869 {
14870 //All command allocated through csrGetCommandBuffer need to
14871 //decrement the pending count when releasing.
14872 pMac->roam.sPendingCommands--;
14873 smeReleaseCommand( pMac, pCommand );
14874 }
14875 else
14876 {
14877 smsLog(pMac, LOGE, FL( "no pending commands"));
14878 VOS_ASSERT(0);
14879 }
14880}
14881
Jeff Johnson295189b2012-06-20 16:38:30 -070014882//Return SUCCESS is the command is queued, failed
14883eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
14884{
14885 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014886 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
14887 {
14888 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
14889 pCommand->u.scanCmd.reason);
14890 return eHAL_STATUS_CSR_WRONG_STATE;
14891 }
14892
14893 //We can call request full power first before putting the command into pending Q
14894 //because we are holding SME lock at this point.
14895 status = csrRequestFullPower( pMac, pCommand );
14896 if( HAL_STATUS_SUCCESS( status ) )
14897 {
14898 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070014899 //make sure roamCmdPendingList is not empty first
14900 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
14901 if( fNoCmdPending )
14902 {
14903 smePushCommand( pMac, pCommand, fHighPriority );
14904 }
14905 else
14906 {
14907 //Other commands are waiting for PMC callback, queue the new command to the pending Q
14908 //no list lock is needed since SME lock is held
14909 if( !fHighPriority )
14910 {
14911 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
14912 }
14913 else {
14914 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
14915 }
14916 }
14917 }
14918 else if( eHAL_STATUS_PMC_PENDING == status )
14919 {
14920 //no list lock is needed since SME lock is held
14921 if( !fHighPriority )
14922 {
14923 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
14924 }
14925 else {
14926 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
14927 }
14928 //Let caller know the command is queue
14929 status = eHAL_STATUS_SUCCESS;
14930 }
14931 else
14932 {
14933 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
14934 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014935 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070014936 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014937 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014938}
Jeff Johnson295189b2012-06-20 16:38:30 -070014939eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
14940{
14941 eHalStatus status = eHAL_STATUS_SUCCESS;
14942 tSirUpdateAPWPSIEsReq *pMsg;
14943 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
14944
14945 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14946 if (NULL == pSession)
14947 {
14948 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
14949 return eHAL_STATUS_FAILURE;
14950 }
14951
Jeff Johnson295189b2012-06-20 16:38:30 -070014952 do
14953 {
14954 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirUpdateAPWPSIEsReq) );
14955 if (!HAL_STATUS_SUCCESS(status)) break;
14956 palZeroMemory( pMac->hHdd, pMsg, sizeof(tSirUpdateAPWPSIEsReq) );
14957 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
14958
14959 pBuf = (tANI_U8 *)&pMsg->transactionId;
14960 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014961 // transactionId
14962 *pBuf = 0;
14963 *( pBuf + 1 ) = 0;
14964 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014965 // bssId
14966 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
14967 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014968 //sessionId
14969 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014970 // APWPSIEs
14971 palCopyMemory( pMac->hHdd, (tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
14972 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070014973 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070014974 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014975 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014976 return ( status );
14977}
Jeff Johnson295189b2012-06-20 16:38:30 -070014978eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
14979{
14980 eHalStatus status = eHAL_STATUS_SUCCESS;
14981 tSirUpdateAPWPARSNIEsReq *pMsg;
14982 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014983 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14984 if (NULL == pSession)
14985 {
14986 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
14987 return eHAL_STATUS_FAILURE;
14988 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014989 do
14990 {
14991 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirUpdateAPWPARSNIEsReq) );
14992 if (!HAL_STATUS_SUCCESS(status)) break;
14993 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ) );
14994 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014995 pBuf = (tANI_U8 *)&pMsg->transactionId;
14996 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014997 // transactionId
14998 *pBuf = 0;
14999 *( pBuf + 1 ) = 0;
15000 pBuf += sizeof(tANI_U16);
15001
15002 // bssId
15003 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
15004 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015005 // sessionId
15006 *pBuf++ = (tANI_U8)sessionId;
15007
15008 // APWPARSNIEs
15009 palCopyMemory( pMac->hHdd, (tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
15010 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070015011 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070015012 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015013 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015014 return ( status );
15015}
Jeff Johnson295189b2012-06-20 16:38:30 -070015016
15017#ifdef WLAN_FEATURE_VOWIFI_11R
15018//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
15019eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
15020{
15021 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
15022 tpSirFTPreAuthReq pftPreAuthReq;
15023 tANI_U16 auth_req_len = 0;
15024 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015025 auth_req_len = sizeof(tSirFTPreAuthReq);
15026 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
15027 if (pftPreAuthReq == NULL)
15028 {
15029 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
15030 return eHAL_STATUS_RESOURCES;
15031 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015032 // Save the SME Session ID here. We need it while processing the preauth response
15033 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015034 vos_mem_zero(pftPreAuthReq, auth_req_len);
15035
15036 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
15037 sizeof(pBssDescription->length) + pBssDescription->length);
15038
15039 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
15040
15041 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
15042
Jeff Johnson295189b2012-06-20 16:38:30 -070015043 palCopyMemory(pMac->hHdd, (void *)&pftPreAuthReq->currbssId, (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015044 palCopyMemory(pMac->hHdd, (void *)&pftPreAuthReq->preAuthbssId, (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
15045
Jeff Johnson295189b2012-06-20 16:38:30 -070015046#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080015047 if (csrRoamIs11rAssoc(pMac) &&
15048 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070015049 {
15050 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
15051 palCopyMemory(pMac->hHdd, pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
15052 pMac->ft.ftSmeContext.auth_ft_ies_length);
15053 }
15054 else
15055#endif
15056 {
15057 pftPreAuthReq->ft_ies_length = 0;
15058 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070015059 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
15060 sizeof(pBssDescription->length) + pBssDescription->length);
15061 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070015062 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
15063}
Jeff Johnson295189b2012-06-20 16:38:30 -070015064/*--------------------------------------------------------------------------
15065 * This will receive and process the FT Pre Auth Rsp from the current
15066 * associated ap.
15067 *
15068 * This will invoke the hdd call back. This is so that hdd can now
15069 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
15070 ------------------------------------------------------------------------*/
15071void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
15072{
15073 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
15074 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015075#ifdef FEATURE_WLAN_LFR
15076 tCsrRoamInfo roamInfo;
15077#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015078
15079#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080015080 smsLog( pMac, LOGE, FL("Preauth response status code 0x%x"), pFTPreAuthRsp->status);
Jeff Johnson295189b2012-06-20 16:38:30 -070015081#endif
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070015082#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080015083 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070015084 if (status != eHAL_STATUS_SUCCESS) {
15085 /*
15086 * Bail out if pre-auth was not even processed.
15087 */
15088 smsLog(pMac, LOGW, FL("Preauth was not processed: %d"), status);
15089 return;
15090 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015091#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015092 /* The below function calls/timers should be invoked only if the pre-auth is successful */
15093 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
15094 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070015095 // Implies a success
15096 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015097 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
15098 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
15099 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070015100 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
15101 * actual transition from the current to handoff AP is triggered */
15102 status = palTimerStart(pMac->hHdd, pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
15103 60 * PAL_TIMER_TO_MS_UNIT,
15104 eANI_BOOLEAN_FALSE);
15105 if (eHAL_STATUS_SUCCESS != status)
15106 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015107 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070015108 return;
15109 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015110 // Save the received response
15111 palCopyMemory(pMac->hHdd, (void *)&pMac->ft.ftSmeContext.preAuthbssId, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
15112 if (csrRoamIs11rAssoc(pMac))
15113 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
15114 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
15115
15116 // Currently we dont do anything special for CCX connection.
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015117#ifdef FEATURE_WLAN_LFR
15118 // If Legacy Fast Roaming is enabled, signal the supplicant
15119 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053015120 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015121 {
15122 // Save the bssid from the received response
15123 palCopyMemory(pMac->hHdd, (void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
15124 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
15125 }
15126
15127#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015128
15129 // Done with it, init it.
15130 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
15131}
15132#endif
15133#ifdef FEATURE_WLAN_BTAMP_UT_RF
15134void csrRoamJoinRetryTimerHandler(void *pv)
15135{
15136 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
15137 tpAniSirGlobal pMac = pInfo->pMac;
15138 tANI_U32 sessionId = pInfo->sessionId;
15139 tCsrRoamSession *pSession;
15140
15141 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
15142 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015143 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015144 pSession = CSR_GET_SESSION( pMac, sessionId );
15145 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
15146 {
15147 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
15148 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015149 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070015150 }
15151 }
15152 }
15153}
Jeff Johnson295189b2012-06-20 16:38:30 -070015154eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
15155{
15156 eHalStatus status = eHAL_STATUS_FAILURE;
15157 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15158
15159 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
15160 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015161 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070015162 pSession->maxRetryCount--;
15163 pSession->joinRetryTimerInfo.pMac = pMac;
15164 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
15165 status = palTimerStart(pMac->hHdd, pSession->hTimerJoinRetry, interval, eANI_BOOLEAN_FALSE);
15166 if(!HAL_STATUS_SUCCESS(status))
15167 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015168 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070015169 }
15170 }
15171 else
15172 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015173 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070015174 pSession->maxRetryCount);
15175 }
15176
15177 return (status);
15178}
Jeff Johnson295189b2012-06-20 16:38:30 -070015179eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
15180{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015181 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070015182 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
15183 {
15184 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerJoinRetry));
15185 }
15186
15187 return eHAL_STATUS_SUCCESS;
15188}
15189#endif
15190
15191
15192/*
15193 pBuf points to the beginning of the message
15194 LIM packs disassoc rsp as below,
15195 messageType - 2 bytes
15196 messageLength - 2 bytes
15197 sessionId - 1 byte
15198 transactionId - 2 bytes (tANI_U16)
15199 reasonCode - 4 bytes (sizeof(tSirResultCodes))
15200 peerMacAddr - 6 bytes
15201 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
15202*/
15203static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
15204{
15205 if(pBuf && pRsp)
15206 {
15207 pBuf += 4; //skip type and length
15208 pRsp->sessionId = *pBuf++;
15209 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
15210 pBuf += 2;
15211 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
15212 pBuf += 4;
15213 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
15214 }
15215}
15216
Jeff Johnsond13512a2012-07-17 11:42:19 -070015217eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
15218{
15219 static uNvTables nvTables;
15220 eHalStatus status = eHAL_STATUS_SUCCESS;
15221 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
15222
15223 /* read the country code from NV and use it */
15224 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
15225 {
15226 palCopyMemory( pMac->hHdd, pCountry,
15227 nvTables.defaultCountryTable.countryCode,
15228 WNI_CFG_COUNTRY_CODE_LEN );
15229 return status;
15230 }
15231 else
15232 {
15233 palCopyMemory( pMac->hHdd, pCountry,
15234 "XXX",
15235 WNI_CFG_COUNTRY_CODE_LEN );
15236 status = eHAL_STATUS_FAILURE;
15237 return status;
15238 }
15239}
15240
15241eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
15242{
15243 palCopyMemory( pMac->hHdd, pCountry,
15244 pMac->scan.countryCode11d,
15245 WNI_CFG_COUNTRY_CODE_LEN );
15246 return eHAL_STATUS_SUCCESS;
15247}