blob: 71f1da81a3dcd93eec353dced1173e9037925d1b [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
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05308371eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
8372{
8373 tpSirResetAPCapsChange pMsg;
8374 tANI_U16 len;
8375 eHalStatus status = eHAL_STATUS_SUCCESS;
8376
8377 /* Create the message and send to lim */
8378 len = sizeof(tSirResetAPCapsChange);
8379 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, len );
8380 if (HAL_STATUS_SUCCESS(status))
8381 {
8382 palZeroMemory(pMac->hHdd, pMsg, sizeof(tSirResetAPCapsChange) );
8383 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
8384 pMsg->length = len;
8385 palCopyMemory( pMac->hHdd, pMsg->bssId, bssId, sizeof(tSirMacAddr) );
8386 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= %02x-%02x-%02x-%02x-%02x-%02x"),
8387 pMsg->bssId[ 0 ], pMsg->bssId[ 1 ], pMsg->bssId[ 2 ],
8388 pMsg->bssId[ 3 ], pMsg->bssId[ 4 ], pMsg->bssId[ 5 ]);
8389 status = palSendMBMessage(pMac->hHdd, pMsg);
8390 }
8391 else
8392 {
8393 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
8394 }
8395 return status;
8396}
8397
Jeff Johnson295189b2012-06-20 16:38:30 -07008398void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
8399{
8400 tSirSmeAssocInd *pAssocInd;
8401 tSirSmeDisassocInd *pDisassocInd;
8402 tSirSmeDeauthInd *pDeauthInd;
8403 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
8404 tSirSmeNewBssInfo *pNewBss;
8405 tSmeIbssPeerInd *pIbssPeerInd;
8406 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
8407 tSirSmeApNewCaps *pApNewCaps;
8408 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
8409 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
8410 tCsrRoamInfo *pRoamInfo = NULL;
8411 tCsrRoamInfo roamInfo;
8412 eHalStatus status;
8413 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
8414 tCsrRoamSession *pSession = NULL;
8415 tpSirSmeSwitchChannelInd pSwitchChnInd;
8416 tSmeMaxAssocInd *pSmeMaxAssocInd;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08008417 tSmeCmd pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008418 pSirMsg->messageType = (pSirMsg->messageType);
8419 pSirMsg->length = (pSirMsg->length);
8420 pSirMsg->statusCode = (pSirMsg->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008421 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07008422 switch( pSirMsg->messageType )
8423 {
8424 case eWNI_SME_ASSOC_IND:
8425 {
8426 tCsrRoamSession *pSession;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008427 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008428 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
8429 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
8430 if( HAL_STATUS_SUCCESS( status ) )
8431 {
8432 pSession = CSR_GET_SESSION(pMac, sessionId);
8433
Jeff Johnson32d95a32012-09-10 13:15:23 -07008434 if(!pSession)
8435 {
8436 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8437 return;
8438 }
8439
Jeff Johnson295189b2012-06-20 16:38:30 -07008440 pRoamInfo = &roamInfo;
8441
8442 // Required for indicating the frames to upper layer
8443 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
8444 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
8445
8446 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
8447 pRoamInfo->beaconLength = pAssocInd->beaconLength;
8448 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8449 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8450
8451 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
8452 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
8453 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
8454
8455 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
8456 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008457 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
8458 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pAssocInd->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008459 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
8460 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07008461 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07008462 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
8463 {
8464 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
8465 {
8466 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
8467 pSession->pConnectBssDesc,
8468 &(pRoamInfo->peerMac),
8469 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
8470 pRoamInfo->fAuthRequired = FALSE;
8471 }
8472 else
8473 {
8474 pRoamInfo->fAuthRequired = TRUE;
8475 }
8476 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
8477 if (!HAL_STATUS_SUCCESS(status))
8478 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
8479 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008480 /* Send Association completion message to PE */
8481 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
8482
8483 /* send a message to CSR itself just to avoid the EAPOL frames going
8484 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07008485 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8486 {
8487 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
8488 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008489 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
8490 {
8491 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
8492 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8493 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
8494 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008495 }
8496 }
8497 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008498 case eWNI_SME_DISASSOC_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008499 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008500 // Check if AP dis-associated us because of MIC failure. If so,
8501 // then we need to take action immediately and not wait till the
8502 // the WmStatusChange requests is pushed and processed
8503 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
8504 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDisassocInd->bssId, &sessionId );
8505 if( HAL_STATUS_SUCCESS( status ) )
8506 {
8507 // If we are in neighbor preauth done state then on receiving
8508 // disassoc or deauth we dont roam instead we just disassoc
8509 // from current ap and then go to disconnected state
8510 // This happens for CCX and 11r FT connections ONLY.
8511#ifdef WLAN_FEATURE_VOWIFI_11R
8512 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8513 {
8514 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8515 }
8516#endif
8517#ifdef FEATURE_WLAN_CCX
8518 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8519 {
8520 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8521 }
8522#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008523#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308524 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008525 {
8526 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8527 }
8528#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008529 pSession = CSR_GET_SESSION( pMac, sessionId );
8530
Jeff Johnson32d95a32012-09-10 13:15:23 -07008531 if(!pSession)
8532 {
8533 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8534 return;
8535 }
8536
Jeff Johnson295189b2012-06-20 16:38:30 -07008537 if ( csrIsConnStateInfra( pMac, sessionId ) )
8538 {
8539 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8540 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008541#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8542 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
8543#endif
8544 csrRoamLinkDown(pMac, sessionId);
8545 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07008546 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
8547 {
8548
8549 pRoamInfo = &roamInfo;
8550
8551 pRoamInfo->statusCode = pDisassocInd->statusCode;
8552 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8553
8554 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
8555
8556 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDisassocInd->peerMacAddr, sizeof(tSirMacAddr));
8557 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pDisassocInd->bssId, sizeof(tCsrBssid));
8558
8559 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08008560
8561 /*
8562 * STA/P2P client got disassociated so remove any pending deauth
8563 * commands in sme pending list
8564 */
8565 pCommand.command = eSmeCommandRoam;
8566 pCommand.sessionId = (tANI_U8)sessionId;
8567 pCommand.u.roamCmd.roamReason = eCsrForcedDeauthSta;
8568 vos_mem_copy(pCommand.u.roamCmd.peerMac, pDisassocInd->peerMacAddr, sizeof(tSirMacAddr));
8569 csrRoamRemoveDuplicateCommand(pMac, sessionId, &pCommand, eCsrForcedDeauthSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07008570 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008571 }
8572 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008573 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008574 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008575 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
8576 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
8577 if( HAL_STATUS_SUCCESS( status ) )
8578 {
8579 // If we are in neighbor preauth done state then on receiving
8580 // disassoc or deauth we dont roam instead we just disassoc
8581 // from current ap and then go to disconnected state
8582 // This happens for CCX and 11r FT connections ONLY.
8583#ifdef WLAN_FEATURE_VOWIFI_11R
8584 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8585 {
8586 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8587 }
8588#endif
8589#ifdef FEATURE_WLAN_CCX
8590 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8591 {
8592 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8593 }
8594#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008595#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308596 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008597 {
8598 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8599 }
8600#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008601 pSession = CSR_GET_SESSION( pMac, sessionId );
8602
Jeff Johnson32d95a32012-09-10 13:15:23 -07008603 if(!pSession)
8604 {
8605 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8606 return;
8607 }
8608
Jeff Johnson295189b2012-06-20 16:38:30 -07008609 if ( csrIsConnStateInfra( pMac, sessionId ) )
8610 {
8611 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8612 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008613#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8614 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
8615#endif
8616 csrRoamLinkDown(pMac, sessionId);
8617 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07008618 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
8619 {
8620
8621 pRoamInfo = &roamInfo;
8622
8623 pRoamInfo->statusCode = pDeauthInd->statusCode;
8624 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8625
8626 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
8627
8628 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDeauthInd->peerMacAddr, sizeof(tSirMacAddr));
8629 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pDeauthInd->bssId, sizeof(tCsrBssid));
8630
8631 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
8632 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008633 }
8634 break;
8635
8636 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 -08008637 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008638 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
8639 //Update with the new channel id.
8640 //The channel id is hidden in the statusCode.
8641 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
8642 if( HAL_STATUS_SUCCESS( status ) )
8643 {
8644 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008645 if(!pSession)
8646 {
8647 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8648 return;
8649 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008650 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
8651 if(pSession->pConnectBssDesc)
8652 {
8653 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
8654 }
8655 }
8656 break;
8657
8658 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008659 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008660 {
8661 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
8662 sessionId = pDeauthRsp->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, pDeauthRsp->peerMacAddr, sizeof(tSirMacAddr));
8676 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
8677 pRoamInfo->statusCode = pDeauthRsp->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;
8683
8684 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07008685 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008686 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07008687 {
8688 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
8689 sessionId = pDisassocRsp->sessionId;
8690 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
8691 {
8692 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008693 if(!pSession)
8694 {
8695 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8696 return;
8697 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008698 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
8699 {
8700 pRoamInfo = &roamInfo;
8701 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8702 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDisassocRsp->peerMacAddr, sizeof(tSirMacAddr));
8703 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
8704 pRoamInfo->statusCode = pDisassocRsp->statusCode;
8705 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
8706 }
8707 }
8708 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008709 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008710 case eWNI_SME_MIC_FAILURE_IND:
8711 {
8712 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
8713 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
8714 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Jeff Johnson295189b2012-06-20 16:38:30 -07008715#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8716 {
8717 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008718 if(!pSession)
8719 {
8720 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8721 return;
8722 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008723 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
8724 palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type));
8725 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
8726 secEvent.encryptionModeMulticast =
8727 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8728 secEvent.encryptionModeUnicast =
8729 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8730 secEvent.authMode =
8731 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8732 palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 );
8733 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
8734 }
8735#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008736 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
8737 if( HAL_STATUS_SUCCESS( status ) )
8738 {
8739 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
8740 roamInfo.u.pMICFailureInfo = &pMicInd->info;
8741 pRoamInfo = &roamInfo;
8742 if(pMicInd->info.multicast)
8743 {
8744 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
8745 }
8746 else
8747 {
8748 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
8749 }
8750 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
8751 }
8752 }
8753 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008754 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
8755 {
8756 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
8757 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008758 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008759
8760 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
8761 if( HAL_STATUS_SUCCESS( status ) )
8762 {
8763 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
8764 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
8765 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
8766 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
8767 }
8768 }
8769 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008770
Jeff Johnson295189b2012-06-20 16:38:30 -07008771 case eWNI_SME_WM_STATUS_CHANGE_NTF:
8772 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
8773 switch( pStatusChangeMsg->statusChangeCode )
8774 {
8775 case eSIR_SME_IBSS_ACTIVE:
8776 sessionId = csrFindIbssSession( pMac );
8777 if( CSR_SESSION_ID_INVALID != sessionId )
8778 {
8779 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008780 if(!pSession)
8781 {
8782 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8783 return;
8784 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008785 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
8786 if(pSession->pConnectBssDesc)
8787 {
8788 palCopyMemory(pMac->hHdd, &roamInfo.bssid, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
8789 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
8790 pRoamInfo = &roamInfo;
8791 }
8792 else
8793 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008794 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07008795 }
8796 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
8797 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
8798 }
8799 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008800 case eSIR_SME_IBSS_INACTIVE:
8801 sessionId = csrFindIbssSession( pMac );
8802 if( CSR_SESSION_ID_INVALID != sessionId )
8803 {
8804 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008805 if(!pSession)
8806 {
8807 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8808 return;
8809 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008810 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
8811 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
8812 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
8813 }
8814 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008815 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
8816 sessionId = csrFindIbssSession( pMac );
8817 if( CSR_SESSION_ID_INVALID != sessionId )
8818 {
8819 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008820 if(!pSession)
8821 {
8822 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8823 return;
8824 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008825 // update the connection state information
8826 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008827#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8828 {
8829 vos_log_ibss_pkt_type *pIbssLog;
8830 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07008831 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8832 if(pIbssLog)
8833 {
8834 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
8835 if(pNewBss)
8836 {
8837 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pNewBss->bssId, 6);
8838 if(pNewBss->ssId.length)
8839 {
8840 palCopyMemory(pMac->hHdd, pIbssLog->ssid, pNewBss->ssId.ssId, pNewBss->ssId.length);
8841 }
8842 pIbssLog->operatingChannel = pNewBss->channelNumber;
8843 }
8844 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
8845 {
8846 //***U8 is not enough for beacon interval
8847 pIbssLog->beaconInterval = (v_U8_t)bi;
8848 }
8849 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
8850 }
8851 }
8852#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008853 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
8854 csrRoamIssueSetContextReq( pMac, sessionId, pSession->connectedProfile.EncryptionType,
8855 pSession->pConnectBssDesc,
8856 &Broadcastaddr,
8857 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
8858 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
8859 roamStatus = eCSR_ROAM_IBSS_IND;
8860 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pNewBss->bssId, sizeof(tCsrBssid));
8861 pRoamInfo = &roamInfo;
8862 //This BSSID is th ereal BSSID, let's save it
8863 if(pSession->pConnectBssDesc)
8864 {
8865 palCopyMemory(pMac->hHdd, pSession->pConnectBssDesc->bssId, &pNewBss->bssId, sizeof(tCsrBssid));
8866 }
8867 // Stop the join IBSS timer in case of join, for
8868 // genuine merge do nothing
8869 if(pSession->ibss_join_pending)
8870 {
8871 pSession->ibss_join_pending = FALSE;
8872 csrRoamStopIbssJoinTimer(pMac, sessionId);
8873 result = eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS;
8874 }
8875 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008876 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07008877 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008878 // detection by LIM that the capabilities of the associated AP have changed.
8879 case eSIR_SME_AP_CAPS_CHANGED:
8880 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008881 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -07008882 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
8883 if( HAL_STATUS_SUCCESS( status ) )
8884 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08008885 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
8886 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05308887 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08008888 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
8889 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
8890 )
8891 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05308892 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
8893 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08008894 }
8895 else
8896 {
8897 smsLog(pMac, LOGW,
8898 "Skipping csrScanForCapabilityChange as "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008899 "CSR is in state %d and sub-state %d",
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08008900 pMac->roam.curState[sessionId],
8901 pMac->roam.curSubState[sessionId]);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05308902 /* We ignore the caps change event if CSR is not in full connected state.
8903 * Send one event to PE to reset limSentCapsChangeNtf
8904 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
8905 * otherwise lim cannot send any CAPS change events to SME */
8906 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08008907 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008908 }
8909 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05308910
Jeff Johnson295189b2012-06-20 16:38:30 -07008911 default:
8912 roamStatus = eCSR_ROAM_FAILED;
8913 result = eCSR_ROAM_RESULT_NONE;
8914 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008915 } // end switch on statusChangeCode
8916 if(eCSR_ROAM_RESULT_NONE != result)
8917 {
8918 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
8919 }
8920 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008921 case eWNI_SME_IBSS_NEW_PEER_IND:
8922 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07008923#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8924 {
8925 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07008926 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8927 if(pIbssLog)
8928 {
8929 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
8930 palCopyMemory(pMac->hHdd, pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
8931 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
8932 }
8933 }
8934#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008935 sessionId = csrFindIbssSession( pMac );
8936 if( CSR_SESSION_ID_INVALID != sessionId )
8937 {
8938 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008939
8940 if(!pSession)
8941 {
8942 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8943 return;
8944 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008945 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
8946 if(pSession->pConnectBssDesc)
8947 {
8948 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
8949 palCopyMemory(pMac->hHdd, &roamInfo.bssid, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
8950 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
8951 {
8952 status = palAllocateMemory(pMac->hHdd, (void **)&roamInfo.pbFrames,
8953 (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd)));
8954 if(HAL_STATUS_SUCCESS(status))
8955 {
8956 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
8957 palCopyMemory(pMac->hHdd, roamInfo.pbFrames, ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
8958 roamInfo.nBeaconLength);
8959 }
8960 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
8961 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8962 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
8963 status = palAllocateMemory(pMac->hHdd, (void **)&roamInfo.pBssDesc,
8964 pSession->pConnectBssDesc->length);
8965 if(HAL_STATUS_SUCCESS(status))
8966 {
8967 palCopyMemory(pMac->hHdd, roamInfo.pBssDesc, pSession->pConnectBssDesc,
8968 pSession->pConnectBssDesc->length);
8969 }
8970 if(HAL_STATUS_SUCCESS(status))
8971 {
8972 pRoamInfo = &roamInfo;
8973 }
8974 else
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 else
8987 {
8988 pRoamInfo = &roamInfo;
8989 }
8990 csrRoamIssueSetContextReq( pMac, sessionId, pSession->connectedProfile.EncryptionType,
8991 pSession->pConnectBssDesc,
8992 &(pIbssPeerInd->peerAddr),
8993 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
8994 }
8995 else
8996 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008997 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07008998 }
8999 //send up the sec type for the new peer
9000 if (pRoamInfo)
9001 {
9002 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9003 }
9004 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9005 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
9006 if(pRoamInfo)
9007 {
9008 if(roamInfo.pbFrames)
9009 {
9010 palFreeMemory(pMac->hHdd, roamInfo.pbFrames);
9011 }
9012 if(roamInfo.pBssDesc)
9013 {
9014 palFreeMemory(pMac->hHdd, roamInfo.pBssDesc);
9015 }
9016 }
9017 }
9018 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009019 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
9020 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
9021 sessionId = csrFindIbssSession( pMac );
9022 if( CSR_SESSION_ID_INVALID != sessionId )
9023 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009024#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9025 {
9026 vos_log_ibss_pkt_type *pIbssLog;
9027
9028 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9029 if(pIbssLog)
9030 {
9031 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
9032 if(pIbssPeerInd)
9033 {
9034 palCopyMemory(pMac->hHdd, pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
9035 }
9036 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9037 }
9038 }
9039#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009040 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009041 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9042 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9043 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
9044 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
9045 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9046 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
9047 }
9048 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009049 case eWNI_SME_SETCONTEXT_RSP:
9050 {
9051 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
9052 tListElem *pEntry;
9053 tSmeCmd *pCommand;
9054
9055 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9056 if ( pEntry )
9057 {
9058 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9059 if ( eSmeCommandSetKey == pCommand->command )
9060 {
9061 sessionId = pCommand->sessionId;
9062 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009063
9064 if(!pSession)
9065 {
9066 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9067 return;
9068 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009069
9070#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9071 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
9072 {
9073 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
9074 palZeroMemory(pMac->hHdd, &setKeyEvent, sizeof(vos_event_wlan_security_payload_type));
9075 if( pRsp->peerMacAddr[0] & 0x01 )
9076 {
9077 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
9078 }
9079 else
9080 {
9081 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
9082 }
9083 setKeyEvent.encryptionModeMulticast =
9084 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9085 setKeyEvent.encryptionModeUnicast =
9086 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9087 palCopyMemory( pMac->hHdd, setKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
9088 setKeyEvent.authMode =
9089 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9090 if( eSIR_SUCCESS != pRsp->statusCode )
9091 {
9092 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9093 }
9094 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9095 }
9096#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
9097 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
9098 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009099 csrRoamStopWaitForKeyTimer( pMac );
9100
Jeff Johnson295189b2012-06-20 16:38:30 -07009101 //We are done with authentication, whethere succeed or not
9102 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009103 //We do it here because this linkup function is not called after association
9104 //when a key needs to be set.
9105 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
9106 {
9107 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9108 }
9109 }
Jeff Johnson43971f52012-07-17 12:26:56 -07009110 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009111 {
9112 palCopyMemory( pMac, &roamInfo.peerMac, &pRsp->peerMacAddr, sizeof(tCsrBssid) );
Jeff Johnsone7245742012-09-05 17:12:55 -07009113 //Make sure we install the GTK before indicating to HDD as authenticated
9114 //This is to prevent broadcast packets go out after PTK and before GTK.
9115 if( palEqualMemory( pMac->hHdd, &Broadcastaddr, pRsp->peerMacAddr,
9116 sizeof(tSirMacAddr) ) )
9117 {
Yathish9f22e662012-12-10 14:21:35 -08009118#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
9119 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
9120 {
9121 tpSirSetActiveModeSetBncFilterReq pMsg;
9122 palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tSirSetActiveModeSetBncFilterReq));
9123 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
9124 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
9125 pMsg->seesionId = sessionId;
9126 status = palSendMBMessage(pMac->hHdd, pMsg );
9127 }
9128#endif
9129 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -07009130 }
9131 else
9132 {
9133 result = eCSR_ROAM_RESULT_NONE;
9134 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009135 pRoamInfo = &roamInfo;
9136 }
9137 else
9138 {
9139 result = eCSR_ROAM_RESULT_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009140 smsLog( pMac, LOGE, "CSR: Roam Completion setkey command failed(%d) PeerMac %02X-%02X-%02X-%02X-%02X-%02X...",
Jeff Johnson295189b2012-06-20 16:38:30 -07009141 pRsp->statusCode, pRsp->peerMacAddr[0], pRsp->peerMacAddr[1], pRsp->peerMacAddr[2],
9142 pRsp->peerMacAddr[3], pRsp->peerMacAddr[4], pRsp->peerMacAddr[5] );
9143 }
9144 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9145 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -07009146 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
9147 // can go ahead and initiate the TSPEC if any are pending
9148 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009149#ifdef FEATURE_WLAN_CCX
9150 //Send Adjacent AP repot to new AP.
9151 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
9152 pSession->isPrevApInfoValid &&
9153 pSession->connectedProfile.isCCXAssoc)
9154 {
9155#ifdef WLAN_FEATURE_VOWIFI
9156 csrCcxSendAdjacentApRepMsg(pMac, pSession);
9157#endif
9158 pSession->isPrevApInfoValid = FALSE;
9159 }
9160#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009161 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9162 {
9163 csrReleaseCommandSetKey( pMac, pCommand );
9164 }
9165 }
9166 else
9167 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009168 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009169 }
9170 }
9171 else
9172 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009173 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009174 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009175 smeProcessPendingQueue( pMac );
9176 }
9177 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009178 case eWNI_SME_REMOVEKEY_RSP:
9179 {
9180 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
9181 tListElem *pEntry;
9182 tSmeCmd *pCommand;
9183
9184 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9185 if ( pEntry )
9186 {
9187 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9188 if ( eSmeCommandRemoveKey == pCommand->command )
9189 {
9190 sessionId = pCommand->sessionId;
9191 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009192
9193 if(!pSession)
9194 {
9195 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9196 return;
9197 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009198#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9199 {
9200 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
9201 palZeroMemory(pMac->hHdd, &removeKeyEvent, sizeof(vos_event_wlan_security_payload_type));
9202 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
9203 removeKeyEvent.encryptionModeMulticast =
9204 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9205 removeKeyEvent.encryptionModeUnicast =
9206 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9207 palCopyMemory( pMac->hHdd, removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
9208 removeKeyEvent.authMode =
9209 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9210 if( eSIR_SUCCESS != pRsp->statusCode )
9211 {
9212 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9213 }
9214 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9215 }
9216#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -07009217 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009218 {
9219 palCopyMemory( pMac, &roamInfo.peerMac, &pRsp->peerMacAddr, sizeof(tCsrBssid) );
9220 result = eCSR_ROAM_RESULT_NONE;
9221 pRoamInfo = &roamInfo;
9222 }
9223 else
9224 {
9225 result = eCSR_ROAM_RESULT_FAILURE;
9226 }
9227 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9228 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
9229 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9230 {
9231 csrReleaseCommandRemoveKey( pMac, pCommand );
9232 }
9233 }
9234 else
9235 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009236 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009237 }
9238 }
9239 else
9240 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009241 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009242 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009243 smeProcessPendingQueue( pMac );
9244 }
9245 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009246 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009247 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009248 csrRoamStatsRspProcessor( pMac, pSirMsg );
9249 break;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009250#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
9251 case eWNI_SME_GET_ROAM_RSSI_RSP:
9252 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
9253 csrRoamRssiRspProcessor( pMac, pSirMsg );
9254 break;
9255#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009256 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009257 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009258 csrUpdateRssi( pMac, pSirMsg );
9259 break;
9260
Jeff Johnson295189b2012-06-20 16:38:30 -07009261#ifdef WLAN_FEATURE_VOWIFI_11R
9262 case eWNI_SME_FT_PRE_AUTH_RSP:
9263 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
9264 break;
9265#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009266 case eWNI_SME_MAX_ASSOC_EXCEEDED:
9267 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009268 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 -07009269 sessionId = pSmeMaxAssocInd->sessionId;
9270 roamInfo.sessionId = sessionId;
9271 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pSmeMaxAssocInd->peerMac, sizeof(tCsrBssid));
9272 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9273 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
9274 break;
9275
9276 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009277 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009278 btampEstablishLogLinkHdlr( pSirMsg );
9279 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07009280 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009281 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009282 csrRoamRssiIndHdlr( pMac, pSirMsg );
9283 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009284
9285 default:
9286 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009287 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -07009288}
9289
Jeff Johnson295189b2012-06-20 16:38:30 -07009290void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
9291 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
9292{
9293 if(pSession)
9294 {
9295 if(pSession->bRefAssocStartCnt)
9296 {
9297 pSession->bRefAssocStartCnt--;
9298 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
9299 //Need to call association_completion because there is an assoc_start pending.
9300 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
9301 eCSR_ROAM_ASSOCIATION_COMPLETION,
9302 eCSR_ROAM_RESULT_FAILURE);
9303 }
9304 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
9305 }
9306 else
9307 {
9308 smsLog(pMac, LOGW, FL(" pSession is NULL"));
9309 }
9310}
9311
9312
9313eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
9314{
9315 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009316 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
9317 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
9318 {
9319 status = csrScanRequestLostLink1( pMac, sessionId );
9320 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009321 return(status);
9322}
9323
Jeff Johnson295189b2012-06-20 16:38:30 -07009324//return a boolean to indicate whether roaming completed or continue.
9325tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
9326 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
9327{
9328 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
9329 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
9330 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
9331 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009332 if(!pSession)
9333 {
9334 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9335 return eANI_BOOLEAN_FALSE;
9336 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009337 //Check whether time is up
9338 if(pSession->fCancelRoaming || fForce ||
9339 ((curTime - pSession->roamingStartTime) > roamTime) ||
9340 eCsrReassocRoaming == pSession->roamingReason ||
9341 eCsrDynamicRoaming == pSession->roamingReason)
9342 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009343 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009344 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
9345 {
9346 //roaming is cancelled, tell HDD to indicate disconnect
9347 //Because LIM overload deauth_ind for both deauth frame and missed beacon
9348 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
9349 //to be eSIR_BEACON_MISSED
9350 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
9351 {
9352 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
9353 }
9354 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
9355 {
9356 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
9357 }
9358 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
9359 {
9360 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
9361 }
9362 else
9363 {
9364 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
9365 }
9366 }
9367 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
9368 pSession->roamingReason = eCsrNotRoaming;
9369 }
9370 else
9371 {
9372 pSession->roamResult = roamResult;
9373 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
9374 {
9375 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
9376 pSession->roamingReason = eCsrNotRoaming;
9377 }
9378 else
9379 {
9380 fCompleted = eANI_BOOLEAN_FALSE;
9381 }
9382 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009383 return(fCompleted);
9384}
9385
Jeff Johnson295189b2012-06-20 16:38:30 -07009386void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
9387{
9388 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009389
9390 if(!pSession)
9391 {
9392 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9393 return;
9394 }
9395
Jeff Johnson295189b2012-06-20 16:38:30 -07009396 if(CSR_IS_ROAMING(pSession))
9397 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009398 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -07009399 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
9400 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
9401 {
9402 //No need to do anything in here because the handler takes care of it
9403 }
9404 else
9405 {
9406 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
9407 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
9408 //Roaming is stopped after here
9409 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
9410 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
9411 csrScanAbortMacScan(pMac);
9412 csrRoamStopRoamingTimer(pMac, sessionId);
9413 }
9414 }
9415}
9416
Jeff Johnson295189b2012-06-20 16:38:30 -07009417void csrRoamRoamingTimerHandler(void *pv)
9418{
9419 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9420 tpAniSirGlobal pMac = pInfo->pMac;
9421 tANI_U32 sessionId = pInfo->sessionId;
9422 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009423
9424 if(!pSession)
9425 {
9426 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9427 return;
9428 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009429
9430 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
9431 {
9432 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
9433 {
9434 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
9435 pSession->roamingReason = eCsrNotRoaming;
9436 }
9437 }
9438}
9439
Jeff Johnson295189b2012-06-20 16:38:30 -07009440eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
9441{
9442 eHalStatus status;
9443 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009444
9445 if(!pSession)
9446 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009447 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009448 return eHAL_STATUS_FAILURE;
9449 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009450
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009451 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -07009452 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
9453 status = palTimerStart(pMac->hHdd, pSession->hTimerRoaming, interval, eANI_BOOLEAN_FALSE);
9454
9455 return (status);
9456}
9457
Jeff Johnson295189b2012-06-20 16:38:30 -07009458eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
9459{
9460 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerRoaming));
9461}
9462
Jeff Johnson295189b2012-06-20 16:38:30 -07009463void csrRoamWaitForKeyTimeOutHandler(void *pv)
9464{
9465 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9466 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009467 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
9468
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009469 smsLog(pMac, LOGW, "WaitForKey timer expired in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009470 pMac->roam.neighborRoamInfo.neighborRoamState,
9471 pMac->roam.curSubState[pInfo->sessionId]);
9472
Jeff Johnson295189b2012-06-20 16:38:30 -07009473 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
9474 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009475#ifdef FEATURE_WLAN_LFR
9476 if (csrNeighborRoamIsHandoffInProgress(pMac))
9477 {
9478 /*
9479 * Enable heartbeat timer when hand-off is in progress
9480 * and Key Wait timer expired.
9481 */
9482 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009483 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009484 pMac->roam.configParam.HeartbeatThresh24);
9485 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
9486 pMac->roam.configParam.HeartbeatThresh24,
9487 NULL, eANI_BOOLEAN_FALSE);
9488 }
9489#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009490 smsLog(pMac, LOGW, " SME pre-auth state timeout. ");
Jeff Johnson295189b2012-06-20 16:38:30 -07009491 //Change the substate so command queue is unblocked.
9492 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, pInfo->sessionId);
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009493 if (pSession)
9494 {
9495 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
9496 {
9497 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9498 smeProcessPendingQueue(pMac);
9499 }
9500 else
9501 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009502 smsLog(pMac, LOGW, "%s: could not post link up",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009503 __func__);
9504 }
9505 }
9506 else
9507 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009508 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009509 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009510 }
9511
9512}
9513
Jeff Johnson295189b2012-06-20 16:38:30 -07009514eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
9515{
9516 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009517#ifdef FEATURE_WLAN_LFR
9518 if (csrNeighborRoamIsHandoffInProgress(pMac))
9519 {
9520 /* Disable heartbeat timer when hand-off is in progress */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009521 smsLog(pMac, LOG2, "%s: disabling HB timer in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009522 __func__,
9523 pMac->roam.neighborRoamInfo.neighborRoamState,
9524 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
9525 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
9526 }
9527#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009528 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -07009529 status = palTimerStart(pMac->hHdd, pMac->roam.hTimerWaitForKey, interval, eANI_BOOLEAN_FALSE);
9530
9531 return (status);
9532}
9533
Jeff Johnson295189b2012-06-20 16:38:30 -07009534eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
9535{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009536 smsLog(pMac, LOG2, "WaitForKey timer stopped in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009537 pMac->roam.neighborRoamInfo.neighborRoamState,
9538 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
9539#ifdef FEATURE_WLAN_LFR
9540 if (csrNeighborRoamIsHandoffInProgress(pMac))
9541 {
9542 /*
9543 * Enable heartbeat timer when hand-off is in progress
9544 * and Key Wait timer got stopped for some reason
9545 */
9546 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009547 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009548 pMac->roam.configParam.HeartbeatThresh24);
9549 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
9550 pMac->roam.configParam.HeartbeatThresh24,
9551 NULL, eANI_BOOLEAN_FALSE);
9552 }
9553#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009554 return (palTimerStop(pMac->hHdd, pMac->roam.hTimerWaitForKey));
9555}
9556
Jeff Johnson295189b2012-06-20 16:38:30 -07009557void csrRoamIbssJoinTimerHandler(void *pv)
9558{
9559 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9560 tpAniSirGlobal pMac = pInfo->pMac;
9561 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE;
9562 tANI_U32 sessionId = pInfo->sessionId;
9563 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009564
9565 if(!pSession)
9566 {
9567 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9568 return;
9569 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009570
9571 pSession->ibss_join_pending = FALSE;
9572 // JEZ100225: As of main/latest "tip", we are no longer doing this. Check on this.
9573 //csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
9574 // Send an IBSS stop request to PE
9575 csrRoamDisconnectInternal(pMac, sessionId, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07009576}
Jeff Johnson295189b2012-06-20 16:38:30 -07009577eHalStatus csrRoamStartIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
9578{
9579 eHalStatus status;
9580 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009581
9582 if(!pSession)
9583 {
9584 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9585 return eHAL_STATUS_FAILURE;
9586 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009587
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009588 smsLog(pMac, LOG1, " csrRoamStartIbssJoinTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -07009589 pSession->ibssJoinTimerInfo.sessionId = (tANI_U8)sessionId;
9590 status = palTimerStart(pMac->hHdd, pSession->hTimerIbssJoining, interval, eANI_BOOLEAN_FALSE);
9591
9592 return (status);
9593}
Jeff Johnson295189b2012-06-20 16:38:30 -07009594eHalStatus csrRoamStopIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
9595{
9596 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerIbssJoining));
9597}
Jeff Johnson295189b2012-06-20 16:38:30 -07009598void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
9599 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
9600{
9601 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
9602 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009603 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9604 /* To silence the KW tool Null chaeck is added */
9605 if(!pSession)
9606 {
9607 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9608 return;
9609 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009610
9611 if(pCommand)
9612 {
9613 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009614 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009615 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009616 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
9617 {
9618 //if success, force roaming completion
9619 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
9620 }
9621 else
9622 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009623 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009624 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07009625 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
9626 }
9627}
9628
Jeff Johnson295189b2012-06-20 16:38:30 -07009629eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
9630{
9631 eHalStatus status = eHAL_STATUS_SUCCESS;
9632 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
9633 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
9634 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
9635 tCsrRoamInfo *pRoamInfo = NULL;
9636 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009637 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -07009638 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009639 /* To silence the KW tool Null chaeck is added */
9640 if(!pSession)
9641 {
9642 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9643 return eHAL_STATUS_FAILURE;
9644 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009645 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009646 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07009647 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
9648 if ( eWNI_SME_DISASSOC_IND == type )
9649 {
9650 result = eCSR_ROAM_RESULT_DISASSOC_IND;
9651 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
9652 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -07009653 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07009654 }
9655 else if ( eWNI_SME_DEAUTH_IND == type )
9656 {
9657 result = eCSR_ROAM_RESULT_DEAUTH_IND;
9658 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
9659 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -08009660 /* Convert into proper reason code */
9661 pSession->joinFailStatusCode.reasonCode =
9662 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
Agarwal Ashish838f1f32013-03-11 20:54:52 +05309663 0 : pDeauthIndMsg->reasonCode;
9664 /* cfg layer expects 0 as reason code if
9665 the driver dosent know the reason code
9666 eSIR_BEACON_MISSED is defined as locally */
Jeff Johnson295189b2012-06-20 16:38:30 -07009667 }
9668 else
9669 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009670 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009671 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -07009672 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07009673 }
9674
9675 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -07009676 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07009677 {
9678 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
9679 }
9680
9681 if ( eWNI_SME_DISASSOC_IND == type )
9682 {
9683 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
9684 }
9685 else if ( eWNI_SME_DEAUTH_IND == type )
9686 {
9687 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
9688 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009689 if(!HAL_STATUS_SUCCESS(status))
9690 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009691 //If fail to send confirmation to PE, not to trigger roaming
9692 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009693 }
9694
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009695 //prepare to tell HDD to disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -07009696 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9697 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
9698 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07009699 if( eWNI_SME_DISASSOC_IND == type)
9700 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009701 //staMacAddr
9702 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDisassocIndMsg->peerMacAddr, sizeof(tSirMacAddr));
9703 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
9704 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009705 else if( eWNI_SME_DEAUTH_IND == type )
9706 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009707 //staMacAddr
9708 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDeauthIndMsg->peerMacAddr, sizeof(tSirMacAddr));
9709 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
9710 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009711 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009712
9713 /* See if we can possibly roam. If so, start the roaming process and notify HDD
9714 that we are roaming. But if we cannot possibly roam, or if we are unable to
9715 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -07009716 if(fToRoam)
9717 {
9718 //Only remove the connected BSS in infrastructure mode
9719 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
9720 //Not to do anying for lostlink with WDS
9721 if( pMac->roam.configParam.nRoamingTime )
9722 {
9723 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
9724 ( eWNI_SME_DEAUTH_IND == type ) ?
9725 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
9726 {
9727 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9728 //For IBSS, we need to give some more info to HDD
9729 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
9730 {
9731 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9732 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
9733 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
9734 }
9735 else
9736 {
9737 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
9738 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009739 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009740 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
9741 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
9742 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
9743 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
9744 }
9745 else
9746 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009747 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07009748 fToRoam = eANI_BOOLEAN_FALSE;
9749 }
9750 }
9751 else
9752 {
9753 //We are told not to roam, indicate lostlink
9754 fToRoam = eANI_BOOLEAN_FALSE;
9755 }
9756 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009757 if(!fToRoam)
9758 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -07009759 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009760 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009761 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009762 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
9763 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
9764 * csrRoamCheckForLinkStatusChange API.
9765 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009766 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
9767 }
9768
9769 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -07009770 Still enable idle scan for polling in case concurrent sessions are running */
9771 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
9772 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009773 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07009774 }
9775 }
9776
9777 return (status);
9778}
9779
Jeff Johnson295189b2012-06-20 16:38:30 -07009780eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
9781{
9782 eHalStatus status = eHAL_STATUS_SUCCESS;
9783 tListElem *pEntry = NULL;
9784 tSmeCmd *pCommand = NULL;
9785 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009786
9787 if(!pSession)
9788 {
9789 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9790 return eHAL_STATUS_FAILURE;
9791 }
9792
Jeff Johnson295189b2012-06-20 16:38:30 -07009793 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009794 //Only remove the connected BSS in infrastructure mode
9795 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
9796 if(pMac->roam.configParam.nRoamingTime)
9797 {
9798 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
9799 {
9800 //before starting the lost link logic release the roam command for handoff
9801 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
9802 if(pEntry)
9803 {
9804 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
9805 }
9806 if(pCommand)
9807 {
9808 if (( eSmeCommandRoam == pCommand->command ) &&
9809 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
9810 {
9811 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9812 {
9813 csrReleaseCommandRoam( pMac, pCommand );
9814 }
9815 }
9816 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009817 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -07009818 }
9819 }
9820 else
9821 {
9822 //We are told not to roam, indicate lostlink
9823 status = eHAL_STATUS_FAILURE;
9824 }
9825
9826 return (status);
9827}
Jeff Johnson295189b2012-06-20 16:38:30 -07009828void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
9829{
9830 tListElem *pEntry;
9831 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07009832 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9833 if ( pEntry )
9834 {
9835 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9836 if ( eSmeCommandWmStatusChange == pCommand->command )
9837 {
9838 // Nothing to process in a Lost Link completion.... It just kicks off a
9839 // roaming sequence.
9840 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9841 {
9842 csrReleaseCommandWmStatusChange( pMac, pCommand );
9843 }
9844 else
9845 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009846 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -07009847 }
9848
9849 }
9850 else
9851 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009852 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009853 }
9854 }
9855 else
9856 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009857 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009858 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009859 smeProcessPendingQueue( pMac );
9860}
9861
Jeff Johnson295189b2012-06-20 16:38:30 -07009862void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
9863{
9864 eHalStatus status = eHAL_STATUS_FAILURE;
9865 tSirSmeRsp *pSirSmeMsg;
9866 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009867
9868 if(!pSession)
9869 {
9870 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
9871 return;
9872 }
9873
Jeff Johnson295189b2012-06-20 16:38:30 -07009874 switch ( pCommand->u.wmStatusChangeCmd.Type )
9875 {
9876 case eCsrDisassociated:
9877 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
9878 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
9879 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009880 case eCsrDeauthenticated:
9881 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
9882 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
9883 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009884 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009885 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009886 break;
9887 }
9888 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
9889 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
9890 {
9891 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
9892 {
9893 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009894 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009895 }
9896 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009897 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
9898 // command here since there is nothing else to do.
9899 csrRoamWmStatusChangeComplete( pMac );
9900}
9901
Jeff Johnson295189b2012-06-20 16:38:30 -07009902//This function returns band and mode information.
9903//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
9904//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -07009905static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
9906 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -07009907{
Jeff Johnson295189b2012-06-20 16:38:30 -07009908 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
9909 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
9910 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07009911 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07009912
Jeff Johnson295189b2012-06-20 16:38:30 -07009913 //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 -07009914 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
9915 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
9916 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
9917 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009918 {
9919 switch( pMac->roam.configParam.uCfgDot11Mode )
9920 {
9921 case eCSR_CFG_DOT11_MODE_11A:
9922 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
9923 eBand = eCSR_BAND_5G;
9924 break;
9925 case eCSR_CFG_DOT11_MODE_11B:
9926 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
9927 eBand = eCSR_BAND_24;
9928 break;
9929 case eCSR_CFG_DOT11_MODE_11G:
9930 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
9931 eBand = eCSR_BAND_24;
9932 break;
9933 case eCSR_CFG_DOT11_MODE_11N:
9934 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
9935 eBand = eCSR_BAND_24;
9936 break;
9937 //case eCSR_CFG_DOT11_MODE_BEST:
9938 // cfgDot11Mode = eCSR_CFG_DOT11_MODE_BEST;
9939 // eBand = eCSR_BAND_24;
9940 // break;
9941 default:
9942 // Global dot11 Mode setting is 11a/b/g.
9943 // use the channel number to determine the Mode setting.
9944 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
9945 {
9946 eBand = pMac->roam.configParam.eBand;
9947 if(eCSR_BAND_24 == eBand)
9948 {
9949 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
9950 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
9951 }
9952 else
9953 {
9954 //prefer 5GHz
9955 eBand = eCSR_BAND_5G;
9956 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
9957 }
9958 }
9959 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
9960 {
9961 // channel is a 2.4GHz channel. Set mode to 11g.
9962 //
9963 // !!LAC - WiFi tests require IBSS networks to start in 11b mode without any change to the
9964 // default parameter settings on the adapter. We use ACU to start an IBSS through creation
9965 // of a startIBSS profile. this startIBSS profile has Auto MACProtocol and the
9966 // adapter property setting for dot11Mode is also AUTO. So in this case, let's start
9967 // the IBSS network in 11b mode instead of 11g mode.
9968 //
9969 // so this is for Auto=profile->MacProtocol && Auto=Global.dot11Mode && profile->channel is < 14,
9970 // then start the IBSS in b mode.
9971 //
9972 // Note: we used to have this start as an 11g IBSS for best performance... now to specify that
9973 // the user will have to set the do11Mode in the property page to 11g to force it.
9974 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
9975 eBand = eCSR_BAND_24;
9976 }
9977 else
9978 {
9979 // else, it's a 5.0GHz channel. Set mode to 11a.
9980 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
9981 eBand = eCSR_BAND_5G;
9982 }
9983 break;
9984 }//switch
9985 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
9986 else
9987 {
9988 //dot11 mode is set, lets pick the band
9989 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
9990 {
9991 // channel is Auto also.
9992 eBand = pMac->roam.configParam.eBand;
9993 if(eCSR_BAND_ALL == eBand)
9994 {
9995 //prefer 5GHz
9996 eBand = eCSR_BAND_5G;
9997 }
9998 }
9999 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10000 {
10001 eBand = eCSR_BAND_24;
10002 }
10003 else
10004 {
10005 eBand = eCSR_BAND_5G;
10006 }
10007 }
10008 if(pBand)
10009 {
10010 *pBand = eBand;
10011 }
10012
10013 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010014 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070010015 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10016 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010017
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080010018 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
10019 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 -070010020 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010021#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010022 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010023#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010024 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
10025 {
10026 //We cannot do 11n here
10027 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10028 {
10029 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10030 }
10031 else
10032 {
10033 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10034 }
10035 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010036 return( cfgDot11Mode );
10037}
10038
Jeff Johnson295189b2012-06-20 16:38:30 -070010039eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
10040{
10041 eHalStatus status;
10042 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010043
10044 if(!pSession)
10045 {
10046 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10047 return eHAL_STATUS_FAILURE;
10048 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010049
10050#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10051 {
10052 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010053 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10054 if(pIbssLog)
10055 {
10056 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
10057 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10058 }
10059 }
10060#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010061 pSession->ibss_join_pending = FALSE;
10062 csrRoamStopIbssJoinTimer(pMac, sessionId );
10063 // Set the roaming substate to 'stop Bss request'...
10064 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
10065
10066 // attempt to stop the Bss (reason code is ignored...)
10067 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080010068 if(!HAL_STATUS_SUCCESS(status))
10069 {
10070 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
10071 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010072 return (status);
10073}
10074
Jeff Johnson295189b2012-06-20 16:38:30 -070010075//pNumChan is a caller allocated space with the sizeof pChannels
10076eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
10077{
10078
10079 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
10080 (tANI_U8 *)pChannels,
10081 pNumChan));
10082}
10083
Kiran4a17ebe2013-01-31 10:43:43 -080010084tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
10085{
10086 tANI_U32 cfgLength = 0;
10087 tANI_U16 cfgId = 0;
10088 tPowerdBm maxTxPwr = 0;
10089 tANI_U8 *pCountryInfo = NULL;
10090 eHalStatus status;
10091 tANI_U8 count = 0;
10092 tANI_U8 firstChannel;
10093 tANI_U8 maxChannels;
10094
10095 if (CSR_IS_CHANNEL_5GHZ(channel))
10096 {
10097 cfgId = WNI_CFG_MAX_TX_POWER_5;
10098 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
10099 }
10100 else if (CSR_IS_CHANNEL_24GHZ(channel))
10101 {
10102 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
10103 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
10104 }
10105 else
10106 return maxTxPwr;
10107
10108 status = palAllocateMemory(pMac->hHdd, (void **)&pCountryInfo, cfgLength);
10109 if (status != eHAL_STATUS_SUCCESS)
10110 {
10111 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10112 FL("%s: palAllocateMemory() failed, status = %d"),
10113 __FUNCTION__, status);
10114 goto error;
10115 }
10116 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
10117 if (status != eHAL_STATUS_SUCCESS)
10118 {
10119 goto error;
10120 }
10121 /* Identify the channel and maxtxpower */
10122 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
10123 {
10124 firstChannel = pCountryInfo[count++];
10125 maxChannels = pCountryInfo[count++];
10126 maxTxPwr = pCountryInfo[count++];
10127
10128 if ((channel >= firstChannel) &&
10129 (channel < (firstChannel + maxChannels)))
10130 {
10131 break;
10132 }
10133 }
10134
10135error:
10136 if (NULL != pCountryInfo)
10137 palFreeMemory(pMac->hHdd, pCountryInfo);
10138
10139 return maxTxPwr;
10140}
10141
10142
Jeff Johnson295189b2012-06-20 16:38:30 -070010143tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
10144{
10145 tANI_BOOLEAN fValid = FALSE;
10146 tANI_U32 idxValidChannels;
10147 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10148
10149 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
10150 {
10151 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
10152 {
10153 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
10154 {
10155 fValid = TRUE;
10156 break;
10157 }
10158 }
10159 }
10160 pMac->roam.numValidChannels = len;
10161 return fValid;
10162}
10163
Jeff Johnson295189b2012-06-20 16:38:30 -070010164tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
10165{
10166 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
10167 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010168 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
10169 {
10170 if(channel == pMac->scan.base40MHzChannels.channelList[i])
10171 {
10172 fValid = eANI_BOOLEAN_TRUE;
10173 break;
10174 }
10175 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010176 return (fValid);
10177}
10178
Jeff Johnson295189b2012-06-20 16:38:30 -070010179//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070010180 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070010181{
Jeff Johnsone7245742012-09-05 17:12:55 -070010182 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010183 tANI_U8 centerChn;
10184 tANI_U32 ChannelBondingMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010185 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
10186 {
10187 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
10188 }
10189 else
10190 {
10191 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
10192 }
10193 //Figure what the other side's CB mode
10194 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
10195 {
10196 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
10197 {
10198 if(pIes->HTInfo.present)
10199 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010200 /* This is called during INFRA STA/CLIENT and should use the merged value of
10201 * supported channel width and recommended tx width as per standard
10202 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010203 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070010204 pIes->HTCaps.supportedChannelWidthSet,
10205 pIes->HTInfo.recommendedTxWidthSet,
10206 pIes->HTInfo.secondaryChannelOffset);
10207
10208 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
10209 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010210 else
Jeff Johnsone7245742012-09-05 17:12:55 -070010211 eRet = PHY_SINGLE_CHANNEL_CENTERED;
10212 switch (eRet) {
10213 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
10214 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
10215 break;
10216 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
10217 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
10218 break;
10219 case PHY_SINGLE_CHANNEL_CENTERED:
10220 default:
10221 centerChn = primaryChn;
10222 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010223 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010224 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070010225 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010226 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Jeff Johnsone7245742012-09-05 17:12:55 -070010227 //eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010228 }
10229 }
10230 }
10231 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010232 return eRet;
10233}
Jeff Johnson295189b2012-06-20 16:38:30 -070010234tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
10235{
10236 tANI_BOOLEAN fFound = FALSE;
10237 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010238 for( idx = 0; idx < pCipherList->numEntries; idx++ )
10239 {
10240 if( pCipherList->encryptionType[idx] == encryptionType )
10241 {
10242 fFound = TRUE;
10243 break;
10244 }
10245 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010246 return fFound;
10247}
Jeff Johnson295189b2012-06-20 16:38:30 -070010248tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
10249{
10250 tANI_BOOLEAN fFound = FALSE;
10251 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010252 for( idx = 0; idx < pAuthList->numEntries; idx++ )
10253 {
10254 if( pAuthList->authType[idx] == authType )
10255 {
10256 fFound = TRUE;
10257 break;
10258 }
10259 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010260 return fFound;
10261}
Jeff Johnson295189b2012-06-20 16:38:30 -070010262tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
10263{
10264 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
10265 tCsrScanResultFilter *pScanFilter = NULL;
10266 eHalStatus status = eHAL_STATUS_SUCCESS;
10267
10268 if(pProfile1 && pProfile2)
10269 {
10270 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
10271 if(HAL_STATUS_SUCCESS(status))
10272 {
10273 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
10274 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
10275 if(HAL_STATUS_SUCCESS(status))
10276 {
10277 fCheck = eANI_BOOLEAN_FALSE;
10278 do
10279 {
10280 tANI_U32 i;
10281 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
10282 {
10283 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
10284 pScanFilter->SSIDs.SSIDList[i].SSID.length,
10285 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
10286 if ( fCheck ) break;
10287 }
10288 if(!fCheck)
10289 {
10290 break;
10291 }
10292 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
10293 || pProfile2->BSSType != pProfile1->BSSType
10294 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
10295 )
10296 {
10297 fCheck = eANI_BOOLEAN_FALSE;
10298 break;
10299 }
10300#ifdef WLAN_FEATURE_VOWIFI_11R
10301 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
10302 {
10303 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
10304 {
10305 fCheck = eANI_BOOLEAN_FALSE;
10306 break;
10307 }
10308 }
10309#endif
10310 //Match found
10311 fCheck = eANI_BOOLEAN_TRUE;
10312 }while(0);
10313 csrFreeScanFilter(pMac, pScanFilter);
10314 }
10315 palFreeMemory(pMac->hHdd, pScanFilter);
10316 }
10317 }
10318
10319 return (fCheck);
10320}
10321
Jeff Johnson295189b2012-06-20 16:38:30 -070010322tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
10323{
10324 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
10325 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010326 do
10327 {
10328 //Only check for static WEP
10329 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
10330 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
10331 {
10332 fCheck = eANI_BOOLEAN_TRUE;
10333 break;
10334 }
10335 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
10336 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
10337 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
10338 {
10339 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
10340 if(!palEqualMemory(pMac->hHdd, &pConnProfile->Keys.KeyMaterial[i],
10341 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
10342 {
10343 break;
10344 }
10345 }
10346 if( i == CSR_MAX_NUM_KEY)
10347 {
10348 fCheck = eANI_BOOLEAN_TRUE;
10349 }
10350 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010351 return (fCheck);
10352}
10353
Jeff Johnson295189b2012-06-20 16:38:30 -070010354//IBSS
10355
Jeff Johnson295189b2012-06-20 16:38:30 -070010356tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
10357{
10358 tANI_U8 channel = 0;
10359 tANI_U32 idx;
10360 tANI_U32 idxValidChannels;
10361 tANI_BOOLEAN fFound = FALSE;
10362 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10363
10364 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
10365 {
10366 channel = pMac->roam.configParam.AdHocChannel5G;
10367 if(!csrRoamIsChannelValid(pMac, channel))
10368 {
10369 channel = 0;
10370 }
10371 }
10372 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
10373 {
10374 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
10375 {
10376 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
10377 {
10378 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
10379 {
10380 fFound = TRUE;
10381 channel = csrStartIbssChannels50[ idx ];
10382 }
10383 }
10384 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010385 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
10386 if (!fFound)
10387 {
10388 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
10389 {
10390 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idx ]) ) // the max channel# in 11g is 14
10391 {
10392 channel = csrStartIbssChannels50[ idx ];
10393 break;
10394 }
10395 }
10396 }
10397 }//if
10398
10399 return( channel );
10400}
10401
Jeff Johnson295189b2012-06-20 16:38:30 -070010402tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
10403{
10404 tANI_U8 channel = 1;
10405 tANI_U32 idx;
10406 tANI_U32 idxValidChannels;
10407 tANI_BOOLEAN fFound = FALSE;
10408 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10409
10410 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
10411 {
10412 channel = pMac->roam.configParam.AdHocChannel24;
10413 if(!csrRoamIsChannelValid(pMac, channel))
10414 {
10415 channel = 0;
10416 }
10417 }
10418
10419 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
10420 {
10421 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
10422 {
10423 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
10424 {
10425 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
10426 {
10427 fFound = TRUE;
10428 channel = csrStartIbssChannels24[ idx ];
10429 }
10430 }
10431 }
10432 }
10433
10434 return( channel );
10435}
10436
Jeff Johnson295189b2012-06-20 16:38:30 -070010437static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10438 tCsrRoamStartBssParams *pParam )
10439{
10440 eCsrCfgDot11Mode cfgDot11Mode;
10441 eCsrBand eBand;
10442 tANI_U8 channel = 0;
10443 tSirNwType nwType;
10444 tANI_U8 operationChannel = 0;
10445
10446 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
10447 {
10448 operationChannel = pProfile->ChannelInfo.ChannelList[0];
10449 }
10450
Jeff Johnson295189b2012-06-20 16:38:30 -070010451 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070010452
Jeff Johnson295189b2012-06-20 16:38:30 -070010453 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
10454 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
10455 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
10456 )
10457 {
10458 /* This should never happen */
10459 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010460 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070010461 pProfile->csrPersona);
10462 VOS_ASSERT(0);
10463 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010464 switch( cfgDot11Mode )
10465 {
10466 case eCSR_CFG_DOT11_MODE_11G:
10467 nwType = eSIR_11G_NW_TYPE;
10468 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010469 case eCSR_CFG_DOT11_MODE_11B:
10470 nwType = eSIR_11B_NW_TYPE;
10471 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010472 case eCSR_CFG_DOT11_MODE_11A:
10473 nwType = eSIR_11A_NW_TYPE;
10474 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010475 default:
10476 case eCSR_CFG_DOT11_MODE_11N:
10477 case eCSR_CFG_DOT11_MODE_TAURUS:
10478 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
10479 if(eCSR_BAND_24 == eBand)
10480 {
10481 nwType = eSIR_11G_NW_TYPE;
10482 }
10483 else
10484 {
10485 nwType = eSIR_11A_NW_TYPE;
10486 }
10487 break;
10488 }
10489
10490 pParam->extendedRateSet.numRates = 0;
10491
10492 switch ( nwType )
10493 {
10494 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010495 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070010496 case eSIR_11A_NW_TYPE:
10497
10498 pParam->operationalRateSet.numRates = 8;
10499
10500 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
10501 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
10502 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
10503 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
10504 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
10505 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
10506 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
10507 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
10508
10509 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10510 {
10511 channel = csrRoamGetIbssStartChannelNumber50( pMac );
10512 if( 0 == channel &&
10513 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
10514 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
10515 )
10516 {
10517 //We could not find a 5G channel by auto pick, let's try 2.4G channels
10518 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
10519 nwType = eSIR_11B_NW_TYPE;
10520 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10521 pParam->operationalRateSet.numRates = 4;
10522 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10523 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10524 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10525 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
10526 }
10527 }
10528 else
10529 {
10530 channel = operationChannel;
10531 }
10532 break;
10533
10534 case eSIR_11B_NW_TYPE:
10535 pParam->operationalRateSet.numRates = 4;
10536 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10537 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10538 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10539 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070010540 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10541 {
10542 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10543 }
10544 else
10545 {
10546 channel = operationChannel;
10547 }
10548
10549 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010550 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070010551 /* For P2P Client and P2P GO, disable 11b rates */
10552 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
10553 (pProfile->csrPersona == VOS_P2P_GO_MODE)
10554 )
10555 {
10556 pParam->operationalRateSet.numRates = 8;
10557
10558 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
10559 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
10560 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
10561 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
10562 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
10563 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
10564 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
10565 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
10566 }
10567 else
Jeff Johnson295189b2012-06-20 16:38:30 -070010568 {
10569 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070010570 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10571 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10572 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10573 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
10574
10575 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070010576 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
10577 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
10578 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
10579 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
10580 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
10581 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
10582 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
10583 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
10584 }
10585
10586 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10587 {
10588 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10589 }
10590 else
10591 {
10592 channel = operationChannel;
10593 }
10594
10595 break;
10596 }
10597 pParam->operationChn = channel;
10598 pParam->sirNwType = nwType;
10599}
10600
Jeff Johnson295189b2012-06-20 16:38:30 -070010601static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
10602 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
10603{
10604
10605 if( pParam )
10606 {
10607 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070010608 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010609 pParam->operationChn = pBssDesc->channelId;
10610 palCopyMemory( pMac->hHdd, &pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid) );
10611
10612 if( pIes )
10613 {
10614 if(pIes->SuppRates.present)
10615 {
10616 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
10617 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
10618 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010619 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 -070010620 pIes->SuppRates.num_rates);
10621 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
10622 }
10623 palCopyMemory(pMac->hHdd, pParam->operationalRateSet.rate, pIes->SuppRates.rates,
10624 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
10625 }
10626 if( pIes->SSID.present )
10627 {
10628 pParam->ssId.length = pIes->SSID.num_ssid;
10629 palCopyMemory(pMac->hHdd, pParam->ssId.ssId, pIes->SSID.ssid, pParam->ssId.length);
10630 }
10631 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070010632 }
10633 else
10634 {
10635 pParam->ssId.length = 0;
10636 pParam->operationalRateSet.numRates = 0;
10637 }
10638 }
10639}
10640
Jeff Johnson295189b2012-06-20 16:38:30 -070010641static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
10642{
10643 tANI_U8 MaxRate = 0;
10644 tANI_U32 i;
10645 tANI_U8 *pRate;
10646
10647 pRate = pSirRateSet->rate;
10648 for ( i = 0; i < pSirRateSet->numRates; i++ )
10649 {
10650 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
10651 }
10652
10653 // Save the max rate in the connected state information...
10654
10655 // modify LastRates variable as well
10656
10657 return;
10658}
10659
Jeff Johnson295189b2012-06-20 16:38:30 -070010660//this function finds a valid secondary channel for channel bonding with "channel".
10661//Param: channel -- primary channel, caller must validate it
10662// cbChoice -- CB directory
10663//Return: if 0, no secondary channel is found. Otherwise a valid secondary channel.
10664static tANI_U8 csrRoamGetSecondaryChannel(tpAniSirGlobal pMac, tANI_U8 channel, eCsrCBChoice cbChoice)
10665{
10666 tANI_U8 chnUp = 0, chnDown = 0, chnRet = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010667 switch (cbChoice)
10668 {
10669 case eCSR_CB_OFF:
10670 chnUp = 0;
10671 chnDown = 0;
10672 break;
10673 case eCSR_CB_DOWN:
10674 chnUp = 0;
10675 chnDown = channel - CSR_CB_CHANNEL_GAP;
10676 break;
10677 case eCSR_CB_UP:
10678 chnUp = channel + CSR_CB_CHANNEL_GAP;
10679 chnDown = 0;
10680 break;
10681 case eCSR_CB_AUTO:
10682 //consider every other value means auto
10683 default:
10684 chnUp = channel + CSR_CB_CHANNEL_GAP;
10685 chnDown = channel - CSR_CB_CHANNEL_GAP;
10686 break;
10687 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010688 //if CB_UP or auto, try channel up first
10689 if(chnUp && CSR_IS_SAME_BAND_CHANNELS(chnUp, channel) && csrRoamIsChannelValid(pMac, chnUp))
10690 {
10691 //found a valid up channel for channel bonding
10692 //check whether the center channel is valid
10693 if(csrRoamIsValid40MhzChannel(pMac, channel + CSR_CB_CENTER_CHANNEL_OFFSET))
10694 {
10695 chnRet = chnUp;
10696 }
10697 }
10698 if(chnRet == 0 && chnDown && CSR_IS_SAME_BAND_CHANNELS(chnDown, channel) && csrRoamIsChannelValid(pMac, chnDown))
10699 {
10700 //found a valid down channel for channel bonding
10701 if(csrRoamIsValid40MhzChannel(pMac, channel - CSR_CB_CENTER_CHANNEL_OFFSET))
10702 {
10703 chnRet = chnDown;
10704 }
10705 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010706 return chnRet;
10707}
10708
Jeff Johnson295189b2012-06-20 16:38:30 -070010709eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
10710 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
10711{
10712 eHalStatus status = eHAL_STATUS_SUCCESS;
10713 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010714 // Set the roaming substate to 'Start BSS attempt'...
10715 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010716#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10717 //Need to figure out whether we need to log WDS???
10718 if( CSR_IS_IBSS( pProfile ) )
10719 {
10720 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010721 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10722 if(pIbssLog)
10723 {
10724 if(pBssDesc)
10725 {
10726 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
10727 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pBssDesc->bssId, 6);
10728 }
10729 else
10730 {
10731 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
10732 }
10733 palCopyMemory(pMac->hHdd, pIbssLog->ssid, pParam->ssId.ssId,
10734 pParam->ssId.length);
10735 if(pProfile->ChannelInfo.numOfChannels == 0)
10736 {
10737 pIbssLog->channelSetting = AUTO_PICK;
10738 }
10739 else
10740 {
10741 pIbssLog->channelSetting = SPECIFIED;
10742 }
10743 pIbssLog->operatingChannel = pParam->operationChn;
10744 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10745 }
10746 }
10747#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
10748 //Put RSN information in for Starting BSS
10749 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
10750 pParam->pRSNIE = pProfile->pRSNReqIE;
10751
Jeff Johnson295189b2012-06-20 16:38:30 -070010752 pParam->privacy = pProfile->privacy;
10753 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
10754 pParam->authType = pProfile->csr80211AuthType;
10755 pParam->beaconInterval = pProfile->beaconInterval;
10756 pParam->dtimPeriod = pProfile->dtimPeriod;
10757 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
10758 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
10759 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
10760 {
10761 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
10762 {
10763 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
10764 }
10765 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010766 pParam->protEnabled = pProfile->protEnabled;
10767 pParam->obssProtEnabled = pProfile->obssProtEnabled;
10768 pParam->ht_protection = pProfile->cfg_protection;
10769 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080010770
Jeff Johnson295189b2012-06-20 16:38:30 -070010771 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
10772 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070010773 pParam->bssPersona = pProfile->csrPersona;
10774 // When starting an IBSS, start on the channel from the Profile.
10775 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070010776 return (status);
10777}
10778
Jeff Johnson295189b2012-06-20 16:38:30 -070010779static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070010780 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070010781{
10782 tANI_U8 Channel, SecondChn;
Jeff Johnsone7245742012-09-05 17:12:55 -070010783 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010784 eCsrCBChoice cbChoice;
10785 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010786
10787 if(!pSession)
10788 {
10789 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10790 return;
10791 }
10792
Jeff Johnson295189b2012-06-20 16:38:30 -070010793 if( pBssDesc )
10794 {
10795 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
10796 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
10797 //The following code has to be do after that.
10798 //For WDS station, use selfMac as the self BSSID
10799 if( CSR_IS_WDS_STA( pProfile ) )
10800 {
10801 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, &pSession->selfMacAddr, sizeof(tCsrBssid));
10802 }
10803 }
10804 else
10805 {
10806 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070010807 //Use the first SSID
10808 if(pProfile->SSIDs.numOfSSIDs)
10809 {
10810 palCopyMemory(pMac->hHdd, &pSession->bssParams.ssId, pProfile->SSIDs.SSIDList, sizeof(tSirMacSSid));
10811 }
10812 //For WDS station, use selfMac as the self BSSID
10813 if( CSR_IS_WDS_STA( pProfile ) )
10814 {
10815 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, &pSession->selfMacAddr, sizeof(tCsrBssid));
10816 }
10817 //Use the first BSSID
10818 else if( pProfile->BSSIDs.numOfBSSIDs )
10819 {
10820 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, pProfile->BSSIDs.bssid, sizeof(tCsrBssid));
10821 }
10822 else
10823 {
10824 palZeroMemory( pMac->hHdd, &pSession->bssParams.bssid, sizeof(tCsrBssid) );
10825 }
10826 }
10827 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070010828 //Set operating channel in pProfile which will be used
10829 //in csrRoamSetBssConfigCfg() to determine channel bonding
10830 //mode and will be configured in CFG later
10831 pProfile->operationChannel = Channel;
10832
10833 if(Channel == 0)
10834 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010835 smsLog(pMac, LOGW, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070010836 }
10837 else
10838 {
10839
10840 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Jeff Johnsone7245742012-09-05 17:12:55 -070010841 if (CSR_IS_INFRA_AP(pProfile))
10842 {
10843 if(CSR_IS_CHANNEL_24GHZ(Channel))
10844 {
10845 cbMode = pMac->roam.configParam.channelBondingMode24GHz;
10846 }
10847 else
10848 {
10849 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
10850 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010851 smsLog(pMac, LOG1, "##softap cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070010852 pBssConfig->cbMode = cbMode;
10853 pSession->bssParams.cbMode = cbMode;
10854 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010855
10856 if( CSR_IS_START_IBSS( pProfile ) )
10857 {
10858 //TBH: channel bonding is not supported for Libra
10859 if( pProfile->ChannelInfo.ChannelList && eCSR_OPERATING_CHANNEL_AUTO != pProfile->ChannelInfo.ChannelList[0] )
10860 {
10861 Channel = pProfile->ChannelInfo.ChannelList[0];
10862 cbChoice = pProfile->CBMode;
10863 }
10864 else {
10865 cbChoice = pMac->roam.configParam.cbChoice;
10866 }
10867 pSession->bssParams.operationChn = Channel;
10868 //make sure channel is valid
10869 if(!csrRoamIsChannelValid(pMac, Channel))
10870 {
10871 //set Channel to 0 to let lim know this is invalid
10872 //We still send this request down to lim even though we know the channel is wrong because
10873 //lim will response with error and hdd's eWNI_SME_START_BSS_RSP handler will roam other profile (if any)
10874 Channel = 0;
10875 pSession->bssParams.operationChn = 0;
10876 }
10877 else {
10878 tANI_U32 ChannelBondingMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010879 if(CSR_IS_CHANNEL_24GHZ(Channel))
10880 {
10881 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
10882 }
10883 else
10884 {
10885 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
10886 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010887 //now we have a valid channel
10888 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
10889 {
10890 //let's pick a secondard channel
10891 SecondChn = csrRoamGetSecondaryChannel(pMac, Channel, cbChoice);
Jeff Johnson295189b2012-06-20 16:38:30 -070010892 if(SecondChn > Channel)
10893 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010894 cbMode = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010895 }
10896 else if(SecondChn && SecondChn < Channel)
10897 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010898 cbMode = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010899 }
10900 else
10901 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010902 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010903 }
10904 pSession->bssParams.cbMode = cbMode;
10905 }
10906 else
10907 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010908 pSession->bssParams.cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010909 }
10910 }
10911 }
10912 }
10913}
10914
Jeff Johnson295189b2012-06-20 16:38:30 -070010915static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
10916 tANI_BOOLEAN *pfSameIbss )
10917{
10918 eHalStatus status = eHAL_STATUS_SUCCESS;
10919 tANI_BOOLEAN fSameIbss = FALSE;
10920
10921 if ( csrIsConnStateIbss( pMac, sessionId ) )
10922 {
10923 // Check if any profile parameter has changed ? If any profile parameter
10924 // has changed then stop old BSS and start a new one with new parameters
10925 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
10926 {
10927 fSameIbss = TRUE;
10928 }
10929 else
10930 {
10931 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
10932 }
10933 }
10934 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
10935 {
10936 // Disassociate from the connected Infrastructure network...
10937 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
10938 }
10939 else
10940 {
10941 tBssConfigParam *pBssConfig;
10942
10943 status = palAllocateMemory(pMac->hHdd, (void **)&pBssConfig, sizeof(tBssConfigParam));
10944 if(HAL_STATUS_SUCCESS(status))
10945 {
10946 palZeroMemory(pMac->hHdd, pBssConfig, sizeof(tBssConfigParam));
10947 // there is no Bss description before we start an IBSS so we need to adopt
10948 // all Bss configuration parameters from the Profile.
10949 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
10950 if(HAL_STATUS_SUCCESS(status))
10951 {
10952 //save dotMode
10953 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
10954 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070010955 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070010956 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
10957 }
10958
10959 palFreeMemory(pMac->hHdd, pBssConfig);
10960 }//Allocate memory
10961 }
10962
10963 if(pfSameIbss)
10964 {
10965 *pfSameIbss = fSameIbss;
10966 }
10967 return( status );
10968}
10969
Jeff Johnson295189b2012-06-20 16:38:30 -070010970static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
10971 tSirSmeNewBssInfo *pNewBss )
10972{
10973 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010974
10975 if(!pSession)
10976 {
10977 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10978 return;
10979 }
10980
Jeff Johnson295189b2012-06-20 16:38:30 -070010981 if( pNewBss )
10982 {
10983 // Set the operating channel.
10984 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
10985 // move the BSSId from the BSS description into the connected state information.
10986 palCopyMemory( pMac->hHdd, &pSession->connectedProfile.bssid,
10987 &(pNewBss->bssId), sizeof( tCsrBssid ) );
10988 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010989 return;
10990}
10991
Jeff Johnson295189b2012-06-20 16:38:30 -070010992#ifdef FEATURE_WLAN_WAPI
10993eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
10994 tANI_U32 numItems )
10995{
10996 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
10997 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070010998 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
10999 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011000 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011001 return status;
11002 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011003 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011004 pSession = CSR_GET_SESSION( pMac, sessionId );
11005 if(numItems <= CSR_MAX_BKID_ALLOWED)
11006 {
11007 status = eHAL_STATUS_SUCCESS;
11008 //numItems may be 0 to clear the cache
11009 pSession->NumBkidCache = (tANI_U16)numItems;
11010 if(numItems && pBKIDCache)
11011 {
11012 status = palCopyMemory( pMac->hHdd, pSession->BkidCacheInfo, pBKIDCache,
11013 sizeof(tBkidCacheInfo) * numItems );
11014 }
11015 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011016 return (status);
11017}
Jeff Johnson295189b2012-06-20 16:38:30 -070011018eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
11019 tBkidCacheInfo *pBkidCache)
11020{
11021 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11022 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011023 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11024 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011025 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011026 return status;
11027 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011028 pSession = CSR_GET_SESSION( pMac, sessionId );
11029 if(pNum && pBkidCache)
11030 {
11031 if(pSession->NumBkidCache == 0)
11032 {
11033 *pNum = 0;
11034 status = eHAL_STATUS_SUCCESS;
11035 }
11036 else if(*pNum >= pSession->NumBkidCache)
11037 {
11038 if(pSession->NumBkidCache > CSR_MAX_PMKID_ALLOWED)
11039 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011040 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 -070011041 pSession->NumBkidCache);
11042 pSession->NumBkidCache = CSR_MAX_PMKID_ALLOWED;
11043 }
11044 palCopyMemory( pMac->hHdd, pBkidCache, pSession->BkidCacheInfo,
11045 sizeof(tBkidCacheInfo) * pSession->NumBkidCache );
11046 *pNum = pSession->NumBkidCache;
11047 status = eHAL_STATUS_SUCCESS;
11048 }
11049 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011050 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070011051}
Jeff Johnson295189b2012-06-20 16:38:30 -070011052tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11053{
11054 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011055}
11056#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011057eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
11058 tPmkidCacheInfo *pPMKIDCache, tANI_U32 numItems )
11059{
11060 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11061 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011062
11063 if(!pSession)
11064 {
11065 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11066 return eHAL_STATUS_FAILURE;
11067 }
11068
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011069 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011070 if(numItems <= CSR_MAX_PMKID_ALLOWED)
11071 {
11072#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11073 {
11074 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
11075 palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type));
11076 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
11077 secEvent.encryptionModeMulticast =
11078 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
11079 secEvent.encryptionModeUnicast =
11080 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
11081 palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 );
11082 secEvent.authMode =
11083 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
11084 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
11085 }
11086#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011087 status = eHAL_STATUS_SUCCESS;
11088 //numItems may be 0 to clear the cache
11089 pSession->NumPmkidCache = (tANI_U16)numItems;
11090 if(numItems && pPMKIDCache)
11091 {
11092 status = palCopyMemory( pMac->hHdd, pSession->PmkidCacheInfo, pPMKIDCache,
11093 sizeof(tPmkidCacheInfo) * numItems );
11094 }
11095 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011096 return (status);
11097}
11098
Jeff Johnson295189b2012-06-20 16:38:30 -070011099tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11100{
11101 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
11102}
11103
Jeff Johnson295189b2012-06-20 16:38:30 -070011104eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
11105{
11106 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11107 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011108
11109 if(!pSession)
11110 {
11111 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11112 return eHAL_STATUS_FAILURE;
11113 }
11114
Jeff Johnson295189b2012-06-20 16:38:30 -070011115 if(pNum && pPmkidCache)
11116 {
11117 if(pSession->NumPmkidCache == 0)
11118 {
11119 *pNum = 0;
11120 status = eHAL_STATUS_SUCCESS;
11121 }
11122 else if(*pNum >= pSession->NumPmkidCache)
11123 {
11124 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
11125 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011126 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 -070011127 pSession->NumPmkidCache);
11128 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
11129 }
11130 palCopyMemory( pMac->hHdd, pPmkidCache, pSession->PmkidCacheInfo,
11131 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache );
11132 *pNum = pSession->NumPmkidCache;
11133 status = eHAL_STATUS_SUCCESS;
11134 }
11135 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011136 return (status);
11137}
11138
Jeff Johnson295189b2012-06-20 16:38:30 -070011139eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11140{
11141 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11142 tANI_U32 len;
11143 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011144
11145 if(!pSession)
11146 {
11147 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11148 return eHAL_STATUS_FAILURE;
11149 }
11150
Jeff Johnson295189b2012-06-20 16:38:30 -070011151 if(pLen)
11152 {
11153 len = *pLen;
11154 *pLen = pSession->nWpaRsnReqIeLength;
11155 if(pBuf)
11156 {
11157 if(len >= pSession->nWpaRsnReqIeLength)
11158 {
11159 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWpaRsnReqIE, pSession->nWpaRsnReqIeLength);
11160 }
11161 }
11162 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011163 return (status);
11164}
11165
Jeff Johnson295189b2012-06-20 16:38:30 -070011166eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11167{
11168 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11169 tANI_U32 len;
11170 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011171
11172 if(!pSession)
11173 {
11174 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11175 return eHAL_STATUS_FAILURE;
11176 }
11177
Jeff Johnson295189b2012-06-20 16:38:30 -070011178 if(pLen)
11179 {
11180 len = *pLen;
11181 *pLen = pSession->nWpaRsnRspIeLength;
11182 if(pBuf)
11183 {
11184 if(len >= pSession->nWpaRsnRspIeLength)
11185 {
11186 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWpaRsnRspIE, pSession->nWpaRsnRspIeLength);
11187 }
11188 }
11189 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011190 return (status);
11191}
Jeff Johnson295189b2012-06-20 16:38:30 -070011192#ifdef FEATURE_WLAN_WAPI
11193eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11194{
11195 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11196 tANI_U32 len;
11197 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011198
11199 if(!pSession)
11200 {
11201 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11202 return eHAL_STATUS_FAILURE;
11203 }
11204
Jeff Johnson295189b2012-06-20 16:38:30 -070011205 if(pLen)
11206 {
11207 len = *pLen;
11208 *pLen = pSession->nWapiReqIeLength;
11209 if(pBuf)
11210 {
11211 if(len >= pSession->nWapiReqIeLength)
11212 {
11213 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWapiReqIE, pSession->nWapiReqIeLength);
11214 }
11215 }
11216 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011217 return (status);
11218}
Jeff Johnson295189b2012-06-20 16:38:30 -070011219eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11220{
11221 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11222 tANI_U32 len;
11223 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011224
11225 if(!pSession)
11226 {
11227 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11228 return eHAL_STATUS_FAILURE;
11229 }
11230
Jeff Johnson295189b2012-06-20 16:38:30 -070011231 if(pLen)
11232 {
11233 len = *pLen;
11234 *pLen = pSession->nWapiRspIeLength;
11235 if(pBuf)
11236 {
11237 if(len >= pSession->nWapiRspIeLength)
11238 {
11239 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWapiRspIE, pSession->nWapiRspIeLength);
11240 }
11241 }
11242 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011243 return (status);
11244}
11245#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011246eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
11247{
11248 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
11249 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011250
11251 if(!pSession)
11252 {
11253 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11254 return (retStatus);
11255 }
11256
Jeff Johnson295189b2012-06-20 16:38:30 -070011257 if(CSR_IS_ROAMING(pSession))
11258 {
11259 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
11260 pSession->fRoaming = eANI_BOOLEAN_FALSE;
11261 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011262 return (retStatus);
11263}
11264
Jeff Johnson295189b2012-06-20 16:38:30 -070011265//This function remove the connected BSS from te cached scan result
11266eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
11267 tCsrRoamConnectedProfile *pConnProfile)
11268{
11269 eHalStatus status = eHAL_STATUS_FAILURE;
11270 tCsrScanResultFilter *pScanFilter = NULL;
11271 tListElem *pEntry;
11272 tCsrScanResult *pResult;
11273 tDot11fBeaconIEs *pIes;
11274 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070011275 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
11276 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
11277 {
11278 do
11279 {
11280 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
11281 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
11282 if(!HAL_STATUS_SUCCESS(status)) break;
11283 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
11284 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->BSSIDs.bssid, sizeof(tCsrBssid));
11285 if(!HAL_STATUS_SUCCESS(status)) break;
11286 palCopyMemory(pMac->hHdd, pScanFilter->BSSIDs.bssid, &pConnProfile->bssid, sizeof(tCsrBssid));
11287 pScanFilter->BSSIDs.numOfBSSIDs = 1;
11288 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
11289 {
11290 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->SSIDs.SSIDList, sizeof(tCsrSSIDInfo));
11291 if(!HAL_STATUS_SUCCESS(status)) break;
11292 palCopyMemory(pMac->hHdd, &pScanFilter->SSIDs.SSIDList[0].SSID, &pConnProfile->SSID, sizeof(tSirMacSSid));
11293 }
11294 pScanFilter->authType.numEntries = 1;
11295 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
11296 pScanFilter->BSSType = pConnProfile->BSSType;
11297 pScanFilter->EncryptionType.numEntries = 1;
11298 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
11299 pScanFilter->mcEncryptionType.numEntries = 1;
11300 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
11301 //We ignore the channel for now, BSSID should be enough
11302 pScanFilter->ChannelInfo.numOfChannels = 0;
11303 //Also ignore the following fields
11304 pScanFilter->uapsd_mask = 0;
11305 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
11306 pScanFilter->countryCode[0] = 0;
11307 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011308 csrLLLock(&pMac->scan.scanResultList);
11309 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
11310 while( pEntry )
11311 {
11312 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
11313 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
11314 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
11315 pScanFilter, NULL, NULL, NULL, &pIes);
11316 //Release the IEs allocated by csrMatchBSS is needed
11317 if( !pResult->Result.pvIes )
11318 {
11319 //need to free the IEs since it is allocated by csrMatchBSS
11320 palFreeMemory(pMac->hHdd, pIes);
11321 }
11322 if(fMatch)
11323 {
11324 //We found the one
11325 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
11326 {
11327 //Free the memory
11328 csrFreeScanResultEntry( pMac, pResult );
11329 }
11330 break;
11331 }
11332 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
11333 }//while
11334 csrLLUnlock(&pMac->scan.scanResultList);
11335 }while(0);
11336 if(pScanFilter)
11337 {
11338 csrFreeScanFilter(pMac, pScanFilter);
11339 palFreeMemory(pMac->hHdd, pScanFilter);
11340 }
11341 }
11342 return (status);
11343}
11344
Jeff Johnson295189b2012-06-20 16:38:30 -070011345//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070011346eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
11347{
11348 eHalStatus status = eHAL_STATUS_SUCCESS;
11349 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011350 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
11351 {
11352 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
11353 {
11354 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
11355 {
11356 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011357 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011358 status = eHAL_STATUS_CSR_WRONG_STATE;
11359 break;
11360 }
11361 if( csrIsConnStateInfra( pMac, sessionId ) )
11362 {
11363 if( chnId &&
11364 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
11365 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011366 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011367 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
11368 status = eHAL_STATUS_CSR_WRONG_STATE;
11369 break;
11370 }
11371 }
11372 }
11373 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011374 return ( status );
11375}
11376
Jeff Johnson295189b2012-06-20 16:38:30 -070011377static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
11378{
11379 eHalStatus status = eHAL_STATUS_SUCCESS;
11380 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11381 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070011382
11383 if(!pSession)
11384 {
11385 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11386 return eHAL_STATUS_FAILURE;
11387 }
11388
Jeff Johnson295189b2012-06-20 16:38:30 -070011389 if ( csrIsConnStateIbss( pMac, sessionId ) )
11390 {
11391 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11392 }
11393 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11394 {
11395 // Disassociate from the connected Infrastructure network...
11396 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11397 }
11398 else
11399 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011400 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
11401 //Otherwise we need to add code to handle the
11402 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
11403 //send stop_bss to PE, before we can continue.
11404 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070011405 palZeroMemory(pMac->hHdd, &bssConfig, sizeof(tBssConfigParam));
11406 /* Assume HDD provide bssid in profile */
11407 palCopyMemory( pMac->hHdd, &pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0], sizeof(tCsrBssid) );
11408 // there is no Bss description before we start an WDS so we need
11409 // to adopt all Bss configuration parameters from the Profile.
11410 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
11411 if(HAL_STATUS_SUCCESS(status))
11412 {
11413 //Save profile for late use
11414 csrFreeRoamProfile( pMac, sessionId );
11415 if (HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
11416 (void **)&pSession->pCurRoamProfile,
11417 sizeof(tCsrRoamProfile))))
11418 {
11419 palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile));
11420 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
11421 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011422 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070011423 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070011424 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
11425 }
11426 }
11427
11428 return( status );
11429}
11430
Jeff Johnson295189b2012-06-20 16:38:30 -070011431////////////////////Mail box
11432
Jeff Johnson295189b2012-06-20 16:38:30 -070011433//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
11434//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
11435static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
11436 tSirBssDescription *pBssDescription,
11437 tANI_U8 *pBuf, tANI_U8 uapsdMask)
11438{
11439 tCsrChannelSet channelGroup;
11440 tSirMacCapabilityInfo *pAP_capabilityInfo;
11441 tAniBool fTmp;
11442 tANI_BOOLEAN found = FALSE;
11443 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080011444 tANI_S8 pwrLimit = 0;
11445 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011446 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
11447 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
11448 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
11449 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070011450 // 802.11h
11451 //We can do this because it is in HOST CPU order for now.
11452 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080011453 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
11454 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
11455 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011456 fTmp = (tAniBool)pal_cpu_to_be32(1);
11457 }
11458 else
11459 fTmp = (tAniBool)0;
11460
11461 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
11462 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool) );
11463 pBuf += sizeof(tAniBool);
11464 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080011465 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070011466 // This is required for 11k test VoWiFi Ent: Test 2.
11467 // We need the power capabilities for Assoc Req.
11468 // This macro is provided by the halPhyCfg.h. We pick our
11469 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080011470 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
11471 if (0 != pwrLimit)
11472 {
11473 *pBuf++ = pwrLimit;
11474 }
11475 else
11476 {
11477 *pBuf++ = MAX_STA_PWR_CAP_DBM;
11478 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011479 size = sizeof(pMac->roam.validChannelList);
11480 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
11481 {
11482 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
11483 for ( i = 0; i < size; i++)
11484 {
11485 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
11486
11487 }
11488 }
11489 else
11490 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011491 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011492 *pBuf++ = 0; //tSirSupChnl->numChnl
11493 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011494 //Check whether it is ok to enter UAPSD
11495#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11496 if( btcIsReadyForUapsd(pMac) )
11497#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
11498 {
11499 *pBuf++ = uapsdMask;
11500 }
11501#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11502 else
11503 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011504 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070011505 *pBuf++ = 0;
11506 }
11507#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
11508
Jeff Johnson295189b2012-06-20 16:38:30 -070011509 // move the entire BssDescription into the join request.
11510 palCopyMemory( pMac->hHdd, pBuf, pBssDescription,
11511 pBssDescription->length + sizeof( pBssDescription->length ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070011512 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
11513}
11514
Jeff Johnson295189b2012-06-20 16:38:30 -070011515/*
11516 * The communication between HDD and LIM is thru mailbox (MB).
11517 * Both sides will access the data structure "tSirSmeJoinReq".
11518 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
11519 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
11520 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
11521 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
11522 */
11523eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011524 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011525{
11526 eHalStatus status = eHAL_STATUS_SUCCESS;
11527 tSirSmeJoinReq *pMsg;
11528 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011529 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070011530 tANI_U16 msgLen, wTmp, ieLen;
11531 tSirMacRateSet OpRateSet;
11532 tSirMacRateSet ExRateSet;
11533 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11534 tANI_U32 dwTmp;
11535 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Jeff Johnson32d95a32012-09-10 13:15:23 -070011536
11537 if(!pSession)
11538 {
11539 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11540 return eHAL_STATUS_FAILURE;
11541 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011542 /* To satisfy klockworks */
11543 if (NULL == pBssDescription)
11544 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011545 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011546 return eHAL_STATUS_FAILURE;
11547 }
11548
Jeff Johnson295189b2012-06-20 16:38:30 -070011549 do {
11550 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
11551 pSession->joinFailStatusCode.reasonCode = 0;
11552 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
11553 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
11554 // IE fields, but the length field in the bssDescription needs to be interpreted to
11555 // determine length of the IE fields.
11556 //
11557 // So, take the size of the JoinReq, subtract the size of the bssDescription and
11558 // add in the length from the bssDescription (then add the size of the 'length' field
11559 // itself because that is NOT included in the length field).
11560 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
11561 pBssDescription->length + sizeof( pBssDescription->length ) +
11562 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 -070011563 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
11564 if ( !HAL_STATUS_SUCCESS(status) ) break;
11565 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011566 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011567 pMsg->length = pal_cpu_to_be16(msgLen);
11568 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011569 // sessionId
11570 *pBuf = (tANI_U8)sessionId;
11571 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011572 // transactionId
11573 *pBuf = 0;
11574 *( pBuf + 1 ) = 0;
11575 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070011576 // ssId
11577 if( pIes->SSID.present && pIes->SSID.num_ssid )
11578 {
11579 // ssId len
11580 *pBuf = pIes->SSID.num_ssid;
11581 pBuf++;
11582 palCopyMemory( pMac->hHdd, pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid );
11583 pBuf += pIes->SSID.num_ssid;
11584 }
11585 else
11586 {
11587 *pBuf = 0;
11588 pBuf++;
11589 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011590 // selfMacAddr
11591 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
11592 pBuf += sizeof(tSirMacAddr);
11593 // bsstype
11594 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
11595 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
11596 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tSirBssType) );
11597 pBuf += sizeof(tSirBssType);
11598 // dot11mode
11599 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
11600 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011601 //Persona
11602 *pBuf = (tANI_U8)pProfile->csrPersona;
11603 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070011604 //CBMode
11605 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
11606 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011607
11608 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070011609 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
11610
Jeff Johnson295189b2012-06-20 16:38:30 -070011611 // uapsdPerAcBitmask
11612 *pBuf = pProfile->uapsd_mask;
11613 pBuf++;
11614
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011615
11616
Jeff Johnson295189b2012-06-20 16:38:30 -070011617 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011618 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011619 {
11620 // OperationalRateSet
11621 if (OpRateSet.numRates) {
11622 *pBuf++ = OpRateSet.numRates;
11623 palCopyMemory(pMac->hHdd, pBuf, OpRateSet.rate, OpRateSet.numRates);
11624 pBuf += OpRateSet.numRates;
11625 } else *pBuf++ = 0;
11626 // ExtendedRateSet
11627 if (ExRateSet.numRates) {
11628 *pBuf++ = ExRateSet.numRates;
11629 palCopyMemory(pMac->hHdd, pBuf, ExRateSet.rate, ExRateSet.numRates);
11630 pBuf += ExRateSet.numRates;
11631 } else *pBuf++ = 0;
11632 }
11633 else
11634 {
11635 *pBuf++ = 0;
11636 *pBuf++ = 0;
11637 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011638 // rsnIE
11639 if ( csrIsProfileWpa( pProfile ) )
11640 {
11641 // Insert the Wpa IE into the join request
11642 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
11643 (tCsrWpaIe *)( wpaRsnIE ) );
11644 }
11645 else if( csrIsProfileRSN( pProfile ) )
11646 {
11647 // Insert the RSN IE into the join request
11648 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11649 (tCsrRSNIe *)( wpaRsnIE ) );
11650 }
11651#ifdef FEATURE_WLAN_WAPI
11652 else if( csrIsProfileWapi( pProfile ) )
11653 {
11654 // Insert the WAPI IE into the join request
11655 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11656 (tCsrWapiIe *)( wpaRsnIE ) );
11657 }
11658#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011659 else
11660 {
11661 ieLen = 0;
11662 }
11663 //remember the IE for future use
11664 if( ieLen )
11665 {
11666 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
11667 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011668 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 -070011669 ieLen = DOT11F_IE_RSN_MAX_LEN;
11670 }
11671#ifdef FEATURE_WLAN_WAPI
11672 if( csrIsProfileWapi( pProfile ) )
11673 {
11674 //Check whether we need to allocate more memory
11675 if(ieLen > pSession->nWapiReqIeLength)
11676 {
11677 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
11678 {
11679 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
11680 }
11681 status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWapiReqIE, ieLen);
11682 if(!HAL_STATUS_SUCCESS(status)) break;
11683 }
11684 pSession->nWapiReqIeLength = ieLen;
11685 palCopyMemory(pMac->hHdd, pSession->pWapiReqIE, wpaRsnIE, ieLen);
11686 wTmp = pal_cpu_to_be16( ieLen );
11687 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11688 pBuf += sizeof(tANI_U16);
11689 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11690 pBuf += ieLen;
11691 }
11692 else//should be WPA/WPA2 otherwise
11693#endif /* FEATURE_WLAN_WAPI */
11694 {
11695 //Check whether we need to allocate more memory
11696 if(ieLen > pSession->nWpaRsnReqIeLength)
11697 {
11698 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
11699 {
11700 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
11701 }
11702 status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnReqIE, ieLen);
11703 if(!HAL_STATUS_SUCCESS(status)) break;
11704 }
11705 pSession->nWpaRsnReqIeLength = ieLen;
11706 palCopyMemory(pMac->hHdd, pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
11707 wTmp = pal_cpu_to_be16( ieLen );
11708 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11709 pBuf += sizeof(tANI_U16);
11710 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11711 pBuf += ieLen;
11712 }
11713 }
11714 else
11715 {
11716 //free whatever old info
11717 pSession->nWpaRsnReqIeLength = 0;
11718 if(pSession->pWpaRsnReqIE)
11719 {
11720 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
11721 pSession->pWpaRsnReqIE = NULL;
11722 }
11723#ifdef FEATURE_WLAN_WAPI
11724 pSession->nWapiReqIeLength = 0;
11725 if(pSession->pWapiReqIE)
11726 {
11727 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
11728 pSession->pWapiReqIE = NULL;
11729 }
11730#endif /* FEATURE_WLAN_WAPI */
11731 //length is two bytes
11732 *pBuf = 0;
11733 *(pBuf + 1) = 0;
11734 pBuf += 2;
11735 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011736#ifdef FEATURE_WLAN_CCX
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011737 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011738 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011739 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070011740 //length is two bytes
11741 *pBuf = 0;
11742 *(pBuf + 1) = 0;
11743 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011744 }
11745 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011746 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011747 // cckmIE
11748 if( csrIsProfileCCX( pProfile ) )
11749 {
11750 // Insert the CCKM IE into the join request
11751 ieLen = csrConstructCcxCckmIe( pMac,
11752 pSession,
11753 pProfile,
11754 pBssDescription,
11755 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070011756 pSession->nWpaRsnReqIeLength,
11757 (void *)( wpaRsnIE ) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011758 }
11759 else
11760 {
11761 ieLen = 0;
11762 }
11763 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
11764 if( ieLen )
11765 {
11766 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
11767 wTmp = pal_cpu_to_be16( ieLen );
11768 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11769 pBuf += sizeof(tANI_U16);
11770 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11771 pBuf += ieLen;
11772 }
11773 else
11774 {
11775 //Indicate you have no CCKM IE
11776 //length is two bytes
11777 *pBuf = 0;
11778 *(pBuf + 1) = 0;
11779 pBuf += 2;
11780 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011781 }
11782#endif /* FEATURE_WLAN_CCX */
Jeff Johnson295189b2012-06-20 16:38:30 -070011783 // addIEScan
11784 if(pProfile->nAddIEScanLength && pProfile->pAddIEScan)
11785 {
11786 ieLen = pProfile->nAddIEScanLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070011787 if(ieLen > pSession->nAddIEScanLength)
11788 {
11789 if(pSession->pAddIEScan && pSession->nAddIEScanLength)
11790 {
11791 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
11792 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011793 status = palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070011794 (void **)&pSession->pAddIEScan, ieLen);
11795 if(!HAL_STATUS_SUCCESS(status)) break;
11796 }
11797 pSession->nAddIEScanLength = ieLen;
11798 palCopyMemory(pMac->hHdd, pSession->pAddIEScan,
11799 pProfile->pAddIEScan, ieLen);
11800 wTmp = pal_cpu_to_be16( ieLen );
11801 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11802 pBuf += sizeof(tANI_U16);
11803 palCopyMemory( pMac->hHdd, pBuf, pProfile->pAddIEScan, ieLen );
11804 pBuf += ieLen;
11805 }
11806 else
11807 {
11808 pSession->nAddIEScanLength = 0;
11809 if(pSession->pAddIEScan)
11810 {
11811 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
11812 pSession->pAddIEScan = NULL;
11813 }
11814 *pBuf = 0;
11815 *(pBuf + 1) = 0;
11816 pBuf += 2;
11817 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011818 // addIEAssoc
11819 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
11820 {
11821 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070011822 if(ieLen > pSession->nAddIEAssocLength)
11823 {
11824 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
11825 {
11826 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
11827 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011828 status = palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070011829 (void **)&pSession->pAddIEAssoc, ieLen);
11830 if(!HAL_STATUS_SUCCESS(status)) break;
11831 }
11832 pSession->nAddIEAssocLength = ieLen;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011833 palCopyMemory(pMac->hHdd, pSession->pAddIEAssoc,
Jeff Johnson295189b2012-06-20 16:38:30 -070011834 pProfile->pAddIEAssoc, ieLen);
11835 wTmp = pal_cpu_to_be16( ieLen );
11836 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11837 pBuf += sizeof(tANI_U16);
11838 palCopyMemory( pMac->hHdd, pBuf, pProfile->pAddIEAssoc, ieLen );
11839 pBuf += ieLen;
11840 }
11841 else
11842 {
11843 pSession->nAddIEAssocLength = 0;
11844 if(pSession->pAddIEAssoc)
11845 {
11846 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
11847 pSession->pAddIEAssoc = NULL;
11848 }
11849 *pBuf = 0;
11850 *(pBuf + 1) = 0;
11851 pBuf += 2;
11852 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011853
11854 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011855 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011856 //Unmask any AC in reassoc that is ACM-set
11857 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
11858 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011859 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011860 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
11861 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011862#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011863 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070011864#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011865 uapsd_mask &= ~(acm_mask);
11866 }
11867 else
11868 {
11869 uapsd_mask = 0;
11870 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011871 }
11872 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011873
Jeff Johnson295189b2012-06-20 16:38:30 -070011874 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
11875 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011876 pBuf += sizeof(tANI_U32);
11877
Jeff Johnson295189b2012-06-20 16:38:30 -070011878 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
11879 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011880 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070011881#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011882 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053011883 if (csrIsProfile11r( pProfile )
11884#ifdef FEATURE_WLAN_CCX
11885 && !((pIes->CCXVersion.present) && (pMac->roam.configParam.isCcxIniFeatureEnabled))
11886#endif
11887 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011888 {
11889 // is11Rconnection;
11890 dwTmp = pal_cpu_to_be32(TRUE);
11891 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11892 pBuf += sizeof(tAniBool);
11893 }
11894 else
11895 {
11896 // is11Rconnection;
11897 dwTmp = pal_cpu_to_be32(FALSE);
11898 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11899 pBuf += sizeof(tAniBool);
11900 }
11901#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011902#ifdef FEATURE_WLAN_CCX
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011903 /* A profile can not be both CCX and 11R. But an 802.11R AP
11904 * may be advertising support for CCX as well. So if we are
11905 * associating Open or explicitly CCX then we will get CCX.
11906 * If we are associating explictly 11R only then we will get
11907 * 11R.
11908 */
11909 if ((csrIsProfileCCX(pProfile) ||
11910 ((pIes->CCXVersion.present)
11911 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011912 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
11913 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
11914 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011915 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011916 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
11917 {
11918 // isCCXconnection;
11919 dwTmp = pal_cpu_to_be32(TRUE);
11920 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11921 pBuf += sizeof(tAniBool);
11922 }
11923 else
11924 {
11925 //isCCXconnection;
11926 dwTmp = pal_cpu_to_be32(FALSE);
11927 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11928 pBuf += sizeof(tAniBool);
11929 }
11930
11931 if (eWNI_SME_JOIN_REQ == messageType)
11932 {
11933 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 else if (eWNI_SME_REASSOC_REQ == messageType)
11941 {
11942 if ((csrIsProfileCCX(pProfile) ||
11943 ((pIes->CCXVersion.present)
11944 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011945 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
11946 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
11947 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011948 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011949 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070011950 {
11951 tCCXTspecInfo ccxTspec;
Jeff Johnson295189b2012-06-20 16:38:30 -070011952 // CCX Tspec information
11953 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
11954 ccxTspec.numTspecs = sme_QosCCxRetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &ccxTspec.tspec[0]);
11955 *pBuf = ccxTspec.numTspecs;
11956 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070011957 // Copy the TSPEC information only if present
11958 if (ccxTspec.numTspecs) {
11959 palCopyMemory(pMac->hHdd, pBuf, (void*)&ccxTspec.tspec[0], (ccxTspec.numTspecs*sizeof(tTspecInfo)));
11960 }
11961 pBuf += sizeof(ccxTspec.tspec);
11962 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011963 else
Jeff Johnson295189b2012-06-20 16:38:30 -070011964 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011965 tCCXTspecInfo ccxTspec;
11966 // CCX-Tspec IEs in the ASSOC request is presently not supported
11967 // so nullify the TSPEC parameters
11968 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
11969 palCopyMemory( pMac->hHdd, pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
11970 pBuf += sizeof(tCCXTspecInfo);
11971 }
11972 }
11973#endif // FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011974#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070011975 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011976 if (pMac->roam.configParam.isFastTransitionEnabled
11977#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053011978 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011979#endif
11980 )
Jeff Johnson295189b2012-06-20 16:38:30 -070011981 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011982 dwTmp = pal_cpu_to_be32(TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011983 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011984 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070011985 }
11986 else
11987 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011988 dwTmp = pal_cpu_to_be32(FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011989 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011990 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070011991 }
11992#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070011993#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053011994 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070011995 {
11996 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011997 dwTmp = pal_cpu_to_be32(TRUE);
Jeff Johnson43971f52012-07-17 12:26:56 -070011998 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011999 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012000 }
12001 else
12002 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012003 dwTmp = pal_cpu_to_be32(FALSE);
Jeff Johnson43971f52012-07-17 12:26:56 -070012004 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012005 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012006 }
12007#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012008
12009 // txLdpcIniFeatureEnabled
12010 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
12011 pBuf++;
12012
Kiran4a17ebe2013-01-31 10:43:43 -080012013 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
12014 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
12015 {
12016 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
12017 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
12018 csrApplyPower2Current(pMac);
12019 }
12020
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012021#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080012022 // txBFIniFeatureEnabled
12023 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
12024 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080012025
12026 // txBFCsnValue
12027 *pBuf = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
12028 pBuf++;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012029#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012030 //BssDesc
12031 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
12032 (tANI_U8)pProfile->uapsd_mask);
12033 status = palSendMBMessage(pMac->hHdd, pMsg );
12034 if(!HAL_STATUS_SUCCESS(status))
12035 {
12036 break;
12037 }
12038 else
12039 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012040#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012041 if (eWNI_SME_JOIN_REQ == messageType)
12042 {
12043 //Tush-QoS: notify QoS module that join happening
12044 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
12045 }
12046 else if (eWNI_SME_REASSOC_REQ == messageType)
12047 {
12048 //Tush-QoS: notify QoS module that reassoc happening
12049 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
12050 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012051#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012052 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012053 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012054 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070012055}
12056
Jeff Johnson295189b2012-06-20 16:38:30 -070012057//
12058eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12059{
12060 eHalStatus status = eHAL_STATUS_SUCCESS;
12061 tSirSmeDisassocReq *pMsg;
12062 tANI_U8 *pBuf;
12063 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012064 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12065 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12066 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012067 do {
12068 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDisassocReq ));
12069 if ( !HAL_STATUS_SUCCESS(status) ) break;
12070 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDisassocReq ));
12071 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
12072 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012073 pBuf = &pMsg->sessionId;
12074 // sessionId
12075 *pBuf++ = (tANI_U8)sessionId;
12076 // transactionId
12077 *pBuf = 0;
12078 *( pBuf + 1 ) = 0;
12079 pBuf += sizeof(tANI_U16);
12080
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053012081 if ( (pSession->pCurRoamProfile != NULL) &&
12082 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
12083 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012084 {
12085 // Set the bssid address before sending the message to LIM
12086 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pSession->selfMacAddr, sizeof( tSirMacAddr ) );
12087 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012088 // Set the peer MAC address before sending the message to LIM
12089 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ) ); //perMacAddr is passed as bssId for softAP
12090 pBuf = pBuf + sizeof ( tSirMacAddr );
12091 }
12092 else
12093 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012094 // Set the peer MAC address before sending the message to LIM
12095 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ) );
12096 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012097 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ) );
12098 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012099 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012100 if(!HAL_STATUS_SUCCESS(status))
12101 {
12102 palFreeMemory(pMac->hHdd, pMsg);
12103 break;
12104 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012105 // reasonCode
12106 wTmp = pal_cpu_to_be16(reasonCode);
12107 status = palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12108 if(!HAL_STATUS_SUCCESS(status))
12109 {
12110 palFreeMemory(pMac->hHdd, pMsg);
12111 break;
12112 }
12113 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012114 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
12115 Here we should not send the disassoc over the air to the AP */
12116 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
12117#ifdef WLAN_FEATURE_VOWIFI_11R
12118 && csrRoamIs11rAssoc(pMac)
12119#endif
12120 )
12121 {
12122 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
12123 }
12124 pBuf += sizeof(tANI_U8);
12125 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012126 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012127 return( status );
12128}
Jeff Johnson295189b2012-06-20 16:38:30 -070012129eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
12130{
12131 eHalStatus status = eHAL_STATUS_SUCCESS;
12132 tSirSmeTkipCntrMeasReq *pMsg;
12133 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012134 do
12135 {
12136 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeTkipCntrMeasReq ));
12137 if ( !HAL_STATUS_SUCCESS(status) ) break;
12138 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeTkipCntrMeasReq ));
12139 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
12140 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012141 pBuf = &pMsg->sessionId;
12142 // sessionId
12143 *pBuf++ = (tANI_U8)sessionId;
12144 // transactionId
12145 *pBuf = 0;
12146 *( pBuf + 1 ) = 0;
12147 pBuf += sizeof(tANI_U16);
12148 // bssid
12149 status = palCopyMemory( pMac->hHdd, pMsg->bssId, bssId, sizeof( tSirMacAddr ) );
12150 pBuf = pBuf + sizeof ( tSirMacAddr );
12151 // bEnable
12152 *pBuf = (tANI_BOOLEAN)bEnable;
12153 if(!HAL_STATUS_SUCCESS(status))
12154 {
12155 palFreeMemory(pMac->hHdd, pMsg);
12156 break;
12157 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012158 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012159 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012160 return( status );
12161}
Jeff Johnson295189b2012-06-20 16:38:30 -070012162eHalStatus
12163csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
12164 VOS_MODULE_ID modId, tSirMacAddr bssId,
12165 void *pUsrContext, void *pfnSapEventCallback,
12166 tANI_U8 *pAssocStasBuf )
12167{
12168 eHalStatus status = eHAL_STATUS_SUCCESS;
12169 tSirSmeGetAssocSTAsReq *pMsg;
12170 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
12171 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012172 do
12173 {
12174 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeGetAssocSTAsReq ) );
12175 if (!HAL_STATUS_SUCCESS(status)) break;
12176 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirSmeGetAssocSTAsReq ) );
12177 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012178 pBuf = (tANI_U8 *)&pMsg->bssId;
12179 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012180 // bssId
12181 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr) );
12182 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012183 // modId
12184 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
12185 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
12186 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012187 // pUsrContext
12188 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
12189 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12190 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012191 // pfnSapEventCallback
12192 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
12193 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12194 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012195 // pAssocStasBuf
12196 dwTmp = pal_cpu_to_be32((tANI_U32)pAssocStasBuf);
12197 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12198 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012199 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070012200 status = palSendMBMessage( pMac->hHdd, pMsg );
12201 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012202 return( status );
12203 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012204eHalStatus
12205csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
12206 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
12207 {
12208 eHalStatus status = eHAL_STATUS_SUCCESS;
12209 tSirSmeGetWPSPBCSessionsReq *pMsg;
12210 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
12211 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012212 do
12213 {
12214 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirSmeGetWPSPBCSessionsReq) );
12215 if (!HAL_STATUS_SUCCESS(status)) break;
12216 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ) );
12217 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012218 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
12219 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012220 // pUsrContext
12221 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
12222 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12223 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012224 // pSapEventCallback
12225 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
12226 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12227 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012228 // bssId
12229 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr) );
12230 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012231 // MAC Address of STA in WPS session
12232 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
12233 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070012234 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070012235 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012236 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012237 return( status );
12238}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012239
12240eHalStatus
12241csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
12242{
12243 tpSirChangeBIParams pMsg;
12244 tANI_U16 len = 0;
12245 eHalStatus status = eHAL_STATUS_SUCCESS;
12246 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12247
12248 if(!pSession)
12249 {
12250 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12251 return eHAL_STATUS_FAILURE;
12252 }
12253
12254 //NO need to update the Beacon Params if update beacon parameter flag is not set
12255 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
12256 return eHAL_STATUS_SUCCESS;
12257
12258 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
12259
12260 /* Create the message and send to lim */
12261 len = sizeof(tSirChangeBIParams);
12262 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, len );
12263 if(HAL_STATUS_SUCCESS(status))
12264 {
12265 palZeroMemory(pMac->hHdd, pMsg, sizeof(tSirChangeBIParams) );
12266 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
12267 pMsg->length = len;
12268
12269 // bssId
12270 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012271 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 -080012272 pMsg->bssId[ 0 ], pMsg->bssId[ 1 ], pMsg->bssId[ 2 ],
12273 pMsg->bssId[ 3 ], pMsg->bssId[ 4 ], pMsg->bssId[ 5 ] );
12274 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012275 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012276 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
12277 status = palSendMBMessage(pMac->hHdd, pMsg);
12278 }
12279 return status;
12280}
12281
Jeff Johnson295189b2012-06-20 16:38:30 -070012282eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12283{
12284 eHalStatus status = eHAL_STATUS_SUCCESS;
12285 tSirSmeDeauthReq *pMsg;
12286 tANI_U8 *pBuf;
12287 tANI_U16 wTmp;
12288 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12289 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12290 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012291 do {
12292 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDeauthReq ));
12293 if ( !HAL_STATUS_SUCCESS(status) ) break;
12294 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDeauthReq ));
12295 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
12296 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
12297 //sessionId
12298 pBuf = &pMsg->sessionId;
12299 *pBuf++ = (tANI_U8)sessionId;
12300
12301 //tansactionId
12302 *pBuf = 0;
12303 *(pBuf + 1 ) = 0;
12304 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012305 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070012306 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070012307 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
12308 // Set the BSSID before sending the message to LIM
12309 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pSession->selfMacAddr, sizeof( pMsg->peerMacAddr ) );
12310 pBuf = pBuf + sizeof(tSirMacAddr);
12311 }
12312 else
12313 {
12314 // Set the BSSID before sending the message to LIM
12315 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
12316 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012317 }
12318 if(!HAL_STATUS_SUCCESS(status))
12319 {
12320 palFreeMemory(pMac->hHdd, pMsg);
12321 break;
12322 }
12323 // Set the peer MAC address before sending the message to LIM
12324 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
12325 pBuf = pBuf + sizeof(tSirMacAddr);
12326 if(!HAL_STATUS_SUCCESS(status))
12327 {
12328 palFreeMemory(pMac->hHdd, pMsg);
12329 break;
12330 }
12331 wTmp = pal_cpu_to_be16(reasonCode);
12332 status = palCopyMemory( pMac->hHdd, pBuf, &wTmp,sizeof( tANI_U16 ) );
12333 if(!HAL_STATUS_SUCCESS(status))
12334 {
12335 palFreeMemory(pMac->hHdd, pMsg);
12336 break;
12337 }
12338 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012339 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012340 return( status );
12341}
12342
Jeff Johnson295189b2012-06-20 16:38:30 -070012343eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
12344{
12345 eHalStatus status = eHAL_STATUS_SUCCESS;
12346 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070012347 do {
12348 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDisassocCnf ));
12349 if ( !HAL_STATUS_SUCCESS(status) ) break;
12350 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDisassocCnf ));
12351 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
12352 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12353 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
12354 status = palCopyMemory(pMac->hHdd, pMsg->peerMacAddr, pDisassocInd->peerMacAddr, sizeof(pMsg->peerMacAddr));
12355 if(!HAL_STATUS_SUCCESS(status))
12356 {
12357 palFreeMemory(pMac->hHdd, pMsg);
12358 break;
12359 }
12360//To test reconn
12361 status = palCopyMemory(pMac->hHdd, pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
12362 if(!HAL_STATUS_SUCCESS(status))
12363 {
12364 palFreeMemory(pMac->hHdd, pMsg);
12365 break;
12366 }
12367//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070012368 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012369 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012370 return( status );
12371}
12372
Jeff Johnson295189b2012-06-20 16:38:30 -070012373eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
12374{
12375 eHalStatus status = eHAL_STATUS_SUCCESS;
12376 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070012377 do {
12378 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDeauthCnf ));
12379 if ( !HAL_STATUS_SUCCESS(status) ) break;
12380 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDeauthCnf ));
12381 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
12382 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12383 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
12384 status = palCopyMemory(pMac->hHdd, pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
12385 if(!HAL_STATUS_SUCCESS(status))
12386 {
12387 palFreeMemory(pMac->hHdd, pMsg);
12388 break;
12389 }
12390 status = palCopyMemory(pMac->hHdd, pMsg->peerMacAddr, pDeauthInd->peerMacAddr, sizeof(pMsg->peerMacAddr));
12391 if(!HAL_STATUS_SUCCESS(status))
12392 {
12393 palFreeMemory(pMac->hHdd, pMsg);
12394 break;
12395 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012396 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012397 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012398 return( status );
12399}
Jeff Johnson295189b2012-06-20 16:38:30 -070012400eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
12401{
12402 eHalStatus status = eHAL_STATUS_SUCCESS;
12403 tSirSmeAssocCnf *pMsg;
12404 tANI_U8 *pBuf;
12405 tSirResultCodes statusCode;
12406 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012407 do {
12408 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeAssocCnf ));
12409 if ( !HAL_STATUS_SUCCESS(status) ) break;
12410 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeAssocCnf ));
12411 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
12412 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012413 pBuf = (tANI_U8 *)&pMsg->statusCode;
12414 if(HAL_STATUS_SUCCESS(Halstatus))
12415 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12416 else
12417 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
12418 palCopyMemory( pMac->hHdd, pBuf, &statusCode, sizeof(tSirResultCodes) );
12419 pBuf += sizeof(tSirResultCodes);
12420 // bssId
12421 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12422 pBuf += sizeof (tSirMacAddr);
12423 // peerMacAddr
12424 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
12425 pBuf += sizeof (tSirMacAddr);
12426 // aid
12427 wTmp = pal_cpu_to_be16(pAssocInd->aid);
12428 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12429 pBuf += sizeof (tANI_U16);
12430 // alternateBssId
12431 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12432 pBuf += sizeof (tSirMacAddr);
12433 // alternateChannelId
12434 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070012435 status = palSendMBMessage( pMac->hHdd, pMsg );
12436 if(!HAL_STATUS_SUCCESS(status))
12437 {
12438 //pMsg is freed by palSendMBMessage
12439 break;
12440 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012441 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012442 return( status );
12443}
Jeff Johnson295189b2012-06-20 16:38:30 -070012444eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
12445 tpSirSmeAssocInd pAssocInd,
12446 eHalStatus Halstatus,
12447 tANI_U8 sessionId)
12448{
12449 tSirMsgQ msgQ;
12450 eHalStatus status = eHAL_STATUS_SUCCESS;
12451 tSirSmeAssocIndToUpperLayerCnf *pMsg;
12452 tANI_U8 *pBuf;
12453 tSirResultCodes statusCode;
12454 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012455 do {
12456 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ));
12457 if ( !HAL_STATUS_SUCCESS(status) ) break;
12458 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ));
Jeff Johnsone7245742012-09-05 17:12:55 -070012459
Jeff Johnson295189b2012-06-20 16:38:30 -070012460 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
12461 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
12462
12463 pMsg->sessionId = sessionId;
12464
12465 pBuf = (tANI_U8 *)&pMsg->statusCode;
12466 if(HAL_STATUS_SUCCESS(Halstatus))
12467 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12468 else
12469 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
12470 palCopyMemory( pMac->hHdd, pBuf, &statusCode, sizeof(tSirResultCodes) );
12471 pBuf += sizeof(tSirResultCodes);
12472 // bssId
12473 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12474 pBuf += sizeof (tSirMacAddr);
12475 // peerMacAddr
12476 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
12477 pBuf += sizeof (tSirMacAddr);
12478 // StaId
12479 wTmp = pal_cpu_to_be16(pAssocInd->staId);
12480 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12481 pBuf += sizeof (tANI_U16);
12482 // alternateBssId
12483 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12484 pBuf += sizeof (tSirMacAddr);
12485 // alternateChannelId
12486 *pBuf = 11;
12487 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012488 // Instead of copying roam Info, we just copy only WmmEnabled , RsnIE information
12489 //Wmm
12490 *pBuf = pAssocInd->wmmEnabledSta;
12491 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012492 //RSN IE
12493 status = palCopyMemory(pMac->hHdd, (tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
12494 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070012495 //Additional IE
12496 status = palCopyMemory(pMac->hHdd, (void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
12497 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070012498 //reassocReq
12499 *pBuf = pAssocInd->reassocReq;
12500 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012501 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
12502 msgQ.bodyptr = pMsg;
12503 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012504 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012505 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012506 return( status );
12507}
Jeff Johnson295189b2012-06-20 16:38:30 -070012508
Jeff Johnson295189b2012-06-20 16:38:30 -070012509eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId ,
12510 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
12511 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
12512 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
12513 tANI_U8 *pKeyRsc )
12514{
12515 tSirSmeSetContextReq *pMsg;
12516 tANI_U16 msgLen;
12517 eHalStatus status = eHAL_STATUS_FAILURE;
12518 tAniEdType tmpEdType;
12519 tAniKeyDirection tmpDirection;
12520 tANI_U8 *pBuf;
12521 tANI_U8 *p;
12522 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012523 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070012524 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012525 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
12526 // key set. Since we only support upto one key, we always allocate memory for 1 key
12527 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
12528 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
12529 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
12530 ( sizeof( pMsg->keyMaterial.key ) );
12531
12532 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12533 if ( !HAL_STATUS_SUCCESS(status) ) break;
12534 palZeroMemory(pMac->hHdd, pMsg, msgLen);
12535 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
12536 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012537 //sessionId
12538 pBuf = &pMsg->sessionId;
12539 *pBuf = (tANI_U8)sessionId;
12540 pBuf++;
12541 // transactionId
12542 *pBuf = 0;
12543 *(pBuf + 1) = 0;
12544 pBuf += sizeof(tANI_U16);
12545 // peerMacAddr
12546 palCopyMemory( pMac->hHdd, pBuf,
12547 (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr) );
12548
12549 pBuf += sizeof(tSirMacAddr);
12550
12551 // bssId
12552 palCopyMemory( pMac->hHdd, pBuf,
12553 (tANI_U8 *)&pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
12554
12555 pBuf += sizeof(tSirMacAddr);
12556
12557 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012558 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
12559 // in the tSirKeyMaterial keyMaterial; field).
12560 //
12561 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
12562 // shorter than this max size. Is LIM interpreting this ok ?
12563 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 -070012564 // set pMsg->keyMaterial.edType
12565 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
12566 palCopyMemory( pMac->hHdd, p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType) );
12567 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070012568 // set the pMsg->keyMaterial.numKeys field
12569 *p = numKeys;
12570 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070012571 // set pSirKey->keyId = keyId;
12572 *p = keyId;
12573 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012574 // set pSirKey->unicast = (tANI_U8)fUnicast;
12575 *p = (tANI_U8)fUnicast;
12576 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070012577 // set pSirKey->keyDirection = aniKeyDirection;
12578 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
12579 palCopyMemory( pMac->hHdd, p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection) );
12580 p += sizeof(tAniKeyDirection);
12581 // pSirKey->keyRsc = ;;
12582 palCopyMemory( pMac->hHdd, p, pKeyRsc, CSR_MAX_RSC_LEN );
12583 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070012584 // set pSirKey->paeRole
12585 *p = paeRole; // 0 is Supplicant
12586 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012587 // set pSirKey->keyLength = keyLength;
12588 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070012589 if ( keyLength && pKey )
12590 {
12591 palCopyMemory( pMac->hHdd, p, pKey, keyLength );
12592 if(keyLength == 16)
12593 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012594 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 -070012595 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
12596 pKey[5], pKey[6], pKey[7], pKey[8],
12597 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
12598 }
12599 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012600 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012601 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012602 return( status );
12603}
12604
Jeff Johnson295189b2012-06-20 16:38:30 -070012605eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
12606 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
12607{
12608 eHalStatus status;
12609 tSirSmeStartBssReq *pMsg;
12610 tANI_U8 *pBuf = NULL;
12611 tANI_U8 *wTmpBuf = NULL;
12612 tANI_U16 msgLen, wTmp;
12613 tANI_U32 dwTmp;
12614 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070012615 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012616 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070012617 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012618
12619 if(!pSession)
12620 {
12621 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12622 return eHAL_STATUS_FAILURE;
12623 }
12624
Jeff Johnson295189b2012-06-20 16:38:30 -070012625 do {
12626 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12627 pSession->joinFailStatusCode.reasonCode = 0;
12628 msgLen = sizeof(tSirSmeStartBssReq);
12629 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12630 if ( !HAL_STATUS_SUCCESS(status) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012631 palZeroMemory(pMac->hHdd, pMsg, msgLen);
12632 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012633 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012634 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012635 //sessionId
12636 *pBuf = (tANI_U8)sessionId;
12637 pBuf++;
12638 // transactionId
12639 *pBuf = 0;
12640 *(pBuf + 1) = 0;
12641 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012642 // bssid
12643 palCopyMemory( pMac->hHdd, pBuf, pParam->bssid, sizeof(tSirMacAddr) );
12644 pBuf += sizeof(tSirMacAddr);
12645 // selfMacAddr
12646 palCopyMemory( pMac->hHdd, pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr) );
12647 pBuf += sizeof(tSirMacAddr);
12648 // beaconInterval
12649 if( pBssDesc && pBssDesc->beaconInterval )
12650 {
12651 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
12652 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012653 else if(pParam->beaconInterval)
12654 {
12655 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
12656 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012657 else
12658 {
12659 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
12660 }
Jeff Johnsone7245742012-09-05 17:12:55 -070012661 if(csrIsconcurrentsessionValid (pMac, sessionId,
12662 pParam->bssPersona)
12663 == eHAL_STATUS_SUCCESS )
12664 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012665 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070012666 pParam->bssPersona);
12667 //Update the beacon Interval
12668 pParam->beaconInterval = wTmp;
12669 }
12670 else
12671 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012672 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070012673 status = eHAL_STATUS_FAILURE;
12674 return status;
12675 }
12676
Jeff Johnson295189b2012-06-20 16:38:30 -070012677 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof( tANI_U16 ) );
12678 pBuf += sizeof(tANI_U16);
12679 // dot11mode
12680 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
12681 pBuf += 1;
12682 // bssType
12683 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
12684 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tSirBssType) );
12685 pBuf += sizeof(tSirBssType);
12686 // ssId
12687 if( pParam->ssId.length )
12688 {
12689 // ssId len
12690 *pBuf = pParam->ssId.length;
12691 pBuf++;
12692 palCopyMemory( pMac->hHdd, pBuf, pParam->ssId.ssId, pParam->ssId.length );
12693 pBuf += pParam->ssId.length;
12694 }
12695 else
12696 {
12697 *pBuf = 0;
12698 pBuf++;
12699 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012700 // set the channel Id
12701 *pBuf = pParam->operationChn;
12702 pBuf++;
12703 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070012704 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
12705 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState) );
12706 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070012707
Jeff Johnson295189b2012-06-20 16:38:30 -070012708 // Set privacy
12709 *pBuf = pParam->privacy;
12710 pBuf++;
12711
12712 //Set Uapsd
12713 *pBuf = pParam->ApUapsdEnable;
12714 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012715 //Set SSID hidden
12716 *pBuf = pParam->ssidHidden;
12717 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012718 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
12719 pBuf++;
12720
12721 //Ht protection Enable/Disable
12722 *pBuf = (tANI_U8)pParam->protEnabled;
12723 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012724 //Enable Beacons to Receive for OBSS protection Enable/Disable
12725 *pBuf = (tANI_U8)pParam->obssProtEnabled;
12726 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012727 //set cfg related to protection
12728 wTmp = pal_cpu_to_be16( pParam->ht_protection );
12729 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof( tANI_U16 ) );
12730 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012731 // Set Auth type
12732 authType = pal_cpu_to_be32(pParam->authType);
12733 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
12734 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012735 // Set DTIM
12736 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
12737 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12738 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012739 // Set wps_state
12740 *pBuf = pParam->wps_state;
12741 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012742 //Persona
12743 *pBuf = (tANI_U8)pParam->bssPersona;
12744 pBuf++;
12745
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080012746 //txLdpcIniFeatureEnabled
12747 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
12748 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070012749
Jeff Johnson295189b2012-06-20 16:38:30 -070012750
12751 // set RSN IE
12752 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
12753 {
12754 status = eHAL_STATUS_INVALID_PARAMETER;
12755 palFreeMemory( pMac->hHdd, pMsg );
12756 break;
12757 }
12758 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
12759 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12760 pBuf += sizeof(tANI_U16);
12761 if( wTmp )
12762 {
12763 wTmp = pParam->nRSNIELength;
12764 palCopyMemory( pMac->hHdd, pBuf, pParam->pRSNIE, wTmp );
12765 pBuf += wTmp;
12766 }
12767 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
12768 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType) );
12769 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012770 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
12771 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012772 palCopyMemory( pMac->hHdd, pBuf, pParam->operationalRateSet.rate, pParam->operationalRateSet.numRates );
12773 pBuf += pParam->operationalRateSet.numRates ;
12774 *pBuf++ = pParam->extendedRateSet.numRates;
12775 if(0 != pParam->extendedRateSet.numRates)
12776 {
12777 palCopyMemory( pMac->hHdd, pBuf, pParam->extendedRateSet.rate, pParam->extendedRateSet.numRates );
12778 pBuf += pParam->extendedRateSet.numRates;
12779 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012780 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
12781 pMsg->length = pal_cpu_to_be16(msgLen);
12782
12783 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012784 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012785 return( status );
12786}
12787
Jeff Johnson295189b2012-06-20 16:38:30 -070012788eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
12789{
12790 eHalStatus status = eHAL_STATUS_FAILURE;
12791 tSirSmeStopBssReq *pMsg;
12792 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12793 tANI_U8 *pBuf;
12794 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012795
12796 if(!pSession)
12797 {
12798 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12799 return eHAL_STATUS_FAILURE;
12800 }
12801
Jeff Johnson295189b2012-06-20 16:38:30 -070012802 do {
12803 status = palAllocateMemory(pMac, (void **)&pMsg, sizeof(tSirSmeStopBssReq));
12804 if ( !HAL_STATUS_SUCCESS(status) ) break;
12805 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeStopBssReq ));
12806 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
12807 pBuf = &pMsg->sessionId;
12808 //sessionId
12809 *pBuf = (tANI_U8)sessionId;
12810 pBuf++;
12811 // transactionId
12812 *pBuf = 0;
12813 pBuf += sizeof(tANI_U16);
12814 //reason code
12815 *pBuf = 0;
12816 pBuf += sizeof(tSirResultCodes);
12817 // bssid
12818 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
12819 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
12820 {
12821 palCopyMemory( pMac->hHdd, pBuf,(tANI_U8 *)&pSession->selfMacAddr, sizeof(tSirMacAddr) );
12822 }
12823 else
12824 {
12825 palCopyMemory( pMac->hHdd, pBuf,(tANI_U8 *)&pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
12826 }
12827 pBuf += sizeof(tSirMacAddr);
12828 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
12829 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012830 status = palSendMBMessage( pMac->hHdd, pMsg );
12831#if 0
12832 status = palAllocateMemory(pMac, (void **)&pMsg, sizeof(tSirSmeStopBssReq));
12833 if ( !HAL_STATUS_SUCCESS(status) ) break;
12834 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeStopBssReq ));
12835 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
12836 pMsg->reasonCode = 0;
12837 // bssid
12838 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
12839 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
12840 {
12841 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
12842 }
12843 else
12844 {
12845 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
12846 }
12847 palCopyMemory( pMac->hHdd, &pMsg->bssId, pbBssid, sizeof(tSirMacAddr) );
12848 pMsg->transactionId = 0;
12849 pMsg->sessionId = (tANI_U8)sessionId;
12850 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
12851 status = palSendMBMessage( pMac->hHdd, pMsg );
12852#endif
12853 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012854 return( status );
12855}
12856
Jeff Johnson295189b2012-06-20 16:38:30 -070012857eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
12858 tCsrRoamModifyProfileFields *pModProfileFields,
12859 tANI_U32 *pRoamId, v_BOOL_t fForce)
12860{
Jeff Johnson295189b2012-06-20 16:38:30 -070012861 eHalStatus status = eHAL_STATUS_FAILURE;
12862 tANI_U32 roamId = 0;
12863 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012864 if((csrIsConnStateConnected(pMac, sessionId)) &&
12865 (fForce || (!palEqualMemory(pMac->hHdd, &pModProfileFields,
12866 &pSession->connectedProfile.modifyProfileFields,
12867 sizeof(tCsrRoamModifyProfileFields)))) )
12868 {
12869 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
12870 if(pRoamId)
12871 {
12872 *pRoamId = roamId;
12873 }
12874
Jeff Johnson295189b2012-06-20 16:38:30 -070012875 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
12876 eCsrSmeIssuedReassocToSameAP, roamId,
12877 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012878 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012879 return status;
12880}
Jeff Johnson295189b2012-06-20 16:38:30 -070012881static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
12882{
12883 eHalStatus status = eHAL_STATUS_SUCCESS;
12884 tCsrRoamInfo roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070012885 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
12886 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
12887 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
12888 return (status);
12889}
Jeff Johnson295189b2012-06-20 16:38:30 -070012890eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
12891{
12892 eHalStatus status = eHAL_STATUS_SUCCESS;
12893 tListElem *pEntry = NULL;
12894 tSmeCmd *pCommand = NULL;
12895 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012896 do
12897 {
12898 if(pMsg == NULL)
12899 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012900 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012901 status = eHAL_STATUS_FAILURE;
12902 break;
12903 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012904 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
12905 if(pEntry)
12906 {
12907 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
12908 if(eSmeCommandAddStaSession == pCommand->command)
12909 {
12910 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012911 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070012912 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070012913 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070012914 //Remove this command out of the active list
12915 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
12916 {
12917 //Now put this command back on the avilable command list
12918 csrReleaseCommand(pMac, pCommand);
12919 }
12920 smeProcessPendingQueue( pMac );
12921 }
12922 else
12923 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012924 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 -070012925 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012926 status = eHAL_STATUS_FAILURE;
12927 break;
12928 }
12929 }
12930 else
12931 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012932 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 -070012933 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012934 status = eHAL_STATUS_FAILURE;
12935 break;
12936 }
12937 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012938 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012939}
Jeff Johnson295189b2012-06-20 16:38:30 -070012940eHalStatus csrSendMBAddSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
12941{
12942 tSirSmeAddStaSelfReq *pMsg;
12943 tANI_U16 msgLen;
12944 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012945 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070012946 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
12947 sizeof( tSirBssType )*/;
Jeff Johnson295189b2012-06-20 16:38:30 -070012948 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12949 if ( !HAL_STATUS_SUCCESS(status) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012950 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012951 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
12952 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012953 // self station address
12954 palCopyMemory( pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr, sizeof(tSirMacAddr) );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012955 smsLog( pMac, LOG1, FL("selfMac=%02x, %02x, %02x, %02x, %02x, %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -070012956 pMsg->selfMacAddr[0],
12957 pMsg->selfMacAddr[1],
12958 pMsg->selfMacAddr[2],
12959 pMsg->selfMacAddr[3],
12960 pMsg->selfMacAddr[4],
12961 pMsg->selfMacAddr[5]);
12962 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012963 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012964 return( status );
12965}
Jeff Johnson295189b2012-06-20 16:38:30 -070012966eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr sessionMacAddr)
12967{
12968 eHalStatus status = eHAL_STATUS_SUCCESS;
12969 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070012970 pCommand = csrGetCommandBuffer(pMac);
12971 if(NULL == pCommand)
12972 {
12973 status = eHAL_STATUS_RESOURCES;
12974 }
12975 else
12976 {
12977 pCommand->command = eSmeCommandAddStaSession;
12978 pCommand->sessionId = (tANI_U8)sessionId;
12979 palCopyMemory( pMac->hHdd, pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr, sizeof( tSirMacAddr ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070012980 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
12981 if( !HAL_STATUS_SUCCESS( status ) )
12982 {
12983 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012984 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070012985 }
12986 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012987 return (status);
12988}
Jeff Johnson295189b2012-06-20 16:38:30 -070012989eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
12990{
12991 return csrSendMBAddSelfStaReqMsg( pMac,
12992 pCommand->u.addStaSessionCmd.selfMacAddr );
12993}
Jeff Johnson295189b2012-06-20 16:38:30 -070012994eHalStatus csrRoamOpenSession( tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext,
12995 tANI_U8 *pSelfMacAddr, tANI_U8 *pbSessionId )
12996{
12997 eHalStatus status = eHAL_STATUS_SUCCESS;
12998 tANI_U32 i;
12999 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070013000 *pbSessionId = CSR_SESSION_ID_INVALID;
13001 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13002 {
13003 if( !CSR_IS_SESSION_VALID( pMac, i ) )
13004 {
13005 pSession = CSR_GET_SESSION( pMac, i );
13006 status = eHAL_STATUS_SUCCESS;
13007 pSession->sessionActive = eANI_BOOLEAN_TRUE;
13008 pSession->sessionId = (tANI_U8)i;
13009 pSession->callback = callback;
13010 pSession->pContext = pContext;
13011 palCopyMemory( pMac->hHdd, &pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid) );
13012 *pbSessionId = (tANI_U8)i;
Jeff Johnson295189b2012-06-20 16:38:30 -070013013 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerRoaming, csrRoamRoamingTimerHandler,
13014 &pSession->roamingTimerInfo);
13015 if(!HAL_STATUS_SUCCESS(status))
13016 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013017 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013018 break;
13019 }
13020#ifdef FEATURE_WLAN_BTAMP_UT_RF
13021 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerJoinRetry, csrRoamJoinRetryTimerHandler,
13022 &pSession->joinRetryTimerInfo);
13023 if(!HAL_STATUS_SUCCESS(status))
13024 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013025 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013026 break;
13027 }
13028#endif
13029 pSession->ibssJoinTimerInfo.pMac = pMac;
13030 pSession->ibssJoinTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Jeff Johnson295189b2012-06-20 16:38:30 -070013031 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerIbssJoining, csrRoamIbssJoinTimerHandler,
13032 &pSession->ibssJoinTimerInfo);
13033 if(!HAL_STATUS_SUCCESS(status))
13034 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013035 smsLog(pMac, LOGE, FL("cannot allocate memory for IbssJoining timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013036 break;
13037 }
13038 status = csrIssueAddStaForSessionReq ( pMac, i, pSelfMacAddr );
13039 break;
13040 }
13041 }
13042 if( CSR_ROAM_SESSION_MAX == i )
13043 {
13044 //No session is available
13045 status = eHAL_STATUS_RESOURCES;
13046 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013047 return ( status );
13048}
Jeff Johnson295189b2012-06-20 16:38:30 -070013049eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13050{
13051 eHalStatus status = eHAL_STATUS_SUCCESS;
13052 tListElem *pEntry = NULL;
13053 tSmeCmd *pCommand = NULL;
13054 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013055 do
13056 {
13057 if(pMsg == NULL)
13058 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013059 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013060 status = eHAL_STATUS_FAILURE;
13061 break;
13062 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013063 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
13064 if(pEntry)
13065 {
13066 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13067 if(eSmeCommandDelStaSession == pCommand->command)
13068 {
13069 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013070 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013071 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013072 //This session is done.
13073 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013074 if(pCommand->u.delStaSessionCmd.callback)
13075 {
13076
13077 status = sme_ReleaseGlobalLock( &pMac->sme );
13078 if ( HAL_STATUS_SUCCESS( status ) )
13079 {
13080 pCommand->u.delStaSessionCmd.callback(
13081 pCommand->u.delStaSessionCmd.pContext);
13082 status = sme_AcquireGlobalLock( &pMac->sme );
13083 if (! HAL_STATUS_SUCCESS( status ) )
13084 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013085 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013086 return status;
13087 }
13088 }
13089 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013090 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013091 }
13092 }
13093
13094 //Remove this command out of the active list
13095 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
13096 {
13097 //Now put this command back on the avilable command list
13098 csrReleaseCommand(pMac, pCommand);
13099 }
13100 smeProcessPendingQueue( pMac );
13101 }
13102 else
13103 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013104 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 -070013105 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013106 status = eHAL_STATUS_FAILURE;
13107 break;
13108 }
13109 }
13110 else
13111 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013112 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 -070013113 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013114 status = eHAL_STATUS_FAILURE;
13115 break;
13116 }
13117 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013118 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013119}
Jeff Johnson295189b2012-06-20 16:38:30 -070013120eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
13121{
13122 tSirSmeDelStaSelfReq *pMsg;
13123 tANI_U16 msgLen;
13124 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013125 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013126 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
13127 sizeof( tSirBssType )*/;
Jeff Johnson295189b2012-06-20 16:38:30 -070013128 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
13129 if ( !HAL_STATUS_SUCCESS(status) ) break;
13130
13131 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013132 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
13133 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013134 // self station address
13135 palCopyMemory( pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr, sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013136 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013137 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013138 return( status );
13139}
Jeff Johnson295189b2012-06-20 16:38:30 -070013140eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
13141 tSirMacAddr sessionMacAddr,
13142 csrRoamSessionCloseCallback callback,
13143 void *pContext)
13144{
13145 eHalStatus status = eHAL_STATUS_SUCCESS;
13146 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070013147 pCommand = csrGetCommandBuffer(pMac);
13148 if(NULL == pCommand)
13149 {
13150 status = eHAL_STATUS_RESOURCES;
13151 }
13152 else
13153 {
13154 pCommand->command = eSmeCommandDelStaSession;
13155 pCommand->sessionId = (tANI_U8)sessionId;
13156 pCommand->u.delStaSessionCmd.callback = callback;
13157 pCommand->u.delStaSessionCmd.pContext = pContext;
13158 palCopyMemory( pMac->hHdd, pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr, sizeof( tSirMacAddr ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013159 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
13160 if( !HAL_STATUS_SUCCESS( status ) )
13161 {
13162 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013163 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013164 }
13165 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013166 return (status);
13167}
Jeff Johnson295189b2012-06-20 16:38:30 -070013168eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
13169{
13170 return csrSendMBDelSelfStaReqMsg( pMac,
13171 pCommand->u.delStaSessionCmd.selfMacAddr );
13172}
Jeff Johnson295189b2012-06-20 16:38:30 -070013173static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
13174{
13175 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
13176 tListElem *pEntry, *pNext;
13177 tSmeCmd *pCommand;
13178 tDblLinkList localList;
13179
13180 vos_mem_zero(&localList, sizeof(tDblLinkList));
13181 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
13182 {
13183 smsLog(pMac, LOGE, FL(" failed to open list"));
13184 return;
13185 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013186 csrLLLock(pList);
13187 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
13188 while(pEntry != NULL)
13189 {
13190 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
13191 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13192 if(pCommand->sessionId == sessionId)
13193 {
13194 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
13195 {
13196 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
13197 }
13198 }
13199 pEntry = pNext;
13200 }
13201 csrLLUnlock(pList);
13202
13203 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
13204 {
13205 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13206 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
13207 }
13208 csrLLClose(&localList);
13209}
13210
Jeff Johnson295189b2012-06-20 16:38:30 -070013211void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
13212{
13213 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13214 {
13215 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013216 csrRoamStop(pMac, sessionId);
13217 csrFreeConnectBssDesc(pMac, sessionId);
13218 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
13219 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
13220 palTimerFree(pMac->hHdd, pSession->hTimerRoaming);
13221#ifdef FEATURE_WLAN_BTAMP_UT_RF
13222 palTimerFree(pMac->hHdd, pSession->hTimerJoinRetry);
13223#endif
13224 palTimerFree(pMac->hHdd, pSession->hTimerIbssJoining);
13225 purgeSmeSessionCmdList(pMac, sessionId);
13226 purgeCsrSessionCmdList(pMac, sessionId);
13227 csrInitSession(pMac, sessionId);
13228 }
13229}
13230
Jeff Johnson295189b2012-06-20 16:38:30 -070013231eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
13232 tANI_BOOLEAN fSync,
13233 csrRoamSessionCloseCallback callback,
13234 void *pContext )
13235{
13236 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013237 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13238 {
13239 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13240 if(fSync)
13241 {
13242 csrCleanupSession(pMac, sessionId);
13243 }
13244 else
13245 {
13246 purgeSmeSessionCmdList(pMac, sessionId);
13247 purgeCsrSessionCmdList(pMac, sessionId);
13248 status = csrIssueDelStaForSessionReq( pMac, sessionId,
13249 pSession->selfMacAddr, callback, pContext);
13250 }
13251 }
13252 else
13253 {
13254 status = eHAL_STATUS_INVALID_PARAMETER;
13255 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013256 return ( status );
13257}
13258
Jeff Johnson295189b2012-06-20 16:38:30 -070013259static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
13260{
13261 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013262
13263 if(!pSession)
13264 {
13265 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13266 return;
13267 }
13268
Jeff Johnson295189b2012-06-20 16:38:30 -070013269 pSession->sessionActive = eANI_BOOLEAN_FALSE;
13270 pSession->sessionId = CSR_SESSION_ID_INVALID;
13271 pSession->callback = NULL;
13272 pSession->pContext = NULL;
13273 pSession->ibss_join_pending = FALSE;
13274 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
13275 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
13276 csrFreeRoamProfile( pMac, sessionId );
13277 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
13278 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
13279 csrFreeConnectBssDesc(pMac, sessionId);
13280 csrScanEnable(pMac);
13281 palZeroMemory( pMac->hHdd, &pSession->selfMacAddr, sizeof(tCsrBssid) );
13282 if(pSession->pWpaRsnReqIE)
13283 {
13284 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
13285 pSession->pWpaRsnReqIE = NULL;
13286 }
13287 pSession->nWpaRsnReqIeLength = 0;
13288 if(pSession->pWpaRsnRspIE)
13289 {
13290 palFreeMemory(pMac->hHdd, pSession->pWpaRsnRspIE);
13291 pSession->pWpaRsnRspIE = NULL;
13292 }
13293 pSession->nWpaRsnRspIeLength = 0;
13294#ifdef FEATURE_WLAN_WAPI
13295 if(pSession->pWapiReqIE)
13296 {
13297 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
13298 pSession->pWapiReqIE = NULL;
13299 }
13300 pSession->nWapiReqIeLength = 0;
13301 if(pSession->pWapiRspIE)
13302 {
13303 palFreeMemory(pMac->hHdd, pSession->pWapiRspIE);
13304 pSession->pWapiRspIE = NULL;
13305 }
13306 pSession->nWapiRspIeLength = 0;
13307#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070013308 if(pSession->pAddIEScan)
13309 {
13310 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
13311 pSession->pAddIEScan = NULL;
13312 }
13313 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013314 if(pSession->pAddIEAssoc)
13315 {
13316 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
13317 pSession->pAddIEAssoc = NULL;
13318}
13319 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013320}
13321
Jeff Johnson295189b2012-06-20 16:38:30 -070013322eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
13323{
13324 eHalStatus status = eHAL_STATUS_FAILURE;
13325 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070013326 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13327 {
13328 if( CSR_IS_SESSION_VALID( pMac, i ) )
13329 {
13330 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
13331 {
13332 //Found it
13333 status = eHAL_STATUS_SUCCESS;
13334 *pSessionId = i;
13335 break;
13336 }
13337 }
13338 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013339 return( status );
13340}
13341
Jeff Johnson295189b2012-06-20 16:38:30 -070013342//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
13343//session because for IBSS, the bssid changes.
13344static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
13345{
13346 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
13347 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070013348 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13349 {
13350 if( CSR_IS_SESSION_VALID( pMac, i ) )
13351 {
13352 pSession = CSR_GET_SESSION( pMac, i );
13353 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
13354 {
13355 //Found it
13356 nRet = i;
13357 break;
13358 }
13359 }
13360 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013361 return (nRet);
13362}
Jeff Johnson295189b2012-06-20 16:38:30 -070013363static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
13364{
13365 /* Update the current BSS info in ho control block based on connected
13366 profile info from pmac global structure */
13367
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013368 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -070013369 bssid[ 0 ], bssid[ 1 ], bssid[ 2 ],
13370 bssid[ 3 ], bssid[ 4 ], bssid[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -070013371 /* Check for user misconfig of RSSI trigger threshold */
13372 pMac->roam.configParam.vccRssiThreshold =
13373 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
13374 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
13375 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070013376 /* Check for user misconfig of UL MAC Loss trigger threshold */
13377 pMac->roam.configParam.vccUlMacLossThreshold =
13378 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
13379 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070013380#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13381 {
13382 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013383 /* Indicate the neighbor roal algorithm about the connect indication */
13384 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
13385 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
13386 }
13387#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013388}
13389
Jeff Johnson295189b2012-06-20 16:38:30 -070013390static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
13391{
13392 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013393
13394 if(!pSession)
13395 {
13396 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13397 return;
13398 }
13399
Jeff Johnson295189b2012-06-20 16:38:30 -070013400 //Only to handle the case for Handover on infra link
13401 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
13402 {
13403 return;
13404 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013405 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
13406 csrRoamDeregStatisticsReq(pMac);
13407 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
13408#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13409 /* Indicate the neighbor roal algorithm about the disconnect indication */
13410 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
13411#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070013412
13413 //Remove this code once SLM_Sessionization is supported
13414 //BMPS_WORKAROUND_NOT_NEEDED
13415 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070013416 csrIsInfraApStarted( pMac ) &&
13417 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070013418 {
13419 pMac->roam.configParam.doBMPSWorkaround = 0;
13420 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013421}
13422
Jeff Johnson295189b2012-06-20 16:38:30 -070013423void csrRoamTlStatsTimerHandler(void *pv)
13424{
13425 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
13426 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013427 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
13428
Jeff Johnsone7245742012-09-05 17:12:55 -070013429 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
13430
Jeff Johnson295189b2012-06-20 16:38:30 -070013431#if 0
13432 // TODO Persession .???
13433 //req TL for stats
13434 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
13435 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013436 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013437 }
13438 else
13439 {
13440 //save in SME
13441 csrRoamSaveStatsFromTl(pMac, tlStats);
13442 }
13443#endif
13444 if(!pMac->roam.tlStatsReqInfo.timerRunning)
13445 {
13446 if(pMac->roam.tlStatsReqInfo.periodicity)
13447 {
13448 //start timer
13449 status = palTimerStart(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer,
13450 pMac->roam.tlStatsReqInfo.periodicity * PAL_TIMER_TO_MS_UNIT, eANI_BOOLEAN_FALSE);
13451 if(!HAL_STATUS_SUCCESS(status))
13452 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013453 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013454 return;
13455 }
13456 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
13457 }
13458 }
13459}
Jeff Johnson295189b2012-06-20 16:38:30 -070013460void csrRoamPeStatsTimerHandler(void *pv)
13461{
13462 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
13463 eHalStatus status;
13464 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
13465 VOS_STATUS vosStatus;
13466 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070013467 pPeStatsReqListEntry->timerRunning = FALSE;
13468 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
13469 {
13470 // If we entered here, meaning the timer could not be successfully
13471 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
13472
13473 /* Destroy the timer */
13474 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
13475 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13476 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013477 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013478 }
13479
13480 // Free the entry
13481 palFreeMemory(pMac->hHdd, pPeStatsReqListEntry);
13482 pPeStatsReqListEntry = NULL;
13483 }
13484 else
13485 {
13486 if(!pPeStatsReqListEntry->rspPending)
13487 {
13488 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
13489 pPeStatsReqListEntry->staId);
13490 if(!HAL_STATUS_SUCCESS(status))
13491 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013492 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013493 }
13494 else
13495 {
13496 pPeStatsReqListEntry->rspPending = TRUE;
13497 }
13498 }
13499
13500 //send down a req
13501 if(pPeStatsReqListEntry->periodicity &&
13502 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
13503 {
13504 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
13505 if(ePMC_FULL_POWER == powerState)
13506 {
13507 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
13508 {
13509 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
13510 }
13511 }
13512 else
13513 {
13514 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
13515 {
13516 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
13517 }
13518 }
13519 //start timer
13520 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
13521 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13522 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013523 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013524 return;
13525 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013526 pPeStatsReqListEntry->timerRunning = TRUE;
13527
13528 }
13529
13530 }
13531}
Jeff Johnson295189b2012-06-20 16:38:30 -070013532void csrRoamStatsClientTimerHandler(void *pv)
13533{
13534 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070013535 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
13536 {
13537#if 0
13538 // TODO Stats fix for multisession
13539 //start the timer
13540 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
13541
13542 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13543 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013544 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013545 }
13546#endif
13547 }
13548#if 0
13549 //send up the stats report
13550 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
13551 pStaEntry->staId, pStaEntry->pContext);
13552#endif
13553}
13554
13555
13556
Jeff Johnson295189b2012-06-20 16:38:30 -070013557eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
13558{
13559 tAniGetPEStatsReq *pMsg;
13560 eHalStatus status = eHAL_STATUS_SUCCESS;
13561 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetPEStatsReq));
13562 if ( !HAL_STATUS_SUCCESS(status) )
13563 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013564 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to allocate mem for stats req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070013565 return status;
13566 }
13567 // need to initiate a stats request to PE
13568 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
13569 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
13570 pMsg->staId = staId;
13571 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070013572 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013573 if(!HAL_STATUS_SUCCESS(status))
13574 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013575 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to send down the stats req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070013576 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013577 return status;
13578}
Jeff Johnson295189b2012-06-20 16:38:30 -070013579void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
13580{
13581 tAniGetPEStatsRsp *pSmeStatsRsp;
13582 eHalStatus status = eHAL_STATUS_FAILURE;
13583 tListElem *pEntry = NULL;
13584 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
13585 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
13586 tANI_U32 tempMask = 0;
13587 tANI_U8 counter = 0;
13588 tANI_U8 *pStats = NULL;
13589 tANI_U32 length = 0;
13590 v_PVOID_t pvosGCtx;
13591 v_S7_t rssi = 0;
13592 tANI_U32 *pRssi = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013593 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
13594 if(pSmeStatsRsp->rc)
13595 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013596 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013597 goto post_update;
13598 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013599 tempMask = pSmeStatsRsp->statsMask;
13600 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070013601 /* subtract all statistics from this length, and after processing the entire
13602 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
13603 * in this 'stats' message.
13604 */
13605 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070013606 //new stats info from PE, fill up the stats strucutres in PMAC
13607 while(tempMask)
13608 {
13609 if(tempMask & 1)
13610 {
13611 switch(counter)
13612 {
13613 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013614 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013615 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
13616 pStats, sizeof(tCsrSummaryStatsInfo));
13617 if(!HAL_STATUS_SUCCESS(status))
13618 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013619 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013620 }
13621 pStats += sizeof(tCsrSummaryStatsInfo);
13622 length -= sizeof(tCsrSummaryStatsInfo);
13623 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013624 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013625 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013626 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classAStatsInfo,
13627 pStats, sizeof(tCsrGlobalClassAStatsInfo));
13628 if(!HAL_STATUS_SUCCESS(status))
13629 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013630 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013631 }
13632 pStats += sizeof(tCsrGlobalClassAStatsInfo);
13633 length -= sizeof(tCsrGlobalClassAStatsInfo);
13634 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013635 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013636 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013637 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classBStatsInfo,
13638 pStats, sizeof(tCsrGlobalClassBStatsInfo));
13639 if(!HAL_STATUS_SUCCESS(status))
13640 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013641 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013642 }
13643 pStats += sizeof(tCsrGlobalClassBStatsInfo);
13644 length -= sizeof(tCsrGlobalClassBStatsInfo);
13645 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013646 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013647 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013648 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classCStatsInfo,
13649 pStats, sizeof(tCsrGlobalClassCStatsInfo));
13650 if(!HAL_STATUS_SUCCESS(status))
13651 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013652 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013653 }
13654 pStats += sizeof(tCsrGlobalClassCStatsInfo);
13655 length -= sizeof(tCsrGlobalClassCStatsInfo);
13656 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013657 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013658 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013659 if( CSR_MAX_STA > pSmeStatsRsp->staId )
13660 {
13661 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
13662 pStats, sizeof(tCsrPerStaStatsInfo));
13663 }
13664 else
13665 {
13666 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013667 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013668 VOS_ASSERT( 0 );
13669 }
13670 if(!HAL_STATUS_SUCCESS(status))
13671 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013672 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013673 }
13674 pStats += sizeof(tCsrPerStaStatsInfo);
13675 length -= sizeof(tCsrPerStaStatsInfo);
13676 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013677 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013678 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013679 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013680 }
13681 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013682 tempMask >>=1;
13683 counter++;
13684 }
13685 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
13686 if (length != 0)
13687 {
13688 pRssi = (tANI_U32*)pStats;
13689 rssi = (v_S7_t)*pRssi;
13690 }
13691 else
13692 {
13693 /* If riva is not sending rssi, continue to use the hack */
13694 rssi = RSSI_HACK_BMPS;
13695 }
13696 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Jeff Johnson295189b2012-06-20 16:38:30 -070013697post_update:
13698 //make sure to update the pe stats req list
13699 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
13700 if(pEntry)
13701 {
13702 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
13703 pPeStaEntry->rspPending = FALSE;
13704
13705 }
13706 //check the one timer cases
13707 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
13708 if(pEntry)
13709 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013710 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013711 if(pTempStaEntry->timerExpired)
13712 {
13713 //send up the stats report
13714 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
13715 pTempStaEntry->staId, pTempStaEntry->pContext);
13716 //also remove from the client list
13717 csrRoamRemoveStatListEntry(pMac, pEntry);
13718 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013719 }
13720 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013721}
Jeff Johnson295189b2012-06-20 16:38:30 -070013722tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
13723{
13724 tListElem *pEntry = NULL;
13725 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013726 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070013727 if(!pEntry)
13728 {
13729 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013730 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070013731 return NULL;
13732 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013733 while( pEntry )
13734 {
13735 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013736 if(pTempStaEntry->statsMask == statsMask)
13737 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013738 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070013739 break;
13740 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013741 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
13742 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013743 return pEntry;
13744}
13745
Jeff Johnson295189b2012-06-20 16:38:30 -070013746tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
13747 tANI_BOOLEAN update)
13748{
13749 tListElem *pEntry;
13750 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070013751 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070013752 if(!pEntry)
13753 {
13754 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070013755 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013756 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070013757 return NULL;
13758 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013759 while( pEntry )
13760 {
13761 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013762 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
13763 (pTempStaEntry->statsMask == pStaEntry->statsMask))
13764 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013765 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070013766 if(update)
13767 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013768 pTempStaEntry->periodicity = pStaEntry->periodicity;
13769 pTempStaEntry->callback = pStaEntry->callback;
13770 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070013771 }
13772 break;
13773 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013774 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
13775 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013776 return pEntry;
13777}
Jeff Johnson295189b2012-06-20 16:38:30 -070013778tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
13779{
13780 tListElem *pEntry;
13781 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070013782 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070013783 if(!pEntry)
13784 {
13785 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070013786 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013787 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070013788 return NULL;
13789 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013790 while( pEntry )
13791 {
13792 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013793 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
13794 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013795 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070013796 break;
13797 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013798 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
13799 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013800 return pEntry;
13801}
Jeff Johnson295189b2012-06-20 16:38:30 -070013802eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
13803 csrRoamLinkQualityIndCallback callback,
13804 void *pContext)
13805{
13806 pMac->roam.linkQualityIndInfo.callback = callback;
13807 pMac->roam.linkQualityIndInfo.context = pContext;
13808 if( NULL == callback )
13809 {
13810 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
13811 }
13812 else
13813 {
13814 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070013815 /* do we need to invoke the callback to notify client of initial value ?? */
13816 }
13817 return eHAL_STATUS_SUCCESS;
13818}
Jeff Johnson295189b2012-06-20 16:38:30 -070013819void csrRoamVccTrigger(tpAniSirGlobal pMac)
13820{
13821 eCsrRoamLinkQualityInd newVccLinkQuality;
13822 tANI_U32 ul_mac_loss = 0;
13823 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070013824 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
13825 /*-------------------------------------------------------------------------
13826 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070013827 Check for a change in link quality and notify client if necessary
13828 -------------------------------------------------------------------------*/
13829 ul_mac_loss_trigger_threshold =
13830 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070013831 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013832 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070013833 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070013834 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
13835 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013836 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070013837 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
13838 }
13839 else
13840 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013841 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070013842 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
13843 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013844 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
13845 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070013846 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
13847 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013848 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070013849 if(NULL != pMac->roam.linkQualityIndInfo.callback)
13850 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013851 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070013852 newVccLinkQuality );
13853
13854 /* we now invoke the callback once to notify client of initial value */
13855 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
13856 pMac->roam.linkQualityIndInfo.context );
13857 //event: EVENT_WLAN_VCC
13858 }
13859 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013860 pMac->roam.vccLinkQuality = newVccLinkQuality;
13861
Jeff Johnson295189b2012-06-20 16:38:30 -070013862}
Jeff Johnson295189b2012-06-20 16:38:30 -070013863VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
13864 v_U8_t rssiNotification,
13865 void * context)
13866{
13867 tpAniSirGlobal pMac = PMAC_STRUCT( context );
13868 eCsrRoamLinkQualityInd newVccLinkQuality;
13869 // TODO : Session info unavailable
13870 tANI_U32 sessionId = 0;
13871 VOS_STATUS status = VOS_STATUS_SUCCESS;
13872 /*-------------------------------------------------------------------------
13873 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070013874 Check for a change in link quality and notify client if necessary
13875 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013876 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070013877 pMac->roam.configParam.vccRssiThreshold);
13878 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
13879 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013880 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070013881 return VOS_STATUS_SUCCESS;
13882 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013883 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
13884 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013885 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070013886 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
13887 }
13888 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
13889 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013890 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070013891 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
13892 }
13893 else
13894 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013895 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070013896 //Set to this so the code below won't do anything
13897 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070013898 VOS_ASSERT(0);
13899 }
13900
Jeff Johnson295189b2012-06-20 16:38:30 -070013901 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
13902 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013903 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070013904 if(NULL != pMac->roam.linkQualityIndInfo.callback)
13905 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013906 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070013907 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070013908 /* we now invoke the callback once to notify client of initial value */
13909 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
13910 pMac->roam.linkQualityIndInfo.context );
13911 //event: EVENT_WLAN_VCC
13912 }
13913 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013914 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070013915 return status;
13916}
Jeff Johnson295189b2012-06-20 16:38:30 -070013917tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
13918 tDblLinkList *pStaList,
13919 tCsrStatsClientReqInfo *pStaEntry)
13920{
13921 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013922 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013923 //if same entity requested for same set of stats with different periodicity &
13924 // callback update it
13925 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
13926 {
13927
13928 status = palAllocateMemory(pMac->hHdd, (void **)&pNewStaEntry, sizeof(tCsrStatsClientReqInfo));
13929 if (!HAL_STATUS_SUCCESS(status))
13930 {
13931 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013932 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070013933 return NULL;
13934 }
13935
Jeff Johnson295189b2012-06-20 16:38:30 -070013936 pNewStaEntry->callback = pStaEntry->callback;
13937 pNewStaEntry->pContext = pStaEntry->pContext;
13938 pNewStaEntry->periodicity = pStaEntry->periodicity;
13939 pNewStaEntry->requesterId = pStaEntry->requesterId;
13940 pNewStaEntry->statsMask = pStaEntry->statsMask;
13941 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
13942 pNewStaEntry->pMac = pStaEntry->pMac;
13943 pNewStaEntry->staId = pStaEntry->staId;
13944 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
13945
13946 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
13947 }
13948 return pNewStaEntry;
13949}
13950
Jeff Johnson295189b2012-06-20 16:38:30 -070013951tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
13952 tDblLinkList *pStaList,
13953 tCsrPeStatsReqInfo *pStaEntry)
13954{
13955 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013956 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013957 status = palAllocateMemory(pMac->hHdd, (void **)&pNewStaEntry, sizeof(tCsrPeStatsReqInfo));
13958 if (!HAL_STATUS_SUCCESS(status))
13959 {
13960 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013961 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070013962 return NULL;
13963 }
13964
Jeff Johnson295189b2012-06-20 16:38:30 -070013965 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
13966 pNewStaEntry->numClient = pStaEntry->numClient;
13967 pNewStaEntry->periodicity = pStaEntry->periodicity;
13968 pNewStaEntry->statsMask = pStaEntry->statsMask;
13969 pNewStaEntry->pMac = pStaEntry->pMac;
13970 pNewStaEntry->staId = pStaEntry->staId;
13971 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
13972 pNewStaEntry->rspPending = pStaEntry->rspPending;
13973
13974 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070013975 return pNewStaEntry;
13976}
Jeff Johnson295189b2012-06-20 16:38:30 -070013977eHalStatus csrGetRssi(tpAniSirGlobal pMac,
13978 tCsrRssiCallback callback,
13979 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
13980{
13981 eHalStatus status = eHAL_STATUS_SUCCESS;
13982 vos_msg_t msg;
13983 tANI_U32 sessionId;
13984
13985 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013986 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013987 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetRssiReq));
13988 if ( !HAL_STATUS_SUCCESS(status) )
13989 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013990 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070013991 return status;
13992 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013993 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
13994
13995 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
13996 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
13997 pMsg->sessionId = sessionId;
13998 pMsg->staId = staId;
13999 pMsg->rssiCallback = callback;
14000 pMsg->pDevContext = pContext;
14001 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014002 msg.type = eWNI_SME_GET_RSSI_REQ;
14003 msg.bodyptr = pMsg;
14004 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014005 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
14006 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014007 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014008 palFreeMemory(pMac->hHdd, (void *)pMsg);
14009 status = eHAL_STATUS_FAILURE;
14010 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014011 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014012 return status;
14013}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014014
14015#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
14016eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
14017 tCsrRssiCallback callback,
14018 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
14019{
14020 eHalStatus status = eHAL_STATUS_SUCCESS;
14021 tAniGetRssiReq *pMsg;
14022
14023 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetRssiReq));
14024 if ( !HAL_STATUS_SUCCESS(status) )
14025 {
14026 smsLog(pMac, LOGE, " csrGetRoamRssi: failed to allocate mem for req");
14027 return status;
14028 }
14029 // need to initiate a stats request to PE
14030 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
14031 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
14032 pMsg->staId = staId;
14033 pMsg->rssiCallback = callback;
14034 pMsg->pDevContext = pContext;
14035 pMsg->pVosContext = pVosContext;
14036 status = palSendMBMessage(pMac->hHdd, pMsg );
14037 if(!HAL_STATUS_SUCCESS(status))
14038 {
14039 smsLog(pMac, LOG1, " csrGetRoamRssi: failed to send down the stats req");
14040 palFreeMemory(pMac->hHdd, (void *)pMsg);
14041 status = eHAL_STATUS_FAILURE;
14042 }
14043 return status;
14044}
14045#endif
14046
Jeff Johnson295189b2012-06-20 16:38:30 -070014047eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
14048 tANI_U32 statsMask,
14049 tCsrStatsCallback callback,
14050 tANI_U32 periodicity, tANI_BOOLEAN cache,
14051 tANI_U8 staId, void *pContext)
14052{
14053 tCsrStatsClientReqInfo staEntry;
14054 tCsrStatsClientReqInfo *pStaEntry = NULL;
14055 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
14056 tListElem *pEntry = NULL;
14057 tANI_BOOLEAN found = FALSE;
14058 eHalStatus status = eHAL_STATUS_SUCCESS;
14059 tANI_BOOLEAN insertInClientList = FALSE;
14060 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070014061 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070014062
14063 if( csrIsAllSessionDisconnected(pMac) )
14064 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014065 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070014066 return eHAL_STATUS_FAILURE;
14067 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014068 if((!statsMask) && (!callback))
14069 {
14070 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014071 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070014072 return eHAL_STATUS_FAILURE;
14073 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014074 //for the search list method for deregister
14075 staEntry.requesterId = requesterId;
14076 staEntry.statsMask = statsMask;
14077 //requester wants to deregister or just an error
14078 if((statsMask) && (!callback))
14079 {
14080 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
14081 if(!pEntry)
14082 {
14083 //msg
14084 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014085 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070014086 return eHAL_STATUS_FAILURE;
14087 }
14088 else
14089 {
14090 //clean up & return
14091 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070014092 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070014093 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014094 pStaEntry->pPeStaEntry->numClient--;
14095 //check if we need to delete the entry from peStatsReqList too
14096 if(!pStaEntry->pPeStaEntry->numClient)
14097 {
14098 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
14099 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014100 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070014101
Jeff Johnson295189b2012-06-20 16:38:30 -070014102 //check if we need to stop the tl stats timer too
14103 pMac->roam.tlStatsReqInfo.numClient--;
14104 if(!pMac->roam.tlStatsReqInfo.numClient)
14105 {
14106 if(pMac->roam.tlStatsReqInfo.timerRunning)
14107 {
14108 status = palTimerStop(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
14109 if(!HAL_STATUS_SUCCESS(status))
14110 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014111 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014112 return eHAL_STATUS_FAILURE;
14113 }
14114 }
14115 pMac->roam.tlStatsReqInfo.periodicity = 0;
14116 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14117 }
14118 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070014119 // Destroy the vos timer...
14120 vosStatus = vos_timer_destroy( &pStaEntry->timer );
14121 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14122 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014123 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014124 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014125 csrRoamRemoveStatListEntry(pMac, pEntry);
14126 pStaEntry = NULL;
14127 return eHAL_STATUS_SUCCESS;
14128 }
14129 }
14130
14131 if(cache && !periodicity)
14132 {
14133 //return the cached stats
14134 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
14135 }
14136 else
14137 {
14138 //add the request in the client req list
14139 staEntry.callback = callback;
14140 staEntry.pContext = pContext;
14141 staEntry.periodicity = periodicity;
14142 staEntry.pPeStaEntry = NULL;
14143 staEntry.staId = staId;
14144 staEntry.pMac = pMac;
14145 staEntry.timerExpired = FALSE;
14146
14147
Jeff Johnson295189b2012-06-20 16:38:30 -070014148 //if periodic report requested with non cached result from PE/TL
14149 if(periodicity)
14150 {
14151
14152 //if looking for stats from PE
14153 if(statsMask & ~(1 << eCsrGlobalClassDStats))
14154 {
14155
14156 //check if same request made already & waiting for rsp
14157 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
14158 periodicity, &found, staId);
14159 if(!pPeStaEntry)
14160 {
14161 //bail out, maxed out on number of req for PE
14162 return eHAL_STATUS_FAILURE;
14163 }
14164 else
14165 {
14166 staEntry.pPeStaEntry = pPeStaEntry;
14167 }
14168
14169 }
14170 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
14171 if(statsMask & (1 << eCsrGlobalClassDStats))
14172 {
14173 if(cache && pMac->roam.tlStatsReqInfo.numClient)
14174 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014175 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014176 }
14177 else
14178 {
14179
14180 //update periodicity
14181 if(pMac->roam.tlStatsReqInfo.periodicity)
14182 {
14183 pMac->roam.tlStatsReqInfo.periodicity =
14184 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
14185 }
14186 else
14187 {
14188 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
14189 }
14190 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
14191 {
14192 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
14193 }
14194
14195 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14196 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014197 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
14198 if(NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014199 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014200 //req TL for class D stats
14201 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
14202 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014203 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070014204 }
14205 else
14206 {
14207 //save in SME
14208 csrRoamSaveStatsFromTl(pMac, pTlStats);
14209 }
14210 vos_mem_free(pTlStats);
14211 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014212 }
14213 else
14214 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014215 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014216 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014217
Jeff Johnson295189b2012-06-20 16:38:30 -070014218 if(pMac->roam.tlStatsReqInfo.periodicity)
14219 {
14220 //start timer
14221 status = palTimerStart(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14222 pMac->roam.tlStatsReqInfo.periodicity * PAL_TIMER_TO_MS_UNIT, eANI_BOOLEAN_FALSE);
14223 if(!HAL_STATUS_SUCCESS(status))
14224 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014225 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014226 return eHAL_STATUS_FAILURE;
14227 }
14228 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14229 }
14230 }
14231 }
14232 pMac->roam.tlStatsReqInfo.numClient++;
14233 }
14234
14235 insertInClientList = TRUE;
14236 }
14237 //if one time report requested with non cached result from PE/TL
14238 else if(!cache && !periodicity)
14239 {
14240 if(statsMask & ~(1 << eCsrGlobalClassDStats))
14241 {
14242 //send down a req
14243 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
14244 if(!HAL_STATUS_SUCCESS(status))
14245 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014246 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014247 }
14248 //so that when the stats rsp comes back from PE we respond to upper layer
14249 //right away
14250 staEntry.timerExpired = TRUE;
14251 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014252 }
14253 if(statsMask & (1 << eCsrGlobalClassDStats))
14254 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014255 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
14256 if(NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014257 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014258 //req TL for class D stats
14259 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
14260 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014261 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070014262 }
14263 else
14264 {
14265 //save in SME
14266 csrRoamSaveStatsFromTl(pMac, pTlStats);
14267 }
14268 vos_mem_free(pTlStats);
14269 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014270 }
14271 else
14272 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014273 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014274 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014275
14276 }
14277 //if looking for stats from TL only
14278 if(!insertInClientList)
14279 {
14280 //return the stats
14281 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
14282 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014283 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014284 if(insertInClientList)
14285 {
14286 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
14287 if(!pStaEntry)
14288 {
14289 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014290 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070014291 return eHAL_STATUS_FAILURE;
14292 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014293 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070014294 //Init & start timer if needed
14295 if(periodicity)
14296 {
14297 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
14298 csrRoamStatsClientTimerHandler, pStaEntry );
14299 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14300 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014301 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014302 return eHAL_STATUS_FAILURE;
14303 }
14304 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
14305 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14306 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014307 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014308 return eHAL_STATUS_FAILURE;
14309 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014310 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014311 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014312 }
14313 return eHAL_STATUS_SUCCESS;
14314}
14315
Jeff Johnson295189b2012-06-20 16:38:30 -070014316tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
14317 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
14318{
14319 tANI_BOOLEAN found = FALSE;
14320 eHalStatus status = eHAL_STATUS_SUCCESS;
14321 tCsrPeStatsReqInfo staEntry;
14322 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
14323 tListElem *pStaEntry = NULL;
14324 VOS_STATUS vosStatus;
14325 tPmcPowerState powerState;
14326 *pFound = FALSE;
14327
14328 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
14329 if(pStaEntry)
14330 {
14331 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
14332 if(pTempStaEntry->periodicity)
14333 {
14334 pTempStaEntry->periodicity =
14335 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
14336 }
14337 else
14338 {
14339 pTempStaEntry->periodicity = periodicity;
14340 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014341 pTempStaEntry->numClient++;
14342 found = TRUE;
14343 }
14344 else
14345 {
14346 palZeroMemory(pMac->hHdd, &staEntry, sizeof(tCsrPeStatsReqInfo));
14347 staEntry.numClient = 1;
14348 staEntry.periodicity = periodicity;
14349 staEntry.pMac = pMac;
14350 staEntry.rspPending = FALSE;
14351 staEntry.staId = staId;
14352 staEntry.statsMask = statsMask;
14353 staEntry.timerRunning = FALSE;
14354 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
14355 if(!pTempStaEntry)
14356 {
14357 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014358 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070014359 return NULL;
14360 }
14361 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014362 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
14363 if(ePMC_FULL_POWER == powerState)
14364 {
14365 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
14366 {
14367 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
14368 }
14369 }
14370 else
14371 {
14372 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
14373 {
14374 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
14375 }
14376 }
14377 if(!pTempStaEntry->timerRunning)
14378 {
14379 //send down a req in case of one time req, for periodic ones wait for timer to expire
14380 if(!pTempStaEntry->rspPending &&
14381 !pTempStaEntry->periodicity)
14382 {
14383 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
14384 if(!HAL_STATUS_SUCCESS(status))
14385 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014386 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014387 }
14388 else
14389 {
14390 pTempStaEntry->rspPending = TRUE;
14391 }
14392 }
14393 if(pTempStaEntry->periodicity)
14394 {
14395 if(!found)
14396 {
14397
14398 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
14399 csrRoamPeStatsTimerHandler, pTempStaEntry );
14400 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14401 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014402 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014403 return NULL;
14404 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014405 }
14406 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014407 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070014408 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
14409 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14410 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014411 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014412 return NULL;
14413 }
14414 pTempStaEntry->timerRunning = TRUE;
14415 }
14416 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014417 *pFound = found;
14418 return pTempStaEntry;
14419}
14420
Jeff Johnson295189b2012-06-20 16:38:30 -070014421/*
14422 pStaEntry is no longer invalid upon the return of this function.
14423*/
14424static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
14425{
14426 if(pEntry)
14427 {
14428 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
14429 {
14430 palFreeMemory(pMac->hHdd, GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070014431 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014432 }
14433 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014434
14435void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
14436{
14437 tListElem *pEntry;
14438 tCsrPeStatsReqInfo *pTempStaEntry;
14439 VOS_STATUS vosStatus;
14440 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014441 if(!pEntry)
14442 {
14443 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014444 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: List empty, no stats req for PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070014445 return;
14446 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014447 while( pEntry )
14448 {
14449 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014450 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
14451 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014452 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014453 if(pTempStaEntry->timerRunning)
14454 {
14455 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
14456 /* If we are not able to stop the timer here, just remove
14457 * the entry from the linked list. Destroy the timer object
14458 * and free the memory in the timer CB
14459 */
14460 if( vosStatus == VOS_STATUS_SUCCESS )
14461 {
14462 /* the timer is successfully stopped */
14463 pTempStaEntry->timerRunning = FALSE;
14464
14465 /* Destroy the timer */
14466 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
14467 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14468 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014469 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014470 }
14471 }
14472 else
14473 {
14474 // the timer could not be stopped. Hence destroy and free the
14475 // memory for the PE stat entry in the timer CB.
14476 pTempStaEntry->timerStopFailed = TRUE;
14477 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014478 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014479
14480 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
14481 {
14482 // Only free the memory if we could stop the timer successfully
14483 if(!pTempStaEntry->timerStopFailed)
14484 {
14485 palFreeMemory(pMac->hHdd, pTempStaEntry);
14486 pTempStaEntry = NULL;
14487 }
14488 break;
14489 }
14490
14491 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
14492 }
14493 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014494 return;
14495}
14496
14497
Jeff Johnsone7245742012-09-05 17:12:55 -070014498void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014499{
14500
Jeff Johnsone7245742012-09-05 17:12:55 -070014501 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
14502 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
14503 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
14504 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
14505 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
14506 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
14507 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070014508 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070014509 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
14510 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
14511 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
14512 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
14513 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
14514 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070014515 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070014516 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
14517 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070014518
14519}
14520
Jeff Johnson295189b2012-06-20 16:38:30 -070014521void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
14522 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
14523{
14524 tANI_U8 stats[500];
14525 tANI_U8 *pStats = NULL;
14526 tANI_U32 tempMask = 0;
14527 tANI_U8 counter = 0;
14528 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014529 if(!callback)
14530 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014531 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014532 return;
14533 }
14534 if(!statsMask)
14535 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014536 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014537 return;
14538 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014539 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070014540 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070014541 while(tempMask)
14542 {
14543 if(tempMask & 1)
14544 {
14545 //new stats info from PE, fill up the stats strucutres in PMAC
14546 switch(counter)
14547 {
14548 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014549 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014550 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
14551 sizeof(tCsrSummaryStatsInfo));
14552 if(!HAL_STATUS_SUCCESS(status))
14553 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014554 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy summary stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014555 }
14556 pStats += sizeof(tCsrSummaryStatsInfo);
14557 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014558 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014559 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014560 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
14561 sizeof(tCsrGlobalClassAStatsInfo));
14562 if(!HAL_STATUS_SUCCESS(status))
14563 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014564 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassA stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014565 }
14566 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070014567 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014568 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014569 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014570 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
14571 sizeof(tCsrGlobalClassBStatsInfo));
14572 if(!HAL_STATUS_SUCCESS(status))
14573 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014574 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassB stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014575 }
14576 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070014577 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014578 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014579 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014580 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
14581 sizeof(tCsrGlobalClassCStatsInfo));
14582 if(!HAL_STATUS_SUCCESS(status))
14583 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014584 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassC stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014585 }
14586 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070014587 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014588 case eCsrGlobalClassDStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014589 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassD stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014590 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
14591 sizeof(tCsrGlobalClassDStatsInfo));
14592 if(!HAL_STATUS_SUCCESS(status))
14593 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014594 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassD stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014595 }
14596 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070014597 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014598 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014599 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014600 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
14601 sizeof(tCsrPerStaStatsInfo));
14602 if(!HAL_STATUS_SUCCESS(status))
14603 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014604 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014605 }
14606 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070014607 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014608 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014609 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014610 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014611 }
14612 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014613 tempMask >>=1;
14614 counter++;
14615 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014616 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070014617}
14618
Jeff Johnson295189b2012-06-20 16:38:30 -070014619eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
14620{
14621 tListElem *pEntry = NULL;
14622 tListElem *pPrevEntry = NULL;
14623 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
14624 eHalStatus status = eHAL_STATUS_SUCCESS;
14625 VOS_STATUS vosStatus;
14626 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014627 if(!pEntry)
14628 {
14629 //list empty
14630 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014631 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014632 return status;
14633 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014634 while( pEntry )
14635 {
14636 if(pPrevEntry)
14637 {
14638 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
14639 //send up the stats report
14640 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
14641 pTempStaEntry->staId, pTempStaEntry->pContext);
14642 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
14643 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014644 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014645 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
14646 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014647 pTempStaEntry->pPeStaEntry->numClient--;
14648 //check if we need to delete the entry from peStatsReqList too
14649 if(!pTempStaEntry->pPeStaEntry->numClient)
14650 {
14651 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
14652 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014653 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014654 //check if we need to stop the tl stats timer too
14655 pMac->roam.tlStatsReqInfo.numClient--;
14656 if(!pMac->roam.tlStatsReqInfo.numClient)
14657 {
14658 if(pMac->roam.tlStatsReqInfo.timerRunning)
14659 {
14660 status = palTimerStop(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
14661 if(!HAL_STATUS_SUCCESS(status))
14662 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014663 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014664 //we will continue
14665 }
14666 }
14667 pMac->roam.tlStatsReqInfo.periodicity = 0;
14668 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14669 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014670 if (pTempStaEntry->periodicity)
14671 {
14672 //While creating StaEntry in csrGetStatistics,
14673 //Initializing and starting timer only when periodicity is set.
14674 //So Stop and Destroy timer only when periodicity is set.
14675
Jeff Johnsone7245742012-09-05 17:12:55 -070014676 vos_timer_stop( &pTempStaEntry->timer );
14677 // Destroy the vos timer...
14678 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
14679 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14680 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014681 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070014682 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014683 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014684
Jeff Johnson295189b2012-06-20 16:38:30 -070014685
14686 pPrevEntry = pEntry;
14687 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14688 }
14689 //the last one
14690 if(pPrevEntry)
14691 {
14692 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
14693 //send up the stats report
14694 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
14695 pTempStaEntry->staId, pTempStaEntry->pContext);
14696 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
14697 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014698 return status;
14699
14700}
14701
Jeff Johnson295189b2012-06-20 16:38:30 -070014702eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
14703 tRequestFullPowerReason *pReason,
14704 tANI_BOOLEAN *pfNeedPower )
14705{
14706 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
14707 tRequestFullPowerReason reason = eSME_REASON_OTHER;
14708 tPmcState pmcState;
14709 eHalStatus status = eHAL_STATUS_SUCCESS;
14710 // TODO : Session info unavailable
14711 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014712 if( pfNeedPower )
14713 {
14714 *pfNeedPower = eANI_BOOLEAN_FALSE;
14715 }
14716 //We only handle CSR commands
14717 if( !(eSmeCsrCommandMask & pCommand->command) )
14718 {
14719 return eHAL_STATUS_SUCCESS;
14720 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014721 //Check PMC state first
14722 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070014723 switch( pmcState )
14724 {
14725 case REQUEST_IMPS:
14726 case IMPS:
14727 if( eSmeCommandScan == pCommand->command )
14728 {
14729 switch( pCommand->u.scanCmd.reason )
14730 {
14731 case eCsrScanGetResult:
14732 case eCsrScanBGScanAbort:
14733 case eCsrScanBGScanEnable:
14734 case eCsrScanGetScanChnInfo:
14735 //Internal process, no need for full power
14736 fNeedFullPower = eANI_BOOLEAN_FALSE;
14737 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014738 default:
14739 //Other scans are real scan, ask for power
14740 fNeedFullPower = eANI_BOOLEAN_TRUE;
14741 break;
14742 } //switch
14743 }
14744 else
14745 {
14746 //ask for power for roam and status change
14747 fNeedFullPower = eANI_BOOLEAN_TRUE;
14748 }
14749 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014750 case REQUEST_BMPS:
14751 case BMPS:
14752 case REQUEST_START_UAPSD:
14753 case UAPSD:
14754 //We treat WOWL same as BMPS
14755 case REQUEST_ENTER_WOWL:
14756 case WOWL:
14757 if( eSmeCommandRoam == pCommand->command )
14758 {
14759 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
14760 tCsrScanResult *pScanResult;
14761 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014762 switch ( pCommand->u.roamCmd.roamReason )
14763 {
14764 case eCsrForcedDisassoc:
14765 case eCsrForcedDisassocMICFailure:
14766 reason = eSME_LINK_DISCONNECTED_BY_HDD;
14767 fNeedFullPower = eANI_BOOLEAN_TRUE;
14768 break;
14769 case eCsrSmeIssuedDisassocForHandoff:
14770 case eCsrForcedDeauth:
14771 case eCsrHddIssuedReassocToSameAP:
14772 case eCsrSmeIssuedReassocToSameAP:
14773 fNeedFullPower = eANI_BOOLEAN_TRUE;
14774 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014775 case eCsrCapsChange:
14776 fNeedFullPower = eANI_BOOLEAN_TRUE;
14777 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014778 default:
14779 //Check whether the profile is already connected. If so, no need for full power
14780 //Note: IBSS is ignored for now because we don't support powersave in IBSS
14781 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
14782 {
14783 //Only need to check the first one
14784 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
14785 if( pEntry )
14786 {
14787 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
14788#if 0
14789 // TODO : Session Specific info pConnectBssDesc
14790 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
14791 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
14792 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
14793 {
14794 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
14795 // with Authenticating first. To force this, stop the current association (Disassociate) and
14796 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
14797 // a new Association.
14798 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
14799 {
14800 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
14801 {
14802 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
14803 //No need for full power
14804 //Set the flag so the code later can avoid to do the above
14805 //check again.
14806 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
14807 break;
14808 }
14809 }
14810 }
14811#endif
14812 }
14813 }
14814 //If we are here, full power is needed
14815 fNeedFullPower = eANI_BOOLEAN_TRUE;
14816 break;
14817 }
14818 }
14819 else if( eSmeCommandWmStatusChange == pCommand->command )
14820 {
14821 //need full power for all
14822 fNeedFullPower = eANI_BOOLEAN_TRUE;
14823 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
14824 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014825#ifdef FEATURE_WLAN_TDLS
14826 else if( eSmeCommandTdlsAddPeer == pCommand->command )
14827 {
14828 //TDLS link is getting established. need full power
14829 fNeedFullPower = eANI_BOOLEAN_TRUE;
14830 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
14831 }
14832#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014833 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014834 case REQUEST_STOP_UAPSD:
14835 case REQUEST_EXIT_WOWL:
14836 if( eSmeCommandRoam == pCommand->command )
14837 {
14838 fNeedFullPower = eANI_BOOLEAN_TRUE;
14839 switch ( pCommand->u.roamCmd.roamReason )
14840 {
14841 case eCsrForcedDisassoc:
14842 case eCsrForcedDisassocMICFailure:
14843 reason = eSME_LINK_DISCONNECTED_BY_HDD;
14844 break;
14845 default:
14846 break;
14847 }
14848 }
14849 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014850 case STOPPED:
14851 case REQUEST_STANDBY:
14852 case STANDBY:
14853 case LOW_POWER:
14854 //We are not supposed to do anything
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014855 smsLog( pMac, LOGE, FL( " cannot process because PMC is in stopped/standby state %d" ), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070014856 status = eHAL_STATUS_FAILURE;
14857 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014858 case FULL_POWER:
14859 case REQUEST_FULL_POWER:
14860 default:
14861 //No need to ask for full power. This has to be FULL_POWER state
14862 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014863 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070014864 if( pReason )
14865 {
14866 *pReason = reason;
14867 }
14868 if( pfNeedPower )
14869 {
14870 *pfNeedPower = fNeedFullPower;
14871 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014872 return ( status );
14873}
14874
Jeff Johnson295189b2012-06-20 16:38:30 -070014875static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14876{
14877 eHalStatus status = eHAL_STATUS_SUCCESS;
14878 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
14879 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070014880 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070014881 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
14882 {
14883 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
14884 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014885 return ( status );
14886}
14887
Jeff Johnson295189b2012-06-20 16:38:30 -070014888tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
14889{
14890 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070014891 if( pCmd )
14892 {
14893 pMac->roam.sPendingCommands++;
14894 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014895 return ( pCmd );
14896}
14897
Jeff Johnson295189b2012-06-20 16:38:30 -070014898void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
14899{
14900 if (pMac->roam.sPendingCommands > 0)
14901 {
14902 //All command allocated through csrGetCommandBuffer need to
14903 //decrement the pending count when releasing.
14904 pMac->roam.sPendingCommands--;
14905 smeReleaseCommand( pMac, pCommand );
14906 }
14907 else
14908 {
14909 smsLog(pMac, LOGE, FL( "no pending commands"));
14910 VOS_ASSERT(0);
14911 }
14912}
14913
Jeff Johnson295189b2012-06-20 16:38:30 -070014914//Return SUCCESS is the command is queued, failed
14915eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
14916{
14917 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014918 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
14919 {
14920 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
14921 pCommand->u.scanCmd.reason);
14922 return eHAL_STATUS_CSR_WRONG_STATE;
14923 }
14924
14925 //We can call request full power first before putting the command into pending Q
14926 //because we are holding SME lock at this point.
14927 status = csrRequestFullPower( pMac, pCommand );
14928 if( HAL_STATUS_SUCCESS( status ) )
14929 {
14930 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070014931 //make sure roamCmdPendingList is not empty first
14932 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
14933 if( fNoCmdPending )
14934 {
14935 smePushCommand( pMac, pCommand, fHighPriority );
14936 }
14937 else
14938 {
14939 //Other commands are waiting for PMC callback, queue the new command to the pending Q
14940 //no list lock is needed since SME lock is held
14941 if( !fHighPriority )
14942 {
14943 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
14944 }
14945 else {
14946 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
14947 }
14948 }
14949 }
14950 else if( eHAL_STATUS_PMC_PENDING == status )
14951 {
14952 //no list lock is needed since SME lock is held
14953 if( !fHighPriority )
14954 {
14955 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
14956 }
14957 else {
14958 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
14959 }
14960 //Let caller know the command is queue
14961 status = eHAL_STATUS_SUCCESS;
14962 }
14963 else
14964 {
14965 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
14966 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014967 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070014968 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014969 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014970}
Jeff Johnson295189b2012-06-20 16:38:30 -070014971eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
14972{
14973 eHalStatus status = eHAL_STATUS_SUCCESS;
14974 tSirUpdateAPWPSIEsReq *pMsg;
14975 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
14976
14977 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14978 if (NULL == pSession)
14979 {
14980 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
14981 return eHAL_STATUS_FAILURE;
14982 }
14983
Jeff Johnson295189b2012-06-20 16:38:30 -070014984 do
14985 {
14986 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirUpdateAPWPSIEsReq) );
14987 if (!HAL_STATUS_SUCCESS(status)) break;
14988 palZeroMemory( pMac->hHdd, pMsg, sizeof(tSirUpdateAPWPSIEsReq) );
14989 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
14990
14991 pBuf = (tANI_U8 *)&pMsg->transactionId;
14992 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014993 // transactionId
14994 *pBuf = 0;
14995 *( pBuf + 1 ) = 0;
14996 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014997 // bssId
14998 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
14999 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015000 //sessionId
15001 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015002 // APWPSIEs
15003 palCopyMemory( pMac->hHdd, (tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
15004 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070015005 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070015006 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015007 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015008 return ( status );
15009}
Jeff Johnson295189b2012-06-20 16:38:30 -070015010eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
15011{
15012 eHalStatus status = eHAL_STATUS_SUCCESS;
15013 tSirUpdateAPWPARSNIEsReq *pMsg;
15014 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015015 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15016 if (NULL == pSession)
15017 {
15018 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
15019 return eHAL_STATUS_FAILURE;
15020 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015021 do
15022 {
15023 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirUpdateAPWPARSNIEsReq) );
15024 if (!HAL_STATUS_SUCCESS(status)) break;
15025 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ) );
15026 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070015027 pBuf = (tANI_U8 *)&pMsg->transactionId;
15028 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015029 // transactionId
15030 *pBuf = 0;
15031 *( pBuf + 1 ) = 0;
15032 pBuf += sizeof(tANI_U16);
15033
15034 // bssId
15035 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
15036 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015037 // sessionId
15038 *pBuf++ = (tANI_U8)sessionId;
15039
15040 // APWPARSNIEs
15041 palCopyMemory( pMac->hHdd, (tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
15042 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070015043 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070015044 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015045 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015046 return ( status );
15047}
Jeff Johnson295189b2012-06-20 16:38:30 -070015048
15049#ifdef WLAN_FEATURE_VOWIFI_11R
15050//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
15051eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
15052{
15053 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
15054 tpSirFTPreAuthReq pftPreAuthReq;
15055 tANI_U16 auth_req_len = 0;
15056 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015057 auth_req_len = sizeof(tSirFTPreAuthReq);
15058 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
15059 if (pftPreAuthReq == NULL)
15060 {
15061 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
15062 return eHAL_STATUS_RESOURCES;
15063 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015064 // Save the SME Session ID here. We need it while processing the preauth response
15065 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015066 vos_mem_zero(pftPreAuthReq, auth_req_len);
15067
15068 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
15069 sizeof(pBssDescription->length) + pBssDescription->length);
15070
15071 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
15072
15073 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
15074
Jeff Johnson295189b2012-06-20 16:38:30 -070015075 palCopyMemory(pMac->hHdd, (void *)&pftPreAuthReq->currbssId, (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015076 palCopyMemory(pMac->hHdd, (void *)&pftPreAuthReq->preAuthbssId, (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
15077
Jeff Johnson295189b2012-06-20 16:38:30 -070015078#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080015079 if (csrRoamIs11rAssoc(pMac) &&
15080 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070015081 {
15082 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
15083 palCopyMemory(pMac->hHdd, pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
15084 pMac->ft.ftSmeContext.auth_ft_ies_length);
15085 }
15086 else
15087#endif
15088 {
15089 pftPreAuthReq->ft_ies_length = 0;
15090 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070015091 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
15092 sizeof(pBssDescription->length) + pBssDescription->length);
15093 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070015094 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
15095}
Jeff Johnson295189b2012-06-20 16:38:30 -070015096/*--------------------------------------------------------------------------
15097 * This will receive and process the FT Pre Auth Rsp from the current
15098 * associated ap.
15099 *
15100 * This will invoke the hdd call back. This is so that hdd can now
15101 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
15102 ------------------------------------------------------------------------*/
15103void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
15104{
15105 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
15106 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015107#ifdef FEATURE_WLAN_LFR
15108 tCsrRoamInfo roamInfo;
15109#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015110
15111#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080015112 smsLog( pMac, LOGE, FL("Preauth response status code 0x%x"), pFTPreAuthRsp->status);
Jeff Johnson295189b2012-06-20 16:38:30 -070015113#endif
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070015114#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080015115 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070015116 if (status != eHAL_STATUS_SUCCESS) {
15117 /*
15118 * Bail out if pre-auth was not even processed.
15119 */
15120 smsLog(pMac, LOGW, FL("Preauth was not processed: %d"), status);
15121 return;
15122 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015123#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015124 /* The below function calls/timers should be invoked only if the pre-auth is successful */
15125 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
15126 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070015127 // Implies a success
15128 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015129 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
15130 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
15131 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070015132 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
15133 * actual transition from the current to handoff AP is triggered */
15134 status = palTimerStart(pMac->hHdd, pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
15135 60 * PAL_TIMER_TO_MS_UNIT,
15136 eANI_BOOLEAN_FALSE);
15137 if (eHAL_STATUS_SUCCESS != status)
15138 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015139 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070015140 return;
15141 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015142 // Save the received response
15143 palCopyMemory(pMac->hHdd, (void *)&pMac->ft.ftSmeContext.preAuthbssId, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
15144 if (csrRoamIs11rAssoc(pMac))
15145 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
15146 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
15147
15148 // Currently we dont do anything special for CCX connection.
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015149#ifdef FEATURE_WLAN_LFR
15150 // If Legacy Fast Roaming is enabled, signal the supplicant
15151 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053015152 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015153 {
15154 // Save the bssid from the received response
15155 palCopyMemory(pMac->hHdd, (void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
15156 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
15157 }
15158
15159#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015160
15161 // Done with it, init it.
15162 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
15163}
15164#endif
15165#ifdef FEATURE_WLAN_BTAMP_UT_RF
15166void csrRoamJoinRetryTimerHandler(void *pv)
15167{
15168 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
15169 tpAniSirGlobal pMac = pInfo->pMac;
15170 tANI_U32 sessionId = pInfo->sessionId;
15171 tCsrRoamSession *pSession;
15172
15173 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
15174 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015175 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015176 pSession = CSR_GET_SESSION( pMac, sessionId );
15177 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
15178 {
15179 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
15180 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015181 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070015182 }
15183 }
15184 }
15185}
Jeff Johnson295189b2012-06-20 16:38:30 -070015186eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
15187{
15188 eHalStatus status = eHAL_STATUS_FAILURE;
15189 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15190
15191 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
15192 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015193 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070015194 pSession->maxRetryCount--;
15195 pSession->joinRetryTimerInfo.pMac = pMac;
15196 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
15197 status = palTimerStart(pMac->hHdd, pSession->hTimerJoinRetry, interval, eANI_BOOLEAN_FALSE);
15198 if(!HAL_STATUS_SUCCESS(status))
15199 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015200 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070015201 }
15202 }
15203 else
15204 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015205 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070015206 pSession->maxRetryCount);
15207 }
15208
15209 return (status);
15210}
Jeff Johnson295189b2012-06-20 16:38:30 -070015211eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
15212{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015213 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070015214 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
15215 {
15216 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerJoinRetry));
15217 }
15218
15219 return eHAL_STATUS_SUCCESS;
15220}
15221#endif
15222
15223
15224/*
15225 pBuf points to the beginning of the message
15226 LIM packs disassoc rsp as below,
15227 messageType - 2 bytes
15228 messageLength - 2 bytes
15229 sessionId - 1 byte
15230 transactionId - 2 bytes (tANI_U16)
15231 reasonCode - 4 bytes (sizeof(tSirResultCodes))
15232 peerMacAddr - 6 bytes
15233 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
15234*/
15235static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
15236{
15237 if(pBuf && pRsp)
15238 {
15239 pBuf += 4; //skip type and length
15240 pRsp->sessionId = *pBuf++;
15241 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
15242 pBuf += 2;
15243 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
15244 pBuf += 4;
15245 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
15246 }
15247}
15248
Jeff Johnsond13512a2012-07-17 11:42:19 -070015249eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
15250{
15251 static uNvTables nvTables;
15252 eHalStatus status = eHAL_STATUS_SUCCESS;
15253 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
15254
15255 /* read the country code from NV and use it */
15256 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
15257 {
15258 palCopyMemory( pMac->hHdd, pCountry,
15259 nvTables.defaultCountryTable.countryCode,
15260 WNI_CFG_COUNTRY_CODE_LEN );
15261 return status;
15262 }
15263 else
15264 {
15265 palCopyMemory( pMac->hHdd, pCountry,
15266 "XXX",
15267 WNI_CFG_COUNTRY_CODE_LEN );
15268 status = eHAL_STATUS_FAILURE;
15269 return status;
15270 }
15271}
15272
15273eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
15274{
15275 palCopyMemory( pMac->hHdd, pCountry,
15276 pMac->scan.countryCode11d,
15277 WNI_CFG_COUNTRY_CODE_LEN );
15278 return eHAL_STATUS_SUCCESS;
15279}
schang86c22c42013-03-13 18:41:24 -070015280
15281eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
15282{
15283 tSirSetTxPowerReq *pMsg = NULL;
15284 eHalStatus status = eHAL_STATUS_SUCCESS;
15285 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
15286
15287 if (!pSession)
15288 {
15289 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15290 return eHAL_STATUS_FAILURE;
15291 }
15292
15293 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tSirSetTxPowerReq));
15294 if (HAL_STATUS_SUCCESS(status))
15295 {
15296 palZeroMemory(pMac->hHdd, (void *)pMsg, sizeof(tSirSetTxPowerReq));
15297 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
15298 pMsg->length = sizeof(tSirSetTxPowerReq);
15299 pMsg->mwPower = mW;
15300 palCopyMemory( pMac->hHdd,
15301 (tSirMacAddr *)pMsg->bssId,
15302 &pSession->selfMacAddr,
15303 sizeof(tSirMacAddr) );
15304 status = palSendMBMessage(pMac->hHdd, pMsg);
15305 if (!HAL_STATUS_SUCCESS(status))
15306 {
15307 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
15308 palFreeMemory(pMac->hHdd, pMsg);
15309 }
15310 }
15311 return status;
15312}