blob: ee67ae8ebe996811e6092452f5cc110fa60769d7 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala9c070ad2013-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
Madan Mohan Koyyalamudi1002ab82012-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 Girigowda6fa58662013-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 {
340 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE\n") );
341 //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 {
368 smsLog( pMac, LOGW, FL(" Invalid country Code Pointer\n") );
369 return eHAL_STATUS_FAILURE;
370 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700371 smsLog( pMac, LOGW, FL(" country Code %s\n"), 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 {
379 smsLog( pMac, LOGW, FL(" Invalid Country Code Length\n") );
380 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 {
386 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %s\n"), apCntryCode );
387 return status;
388 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700389 status = WDA_SetRegDomain(hHal, regId);
390 if (status != eHAL_STATUS_SUCCESS)
391 {
392 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %s\n"), apCntryCode );
393 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 Nakkala277e02b2012-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 {
479 smsLog(pMac, LOGW, " csrStart: Couldn't Init HO control blk \n");
480 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 Nakkala277e02b2012-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);
Madan Mohan Koyyalamudi7da2fd72012-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 {
543 smsLog( pMac, LOGE, "csrInitChannelList failed during csrReady with status=%d\n",
544 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 {
593 smsLog(pMac, LOGE, FL("cannot allocate memory for WaitForKey time out timer\n"));
594 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 {
599 smsLog(pMac, LOGE, FL("cannot allocate memory for summary Statistics timer\n"));
600 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 Girigowdafe1e2882013-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 Johnson3d710ea2012-12-10 14:31:52 -0800821 // We need to inform the requester before dropping the scan command
Jeff Johnson295189b2012-06-20 16:38:30 -0700822 smsLog( pMac, LOGW, "%s: Drop scan reason %d callback 0x%X\n",
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 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700826 smsLog( pMac, LOGW, "%s callback scan requester\n", __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:
848 smsLog( pMac, LOGW, " CSR abort standard command %d\n", pCommand->command );
849 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{
857 smsLog( pMac, LOG1, " CSR RoamSubstate: [ %d <== %d ]\n", NewSubstate, pMac->roam.curSubState[sessionId]);
858
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
870 smsLog( pMac, LOG1, "CSR RoamState: [ %d <== %d ]\n", NewRoamState, pMac->roam.curState[sessionId]);
871
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 Lokere30b07722013-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;
Madan Mohan Koyyalamudi8591f092012-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 Girigowda6fa58662013-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 Girigowda6fa58662013-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 Girigowda6fa58662013-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 Girigowda6fa58662013-02-14 16:31:48 -08001201 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
1202 "failed to set band cfg80211 = %u, band = %u\n",
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 Girigowda6fa58662013-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 Girigowda6fa58662013-02-14 16:31:48 -08001212 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
1213 "failed to set band dot11mode = %u, band = %u\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07001214 pMac->roam.configParam.uCfgDot11Mode, eBand);
1215 return eHAL_STATUS_INVALID_PARAMETER;
1216 }
Srinivas Girigowda6fa58662013-02-14 16:31:48 -08001217 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07001218 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)\n", eBand);
Srinivas Girigowda6fa58662013-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 Girigowda6fa58662013-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 Girigowda6fa58662013-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 {
1367 smsLog( pMac, LOGW, "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED\n", pParam->channelBondingMode24GHz);
1368 }
1369 pMac->roam.configParam.channelBondingMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode24GHz);
1370 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
1371 {
1372 smsLog( pMac, LOGW, "Invalid CB value from ini in 5GHz band %d, CB DISABLED\n", pParam->channelBondingMode5GHz);
1373 }
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 Lokere30b07722013-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 Lokere30b07722013-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 Lokere30b07722013-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 Lokere30b07722013-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 Lokere30b07722013-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 Lokere30b07722013-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 Lokere30b07722013-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 Lokere30b07722013-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 Lokere30b07722013-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 Lokere30b07722013-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 Lokere30b07722013-02-24 22:21:28 -08001434 if (pParam->nNumChanCombinedConc)
Madan Mohan Koyyalamudi8591f092012-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 Lokere30b07722013-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 Lokere30b07722013-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) );
1515 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d\n", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
1516#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 Koyyalamudif4289db2012-12-03 16:45:39 -08001520 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
1521 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d\n",
1522 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudic4c01172012-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) );
Jeff Johnson295189b2012-06-20 16:38:30 -07001534 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d\n", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
1535 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d\n", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
1536 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d\n", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
1537 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d\n", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
1538 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d\n", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
Srinivas Girigowda6fa58662013-02-14 16:31:48 -08001539 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d\n", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
1540 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d\n", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
1541 smsLog( pMac, LOG1, "nEmptyScanRefreshPeriod = %d\n", pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07001542 {
1543 int i;
1544 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d\n"), 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 }
1549 smsLog( pMac, LOG1, "\n");
1550 }
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;
Madan Mohan Koyyalamudi7da2fd72012-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 Karmuchi31f9ebe2013-01-17 12:51:24 -08001571 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchi95934c32013-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 Nakkalab7ed0a62013-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;
Madan Mohan Koyyalamudi8591f092012-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 Ravi441b91b2013-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 Karmuchi31f9ebe2013-01-17 12:51:24 -08001654 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchi95934c32013-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
1766 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X\n"), phyMode );
1767 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 {
1890 smsLog( pMac, LOGE, FL("failed to get channels \n"));
1891 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);
Kirand170dcb2013-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 Nakkala277e02b2012-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 Nakkala277e02b2012-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 Koyyalamudi15407ac2013-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 {
2100 smsLog(pMac, LOGW, FL(" roamReason = %d\n"), pDupCommand->u.roamCmd.roamReason);
2101 // 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 {
2135 smsLog(pMac, LOGE, "Session ID:%d is not valid\n", sessionId);
2136 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 {
2141 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d\n", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
2142 }
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 {
2160 smsLog(pMac, LOG1, "Session ID is not valid\n");
2161 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 Nakkala79353d12012-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 Nakkala79353d12012-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 Nakkala79353d12012-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 Nakkala79353d12012-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 {
2348 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
2349 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 {
2390 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
2391 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 {
2406 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found\n");
2407 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 {
2415 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found\n");
2416 return (status);
2417 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002418 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = %02x-%02x-%02x-%02x-%02x-%02x, Enable = %d\n",
2419 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 {
2434 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found\n");
2435 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 {
2443 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found\n");
2444 return (status);
2445 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002446 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = %02x-%02x-%02x-%02x-%02x-%02x\n",
2447 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 {
2462 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found\n");
2463 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 {
2471 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found\n");
2472 return (status);
2473 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002474 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = %02x-%02x-%02x-%02x-%02x-%02x\n",
2475 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 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002498 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= %02x-%02x-%02x-%02x-%02x-%02x\n",
2499 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 Koyyalamudi64571a62013-01-30 19:59:23 +05302503 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Gopichand Nakkala79353d12012-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#if defined(VOSS_ENABLED)
2561 VOS_ASSERT( pIes != NULL );
2562#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002563
Jeff Johnson295189b2012-06-20 16:38:30 -07002564 do
2565 {
2566 palCopyMemory(pMac->hHdd, &pBssConfig->BssCap, &pBssDesc->capabilityInfo, sizeof(tSirMacCapabilityInfo));
2567 //get qos
2568 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
2569 //get SSID
2570 if(pIes->SSID.present)
2571 {
2572 palCopyMemory(pMac->hHdd, &pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
2573 pBssConfig->SSID.length = pIes->SSID.num_ssid;
2574 }
2575 else
2576 pBssConfig->SSID.length = 0;
2577 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
2578 {
2579 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard\n");
2580 //Return failed if profile doesn't have an SSID either.
2581 if(pProfile->SSIDs.numOfSSIDs == 0)
2582 {
2583 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID\n");
2584 status = eHAL_STATUS_FAILURE;
2585 break;
2586 }
2587 }
2588 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
2589 {
2590 pBssConfig->eBand = eCSR_BAND_5G;
2591 }
2592 else
2593 {
2594 pBssConfig->eBand = eCSR_BAND_24;
2595 }
2596 //phymode
2597 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
2598 {
2599 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
2600 }
2601 else
2602 {
2603 smsLog(pMac, LOGW, " Can not find match phy mode\n");
2604 //force it
2605 if(eCSR_BAND_24 == pBssConfig->eBand)
2606 {
2607 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2608 }
2609 else
2610 {
2611 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2612 }
2613 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002614 //Qos
2615 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
2616 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
2617 {
2618 //Joining BSS is not 11n capable and WMM is disabled on client.
2619 //Disable QoS and WMM
2620 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2621 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302622
2623 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05302624 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302625 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
2626 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
2627 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
2628 {
2629 //Joining BSS is 11n capable and WMM is disabled on AP.
2630 //Assume all HT AP's are QOS AP's and enable WMM
2631 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2632 }
2633
Jeff Johnson295189b2012-06-20 16:38:30 -07002634 //auth type
2635 switch( pProfile->negotiatedAuthType )
2636 {
2637 default:
2638 case eCSR_AUTH_TYPE_WPA:
2639 case eCSR_AUTH_TYPE_WPA_PSK:
2640 case eCSR_AUTH_TYPE_WPA_NONE:
2641 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2642 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2643 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002644 case eCSR_AUTH_TYPE_SHARED_KEY:
2645 pBssConfig->authType = eSIR_SHARED_KEY;
2646 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002647 case eCSR_AUTH_TYPE_AUTOSWITCH:
2648 pBssConfig->authType = eSIR_AUTO_SWITCH;
2649 break;
2650 }
2651 //short slot time
2652 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
2653 {
2654 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2655 }
2656 else
2657 {
2658 pBssConfig->uShortSlotTime = 0;
2659 }
2660 if(pBssConfig->BssCap.ibss)
2661 {
2662 //We don't support 11h on IBSS
2663 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2664 }
2665 else
2666 {
2667 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
2668 }
2669 //power constraint
2670 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
2671 //heartbeat
2672 if ( CSR_IS_11A_BSS( pBssDesc ) )
2673 {
2674 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2675 }
2676 else
2677 {
2678 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2679 }
2680 //Join timeout
2681 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07002682 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07002683 if ( pBssDesc->beaconInterval )
2684 {
2685 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07002686 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002687 }
2688 else
2689 {
2690 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
2691 }
2692 //validate CB
2693 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
2694 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002695 return (status);
2696}
2697
Jeff Johnson295189b2012-06-20 16:38:30 -07002698static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2699 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
2700{
2701 eHalStatus status = eHAL_STATUS_SUCCESS;
2702 tANI_U8 operationChannel = 0;
2703 tANI_U8 qAPisEnabled = FALSE;
2704 //SSID
2705 pBssConfig->SSID.length = 0;
2706 if(pProfile->SSIDs.numOfSSIDs)
2707 {
2708 //only use the first one
2709 palCopyMemory(pMac->hHdd, &pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID, sizeof(tSirMacSSid));
2710 }
2711 else
2712 {
2713 //SSID must present
2714 return eHAL_STATUS_FAILURE;
2715 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002716 //Settomg up the capabilities
2717 if( csrIsBssTypeIBSS(pProfile->BSSType) )
2718 {
2719 pBssConfig->BssCap.ibss = 1;
2720 }
2721 else
2722 {
2723 pBssConfig->BssCap.ess = 1;
2724 }
2725 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
2726 {
2727 pBssConfig->BssCap.privacy = 1;
2728 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002729 pBssConfig->eBand = pMac->roam.configParam.eBand;
2730 //phymode
2731 if(pProfile->ChannelInfo.ChannelList)
2732 {
2733 operationChannel = pProfile->ChannelInfo.ChannelList[0];
2734 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002735 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
2736 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07002737 //QOS
2738 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07002739 if ( pBssConfig->BssCap.ess == 1 )
2740 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002741 /*For Softap case enable WMM*/
2742 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
2743 qAPisEnabled = TRUE;
2744 }
2745 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002746 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
2747 qAPisEnabled = TRUE;
2748 } else {
2749 qAPisEnabled = FALSE;
2750 }
2751 } else {
2752 qAPisEnabled = TRUE;
2753 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002754 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
2755 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
2756 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
2757 )
2758 {
2759 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2760 } else {
2761 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2762 }
2763
2764 //auth type
Jeff Johnson3d30ed12012-12-10 14:41:22 -08002765 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07002766 {
2767 default:
2768 case eCSR_AUTH_TYPE_WPA:
2769 case eCSR_AUTH_TYPE_WPA_PSK:
2770 case eCSR_AUTH_TYPE_WPA_NONE:
2771 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2772 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2773 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002774 case eCSR_AUTH_TYPE_SHARED_KEY:
2775 pBssConfig->authType = eSIR_SHARED_KEY;
2776 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002777 case eCSR_AUTH_TYPE_AUTOSWITCH:
2778 pBssConfig->authType = eSIR_AUTO_SWITCH;
2779 break;
2780 }
2781 //short slot time
2782 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
2783 {
2784 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2785 }
2786 else
2787 {
2788 pBssConfig->uShortSlotTime = 0;
2789 }
2790 //power constraint. We don't support 11h on IBSS
2791 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2792 pBssConfig->uPowerLimit = 0;
2793 //heartbeat
2794 if ( eCSR_BAND_5G == pBssConfig->eBand )
2795 {
2796 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2797 }
2798 else
2799 {
2800 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2801 }
2802 //Join timeout
2803 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07002804
Jeff Johnson295189b2012-06-20 16:38:30 -07002805 return (status);
2806}
Jeff Johnson295189b2012-06-20 16:38:30 -07002807static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
2808{
2809 eHalStatus status = eHAL_STATUS_FAILURE;
2810 tDot11fBeaconIEs *pIes = NULL;
2811
2812 do
2813 {
2814 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
2815 {
2816 //err msg
2817 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
2818 "csrRoamGetQosInfoFromBss() failed\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07002819 break;
2820 }
2821 //check if the AP is QAP & it supports APSD
2822 if( CSR_IS_QOS_BSS(pIes) )
2823 {
2824 return eHAL_STATUS_SUCCESS;
2825 }
2826 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002827 return status;
2828}
2829
Jeff Johnson295189b2012-06-20 16:38:30 -07002830void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
2831{
Jeff Johnson295189b2012-06-20 16:38:30 -07002832 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
2833 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
2834 // See !!Note: below in this function...
2835 tANI_U32 PrivacyEnabled = 0;
2836 tANI_U32 RsnEnabled = 0;
2837 tANI_U32 WepDefaultKeyId = 0;
2838 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
2839 tANI_U32 Key0Length = 0;
2840 tANI_U32 Key1Length = 0;
2841 tANI_U32 Key2Length = 0;
2842 tANI_U32 Key3Length = 0;
2843
2844 // Reserve for the biggest key
2845 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
2846 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
2847 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
2848 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
2849
2850 switch ( pProfile->negotiatedUCEncryptionType )
2851 {
2852 case eCSR_ENCRYPT_TYPE_NONE:
2853
2854 // for NO encryption, turn off Privacy and Rsn.
2855 PrivacyEnabled = 0;
2856 RsnEnabled = 0;
2857
2858 // WEP key length and Wep Default Key ID don't matter in this case....
2859
2860 // clear out the WEP keys that may be hanging around.
2861 Key0Length = 0;
2862 Key1Length = 0;
2863 Key2Length = 0;
2864 Key3Length = 0;
2865
2866 break;
2867
2868 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
2869
2870 // Privacy is ON. NO RSN for Wep40 static key.
2871 PrivacyEnabled = 1;
2872 RsnEnabled = 0;
2873
2874 // Set the Wep default key ID.
2875 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07002876 // Wep key size if 5 bytes (40 bits).
2877 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
2878
2879 // set encryption keys in the CFG database or clear those that are not present in this profile.
2880 if ( pProfile->Keys.KeyLength[0] )
2881 {
2882 palCopyMemory( pMac->hHdd, Key0, pProfile->Keys.KeyMaterial[0], WNI_CFG_WEP_KEY_LENGTH_5 );
2883 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
2884 }
2885 else
2886 {
2887 Key0Length = 0;
2888 }
2889
2890 if ( pProfile->Keys.KeyLength[1] )
2891 {
2892 palCopyMemory( pMac->hHdd, Key1, pProfile->Keys.KeyMaterial[1], WNI_CFG_WEP_KEY_LENGTH_5 );
2893 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
2894 }
2895 else
2896 {
2897 Key1Length = 0;
2898 }
2899
2900 if ( pProfile->Keys.KeyLength[2] )
2901 {
2902 palCopyMemory( pMac->hHdd, Key2, pProfile->Keys.KeyMaterial[2], WNI_CFG_WEP_KEY_LENGTH_5 );
2903 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
2904 }
2905 else
2906 {
2907 Key2Length = 0;
2908 }
2909
2910 if ( pProfile->Keys.KeyLength[3] )
2911 {
2912 palCopyMemory( pMac->hHdd, Key3, pProfile->Keys.KeyMaterial[3], WNI_CFG_WEP_KEY_LENGTH_5 );
2913 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
2914 }
2915 else
2916 {
2917 Key3Length = 0;
2918 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002919 break;
2920
2921 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
2922
2923 // Privacy is ON. NO RSN for Wep40 static key.
2924 PrivacyEnabled = 1;
2925 RsnEnabled = 0;
2926
2927 // Set the Wep default key ID.
2928 WepDefaultKeyId = pProfile->Keys.defaultIndex;
2929
2930 // Wep key size if 13 bytes (104 bits).
2931 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
2932
2933 // set encryption keys in the CFG database or clear those that are not present in this profile.
2934 if ( pProfile->Keys.KeyLength[0] )
2935 {
2936 palCopyMemory( pMac->hHdd, Key0, pProfile->Keys.KeyMaterial[ 0 ], WNI_CFG_WEP_KEY_LENGTH_13 );
2937 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
2938 }
2939 else
2940 {
2941 Key0Length = 0;
2942 }
2943
2944 if ( pProfile->Keys.KeyLength[1] )
2945 {
2946 palCopyMemory( pMac->hHdd, Key1, pProfile->Keys.KeyMaterial[ 1 ], WNI_CFG_WEP_KEY_LENGTH_13 );
2947 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
2948 }
2949 else
2950 {
2951 Key1Length = 0;
2952 }
2953
2954 if ( pProfile->Keys.KeyLength[2] )
2955 {
2956 palCopyMemory( pMac->hHdd, Key2, pProfile->Keys.KeyMaterial[ 2 ], WNI_CFG_WEP_KEY_LENGTH_13 );
2957 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
2958 }
2959 else
2960 {
2961 Key2Length = 0;
2962 }
2963
2964 if ( pProfile->Keys.KeyLength[3] )
2965 {
2966 palCopyMemory( pMac->hHdd, Key3, pProfile->Keys.KeyMaterial[ 3 ], WNI_CFG_WEP_KEY_LENGTH_13 );
2967 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
2968 }
2969 else
2970 {
2971 Key3Length = 0;
2972 }
2973
2974 break;
2975
2976 case eCSR_ENCRYPT_TYPE_WEP40:
2977 case eCSR_ENCRYPT_TYPE_WEP104:
2978 case eCSR_ENCRYPT_TYPE_TKIP:
2979 case eCSR_ENCRYPT_TYPE_AES:
2980#ifdef FEATURE_WLAN_WAPI
2981 case eCSR_ENCRYPT_TYPE_WPI:
2982#endif /* FEATURE_WLAN_WAPI */
2983 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
2984 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
2985 PrivacyEnabled = (0 != fPrivacy);
2986
2987 // turn on RSN enabled for WPA associations
2988 RsnEnabled = 1;
2989
2990 // WEP key length and Wep Default Key ID don't matter in this case....
2991
2992 // clear out the static WEP keys that may be hanging around.
2993 Key0Length = 0;
2994 Key1Length = 0;
2995 Key2Length = 0;
2996 Key3Length = 0;
2997
2998 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002999 default:
3000 PrivacyEnabled = 0;
3001 RsnEnabled = 0;
3002 break;
3003 }
3004
3005 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3006 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3007 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3008 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3009 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3010 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3011 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3012 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3013}
3014
Jeff Johnson295189b2012-06-20 16:38:30 -07003015static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3016{
3017 tANI_U32 len = 0;
3018 if(pSSID->length <= WNI_CFG_SSID_LEN)
3019 {
3020 len = pSSID->length;
3021 }
3022 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3023}
3024
Jeff Johnson295189b2012-06-20 16:38:30 -07003025eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3026{
3027 eHalStatus status = eHAL_STATUS_SUCCESS;
3028 tANI_U32 QoSEnabled;
3029 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003030 // set the CFG enable/disable variables based on the qosType being configured...
3031 switch( qosType )
3032 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003033 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3034 QoSEnabled = FALSE;
3035 WmeEnabled = TRUE;
3036 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003037 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3038 QoSEnabled = FALSE;
3039 WmeEnabled = TRUE;
3040 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003041 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3042 QoSEnabled = FALSE;
3043 WmeEnabled = TRUE;
3044 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003045 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3046 QoSEnabled = TRUE;
3047 WmeEnabled = FALSE;
3048 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003049 case eCSR_MEDIUM_ACCESS_11e_HCF:
3050 QoSEnabled = TRUE;
3051 WmeEnabled = FALSE;
3052 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003053 default:
3054 case eCSR_MEDIUM_ACCESS_DCF:
3055 QoSEnabled = FALSE;
3056 WmeEnabled = FALSE;
3057 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003058 }
3059 //save the WMM setting for later use
3060 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003061 status = ccmCfgSetInt(pMac, WNI_CFG_QOS_ENABLED, QoSEnabled, NULL, eANI_BOOLEAN_FALSE);
3062 status = ccmCfgSetInt(pMac, WNI_CFG_WME_ENABLED, WmeEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003063 return (status);
3064}
Jeff Johnson295189b2012-06-20 16:38:30 -07003065static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
3066 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet)
3067{
3068 eHalStatus status = eHAL_STATUS_FAILURE;
3069 int i;
3070 eCsrCfgDot11Mode cfgDot11Mode;
3071 tANI_U8 *pDstRate;
Jeff Johnson295189b2012-06-20 16:38:30 -07003072 palZeroMemory(pMac->hHdd, pOpRateSet, sizeof(tSirMacRateSet));
3073 palZeroMemory(pMac->hHdd, pExRateSet, sizeof(tSirMacRateSet));
Jeff Johnson295189b2012-06-20 16:38:30 -07003074#if defined(VOSS_ENABLED)
3075 VOS_ASSERT( pIes != NULL );
3076#endif
3077
3078 if( NULL != pIes )
3079 {
3080 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003081 // Originally, we thought that for 11a networks, the 11a rates are always
3082 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3083 // appear in the Operational Rate set. Consequently, in either case, we
3084 // would blindly put the rates we support into our Operational Rate set
3085 // (including the basic rates, which we have already verified are
3086 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003087 // However, it turns out that this is not always the case. Some AP's
3088 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3089 // too. Now, we're a little more careful:
3090 pDstRate = pOpRateSet->rate;
3091 if(pIes->SuppRates.present)
3092 {
3093 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3094 {
3095 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3096 {
3097 *pDstRate++ = pIes->SuppRates.rates[ i ];
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003098 pOpRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003099 }
3100 }
3101 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003102 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3103 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3104 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3105 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3106 {
3107 // If there are Extended Rates in the beacon, we will reflect those
3108 // extended rates that we support in out Extended Operational Rate
3109 // set:
3110 pDstRate = pExRateSet->rate;
3111 if(pIes->ExtSuppRates.present)
3112 {
3113 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3114 {
3115 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) )
3116 {
3117 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3118 pExRateSet->numRates++;
3119 }
3120 }
3121 }
3122 }
3123 }//Parsing BSSDesc
3124 else
3125 {
3126 smsLog(pMac, LOGE, FL("failed to parse BssDesc\n"));
3127 }
3128 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3129 return status;
3130}
3131
3132static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3133 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3134{
3135 int i;
3136 tANI_U8 *pDstRate;
3137 eCsrCfgDot11Mode cfgDot11Mode;
3138 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3139 tANI_U32 OperationalRatesLength = 0;
3140 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3141 tANI_U32 ExtendedOperationalRatesLength = 0;
3142 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3143 tANI_U32 ProprietaryOperationalRatesLength = 0;
3144 tANI_U32 PropRatesEnable = 0;
3145 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3146 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003147#if defined(VOSS_ENABLED)
3148 VOS_ASSERT( pIes != NULL );
3149#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003150 if( NULL != pIes )
3151 {
3152 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003153 // Originally, we thought that for 11a networks, the 11a rates are always
3154 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3155 // appear in the Operational Rate set. Consequently, in either case, we
3156 // would blindly put the rates we support into our Operational Rate set
3157 // (including the basic rates, which we have already verified are
3158 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003159 // However, it turns out that this is not always the case. Some AP's
3160 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3161 // too. Now, we're a little more careful:
3162 pDstRate = OperationalRates;
3163 if(pIes->SuppRates.present)
3164 {
3165 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3166 {
3167 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3168 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3169 {
3170 *pDstRate++ = pIes->SuppRates.rates[ i ];
3171 OperationalRatesLength++;
3172 }
3173 }
3174 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003175 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3176 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3177 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3178 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3179 {
3180 // If there are Extended Rates in the beacon, we will reflect those
3181 // extended rates that we support in out Extended Operational Rate
3182 // set:
3183 pDstRate = ExtendedOperationalRates;
3184 if(pIes->ExtSuppRates.present)
3185 {
3186 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3187 {
3188 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3189 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3190 {
3191 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3192 ExtendedOperationalRatesLength++;
3193 }
3194 }
3195 }
3196 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003197 // Enable proprietary MAC features if peer node is Airgo node and STA
3198 // user wants to use them
3199 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3200 {
3201 PropRatesEnable = 1;
3202 }
3203 else
3204 {
3205 PropRatesEnable = 0;
3206 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003207 // For ANI network companions, we need to populate the proprietary rate
3208 // set with any proprietary rates we found in the beacon, only if user
3209 // allows them...
3210 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3211 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3212 {
3213 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3214 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3215 {
3216 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3217 }
3218 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates, pIes->Airgo.PropSuppRates.rates, ProprietaryOperationalRatesLength );
3219 }
3220 else {
3221 // No proprietary modes...
3222 ProprietaryOperationalRatesLength = 0;
3223 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003224 /* Get MCS Rate */
3225 pDstRate = MCSRateIdxSet;
3226 if ( pIes->HTCaps.present )
3227 {
3228 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3229 {
3230 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3231 {
3232 MCSRateLength++;
3233 *pDstRate++ = i;
3234 }
3235 }
3236 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003237 // Set the operational rate set CFG variables...
3238 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3239 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3240 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3241 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3242 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3243 ProprietaryOperationalRates,
3244 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3245 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3246 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3247 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3248 }//Parsing BSSDesc
3249 else
3250 {
3251 smsLog(pMac, LOGE, FL("failed to parse BssDesc\n"));
3252 }
3253}
3254
Jeff Johnson295189b2012-06-20 16:38:30 -07003255static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3256 tCsrRoamProfile *pProfile )
3257{
3258 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3259 { 8,
3260 { SIR_MAC_RATE_6,
3261 SIR_MAC_RATE_9,
3262 SIR_MAC_RATE_12,
3263 SIR_MAC_RATE_18,
3264 SIR_MAC_RATE_24,
3265 SIR_MAC_RATE_36,
3266 SIR_MAC_RATE_48,
3267 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003268 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3269 { 4,
3270 { SIR_MAC_RATE_1,
3271 SIR_MAC_RATE_2,
3272 SIR_MAC_RATE_5_5,
3273 SIR_MAC_RATE_11 } } };
3274
3275
3276 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3277 { SIR_MAC_RATE_72,
3278 SIR_MAC_RATE_96,
3279 SIR_MAC_RATE_108 } };
3280 eCsrCfgDot11Mode cfgDot11Mode;
3281 eCsrBand eBand;
3282 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3283 tANI_U32 OperationalRatesLength = 0;
3284 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3285 tANI_U32 ExtendedOperationalRatesLength = 0;
3286 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3287 tANI_U32 ProprietaryOperationalRatesLength = 0;
3288 tANI_U32 PropRatesEnable = 0;
3289 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003290 if(pProfile->ChannelInfo.ChannelList)
3291 {
3292 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3293 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003294 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07003295 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3296 // networks, the 11b rates appear in the Operational Rate set. In either case,
3297 // we can blindly put the rates we support into our Operational Rate set
3298 // (including the basic rates, which we have already verified are supported
3299 // earlier in the roaming decision).
3300 if ( eCSR_BAND_5G == eBand )
3301 {
3302 // 11a rates into the Operational Rate Set.
3303 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3304 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
3305 palCopyMemory( pMac->hHdd, OperationalRates,
3306 DefaultSupportedRates11a.supportedRateSet.rate,
3307 OperationalRatesLength );
3308
3309 // Nothing in the Extended rate set.
3310 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003311 // populate proprietary rates if user allows them
3312 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3313 {
3314 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3315 sizeof(*DefaultSupportedPropRates.propRate);
3316 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates,
3317 DefaultSupportedPropRates.propRate,
3318 ProprietaryOperationalRatesLength );
3319 }
3320 else
3321 {
3322 // No proprietary modes
3323 ProprietaryOperationalRatesLength = 0;
3324 }
3325 }
3326 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3327 {
3328 // 11b rates into the Operational Rate Set.
3329 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3330 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
3331 palCopyMemory( pMac->hHdd, OperationalRates,
3332 DefaultSupportedRates11b.supportedRateSet.rate,
3333 OperationalRatesLength );
3334 // Nothing in the Extended rate set.
3335 ExtendedOperationalRatesLength = 0;
3336 // No proprietary modes
3337 ProprietaryOperationalRatesLength = 0;
3338 }
3339 else
3340 {
3341 // 11G
3342
3343 // 11b rates into the Operational Rate Set.
3344 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3345 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
3346 palCopyMemory( pMac->hHdd, OperationalRates,
3347 DefaultSupportedRates11b.supportedRateSet.rate,
3348 OperationalRatesLength );
3349
3350 // 11a rates go in the Extended rate set.
3351 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3352 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
3353 palCopyMemory( pMac->hHdd, ExtendedOperationalRates,
3354 DefaultSupportedRates11a.supportedRateSet.rate,
3355 ExtendedOperationalRatesLength );
3356
3357 // populate proprietary rates if user allows them
3358 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3359 {
3360 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3361 sizeof(*DefaultSupportedPropRates.propRate);
3362 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates,
3363 DefaultSupportedPropRates.propRate,
3364 ProprietaryOperationalRatesLength );
3365 }
3366 else
3367 {
3368 // No proprietary modes
3369 ProprietaryOperationalRatesLength = 0;
3370 }
3371 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003372 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3373 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3374 {
3375 PropRatesEnable = 1;
3376 }
3377 else
3378 {
3379 PropRatesEnable = 0;
3380 }
3381
3382 // Set the operational rate set CFG variables...
3383 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3384 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3385 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3386 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3387 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3388 ProprietaryOperationalRates,
3389 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3390 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003391}
Jeff Johnson295189b2012-06-20 16:38:30 -07003392void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3393{
3394 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07003395
Jeff Johnson295189b2012-06-20 16:38:30 -07003396 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3397 tANI_U32 sessionId;
3398 tSmeCmd *pCommand = NULL;
3399
3400 if(NULL == pEntry)
3401 {
3402 smsLog(pMac, LOGW, " CFG_CNF with active list empty\n");
3403 return;
3404 }
3405 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3406 sessionId = pCommand->sessionId;
3407
3408 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3409 {
3410 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3411 }
3412}
3413
Jeff Johnson295189b2012-06-20 16:38:30 -07003414//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3415tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3416{
3417 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3418 {
3419 return (WNI_CFG_PHY_MODE_11B);
3420 }
3421 else
3422 {
3423 if(eCSR_BAND_24 == band)
3424 return (WNI_CFG_PHY_MODE_11G);
3425 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003426 return (WNI_CFG_PHY_MODE_11A);
3427}
Jeff Johnson295189b2012-06-20 16:38:30 -07003428
Jeff Johnsone7245742012-09-05 17:12:55 -07003429
3430#ifdef WLAN_FEATURE_11AC
3431ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
3432{
3433 switch ( aniCBMode )
3434 {
3435 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
3436 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
3437 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
3438 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3439 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
3440 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
3441 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
3442 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3443 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003444 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07003445 return PHY_SINGLE_CHANNEL_CENTERED;
3446 }
3447}
3448#endif
3449
Jeff Johnson295189b2012-06-20 16:38:30 -07003450//pIes may be NULL
3451eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3452 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
3453 tDot11fBeaconIEs *pIes)
3454{
3455 eHalStatus status = eHAL_STATUS_SUCCESS;
3456 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3457 tANI_U8 channel = 0;
3458 //Make sure we have the domain info for the BSS we try to connect to.
3459 //Do we need to worry about sequence for OSs that are not Windows??
3460 if(pBssDesc)
3461 {
3462 if(csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
3463 {
3464 //Make sure the 11d info from this BSSDesc can be applied
3465 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
3466 csrApplyCountryInformation( pMac, TRUE );
3467 }
Kirand170dcb2013-01-31 10:43:43 -08003468 if ((csrIs11dSupported (pMac)) && pIes)
3469 {
3470 if (!pIes->Country.present)
3471 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
3472 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003473 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003474 //Qos
3475 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3476 //SSID
3477 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3478 //fragment threshold
3479 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3480 //RTS threshold
3481 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3482
3483 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
3484
3485 //Auth type
3486 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
3487 //encryption type
3488 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
3489 //short slot time
3490 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003491 //11d
3492 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
3493 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
3494 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003495 /*//11h
3496 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
3497 */
3498 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
3499 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07003500
Jeff Johnson295189b2012-06-20 16:38:30 -07003501 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile))
3502 {
3503 channel = pProfile->operationChannel;
3504 }
3505 else
3506 {
3507 if(pBssDesc)
3508 {
3509 channel = pBssDesc->channelId;
3510 }
3511 }
3512 if(0 != channel)
3513 {
3514 if(CSR_IS_CHANNEL_24GHZ(channel))
3515 {//for now if we are on 2.4 Ghz, CB will be always disabled
3516 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3517 }
3518 else
3519 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003520 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003521 }
3522 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003523#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08003524 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
3525 // in function csrConvertCBIniValueToPhyCBState()
3526 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
3527 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07003528 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003529 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003530 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003531 }
3532 else
3533 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003534 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003535 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003536 }
3537 else
3538#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003539 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
3540 //Rate
3541 //Fixed Rate
3542 if(pBssDesc)
3543 {
3544 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
3545 }
3546 else
3547 {
3548 csrSetCfgRateSetFromProfile(pMac, pProfile);
3549 }
3550 //Make this the last CFG to set. The callback will trigger a join_req
3551 //Join time out
3552 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
3553
3554 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003555 return (status);
3556}
3557
Jeff Johnson295189b2012-06-20 16:38:30 -07003558eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3559 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3560{
3561 eHalStatus status;
3562 tBssConfigParam *pBssConfig;
3563 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003564
3565 if(!pSession)
3566 {
3567 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3568 return eHAL_STATUS_FAILURE;
3569 }
3570
Jeff Johnson295189b2012-06-20 16:38:30 -07003571 status = palAllocateMemory(pMac->hHdd, (void **)&pBssConfig, sizeof(tBssConfigParam));
3572 if(HAL_STATUS_SUCCESS(status))
3573 {
3574 palZeroMemory(pMac->hHdd, pBssConfig, sizeof(tBssConfigParam));
3575 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
3576 if(HAL_STATUS_SUCCESS(status))
3577 {
3578 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003579 /* This will allow to pass cbMode during join req */
3580 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003581 //For IBSS, we need to prepare some more information
3582 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003583 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003584 )
3585 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003586 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07003587 }
3588 // If we are in an IBSS, then stop the IBSS...
3589 ////Not worry about WDS connection for now
3590 if ( csrIsConnStateIbss( pMac, sessionId ) )
3591 {
3592 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
3593 }
3594 else
3595 {
3596 // if we are in an Infrastructure association....
3597 if ( csrIsConnStateInfra( pMac, sessionId ) )
3598 {
3599 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
3600 // across SSIDs (roaming to a new SSID)... //
3601 //Not worry about WDS connection for now
3602 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
3603 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
3604 {
3605 // then we need to disassociate from the Infrastructure network...
3606 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
3607 }
3608 else
3609 {
3610 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
3611 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
3612 if ( pBssDesc )
3613 {
3614 // Set parameters for this Bss.
3615 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
3616 }
3617 }
3618 }
3619 else
3620 {
3621 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
3622 // Nothing to stop.
3623 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003624 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003625 )
3626 {
3627 // Set parameters for this Bss.
3628 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
3629 }
3630 }
3631 }
3632 }//Success getting BSS config info
3633 palFreeMemory(pMac->hHdd, pBssConfig);
3634 }//Allocate memory
3635
3636 return (status);
3637}
3638
Jeff Johnson295189b2012-06-20 16:38:30 -07003639eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
3640 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
3641{
3642 eCsrJoinState eRoamState = eCsrContinueRoaming;
3643 eHalStatus status;
3644 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
3645 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
3646 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003647
3648 if(!pSession)
3649 {
3650 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3651 return (eCsrStopRoaming);
3652 }
3653
Jeff Johnson295189b2012-06-20 16:38:30 -07003654 if( CSR_IS_WDS_STA( pProfile ) )
3655 {
3656 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
3657 if( !HAL_STATUS_SUCCESS( status ) )
3658 {
3659 eRoamState = eCsrStopRoaming;
3660 }
3661 }
3662 else
3663 {
3664 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
3665 {
3666 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
3667 return (eCsrStopRoaming);
3668 }
3669 if ( csrIsInfraBssDesc( pBssDesc ) )
3670 {
3671 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
3672 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
3673 // have changed and handle the changes (without disturbing the current association).
3674
3675 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
3676 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
3677 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
3678 )
3679 {
3680 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
3681 // with Authenticating first. To force this, stop the current association (Disassociate) and
3682 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
3683 // a new Association.
3684 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
3685 {
3686 smsLog(pMac, LOGW, FL(" detect same profile authType = %d encryType = %d\n"), pProfile->AuthType, pProfile->EncryptionType);
3687 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
3688 {
3689 eRoamState = eCsrReassocToSelfNoCapChange;
3690 }
3691 else
3692 {
3693 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07003694 //The key changes
3695 palZeroMemory(pMac->hHdd, &bssConfig, sizeof(bssConfig));
3696 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
3697 if(HAL_STATUS_SUCCESS(status))
3698 {
3699 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003700 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003701 //Reapply the config including Keys so reassoc is happening.
3702 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, pBssDesc, &bssConfig, pIesLocal);
3703 if(!HAL_STATUS_SUCCESS(status))
3704 {
3705 eRoamState = eCsrStopRoaming;
3706 }
3707 }
3708 else
3709 {
3710 eRoamState = eCsrStopRoaming;
3711 }
3712 }//same profile
3713 }
3714 else
3715 {
3716 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
3717 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
3718 {
3719 smsLog(pMac, LOGW, FL(" fail to issue disassociate\n"));
3720 eRoamState = eCsrStopRoaming;
3721 }
3722 }
3723 }
3724 else
3725 {
3726 // note: we used to pre-auth here with open authentication networks but that was not working so well.
3727 // we had a lot of join timeouts when testing at Samsung. removing this step helped associations
3728 // work much better.
3729 //
3730 //
3731 // stop the existing network before attempting to join the new network...
3732 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
3733 {
3734 eRoamState = eCsrStopRoaming;
3735 }
3736 }
3737 }//Infra
3738 else
3739 {
3740 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
3741 {
3742 eRoamState = eCsrStopRoaming;
3743 }
3744 }
3745 if( pIesLocal && !pScanResult->pvIes )
3746 {
3747 palFreeMemory(pMac->hHdd, pIesLocal);
3748 }
3749 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003750 return( eRoamState );
3751}
3752
Jeff Johnson295189b2012-06-20 16:38:30 -07003753eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
3754 tSirBssDescription *pBssDesc, tANI_U32 roamId)
3755{
3756 eHalStatus status = eHAL_STATUS_SUCCESS;
3757 tCsrRoamInfo roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07003758 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
3759 roamInfo.pBssDesc = pBssDesc;
3760 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
3761 return (status);
3762}
Jeff Johnson295189b2012-06-20 16:38:30 -07003763//In case no matching BSS is found, use whatever default we can find
3764static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
3765{
3766 //Need to get all negotiated types in place first
3767 //auth type
Jeff Johnson3d30ed12012-12-10 14:41:22 -08003768 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003769 {
3770 default:
3771 case eCSR_AUTH_TYPE_WPA:
3772 case eCSR_AUTH_TYPE_WPA_PSK:
3773 case eCSR_AUTH_TYPE_WPA_NONE:
3774 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3775 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3776 break;
3777
3778 case eCSR_AUTH_TYPE_SHARED_KEY:
3779 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
3780 break;
3781
3782 case eCSR_AUTH_TYPE_AUTOSWITCH:
3783 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
3784 break;
3785 }
3786 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
3787 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
3788 //In this case, the multicast encryption needs to follow the uncast ones.
3789 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
3790 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
3791}
3792
3793static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
3794{
3795 eHalStatus status;
3796 tCsrScanResult *pScanResult = NULL;
3797 eCsrJoinState eRoamState = eCsrStopRoaming;
3798 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
3799 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
3800 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
3801#ifndef WLAN_MDM_CODE_REDUCTION_OPT
3802 v_U8_t acm_mask = 0;
3803#endif
3804 tANI_U32 sessionId = pCommand->sessionId;
3805 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3806 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
3807 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07003808
3809 if(!pSession)
3810 {
3811 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3812 return (eCsrStopRoaming);
3813 }
3814
Jeff Johnson295189b2012-06-20 16:38:30 -07003815 do
3816 {
3817 // Check for Cardbus eject condition, before trying to Roam to any BSS
3818 //***if( !balIsCardPresent(pAdapter) ) break;
3819
3820 if(NULL != pBSSList)
3821 {
3822 // When handling AP's capability change, continue to associate to
3823 // same BSS and make sure pRoamBssEntry is not Null.
3824 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
3825 {
3826 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
3827 {
3828 //Try the first BSS
3829 pCommand->u.roamCmd.pLastRoamBss = NULL;
3830 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
3831 }
3832 else
3833 {
3834 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
3835 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
3836 {
3837 //Done with all the BSSs
3838 //In this case, will tell HDD the completion
3839 break;
3840 }
3841 else
3842 {
3843 //We need to indicate to HDD that we are done with this one.
3844 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
3845 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
3846 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
3847 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
3848 pRoamInfo = &roamInfo;
3849 }
3850 }
3851 while(pCommand->u.roamCmd.pRoamBssEntry)
3852 {
3853 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07003854 /*If concurrency enabled take the concurrent connected channel first. */
3855 /* Valid multichannel concurrent sessions exempted */
Jeff Johnsone7245742012-09-05 17:12:55 -07003856 if (vos_concurrent_sessions_running() &&
3857 !csrIsValidMcConcurrentSession(pMac, sessionId, &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07003858 {
3859 concurrentChannel =
3860 csrGetConcurrentOperationChannel(pMac);
3861 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003862 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07003863 if ((concurrentChannel) &&
3864 (concurrentChannel ==
3865 pScanResult->Result.BssDescriptor.channelId))
3866 {
3867 //make this 0 because we do not want the
3868 //below check to pass as we don't want to
3869 //connect on other channel
3870 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
3871 FL("Concurrent channel match =%d"),
3872 concurrentChannel);
3873 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003874 }
3875 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003876
3877 if (!concurrentChannel)
3878 {
3879
3880 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
3881 sessionId, &pScanResult->Result.BssDescriptor,
3882 pCommand->u.roamCmd.roamId)))
3883 {
3884 //Ok to roam this
3885 break;
3886 }
3887 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003888 else
3889 {
3890 eRoamState = eCsrStopRoamingDueToConcurrency;
3891 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003892 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
3893 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
3894 {
3895 //Done with all the BSSs
3896 fDone = eANI_BOOLEAN_TRUE;
3897 break;
3898 }
3899 }
3900 if(fDone)
3901 {
3902 break;
3903 }
3904 }
3905 }
3906 //We have something to roam, tell HDD when it is infra.
3907 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
3908 //For WDS, the indication is eCSR_ROAM_WDS_IND
3909 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
3910 {
3911 if(pRoamInfo)
3912 {
3913 pSession->bRefAssocStartCnt--;
3914 //Complete the last association attemp because a new one is about to be tried
3915 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
3916 eCSR_ROAM_ASSOCIATION_COMPLETION,
3917 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
3918 }
3919 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
3920 if(pScanResult)
3921 {
3922 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07003923 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
3924 {
3925 smsLog(pMac, LOGE, FL(" cannot parse IEs\n"));
3926 fDone = eANI_BOOLEAN_TRUE;
3927 eRoamState = eCsrStopRoaming;
3928 break;
3929 }
3930 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
3931 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
3932 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
3933 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
3934 CSR_IS_QOS_BSS(pIesLocal) &&
3935 CSR_IS_UAPSD_BSS(pIesLocal) )
3936 {
3937#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07003938 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
3939 pIesLocal);
3940 pCommand->u.roamCmd.roamProfile.uapsd_mask &= ~(acm_mask);
3941#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07003942 }
3943 else
3944 {
3945 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
3946 }
3947 if( pIesLocal && !pScanResult->Result.pvIes)
3948 {
3949 palFreeMemory(pMac->hHdd, pIesLocal);
3950 }
3951 }
3952 else
3953 {
3954 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
3955 }
3956 roamInfo.pProfile = pProfile;
3957 pSession->bRefAssocStartCnt++;
3958 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
3959 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
3960 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003961 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
3962 {
3963 // If this is a start IBSS profile, then we need to start the IBSS.
3964 if ( CSR_IS_START_IBSS(pProfile) )
3965 {
3966 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003967 // Attempt to start this IBSS...
3968 csrRoamAssignDefaultParam( pMac, pCommand );
3969 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
3970 if(HAL_STATUS_SUCCESS(status))
3971 {
3972 if ( fSameIbss )
3973 {
3974 eRoamState = eCsrStartIbssSameIbss;
3975 }
3976 else
3977 {
3978 eRoamState = eCsrContinueRoaming;
3979 }
3980 }
3981 else
3982 {
3983 //it somehow fail need to stop
3984 eRoamState = eCsrStopRoaming;
3985 }
3986 break;
3987 }
3988 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07003989 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07003990 )
3991 {
3992 // Attempt to start this WDS...
3993 csrRoamAssignDefaultParam( pMac, pCommand );
3994 /* For AP WDS, we dont have any BSSDescription */
3995 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
3996 if(HAL_STATUS_SUCCESS(status))
3997 {
3998 eRoamState = eCsrContinueRoaming;
3999 }
4000 else
4001 {
4002 //it somehow fail need to stop
4003 eRoamState = eCsrStopRoaming;
4004 }
4005 }
4006 else
4007 {
4008 //Nothing we can do
4009 smsLog(pMac, LOGW, FL("cannot continue without BSS list\n"));
4010 eRoamState = eCsrStopRoaming;
4011 break;
4012 }
4013 }
4014 else //We have BSS
4015 {
4016 //Need to assign these value because they are used in csrIsSameProfile
4017 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4018 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType = pScanResult->ucEncryptionType; //Negotiated while building scan result.
4019 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType = pScanResult->mcEncryptionType;
4020 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4021 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4022 {
4023 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4024 {
4025 eRoamState = eCsrStartIbssSameIbss;
4026 break;
4027 }
4028 }
4029 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4030 {
4031 //trying to connect to the one already connected
4032 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4033 eRoamState = eCsrReassocToSelfNoCapChange;
4034 break;
4035 }
4036 // Attempt to Join this Bss...
4037 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4038 break;
4039 }
4040
4041 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004042 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4043 {
4044 //Need to indicate association_completion if association_start has been done
4045 if(pSession->bRefAssocStartCnt > 0)
4046 {
4047 pSession->bRefAssocStartCnt--;
4048 //Complete the last association attemp because a new one is about to be tried
4049 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4050 eCSR_ROAM_ASSOCIATION_COMPLETION,
4051 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4052 }
4053 }
4054
4055 return( eRoamState );
4056}
4057
Jeff Johnson295189b2012-06-20 16:38:30 -07004058static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4059{
4060 eHalStatus status = eHAL_STATUS_SUCCESS;
4061 eCsrJoinState RoamState;
4062 tANI_U32 sessionId = pCommand->sessionId;
4063
Jeff Johnson295189b2012-06-20 16:38:30 -07004064 //***if( hddIsRadioStateOn( pAdapter ) )
4065 {
4066 // Attept to join a Bss...
4067 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004068
Jeff Johnson295189b2012-06-20 16:38:30 -07004069 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004070 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004071 {
4072 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004073 // and if connected in Infrastructure mode...
4074 if ( csrIsConnStateInfra(pMac, sessionId) )
4075 {
4076 //... then we need to issue a disassociation
4077 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4078 if(!HAL_STATUS_SUCCESS(status))
4079 {
4080 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d\n"), status);
4081 //roam command is completed by caller in the failed case
4082 fComplete = eANI_BOOLEAN_TRUE;
4083 }
4084 }
4085 else if( csrIsConnStateIbss(pMac, sessionId) )
4086 {
4087 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4088 if(!HAL_STATUS_SUCCESS(status))
4089 {
4090 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d\n"), status);
4091 //roam command is completed by caller in the failed case
4092 fComplete = eANI_BOOLEAN_TRUE;
4093 }
4094 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004095 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4096 {
4097 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4098 if(!HAL_STATUS_SUCCESS(status))
4099 {
4100 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d\n"), status);
4101 //roam command is completed by caller in the failed case
4102 fComplete = eANI_BOOLEAN_TRUE;
4103 }
4104 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004105 else
4106 {
4107 fComplete = eANI_BOOLEAN_TRUE;
4108 }
4109 if(fComplete)
4110 {
4111 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004112 if(eCsrStopRoamingDueToConcurrency == RoamState)
4113 {
4114 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4115 }
4116 else
4117 {
4118 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4119 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004120 }
4121 }
4122 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4123 {
4124 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4125 }
4126 else if ( eCsrStartIbssSameIbss == RoamState )
4127 {
4128 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4129 }
4130 }//hddIsRadioStateOn
4131
4132 return status;
4133}
Jeff Johnson295189b2012-06-20 16:38:30 -07004134eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4135{
4136 tANI_U32 sessionId;
4137 tCsrRoamSession *pSession;
4138 tCsrScanResult *pScanResult = NULL;
4139 tSirBssDescription *pBssDesc = NULL;
4140 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004141 sessionId = pCommand->sessionId;
4142 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004143
4144 if(!pSession)
4145 {
4146 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4147 return eHAL_STATUS_FAILURE;
4148 }
4149
Jeff Johnson295189b2012-06-20 16:38:30 -07004150 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4151 {
4152 //the roaming is cancelled. Simply complete the command
4153 smsLog(pMac, LOG1, FL(" Roam command cancelled\n"));
4154 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4155 return eHAL_STATUS_FAILURE;
4156 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004157 if (pCommand->u.roamCmd.pRoamBssEntry)
4158 {
4159 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4160 pBssDesc = &pScanResult->Result.BssDescriptor;
4161 }
4162 else
4163 {
4164 //the roaming is cancelled. Simply complete the command
4165 smsLog(pMac, LOG1, FL(" Roam command cancelled\n"));
4166 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4167 return eHAL_STATUS_FAILURE;
4168 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004169 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4170 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4171 return status;
4172}
4173
Jeff Johnson295189b2012-06-20 16:38:30 -07004174eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4175{
4176 eHalStatus status = eHAL_STATUS_SUCCESS;
4177 tCsrRoamInfo roamInfo;
4178 tANI_U32 sessionId = pCommand->sessionId;
4179 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004180
4181 if(!pSession)
4182 {
4183 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4184 return eHAL_STATUS_FAILURE;
4185 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004186
4187 switch ( pCommand->u.roamCmd.roamReason )
4188 {
4189 case eCsrForcedDisassoc:
4190 csrFreeRoamProfile(pMac, sessionId);
4191 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4192 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004193 case eCsrSmeIssuedDisassocForHandoff:
4194 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4195#if 0 // TODO : Confirm this change
4196 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4197#else
4198 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4199#endif
4200
4201 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004202 case eCsrForcedDisassocMICFailure:
4203 csrFreeRoamProfile(pMac, sessionId);
4204 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
4205 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004206 case eCsrForcedDeauth:
4207 csrFreeRoamProfile(pMac, sessionId);
4208 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
4209 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004210 case eCsrHddIssuedReassocToSameAP:
4211 case eCsrSmeIssuedReassocToSameAP:
4212 {
4213 tDot11fBeaconIEs *pIes = NULL;
4214
Jeff Johnson295189b2012-06-20 16:38:30 -07004215 if( pSession->pConnectBssDesc )
4216 {
4217 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4218 if(!HAL_STATUS_SUCCESS(status) )
4219 {
4220 smsLog(pMac, LOGE, FL(" fail to parse IEs\n"));
4221 }
4222 else
4223 {
4224 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4225 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4226 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004227 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4228 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4229 pSession->bRefAssocStartCnt++;
4230 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4231 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4232
4233 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate\n"));
Gopichand Nakkala79353d12012-12-31 16:31:46 -08004234 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4235 &pCommand->u.roamCmd.roamProfile );
4236 if(!HAL_STATUS_SUCCESS(status))
4237 {
4238 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
4239 }
4240
Jeff Johnson295189b2012-06-20 16:38:30 -07004241 palFreeMemory(pMac->hHdd, pIes);
4242 pIes = NULL;
4243 }
4244 }
4245 break;
4246 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004247 case eCsrCapsChange:
4248 smsLog(pMac, LOGE, FL("received eCsrCapsChange \n"));
4249 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4250 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4251 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004252 case eCsrSmeIssuedFTReassoc:
4253 smsLog(pMac, LOGE, FL("received FT Reassoc Req \n"));
4254 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4255 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004256
Jeff Johnson295189b2012-06-20 16:38:30 -07004257 case eCsrStopBss:
4258 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4259 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4260 break;
4261
4262 case eCsrForcedDisassocSta:
4263 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4264 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4265 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4266 pCommand->u.roamCmd.reason);
4267 break;
4268
4269 case eCsrForcedDeauthSta:
4270 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4271 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4272 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4273 pCommand->u.roamCmd.reason);
4274 break;
Gopichand Nakkala79353d12012-12-31 16:31:46 -08004275
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004276 case eCsrPerformPreauth:
Varun Reddy Yeturu9163b672013-02-11 14:05:06 -08004277 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004278 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4279 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala79353d12012-12-31 16:31:46 -08004280 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004281
4282 default:
4283 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4284
4285 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4286 {
4287 //Remember the roaming profile
4288 csrFreeRoamProfile(pMac, sessionId);
4289 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pSession->pCurRoamProfile, sizeof(tCsrRoamProfile))))
4290 {
4291 palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile));
4292 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4293 }
4294 }
4295
4296 //At this point, original uapsd_mask is saved in pCurRoamProfile
4297 //uapsd_mask in the pCommand may change from this point on.
4298
4299 // Attempt to roam with the new scan results (if we need to..)
4300 status = csrRoam( pMac, pCommand );
Gopichand Nakkala79353d12012-12-31 16:31:46 -08004301 if(!HAL_STATUS_SUCCESS(status))
4302 {
4303 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X\n"), status);
4304 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004305 break;
4306 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004307 return (status);
4308}
4309
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004310void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4311{
4312 pCommand->u.roamCmd.pLastRoamBss = NULL;
4313 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4314 //Because u.roamCmd is union and share with scanCmd and StatusChange
4315 palZeroMemory(pMac->hHdd, &pCommand->u.roamCmd, sizeof(tRoamCmd));
4316}
4317
Jeff Johnson295189b2012-06-20 16:38:30 -07004318void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4319{
4320 if(pCommand->u.roamCmd.fReleaseBssList)
4321 {
4322 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4323 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4324 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4325 }
4326 if(pCommand->u.roamCmd.fReleaseProfile)
4327 {
4328 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4329 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4330 }
4331 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4332 //Because u.roamCmd is union and share with scanCmd and StatusChange
4333 palZeroMemory(pMac->hHdd, &pCommand->u.roamCmd, sizeof(tRoamCmd));
4334}
4335
Jeff Johnson295189b2012-06-20 16:38:30 -07004336void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4337{
4338 palZeroMemory(pMac->hHdd, &pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd));
4339}
Jeff Johnson295189b2012-06-20 16:38:30 -07004340void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4341{
4342 tListElem *pEntry;
4343 tSmeCmd *pCommand;
4344 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Gopichand Nakkala79353d12012-12-31 16:31:46 -08004345 smsLog( pMac, LOG2, "Roam Completion ...\n" );
Jeff Johnson295189b2012-06-20 16:38:30 -07004346 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4347 if ( pEntry )
4348 {
4349 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004350 // If the head of the queue is Active and it is a ROAM command, remove
4351 // and put this on the Free queue.
4352 if ( eSmeCommandRoam == pCommand->command )
4353 {
4354 //we need to process the result first before removing it from active list because state changes
4355 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4356 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4357 if( fReleaseCommand )
4358 {
4359 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4360 {
4361 csrReleaseCommandRoam( pMac, pCommand );
4362 }
4363 else
4364 {
4365 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d\n",
Gopichand Nakkala79353d12012-12-31 16:31:46 -08004366 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004367 }
4368 }
4369 else
4370 {
4371 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d\n",
Gopichand Nakkala79353d12012-12-31 16:31:46 -08004372 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004373 }
4374 }
4375 else
4376 {
4377 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ...\n" );
4378 }
4379 }
4380 else
4381 {
4382 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ...\n" );
4383 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004384 if( fReleaseCommand )
4385 {
4386 smeProcessPendingQueue( pMac );
4387 }
4388}
4389
Jeff Johnson295189b2012-06-20 16:38:30 -07004390void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4391{
4392 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004393 if(!pSession)
4394 {
4395 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4396 return;
4397 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004398 palZeroMemory( pMac->hHdd, &(pSession->PmkidCandidateInfo[0]), sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED );
4399 pSession->NumPmkidCandidate = 0;
4400}
Jeff Johnson295189b2012-06-20 16:38:30 -07004401#ifdef FEATURE_WLAN_WAPI
4402void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4403{
4404 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004405 if(!pSession)
4406 {
4407 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4408 return;
4409 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004410 palZeroMemory( pMac->hHdd, &(pSession->BkidCandidateInfo[0]), sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED );
4411 pSession->NumBkidCandidate = 0;
4412}
4413#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004414extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4415
Jeff Johnson295189b2012-06-20 16:38:30 -07004416static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4417 tSirBssDescription *pSirBssDesc,
4418 tDot11fBeaconIEs *pIes)
4419{
4420 eHalStatus status = eHAL_STATUS_SUCCESS;
4421 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4422 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004423
4424 if(!pSession)
4425 {
4426 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4427 return eHAL_STATUS_FAILURE;
4428 }
4429
Jeff Johnson295189b2012-06-20 16:38:30 -07004430 if((eCSR_AUTH_TYPE_WPA == authType) ||
4431 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
4432 (eCSR_AUTH_TYPE_RSN == authType) ||
4433 (eCSR_AUTH_TYPE_RSN_PSK == authType)
4434#if defined WLAN_FEATURE_VOWIFI_11R
4435 ||
4436 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4437 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
4438#endif /* FEATURE_WLAN_WAPI */
4439#ifdef FEATURE_WLAN_WAPI
4440 ||
4441 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4442 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
4443#endif /* FEATURE_WLAN_WAPI */
4444 )
4445 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004446 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4447 {
4448 smsLog(pMac, LOGE, FL(" cannot parse IEs\n"));
4449 }
4450 if( pIesLocal )
4451 {
4452 tANI_U32 nIeLen;
4453 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07004454 if((eCSR_AUTH_TYPE_RSN == authType) ||
4455#if defined WLAN_FEATURE_VOWIFI_11R
4456 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4457 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
4458#endif /* WLAN_FEATURE_VOWIFI_11R */
4459 (eCSR_AUTH_TYPE_RSN_PSK == authType))
4460 {
4461 if(pIesLocal->RSN.present)
4462 {
4463 //Calculate the actual length
4464 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
4465 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
4466 + 2 //akm_suite_count
4467 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
4468 + 2; //reserved
4469 if( pIesLocal->RSN.pmkid_count )
4470 {
4471 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
4472 }
4473 //nIeLen doesn't count EID and length fields
4474 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnRspIE, nIeLen + 2))))
4475 {
4476 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
4477 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4478 //copy upto akm_suites
4479 pIeBuf = pSession->pWpaRsnRspIE + 2;
4480 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.version, 8);
4481 pIeBuf += 8;
4482 if( pIesLocal->RSN.pwise_cipher_suite_count )
4483 {
4484 //copy pwise_cipher_suites
4485 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.pwise_cipher_suites,
4486 pIesLocal->RSN.pwise_cipher_suite_count * 4);
4487 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
4488 }
4489 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
4490 pIeBuf += 2;
4491 if( pIesLocal->RSN.akm_suite_count )
4492 {
4493 //copy akm_suites
4494 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.akm_suites,
4495 pIesLocal->RSN.akm_suite_count * 4);
4496 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
4497 }
4498 //copy the rest
4499 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.akm_suites +
4500 pIesLocal->RSN.akm_suite_count * 4,
4501 2 + pIesLocal->RSN.pmkid_count * 4);
4502 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4503 }
4504 }
4505 }
4506 else if((eCSR_AUTH_TYPE_WPA == authType) ||
4507 (eCSR_AUTH_TYPE_WPA_PSK == authType))
4508 {
4509 if(pIesLocal->WPA.present)
4510 {
4511 //Calculate the actual length
4512 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
4513 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
4514 + 2 //auth_suite_count
4515 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
4516 // The WPA capabilities follows the Auth Suite (two octects)--
4517 // this field is optional, and we always "send" zero, so just
4518 // remove it. This is consistent with our assumptions in the
4519 // frames compiler; c.f. bug 15234:
4520 //nIeLen doesn't count EID and length fields
4521 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnRspIE, nIeLen + 2))))
4522 {
4523 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
4524 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4525 pIeBuf = pSession->pWpaRsnRspIE + 2;
4526 //Copy WPA OUI
4527 palCopyMemory(pMac->hHdd, pIeBuf, &csrWpaOui[1], 4);
4528 pIeBuf += 4;
4529 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WPA.version, 8 +
4530 pIesLocal->WPA.unicast_cipher_count * 4);
4531 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
4532 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WPA.auth_suite_count, 2 +
4533 pIesLocal->WPA.auth_suite_count * 4);
4534 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
4535 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4536 }
4537 }
4538 }
4539#ifdef FEATURE_WLAN_WAPI
4540 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4541 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
4542 {
4543 if(pIesLocal->WAPI.present)
4544 {
4545 //Calculate the actual length
4546 nIeLen = 4 //version + akm_suite_count
4547 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
4548 + 2 //pwise_cipher_suite_count
4549 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
4550 + 6; //gp_cipher_suite + preauth + reserved
4551 if( pIesLocal->WAPI.bkid_count )
4552 {
4553 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
4554 }
4555
4556 //nIeLen doesn't count EID and length fields
4557 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWapiRspIE, nIeLen + 2))))
4558 {
4559 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
4560 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
4561 pIeBuf = pSession->pWapiRspIE + 2;
4562 //copy upto akm_suite_count
4563 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.version, 4);
4564 pIeBuf += 4;
4565 if( pIesLocal->WAPI.akm_suite_count )
4566 {
4567 //copy akm_suites
4568 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.akm_suites,
4569 pIesLocal->WAPI.akm_suite_count * 4);
4570 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
4571 }
4572 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.unicast_cipher_suite_count, 2);
4573 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004574 if( pIesLocal->WAPI.unicast_cipher_suite_count )
4575 {
4576 //copy pwise_cipher_suites
4577 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.unicast_cipher_suites,
4578 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
4579 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
4580 }
4581 //gp_cipher_suite + preauth + reserved + bkid_count
4582 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.multicast_cipher_suite, 8);
4583 pIeBuf += 8;
4584 if( pIesLocal->WAPI.bkid_count )
4585 {
4586 //copy akm_suites
4587 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.bkid, pIesLocal->WAPI.bkid_count * 4);
4588 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
4589 }
4590 pSession->nWapiRspIeLength = nIeLen + 2;
4591 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004592 }
4593 }
4594#endif /* FEATURE_WLAN_WAPI */
4595 if( !pIes )
4596 {
4597 //locally allocated
4598 palFreeMemory(pMac->hHdd, pIesLocal);
4599 }
4600 }
4601 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004602 return (status);
4603}
4604
Jeff Johnson295189b2012-06-20 16:38:30 -07004605static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
4606{
4607 v_U8_t bACWeights[WLANTL_MAX_AC];
4608 v_U8_t paramBk, paramBe, paramVi, paramVo;
4609 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004610 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
4611 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
4612 //of the higher AC one, make the higher AC has the same weight as the lower AC.
4613 //This doesn't address the case where the lower AC needs a real higher weight
4614 if( pIEs->WMMParams.present )
4615 {
4616 //no change to the lowest ones
4617 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
4618 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
4619 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
4620 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
4621 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
4622 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
4623 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
4624 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
4625 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
4626 {
4627 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
4628 fWeightChange = VOS_TRUE;
4629 }
4630 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
4631 {
4632 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
4633 fWeightChange = VOS_TRUE;
4634 }
4635 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
4636 {
4637 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
4638 fWeightChange = VOS_TRUE;
4639 }
4640 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
4641 {
4642 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
4643 fWeightChange = VOS_TRUE;
4644 }
4645 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
4646 {
4647 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
4648 fWeightChange = VOS_TRUE;
4649 }
4650 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
4651 {
4652 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
4653 fWeightChange = VOS_TRUE;
4654 }
4655 if(fWeightChange)
4656 {
4657 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)\n"), bACWeights[0], bACWeights[1],
4658 bACWeights[2], bACWeights[3]);
4659 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
4660 }
4661 }
4662}
Jeff Johnson295189b2012-06-20 16:38:30 -07004663#ifdef WLAN_FEATURE_VOWIFI_11R
4664//Returns whether the current association is a 11r assoc or not
4665tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
4666{
4667#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
4668 return csrNeighborRoamIs11rAssoc(pMac);
4669#else
4670 return eANI_BOOLEAN_FALSE;
4671#endif
4672}
4673#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004674#ifdef FEATURE_WLAN_CCX
4675//Returns whether the current association is a CCX assoc or not
4676tANI_BOOLEAN csrRoamIsCCXAssoc(tpAniSirGlobal pMac)
4677{
4678#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
4679 return csrNeighborRoamIsCCXAssoc(pMac);
4680#else
4681 return eANI_BOOLEAN_FALSE;
4682#endif
4683}
4684#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004685#ifdef FEATURE_WLAN_LFR
4686//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304687tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004688{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304689 tCsrRoamSession *pSession = NULL;
4690
4691 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
4692 {
4693 pSession = CSR_GET_SESSION( pMac, sessionId );
4694 if (NULL != pSession->pCurRoamProfile)
4695 {
4696 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
4697 {
4698 return eANI_BOOLEAN_FALSE;
4699 }
4700 }
4701 }
4702
Madan Mohan Koyyalamudi9ce36ec2012-10-15 16:03:17 -07004703 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07004704 (!csrIsConcurrentSessionRunning(pMac)));
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004705}
4706#endif
4707
Jeff Johnson295189b2012-06-20 16:38:30 -07004708//Return true means the command can be release, else not
4709static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
4710 eCsrRoamCompleteResult Result, void *Context )
4711{
4712 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
4713 tSirBssDescription *pSirBssDesc = NULL;
4714 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
4715 tCsrScanResult *pScanResult = NULL;
4716 tCsrRoamInfo roamInfo;
4717 sme_QosAssocInfo assocInfo;
4718 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
4719 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
4720 tDot11fBeaconIEs *pIes = NULL;
4721 tANI_U32 sessionId = pCommand->sessionId;
4722 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4723 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4724 eRoamCmdStatus roamStatus;
4725 eCsrRoamResult roamResult;
4726 eHalStatus status;
4727 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004728 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004729
Jeff Johnson32d95a32012-09-10 13:15:23 -07004730 if(!pSession)
4731 {
4732 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4733 return eANI_BOOLEAN_FALSE;
4734 }
4735
Jeff Johnson295189b2012-06-20 16:38:30 -07004736 smsLog( pMac, LOG1, FL("Processing ROAM results...\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004737 switch( Result )
4738 {
4739 case eCsrJoinSuccess:
4740 // reset the IDLE timer
4741 // !!
4742 // !! fall through to the next CASE statement here is intentional !!
4743 // !!
4744 case eCsrReassocSuccess:
4745 if(eCsrReassocSuccess == Result)
4746 {
4747 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
4748 }
4749 else
4750 {
4751 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
4752 }
4753 // Success Join Response from LIM. Tell NDIS we are connected and save the
4754 // Connected state...
4755 smsLog(pMac, LOGW, FL("receives association indication\n"));
4756 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
4757 //always free the memory here
4758 if(pSession->pWpaRsnRspIE)
4759 {
4760 pSession->nWpaRsnRspIeLength = 0;
4761 palFreeMemory(pMac->hHdd, pSession->pWpaRsnRspIE);
4762 pSession->pWpaRsnRspIE = NULL;
4763 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004764#ifdef FEATURE_WLAN_WAPI
4765 if(pSession->pWapiRspIE)
4766 {
4767 pSession->nWapiRspIeLength = 0;
4768 palFreeMemory(pMac->hHdd, pSession->pWapiRspIE);
4769 pSession->pWapiRspIE = NULL;
4770 }
4771#endif /* FEATURE_WLAN_WAPI */
4772#ifdef FEATURE_WLAN_BTAMP_UT_RF
4773 //Reset counter so no join retry is needed.
4774 pSession->maxRetryCount = 0;
4775 csrRoamStopJoinRetryTimer(pMac, sessionId);
4776#endif
4777 /* This creates problem since we have not saved the connected profile.
4778 So moving this after saving the profile
4779 */
4780 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
4781 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4782 {
4783 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
4784 }
4785 else
4786 {
4787 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
4788 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004789 //Use the last connected bssdesc for reassoc-ing to the same AP.
4790 //NOTE: What to do when reassoc to a different AP???
4791 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
4792 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
4793 {
4794 pSirBssDesc = pSession->pConnectBssDesc;
4795 if(pSirBssDesc)
4796 {
4797 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
4798 }
4799 }
4800 else
4801 {
4802
4803 if(pCommand->u.roamCmd.pRoamBssEntry)
4804 {
4805 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4806 if(pScanResult != NULL)
4807 {
4808 pSirBssDesc = &pScanResult->Result.BssDescriptor;
4809 //this can be NULL
4810 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
4811 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
4812 }
4813 }
4814 }
4815 if( pSirBssDesc )
4816 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004817 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07004818 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
4819 //Save WPA/RSN IE
4820 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
4821#ifdef FEATURE_WLAN_CCX
4822 roamInfo.isCCXAssoc = pSession->connectedProfile.isCCXAssoc;
4823#endif
4824
4825 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
4826 // substate change.
4827 // Moving even save profile above so that below mentioned conditon is also met.
4828 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
4829 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07004830 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
4831 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
4832 // will be dropped for the security context may not be set properly.
4833 //
4834 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
4835 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
4836 //
4837 // this reordering was done on titan_prod_usb branch and is being replicated here.
4838 //
4839
4840 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
4841 !pProfile->bWPSAssociation)
4842 {
4843 // Issue the set Context request to LIM to establish the Unicast STA context
4844 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
4845 pProfile->negotiatedUCEncryptionType,
4846 pSirBssDesc, &(pSirBssDesc->bssId),
4847 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
4848 {
4849 smsLog( pMac, LOGE, FL(" Set context for unicast fail\n") );
4850 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
4851 }
4852 // Issue the set Context request to LIM to establish the Broadcast STA context
4853 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
4854 pSirBssDesc, &BroadcastMac,
4855 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
4856 }
4857 else
4858 {
4859 //Need to wait for supplicant authtication
4860 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004861 //Set the subestate to WaitForKey in case authentiation is needed
4862 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
4863
Jeff Johnson295189b2012-06-20 16:38:30 -07004864 if(pProfile->bWPSAssociation)
4865 {
4866 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
4867 }
4868 else
4869 {
4870 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
4871 }
4872
4873 //Save sessionId in case of timeout
4874 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
4875 //This time should be long enough for the rest of the process plus setting key
4876 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
4877 {
4878 //Reset our state so nothting is blocked.
4879 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer\n") );
4880 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
4881 }
4882 }
4883
4884 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
4885 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004886 if(Context)
4887 {
4888 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
4889 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07004890 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
4891 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
4892#ifdef WLAN_FEATURE_VOWIFI_11R
4893 len += pJoinRsp->parsedRicRspLen;
4894#endif /* WLAN_FEATURE_VOWIFI_11R */
4895#ifdef FEATURE_WLAN_CCX
4896 len += pJoinRsp->tspecIeLen;
4897#endif
4898 if(len)
4899 {
4900 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
4901 (void **)&pSession->connectedInfo.pbFrames, len)))
4902 {
4903 if(HAL_STATUS_SUCCESS( palCopyMemory(pMac->hHdd,
4904 pSession->connectedInfo.pbFrames, pJoinRsp->frames, len) ))
4905 {
4906 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
4907 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
4908 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
4909#ifdef WLAN_FEATURE_VOWIFI_11R
4910 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
4911#endif /* WLAN_FEATURE_VOWIFI_11R */
4912#ifdef FEATURE_WLAN_CCX
4913 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
4914#endif
4915 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
4916 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
4917 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
4918 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
4919 }
4920 else
4921 {
4922 smsLog(pMac, LOGE, "%s: Copying of memory failed for %d bytes !!!\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004923 __func__, len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004924 palFreeMemory( pMac->hHdd, pSession->connectedInfo.pbFrames );
4925 pSession->connectedInfo.pbFrames = NULL;
4926 }
4927 }
4928 }
4929 if(pCommand->u.roamCmd.fReassoc)
4930 {
4931 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
4932 }
4933 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
4934 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
4935 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
4936 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
4937 }
4938 else
4939 {
4940 if(pCommand->u.roamCmd.fReassoc)
4941 {
4942 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
4943 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
4944 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
4945 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
4946 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
4947 }
4948 }
4949#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4950 // Indicate SME-QOS with reassoc success event, only after
4951 // copying the frames
4952 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
4953#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004954 roamInfo.pBssDesc = pSirBssDesc;
4955 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4956 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4957#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4958 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
4959#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
4960 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07004961#ifdef FEATURE_WLAN_UAPSD_FW_TRG_FRAMES
4962 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
4963 //It may be better to let QoS do this????
4964 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
4965 {
4966 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now\n",
4967 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
4968 pmcStartUapsd( pMac, NULL, NULL );
4969 }
4970#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004971 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
4972 if( pSession->bRefAssocStartCnt > 0 )
4973 {
4974 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07004975 //Remove this code once SLM_Sessionization is supported
4976 //BMPS_WORKAROUND_NOT_NEEDED
4977 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07004978 {
4979 pMac->roam.configParam.doBMPSWorkaround = 1;
4980 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004981 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
4982 }
4983
4984 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004985 // reset the PMKID candidate list
4986 csrResetPMKIDCandidateList( pMac, sessionId );
4987 //Update TL's AC weight base on the current EDCA parameters
4988 //These parameters may change in the course of the connection, that sictuation
4989 //is not taken care here. This change is mainly to address a WIFI WMM test where
4990 //BE has a equal or higher TX priority than VI.
4991 //We only do this for infra link
4992 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
4993 {
4994 csrCheckAndUpdateACWeight(pMac, pIes);
4995 }
4996#ifdef FEATURE_WLAN_WAPI
4997 // reset the BKID candidate list
4998 csrResetBKIDCandidateList( pMac, sessionId );
4999#endif /* FEATURE_WLAN_WAPI */
5000 }
5001 else
5002 {
5003 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc\n");
5004 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005005 csrScanCancelIdleScan(pMac);
5006 //Not to signal link up because keys are yet to be set.
5007 //The linkup function will overwrite the sub-state that we need to keep at this point.
5008 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5009 {
5010 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5011 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005012 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5013 //enough to let security and DHCP handshake succeed before entry into BMPS
5014 if (pmcShouldBmpsTimerRun(pMac))
5015 {
5016 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5017 != eHAL_STATUS_SUCCESS)
5018 {
5019 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5020 }
5021 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5022 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005023 break;
5024
Jeff Johnson295189b2012-06-20 16:38:30 -07005025 case eCsrStartBssSuccess:
5026 // on the StartBss Response, LIM is returning the Bss Description that we
5027 // are beaconing. Add this Bss Description to our scan results and
5028 // chain the Profile to this Bss Description. On a Start BSS, there was no
5029 // detected Bss description (no partner) so we issued the Start Bss to
5030 // start the Ibss without any Bss description. Lim was kind enough to return
5031 // the Bss Description that we start beaconing for the newly started Ibss.
5032 smsLog(pMac, LOG2, FL("receives start BSS ok indication\n"));
5033 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005034 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Jeff Johnson295189b2012-06-20 16:38:30 -07005035 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5036 if( CSR_IS_IBSS( pProfile ) )
5037 {
5038 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5039 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005040 else if (CSR_IS_INFRA_AP(pProfile))
5041 {
5042 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5043 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005044 else
5045 {
5046 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5047 }
5048 if( !CSR_IS_WDS_STA( pProfile ) )
5049 {
5050 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005051 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005052 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5053 {
5054 smsLog(pMac, LOG2, FL("cannot parse IBSS IEs\n"));
5055 roamInfo.pBssDesc = pSirBssDesc;
5056 //We need to associate_complete it first, becasue Associate_start already indicated.
5057 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5058 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5059 break;
5060 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005061 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005062 {
5063 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes );
5064 }
5065 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5066 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5067 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5068 if(pSirBssDesc)
5069 {
5070 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5071 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
5072 }
5073 //We are doen with the IEs so free it
5074 palFreeMemory(pMac->hHdd, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005075#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5076 {
5077 vos_log_ibss_pkt_type *pIbssLog;
5078 tANI_U32 bi;
5079
5080 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5081 if(pIbssLog)
5082 {
5083 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5084 {
5085 //We start the IBSS (didn't find any matched IBSS out there)
5086 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
5087 }
5088 else
5089 {
5090 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
5091 }
5092 if(pSirBssDesc)
5093 {
5094 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pSirBssDesc->bssId, 6);
5095 pIbssLog->operatingChannel = pSirBssDesc->channelId;
5096 }
5097 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
5098 {
5099 //***U8 is not enough for beacon interval
5100 pIbssLog->beaconInterval = (v_U8_t)bi;
5101 }
5102 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5103 }
5104 }
5105#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5106 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
5107 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07005108 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
5109 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005110 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
5111 csrRoamIssueSetContextReq( pMac, sessionId,
5112 pProfile->negotiatedMCEncryptionType,
5113 pSirBssDesc, &BroadcastMac,
5114 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5115 }
5116 }
5117 else
5118 {
5119 //Keep the state to eCSR_ROAMING_STATE_JOINING
5120 //Need to send join_req.
5121 if(pCommand->u.roamCmd.pRoamBssEntry)
5122 {
5123 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
5124 {
5125 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5126 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5127 // Set the roaming substate to 'join attempt'...
5128 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowda071f6082013-01-16 13:39:39 -08005129 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005130 }
5131 }
5132 else
5133 {
5134 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc\n" );
5135 VOS_ASSERT( 0 );
5136 }
5137 }
5138 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5139 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5140 //trigger the connection start indication in Vista
5141 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
5142 {
5143 roamStatus = eCSR_ROAM_IBSS_IND;
5144 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5145 if( CSR_IS_WDS( pProfile ) )
5146 {
5147 roamStatus = eCSR_ROAM_WDS_IND;
5148 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5149 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005150 if( CSR_IS_INFRA_AP( pProfile ) )
5151 {
5152 roamStatus = eCSR_ROAM_INFRA_IND;
5153 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
5154 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005155
5156 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5157 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5158 //trigger the connection start indication in Vista
5159 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5160 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5161 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5162 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5163 {
5164 //We start the IBSS (didn't find any matched IBSS out there)
5165 roamInfo.pBssDesc = pSirBssDesc;
5166 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005167 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005168 //Remove this code once SLM_Sessionization is supported
5169 //BMPS_WORKAROUND_NOT_NEEDED
5170 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005171 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005172 {
5173 pMac->roam.configParam.doBMPSWorkaround = 1;
5174 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005175
Jeff Johnson295189b2012-06-20 16:38:30 -07005176 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5177 }
5178
5179 csrScanCancelIdleScan(pMac);
5180 //Only use this timer for ibss. BAP has its own timer for WDS
5181 if( CSR_IS_IBSS( pProfile) && CSR_INVALID_SCANRESULT_HANDLE != pCommand->u.roamCmd.hBSSList)
5182 {
5183 //start the join IBSS timer
5184 csrRoamStartIbssJoinTimer(pMac, sessionId, CSR_IBSS_JOIN_TIMEOUT_PERIOD); //interval
5185 pSession->ibss_join_pending = TRUE;
5186 }
5187 if( HAL_STATUS_SUCCESS( status ) )
5188 {
5189 //Already sent join_req for the WDS station
5190 fReleaseCommand = eANI_BOOLEAN_FALSE;
5191 }
5192 else if( CSR_IS_WDS_STA( pProfile ) )
5193 {
5194 //need to send stop BSS because we fail to send join_req
5195 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5196 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5197 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5198 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005199 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005200 case eCsrStartBssFailure:
5201#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5202 {
5203 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005204 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5205 if(pIbssLog)
5206 {
5207 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5208 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5209 }
5210 }
5211#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005212 roamStatus = eCSR_ROAM_IBSS_IND;
5213 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5214 if( CSR_IS_WDS( pProfile ) )
5215 {
5216 roamStatus = eCSR_ROAM_WDS_IND;
5217 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5218 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005219 if( CSR_IS_INFRA_AP( pProfile ) )
5220 {
5221 roamStatus = eCSR_ROAM_INFRA_IND;
5222 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5223 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005224 if(Context)
5225 {
5226 pSirBssDesc = (tSirBssDescription *)Context;
5227 }
5228 else
5229 {
5230 pSirBssDesc = NULL;
5231 }
5232 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5233 roamInfo.pBssDesc = pSirBssDesc;
5234 //We need to associate_complete it first, becasue Associate_start already indicated.
5235 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5236 csrSetDefaultDot11Mode( pMac );
5237 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005238 case eCsrSilentlyStopRoaming:
5239 // We are here because we try to start the same IBSS
5240 //No message to PE
5241 // return the roaming state to Joined.
5242 smsLog(pMac, LOGW, FL("receives silently roaming indication\n"));
5243 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5244 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5245 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5246 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5247 if( roamInfo.pBssDesc )
5248 {
5249 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &roamInfo.pBssDesc->bssId, sizeof(tCsrBssid));
5250 }
5251 //Since there is no change in the current state, simply pass back no result otherwise
5252 //HDD may be mistakenly mark to disconnected state.
5253 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5254 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005255 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005256 case eCsrSilentlyStopRoamingSaveState:
5257 //We are here because we try to connect to the same AP
5258 //No message to PE
5259 smsLog(pMac, LOGW, FL("receives silently stop roaming indication\n"));
5260 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
5261
5262 //to aviod resetting the substate to NONE
5263 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5264 //No need to change substate to wai_for_key because there is no state change
5265 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5266 if( roamInfo.pBssDesc )
5267 {
5268 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &roamInfo.pBssDesc->bssId, sizeof(tCsrBssid));
5269 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005270 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5271 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5272 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5273 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5274 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5275 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5276 roamInfo.staId = pSession->connectedInfo.staId;
5277 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5278#if defined(VOSS_ENABLED)
5279 VOS_ASSERT( roamInfo.staId != 0 );
5280#endif
5281 pSession->bRefAssocStartCnt--;
5282 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5283 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5284 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5285 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005286 case eCsrReassocFailure:
5287#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5288 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5289#endif
5290 case eCsrJoinWdsFailure:
5291 smsLog(pMac, LOGW, FL("failed to join WDS\n"));
5292 csrFreeConnectBssDesc(pMac, sessionId);
5293 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5294 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5295 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5296 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5297 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5298 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5299 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5300 eCSR_ROAM_WDS_IND,
5301 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5302 //Need to issue stop_bss
5303 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005304 case eCsrJoinFailure:
5305 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07005306 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07005307 default:
5308 {
5309 smsLog(pMac, LOGW, FL("receives no association indication\n"));
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07005310 smsLog(pMac, LOG1, FL("Assoc ref count %d\n"),
5311 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07005312 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
5313 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
5314 {
5315 //do not free for the other profiles as we need to send down stop BSS later
5316 csrFreeConnectBssDesc(pMac, sessionId);
5317 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5318 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5319 csrSetDefaultDot11Mode( pMac );
5320 }
5321
5322 switch( pCommand->u.roamCmd.roamReason )
5323 {
5324 // If this transition is because of an 802.11 OID, then we transition
5325 // back to INIT state so we sit waiting for more OIDs to be issued and
5326 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07005327 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005328 case eCsrSmeIssuedAssocToSimilarAP:
5329 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08005330 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07005331 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5332 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5333 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5334 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5335 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005336 /* Defeaturize this later if needed */
5337#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5338 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
5339 if (csrRoamIsHandoffInProgress(pMac))
5340 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005341 /* Should indicate neighbor roam algorithm about the connect failure here */
5342 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
5343 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005344#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005345 if(pSession->bRefAssocStartCnt > 0)
5346 {
5347 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07005348 if(eCsrJoinFailureDueToConcurrency == Result)
5349 {
5350 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5351 eCSR_ROAM_ASSOCIATION_COMPLETION,
5352 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
5353 }
5354 else
5355 {
5356 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005357 eCSR_ROAM_ASSOCIATION_COMPLETION,
5358 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07005359 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005360 }
Gopichand Nakkalad9a00c52012-12-31 16:43:00 -08005361 else
5362 {
5363 /* bRefAssocStartCnt is not incremented when
5364 * eRoamState == eCsrStopRoamingDueToConcurrency
5365 * in csrRoamJoinNextBss API. so handle this in
5366 * else case by sending assoc failure
5367 */
5368 csrRoamCallCallback(pMac, sessionId, NULL,
5369 pCommand->u.scanCmd.roamId,
5370 eCSR_ROAM_ASSOCIATION_FAILURE,
5371 eCSR_ROAM_RESULT_FAILURE);
5372 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005373 smsLog(pMac, LOG1, FL(" roam(reason %d) failed\n"), pCommand->u.roamCmd.roamReason);
5374#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5375 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5376#endif
5377 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5378 csrScanStartIdleScan(pMac);
5379#ifdef FEATURE_WLAN_BTAMP_UT_RF
5380 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
5381 //BT activity and not able to recevie WLAN traffic. Retry the join
5382 if( CSR_IS_WDS_STA(pProfile) )
5383 {
5384 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
5385 }
5386#endif
5387 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005388 case eCsrHddIssuedReassocToSameAP:
5389 case eCsrSmeIssuedReassocToSameAP:
5390 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5391
5392 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5393#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5394 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5395#endif
5396 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5397 csrScanStartIdleScan(pMac);
5398 break;
5399 case eCsrForcedDisassoc:
5400 case eCsrForcedDeauth:
5401 case eCsrSmeIssuedIbssJoinFailure:
5402 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5403
5404 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
5405 {
5406 // Notify HDD that IBSS join failed
5407 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
5408 }
5409 else
5410 {
5411 csrRoamCallCallback(pMac, sessionId, NULL,
5412 pCommand->u.roamCmd.roamId,
5413 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5414 }
5415#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5416 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5417#endif
5418 csrRoamLinkDown(pMac, sessionId);
5419 csrScanStartIdleScan(pMac);
5420 break;
5421 case eCsrForcedIbssLeave:
5422 csrRoamCallCallback(pMac, sessionId, NULL,
5423 pCommand->u.roamCmd.roamId,
5424 eCSR_ROAM_IBSS_LEAVE,
5425 eCSR_ROAM_RESULT_IBSS_STOP);
5426 break;
5427 case eCsrForcedDisassocMICFailure:
5428 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5429
5430 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
5431#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5432 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
5433#endif
5434 csrScanStartIdleScan(pMac);
5435 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005436 case eCsrStopBss:
5437 csrRoamCallCallback(pMac, sessionId, NULL,
5438 pCommand->u.roamCmd.roamId,
5439 eCSR_ROAM_INFRA_IND,
5440 eCSR_ROAM_RESULT_INFRA_STOPPED);
5441 break;
5442 case eCsrForcedDisassocSta:
5443 case eCsrForcedDeauthSta:
5444 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
5445 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
5446 {
5447 pSession = CSR_GET_SESSION(pMac, sessionId);
5448 if (!pSession)
5449 break;
5450
5451 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
5452 {
5453 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5454 palCopyMemory(pMac->hHdd, roamInfo.peerMac,
5455 pCommand->u.roamCmd.peerMac, sizeof(tSirMacAddr));
5456 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
5457 roamInfo.statusCode = eSIR_SME_SUCCESS;
5458 status = csrRoamCallCallback(pMac, sessionId,
5459 &roamInfo, pCommand->u.roamCmd.roamId,
5460 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
5461 }
5462 }
5463 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005464 case eCsrLostLink1:
5465 // if lost link roam1 failed, then issue lost link Scan2 ...
5466 csrScanRequestLostLink2(pMac, sessionId);
5467 break;
5468 case eCsrLostLink2:
5469 // if lost link roam2 failed, then issue lost link scan3 ...
5470 csrScanRequestLostLink3(pMac, sessionId);
5471 break;
5472 case eCsrLostLink3:
5473 default:
5474 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5475
5476 //We are done with one round of lostlink roaming here
5477 csrScanHandleFailedLostlink3(pMac, sessionId);
5478 break;
5479 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005480 break;
5481 }
5482 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005483 return ( fReleaseCommand );
5484}
5485
Jeff Johnson295189b2012-06-20 16:38:30 -07005486eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
5487{
5488 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005489 return (status);
5490}
5491
Jeff Johnson295189b2012-06-20 16:38:30 -07005492eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
5493{
5494 eHalStatus status = eHAL_STATUS_SUCCESS;
5495 tANI_U32 size = 0;
5496
5497 do
5498 {
5499 palZeroMemory(pMac->hHdd, pDstProfile, sizeof(tCsrRoamProfile));
5500 if(pSrcProfile->BSSIDs.numOfBSSIDs)
5501 {
5502 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
5503 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->BSSIDs.bssid, size);
5504 if(!HAL_STATUS_SUCCESS(status))
5505 {
5506 break;
5507 }
5508 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
5509 palCopyMemory(pMac->hHdd, pDstProfile->BSSIDs.bssid, pSrcProfile->BSSIDs.bssid, size);
5510 }
5511 if(pSrcProfile->SSIDs.numOfSSIDs)
5512 {
5513 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
5514 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->SSIDs.SSIDList, size);
5515 if(!HAL_STATUS_SUCCESS(status))
5516 {
5517 break;
5518 }
5519 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
5520 palCopyMemory(pMac->hHdd, pDstProfile->SSIDs.SSIDList, pSrcProfile->SSIDs.SSIDList, size);
5521 }
5522 if(pSrcProfile->nWPAReqIELength)
5523 {
5524 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pWPAReqIE, pSrcProfile->nWPAReqIELength);
5525 if(!HAL_STATUS_SUCCESS(status))
5526 {
5527 break;
5528 }
5529 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
5530 palCopyMemory(pMac->hHdd, pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE, pSrcProfile->nWPAReqIELength);
5531 }
5532 if(pSrcProfile->nRSNReqIELength)
5533 {
5534 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pRSNReqIE, pSrcProfile->nRSNReqIELength);
5535 if(!HAL_STATUS_SUCCESS(status))
5536 {
5537 break;
5538 }
5539 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
5540 palCopyMemory(pMac->hHdd, pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE, pSrcProfile->nRSNReqIELength);
5541 }
5542#ifdef FEATURE_WLAN_WAPI
5543 if(pSrcProfile->nWAPIReqIELength)
5544 {
5545 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pWAPIReqIE, pSrcProfile->nWAPIReqIELength);
5546 if(!HAL_STATUS_SUCCESS(status))
5547 {
5548 break;
5549 }
5550 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
5551 palCopyMemory(pMac->hHdd, pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE, pSrcProfile->nWAPIReqIELength);
5552 }
5553#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07005554 if(pSrcProfile->nAddIEScanLength)
5555 {
5556 status = palAllocateMemory(pMac->hHdd,
5557 (void **)&pDstProfile->pAddIEScan, pSrcProfile->nAddIEScanLength);
5558 if(!HAL_STATUS_SUCCESS(status))
5559 {
5560 break;
5561 }
5562 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
5563 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEScan, pSrcProfile->pAddIEScan,
5564 pSrcProfile->nAddIEScanLength);
5565 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005566 if(pSrcProfile->nAddIEAssocLength)
5567 {
5568 status = palAllocateMemory(pMac->hHdd,
5569 (void **)&pDstProfile->pAddIEAssoc, pSrcProfile->nAddIEAssocLength);
5570 if(!HAL_STATUS_SUCCESS(status))
5571 {
5572 break;
5573 }
5574 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
5575 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
5576 pSrcProfile->nAddIEAssocLength);
5577 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005578 if(pSrcProfile->ChannelInfo.ChannelList)
5579 {
5580 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.numOfChannels);
5581 if(!HAL_STATUS_SUCCESS(status))
5582 {
5583 break;
5584 }
5585 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
5586 palCopyMemory(pMac->hHdd, pDstProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.numOfChannels);
5587 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005588 pDstProfile->AuthType = pSrcProfile->AuthType;
5589 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
5590 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
5591 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
5592 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
5593 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
5594 pDstProfile->BSSType = pSrcProfile->BSSType;
5595 pDstProfile->phyMode = pSrcProfile->phyMode;
5596 pDstProfile->csrPersona = pSrcProfile->csrPersona;
5597
5598#ifdef FEATURE_WLAN_WAPI
5599 if(csrIsProfileWapi(pSrcProfile))
5600 {
5601 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
5602 {
5603 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
5604 }
5605 }
5606#endif /* FEATURE_WLAN_WAPI */
5607 pDstProfile->CBMode = pSrcProfile->CBMode;
5608 /*Save the WPS info*/
5609 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
5610 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005611 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07005612 pDstProfile->privacy = pSrcProfile->privacy;
5613 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
5614 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
5615 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
5616 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
5617 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
5618 pDstProfile->protEnabled = pSrcProfile->protEnabled;
5619 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
5620 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
5621 pDstProfile->wps_state = pSrcProfile->wps_state;
5622 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Jeff Johnson295189b2012-06-20 16:38:30 -07005623 palCopyMemory(pMac->hHdd, &pDstProfile->Keys, &pSrcProfile->Keys, sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07005624#ifdef WLAN_FEATURE_VOWIFI_11R
5625 if (pSrcProfile->MDID.mdiePresent)
5626 {
5627 pDstProfile->MDID.mdiePresent = 1;
5628 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
5629 }
5630#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005631 }while(0);
5632
5633 if(!HAL_STATUS_SUCCESS(status))
5634 {
5635 csrReleaseProfile(pMac, pDstProfile);
5636 pDstProfile = NULL;
5637 }
5638
5639 return (status);
5640}
Jeff Johnson295189b2012-06-20 16:38:30 -07005641eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
5642{
5643 eHalStatus status = eHAL_STATUS_SUCCESS;
5644 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
5645 do
5646 {
5647 palZeroMemory(pMac->hHdd, pDstProfile, sizeof(tCsrRoamProfile));
5648 if(pSrcProfile->bssid)
5649 {
5650 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->BSSIDs.bssid, sizeof(tCsrBssid));
5651 if(!HAL_STATUS_SUCCESS(status))
5652 {
5653 break;
5654 }
5655 pDstProfile->BSSIDs.numOfBSSIDs = 1;
5656 palCopyMemory(pMac->hHdd, pDstProfile->BSSIDs.bssid, pSrcProfile->bssid, sizeof(tCsrBssid));
5657 }
5658 if(pSrcProfile->SSID.ssId)
5659 {
5660 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->SSIDs.SSIDList, sizeof(tCsrSSIDInfo));
5661 if(!HAL_STATUS_SUCCESS(status))
5662 {
5663 break;
5664 }
5665 pDstProfile->SSIDs.numOfSSIDs = 1;
5666 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
5667 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
5668 palCopyMemory(pMac->hHdd, &pDstProfile->SSIDs.SSIDList[0].SSID, &pSrcProfile->SSID, sizeof(tSirMacSSid));
5669 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07005670 if(pSrcProfile->nAddIEAssocLength)
5671 {
5672 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pAddIEAssoc, pSrcProfile->nAddIEAssocLength);
5673 if(!HAL_STATUS_SUCCESS(status))
5674 {
5675 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs \n") );
5676 break;
5677 }
5678 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
5679 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
5680 pSrcProfile->nAddIEAssocLength);
5681 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005682 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->ChannelInfo.ChannelList, 1);
5683 if(!HAL_STATUS_SUCCESS(status))
5684 {
5685 break;
5686 }
5687 pDstProfile->ChannelInfo.numOfChannels = 1;
5688 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07005689 pDstProfile->AuthType.numEntries = 1;
5690 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
5691 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
5692 pDstProfile->EncryptionType.numEntries = 1;
5693 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
5694 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
5695 pDstProfile->mcEncryptionType.numEntries = 1;
5696 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
5697 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
5698 pDstProfile->BSSType = pSrcProfile->BSSType;
5699 pDstProfile->CBMode = pSrcProfile->CBMode;
5700 palCopyMemory(pMac->hHdd, &pDstProfile->Keys, &pSrcProfile->Keys, sizeof(pDstProfile->Keys));
5701#ifdef WLAN_FEATURE_VOWIFI_11R
5702 if (pSrcProfile->MDID.mdiePresent)
5703 {
5704 pDstProfile->MDID.mdiePresent = 1;
5705 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
5706 }
5707#endif
5708
5709 }while(0);
5710
5711 if(!HAL_STATUS_SUCCESS(status))
5712 {
5713 csrReleaseProfile(pMac, pDstProfile);
5714 pDstProfile = NULL;
5715 }
5716
5717 return (status);
5718}
5719
Jeff Johnson295189b2012-06-20 16:38:30 -07005720eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5721 tScanResultHandle hBSSList,
5722 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
5723 tANI_BOOLEAN fClearScan)
5724{
5725 eHalStatus status = eHAL_STATUS_SUCCESS;
5726 tSmeCmd *pCommand;
5727
5728 pCommand = csrGetCommandBuffer(pMac);
5729 if(NULL == pCommand)
5730 {
5731 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
5732 status = eHAL_STATUS_RESOURCES;
5733 }
5734 else
5735 {
5736 if( fClearScan )
5737 {
5738 csrScanCancelIdleScan(pMac);
5739 csrScanAbortMacScanNotForConnect(pMac);
5740 }
5741 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
5742 if(NULL == pProfile)
5743 {
5744 //We can roam now
5745 //Since pProfile is NULL, we need to build our own profile, set everything to default
5746 //We can only support open and no encryption
5747 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
5748 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5749 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
5750 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5751 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
5752 }
5753 else
5754 {
5755 //make a copy of the profile
5756 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
5757 if(HAL_STATUS_SUCCESS(status))
5758 {
5759 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
5760 }
5761 }
5762 pCommand->command = eSmeCommandRoam;
5763 pCommand->sessionId = (tANI_U8)sessionId;
5764 pCommand->u.roamCmd.hBSSList = hBSSList;
5765 pCommand->u.roamCmd.roamId = roamId;
5766 pCommand->u.roamCmd.roamReason = reason;
5767 //We need to free the BssList when the command is done
5768 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
5769 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005770 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
5771 FL("CSR PERSONA=%d"),
5772 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07005773 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
5774 if( !HAL_STATUS_SUCCESS( status ) )
5775 {
5776 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
5777 csrReleaseCommandRoam( pMac, pCommand );
5778 }
5779 }
5780
5781 return (status);
5782}
Jeff Johnson295189b2012-06-20 16:38:30 -07005783eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5784 tCsrRoamModifyProfileFields *pMmodProfileFields,
5785 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
5786{
5787 eHalStatus status = eHAL_STATUS_SUCCESS;
5788 tSmeCmd *pCommand;
5789
5790 pCommand = csrGetCommandBuffer(pMac);
5791 if(NULL == pCommand)
5792 {
5793 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
5794 status = eHAL_STATUS_RESOURCES;
5795 }
5796 else
5797 {
5798 csrScanCancelIdleScan(pMac);
5799 csrScanAbortMacScanNotForConnect(pMac);
5800 if(pProfile)
5801 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005802 //This is likely trying to reassoc to different profile
5803 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
5804 //make a copy of the profile
5805 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
5806 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005807 }
5808 else
5809 {
5810 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
5811 //how to update WPA/WPA2 info in roamProfile??
5812 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005813 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005814 if(HAL_STATUS_SUCCESS(status))
5815 {
5816 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
5817 }
5818 pCommand->command = eSmeCommandRoam;
5819 pCommand->sessionId = (tANI_U8)sessionId;
5820 pCommand->u.roamCmd.roamId = roamId;
5821 pCommand->u.roamCmd.roamReason = reason;
5822 //We need to free the BssList when the command is done
5823 //For reassoc there is no BSS list, so the boolean set to false
5824 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
5825 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
5826 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005827 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
5828 if( !HAL_STATUS_SUCCESS( status ) )
5829 {
5830 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
5831 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5832 csrReleaseCommandRoam( pMac, pCommand );
5833 }
5834 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005835 return (status);
5836}
5837
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005838eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
5839 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
5840// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
5841{
5842 eHalStatus status = eHAL_STATUS_SUCCESS;
5843 tSmeCmd *pCommand;
5844
5845 pCommand = csrGetCommandBuffer(pMac);
5846 if(NULL == pCommand)
5847 {
5848 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
5849 status = eHAL_STATUS_RESOURCES;
5850 }
5851 else
5852 {
5853 if(pBssDescription)
5854 {
5855 //copy over the parameters we need later
5856 pCommand->command = eSmeCommandRoam;
5857 pCommand->sessionId = (tANI_U8)sessionId;
5858 pCommand->u.roamCmd.roamReason = reason;
5859 //this is the important parameter
5860 //in this case we are using this field for the "next" BSS
5861 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
5862 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
5863 if( !HAL_STATUS_SUCCESS( status ) )
5864 {
5865 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d\n"), status );
5866 csrReleaseCommandPreauth( pMac, pCommand );
5867 }
5868 }
5869 else
5870 {
5871 //Return failure
5872 status = eHAL_STATUS_RESOURCES;
5873 }
5874 }
5875 return (status);
5876}
5877
5878eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
5879{
5880 tListElem *pEntry;
5881 tSmeCmd *pCommand;
5882 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
5883 if ( pEntry )
5884 {
5885 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
5886 if ( (eSmeCommandRoam == pCommand->command) &&
5887 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
5888 {
Varun Reddy Yeturu9163b672013-02-11 14:05:06 -08005889 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005890 pCommand->command, pCommand->u.roamCmd.roamReason);
5891 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
5892 csrReleaseCommandPreauth( pMac, pCommand );
5893 }
5894 } else {
5895 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d \n"),
5896 pCommand->command, pCommand->u.roamCmd.roamReason);
5897 }
5898 }
5899 else {
5900 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP\n"));
5901 }
5902 smeProcessPendingQueue( pMac );
5903 return eHAL_STATUS_SUCCESS;
5904}
5905
Jeff Johnson295189b2012-06-20 16:38:30 -07005906eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5907 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
5908{
5909 eHalStatus status = eHAL_STATUS_FAILURE;
5910 tScanResultHandle hBSSList;
5911 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005912 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
5913 if(HAL_STATUS_SUCCESS(status))
5914 {
5915 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
5916 if(pRoamId)
5917 {
5918 *pRoamId = roamId;
5919 }
5920 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
5921 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
5922 if(!HAL_STATUS_SUCCESS(status))
5923 {
5924 smsLog(pMac, LOGE, FL("failed to start a join process\n"));
5925 csrScanResultPurge(pMac, hBSSList);
5926 }
5927 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005928 return (status);
5929}
5930
Jeff Johnson295189b2012-06-20 16:38:30 -07005931eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5932 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
5933{
5934 eHalStatus status = eHAL_STATUS_SUCCESS;
5935 tScanResultHandle hBSSList;
5936 tCsrScanResultFilter *pScanFilter;
5937 tANI_U32 roamId = 0;
5938 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
5939 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005940 if (NULL == pProfile)
5941 {
5942 smsLog(pMac, LOGP, FL("No profile specified"));
5943 return eHAL_STATUS_FAILURE;
5944 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005945 smsLog(pMac, LOG1, FL("called BSSType = %d authtype = %d encryType = %d\n"),
5946 pProfile->BSSType, pProfile->AuthType.authType[0], pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005947 if( CSR_IS_WDS( pProfile ) &&
5948 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
5949 {
Gopichand Nakkala79353d12012-12-31 16:31:46 -08005950 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d\n"),
5951 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07005952 return status;
5953 }
5954 csrRoamCancelRoaming(pMac, sessionId);
5955 csrScanRemoveFreshScanCommand(pMac, sessionId);
5956 csrScanCancelIdleScan(pMac);
5957 //Only abort the scan if it is not used for other roam/connect purpose
5958 csrScanAbortMacScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07005959 if (!vos_concurrent_sessions_running() && (VOS_STA_SAP_MODE == pProfile->csrPersona))//In case of AP mode we do not want idle mode scan
5960 {
5961 csrScanDisable(pMac);
5962 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005963 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
5964 //Check whether ssid changes
5965 if(csrIsConnStateConnected(pMac, sessionId))
5966 {
5967 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
5968 {
5969 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
5970 }
5971 }
5972#ifdef FEATURE_WLAN_BTAMP_UT_RF
5973 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
5974#endif
5975 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
5976 {
Gopichand Nakkala79353d12012-12-31 16:31:46 -08005977 smsLog(pMac, LOG1, FL("is called with BSSList\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005978 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
5979 if(pRoamId)
5980 {
5981 roamId = *pRoamId;
5982 }
5983 if(!HAL_STATUS_SUCCESS(status))
5984 {
5985 fCallCallback = eANI_BOOLEAN_TRUE;
5986 }
5987 }
5988 else
5989 {
5990 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
5991 if(HAL_STATUS_SUCCESS(status))
5992 {
5993 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
5994 //Try to connect to any BSS
5995 if(NULL == pProfile)
5996 {
5997 //No encryption
5998 pScanFilter->EncryptionType.numEntries = 1;
5999 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6000 }//we don't have a profile
6001 else
6002 {
6003 //Here is the profile we need to connect to
6004 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6005 }//We have a profile
6006 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6007 if(pRoamId)
6008 {
6009 *pRoamId = roamId;
6010 }
6011
6012 if(HAL_STATUS_SUCCESS(status))
6013 {
6014 /*Save the WPS info*/
6015 if(NULL != pProfile)
6016 {
6017 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
6018 }
6019 else
6020 {
6021 pScanFilter->bWPSAssociation = 0;
6022 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006023 do
6024 {
6025 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006026 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006027 )
6028 {
Gopichand Nakkala79353d12012-12-31 16:31:46 -08006029 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07006030 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6031 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6032 if(!HAL_STATUS_SUCCESS(status))
6033 {
Gopichand Nakkala79353d12012-12-31 16:31:46 -08006034 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X\n"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006035 fCallCallback = eANI_BOOLEAN_TRUE;
6036 }
Gopichand Nakkala79353d12012-12-31 16:31:46 -08006037 else
6038 {
6039 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
6040 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006041 break;
6042 }
6043 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Mohit Khanna23863762012-09-11 17:40:09 -07006044 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d\n", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006045 if(HAL_STATUS_SUCCESS(status))
6046 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006047 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6048 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6049 if(!HAL_STATUS_SUCCESS(status))
6050 {
Gopichand Nakkala79353d12012-12-31 16:31:46 -08006051 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X\n"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006052 csrScanResultPurge(pMac, hBSSList);
6053 fCallCallback = eANI_BOOLEAN_TRUE;
6054 }
6055 }//Have scan result
6056 else if(NULL != pProfile)
6057 {
6058 //Check whether it is for start ibss
6059 if(CSR_IS_START_IBSS(pProfile))
6060 {
6061 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6062 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6063 if(!HAL_STATUS_SUCCESS(status))
6064 {
6065 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X\n", status);
6066 fCallCallback = eANI_BOOLEAN_TRUE;
6067 }
6068 }
6069 else
6070 {
6071 //scan for this SSID
6072 status = csrScanForSSID(pMac, sessionId, pProfile, roamId);
6073 if(!HAL_STATUS_SUCCESS(status))
6074 {
Gopichand Nakkala79353d12012-12-31 16:31:46 -08006075 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X\n"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006076 fCallCallback = eANI_BOOLEAN_TRUE;
6077 }
Gopichand Nakkala79353d12012-12-31 16:31:46 -08006078 else
6079 {
6080 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
6081 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006082 }
6083 }
6084 else
6085 {
6086 fCallCallback = eANI_BOOLEAN_TRUE;
6087 }
6088 } while (0);
6089 if(NULL != pProfile)
6090 {
6091 //we need to free memory for filter if profile exists
6092 csrFreeScanFilter(pMac, pScanFilter);
6093 }
6094 }//Got the scan filter from profile
6095
6096 palFreeMemory(pMac->hHdd, pScanFilter);
6097 }//allocated memory for pScanFilter
6098 }//No Bsslist coming in
6099 //tell the caller if we fail to trigger a join request
6100 if( fCallCallback )
6101 {
6102 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6103 }
6104
6105 return (status);
6106}
Jeff Johnson295189b2012-06-20 16:38:30 -07006107eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6108 tCsrRoamModifyProfileFields modProfileFields,
6109 tANI_U32 *pRoamId)
6110{
6111 eHalStatus status = eHAL_STATUS_SUCCESS;
6112 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
6113 tANI_U32 roamId = 0;
6114 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006115 if (NULL == pProfile)
6116 {
6117 smsLog(pMac, LOGP, FL("No profile specified"));
6118 return eHAL_STATUS_FAILURE;
6119 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006120 smsLog(pMac, LOG1, FL("called BSSType = %d authtype = %d encryType = %d\n"), pProfile->BSSType, pProfile->AuthType.authType[0], pProfile->EncryptionType.encryptionType[0]);
6121 csrRoamCancelRoaming(pMac, sessionId);
6122 csrScanRemoveFreshScanCommand(pMac, sessionId);
6123 csrScanCancelIdleScan(pMac);
6124 csrScanAbortMacScanNotForConnect(pMac);
6125 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07006126 if(csrIsConnStateConnected(pMac, sessionId))
6127 {
6128 if(pProfile)
6129 {
6130 if(pProfile->SSIDs.numOfSSIDs &&
6131 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6132 {
6133 fCallCallback = eANI_BOOLEAN_FALSE;
6134 }
6135 else
6136 {
6137 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile\n"));
6138 }
6139 }
6140 else if(!palEqualMemory(pMac->hHdd, &modProfileFields,
6141 &pSession->connectedProfile.modifyProfileFields,
6142 sizeof(tCsrRoamModifyProfileFields)))
6143 {
6144 fCallCallback = eANI_BOOLEAN_FALSE;
6145 }
6146 else
6147 {
6148 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
6149 "in tCsrRoamModifyProfileFields got modified\n"));
6150 }
6151 }
6152 else
6153 {
6154 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc\n"));
6155 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006156 if(!fCallCallback)
6157 {
6158 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6159 if(pRoamId)
6160 {
6161 *pRoamId = roamId;
6162 }
6163
Jeff Johnson295189b2012-06-20 16:38:30 -07006164 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6165 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006166 }
6167 else
6168 {
6169 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6170 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6171 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006172 return status;
6173}
Jeff Johnson295189b2012-06-20 16:38:30 -07006174eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6175{
6176 eHalStatus status = eHAL_STATUS_FAILURE;
6177 tScanResultHandle hBSSList = NULL;
6178 tCsrScanResultFilter *pScanFilter = NULL;
6179 tANI_U32 roamId;
6180 tCsrRoamProfile *pProfile = NULL;
6181 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006182
6183 if(!pSession)
6184 {
6185 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6186 return eHAL_STATUS_FAILURE;
6187 }
6188
Jeff Johnson295189b2012-06-20 16:38:30 -07006189 do
6190 {
6191 if(pSession->pCurRoamProfile)
6192 {
6193 csrScanCancelIdleScan(pMac);
6194 csrScanAbortMacScanNotForConnect(pMac);
6195 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
6196 status = palAllocateMemory(pMac->hHdd, (void **)&pProfile, sizeof(tCsrRoamProfile));
6197 if(!HAL_STATUS_SUCCESS(status))
6198 break;
6199 palZeroMemory(pMac->hHdd, pProfile, sizeof(tCsrRoamProfile));
6200 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
6201 if(!HAL_STATUS_SUCCESS(status))
6202 break;
6203 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
6204 if(!HAL_STATUS_SUCCESS(status))
6205 {
6206 break;
6207 }
6208 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
6209 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6210 if(!HAL_STATUS_SUCCESS(status))
6211 {
6212 break;
6213 }
6214 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6215 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6216 if(HAL_STATUS_SUCCESS(status))
6217 {
6218 //we want to put the last connected BSS to the very beginning, if possible
6219 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
6220 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6221 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6222 if(!HAL_STATUS_SUCCESS(status))
6223 {
6224 csrScanResultPurge(pMac, hBSSList);
6225 break;
6226 }
6227 }
6228 else
6229 {
6230 //Do a scan on this profile
6231 //scan for this SSID only in case the AP suppresses SSID
6232 status = csrScanForSSID(pMac, sessionId, pProfile, roamId);
6233 if(!HAL_STATUS_SUCCESS(status))
6234 {
6235 break;
6236 }
6237 }
6238 }//We have a profile
6239 else
6240 {
6241 smsLog(pMac, LOGW, FL("cannot find a roaming profile\n"));
6242 break;
6243 }
6244 }while(0);
6245 if(pScanFilter)
6246 {
6247 csrFreeScanFilter(pMac, pScanFilter);
6248 palFreeMemory(pMac->hHdd, pScanFilter);
6249 }
6250 if(NULL != pProfile)
6251 {
6252 csrReleaseProfile(pMac, pProfile);
6253 palFreeMemory(pMac->hHdd, pProfile);
6254 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006255 return (status);
6256}
Jeff Johnson295189b2012-06-20 16:38:30 -07006257eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
6258{
6259 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006260 if(csrIsConnStateConnected(pMac, sessionId))
6261 {
6262 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6263 if(HAL_STATUS_SUCCESS(status))
6264 {
6265 status = csrRoamJoinLastProfile(pMac, sessionId);
6266 }
6267 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006268 return (status);
6269}
6270
Jeff Johnson295189b2012-06-20 16:38:30 -07006271eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6272{
6273 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006274 smsLog(pMac, LOGW, FL("is called\n"));
6275 csrRoamCancelRoaming(pMac, sessionId);
6276 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6277 if(csrIsConnStateDisconnected(pMac, sessionId))
6278 {
6279 status = csrRoamJoinLastProfile(pMac, sessionId);
6280 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006281 return (status);
6282}
6283
Jeff Johnson295189b2012-06-20 16:38:30 -07006284eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
6285{
6286 eHalStatus status = eHAL_STATUS_SUCCESS;
6287 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
6288 eCsrRoamSubState NewSubstate;
6289 tANI_U32 sessionId = pCommand->sessionId;
6290
6291 // change state to 'Roaming'...
6292 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
6293
6294 if ( csrIsConnStateIbss( pMac, sessionId ) )
6295 {
6296 // If we are in an IBSS, then stop the IBSS...
6297 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6298 fComplete = (!HAL_STATUS_SUCCESS(status));
6299 }
6300 else if ( csrIsConnStateInfra( pMac, sessionId ) )
6301 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07006302 smsLog(pMac, LOG1, FL(" restore AC weights (%d-%d-%d-%d)\n"), pMac->roam.ucACWeights[0], pMac->roam.ucACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07006303 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
6304 //Restore AC weight in case we change it
6305 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
6306 // in Infrasturcture, we need to disassociate from the Infrastructure network...
6307 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
6308 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
6309 {
6310 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
6311 }
6312 if( fDisassoc )
6313 {
6314 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
6315 }
6316 else
6317 {
6318 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
6319 }
6320 fComplete = (!HAL_STATUS_SUCCESS(status));
6321 }
6322 else if ( csrIsConnStateWds( pMac, sessionId ) )
6323 {
6324 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
6325 {
6326 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6327 fComplete = (!HAL_STATUS_SUCCESS(status));
6328 }
6329 //This has to be WDS station
6330 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
6331 {
6332
6333 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6334 if( fDisassoc )
6335 {
6336 status = csrRoamIssueDisassociate( pMac, sessionId,
6337 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
6338 fComplete = (!HAL_STATUS_SUCCESS(status));
6339 }
6340 }
6341 } else {
6342 // we got a dis-assoc request while not connected to any peer
6343 // just complete the command
6344 fComplete = eANI_BOOLEAN_TRUE;
6345 status = eHAL_STATUS_FAILURE;
6346 }
6347 if(fComplete)
6348 {
6349 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6350 }
6351
6352 if(HAL_STATUS_SUCCESS(status))
6353 {
6354 if ( csrIsConnStateInfra( pMac, sessionId ) )
6355 {
6356 //Set the state to disconnect here
6357 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
6358 }
6359 }
Gopichand Nakkala79353d12012-12-31 16:31:46 -08006360 else
6361 {
6362 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
6363 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006364 return (status);
6365}
6366
Jeff Johnson295189b2012-06-20 16:38:30 -07006367/* This is been removed from latest code base */
6368/*
6369static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
6370{
6371 eHalStatus status;
6372 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07006373 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
6374 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006375 return ( status );
6376}
6377*/
6378
Jeff Johnson295189b2012-06-20 16:38:30 -07006379eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
6380{
6381 eHalStatus status = eHAL_STATUS_SUCCESS;
6382 tSmeCmd *pCommand;
6383 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006384 do
6385 {
Varun Reddy Yeturu9163b672013-02-11 14:05:06 -08006386 smsLog( pMac, LOG1, FL(" reason = %d"), reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07006387 pCommand = csrGetCommandBuffer( pMac );
6388 if ( !pCommand )
6389 {
6390 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
6391 status = eHAL_STATUS_RESOURCES;
6392 break;
6393 }
6394 //Change the substate in case it is wait-for-key
6395 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
6396 {
6397 csrRoamStopWaitForKeyTimer( pMac );
6398 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6399 }
6400 pCommand->command = eSmeCommandRoam;
6401 pCommand->sessionId = (tANI_U8)sessionId;
6402 switch ( reason )
6403 {
6404 case eCSR_DISCONNECT_REASON_MIC_ERROR:
6405 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
6406 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006407 case eCSR_DISCONNECT_REASON_DEAUTH:
6408 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
6409 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006410 case eCSR_DISCONNECT_REASON_HANDOFF:
6411 fHighPriority = eANI_BOOLEAN_TRUE;
6412 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
6413 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006414 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
6415 case eCSR_DISCONNECT_REASON_DISASSOC:
6416 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
6417 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006418 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
6419 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
6420 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006421 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
6422 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
6423 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006424 default:
6425 break;
6426 }
6427 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6428 if( !HAL_STATUS_SUCCESS( status ) )
6429 {
6430 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
6431 csrReleaseCommandRoam( pMac, pCommand );
6432 }
6433 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006434 return( status );
6435}
6436
Jeff Johnson295189b2012-06-20 16:38:30 -07006437eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
6438{
6439 eHalStatus status = eHAL_STATUS_SUCCESS;
6440 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07006441 pCommand = csrGetCommandBuffer( pMac );
6442 if ( NULL != pCommand )
6443 {
6444 //Change the substate in case it is wait-for-key
6445 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
6446 {
6447 csrRoamStopWaitForKeyTimer( pMac );
6448 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6449 }
6450 pCommand->command = eSmeCommandRoam;
6451 pCommand->sessionId = (tANI_U8)sessionId;
6452 pCommand->u.roamCmd.roamReason = eCsrStopBss;
6453 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6454 if( !HAL_STATUS_SUCCESS( status ) )
6455 {
6456 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
6457 csrReleaseCommandRoam( pMac, pCommand );
6458 }
6459 }
6460 else
6461 {
6462 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
6463 status = eHAL_STATUS_RESOURCES;
6464 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006465 return ( status );
6466}
6467
Jeff Johnson295189b2012-06-20 16:38:30 -07006468eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
6469{
6470 eHalStatus status = eHAL_STATUS_SUCCESS;
6471 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006472
6473 if(!pSession)
6474 {
6475 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6476 return eHAL_STATUS_FAILURE;
6477 }
6478
Jeff Johnson295189b2012-06-20 16:38:30 -07006479#ifdef FEATURE_WLAN_BTAMP_UT_RF
6480 //Stop te retry
6481 pSession->maxRetryCount = 0;
6482 csrRoamStopJoinRetryTimer(pMac, sessionId);
6483#endif
6484 //Not to call cancel roaming here
6485 //Only issue disconnect when necessary
6486 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
6487 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
6488 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
6489
6490 {
6491 smsLog(pMac, LOG2, FL("called\n"));
6492 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
6493 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006494 return (status);
6495}
6496
Jeff Johnson295189b2012-06-20 16:38:30 -07006497eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
6498{
6499 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006500
6501 if(!pSession)
6502 {
6503 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6504 return eHAL_STATUS_FAILURE;
6505 }
6506
Jeff Johnson295189b2012-06-20 16:38:30 -07006507 csrRoamCancelRoaming(pMac, sessionId);
6508 pSession->ibss_join_pending = FALSE;
6509 csrRoamStopIbssJoinTimer(pMac, sessionId);
6510 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
6511
6512 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
6513}
6514
Jeff Johnson295189b2012-06-20 16:38:30 -07006515eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6516 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
6517{
6518 eHalStatus status = eHAL_STATUS_SUCCESS;
6519 tDot11fBeaconIEs *pIesTemp = pIes;
6520 tANI_U8 index;
6521 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
6522 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07006523
6524 if(!pSession)
6525 {
6526 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6527 return eHAL_STATUS_FAILURE;
6528 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006529
6530 palZeroMemory(pMac->hHdd, &pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile));
6531 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
6532 pConnectProfile->AuthInfo = pProfile->AuthType;
6533 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
6534 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
6535 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
6536 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
6537 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
6538 pConnectProfile->BSSType = pProfile->BSSType;
6539 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
6540 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07006541 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
6542
Jeff Johnson295189b2012-06-20 16:38:30 -07006543 palCopyMemory(pMac->hHdd, &pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006544 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
6545 if(pProfile->nAddIEAssocLength)
6546 {
6547 status = palAllocateMemory(pMac->hHdd,
6548 (void **)&pConnectProfile->pAddIEAssoc, pProfile->nAddIEAssocLength);
6549 if(!HAL_STATUS_SUCCESS(status))
6550 {
6551 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
6552 return eHAL_STATUS_FAILURE;
6553 }
6554 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
6555 palCopyMemory(pMac->hHdd, pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
6556 pProfile->nAddIEAssocLength);
6557 }
6558
Jeff Johnson295189b2012-06-20 16:38:30 -07006559 //Save bssid
6560 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
6561#ifdef WLAN_FEATURE_VOWIFI_11R
6562 if (pSirBssDesc->mdiePresent)
6563 {
6564 pConnectProfile->MDID.mdiePresent = 1;
6565 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
6566 }
6567#endif
6568#ifdef FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006569 if ((csrIsProfileCCX(pProfile) ||
6570 ((pIesTemp->CCXVersion.present)
6571 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
6572 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
6573 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
6574 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
6575 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
6576 && (!(csrIsProfile11r( pProfile )))
6577 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07006578 {
6579 pConnectProfile->isCCXAssoc = 1;
6580 }
6581#endif
6582 //save ssid
6583 if( NULL == pIesTemp )
6584 {
6585 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
6586 }
6587 if(HAL_STATUS_SUCCESS(status))
6588 {
6589 if(pIesTemp->SSID.present)
6590 {
6591 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
6592 palCopyMemory(pMac->hHdd, pConnectProfile->SSID.ssId,
6593 pIesTemp->SSID.ssid, pIesTemp->SSID.num_ssid);
6594 }
6595
6596 //Save the bss desc
6597 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05306598
6599 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07006600 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05306601 //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 -07006602 pConnectProfile->qap = TRUE;
6603 }
6604 else
6605 {
6606 pConnectProfile->qap = FALSE;
6607 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006608 if ( NULL == pIes )
6609 {
6610 //Free memory if it allocated locally
6611 palFreeMemory(pMac->hHdd, pIesTemp);
6612 }
6613 }
6614 //Save Qos connection
6615 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
6616
6617 if(!HAL_STATUS_SUCCESS(status))
6618 {
6619 csrFreeConnectBssDesc(pMac, sessionId);
6620 }
6621 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
6622 {
6623 if((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
6624 palEqualMemory(pMac->hHdd, pProfile->SSIDs.SSIDList[index].SSID.ssId,
6625 pConnectProfile->SSID.ssId, pConnectProfile->SSID.length))
6626 {
6627 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
6628 break;
6629 }
6630 pConnectProfile->handoffPermitted = FALSE;
6631 }
6632
6633 return (status);
6634}
6635
Jeff Johnson295189b2012-06-20 16:38:30 -07006636static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
6637{
6638 tListElem *pEntry = NULL;
6639 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006640 //The head of the active list is the request we sent
6641 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
6642 if(pEntry)
6643 {
6644 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6645 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006646 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
6647 {
6648 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
6649 {
6650#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6651 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
6652#endif
6653 }
6654 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
6655 }
6656 else
6657 {
6658 tANI_U32 roamId = 0;
6659 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006660 if(!pSession)
6661 {
6662 smsLog(pMac, LOGE, FL(" session %d not found "), pSmeJoinRsp->sessionId);
6663 return;
6664 }
6665
Jeff Johnson295189b2012-06-20 16:38:30 -07006666
6667 //The head of the active list is the request we sent
6668 //Try to get back the same profile and roam again
6669 if(pCommand)
6670 {
6671 roamId = pCommand->u.roamCmd.roamId;
6672 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006673 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
6674 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
6675 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08lX [%d]\n", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
6676#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
6677 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
6678 if (csrRoamIsHandoffInProgress(pMac))
6679 {
6680 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6681 /* Should indicate neighbor roam algorithm about the connect failure here */
6682 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
6683 }
6684#endif
6685 if (pCommand)
6686 {
6687 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
6688 {
6689 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6690 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
6691 csrRoamReissueRoamCommand(pMac);
6692 }
6693 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
6694 {
6695 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6696 }
6697 else
6698 {
6699 csrRoam(pMac, pCommand);
6700 }
6701 }
6702 else
6703 {
6704 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6705 }
6706 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
6707}
6708
Jeff Johnson295189b2012-06-20 16:38:30 -07006709eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
6710 tDot11fBeaconIEs *pIes,
6711 tCsrRoamProfile *pProfile, tANI_U32 roamId )
6712{
6713 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006714 smsLog( pMac, LOG1, "Attempting to Join Bssid= %02x-%02x-%02x-%02x-%02x-%02x\n",
6715 pSirBssDesc->bssId[ 0 ],pSirBssDesc->bssId[ 1 ],pSirBssDesc->bssId[ 2 ],
6716 pSirBssDesc->bssId[ 3 ],pSirBssDesc->bssId[ 4 ],pSirBssDesc->bssId[ 5 ] );
6717
6718 // Set the roaming substate to 'join attempt'...
6719 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006720 // attempt to Join this BSS...
Srinivas Girigowda071f6082013-01-16 13:39:39 -08006721 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006722 return (status);
6723}
6724
Jeff Johnson295189b2012-06-20 16:38:30 -07006725static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
6726 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
6727{
6728 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006729 // Set the roaming substate to 'join attempt'...
6730 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
6731
Srinivas Girigowda071f6082013-01-16 13:39:39 -08006732 smsLog(pMac, LOGE, FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006733
6734 // attempt to Join this BSS...
Srinivas Girigowda071f6082013-01-16 13:39:39 -08006735 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07006736}
6737
Jeff Johnson295189b2012-06-20 16:38:30 -07006738void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
6739{
6740 tListElem *pEntry;
6741 tSmeCmd *pCommand;
6742 tCsrRoamInfo roamInfo;
6743 tANI_U32 sessionId;
6744 tCsrRoamSession *pSession;
6745
6746 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
6747 if(pEntry)
6748 {
6749 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6750 if ( eSmeCommandRoam == pCommand->command )
6751 {
6752 sessionId = pCommand->sessionId;
6753 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006754
6755 if(!pSession)
6756 {
6757 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6758 return;
6759 }
6760
Jeff Johnson295189b2012-06-20 16:38:30 -07006761 if( pCommand->u.roamCmd.fStopWds )
6762 {
6763 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
6764 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
6765 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6766 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07006767 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07006768 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
6769 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6770 eCSR_ROAM_WDS_IND,
6771 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07006772 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
6773 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
6774 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6775 eCSR_ROAM_INFRA_IND,
6776 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
6777 }
6778
Jeff Johnson295189b2012-06-20 16:38:30 -07006779
Jeff Johnson295189b2012-06-20 16:38:30 -07006780 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
6781 {
6782 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated\n");
6783 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6784 }
6785 }
6786 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
6787 {
6788 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated\n");
6789 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6790 }
6791 }
6792 else
6793 {
6794 smsLog(pMac, LOGW, " Command is not roaming after disassociated\n");
6795 }
6796 }
6797 else
6798 {
6799 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available\n");
6800 }
6801}
6802
Jeff Johnson295189b2012-06-20 16:38:30 -07006803tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
6804{
6805 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
6806 tListElem *pEntry;
6807 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006808 //alwasy lock active list before locking pending list
6809 csrLLLock( &pMac->sme.smeCmdActiveList );
6810 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
6811 if(pEntry)
6812 {
6813 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6814 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
6815 {
6816 fRet = eANI_BOOLEAN_TRUE;
6817 }
6818 }
6819 if(eANI_BOOLEAN_FALSE == fRet)
6820 {
6821 csrLLLock(&pMac->sme.smeCmdPendingList);
6822 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
6823 while(pEntry)
6824 {
6825 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6826 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
6827 {
6828 fRet = eANI_BOOLEAN_TRUE;
6829 break;
6830 }
6831 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
6832 }
6833 csrLLUnlock(&pMac->sme.smeCmdPendingList);
6834 }
6835 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07006836 return (fRet);
6837}
6838
Jeff Johnson295189b2012-06-20 16:38:30 -07006839tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
6840{
6841 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
6842 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07006843 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
6844 {
6845 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
6846 {
6847 break;
6848 }
6849 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006850 return ( fRet );
6851}
6852
Jeff Johnson295189b2012-06-20 16:38:30 -07006853tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
6854{
6855 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006856 //alwasy lock active list before locking pending list
6857 csrLLLock( &pMac->sme.smeCmdActiveList );
6858 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
6859 if(eANI_BOOLEAN_FALSE == fRet)
6860 {
6861 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
6862 }
6863 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07006864 return (fRet);
6865}
6866
Jeff Johnson295189b2012-06-20 16:38:30 -07006867tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
6868{
6869 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
6870 tListElem *pEntry;
6871 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07006872 //alwasy lock active list before locking pending list
6873 csrLLLock( &pMac->sme.smeCmdActiveList );
6874 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
6875 if( pEntry )
6876 {
6877 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
6878 if( ( eCsrRoamCommandScan == pCommand->command ) &&
6879 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
6880 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
6881 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
6882 {
6883 fRet = eANI_BOOLEAN_TRUE;
6884 }
6885 }
6886 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07006887 return (fRet);
6888}
Jeff Johnson295189b2012-06-20 16:38:30 -07006889eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
6890{
6891 eHalStatus status = eHAL_STATUS_SUCCESS;
6892 tSmeCmd *pCommand = NULL;
6893 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
6894 tANI_BOOLEAN fRemoveCmd = FALSE;
6895 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07006896 // Delete the old assoc command. All is setup for reassoc to be serialized
6897 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6898 if ( pEntry )
6899 {
6900 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6901 if ( !pCommand )
6902 {
6903 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
6904 return eHAL_STATUS_RESOURCES;
6905 }
6906 if ( eSmeCommandRoam == pCommand->command )
6907 {
6908 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
6909 {
6910 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
6911 }
6912 else
6913 {
6914 smsLog( pMac, LOGE, FL(" Unexpected active roam command present \n") );
6915 }
6916 if (fRemoveCmd == FALSE)
6917 {
6918 // Implies we did not get the serialized assoc command we
6919 // were expecting
6920 pCommand = NULL;
6921 }
6922 }
6923 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006924 if(NULL == pCommand)
6925 {
6926 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command\n") );
6927 return eHAL_STATUS_RESOURCES;
6928 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006929 do
6930 {
6931 //Change the substate in case it is wait-for-key
6932 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
6933 {
6934 csrRoamStopWaitForKeyTimer( pMac );
6935 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
6936 }
6937 pCommand->command = eSmeCommandRoam;
6938 pCommand->sessionId = (tANI_U8)sessionId;
6939 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07006940 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6941 if( !HAL_STATUS_SUCCESS( status ) )
6942 {
6943 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
6944 csrReleaseCommandRoam( pMac, pCommand );
6945 }
6946 } while( 0 );
6947
Jeff Johnson295189b2012-06-20 16:38:30 -07006948 return( status );
6949}
6950static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
6951{
6952 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
6953 tCsrScanResult *pScanResult = NULL;
6954 tSirBssDescription *pBssDesc = NULL;
6955 tSmeCmd *pCommand = NULL;
6956 tANI_U32 sessionId;
6957 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07006958 if(NULL == pEntry)
6959 {
6960 smsLog(pMac, LOGW, " CFG_CNF with active list empty\n");
6961 return;
6962 }
6963 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6964 sessionId = pCommand->sessionId;
6965 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006966
6967 if(!pSession)
6968 {
6969 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6970 return;
6971 }
6972
Jeff Johnson295189b2012-06-20 16:38:30 -07006973 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
6974 {
6975 //the roaming is cancelled. Simply complete the command
6976 smsLog(pMac, LOGW, FL(" Roam command cancelled\n"));
6977 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
6978 }
6979 else
6980 {
6981 if ( CCM_IS_RESULT_SUCCESS(result) )
6982 {
6983 smsLog(pMac, LOG2, "Cfg sequence complete\n");
6984 // Successfully set the configuration parameters for the new Bss. Attempt to
6985 // join the roaming Bss.
6986 if(pCommand->u.roamCmd.pRoamBssEntry)
6987 {
6988 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
6989 pBssDesc = &pScanResult->Result.BssDescriptor;
6990 }
6991 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
6992 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07006993 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07006994 )
6995 {
6996 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
6997 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
6998 pBssDesc, pCommand->u.roamCmd.roamId )))
6999 {
7000 smsLog(pMac, LOGW, " CSR start BSS failed\n");
7001 //We need to complete the command
7002 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7003 }
7004 }
7005 else
7006 {
7007 if (!pCommand->u.roamCmd.pRoamBssEntry)
7008 {
7009 smsLog(pMac, LOGW, " pRoamBssEntry is NULL\n");
7010 //We need to complete the command
7011 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
7012 return;
7013 }
7014 // If we are roaming TO an Infrastructure BSS...
7015 VOS_ASSERT(pScanResult != NULL);
7016 if ( csrIsInfraBssDesc( pBssDesc ) )
7017 {
7018 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07007019 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
7020 {
7021 // ..and currently in an Infrastructure connection....
7022 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
7023 {
7024 // ...and the SSIDs are equal, then we Reassoc.
7025 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
7026 pIesLocal ) )
7027 // ..and currently in an infrastructure connection
7028 {
7029 // then issue a Reassoc.
7030 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
7031 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
7032 &pCommand->u.roamCmd.roamProfile );
7033 }
7034 else
7035 {
7036
7037 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
7038 // previously associated AP.
7039 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7040 pIesLocal,
7041 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
7042 {
7043 //try something else
7044 csrRoam( pMac, pCommand );
7045 }
7046 }
7047 }
7048 else
7049 {
7050 eHalStatus status = eHAL_STATUS_SUCCESS;
7051
7052 /* We need to come with other way to figure out that this is because of HO in BMP
7053 The below API will be only available for Android as it uses a different HO algorithm */
7054 /* Reassoc request will be used only for CCX and 11r handoff whereas other legacy roaming should
7055 * use join request */
7056#ifdef WLAN_FEATURE_VOWIFI_11R
7057 if (csrRoamIsHandoffInProgress(pMac) &&
7058 csrRoamIs11rAssoc(pMac))
7059 {
7060 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
7061 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
7062 }
7063 else
7064#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007065#ifdef FEATURE_WLAN_CCX
7066 if (csrRoamIsHandoffInProgress(pMac) &&
7067 csrRoamIsCCXAssoc(pMac))
7068 {
7069 // Now serialize the reassoc command.
7070 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7071 }
7072 else
7073#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007074#ifdef FEATURE_WLAN_LFR
7075 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05307076 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007077 {
7078 // Now serialize the reassoc command.
7079 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7080 }
7081 else
7082#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007083 // else we are not connected and attempting to Join. Issue the
7084 // Join request.
7085 {
7086 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7087 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
7088 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
7089 }
7090 if(!HAL_STATUS_SUCCESS(status))
7091 {
7092 //try something else
7093 csrRoam( pMac, pCommand );
7094 }
7095 }
7096 if( !pScanResult->Result.pvIes )
7097 {
7098 //Locally allocated
7099 palFreeMemory(pMac->hHdd, pIesLocal);
7100 }
7101 }
7102 }//if ( csrIsInfraBssDesc( pBssDesc ) )
7103 else
7104 {
7105 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description\n"));
7106 }
7107 }//else
7108 }//if ( WNI_CFG_SUCCESS == result )
7109 else
7110 {
7111 // In the event the configuration failed, for infra let the roam processor
7112 //attempt to join something else...
7113 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
7114 {
7115 csrRoam(pMac, pCommand);
7116 }
7117 else
7118 {
7119 //We need to complete the command
7120 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
7121 {
7122 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7123 }
7124 else
7125 {
7126 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7127 }
7128 }
7129 }
7130 }//we have active entry
7131}
7132
Jeff Johnson295189b2012-06-20 16:38:30 -07007133static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
7134{
7135 //No one is sending eWNI_SME_AUTH_REQ to PE.
7136 smsLog(pMac, LOGW, FL("is no-op\n"));
7137 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
7138 {
7139 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful\n" );
7140 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
7141 // join the new one...
7142 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07007143 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
7144 }
7145 else {
7146 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08lX [%d]\n", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
7147 /***profHandleLostLinkAfterReset(pAdapter);
7148 // In the event the authenticate fails, let the roam processor attempt to join something else...
7149 roamRoam( pAdapter );***/
7150 }
7151}
7152
Jeff Johnson295189b2012-06-20 16:38:30 -07007153static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
7154{
7155 eCsrRoamCompleteResult result;
7156 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7157 tCsrRoamInfo roamInfo;
7158 tANI_U32 roamId = 0;
7159
7160 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7161 {
7162 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful\n" );
7163 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07007164 /* Defeaturize this part later if needed */
7165#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7166 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
7167 * we need the response contents while processing the result in csrRoamProcessResults() */
7168 if (csrRoamIsHandoffInProgress(pMac))
7169 {
7170 /* Need to dig more on indicating events to SME QoS module */
7171 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7172 csrRoamComplete( pMac, result, pSmeJoinRsp);
7173 }
7174 else
7175#endif
7176 {
7177 csrRoamComplete( pMac, result, NULL );
7178 }
7179 }
7180 /* Should we handle this similar to handling the join failure? Is it ok
7181 * to call csrRoamComplete() with state as CsrJoinFailure */
7182 else
7183 {
7184 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08lX [%d]\n", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
7185 result = eCsrReassocFailure;
7186#ifdef WLAN_FEATURE_VOWIFI_11R
7187 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
7188 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode))
7189 {
7190 // Inform HDD to turn off FT flag in HDD
7191 if (pNeighborRoamInfo)
7192 {
7193 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7194 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
7195 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07007196 /*
7197 * Since the above callback sends a disconnect
7198 * to HDD, we should clean-up our state
7199 * machine as well to be in sync with the upper
7200 * layers. There is no need to send a disassoc
7201 * since: 1) we will never reassoc to the current
7202 * AP in LFR, and 2) there is no need to issue a
7203 * disassoc to the AP with which we were trying
7204 * to reassoc.
7205 */
7206 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7207 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007208 }
7209 }
7210#endif
7211 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
7212 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
7213 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
7214 //The disassoc rsp message will remove the command from active list
7215 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
7216 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
7217 {
7218 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7219 }
7220 }
7221}
7222
Jeff Johnson295189b2012-06-20 16:38:30 -07007223static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
7224{
Jeff Johnson295189b2012-06-20 16:38:30 -07007225#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7226 {
7227 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07007228 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
7229 if(pIbssLog)
7230 {
7231 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
7232 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
7233 {
7234 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
7235 }
7236 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
7237 }
7238 }
7239#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007240 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7241 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
7242 {
7243 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7244 }
7245 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
7246 {
7247 csrRoamReissueRoamCommand(pMac);
7248 }
7249}
7250
Jeff Johnson295189b2012-06-20 16:38:30 -07007251void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
7252{
7253 tSirResultCodes statusCode;
7254#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7255 tScanResultHandle hBSSList;
7256 tANI_BOOLEAN fCallCallback, fRemoveCmd;
7257 eHalStatus status;
7258 tCsrRoamInfo roamInfo;
7259 tCsrScanResultFilter *pScanFilter = NULL;
7260 tANI_U32 roamId = 0;
7261 tCsrRoamProfile *pCurRoamProfile = NULL;
7262 tListElem *pEntry = NULL;
7263 tSmeCmd *pCommand = NULL;
7264#endif
7265 tANI_U32 sessionId;
7266 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07007267
Jeff Johnson295189b2012-06-20 16:38:30 -07007268 tSirSmeDisassocRsp SmeDisassocRsp;
7269
7270 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
7271 sessionId = SmeDisassocRsp.sessionId;
7272 statusCode = SmeDisassocRsp.statusCode;
7273
7274 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d\n", sessionId);
7275
7276 if ( csrIsConnStateInfra( pMac, sessionId ) )
7277 {
7278 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7279 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007280 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007281
7282 if(!pSession)
7283 {
7284 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7285 return;
7286 }
7287
Jeff Johnson295189b2012-06-20 16:38:30 -07007288 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
7289 {
7290 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7291 }
7292 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
7293 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
7294 {
7295 if ( eSIR_SME_SUCCESS == statusCode )
7296 {
7297 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully\n" );
7298 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
7299 }
7300 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7301 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007302 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
7303 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007304 smsLog( pMac, LOGE, "CSR SmeDisassocReq due to HO on session %d\n", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007305#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007306 /*
7307 * First ensure if the roam profile is in the scan cache.
7308 * If not, post a reassoc failure and disconnect.
7309 */
7310 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
7311 if(HAL_STATUS_SUCCESS(status))
7312 {
7313 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
7314 status = csrRoamPrepareFilterFromProfile(pMac,
7315 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
7316 if(!HAL_STATUS_SUCCESS(status))
7317 {
7318 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
7319 __func__, status);
7320 goto POST_ROAM_FAILURE;
7321 }
7322 else
7323 {
7324 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7325 if (!HAL_STATUS_SUCCESS(status))
7326 {
7327 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
7328 __func__, status);
7329 goto POST_ROAM_FAILURE;
7330 }
7331 }
7332 }
7333 else
7334 {
7335 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
7336 __func__, status);
7337 goto POST_ROAM_FAILURE;
7338 }
7339
7340 /*
7341 * After ensuring that the roam profile is in the scan result list,
7342 * dequeue the command from the active list.
7343 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007344 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7345 if ( pEntry )
7346 {
7347 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007348 /* If the head of the queue is Active and it is a ROAM command, remove
7349 * and put this on the Free queue.
7350 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007351 if ( eSmeCommandRoam == pCommand->command )
7352 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007353
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007354 /*
7355 * we need to process the result first before removing it from active list
7356 * because state changes still happening insides roamQProcessRoamResults so
7357 * no other roam command should be issued.
7358 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007359 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7360 if(pCommand->u.roamCmd.fReleaseProfile)
7361 {
7362 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
7363 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
7364 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007365 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07007366 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07007367 else
7368 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007369 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d\n",
7370 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07007371 }
7372 }
7373 else
7374 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007375 smsLog( pMac, LOGE, "%s: roam command not active\n", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007376 }
7377 }
7378 else
7379 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007380 smsLog( pMac, LOGE, "%s: NO commands are active\n", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007381 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007382
7383 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07007384 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
7385
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007386 palCopyMemory(pMac->hHdd, roamInfo.bssid,
7387 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
7388 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07007389
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007390 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
7391 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007392
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007393 /* Copy the connected profile to apply the same for this connection as well */
7394 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
7395 (void **)&pCurRoamProfile, sizeof(tCsrRoamProfile))))
Jeff Johnson295189b2012-06-20 16:38:30 -07007396 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007397 palZeroMemory(pMac->hHdd, pCurRoamProfile, sizeof(tCsrRoamProfile));
7398 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
7399 //make sure to put it at the head of the cmd queue
7400 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
7401 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
7402 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
7403
Jeff Johnson295189b2012-06-20 16:38:30 -07007404 if(!HAL_STATUS_SUCCESS(status))
7405 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007406 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
7407 __func__, status);
7408 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007409 }
7410
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007411 /* Notify sub-modules like QoS etc. that handoff happening */
7412 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
7413 palFreeMemory(pMac->hHdd, pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07007414 csrFreeScanFilter(pMac, pScanFilter);
7415 palFreeMemory( pMac->hHdd, pScanFilter );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007416 return;
7417 }
7418
7419POST_ROAM_FAILURE:
7420 if (pScanFilter)
7421 {
7422 csrFreeScanFilter(pMac, pScanFilter);
7423 palFreeMemory( pMac->hHdd, pScanFilter );
7424 }
7425 if (pCurRoamProfile)
7426 palFreeMemory(pMac->hHdd, pCurRoamProfile);
7427
7428 /* Inform the upper layers that the reassoc failed */
7429 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7430 csrRoamCallCallback(pMac, sessionId,
7431 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
7432
7433 /*
7434 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
7435 * Upon success, we would re-enter this routine after receiving the disassoc
7436 * response and will fall into the reassoc fail sub-state. And, eventually
7437 * call csrRoamComplete which would remove the roam command from SME active
7438 * queue.
7439 */
7440 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
7441 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
7442 {
7443 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
7444 __func__, status);
7445 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07007446 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007447#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07007448
Jeff Johnson295189b2012-06-20 16:38:30 -07007449 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
7450 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
7451 {
7452 // Disassoc due to Reassoc failure falls into this codepath....
7453 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7454 }
7455 else
7456 {
7457 if ( eSIR_SME_SUCCESS == statusCode )
7458 {
7459 // Successfully disassociated from the 'old' Bss...
7460 //
7461 // We get Disassociate response in three conditions.
7462 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
7463 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
7464 // Infrastructure network.
7465 // - Third is where we are doing an Infra to Infra roam between networks with different
7466 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
7467
7468 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully\n" );
7469 }
7470 else
7471 {
7472 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08lX\n", statusCode );
7473 }
7474 //We are not done yet. Get the data and continue roaming
7475 csrRoamReissueRoamCommand(pMac);
7476 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007477}
7478
Jeff Johnson295189b2012-06-20 16:38:30 -07007479static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
7480{
7481 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007482 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
7483 smsLog(pMac, LOGW, FL("is no-op\n"));
7484 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
7485 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
7486 {
7487 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7488 }
7489 else
7490 {
7491 if ( eSIR_SME_SUCCESS == statusCode )
7492 {
7493 // Successfully deauth from the 'old' Bss...
7494 //
7495 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully\n" );
7496 }
7497 else
7498 {
7499 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08lX\n", statusCode );
7500 }
7501 //We are not done yet. Get the data and continue roaming
7502 csrRoamReissueRoamCommand(pMac);
7503 }
7504}
7505
Jeff Johnson295189b2012-06-20 16:38:30 -07007506static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
7507{
7508 eCsrRoamCompleteResult result;
7509
7510 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
7511 {
7512 smsLog( pMac, LOGW, "SmeStartBssReq Successful\n" );
7513 result = eCsrStartBssSuccess;
7514 }
7515 else
7516 {
7517 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08lX\n", pSmeStartBssRsp->statusCode );
7518 //Let csrRoamComplete decide what to do
7519 result = eCsrStartBssFailure;
7520 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007521 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007522}
7523
Jeff Johnson295189b2012-06-20 16:38:30 -07007524/*
7525 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
7526 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
7527 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
7528 For the messages where sender allocates memory for specific structures, then it can be
7529 cast accordingly.
7530*/
7531void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
7532{
7533 tSirSmeRsp *pSmeRsp;
7534 tSmeIbssPeerInd *pIbssPeerInd;
7535 tCsrRoamInfo roamInfo;
7536 // TODO Session Id need to be acquired in this function
7537 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007538 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07007539 smsLog( pMac, LOG2, "Message %d[0x%04X] received in substate %d\n",
7540 pSmeRsp->messageType, pSmeRsp->messageType,
7541 pMac->roam.curSubState[pSmeRsp->sessionId] );
7542#if defined ANI_PRODUCT_TYPE_AP
7543 pSmeRsp->messageType = pal_be16_to_cpu(pSmeRsp->messageType);
7544 pSmeRsp->length = pal_be16_to_cpu(pSmeRsp->length);
7545 pSmeRsp->statusCode = pal_be32_to_cpu(pSmeRsp->statusCode);
7546#else
7547 pSmeRsp->messageType = (pSmeRsp->messageType);
7548 pSmeRsp->length = (pSmeRsp->length);
7549 pSmeRsp->statusCode = (pSmeRsp->statusCode);
7550#endif
7551 switch (pSmeRsp->messageType)
7552 {
7553
7554 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
7555 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
7556 {
7557 //We sent a JOIN_REQ
7558 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
7559 }
7560 break;
7561
7562 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
7563 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
7564 {
7565 //We sent a AUTH_REQ
7566 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
7567 }
7568 break;
7569
7570 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
7571 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
7572 {
7573 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
7574 }
7575 break;
7576
7577 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
7578 {
7579 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
7580 }
7581 break;
7582
7583 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
7584 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
7585 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
7586 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
7587 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
7588 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
7589//HO
7590 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
7591 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07007592 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %d\n"), pMac->roam.curSubState[pSmeRsp->sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007593 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
7594 }
7595 break;
7596
7597 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
7598 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
7599 {
7600 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
7601 }
7602 break;
7603
7604 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
7605 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
7606 {
7607 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
7608 }
7609 break;
7610
7611 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
7612 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
7613 {
7614 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
7615 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007616 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007617 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
7618 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
7619 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
7620 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state\n");
7621 palZeroMemory( pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo) );
7622 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
7623 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
7624 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
7625 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
7626 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
7627 eCSR_ROAM_CONNECT_STATUS_UPDATE,
7628 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
7629 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007630 default:
7631 smsLog( pMac, LOG1, "Unexpected message type = %d[0x%X] received in substate %d\n",
7632 pSmeRsp->messageType, pSmeRsp->messageType,
7633 pMac->roam.curSubState[pSmeRsp->sessionId] );
7634
7635 //If we are connected, check the link status change
7636 if(!csrIsConnStateDisconnected(pMac, sessionId))
7637 {
7638 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
7639 }
7640 break;
7641 }
7642}
7643
Jeff Johnson295189b2012-06-20 16:38:30 -07007644void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
7645{
7646 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07007647 switch (pSirMsg->messageType)
7648 {
7649 case eWNI_SME_GET_STATISTICS_RSP:
Mohit Khanna23863762012-09-11 17:40:09 -07007650 smsLog( pMac, LOG2, FL("Stats rsp from PE\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007651 csrRoamStatsRspProcessor( pMac, pSirMsg );
7652 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007653 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
7654 {
7655 tCsrRoamSession *pSession;
7656 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
7657 tCsrRoamInfo roamInfo;
7658 tCsrRoamInfo *pRoamInfo = NULL;
7659 tANI_U32 sessionId;
7660 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007661 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer \n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007662 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
7663 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07007664 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
7665 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
7666 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07007667
7668 if(!pSession)
7669 {
7670 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7671 return;
7672 }
7673
Jeff Johnson295189b2012-06-20 16:38:30 -07007674 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
7675 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07007676 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
7677 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
7678 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07007679 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
7680 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07007681 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr, sizeof(tSirMacAddr));
7682 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pUpperLayerAssocCnf->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07007683 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07007684 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
7685 {
7686 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
7687 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
7688 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
7689 }
7690 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
7691 {
7692 vos_sleep( 100 );
7693 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
7694 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
7695 }
7696
Jeff Johnson295189b2012-06-20 16:38:30 -07007697 }
7698 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007699 default:
7700 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
7701 break;
7702 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007703}
7704
Jeff Johnson295189b2012-06-20 16:38:30 -07007705eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
7706 tSirBssDescription *pBssDescription,
7707 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
7708 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
7709 tANI_U8 keyId, tANI_U16 keyLength,
7710 tANI_U8 *pKey, tANI_U8 paeRole )
7711{
7712 eHalStatus status = eHAL_STATUS_SUCCESS;
7713 tAniEdType edType;
7714
7715 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
7716 {
7717 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
7718 }
7719
7720 edType = csrTranslateEncryptTypeToEdType( EncryptType );
7721
7722 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
7723 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
7724 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
7725 addKey )
7726 {
7727 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07007728 setKey.encType = EncryptType;
7729 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
7730 palCopyMemory( pMac->hHdd, &setKey.peerMac, bssId, sizeof(tCsrBssid) );
7731 setKey.paeRole = paeRole; //0 for supplicant
7732 setKey.keyId = keyId; // Kye index
7733 setKey.keyLength = keyLength;
7734 if( keyLength )
7735 {
7736 palCopyMemory( pMac->hHdd, setKey.Key, pKey, keyLength );
7737 }
7738 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
7739 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007740 return (status);
7741}
7742
Jeff Johnson295189b2012-06-20 16:38:30 -07007743static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
7744 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
7745{
7746 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
7747 tSmeCmd *pCommand = NULL;
7748#ifdef FEATURE_WLAN_CCX
7749 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7750#endif /* FEATURE_WLAN_CCX */
7751
7752 do
7753 {
7754 pCommand = csrGetCommandBuffer(pMac);
7755 if(NULL == pCommand)
7756 {
7757 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
7758 status = eHAL_STATUS_RESOURCES;
7759 break;
7760 }
7761 pCommand->command = eSmeCommandSetKey;
7762 pCommand->sessionId = (tANI_U8)sessionId;
7763 // validate the key length, Adjust if too long...
7764 // for static WEP the keys are not set thru' SetContextReq
7765 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
7766 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
7767 {
7768 //KeyLength maybe 0 for static WEP
7769 if( pSetKey->keyLength )
7770 {
7771 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
7772 {
7773 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7774 break;
7775 }
7776
7777 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
7778 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WEP40_KEY_LEN );
7779 }
7780 }
7781 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
7782 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
7783 {
7784 //KeyLength maybe 0 for static WEP
7785 if( pSetKey->keyLength )
7786 {
7787 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
7788 {
7789 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7790 break;
7791 }
7792
7793 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
7794 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WEP104_KEY_LEN );
7795 }
7796 }
7797 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
7798 {
7799 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
7800 {
7801 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7802 break;
7803 }
7804 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
7805 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_TKIP_KEY_LEN );
7806 }
7807 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
7808 {
7809 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
7810 {
7811 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7812 break;
7813 }
7814 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
7815 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN );
7816 }
7817#ifdef FEATURE_WLAN_WAPI
7818 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
7819 {
7820 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
7821 {
7822 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7823 break;
7824 }
7825 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
7826 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WAPI_KEY_LEN );
7827 }
7828#endif /* FEATURE_WLAN_WAPI */
7829#ifdef FEATURE_WLAN_CCX
7830 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
7831 {
7832 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
7833 {
7834 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7835 break;
7836 }
7837 palCopyMemory( pMac->hHdd, pSession->ccxCckmInfo.krk, pSetKey->Key, CSR_KRK_KEY_LEN );
7838 pSession->ccxCckmInfo.reassoc_req_num=1;
7839 pSession->ccxCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
7840 status = eHAL_STATUS_SUCCESS;
7841 break;
7842 }
7843#endif /* FEATURE_WLAN_CCX */
Jeff Johnsone7245742012-09-05 17:12:55 -07007844
Jeff Johnson295189b2012-06-20 16:38:30 -07007845#ifdef WLAN_FEATURE_11W
7846 //Check for 11w BIP
7847 else if ( eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType )
7848 {
7849 tANI_U16 count = 0;
7850 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
7851 {
7852 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7853 break;
7854 }
7855 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
7856 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN );
7857 }
7858#endif
7859 status = eHAL_STATUS_SUCCESS;
7860 pCommand->u.setKeyCmd.roamId = roamId;
7861 pCommand->u.setKeyCmd.encType = pSetKey->encType;
7862 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
7863 palCopyMemory( pMac->hHdd, &pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac, sizeof(tCsrBssid) );
7864 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
7865 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
7866 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN );
7867 //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
7868
7869 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
7870 if( !HAL_STATUS_SUCCESS( status ) )
7871 {
7872 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
7873 }
7874 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007875 // Free the command if there has been a failure, or it is a
7876 // "local" operation like the set CCX CCKM KRK key.
7877 if( (!HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ))
7878#ifdef FEATURE_WLAN_CCX
7879 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
7880#endif /* FEATURE_WLAN_CCX */
7881 )
7882 {
7883 csrReleaseCommandSetKey( pMac, pCommand );
7884 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007885 return( status );
7886}
7887
Jeff Johnson295189b2012-06-20 16:38:30 -07007888eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
7889 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
7890{
7891 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
7892 tSmeCmd *pCommand = NULL;
7893 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007894 do
7895 {
7896 if( !csrIsSetKeyAllowed(pMac, sessionId) )
7897 {
7898 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key\n") );
7899 status = eHAL_STATUS_CSR_WRONG_STATE;
7900 break;
7901 }
7902 pCommand = csrGetCommandBuffer(pMac);
7903 if(NULL == pCommand)
7904 {
7905 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
7906 status = eHAL_STATUS_RESOURCES;
7907 break;
7908 }
7909 pCommand->command = eSmeCommandRemoveKey;
7910 pCommand->sessionId = (tANI_U8)sessionId;
7911 pCommand->u.removeKeyCmd.roamId = roamId;
7912 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
7913 palCopyMemory( pMac->hHdd, &pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac, sizeof(tSirMacAddr) );
7914 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
7915 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7916 {
7917 //in this case, put it to the end of the Q incase there is a set key pending.
7918 fImediate = eANI_BOOLEAN_FALSE;
7919 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007920 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac=%02x, %02x, %02x, %02x, %02x, %02x\n"),
7921 pRemoveKey->encType, pRemoveKey->keyId,
7922 pCommand->u.removeKeyCmd.peerMac[0],
7923 pCommand->u.removeKeyCmd.peerMac[1],
7924 pCommand->u.removeKeyCmd.peerMac[2],
7925 pCommand->u.removeKeyCmd.peerMac[3],
7926 pCommand->u.removeKeyCmd.peerMac[4],
7927 pCommand->u.removeKeyCmd.peerMac[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007928 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
7929 if( !HAL_STATUS_SUCCESS( status ) )
7930 {
7931 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
7932 break;
7933 }
7934 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007935 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
7936 {
7937 csrReleaseCommandRemoveKey( pMac, pCommand );
7938 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007939 return (status );
7940}
7941
Jeff Johnson295189b2012-06-20 16:38:30 -07007942eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
7943{
7944 eHalStatus status;
7945 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
7946 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
7947 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
7948 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007949#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7950 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7951 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07007952 if(eCSR_ENCRYPT_TYPE_NONE != edType)
7953 {
7954 palZeroMemory(pMac->hHdd, &setKeyEvent, sizeof(vos_event_wlan_security_payload_type));
7955 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
7956 {
7957 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
7958 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
7959 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
7960 }
7961 else
7962 {
7963 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
7964 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
7965 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
7966 }
7967 palCopyMemory( pMac->hHdd, setKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
7968 if(CSR_IS_ENC_TYPE_STATIC(edType))
7969 {
7970 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007971 //It has to be static WEP here
7972 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
7973 {
7974 setKeyEvent.keyId = (v_U8_t)defKeyId;
7975 }
7976 }
7977 else
7978 {
7979 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
7980 }
7981 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
7982 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
7983 }
7984#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007985 if( csrIsSetKeyAllowed(pMac, sessionId) )
7986 {
7987 status = csrSendMBSetContextReqMsg( pMac, sessionId,
7988 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
7989 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
7990 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
7991 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
7992 pCommand->u.setKeyCmd.keyRsc);
7993 }
7994 else
7995 {
7996 smsLog( pMac, LOGW, FL(" cannot process not connected\n") );
7997 //Set this status so the error handling take care of the case.
7998 status = eHAL_STATUS_CSR_WRONG_STATE;
7999 }
8000 if( !HAL_STATUS_SUCCESS(status) )
8001 {
8002 smsLog( pMac, LOGE, FL(" error status %d\n"), status );
8003 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008004#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8005 if(eCSR_ENCRYPT_TYPE_NONE != edType)
8006 {
8007 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8008 {
8009 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8010 }
8011 else
8012 {
8013 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8014 }
8015 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8016 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8017 }
8018#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008019 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008020 return ( status );
8021}
8022
Jeff Johnson295189b2012-06-20 16:38:30 -07008023eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8024{
8025 eHalStatus status;
8026 tpSirSmeRemoveKeyReq pMsg = NULL;
8027 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
8028 tANI_U8 *p;
8029 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008030#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8031 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8032 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07008033 palZeroMemory(pMac->hHdd, &removeKeyEvent, sizeof(vos_event_wlan_security_payload_type));
8034 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
8035 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8036 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8037 palCopyMemory( pMac->hHdd, removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
8038 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
8039 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8040 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8041#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008042 if( csrIsSetKeyAllowed(pMac, sessionId) )
8043 {
8044 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, wMsgLen );
8045 }
8046 else
8047 {
8048 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key\n") );
8049 //Set the error status so error handling kicks in below
8050 status = eHAL_STATUS_CSR_WRONG_STATE;
8051 }
8052 if( HAL_STATUS_SUCCESS( status ) )
8053 {
8054 palZeroMemory(pMac->hHdd, pMsg, wMsgLen);
8055 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
8056 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008057 pMsg->sessionId = (tANI_U8)sessionId;
8058 pMsg->transactionId = 0;
8059 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
8060 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
8061 // bssId - copy from session Info
8062 palCopyMemory( pMac->hHdd, p, &pMac->roam.roamSession[sessionId].connectedProfile.bssid, sizeof(tSirMacAddr) );
8063 p += sizeof(tSirMacAddr);
8064 // peerMacAddr
8065 palCopyMemory( pMac->hHdd, p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr) );
8066 p += sizeof(tSirMacAddr);
8067 // edType
8068 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
8069 p++;
8070 // weptype
8071 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
8072 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
8073 {
8074 *p = (tANI_U8)eSIR_WEP_STATIC;
8075 }
8076 else
8077 {
8078 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
8079 }
8080 p++;
8081 //keyid
8082 *p = pCommand->u.removeKeyCmd.keyId;
8083 p++;
8084 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008085 status = palSendMBMessage(pMac->hHdd, pMsg);
8086 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008087 if( !HAL_STATUS_SUCCESS( status ) )
8088 {
8089 smsLog( pMac, LOGE, FL(" error status \n"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008090#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8091 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07008092 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008093 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8094#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008095 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
8096 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008097 return ( status );
8098}
8099
Jeff Johnson295189b2012-06-20 16:38:30 -07008100eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8101{
8102 eHalStatus status;
8103
8104 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8105 {
8106 status = eHAL_STATUS_CSR_WRONG_STATE;
8107 }
8108 else
8109 {
8110 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
8111 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008112 return ( status );
8113}
8114
Jeff Johnson295189b2012-06-20 16:38:30 -07008115/*
8116 Prepare a filter base on a profile for parsing the scan results.
8117 Upon successful return, caller MUST call csrFreeScanFilter on
8118 pScanFilter when it is done with the filter.
8119*/
8120eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
8121 tCsrScanResultFilter *pScanFilter)
8122{
8123 eHalStatus status = eHAL_STATUS_SUCCESS;
8124 tANI_U32 size = 0;
8125 tANI_U8 index = 0;
8126
8127 do
8128 {
8129 if(pProfile->BSSIDs.numOfBSSIDs)
8130 {
8131 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
8132 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->BSSIDs.bssid, size);
8133 if(!HAL_STATUS_SUCCESS(status))
8134 {
8135 break;
8136 }
8137 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
8138 palCopyMemory(pMac->hHdd, pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
8139 }
8140 if(pProfile->SSIDs.numOfSSIDs)
8141 {
8142 if( !CSR_IS_WDS_STA( pProfile ) )
8143 {
8144 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
8145 }
8146 else
8147 {
8148 //For WDS station
8149 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
8150 pScanFilter->SSIDs.numOfSSIDs = 1;
8151 }
8152 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
8153 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->SSIDs.SSIDList, size);
8154 if(!HAL_STATUS_SUCCESS(status))
8155 {
8156 break;
8157 }
8158 palCopyMemory(pMac->hHdd, pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList, size);
8159 }
8160 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
8161 {
8162 pScanFilter->ChannelInfo.numOfChannels = 0;
8163 pScanFilter->ChannelInfo.ChannelList = NULL;
8164 }
8165 else if(pProfile->ChannelInfo.numOfChannels)
8166 {
8167 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->ChannelInfo.ChannelList, sizeof(*pScanFilter->ChannelInfo.ChannelList) * pProfile->ChannelInfo.numOfChannels);
8168 pScanFilter->ChannelInfo.numOfChannels = 0;
8169 if(HAL_STATUS_SUCCESS(status))
8170 {
8171 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
8172 {
8173 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
8174 {
8175 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
8176 = pProfile->ChannelInfo.ChannelList[index];
8177 pScanFilter->ChannelInfo.numOfChannels++;
8178 }
8179 else
8180 {
8181 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid\n"), pProfile->ChannelInfo.ChannelList[index]);
8182 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008183 }
8184 }
8185 else
8186 {
8187 break;
8188 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008189 }
8190 else
8191 {
8192 smsLog(pMac, LOGW, FL("Channel list empty\n"));
8193 status = eHAL_STATUS_FAILURE;
8194 break;
8195 }
8196 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
8197 pScanFilter->authType = pProfile->AuthType;
8198 pScanFilter->EncryptionType = pProfile->EncryptionType;
8199 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
8200 pScanFilter->BSSType = pProfile->BSSType;
8201 pScanFilter->phyMode = pProfile->phyMode;
8202#ifdef FEATURE_WLAN_WAPI
8203 //check if user asked for WAPI with 11n or auto mode, in that case modify
8204 //the phymode to 11g
8205 if(csrIsProfileWapi(pProfile))
8206 {
8207 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
8208 {
8209 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
8210 }
8211 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
8212 {
8213 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
8214 }
8215 if(!pScanFilter->phyMode)
8216 {
8217 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
8218 }
8219 }
8220#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07008221 /*Save the WPS info*/
8222 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07008223 if( pProfile->countryCode[0] )
8224 {
8225 //This causes the matching function to use countryCode as one of the criteria.
8226 palCopyMemory( pMac->hHdd, pScanFilter->countryCode, pProfile->countryCode,
8227 WNI_CFG_COUNTRY_CODE_LEN );
8228 }
8229#ifdef WLAN_FEATURE_VOWIFI_11R
8230 if (pProfile->MDID.mdiePresent)
8231 {
8232 pScanFilter->MDID.mdiePresent = 1;
8233 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
8234 }
8235#endif
8236
8237 }while(0);
8238
8239 if(!HAL_STATUS_SUCCESS(status))
8240 {
8241 csrFreeScanFilter(pMac, pScanFilter);
8242 }
8243
8244 return(status);
8245}
8246
Jeff Johnson295189b2012-06-20 16:38:30 -07008247tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
8248 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
8249{
8250 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
8251 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008252 do
8253 {
8254 // Validate the type is ok...
8255 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
8256 pCommand = csrGetCommandBuffer( pMac );
8257 if ( !pCommand )
8258 {
8259 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
8260 break;
8261 }
8262 //Change the substate in case it is waiting for key
8263 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8264 {
8265 csrRoamStopWaitForKeyTimer( pMac );
8266 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
8267 }
8268 pCommand->command = eSmeCommandWmStatusChange;
8269 pCommand->sessionId = (tANI_U8)sessionId;
8270 pCommand->u.wmStatusChangeCmd.Type = Type;
8271 if ( eCsrDisassociated == Type )
8272 {
8273 palCopyMemory( pMac->hHdd, &pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg, pSmeRsp,
8274 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ) );
8275 }
8276 else
8277 {
8278 palCopyMemory( pMac->hHdd, &pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg, pSmeRsp,
8279 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ) );
8280 }
8281 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
8282 {
8283 fCommandQueued = eANI_BOOLEAN_TRUE;
8284 }
8285 else
8286 {
8287 smsLog( pMac, LOGE, FL(" fail to send message \n") );
8288 csrReleaseCommandWmStatusChange( pMac, pCommand );
8289 }
8290
Jeff Johnson295189b2012-06-20 16:38:30 -07008291 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
8292 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07008293 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07008294 return( fCommandQueued );
8295}
8296
Jeff Johnson295189b2012-06-20 16:38:30 -07008297static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
8298{
8299 v_S7_t rssi = 0;
8300 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
8301 if(pGetRssiReq)
8302 {
8303 if(NULL != pGetRssiReq->pVosContext)
8304 {
8305 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
8306 }
8307 else
8308 {
8309 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL\n"));
8310 return;
8311 }
8312
8313 if(NULL != pGetRssiReq->rssiCallback)
8314 {
8315 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
8316 }
8317 else
8318 {
8319 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL\n"));
8320 return;
8321 }
8322 }
8323 else
8324 {
8325 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL\n"));
8326 }
8327 return;
8328}
Jeff Johnsone7245742012-09-05 17:12:55 -07008329static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
8330{
8331 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
8332 if(pTlRssiInd)
8333 {
8334 if(NULL != pTlRssiInd->tlCallback)
8335 {
8336 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Madan Mohan Koyyalamudi313a5932012-12-12 15:59:44 -08008337 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07008338 }
8339 else
8340 {
8341 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL\n"));
8342 }
8343 }
8344 else
8345 {
8346 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL\n"));
8347 }
8348 return;
8349}
Jeff Johnson295189b2012-06-20 16:38:30 -07008350
8351void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
8352{
8353 tSirSmeAssocInd *pAssocInd;
8354 tSirSmeDisassocInd *pDisassocInd;
8355 tSirSmeDeauthInd *pDeauthInd;
8356 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
8357 tSirSmeNewBssInfo *pNewBss;
8358 tSmeIbssPeerInd *pIbssPeerInd;
8359 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
8360 tSirSmeApNewCaps *pApNewCaps;
8361 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
8362 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
8363 tCsrRoamInfo *pRoamInfo = NULL;
8364 tCsrRoamInfo roamInfo;
8365 eHalStatus status;
8366 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
8367 tCsrRoamSession *pSession = NULL;
8368 tpSirSmeSwitchChannelInd pSwitchChnInd;
8369 tSmeMaxAssocInd *pSmeMaxAssocInd;
Madan Mohan Koyyalamudi15407ac2013-01-11 15:30:36 -08008370 tSmeCmd pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008371#if defined ANI_PRODUCT_TYPE_AP
8372 pSirMsg->messageType = pal_be16_to_cpu(pSirMsg->messageType);
8373 pSirMsg->length = pal_be16_to_cpu(pSirMsg->length);
8374 pSirMsg->statusCode = pal_be32_to_cpu(pSirMsg->statusCode);
8375#else
8376 pSirMsg->messageType = (pSirMsg->messageType);
8377 pSirMsg->length = (pSirMsg->length);
8378 pSirMsg->statusCode = (pSirMsg->statusCode);
8379#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008380 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07008381 switch( pSirMsg->messageType )
8382 {
8383 case eWNI_SME_ASSOC_IND:
8384 {
8385 tCsrRoamSession *pSession;
8386 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME\n"));
8387 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
8388 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
8389 if( HAL_STATUS_SUCCESS( status ) )
8390 {
8391 pSession = CSR_GET_SESSION(pMac, sessionId);
8392
Jeff Johnson32d95a32012-09-10 13:15:23 -07008393 if(!pSession)
8394 {
8395 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8396 return;
8397 }
8398
Jeff Johnson295189b2012-06-20 16:38:30 -07008399 pRoamInfo = &roamInfo;
8400
8401 // Required for indicating the frames to upper layer
8402 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
8403 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
8404
8405 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
8406 pRoamInfo->beaconLength = pAssocInd->beaconLength;
8407 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8408 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8409
8410 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
8411 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
8412 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
8413
8414 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
8415 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008416 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
8417 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pAssocInd->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008418 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
8419 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07008420 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07008421 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
8422 {
8423 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
8424 {
8425 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
8426 pSession->pConnectBssDesc,
8427 &(pRoamInfo->peerMac),
8428 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
8429 pRoamInfo->fAuthRequired = FALSE;
8430 }
8431 else
8432 {
8433 pRoamInfo->fAuthRequired = TRUE;
8434 }
8435 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
8436 if (!HAL_STATUS_SUCCESS(status))
8437 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
8438 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008439 /* Send Association completion message to PE */
8440 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
8441
8442 /* send a message to CSR itself just to avoid the EAPOL frames going
8443 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07008444 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8445 {
8446 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
8447 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008448 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
8449 {
8450 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
8451 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8452 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
8453 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008454 }
8455 }
8456 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008457 case eWNI_SME_DISASSOC_IND:
8458 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008459 // Check if AP dis-associated us because of MIC failure. If so,
8460 // then we need to take action immediately and not wait till the
8461 // the WmStatusChange requests is pushed and processed
8462 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
8463 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDisassocInd->bssId, &sessionId );
8464 if( HAL_STATUS_SUCCESS( status ) )
8465 {
8466 // If we are in neighbor preauth done state then on receiving
8467 // disassoc or deauth we dont roam instead we just disassoc
8468 // from current ap and then go to disconnected state
8469 // This happens for CCX and 11r FT connections ONLY.
8470#ifdef WLAN_FEATURE_VOWIFI_11R
8471 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8472 {
8473 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8474 }
8475#endif
8476#ifdef FEATURE_WLAN_CCX
8477 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8478 {
8479 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8480 }
8481#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008482#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308483 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008484 {
8485 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8486 }
8487#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008488 pSession = CSR_GET_SESSION( pMac, sessionId );
8489
Jeff Johnson32d95a32012-09-10 13:15:23 -07008490 if(!pSession)
8491 {
8492 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8493 return;
8494 }
8495
Jeff Johnson295189b2012-06-20 16:38:30 -07008496 if ( csrIsConnStateInfra( pMac, sessionId ) )
8497 {
8498 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8499 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008500#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8501 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
8502#endif
8503 csrRoamLinkDown(pMac, sessionId);
8504 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07008505 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
8506 {
8507
8508 pRoamInfo = &roamInfo;
8509
8510 pRoamInfo->statusCode = pDisassocInd->statusCode;
8511 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8512
8513 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
8514
8515 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDisassocInd->peerMacAddr, sizeof(tSirMacAddr));
8516 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pDisassocInd->bssId, sizeof(tCsrBssid));
8517
8518 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Madan Mohan Koyyalamudi15407ac2013-01-11 15:30:36 -08008519
8520 /*
8521 * STA/P2P client got disassociated so remove any pending deauth
8522 * commands in sme pending list
8523 */
8524 pCommand.command = eSmeCommandRoam;
8525 pCommand.sessionId = (tANI_U8)sessionId;
8526 pCommand.u.roamCmd.roamReason = eCsrForcedDeauthSta;
8527 vos_mem_copy(pCommand.u.roamCmd.peerMac, pDisassocInd->peerMacAddr, sizeof(tSirMacAddr));
8528 csrRoamRemoveDuplicateCommand(pMac, sessionId, &pCommand, eCsrForcedDeauthSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07008529 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008530 }
8531 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008532 case eWNI_SME_DEAUTH_IND:
8533 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC\n"));
8534 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
8535 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
8536 if( HAL_STATUS_SUCCESS( status ) )
8537 {
8538 // If we are in neighbor preauth done state then on receiving
8539 // disassoc or deauth we dont roam instead we just disassoc
8540 // from current ap and then go to disconnected state
8541 // This happens for CCX and 11r FT connections ONLY.
8542#ifdef WLAN_FEATURE_VOWIFI_11R
8543 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8544 {
8545 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8546 }
8547#endif
8548#ifdef FEATURE_WLAN_CCX
8549 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8550 {
8551 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8552 }
8553#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008554#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308555 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008556 {
8557 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8558 }
8559#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008560 pSession = CSR_GET_SESSION( pMac, sessionId );
8561
Jeff Johnson32d95a32012-09-10 13:15:23 -07008562 if(!pSession)
8563 {
8564 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8565 return;
8566 }
8567
Jeff Johnson295189b2012-06-20 16:38:30 -07008568 if ( csrIsConnStateInfra( pMac, sessionId ) )
8569 {
8570 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8571 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008572#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8573 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
8574#endif
8575 csrRoamLinkDown(pMac, sessionId);
8576 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07008577 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
8578 {
8579
8580 pRoamInfo = &roamInfo;
8581
8582 pRoamInfo->statusCode = pDeauthInd->statusCode;
8583 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8584
8585 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
8586
8587 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDeauthInd->peerMacAddr, sizeof(tSirMacAddr));
8588 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pDeauthInd->bssId, sizeof(tCsrBssid));
8589
8590 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
8591 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008592 }
8593 break;
8594
8595 case eWNI_SME_SWITCH_CHL_REQ: // in case of STA, the SWITCH_CHANNEL originates from its AP
8596 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME\n"));
8597 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
8598 //Update with the new channel id.
8599 //The channel id is hidden in the statusCode.
8600 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
8601 if( HAL_STATUS_SUCCESS( status ) )
8602 {
8603 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008604 if(!pSession)
8605 {
8606 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8607 return;
8608 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008609 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
8610 if(pSession->pConnectBssDesc)
8611 {
8612 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
8613 }
8614 }
8615 break;
8616
8617 case eWNI_SME_DEAUTH_RSP:
8618 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008619 {
8620 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
8621 sessionId = pDeauthRsp->sessionId;
8622 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
8623 {
8624 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008625 if(!pSession)
8626 {
8627 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8628 return;
8629 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008630 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
8631 {
8632 pRoamInfo = &roamInfo;
8633 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8634 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDeauthRsp->peerMacAddr, sizeof(tSirMacAddr));
8635 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
8636 pRoamInfo->statusCode = pDeauthRsp->statusCode;
8637 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
8638 }
8639 }
8640 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008641 break;
8642
8643 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07008644 /* session id is invalid here so cant use it to access the array curSubstate as index */
8645 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME \n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008646 {
8647 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
8648 sessionId = pDisassocRsp->sessionId;
8649 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
8650 {
8651 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008652 if(!pSession)
8653 {
8654 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8655 return;
8656 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008657 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
8658 {
8659 pRoamInfo = &roamInfo;
8660 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8661 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDisassocRsp->peerMacAddr, sizeof(tSirMacAddr));
8662 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
8663 pRoamInfo->statusCode = pDisassocRsp->statusCode;
8664 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
8665 }
8666 }
8667 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008668 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008669 case eWNI_SME_MIC_FAILURE_IND:
8670 {
8671 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
8672 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
8673 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Jeff Johnson295189b2012-06-20 16:38:30 -07008674#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8675 {
8676 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008677 if(!pSession)
8678 {
8679 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8680 return;
8681 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008682 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
8683 palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type));
8684 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
8685 secEvent.encryptionModeMulticast =
8686 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8687 secEvent.encryptionModeUnicast =
8688 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8689 secEvent.authMode =
8690 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8691 palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 );
8692 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
8693 }
8694#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008695 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
8696 if( HAL_STATUS_SUCCESS( status ) )
8697 {
8698 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
8699 roamInfo.u.pMICFailureInfo = &pMicInd->info;
8700 pRoamInfo = &roamInfo;
8701 if(pMicInd->info.multicast)
8702 {
8703 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
8704 }
8705 else
8706 {
8707 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
8708 }
8709 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
8710 }
8711 }
8712 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008713 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
8714 {
8715 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
8716 tCsrRoamInfo roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008717 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME\n"));
8718
8719 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
8720 if( HAL_STATUS_SUCCESS( status ) )
8721 {
8722 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
8723 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
8724 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
8725 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
8726 }
8727 }
8728 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008729
Jeff Johnson295189b2012-06-20 16:38:30 -07008730 case eWNI_SME_WM_STATUS_CHANGE_NTF:
8731 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
8732 switch( pStatusChangeMsg->statusChangeCode )
8733 {
8734 case eSIR_SME_IBSS_ACTIVE:
8735 sessionId = csrFindIbssSession( pMac );
8736 if( CSR_SESSION_ID_INVALID != sessionId )
8737 {
8738 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008739 if(!pSession)
8740 {
8741 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8742 return;
8743 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008744 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
8745 if(pSession->pConnectBssDesc)
8746 {
8747 palCopyMemory(pMac->hHdd, &roamInfo.bssid, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
8748 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
8749 pRoamInfo = &roamInfo;
8750 }
8751 else
8752 {
8753 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty\n");
8754 }
8755 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
8756 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
8757 }
8758 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008759 case eSIR_SME_IBSS_INACTIVE:
8760 sessionId = csrFindIbssSession( pMac );
8761 if( CSR_SESSION_ID_INVALID != sessionId )
8762 {
8763 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008764 if(!pSession)
8765 {
8766 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8767 return;
8768 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008769 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
8770 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
8771 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
8772 }
8773 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008774 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
8775 sessionId = csrFindIbssSession( pMac );
8776 if( CSR_SESSION_ID_INVALID != sessionId )
8777 {
8778 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008779 if(!pSession)
8780 {
8781 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8782 return;
8783 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008784 // update the connection state information
8785 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008786#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8787 {
8788 vos_log_ibss_pkt_type *pIbssLog;
8789 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07008790 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8791 if(pIbssLog)
8792 {
8793 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
8794 if(pNewBss)
8795 {
8796 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pNewBss->bssId, 6);
8797 if(pNewBss->ssId.length)
8798 {
8799 palCopyMemory(pMac->hHdd, pIbssLog->ssid, pNewBss->ssId.ssId, pNewBss->ssId.length);
8800 }
8801 pIbssLog->operatingChannel = pNewBss->channelNumber;
8802 }
8803 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
8804 {
8805 //***U8 is not enough for beacon interval
8806 pIbssLog->beaconInterval = (v_U8_t)bi;
8807 }
8808 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
8809 }
8810 }
8811#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008812 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
8813 csrRoamIssueSetContextReq( pMac, sessionId, pSession->connectedProfile.EncryptionType,
8814 pSession->pConnectBssDesc,
8815 &Broadcastaddr,
8816 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
8817 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
8818 roamStatus = eCSR_ROAM_IBSS_IND;
8819 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pNewBss->bssId, sizeof(tCsrBssid));
8820 pRoamInfo = &roamInfo;
8821 //This BSSID is th ereal BSSID, let's save it
8822 if(pSession->pConnectBssDesc)
8823 {
8824 palCopyMemory(pMac->hHdd, pSession->pConnectBssDesc->bssId, &pNewBss->bssId, sizeof(tCsrBssid));
8825 }
8826 // Stop the join IBSS timer in case of join, for
8827 // genuine merge do nothing
8828 if(pSession->ibss_join_pending)
8829 {
8830 pSession->ibss_join_pending = FALSE;
8831 csrRoamStopIbssJoinTimer(pMac, sessionId);
8832 result = eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS;
8833 }
8834 }
8835 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE\n");
8836 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008837 // detection by LIM that the capabilities of the associated AP have changed.
8838 case eSIR_SME_AP_CAPS_CHANGED:
8839 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
8840 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED\n");
8841 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
8842 if( HAL_STATUS_SUCCESS( status ) )
8843 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08008844 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
8845 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
8846 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
8847 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
8848 )
8849 {
8850 csrScanForCapabilityChange( pMac, pApNewCaps );
8851 result = eCSR_ROAM_RESULT_CAP_CHANGED;
8852 roamStatus = eCSR_ROAM_GEN_INFO;
8853 }
8854 else
8855 {
8856 smsLog(pMac, LOGW,
8857 "Skipping csrScanForCapabilityChange as "
8858 "CSR is in state %d and sub-state %d\n",
8859 pMac->roam.curState[sessionId],
8860 pMac->roam.curSubState[sessionId]);
8861 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008862 }
8863 break;
8864
8865 default:
8866 roamStatus = eCSR_ROAM_FAILED;
8867 result = eCSR_ROAM_RESULT_NONE;
8868 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008869 } // end switch on statusChangeCode
8870 if(eCSR_ROAM_RESULT_NONE != result)
8871 {
8872 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
8873 }
8874 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008875 case eWNI_SME_IBSS_NEW_PEER_IND:
8876 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07008877#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8878 {
8879 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07008880 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8881 if(pIbssLog)
8882 {
8883 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
8884 palCopyMemory(pMac->hHdd, pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
8885 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
8886 }
8887 }
8888#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008889 sessionId = csrFindIbssSession( pMac );
8890 if( CSR_SESSION_ID_INVALID != sessionId )
8891 {
8892 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008893
8894 if(!pSession)
8895 {
8896 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8897 return;
8898 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008899 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
8900 if(pSession->pConnectBssDesc)
8901 {
8902 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
8903 palCopyMemory(pMac->hHdd, &roamInfo.bssid, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
8904 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
8905 {
8906 status = palAllocateMemory(pMac->hHdd, (void **)&roamInfo.pbFrames,
8907 (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd)));
8908 if(HAL_STATUS_SUCCESS(status))
8909 {
8910 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
8911 palCopyMemory(pMac->hHdd, roamInfo.pbFrames, ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
8912 roamInfo.nBeaconLength);
8913 }
8914 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
8915 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8916 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
8917 status = palAllocateMemory(pMac->hHdd, (void **)&roamInfo.pBssDesc,
8918 pSession->pConnectBssDesc->length);
8919 if(HAL_STATUS_SUCCESS(status))
8920 {
8921 palCopyMemory(pMac->hHdd, roamInfo.pBssDesc, pSession->pConnectBssDesc,
8922 pSession->pConnectBssDesc->length);
8923 }
8924 if(HAL_STATUS_SUCCESS(status))
8925 {
8926 pRoamInfo = &roamInfo;
8927 }
8928 else
8929 {
8930 if(roamInfo.pbFrames)
8931 {
8932 palFreeMemory(pMac->hHdd, roamInfo.pbFrames);
8933 }
8934 if(roamInfo.pBssDesc)
8935 {
8936 palFreeMemory(pMac->hHdd, roamInfo.pBssDesc);
8937 }
8938 }
8939 }
8940 else
8941 {
8942 pRoamInfo = &roamInfo;
8943 }
8944 csrRoamIssueSetContextReq( pMac, sessionId, pSession->connectedProfile.EncryptionType,
8945 pSession->pConnectBssDesc,
8946 &(pIbssPeerInd->peerAddr),
8947 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
8948 }
8949 else
8950 {
8951 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty\n");
8952 }
8953 //send up the sec type for the new peer
8954 if (pRoamInfo)
8955 {
8956 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8957 }
8958 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
8959 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
8960 if(pRoamInfo)
8961 {
8962 if(roamInfo.pbFrames)
8963 {
8964 palFreeMemory(pMac->hHdd, roamInfo.pbFrames);
8965 }
8966 if(roamInfo.pBssDesc)
8967 {
8968 palFreeMemory(pMac->hHdd, roamInfo.pBssDesc);
8969 }
8970 }
8971 }
8972 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008973 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
8974 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
8975 sessionId = csrFindIbssSession( pMac );
8976 if( CSR_SESSION_ID_INVALID != sessionId )
8977 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008978#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8979 {
8980 vos_log_ibss_pkt_type *pIbssLog;
8981
8982 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8983 if(pIbssLog)
8984 {
8985 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
8986 if(pIbssPeerInd)
8987 {
8988 palCopyMemory(pMac->hHdd, pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
8989 }
8990 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
8991 }
8992 }
8993#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008994 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM\n");
8995 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
8996 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8997 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
8998 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
8999 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9000 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
9001 }
9002 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009003 case eWNI_SME_SETCONTEXT_RSP:
9004 {
9005 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
9006 tListElem *pEntry;
9007 tSmeCmd *pCommand;
9008
9009 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9010 if ( pEntry )
9011 {
9012 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9013 if ( eSmeCommandSetKey == pCommand->command )
9014 {
9015 sessionId = pCommand->sessionId;
9016 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009017
9018 if(!pSession)
9019 {
9020 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9021 return;
9022 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009023
9024#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9025 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
9026 {
9027 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
9028 palZeroMemory(pMac->hHdd, &setKeyEvent, sizeof(vos_event_wlan_security_payload_type));
9029 if( pRsp->peerMacAddr[0] & 0x01 )
9030 {
9031 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
9032 }
9033 else
9034 {
9035 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
9036 }
9037 setKeyEvent.encryptionModeMulticast =
9038 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9039 setKeyEvent.encryptionModeUnicast =
9040 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9041 palCopyMemory( pMac->hHdd, setKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
9042 setKeyEvent.authMode =
9043 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9044 if( eSIR_SUCCESS != pRsp->statusCode )
9045 {
9046 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9047 }
9048 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9049 }
9050#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
9051 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
9052 {
Madan Mohan Koyyalamudic11c6b12012-12-27 17:34:52 -08009053 csrRoamStopWaitForKeyTimer( pMac );
9054
Jeff Johnson295189b2012-06-20 16:38:30 -07009055 //We are done with authentication, whethere succeed or not
9056 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009057 //We do it here because this linkup function is not called after association
9058 //when a key needs to be set.
9059 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
9060 {
9061 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9062 }
9063 }
Jeff Johnson43971f52012-07-17 12:26:56 -07009064 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009065 {
9066 palCopyMemory( pMac, &roamInfo.peerMac, &pRsp->peerMacAddr, sizeof(tCsrBssid) );
Jeff Johnsone7245742012-09-05 17:12:55 -07009067 //Make sure we install the GTK before indicating to HDD as authenticated
9068 //This is to prevent broadcast packets go out after PTK and before GTK.
9069 if( palEqualMemory( pMac->hHdd, &Broadcastaddr, pRsp->peerMacAddr,
9070 sizeof(tSirMacAddr) ) )
9071 {
Yathishd8713192012-12-10 14:21:35 -08009072#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
9073 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
9074 {
9075 tpSirSetActiveModeSetBncFilterReq pMsg;
9076 palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tSirSetActiveModeSetBncFilterReq));
9077 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
9078 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
9079 pMsg->seesionId = sessionId;
9080 status = palSendMBMessage(pMac->hHdd, pMsg );
9081 }
9082#endif
9083 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -07009084 }
9085 else
9086 {
9087 result = eCSR_ROAM_RESULT_NONE;
9088 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009089 pRoamInfo = &roamInfo;
9090 }
9091 else
9092 {
9093 result = eCSR_ROAM_RESULT_FAILURE;
9094 smsLog( pMac, LOGE, "CSR: Roam Completion setkey command failed(%d) PeerMac %02X-%02X-%02X-%02X-%02X-%02X...\n",
9095 pRsp->statusCode, pRsp->peerMacAddr[0], pRsp->peerMacAddr[1], pRsp->peerMacAddr[2],
9096 pRsp->peerMacAddr[3], pRsp->peerMacAddr[4], pRsp->peerMacAddr[5] );
9097 }
9098 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9099 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -07009100 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
9101 // can go ahead and initiate the TSPEC if any are pending
9102 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009103#ifdef FEATURE_WLAN_CCX
9104 //Send Adjacent AP repot to new AP.
9105 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
9106 pSession->isPrevApInfoValid &&
9107 pSession->connectedProfile.isCCXAssoc)
9108 {
9109#ifdef WLAN_FEATURE_VOWIFI
9110 csrCcxSendAdjacentApRepMsg(pMac, pSession);
9111#endif
9112 pSession->isPrevApInfoValid = FALSE;
9113 }
9114#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009115 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9116 {
9117 csrReleaseCommandSetKey( pMac, pCommand );
9118 }
9119 }
9120 else
9121 {
9122 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ...\n" );
9123 }
9124 }
9125 else
9126 {
9127 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ...\n" );
9128 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009129 smeProcessPendingQueue( pMac );
9130 }
9131 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009132 case eWNI_SME_REMOVEKEY_RSP:
9133 {
9134 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
9135 tListElem *pEntry;
9136 tSmeCmd *pCommand;
9137
9138 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9139 if ( pEntry )
9140 {
9141 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9142 if ( eSmeCommandRemoveKey == pCommand->command )
9143 {
9144 sessionId = pCommand->sessionId;
9145 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009146
9147 if(!pSession)
9148 {
9149 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9150 return;
9151 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009152#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9153 {
9154 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
9155 palZeroMemory(pMac->hHdd, &removeKeyEvent, sizeof(vos_event_wlan_security_payload_type));
9156 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
9157 removeKeyEvent.encryptionModeMulticast =
9158 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9159 removeKeyEvent.encryptionModeUnicast =
9160 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9161 palCopyMemory( pMac->hHdd, removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
9162 removeKeyEvent.authMode =
9163 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9164 if( eSIR_SUCCESS != pRsp->statusCode )
9165 {
9166 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9167 }
9168 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9169 }
9170#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -07009171 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009172 {
9173 palCopyMemory( pMac, &roamInfo.peerMac, &pRsp->peerMacAddr, sizeof(tCsrBssid) );
9174 result = eCSR_ROAM_RESULT_NONE;
9175 pRoamInfo = &roamInfo;
9176 }
9177 else
9178 {
9179 result = eCSR_ROAM_RESULT_FAILURE;
9180 }
9181 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9182 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
9183 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9184 {
9185 csrReleaseCommandRemoveKey( pMac, pCommand );
9186 }
9187 }
9188 else
9189 {
9190 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ...\n" );
9191 }
9192 }
9193 else
9194 {
9195 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ...\n" );
9196 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009197 smeProcessPendingQueue( pMac );
9198 }
9199 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009200 case eWNI_SME_GET_STATISTICS_RSP:
Mohit Khanna23863762012-09-11 17:40:09 -07009201 smsLog( pMac, LOG2, FL("Stats rsp from PE\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009202 csrRoamStatsRspProcessor( pMac, pSirMsg );
9203 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009204 case eWNI_SME_GET_RSSI_REQ:
Mohit Khanna23863762012-09-11 17:40:09 -07009205 smsLog( pMac, LOG2, FL("GetRssiReq from self\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009206 csrUpdateRssi( pMac, pSirMsg );
9207 break;
9208
Jeff Johnson295189b2012-06-20 16:38:30 -07009209#ifdef WLAN_FEATURE_VOWIFI_11R
9210 case eWNI_SME_FT_PRE_AUTH_RSP:
9211 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
9212 break;
9213#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009214 case eWNI_SME_MAX_ASSOC_EXCEEDED:
9215 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
9216 smsLog( pMac, LOG1, FL("send indication that max assoc have been reached and the new peer cannot be accepted\n"));
9217 sessionId = pSmeMaxAssocInd->sessionId;
9218 roamInfo.sessionId = sessionId;
9219 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pSmeMaxAssocInd->peerMac, sizeof(tCsrBssid));
9220 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9221 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
9222 break;
9223
9224 case eWNI_SME_BTAMP_LOG_LINK_IND:
9225 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread\n"));
9226 btampEstablishLogLinkHdlr( pSirMsg );
9227 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07009228 case eWNI_SME_RSSI_IND:
9229 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread\n"));
9230 csrRoamRssiIndHdlr( pMac, pSirMsg );
9231 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009232
9233 default:
9234 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009235 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -07009236}
9237
Jeff Johnson295189b2012-06-20 16:38:30 -07009238void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
9239 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
9240{
9241 if(pSession)
9242 {
9243 if(pSession->bRefAssocStartCnt)
9244 {
9245 pSession->bRefAssocStartCnt--;
9246 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
9247 //Need to call association_completion because there is an assoc_start pending.
9248 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
9249 eCSR_ROAM_ASSOCIATION_COMPLETION,
9250 eCSR_ROAM_RESULT_FAILURE);
9251 }
9252 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
9253 }
9254 else
9255 {
9256 smsLog(pMac, LOGW, FL(" pSession is NULL"));
9257 }
9258}
9259
9260
9261eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
9262{
9263 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009264 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
9265 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
9266 {
9267 status = csrScanRequestLostLink1( pMac, sessionId );
9268 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009269 return(status);
9270}
9271
Jeff Johnson295189b2012-06-20 16:38:30 -07009272//return a boolean to indicate whether roaming completed or continue.
9273tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
9274 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
9275{
9276 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
9277 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
9278 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
9279 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009280 if(!pSession)
9281 {
9282 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9283 return eANI_BOOLEAN_FALSE;
9284 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009285 //Check whether time is up
9286 if(pSession->fCancelRoaming || fForce ||
9287 ((curTime - pSession->roamingStartTime) > roamTime) ||
9288 eCsrReassocRoaming == pSession->roamingReason ||
9289 eCsrDynamicRoaming == pSession->roamingReason)
9290 {
9291 smsLog(pMac, LOGW, FL(" indicates roaming completion\n"));
9292 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
9293 {
9294 //roaming is cancelled, tell HDD to indicate disconnect
9295 //Because LIM overload deauth_ind for both deauth frame and missed beacon
9296 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
9297 //to be eSIR_BEACON_MISSED
9298 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
9299 {
9300 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
9301 }
9302 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
9303 {
9304 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
9305 }
9306 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
9307 {
9308 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
9309 }
9310 else
9311 {
9312 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
9313 }
9314 }
9315 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
9316 pSession->roamingReason = eCsrNotRoaming;
9317 }
9318 else
9319 {
9320 pSession->roamResult = roamResult;
9321 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
9322 {
9323 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
9324 pSession->roamingReason = eCsrNotRoaming;
9325 }
9326 else
9327 {
9328 fCompleted = eANI_BOOLEAN_FALSE;
9329 }
9330 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009331 return(fCompleted);
9332}
9333
Jeff Johnson295189b2012-06-20 16:38:30 -07009334void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
9335{
9336 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009337
9338 if(!pSession)
9339 {
9340 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9341 return;
9342 }
9343
Jeff Johnson295189b2012-06-20 16:38:30 -07009344 if(CSR_IS_ROAMING(pSession))
9345 {
9346 smsLog(pMac, LOGW, " Cancelling roaming\n");
9347 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
9348 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
9349 {
9350 //No need to do anything in here because the handler takes care of it
9351 }
9352 else
9353 {
9354 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
9355 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
9356 //Roaming is stopped after here
9357 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
9358 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
9359 csrScanAbortMacScan(pMac);
9360 csrRoamStopRoamingTimer(pMac, sessionId);
9361 }
9362 }
9363}
9364
Jeff Johnson295189b2012-06-20 16:38:30 -07009365void csrRoamRoamingTimerHandler(void *pv)
9366{
9367 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9368 tpAniSirGlobal pMac = pInfo->pMac;
9369 tANI_U32 sessionId = pInfo->sessionId;
9370 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009371
9372 if(!pSession)
9373 {
9374 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9375 return;
9376 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009377
9378 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
9379 {
9380 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
9381 {
9382 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
9383 pSession->roamingReason = eCsrNotRoaming;
9384 }
9385 }
9386}
9387
Jeff Johnson295189b2012-06-20 16:38:30 -07009388eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
9389{
9390 eHalStatus status;
9391 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009392
9393 if(!pSession)
9394 {
9395 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9396 return eHAL_STATUS_FAILURE;
9397 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009398
9399 smsLog(pMac, LOG1, " csrScanStartRoamingTimer \n ");
9400 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
9401 status = palTimerStart(pMac->hHdd, pSession->hTimerRoaming, interval, eANI_BOOLEAN_FALSE);
9402
9403 return (status);
9404}
9405
Jeff Johnson295189b2012-06-20 16:38:30 -07009406eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
9407{
9408 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerRoaming));
9409}
9410
Jeff Johnson295189b2012-06-20 16:38:30 -07009411void csrRoamWaitForKeyTimeOutHandler(void *pv)
9412{
9413 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9414 tpAniSirGlobal pMac = pInfo->pMac;
Madan Mohan Koyyalamudic11c6b12012-12-27 17:34:52 -08009415 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
9416
9417 smsLog(pMac, LOGW, "WaitForKey timer expired in state=%d sub-state=%d\n",
9418 pMac->roam.neighborRoamInfo.neighborRoamState,
9419 pMac->roam.curSubState[pInfo->sessionId]);
9420
Jeff Johnson295189b2012-06-20 16:38:30 -07009421 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
9422 {
Madan Mohan Koyyalamudic11c6b12012-12-27 17:34:52 -08009423#ifdef FEATURE_WLAN_LFR
9424 if (csrNeighborRoamIsHandoffInProgress(pMac))
9425 {
9426 /*
9427 * Enable heartbeat timer when hand-off is in progress
9428 * and Key Wait timer expired.
9429 */
9430 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
9431 " (nHBCount=%d)\n",
9432 pMac->roam.configParam.HeartbeatThresh24);
9433 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
9434 pMac->roam.configParam.HeartbeatThresh24,
9435 NULL, eANI_BOOLEAN_FALSE);
9436 }
9437#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009438 smsLog(pMac, LOGW, " SME pre-auth state timeout. \n ");
9439 //Change the substate so command queue is unblocked.
9440 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, pInfo->sessionId);
Madan Mohan Koyyalamudic11c6b12012-12-27 17:34:52 -08009441 if (pSession)
9442 {
9443 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
9444 {
9445 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9446 smeProcessPendingQueue(pMac);
9447 }
9448 else
9449 {
9450 smsLog(pMac, LOGW, "%s: could not post link up\n",
9451 __func__);
9452 }
9453 }
9454 else
9455 {
9456 smsLog(pMac, LOGW, "%s: session not found\n", __func__);
9457 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009458 }
9459
9460}
9461
Jeff Johnson295189b2012-06-20 16:38:30 -07009462eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
9463{
9464 eHalStatus status;
Madan Mohan Koyyalamudic11c6b12012-12-27 17:34:52 -08009465#ifdef FEATURE_WLAN_LFR
9466 if (csrNeighborRoamIsHandoffInProgress(pMac))
9467 {
9468 /* Disable heartbeat timer when hand-off is in progress */
9469 smsLog(pMac, LOG2, "%s: disabling HB timer in state=%d sub-state=%d\n",
9470 __func__,
9471 pMac->roam.neighborRoamInfo.neighborRoamState,
9472 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
9473 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
9474 }
9475#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009476 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer \n ");
9477 status = palTimerStart(pMac->hHdd, pMac->roam.hTimerWaitForKey, interval, eANI_BOOLEAN_FALSE);
9478
9479 return (status);
9480}
9481
Jeff Johnson295189b2012-06-20 16:38:30 -07009482eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
9483{
Madan Mohan Koyyalamudic11c6b12012-12-27 17:34:52 -08009484 smsLog(pMac, LOG2, "WaitForKey timer stopped in state=%d sub-state=%d\n",
9485 pMac->roam.neighborRoamInfo.neighborRoamState,
9486 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
9487#ifdef FEATURE_WLAN_LFR
9488 if (csrNeighborRoamIsHandoffInProgress(pMac))
9489 {
9490 /*
9491 * Enable heartbeat timer when hand-off is in progress
9492 * and Key Wait timer got stopped for some reason
9493 */
9494 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
9495 " (nHBCount=%d)\n",
9496 pMac->roam.configParam.HeartbeatThresh24);
9497 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
9498 pMac->roam.configParam.HeartbeatThresh24,
9499 NULL, eANI_BOOLEAN_FALSE);
9500 }
9501#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009502 return (palTimerStop(pMac->hHdd, pMac->roam.hTimerWaitForKey));
9503}
9504
Jeff Johnson295189b2012-06-20 16:38:30 -07009505void csrRoamIbssJoinTimerHandler(void *pv)
9506{
9507 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9508 tpAniSirGlobal pMac = pInfo->pMac;
9509 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE;
9510 tANI_U32 sessionId = pInfo->sessionId;
9511 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009512
9513 if(!pSession)
9514 {
9515 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9516 return;
9517 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009518
9519 pSession->ibss_join_pending = FALSE;
9520 // JEZ100225: As of main/latest "tip", we are no longer doing this. Check on this.
9521 //csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
9522 // Send an IBSS stop request to PE
9523 csrRoamDisconnectInternal(pMac, sessionId, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07009524}
Jeff Johnson295189b2012-06-20 16:38:30 -07009525eHalStatus csrRoamStartIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
9526{
9527 eHalStatus status;
9528 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009529
9530 if(!pSession)
9531 {
9532 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9533 return eHAL_STATUS_FAILURE;
9534 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009535
9536 smsLog(pMac, LOG1, " csrRoamStartIbssJoinTimer \n ");
9537 pSession->ibssJoinTimerInfo.sessionId = (tANI_U8)sessionId;
9538 status = palTimerStart(pMac->hHdd, pSession->hTimerIbssJoining, interval, eANI_BOOLEAN_FALSE);
9539
9540 return (status);
9541}
Jeff Johnson295189b2012-06-20 16:38:30 -07009542eHalStatus csrRoamStopIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
9543{
9544 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerIbssJoining));
9545}
Jeff Johnson295189b2012-06-20 16:38:30 -07009546void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
9547 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
9548{
9549 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
9550 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009551 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9552 /* To silence the KW tool Null chaeck is added */
9553 if(!pSession)
9554 {
9555 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9556 return;
9557 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009558
9559 if(pCommand)
9560 {
9561 roamId = pCommand->u.roamCmd.roamId;
9562#if defined(VOSS_ENABLED)
9563 VOS_ASSERT( sessionId == pCommand->sessionId );
9564#endif
9565 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009566 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
9567 {
9568 //if success, force roaming completion
9569 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
9570 }
9571 else
9572 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009573 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009574 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d\n"), roamResult);
9575 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
9576 }
9577}
9578
Jeff Johnson295189b2012-06-20 16:38:30 -07009579eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
9580{
9581 eHalStatus status = eHAL_STATUS_SUCCESS;
9582 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
9583 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
9584 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
9585 tCsrRoamInfo *pRoamInfo = NULL;
9586 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009587 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -07009588 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009589 /* To silence the KW tool Null chaeck is added */
9590 if(!pSession)
9591 {
9592 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9593 return eHAL_STATUS_FAILURE;
9594 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009595 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009596 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07009597 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
9598 if ( eWNI_SME_DISASSOC_IND == type )
9599 {
9600 result = eCSR_ROAM_RESULT_DISASSOC_IND;
9601 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
9602 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -07009603 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07009604 }
9605 else if ( eWNI_SME_DEAUTH_IND == type )
9606 {
9607 result = eCSR_ROAM_RESULT_DEAUTH_IND;
9608 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
9609 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -08009610 /* Convert into proper reason code */
9611 pSession->joinFailStatusCode.reasonCode =
9612 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
9613 eSIR_MAC_DISASSOC_LEAVING_BSS_REASON : pDeauthIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07009614 }
9615 else
9616 {
9617 smsLog(pMac, LOGW, FL("gets an unknown type (%d)\n"), type);
9618 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -07009619 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07009620 }
9621
9622 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -07009623 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07009624 {
9625 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
9626 }
9627
9628 if ( eWNI_SME_DISASSOC_IND == type )
9629 {
9630 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
9631 }
9632 else if ( eWNI_SME_DEAUTH_IND == type )
9633 {
9634 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
9635 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009636 if(!HAL_STATUS_SUCCESS(status))
9637 {
Jeff Johnson56dc6b02013-02-17 10:32:30 -08009638 //If fail to send confirmation to PE, not to trigger roaming
9639 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009640 }
9641
Jeff Johnson56dc6b02013-02-17 10:32:30 -08009642 //prepare to tell HDD to disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -07009643 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9644 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
9645 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07009646 if( eWNI_SME_DISASSOC_IND == type)
9647 {
Jeff Johnson56dc6b02013-02-17 10:32:30 -08009648 //staMacAddr
9649 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDisassocIndMsg->peerMacAddr, sizeof(tSirMacAddr));
9650 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
9651 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009652 else if( eWNI_SME_DEAUTH_IND == type )
9653 {
Jeff Johnson56dc6b02013-02-17 10:32:30 -08009654 //staMacAddr
9655 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDeauthIndMsg->peerMacAddr, sizeof(tSirMacAddr));
9656 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
9657 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009658 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)\n"), roamInfo.staId);
Jeff Johnson56dc6b02013-02-17 10:32:30 -08009659
9660 /* See if we can possibly roam. If so, start the roaming process and notify HDD
9661 that we are roaming. But if we cannot possibly roam, or if we are unable to
9662 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -07009663 if(fToRoam)
9664 {
9665 //Only remove the connected BSS in infrastructure mode
9666 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
9667 //Not to do anying for lostlink with WDS
9668 if( pMac->roam.configParam.nRoamingTime )
9669 {
9670 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
9671 ( eWNI_SME_DEAUTH_IND == type ) ?
9672 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
9673 {
9674 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9675 //For IBSS, we need to give some more info to HDD
9676 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
9677 {
9678 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9679 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
9680 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
9681 }
9682 else
9683 {
9684 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
9685 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009686 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009687 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
9688 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
9689 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
9690 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
9691 }
9692 else
9693 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009694 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07009695 fToRoam = eANI_BOOLEAN_FALSE;
9696 }
9697 }
9698 else
9699 {
9700 //We are told not to roam, indicate lostlink
9701 fToRoam = eANI_BOOLEAN_FALSE;
9702 }
9703 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009704 if(!fToRoam)
9705 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -07009706 //Tell HDD about the lost link
Jeff Johnson56dc6b02013-02-17 10:32:30 -08009707 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudi15407ac2013-01-11 15:30:36 -08009708 {
Jeff Johnson56dc6b02013-02-17 10:32:30 -08009709 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
9710 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
9711 * csrRoamCheckForLinkStatusChange API.
9712 */
Madan Mohan Koyyalamudi15407ac2013-01-11 15:30:36 -08009713 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
9714 }
9715
9716 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -07009717 Still enable idle scan for polling in case concurrent sessions are running */
9718 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
9719 {
Jeff Johnson56dc6b02013-02-17 10:32:30 -08009720 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07009721 }
9722 }
9723
9724 return (status);
9725}
9726
Jeff Johnson295189b2012-06-20 16:38:30 -07009727eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
9728{
9729 eHalStatus status = eHAL_STATUS_SUCCESS;
9730 tListElem *pEntry = NULL;
9731 tSmeCmd *pCommand = NULL;
9732 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009733
9734 if(!pSession)
9735 {
9736 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9737 return eHAL_STATUS_FAILURE;
9738 }
9739
Jeff Johnson295189b2012-06-20 16:38:30 -07009740 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009741 //Only remove the connected BSS in infrastructure mode
9742 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
9743 if(pMac->roam.configParam.nRoamingTime)
9744 {
9745 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
9746 {
9747 //before starting the lost link logic release the roam command for handoff
9748 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
9749 if(pEntry)
9750 {
9751 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
9752 }
9753 if(pCommand)
9754 {
9755 if (( eSmeCommandRoam == pCommand->command ) &&
9756 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
9757 {
9758 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9759 {
9760 csrReleaseCommandRoam( pMac, pCommand );
9761 }
9762 }
9763 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009764 smsLog( pMac, LOGW, "Lost link roaming started ...\n");
9765 }
9766 }
9767 else
9768 {
9769 //We are told not to roam, indicate lostlink
9770 status = eHAL_STATUS_FAILURE;
9771 }
9772
9773 return (status);
9774}
Jeff Johnson295189b2012-06-20 16:38:30 -07009775void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
9776{
9777 tListElem *pEntry;
9778 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07009779 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9780 if ( pEntry )
9781 {
9782 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9783 if ( eSmeCommandWmStatusChange == pCommand->command )
9784 {
9785 // Nothing to process in a Lost Link completion.... It just kicks off a
9786 // roaming sequence.
9787 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9788 {
9789 csrReleaseCommandWmStatusChange( pMac, pCommand );
9790 }
9791 else
9792 {
9793 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command\n");
9794 }
9795
9796 }
9797 else
9798 {
9799 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ...\n" );
9800 }
9801 }
9802 else
9803 {
9804 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ...\n" );
9805 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009806 smeProcessPendingQueue( pMac );
9807}
9808
Jeff Johnson295189b2012-06-20 16:38:30 -07009809void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
9810{
9811 eHalStatus status = eHAL_STATUS_FAILURE;
9812 tSirSmeRsp *pSirSmeMsg;
9813 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009814
9815 if(!pSession)
9816 {
9817 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
9818 return;
9819 }
9820
Jeff Johnson295189b2012-06-20 16:38:30 -07009821 switch ( pCommand->u.wmStatusChangeCmd.Type )
9822 {
9823 case eCsrDisassociated:
9824 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
9825 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
9826 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009827 case eCsrDeauthenticated:
9828 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
9829 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
9830 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009831 default:
9832 smsLog(pMac, LOGW, FL("gets an unknown command %d\n"), pCommand->u.wmStatusChangeCmd.Type);
9833 break;
9834 }
9835 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
9836 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
9837 {
9838 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
9839 {
9840 //This is not good
9841 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command\n"));
9842 }
9843 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009844 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
9845 // command here since there is nothing else to do.
9846 csrRoamWmStatusChangeComplete( pMac );
9847}
9848
Jeff Johnson295189b2012-06-20 16:38:30 -07009849//This function returns band and mode information.
9850//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
9851//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -07009852static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
9853 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -07009854{
Jeff Johnson295189b2012-06-20 16:38:30 -07009855 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
9856 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
9857 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07009858 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07009859
Jeff Johnson295189b2012-06-20 16:38:30 -07009860 //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 -07009861 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
9862 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
9863 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
9864 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009865 {
9866 switch( pMac->roam.configParam.uCfgDot11Mode )
9867 {
9868 case eCSR_CFG_DOT11_MODE_11A:
9869 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
9870 eBand = eCSR_BAND_5G;
9871 break;
9872 case eCSR_CFG_DOT11_MODE_11B:
9873 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
9874 eBand = eCSR_BAND_24;
9875 break;
9876 case eCSR_CFG_DOT11_MODE_11G:
9877 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
9878 eBand = eCSR_BAND_24;
9879 break;
9880 case eCSR_CFG_DOT11_MODE_11N:
9881 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
9882 eBand = eCSR_BAND_24;
9883 break;
9884 //case eCSR_CFG_DOT11_MODE_BEST:
9885 // cfgDot11Mode = eCSR_CFG_DOT11_MODE_BEST;
9886 // eBand = eCSR_BAND_24;
9887 // break;
9888 default:
9889 // Global dot11 Mode setting is 11a/b/g.
9890 // use the channel number to determine the Mode setting.
9891 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
9892 {
9893 eBand = pMac->roam.configParam.eBand;
9894 if(eCSR_BAND_24 == eBand)
9895 {
9896 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
9897 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
9898 }
9899 else
9900 {
9901 //prefer 5GHz
9902 eBand = eCSR_BAND_5G;
9903 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
9904 }
9905 }
9906 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
9907 {
9908 // channel is a 2.4GHz channel. Set mode to 11g.
9909 //
9910 // !!LAC - WiFi tests require IBSS networks to start in 11b mode without any change to the
9911 // default parameter settings on the adapter. We use ACU to start an IBSS through creation
9912 // of a startIBSS profile. this startIBSS profile has Auto MACProtocol and the
9913 // adapter property setting for dot11Mode is also AUTO. So in this case, let's start
9914 // the IBSS network in 11b mode instead of 11g mode.
9915 //
9916 // so this is for Auto=profile->MacProtocol && Auto=Global.dot11Mode && profile->channel is < 14,
9917 // then start the IBSS in b mode.
9918 //
9919 // Note: we used to have this start as an 11g IBSS for best performance... now to specify that
9920 // the user will have to set the do11Mode in the property page to 11g to force it.
9921 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
9922 eBand = eCSR_BAND_24;
9923 }
9924 else
9925 {
9926 // else, it's a 5.0GHz channel. Set mode to 11a.
9927 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
9928 eBand = eCSR_BAND_5G;
9929 }
9930 break;
9931 }//switch
9932 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
9933 else
9934 {
9935 //dot11 mode is set, lets pick the band
9936 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
9937 {
9938 // channel is Auto also.
9939 eBand = pMac->roam.configParam.eBand;
9940 if(eCSR_BAND_ALL == eBand)
9941 {
9942 //prefer 5GHz
9943 eBand = eCSR_BAND_5G;
9944 }
9945 }
9946 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
9947 {
9948 eBand = eCSR_BAND_24;
9949 }
9950 else
9951 {
9952 eBand = eCSR_BAND_5G;
9953 }
9954 }
9955 if(pBand)
9956 {
9957 *pBand = eBand;
9958 }
9959
9960 if (operationChn == 14){
9961 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode \n"));
9962 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
9963 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -07009964
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -08009965 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
9966 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 -07009967 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -07009968#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -07009969 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -07009970#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -07009971 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
9972 {
9973 //We cannot do 11n here
9974 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
9975 {
9976 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
9977 }
9978 else
9979 {
9980 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
9981 }
9982 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009983 return( cfgDot11Mode );
9984}
9985
Jeff Johnson295189b2012-06-20 16:38:30 -07009986eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
9987{
9988 eHalStatus status;
9989 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009990
9991 if(!pSession)
9992 {
9993 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9994 return eHAL_STATUS_FAILURE;
9995 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009996
9997#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9998 {
9999 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010000 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10001 if(pIbssLog)
10002 {
10003 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
10004 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10005 }
10006 }
10007#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010008 pSession->ibss_join_pending = FALSE;
10009 csrRoamStopIbssJoinTimer(pMac, sessionId );
10010 // Set the roaming substate to 'stop Bss request'...
10011 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
10012
10013 // attempt to stop the Bss (reason code is ignored...)
10014 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala79353d12012-12-31 16:31:46 -080010015 if(!HAL_STATUS_SUCCESS(status))
10016 {
10017 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
10018 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010019 return (status);
10020}
10021
Jeff Johnson295189b2012-06-20 16:38:30 -070010022//pNumChan is a caller allocated space with the sizeof pChannels
10023eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
10024{
10025
10026 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
10027 (tANI_U8 *)pChannels,
10028 pNumChan));
10029}
10030
Kirand170dcb2013-01-31 10:43:43 -080010031tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
10032{
10033 tANI_U32 cfgLength = 0;
10034 tANI_U16 cfgId = 0;
10035 tPowerdBm maxTxPwr = 0;
10036 tANI_U8 *pCountryInfo = NULL;
10037 eHalStatus status;
10038 tANI_U8 count = 0;
10039 tANI_U8 firstChannel;
10040 tANI_U8 maxChannels;
10041
10042 if (CSR_IS_CHANNEL_5GHZ(channel))
10043 {
10044 cfgId = WNI_CFG_MAX_TX_POWER_5;
10045 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
10046 }
10047 else if (CSR_IS_CHANNEL_24GHZ(channel))
10048 {
10049 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
10050 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
10051 }
10052 else
10053 return maxTxPwr;
10054
10055 status = palAllocateMemory(pMac->hHdd, (void **)&pCountryInfo, cfgLength);
10056 if (status != eHAL_STATUS_SUCCESS)
10057 {
10058 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10059 FL("%s: palAllocateMemory() failed, status = %d"),
10060 __FUNCTION__, status);
10061 goto error;
10062 }
10063 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
10064 if (status != eHAL_STATUS_SUCCESS)
10065 {
10066 goto error;
10067 }
10068 /* Identify the channel and maxtxpower */
10069 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
10070 {
10071 firstChannel = pCountryInfo[count++];
10072 maxChannels = pCountryInfo[count++];
10073 maxTxPwr = pCountryInfo[count++];
10074
10075 if ((channel >= firstChannel) &&
10076 (channel < (firstChannel + maxChannels)))
10077 {
10078 break;
10079 }
10080 }
10081
10082error:
10083 if (NULL != pCountryInfo)
10084 palFreeMemory(pMac->hHdd, pCountryInfo);
10085
10086 return maxTxPwr;
10087}
10088
10089
Jeff Johnson295189b2012-06-20 16:38:30 -070010090tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
10091{
10092 tANI_BOOLEAN fValid = FALSE;
10093 tANI_U32 idxValidChannels;
10094 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10095
10096 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
10097 {
10098 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
10099 {
10100 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
10101 {
10102 fValid = TRUE;
10103 break;
10104 }
10105 }
10106 }
10107 pMac->roam.numValidChannels = len;
10108 return fValid;
10109}
10110
Jeff Johnson295189b2012-06-20 16:38:30 -070010111tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
10112{
10113 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
10114 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010115 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
10116 {
10117 if(channel == pMac->scan.base40MHzChannels.channelList[i])
10118 {
10119 fValid = eANI_BOOLEAN_TRUE;
10120 break;
10121 }
10122 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010123 return (fValid);
10124}
10125
Jeff Johnson295189b2012-06-20 16:38:30 -070010126//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070010127 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070010128{
Jeff Johnsone7245742012-09-05 17:12:55 -070010129 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010130 tANI_U8 centerChn;
10131 tANI_U32 ChannelBondingMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010132 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
10133 {
10134 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
10135 }
10136 else
10137 {
10138 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
10139 }
10140 //Figure what the other side's CB mode
10141 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
10142 {
10143 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
10144 {
10145 if(pIes->HTInfo.present)
10146 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010147 /* This is called during INFRA STA/CLIENT and should use the merged value of
10148 * supported channel width and recommended tx width as per standard
10149 */
10150 smsLog(pMac, LOG1, "scws %u rtws %u sco %u\n",
10151 pIes->HTCaps.supportedChannelWidthSet,
10152 pIes->HTInfo.recommendedTxWidthSet,
10153 pIes->HTInfo.secondaryChannelOffset);
10154
10155 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
10156 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010157 else
Jeff Johnsone7245742012-09-05 17:12:55 -070010158 eRet = PHY_SINGLE_CHANNEL_CENTERED;
10159 switch (eRet) {
10160 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
10161 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
10162 break;
10163 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
10164 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
10165 break;
10166 case PHY_SINGLE_CHANNEL_CENTERED:
10167 default:
10168 centerChn = primaryChn;
10169 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010170 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010171 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070010172 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010173 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode\n", centerChn);
10174 //eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010175 }
10176 }
10177 }
10178 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010179 return eRet;
10180}
Jeff Johnson295189b2012-06-20 16:38:30 -070010181tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
10182{
10183 tANI_BOOLEAN fFound = FALSE;
10184 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010185 for( idx = 0; idx < pCipherList->numEntries; idx++ )
10186 {
10187 if( pCipherList->encryptionType[idx] == encryptionType )
10188 {
10189 fFound = TRUE;
10190 break;
10191 }
10192 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010193 return fFound;
10194}
Jeff Johnson295189b2012-06-20 16:38:30 -070010195tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
10196{
10197 tANI_BOOLEAN fFound = FALSE;
10198 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010199 for( idx = 0; idx < pAuthList->numEntries; idx++ )
10200 {
10201 if( pAuthList->authType[idx] == authType )
10202 {
10203 fFound = TRUE;
10204 break;
10205 }
10206 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010207 return fFound;
10208}
Jeff Johnson295189b2012-06-20 16:38:30 -070010209tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
10210{
10211 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
10212 tCsrScanResultFilter *pScanFilter = NULL;
10213 eHalStatus status = eHAL_STATUS_SUCCESS;
10214
10215 if(pProfile1 && pProfile2)
10216 {
10217 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
10218 if(HAL_STATUS_SUCCESS(status))
10219 {
10220 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
10221 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
10222 if(HAL_STATUS_SUCCESS(status))
10223 {
10224 fCheck = eANI_BOOLEAN_FALSE;
10225 do
10226 {
10227 tANI_U32 i;
10228 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
10229 {
10230 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
10231 pScanFilter->SSIDs.SSIDList[i].SSID.length,
10232 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
10233 if ( fCheck ) break;
10234 }
10235 if(!fCheck)
10236 {
10237 break;
10238 }
10239 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
10240 || pProfile2->BSSType != pProfile1->BSSType
10241 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
10242 )
10243 {
10244 fCheck = eANI_BOOLEAN_FALSE;
10245 break;
10246 }
10247#ifdef WLAN_FEATURE_VOWIFI_11R
10248 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
10249 {
10250 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
10251 {
10252 fCheck = eANI_BOOLEAN_FALSE;
10253 break;
10254 }
10255 }
10256#endif
10257 //Match found
10258 fCheck = eANI_BOOLEAN_TRUE;
10259 }while(0);
10260 csrFreeScanFilter(pMac, pScanFilter);
10261 }
10262 palFreeMemory(pMac->hHdd, pScanFilter);
10263 }
10264 }
10265
10266 return (fCheck);
10267}
10268
Jeff Johnson295189b2012-06-20 16:38:30 -070010269tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
10270{
10271 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
10272 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010273 do
10274 {
10275 //Only check for static WEP
10276 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
10277 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
10278 {
10279 fCheck = eANI_BOOLEAN_TRUE;
10280 break;
10281 }
10282 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
10283 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
10284 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
10285 {
10286 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
10287 if(!palEqualMemory(pMac->hHdd, &pConnProfile->Keys.KeyMaterial[i],
10288 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
10289 {
10290 break;
10291 }
10292 }
10293 if( i == CSR_MAX_NUM_KEY)
10294 {
10295 fCheck = eANI_BOOLEAN_TRUE;
10296 }
10297 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010298 return (fCheck);
10299}
10300
Jeff Johnson295189b2012-06-20 16:38:30 -070010301//IBSS
10302
Jeff Johnson295189b2012-06-20 16:38:30 -070010303tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
10304{
10305 tANI_U8 channel = 0;
10306 tANI_U32 idx;
10307 tANI_U32 idxValidChannels;
10308 tANI_BOOLEAN fFound = FALSE;
10309 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10310
10311 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
10312 {
10313 channel = pMac->roam.configParam.AdHocChannel5G;
10314 if(!csrRoamIsChannelValid(pMac, channel))
10315 {
10316 channel = 0;
10317 }
10318 }
10319 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
10320 {
10321 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
10322 {
10323 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
10324 {
10325 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
10326 {
10327 fFound = TRUE;
10328 channel = csrStartIbssChannels50[ idx ];
10329 }
10330 }
10331 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010332 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
10333 if (!fFound)
10334 {
10335 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
10336 {
10337 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idx ]) ) // the max channel# in 11g is 14
10338 {
10339 channel = csrStartIbssChannels50[ idx ];
10340 break;
10341 }
10342 }
10343 }
10344 }//if
10345
10346 return( channel );
10347}
10348
Jeff Johnson295189b2012-06-20 16:38:30 -070010349tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
10350{
10351 tANI_U8 channel = 1;
10352 tANI_U32 idx;
10353 tANI_U32 idxValidChannels;
10354 tANI_BOOLEAN fFound = FALSE;
10355 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10356
10357 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
10358 {
10359 channel = pMac->roam.configParam.AdHocChannel24;
10360 if(!csrRoamIsChannelValid(pMac, channel))
10361 {
10362 channel = 0;
10363 }
10364 }
10365
10366 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
10367 {
10368 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
10369 {
10370 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
10371 {
10372 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
10373 {
10374 fFound = TRUE;
10375 channel = csrStartIbssChannels24[ idx ];
10376 }
10377 }
10378 }
10379 }
10380
10381 return( channel );
10382}
10383
Jeff Johnson295189b2012-06-20 16:38:30 -070010384static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10385 tCsrRoamStartBssParams *pParam )
10386{
10387 eCsrCfgDot11Mode cfgDot11Mode;
10388 eCsrBand eBand;
10389 tANI_U8 channel = 0;
10390 tSirNwType nwType;
10391 tANI_U8 operationChannel = 0;
10392
10393 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
10394 {
10395 operationChannel = pProfile->ChannelInfo.ChannelList[0];
10396 }
10397
Jeff Johnson295189b2012-06-20 16:38:30 -070010398 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070010399
10400#ifdef WLAN_FEATURE_P2P
10401 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
10402 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
10403 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
10404 )
10405 {
10406 /* This should never happen */
10407 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
10408 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B\n"),
10409 pProfile->csrPersona);
10410 VOS_ASSERT(0);
10411 }
10412#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010413 switch( cfgDot11Mode )
10414 {
10415 case eCSR_CFG_DOT11_MODE_11G:
10416 nwType = eSIR_11G_NW_TYPE;
10417 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010418 case eCSR_CFG_DOT11_MODE_11B:
10419 nwType = eSIR_11B_NW_TYPE;
10420 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010421 case eCSR_CFG_DOT11_MODE_11A:
10422 nwType = eSIR_11A_NW_TYPE;
10423 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010424 default:
10425 case eCSR_CFG_DOT11_MODE_11N:
10426 case eCSR_CFG_DOT11_MODE_TAURUS:
10427 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
10428 if(eCSR_BAND_24 == eBand)
10429 {
10430 nwType = eSIR_11G_NW_TYPE;
10431 }
10432 else
10433 {
10434 nwType = eSIR_11A_NW_TYPE;
10435 }
10436 break;
10437 }
10438
10439 pParam->extendedRateSet.numRates = 0;
10440
10441 switch ( nwType )
10442 {
10443 default:
10444 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)\n"), nwType);
10445 case eSIR_11A_NW_TYPE:
10446
10447 pParam->operationalRateSet.numRates = 8;
10448
10449 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
10450 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
10451 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
10452 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
10453 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
10454 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
10455 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
10456 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
10457
10458 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10459 {
10460 channel = csrRoamGetIbssStartChannelNumber50( pMac );
10461 if( 0 == channel &&
10462 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
10463 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
10464 )
10465 {
10466 //We could not find a 5G channel by auto pick, let's try 2.4G channels
10467 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
10468 nwType = eSIR_11B_NW_TYPE;
10469 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10470 pParam->operationalRateSet.numRates = 4;
10471 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10472 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10473 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10474 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
10475 }
10476 }
10477 else
10478 {
10479 channel = operationChannel;
10480 }
10481 break;
10482
10483 case eSIR_11B_NW_TYPE:
10484 pParam->operationalRateSet.numRates = 4;
10485 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10486 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10487 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10488 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070010489 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10490 {
10491 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10492 }
10493 else
10494 {
10495 channel = operationChannel;
10496 }
10497
10498 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010499 case eSIR_11G_NW_TYPE:
10500#ifdef WLAN_FEATURE_P2P
10501 /* For P2P Client and P2P GO, disable 11b rates */
10502 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
10503 (pProfile->csrPersona == VOS_P2P_GO_MODE)
10504 )
10505 {
10506 pParam->operationalRateSet.numRates = 8;
10507
10508 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
10509 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
10510 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
10511 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
10512 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
10513 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
10514 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
10515 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
10516 }
10517 else
10518#endif
10519 {
10520 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070010521 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10522 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10523 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10524 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
10525
10526 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070010527 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
10528 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
10529 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
10530 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
10531 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
10532 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
10533 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
10534 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
10535 }
10536
10537 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10538 {
10539 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10540 }
10541 else
10542 {
10543 channel = operationChannel;
10544 }
10545
10546 break;
10547 }
10548 pParam->operationChn = channel;
10549 pParam->sirNwType = nwType;
10550}
10551
Jeff Johnson295189b2012-06-20 16:38:30 -070010552static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
10553 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
10554{
10555
10556 if( pParam )
10557 {
10558 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070010559 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010560 pParam->operationChn = pBssDesc->channelId;
10561 palCopyMemory( pMac->hHdd, &pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid) );
10562
10563 if( pIes )
10564 {
10565 if(pIes->SuppRates.present)
10566 {
10567 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
10568 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
10569 {
10570 smsLog(pMac, LOGE, FL("num_rates :%d is more than SIR_MAC_RATESET_EID_MAX, resetting to SIR_MAC_RATESET_EID_MAX\n"),
10571 pIes->SuppRates.num_rates);
10572 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
10573 }
10574 palCopyMemory(pMac->hHdd, pParam->operationalRateSet.rate, pIes->SuppRates.rates,
10575 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
10576 }
10577 if( pIes->SSID.present )
10578 {
10579 pParam->ssId.length = pIes->SSID.num_ssid;
10580 palCopyMemory(pMac->hHdd, pParam->ssId.ssId, pIes->SSID.ssid, pParam->ssId.length);
10581 }
10582 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070010583 }
10584 else
10585 {
10586 pParam->ssId.length = 0;
10587 pParam->operationalRateSet.numRates = 0;
10588 }
10589 }
10590}
10591
Jeff Johnson295189b2012-06-20 16:38:30 -070010592static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
10593{
10594 tANI_U8 MaxRate = 0;
10595 tANI_U32 i;
10596 tANI_U8 *pRate;
10597
10598 pRate = pSirRateSet->rate;
10599 for ( i = 0; i < pSirRateSet->numRates; i++ )
10600 {
10601 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
10602 }
10603
10604 // Save the max rate in the connected state information...
10605
10606 // modify LastRates variable as well
10607
10608 return;
10609}
10610
Jeff Johnson295189b2012-06-20 16:38:30 -070010611//this function finds a valid secondary channel for channel bonding with "channel".
10612//Param: channel -- primary channel, caller must validate it
10613// cbChoice -- CB directory
10614//Return: if 0, no secondary channel is found. Otherwise a valid secondary channel.
10615static tANI_U8 csrRoamGetSecondaryChannel(tpAniSirGlobal pMac, tANI_U8 channel, eCsrCBChoice cbChoice)
10616{
10617 tANI_U8 chnUp = 0, chnDown = 0, chnRet = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010618 switch (cbChoice)
10619 {
10620 case eCSR_CB_OFF:
10621 chnUp = 0;
10622 chnDown = 0;
10623 break;
10624 case eCSR_CB_DOWN:
10625 chnUp = 0;
10626 chnDown = channel - CSR_CB_CHANNEL_GAP;
10627 break;
10628 case eCSR_CB_UP:
10629 chnUp = channel + CSR_CB_CHANNEL_GAP;
10630 chnDown = 0;
10631 break;
10632 case eCSR_CB_AUTO:
10633 //consider every other value means auto
10634 default:
10635 chnUp = channel + CSR_CB_CHANNEL_GAP;
10636 chnDown = channel - CSR_CB_CHANNEL_GAP;
10637 break;
10638 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010639 //if CB_UP or auto, try channel up first
10640 if(chnUp && CSR_IS_SAME_BAND_CHANNELS(chnUp, channel) && csrRoamIsChannelValid(pMac, chnUp))
10641 {
10642 //found a valid up channel for channel bonding
10643 //check whether the center channel is valid
10644 if(csrRoamIsValid40MhzChannel(pMac, channel + CSR_CB_CENTER_CHANNEL_OFFSET))
10645 {
10646 chnRet = chnUp;
10647 }
10648 }
10649 if(chnRet == 0 && chnDown && CSR_IS_SAME_BAND_CHANNELS(chnDown, channel) && csrRoamIsChannelValid(pMac, chnDown))
10650 {
10651 //found a valid down channel for channel bonding
10652 if(csrRoamIsValid40MhzChannel(pMac, channel - CSR_CB_CENTER_CHANNEL_OFFSET))
10653 {
10654 chnRet = chnDown;
10655 }
10656 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010657 return chnRet;
10658}
10659
Jeff Johnson295189b2012-06-20 16:38:30 -070010660eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
10661 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
10662{
10663 eHalStatus status = eHAL_STATUS_SUCCESS;
10664 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010665 // Set the roaming substate to 'Start BSS attempt'...
10666 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010667#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10668 //Need to figure out whether we need to log WDS???
10669 if( CSR_IS_IBSS( pProfile ) )
10670 {
10671 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010672 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10673 if(pIbssLog)
10674 {
10675 if(pBssDesc)
10676 {
10677 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
10678 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pBssDesc->bssId, 6);
10679 }
10680 else
10681 {
10682 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
10683 }
10684 palCopyMemory(pMac->hHdd, pIbssLog->ssid, pParam->ssId.ssId,
10685 pParam->ssId.length);
10686 if(pProfile->ChannelInfo.numOfChannels == 0)
10687 {
10688 pIbssLog->channelSetting = AUTO_PICK;
10689 }
10690 else
10691 {
10692 pIbssLog->channelSetting = SPECIFIED;
10693 }
10694 pIbssLog->operatingChannel = pParam->operationChn;
10695 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10696 }
10697 }
10698#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
10699 //Put RSN information in for Starting BSS
10700 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
10701 pParam->pRSNIE = pProfile->pRSNReqIE;
10702
Jeff Johnson295189b2012-06-20 16:38:30 -070010703 pParam->privacy = pProfile->privacy;
10704 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
10705 pParam->authType = pProfile->csr80211AuthType;
10706 pParam->beaconInterval = pProfile->beaconInterval;
10707 pParam->dtimPeriod = pProfile->dtimPeriod;
10708 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
10709 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
10710 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
10711 {
10712 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
10713 {
10714 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
10715 }
10716 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010717 pParam->protEnabled = pProfile->protEnabled;
10718 pParam->obssProtEnabled = pProfile->obssProtEnabled;
10719 pParam->ht_protection = pProfile->cfg_protection;
10720 pParam->wps_state = pProfile->wps_state;
Jeff Johnson398def02013-02-26 21:23:00 -080010721
Jeff Johnson295189b2012-06-20 16:38:30 -070010722 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
10723 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070010724 pParam->bssPersona = pProfile->csrPersona;
10725 // When starting an IBSS, start on the channel from the Profile.
10726 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070010727 return (status);
10728}
10729
Jeff Johnson295189b2012-06-20 16:38:30 -070010730static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070010731 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070010732{
10733 tANI_U8 Channel, SecondChn;
Jeff Johnsone7245742012-09-05 17:12:55 -070010734 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010735 eCsrCBChoice cbChoice;
10736 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010737
10738 if(!pSession)
10739 {
10740 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10741 return;
10742 }
10743
Jeff Johnson295189b2012-06-20 16:38:30 -070010744 if( pBssDesc )
10745 {
10746 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
10747 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
10748 //The following code has to be do after that.
10749 //For WDS station, use selfMac as the self BSSID
10750 if( CSR_IS_WDS_STA( pProfile ) )
10751 {
10752 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, &pSession->selfMacAddr, sizeof(tCsrBssid));
10753 }
10754 }
10755 else
10756 {
10757 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070010758 //Use the first SSID
10759 if(pProfile->SSIDs.numOfSSIDs)
10760 {
10761 palCopyMemory(pMac->hHdd, &pSession->bssParams.ssId, pProfile->SSIDs.SSIDList, sizeof(tSirMacSSid));
10762 }
10763 //For WDS station, use selfMac as the self BSSID
10764 if( CSR_IS_WDS_STA( pProfile ) )
10765 {
10766 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, &pSession->selfMacAddr, sizeof(tCsrBssid));
10767 }
10768 //Use the first BSSID
10769 else if( pProfile->BSSIDs.numOfBSSIDs )
10770 {
10771 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, pProfile->BSSIDs.bssid, sizeof(tCsrBssid));
10772 }
10773 else
10774 {
10775 palZeroMemory( pMac->hHdd, &pSession->bssParams.bssid, sizeof(tCsrBssid) );
10776 }
10777 }
10778 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070010779 //Set operating channel in pProfile which will be used
10780 //in csrRoamSetBssConfigCfg() to determine channel bonding
10781 //mode and will be configured in CFG later
10782 pProfile->operationChannel = Channel;
10783
10784 if(Channel == 0)
10785 {
10786 smsLog(pMac, LOGW, " CSR cannot find a channel to start IBSS\n");
10787 }
10788 else
10789 {
10790
10791 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Jeff Johnsone7245742012-09-05 17:12:55 -070010792 if (CSR_IS_INFRA_AP(pProfile))
10793 {
10794 if(CSR_IS_CHANNEL_24GHZ(Channel))
10795 {
10796 cbMode = pMac->roam.configParam.channelBondingMode24GHz;
10797 }
10798 else
10799 {
10800 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
10801 }
10802 smsLog(pMac, LOG1, "##softap cbMode %d\n", cbMode);
10803 pBssConfig->cbMode = cbMode;
10804 pSession->bssParams.cbMode = cbMode;
10805 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010806
10807 if( CSR_IS_START_IBSS( pProfile ) )
10808 {
10809 //TBH: channel bonding is not supported for Libra
10810 if( pProfile->ChannelInfo.ChannelList && eCSR_OPERATING_CHANNEL_AUTO != pProfile->ChannelInfo.ChannelList[0] )
10811 {
10812 Channel = pProfile->ChannelInfo.ChannelList[0];
10813 cbChoice = pProfile->CBMode;
10814 }
10815 else {
10816 cbChoice = pMac->roam.configParam.cbChoice;
10817 }
10818 pSession->bssParams.operationChn = Channel;
10819 //make sure channel is valid
10820 if(!csrRoamIsChannelValid(pMac, Channel))
10821 {
10822 //set Channel to 0 to let lim know this is invalid
10823 //We still send this request down to lim even though we know the channel is wrong because
10824 //lim will response with error and hdd's eWNI_SME_START_BSS_RSP handler will roam other profile (if any)
10825 Channel = 0;
10826 pSession->bssParams.operationChn = 0;
10827 }
10828 else {
10829 tANI_U32 ChannelBondingMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010830 if(CSR_IS_CHANNEL_24GHZ(Channel))
10831 {
10832 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
10833 }
10834 else
10835 {
10836 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
10837 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010838 //now we have a valid channel
10839 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
10840 {
10841 //let's pick a secondard channel
10842 SecondChn = csrRoamGetSecondaryChannel(pMac, Channel, cbChoice);
Jeff Johnson295189b2012-06-20 16:38:30 -070010843 if(SecondChn > Channel)
10844 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010845 cbMode = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010846 }
10847 else if(SecondChn && SecondChn < Channel)
10848 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010849 cbMode = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010850 }
10851 else
10852 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010853 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010854 }
10855 pSession->bssParams.cbMode = cbMode;
10856 }
10857 else
10858 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010859 pSession->bssParams.cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010860 }
10861 }
10862 }
10863 }
10864}
10865
Jeff Johnson295189b2012-06-20 16:38:30 -070010866static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
10867 tANI_BOOLEAN *pfSameIbss )
10868{
10869 eHalStatus status = eHAL_STATUS_SUCCESS;
10870 tANI_BOOLEAN fSameIbss = FALSE;
10871
10872 if ( csrIsConnStateIbss( pMac, sessionId ) )
10873 {
10874 // Check if any profile parameter has changed ? If any profile parameter
10875 // has changed then stop old BSS and start a new one with new parameters
10876 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
10877 {
10878 fSameIbss = TRUE;
10879 }
10880 else
10881 {
10882 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
10883 }
10884 }
10885 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
10886 {
10887 // Disassociate from the connected Infrastructure network...
10888 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
10889 }
10890 else
10891 {
10892 tBssConfigParam *pBssConfig;
10893
10894 status = palAllocateMemory(pMac->hHdd, (void **)&pBssConfig, sizeof(tBssConfigParam));
10895 if(HAL_STATUS_SUCCESS(status))
10896 {
10897 palZeroMemory(pMac->hHdd, pBssConfig, sizeof(tBssConfigParam));
10898 // there is no Bss description before we start an IBSS so we need to adopt
10899 // all Bss configuration parameters from the Profile.
10900 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
10901 if(HAL_STATUS_SUCCESS(status))
10902 {
10903 //save dotMode
10904 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
10905 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070010906 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070010907 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
10908 }
10909
10910 palFreeMemory(pMac->hHdd, pBssConfig);
10911 }//Allocate memory
10912 }
10913
10914 if(pfSameIbss)
10915 {
10916 *pfSameIbss = fSameIbss;
10917 }
10918 return( status );
10919}
10920
Jeff Johnson295189b2012-06-20 16:38:30 -070010921static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
10922 tSirSmeNewBssInfo *pNewBss )
10923{
10924 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010925
10926 if(!pSession)
10927 {
10928 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10929 return;
10930 }
10931
Jeff Johnson295189b2012-06-20 16:38:30 -070010932 if( pNewBss )
10933 {
10934 // Set the operating channel.
10935 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
10936 // move the BSSId from the BSS description into the connected state information.
10937 palCopyMemory( pMac->hHdd, &pSession->connectedProfile.bssid,
10938 &(pNewBss->bssId), sizeof( tCsrBssid ) );
10939 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010940 return;
10941}
10942
Jeff Johnson295189b2012-06-20 16:38:30 -070010943#ifdef FEATURE_WLAN_WAPI
10944eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
10945 tANI_U32 numItems )
10946{
10947 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
10948 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070010949 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
10950 {
10951 smsLog(pMac, LOGE, FL(" Invalid session ID\n"));
10952 return status;
10953 }
10954 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d\n", numItems);
10955 pSession = CSR_GET_SESSION( pMac, sessionId );
10956 if(numItems <= CSR_MAX_BKID_ALLOWED)
10957 {
10958 status = eHAL_STATUS_SUCCESS;
10959 //numItems may be 0 to clear the cache
10960 pSession->NumBkidCache = (tANI_U16)numItems;
10961 if(numItems && pBKIDCache)
10962 {
10963 status = palCopyMemory( pMac->hHdd, pSession->BkidCacheInfo, pBKIDCache,
10964 sizeof(tBkidCacheInfo) * numItems );
10965 }
10966 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010967 return (status);
10968}
Jeff Johnson295189b2012-06-20 16:38:30 -070010969eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
10970 tBkidCacheInfo *pBkidCache)
10971{
10972 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
10973 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070010974 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
10975 {
10976 smsLog(pMac, LOGE, FL(" Invalid session ID\n"));
10977 return status;
10978 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010979 pSession = CSR_GET_SESSION( pMac, sessionId );
10980 if(pNum && pBkidCache)
10981 {
10982 if(pSession->NumBkidCache == 0)
10983 {
10984 *pNum = 0;
10985 status = eHAL_STATUS_SUCCESS;
10986 }
10987 else if(*pNum >= pSession->NumBkidCache)
10988 {
10989 if(pSession->NumBkidCache > CSR_MAX_PMKID_ALLOWED)
10990 {
10991 smsLog(pMac, LOGE, FL("NumPmkidCache :%d is more than CSR_MAX_PMKID_ALLOWED, resetting to CSR_MAX_PMKID_ALLOWED\n"),
10992 pSession->NumBkidCache);
10993 pSession->NumBkidCache = CSR_MAX_PMKID_ALLOWED;
10994 }
10995 palCopyMemory( pMac->hHdd, pBkidCache, pSession->BkidCacheInfo,
10996 sizeof(tBkidCacheInfo) * pSession->NumBkidCache );
10997 *pNum = pSession->NumBkidCache;
10998 status = eHAL_STATUS_SUCCESS;
10999 }
11000 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011001 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070011002}
Jeff Johnson295189b2012-06-20 16:38:30 -070011003tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11004{
11005 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011006}
11007#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011008eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
11009 tPmkidCacheInfo *pPMKIDCache, tANI_U32 numItems )
11010{
11011 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11012 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011013
11014 if(!pSession)
11015 {
11016 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11017 return eHAL_STATUS_FAILURE;
11018 }
11019
Jeff Johnson295189b2012-06-20 16:38:30 -070011020 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d\n", numItems);
11021 if(numItems <= CSR_MAX_PMKID_ALLOWED)
11022 {
11023#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11024 {
11025 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
11026 palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type));
11027 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
11028 secEvent.encryptionModeMulticast =
11029 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
11030 secEvent.encryptionModeUnicast =
11031 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
11032 palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 );
11033 secEvent.authMode =
11034 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
11035 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
11036 }
11037#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011038 status = eHAL_STATUS_SUCCESS;
11039 //numItems may be 0 to clear the cache
11040 pSession->NumPmkidCache = (tANI_U16)numItems;
11041 if(numItems && pPMKIDCache)
11042 {
11043 status = palCopyMemory( pMac->hHdd, pSession->PmkidCacheInfo, pPMKIDCache,
11044 sizeof(tPmkidCacheInfo) * numItems );
11045 }
11046 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011047 return (status);
11048}
11049
Jeff Johnson295189b2012-06-20 16:38:30 -070011050tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11051{
11052 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
11053}
11054
Jeff Johnson295189b2012-06-20 16:38:30 -070011055eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
11056{
11057 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11058 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011059
11060 if(!pSession)
11061 {
11062 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11063 return eHAL_STATUS_FAILURE;
11064 }
11065
Jeff Johnson295189b2012-06-20 16:38:30 -070011066 if(pNum && pPmkidCache)
11067 {
11068 if(pSession->NumPmkidCache == 0)
11069 {
11070 *pNum = 0;
11071 status = eHAL_STATUS_SUCCESS;
11072 }
11073 else if(*pNum >= pSession->NumPmkidCache)
11074 {
11075 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
11076 {
11077 smsLog(pMac, LOGE, FL("NumPmkidCache :%d is more than CSR_MAX_PMKID_ALLOWED, resetting to CSR_MAX_PMKID_ALLOWED\n"),
11078 pSession->NumPmkidCache);
11079 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
11080 }
11081 palCopyMemory( pMac->hHdd, pPmkidCache, pSession->PmkidCacheInfo,
11082 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache );
11083 *pNum = pSession->NumPmkidCache;
11084 status = eHAL_STATUS_SUCCESS;
11085 }
11086 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011087 return (status);
11088}
11089
Jeff Johnson295189b2012-06-20 16:38:30 -070011090eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11091{
11092 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11093 tANI_U32 len;
11094 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011095
11096 if(!pSession)
11097 {
11098 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11099 return eHAL_STATUS_FAILURE;
11100 }
11101
Jeff Johnson295189b2012-06-20 16:38:30 -070011102 if(pLen)
11103 {
11104 len = *pLen;
11105 *pLen = pSession->nWpaRsnReqIeLength;
11106 if(pBuf)
11107 {
11108 if(len >= pSession->nWpaRsnReqIeLength)
11109 {
11110 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWpaRsnReqIE, pSession->nWpaRsnReqIeLength);
11111 }
11112 }
11113 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011114 return (status);
11115}
11116
Jeff Johnson295189b2012-06-20 16:38:30 -070011117eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11118{
11119 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11120 tANI_U32 len;
11121 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011122
11123 if(!pSession)
11124 {
11125 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11126 return eHAL_STATUS_FAILURE;
11127 }
11128
Jeff Johnson295189b2012-06-20 16:38:30 -070011129 if(pLen)
11130 {
11131 len = *pLen;
11132 *pLen = pSession->nWpaRsnRspIeLength;
11133 if(pBuf)
11134 {
11135 if(len >= pSession->nWpaRsnRspIeLength)
11136 {
11137 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWpaRsnRspIE, pSession->nWpaRsnRspIeLength);
11138 }
11139 }
11140 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011141 return (status);
11142}
Jeff Johnson295189b2012-06-20 16:38:30 -070011143#ifdef FEATURE_WLAN_WAPI
11144eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11145{
11146 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11147 tANI_U32 len;
11148 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011149
11150 if(!pSession)
11151 {
11152 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11153 return eHAL_STATUS_FAILURE;
11154 }
11155
Jeff Johnson295189b2012-06-20 16:38:30 -070011156 if(pLen)
11157 {
11158 len = *pLen;
11159 *pLen = pSession->nWapiReqIeLength;
11160 if(pBuf)
11161 {
11162 if(len >= pSession->nWapiReqIeLength)
11163 {
11164 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWapiReqIE, pSession->nWapiReqIeLength);
11165 }
11166 }
11167 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011168 return (status);
11169}
Jeff Johnson295189b2012-06-20 16:38:30 -070011170eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11171{
11172 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11173 tANI_U32 len;
11174 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011175
11176 if(!pSession)
11177 {
11178 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11179 return eHAL_STATUS_FAILURE;
11180 }
11181
Jeff Johnson295189b2012-06-20 16:38:30 -070011182 if(pLen)
11183 {
11184 len = *pLen;
11185 *pLen = pSession->nWapiRspIeLength;
11186 if(pBuf)
11187 {
11188 if(len >= pSession->nWapiRspIeLength)
11189 {
11190 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWapiRspIE, pSession->nWapiRspIeLength);
11191 }
11192 }
11193 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011194 return (status);
11195}
11196#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011197eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
11198{
11199 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
11200 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011201
11202 if(!pSession)
11203 {
11204 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11205 return (retStatus);
11206 }
11207
Jeff Johnson295189b2012-06-20 16:38:30 -070011208 if(CSR_IS_ROAMING(pSession))
11209 {
11210 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
11211 pSession->fRoaming = eANI_BOOLEAN_FALSE;
11212 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011213 return (retStatus);
11214}
11215
Jeff Johnson295189b2012-06-20 16:38:30 -070011216//This function remove the connected BSS from te cached scan result
11217eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
11218 tCsrRoamConnectedProfile *pConnProfile)
11219{
11220 eHalStatus status = eHAL_STATUS_FAILURE;
11221 tCsrScanResultFilter *pScanFilter = NULL;
11222 tListElem *pEntry;
11223 tCsrScanResult *pResult;
11224 tDot11fBeaconIEs *pIes;
11225 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070011226 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
11227 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
11228 {
11229 do
11230 {
11231 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
11232 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
11233 if(!HAL_STATUS_SUCCESS(status)) break;
11234 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
11235 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->BSSIDs.bssid, sizeof(tCsrBssid));
11236 if(!HAL_STATUS_SUCCESS(status)) break;
11237 palCopyMemory(pMac->hHdd, pScanFilter->BSSIDs.bssid, &pConnProfile->bssid, sizeof(tCsrBssid));
11238 pScanFilter->BSSIDs.numOfBSSIDs = 1;
11239 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
11240 {
11241 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->SSIDs.SSIDList, sizeof(tCsrSSIDInfo));
11242 if(!HAL_STATUS_SUCCESS(status)) break;
11243 palCopyMemory(pMac->hHdd, &pScanFilter->SSIDs.SSIDList[0].SSID, &pConnProfile->SSID, sizeof(tSirMacSSid));
11244 }
11245 pScanFilter->authType.numEntries = 1;
11246 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
11247 pScanFilter->BSSType = pConnProfile->BSSType;
11248 pScanFilter->EncryptionType.numEntries = 1;
11249 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
11250 pScanFilter->mcEncryptionType.numEntries = 1;
11251 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
11252 //We ignore the channel for now, BSSID should be enough
11253 pScanFilter->ChannelInfo.numOfChannels = 0;
11254 //Also ignore the following fields
11255 pScanFilter->uapsd_mask = 0;
11256 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
11257 pScanFilter->countryCode[0] = 0;
11258 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011259 csrLLLock(&pMac->scan.scanResultList);
11260 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
11261 while( pEntry )
11262 {
11263 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
11264 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
11265 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
11266 pScanFilter, NULL, NULL, NULL, &pIes);
11267 //Release the IEs allocated by csrMatchBSS is needed
11268 if( !pResult->Result.pvIes )
11269 {
11270 //need to free the IEs since it is allocated by csrMatchBSS
11271 palFreeMemory(pMac->hHdd, pIes);
11272 }
11273 if(fMatch)
11274 {
11275 //We found the one
11276 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
11277 {
11278 //Free the memory
11279 csrFreeScanResultEntry( pMac, pResult );
11280 }
11281 break;
11282 }
11283 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
11284 }//while
11285 csrLLUnlock(&pMac->scan.scanResultList);
11286 }while(0);
11287 if(pScanFilter)
11288 {
11289 csrFreeScanFilter(pMac, pScanFilter);
11290 palFreeMemory(pMac->hHdd, pScanFilter);
11291 }
11292 }
11293 return (status);
11294}
11295
Jeff Johnson295189b2012-06-20 16:38:30 -070011296//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070011297eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
11298{
11299 eHalStatus status = eHAL_STATUS_SUCCESS;
11300 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011301 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
11302 {
11303 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
11304 {
11305 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
11306 {
11307 //co-exist with IBSS or BT-AMP is not supported
11308 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d\n", sessionId );
11309 status = eHAL_STATUS_CSR_WRONG_STATE;
11310 break;
11311 }
11312 if( csrIsConnStateInfra( pMac, sessionId ) )
11313 {
11314 if( chnId &&
11315 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
11316 {
11317 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)\n",
11318 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
11319 status = eHAL_STATUS_CSR_WRONG_STATE;
11320 break;
11321 }
11322 }
11323 }
11324 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011325 return ( status );
11326}
11327
Jeff Johnson295189b2012-06-20 16:38:30 -070011328static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
11329{
11330 eHalStatus status = eHAL_STATUS_SUCCESS;
11331 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11332 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070011333
11334 if(!pSession)
11335 {
11336 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11337 return eHAL_STATUS_FAILURE;
11338 }
11339
Jeff Johnson295189b2012-06-20 16:38:30 -070011340 if ( csrIsConnStateIbss( pMac, sessionId ) )
11341 {
11342 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11343 }
11344 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11345 {
11346 // Disassociate from the connected Infrastructure network...
11347 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11348 }
11349 else
11350 {
11351#if defined(VOSS_ENABLED)
11352 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
11353 //Otherwise we need to add code to handle the
11354 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
11355 //send stop_bss to PE, before we can continue.
11356 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
11357#endif
11358 palZeroMemory(pMac->hHdd, &bssConfig, sizeof(tBssConfigParam));
11359 /* Assume HDD provide bssid in profile */
11360 palCopyMemory( pMac->hHdd, &pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0], sizeof(tCsrBssid) );
11361 // there is no Bss description before we start an WDS so we need
11362 // to adopt all Bss configuration parameters from the Profile.
11363 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
11364 if(HAL_STATUS_SUCCESS(status))
11365 {
11366 //Save profile for late use
11367 csrFreeRoamProfile( pMac, sessionId );
11368 if (HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
11369 (void **)&pSession->pCurRoamProfile,
11370 sizeof(tCsrRoamProfile))))
11371 {
11372 palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile));
11373 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
11374 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011375 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070011376 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070011377 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
11378 }
11379 }
11380
11381 return( status );
11382}
11383
Jeff Johnson295189b2012-06-20 16:38:30 -070011384////////////////////Mail box
11385
Jeff Johnson295189b2012-06-20 16:38:30 -070011386//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
11387//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
11388static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
11389 tSirBssDescription *pBssDescription,
11390 tANI_U8 *pBuf, tANI_U8 uapsdMask)
11391{
11392 tCsrChannelSet channelGroup;
11393 tSirMacCapabilityInfo *pAP_capabilityInfo;
11394 tAniBool fTmp;
11395 tANI_BOOLEAN found = FALSE;
11396 tANI_U32 size = 0;
Kirand170dcb2013-01-31 10:43:43 -080011397 tANI_S8 pwrLimit = 0;
11398 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011399 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
11400 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
11401 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
11402 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070011403 // 802.11h
11404 //We can do this because it is in HOST CPU order for now.
11405 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kirand170dcb2013-01-31 10:43:43 -080011406 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
11407 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
11408 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011409 fTmp = (tAniBool)pal_cpu_to_be32(1);
11410 }
11411 else
11412 fTmp = (tAniBool)0;
11413
11414 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
11415 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool) );
11416 pBuf += sizeof(tAniBool);
11417 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kirand170dcb2013-01-31 10:43:43 -080011418 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070011419 // This is required for 11k test VoWiFi Ent: Test 2.
11420 // We need the power capabilities for Assoc Req.
11421 // This macro is provided by the halPhyCfg.h. We pick our
11422 // max and min capability by the halPhy provided macros
Kirand170dcb2013-01-31 10:43:43 -080011423 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
11424 if (0 != pwrLimit)
11425 {
11426 *pBuf++ = pwrLimit;
11427 }
11428 else
11429 {
11430 *pBuf++ = MAX_STA_PWR_CAP_DBM;
11431 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011432 size = sizeof(pMac->roam.validChannelList);
11433 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
11434 {
11435 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
11436 for ( i = 0; i < size; i++)
11437 {
11438 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
11439
11440 }
11441 }
11442 else
11443 {
11444 smsLog(pMac, LOGE, FL("can not find any valid channel\n"));
11445 *pBuf++ = 0; //tSirSupChnl->numChnl
11446 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011447 //Check whether it is ok to enter UAPSD
11448#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11449 if( btcIsReadyForUapsd(pMac) )
11450#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
11451 {
11452 *pBuf++ = uapsdMask;
11453 }
11454#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11455 else
11456 {
11457 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)\n"), uapsdMask);
11458 *pBuf++ = 0;
11459 }
11460#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
11461
Jeff Johnson295189b2012-06-20 16:38:30 -070011462 // move the entire BssDescription into the join request.
11463 palCopyMemory( pMac->hHdd, pBuf, pBssDescription,
11464 pBssDescription->length + sizeof( pBssDescription->length ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070011465 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
11466}
11467
Jeff Johnson295189b2012-06-20 16:38:30 -070011468/*
11469 * The communication between HDD and LIM is thru mailbox (MB).
11470 * Both sides will access the data structure "tSirSmeJoinReq".
11471 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
11472 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
11473 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
11474 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
11475 */
11476eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011477 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011478{
11479 eHalStatus status = eHAL_STATUS_SUCCESS;
11480 tSirSmeJoinReq *pMsg;
11481 tANI_U8 *pBuf;
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011482 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070011483 tANI_U16 msgLen, wTmp, ieLen;
11484 tSirMacRateSet OpRateSet;
11485 tSirMacRateSet ExRateSet;
11486 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11487 tANI_U32 dwTmp;
11488 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Jeff Johnson32d95a32012-09-10 13:15:23 -070011489
11490 if(!pSession)
11491 {
11492 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11493 return eHAL_STATUS_FAILURE;
11494 }
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011495 /* To satisfy klockworks */
11496 if (NULL == pBssDescription)
11497 {
11498 smsLog(pMac, LOGE, FL(" pBssDescription is NULL\n"));
11499 return eHAL_STATUS_FAILURE;
11500 }
11501
Jeff Johnson295189b2012-06-20 16:38:30 -070011502 do {
11503 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
11504 pSession->joinFailStatusCode.reasonCode = 0;
11505 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
11506 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
11507 // IE fields, but the length field in the bssDescription needs to be interpreted to
11508 // determine length of the IE fields.
11509 //
11510 // So, take the size of the JoinReq, subtract the size of the bssDescription and
11511 // add in the length from the bssDescription (then add the size of the 'length' field
11512 // itself because that is NOT included in the length field).
11513 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
11514 pBssDescription->length + sizeof( pBssDescription->length ) +
11515 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 -070011516 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
11517 if ( !HAL_STATUS_SUCCESS(status) ) break;
11518 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011519 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011520 pMsg->length = pal_cpu_to_be16(msgLen);
11521 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011522 // sessionId
11523 *pBuf = (tANI_U8)sessionId;
11524 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011525 // transactionId
11526 *pBuf = 0;
11527 *( pBuf + 1 ) = 0;
11528 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070011529 // ssId
11530 if( pIes->SSID.present && pIes->SSID.num_ssid )
11531 {
11532 // ssId len
11533 *pBuf = pIes->SSID.num_ssid;
11534 pBuf++;
11535 palCopyMemory( pMac->hHdd, pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid );
11536 pBuf += pIes->SSID.num_ssid;
11537 }
11538 else
11539 {
11540 *pBuf = 0;
11541 pBuf++;
11542 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011543 // selfMacAddr
11544 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
11545 pBuf += sizeof(tSirMacAddr);
11546 // bsstype
11547 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
11548 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
11549 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tSirBssType) );
11550 pBuf += sizeof(tSirBssType);
11551 // dot11mode
11552 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
11553 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011554 //Persona
11555 *pBuf = (tANI_U8)pProfile->csrPersona;
11556 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070011557 //CBMode
11558 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
11559 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011560
11561 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070011562 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
11563
Jeff Johnson295189b2012-06-20 16:38:30 -070011564 // uapsdPerAcBitmask
11565 *pBuf = pProfile->uapsd_mask;
11566 pBuf++;
11567
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011568
11569
11570#if (WNI_POLARIS_FW_PACKAGE == ADVANCED)
Jeff Johnson295189b2012-06-20 16:38:30 -070011571#endif /*(WNI_POLARIS_FW_PACKAGE == ADVANCED)*/
Jeff Johnson295189b2012-06-20 16:38:30 -070011572 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011573 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011574 {
11575 // OperationalRateSet
11576 if (OpRateSet.numRates) {
11577 *pBuf++ = OpRateSet.numRates;
11578 palCopyMemory(pMac->hHdd, pBuf, OpRateSet.rate, OpRateSet.numRates);
11579 pBuf += OpRateSet.numRates;
11580 } else *pBuf++ = 0;
11581 // ExtendedRateSet
11582 if (ExRateSet.numRates) {
11583 *pBuf++ = ExRateSet.numRates;
11584 palCopyMemory(pMac->hHdd, pBuf, ExRateSet.rate, ExRateSet.numRates);
11585 pBuf += ExRateSet.numRates;
11586 } else *pBuf++ = 0;
11587 }
11588 else
11589 {
11590 *pBuf++ = 0;
11591 *pBuf++ = 0;
11592 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011593 // rsnIE
11594 if ( csrIsProfileWpa( pProfile ) )
11595 {
11596 // Insert the Wpa IE into the join request
11597 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
11598 (tCsrWpaIe *)( wpaRsnIE ) );
11599 }
11600 else if( csrIsProfileRSN( pProfile ) )
11601 {
11602 // Insert the RSN IE into the join request
11603 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11604 (tCsrRSNIe *)( wpaRsnIE ) );
11605 }
11606#ifdef FEATURE_WLAN_WAPI
11607 else if( csrIsProfileWapi( pProfile ) )
11608 {
11609 // Insert the WAPI IE into the join request
11610 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11611 (tCsrWapiIe *)( wpaRsnIE ) );
11612 }
11613#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011614 else
11615 {
11616 ieLen = 0;
11617 }
11618 //remember the IE for future use
11619 if( ieLen )
11620 {
11621 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
11622 {
11623 smsLog(pMac, LOGE, FL(" WPA RSN IE length :%d is more than DOT11F_IE_RSN_MAX_LEN, resetting to %d\n"), ieLen, DOT11F_IE_RSN_MAX_LEN);
11624 ieLen = DOT11F_IE_RSN_MAX_LEN;
11625 }
11626#ifdef FEATURE_WLAN_WAPI
11627 if( csrIsProfileWapi( pProfile ) )
11628 {
11629 //Check whether we need to allocate more memory
11630 if(ieLen > pSession->nWapiReqIeLength)
11631 {
11632 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
11633 {
11634 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
11635 }
11636 status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWapiReqIE, ieLen);
11637 if(!HAL_STATUS_SUCCESS(status)) break;
11638 }
11639 pSession->nWapiReqIeLength = ieLen;
11640 palCopyMemory(pMac->hHdd, pSession->pWapiReqIE, wpaRsnIE, ieLen);
11641 wTmp = pal_cpu_to_be16( ieLen );
11642 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11643 pBuf += sizeof(tANI_U16);
11644 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11645 pBuf += ieLen;
11646 }
11647 else//should be WPA/WPA2 otherwise
11648#endif /* FEATURE_WLAN_WAPI */
11649 {
11650 //Check whether we need to allocate more memory
11651 if(ieLen > pSession->nWpaRsnReqIeLength)
11652 {
11653 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
11654 {
11655 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
11656 }
11657 status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnReqIE, ieLen);
11658 if(!HAL_STATUS_SUCCESS(status)) break;
11659 }
11660 pSession->nWpaRsnReqIeLength = ieLen;
11661 palCopyMemory(pMac->hHdd, pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
11662 wTmp = pal_cpu_to_be16( ieLen );
11663 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11664 pBuf += sizeof(tANI_U16);
11665 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11666 pBuf += ieLen;
11667 }
11668 }
11669 else
11670 {
11671 //free whatever old info
11672 pSession->nWpaRsnReqIeLength = 0;
11673 if(pSession->pWpaRsnReqIE)
11674 {
11675 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
11676 pSession->pWpaRsnReqIE = NULL;
11677 }
11678#ifdef FEATURE_WLAN_WAPI
11679 pSession->nWapiReqIeLength = 0;
11680 if(pSession->pWapiReqIE)
11681 {
11682 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
11683 pSession->pWapiReqIE = NULL;
11684 }
11685#endif /* FEATURE_WLAN_WAPI */
11686 //length is two bytes
11687 *pBuf = 0;
11688 *(pBuf + 1) = 0;
11689 pBuf += 2;
11690 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011691#ifdef FEATURE_WLAN_CCX
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011692 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011693 {
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011694 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070011695 //length is two bytes
11696 *pBuf = 0;
11697 *(pBuf + 1) = 0;
11698 pBuf += 2;
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011699 }
11700 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011701 {
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011702 // cckmIE
11703 if( csrIsProfileCCX( pProfile ) )
11704 {
11705 // Insert the CCKM IE into the join request
11706 ieLen = csrConstructCcxCckmIe( pMac,
11707 pSession,
11708 pProfile,
11709 pBssDescription,
11710 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070011711 pSession->nWpaRsnReqIeLength,
11712 (void *)( wpaRsnIE ) );
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011713 }
11714 else
11715 {
11716 ieLen = 0;
11717 }
11718 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
11719 if( ieLen )
11720 {
11721 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
11722 wTmp = pal_cpu_to_be16( ieLen );
11723 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11724 pBuf += sizeof(tANI_U16);
11725 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11726 pBuf += ieLen;
11727 }
11728 else
11729 {
11730 //Indicate you have no CCKM IE
11731 //length is two bytes
11732 *pBuf = 0;
11733 *(pBuf + 1) = 0;
11734 pBuf += 2;
11735 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011736 }
11737#endif /* FEATURE_WLAN_CCX */
Jeff Johnson295189b2012-06-20 16:38:30 -070011738 // addIEScan
11739 if(pProfile->nAddIEScanLength && pProfile->pAddIEScan)
11740 {
11741 ieLen = pProfile->nAddIEScanLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070011742 if(ieLen > pSession->nAddIEScanLength)
11743 {
11744 if(pSession->pAddIEScan && pSession->nAddIEScanLength)
11745 {
11746 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
11747 }
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011748 status = palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070011749 (void **)&pSession->pAddIEScan, ieLen);
11750 if(!HAL_STATUS_SUCCESS(status)) break;
11751 }
11752 pSession->nAddIEScanLength = ieLen;
11753 palCopyMemory(pMac->hHdd, pSession->pAddIEScan,
11754 pProfile->pAddIEScan, ieLen);
11755 wTmp = pal_cpu_to_be16( ieLen );
11756 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11757 pBuf += sizeof(tANI_U16);
11758 palCopyMemory( pMac->hHdd, pBuf, pProfile->pAddIEScan, ieLen );
11759 pBuf += ieLen;
11760 }
11761 else
11762 {
11763 pSession->nAddIEScanLength = 0;
11764 if(pSession->pAddIEScan)
11765 {
11766 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
11767 pSession->pAddIEScan = NULL;
11768 }
11769 *pBuf = 0;
11770 *(pBuf + 1) = 0;
11771 pBuf += 2;
11772 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011773 // addIEAssoc
11774 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
11775 {
11776 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070011777 if(ieLen > pSession->nAddIEAssocLength)
11778 {
11779 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
11780 {
11781 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
11782 }
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011783 status = palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070011784 (void **)&pSession->pAddIEAssoc, ieLen);
11785 if(!HAL_STATUS_SUCCESS(status)) break;
11786 }
11787 pSession->nAddIEAssocLength = ieLen;
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011788 palCopyMemory(pMac->hHdd, pSession->pAddIEAssoc,
Jeff Johnson295189b2012-06-20 16:38:30 -070011789 pProfile->pAddIEAssoc, ieLen);
11790 wTmp = pal_cpu_to_be16( ieLen );
11791 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11792 pBuf += sizeof(tANI_U16);
11793 palCopyMemory( pMac->hHdd, pBuf, pProfile->pAddIEAssoc, ieLen );
11794 pBuf += ieLen;
11795 }
11796 else
11797 {
11798 pSession->nAddIEAssocLength = 0;
11799 if(pSession->pAddIEAssoc)
11800 {
11801 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
11802 pSession->pAddIEAssoc = NULL;
11803 }
11804 *pBuf = 0;
11805 *(pBuf + 1) = 0;
11806 pBuf += 2;
11807 }
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011808
11809 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011810 {
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011811 //Unmask any AC in reassoc that is ACM-set
11812 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
11813 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011814 {
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011815 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
11816 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011817#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011818 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070011819#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011820 uapsd_mask &= ~(acm_mask);
11821 }
11822 else
11823 {
11824 uapsd_mask = 0;
11825 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011826 }
11827 }
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011828
Jeff Johnson295189b2012-06-20 16:38:30 -070011829 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
11830 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011831 pBuf += sizeof(tANI_U32);
11832
Jeff Johnson295189b2012-06-20 16:38:30 -070011833 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
11834 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011835 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070011836#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011837 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
11838 if (csrIsProfile11r( pProfile ) )
11839 {
11840 // is11Rconnection;
11841 dwTmp = pal_cpu_to_be32(TRUE);
11842 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11843 pBuf += sizeof(tAniBool);
11844 }
11845 else
11846 {
11847 // is11Rconnection;
11848 dwTmp = pal_cpu_to_be32(FALSE);
11849 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11850 pBuf += sizeof(tAniBool);
11851 }
11852#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011853#ifdef FEATURE_WLAN_CCX
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011854 /* A profile can not be both CCX and 11R. But an 802.11R AP
11855 * may be advertising support for CCX as well. So if we are
11856 * associating Open or explicitly CCX then we will get CCX.
11857 * If we are associating explictly 11R only then we will get
11858 * 11R.
11859 */
11860 if ((csrIsProfileCCX(pProfile) ||
11861 ((pIes->CCXVersion.present)
11862 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011863 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
11864 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
11865 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011866 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
11867 && (!(csrIsProfile11r( pProfile )))
11868 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
11869 {
11870 // isCCXconnection;
11871 dwTmp = pal_cpu_to_be32(TRUE);
11872 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11873 pBuf += sizeof(tAniBool);
11874 }
11875 else
11876 {
11877 //isCCXconnection;
11878 dwTmp = pal_cpu_to_be32(FALSE);
11879 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11880 pBuf += sizeof(tAniBool);
11881 }
11882
11883 if (eWNI_SME_JOIN_REQ == messageType)
11884 {
11885 tCCXTspecInfo ccxTspec;
11886 // CCX-Tspec IEs in the ASSOC request is presently not supported
11887 // so nullify the TSPEC parameters
11888 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
11889 palCopyMemory( pMac->hHdd, pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
11890 pBuf += sizeof(tCCXTspecInfo);
11891 }
11892 else if (eWNI_SME_REASSOC_REQ == messageType)
11893 {
11894 if ((csrIsProfileCCX(pProfile) ||
11895 ((pIes->CCXVersion.present)
11896 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011897 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
11898 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
11899 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011900 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
11901 && (!(csrIsProfile11r( pProfile )))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011902 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070011903 {
11904 tCCXTspecInfo ccxTspec;
Jeff Johnson295189b2012-06-20 16:38:30 -070011905 // CCX Tspec information
11906 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
11907 ccxTspec.numTspecs = sme_QosCCxRetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &ccxTspec.tspec[0]);
11908 *pBuf = ccxTspec.numTspecs;
11909 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070011910 // Copy the TSPEC information only if present
11911 if (ccxTspec.numTspecs) {
11912 palCopyMemory(pMac->hHdd, pBuf, (void*)&ccxTspec.tspec[0], (ccxTspec.numTspecs*sizeof(tTspecInfo)));
11913 }
11914 pBuf += sizeof(ccxTspec.tspec);
11915 }
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011916 else
Jeff Johnson295189b2012-06-20 16:38:30 -070011917 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011918 tCCXTspecInfo ccxTspec;
11919 // CCX-Tspec IEs in the ASSOC request is presently not supported
11920 // so nullify the TSPEC parameters
11921 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
11922 palCopyMemory( pMac->hHdd, pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
11923 pBuf += sizeof(tCCXTspecInfo);
11924 }
11925 }
11926#endif // FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011927#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070011928 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011929 if (pMac->roam.configParam.isFastTransitionEnabled
11930#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053011931 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011932#endif
11933 )
Jeff Johnson295189b2012-06-20 16:38:30 -070011934 {
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011935 dwTmp = pal_cpu_to_be32(TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011936 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011937 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070011938 }
11939 else
11940 {
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011941 dwTmp = pal_cpu_to_be32(FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011942 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011943 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070011944 }
11945#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070011946#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053011947 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070011948 {
11949 //legacy fast roaming enabled
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011950 dwTmp = pal_cpu_to_be32(TRUE);
Jeff Johnson43971f52012-07-17 12:26:56 -070011951 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011952 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070011953 }
11954 else
11955 {
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011956 dwTmp = pal_cpu_to_be32(FALSE);
Jeff Johnson43971f52012-07-17 12:26:56 -070011957 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011958 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070011959 }
11960#endif
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011961
11962 // txLdpcIniFeatureEnabled
11963 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
11964 pBuf++;
11965
Kirand170dcb2013-01-31 10:43:43 -080011966 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
11967 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
11968 {
11969 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
11970 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
11971 csrApplyPower2Current(pMac);
11972 }
11973
Shailender Karmuchi31f9ebe2013-01-17 12:51:24 -080011974#ifdef WLAN_FEATURE_11AC
Kirand170dcb2013-01-31 10:43:43 -080011975 // txBFIniFeatureEnabled
11976 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
11977 pBuf++;
Shailender Karmuchi95934c32013-02-16 18:18:33 -080011978
11979 // txBFCsnValue
11980 *pBuf = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
11981 pBuf++;
Shailender Karmuchi31f9ebe2013-01-17 12:51:24 -080011982#endif
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011983 //BssDesc
11984 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
11985 (tANI_U8)pProfile->uapsd_mask);
11986 status = palSendMBMessage(pMac->hHdd, pMsg );
11987 if(!HAL_STATUS_SUCCESS(status))
11988 {
11989 break;
11990 }
11991 else
11992 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011993#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowda071f6082013-01-16 13:39:39 -080011994 if (eWNI_SME_JOIN_REQ == messageType)
11995 {
11996 //Tush-QoS: notify QoS module that join happening
11997 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
11998 }
11999 else if (eWNI_SME_REASSOC_REQ == messageType)
12000 {
12001 //Tush-QoS: notify QoS module that reassoc happening
12002 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
12003 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012004#endif
Srinivas Girigowda071f6082013-01-16 13:39:39 -080012005 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012006 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012007 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070012008}
12009
Jeff Johnson295189b2012-06-20 16:38:30 -070012010//
12011eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12012{
12013 eHalStatus status = eHAL_STATUS_SUCCESS;
12014 tSirSmeDisassocReq *pMsg;
12015 tANI_U8 *pBuf;
12016 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012017 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12018 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12019 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012020 do {
12021 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDisassocReq ));
12022 if ( !HAL_STATUS_SUCCESS(status) ) break;
12023 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDisassocReq ));
12024 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
12025 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012026 pBuf = &pMsg->sessionId;
12027 // sessionId
12028 *pBuf++ = (tANI_U8)sessionId;
12029 // transactionId
12030 *pBuf = 0;
12031 *( pBuf + 1 ) = 0;
12032 pBuf += sizeof(tANI_U16);
12033
Jeff Johnson295189b2012-06-20 16:38:30 -070012034 if ( (pSession->pCurRoamProfile != NULL ) &&
12035 ( reasonCode == eSIR_MAC_UNSPEC_FAILURE_REASON ) &&
12036 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) || (CSR_IS_WDS_AP(pSession->pCurRoamProfile))))
12037 {
12038 // Set the bssid address before sending the message to LIM
12039 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pSession->selfMacAddr, sizeof( tSirMacAddr ) );
12040 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012041 // Set the peer MAC address before sending the message to LIM
12042 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ) ); //perMacAddr is passed as bssId for softAP
12043 pBuf = pBuf + sizeof ( tSirMacAddr );
12044 }
12045 else
12046 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012047 // Set the peer MAC address before sending the message to LIM
12048 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ) );
12049 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012050 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ) );
12051 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012052 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012053 if(!HAL_STATUS_SUCCESS(status))
12054 {
12055 palFreeMemory(pMac->hHdd, pMsg);
12056 break;
12057 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012058 // reasonCode
12059 wTmp = pal_cpu_to_be16(reasonCode);
12060 status = palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12061 if(!HAL_STATUS_SUCCESS(status))
12062 {
12063 palFreeMemory(pMac->hHdd, pMsg);
12064 break;
12065 }
12066 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012067 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
12068 Here we should not send the disassoc over the air to the AP */
12069 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
12070#ifdef WLAN_FEATURE_VOWIFI_11R
12071 && csrRoamIs11rAssoc(pMac)
12072#endif
12073 )
12074 {
12075 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
12076 }
12077 pBuf += sizeof(tANI_U8);
12078 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012079 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012080 return( status );
12081}
Jeff Johnson295189b2012-06-20 16:38:30 -070012082eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
12083{
12084 eHalStatus status = eHAL_STATUS_SUCCESS;
12085 tSirSmeTkipCntrMeasReq *pMsg;
12086 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012087 do
12088 {
12089 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeTkipCntrMeasReq ));
12090 if ( !HAL_STATUS_SUCCESS(status) ) break;
12091 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeTkipCntrMeasReq ));
12092 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
12093 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012094 pBuf = &pMsg->sessionId;
12095 // sessionId
12096 *pBuf++ = (tANI_U8)sessionId;
12097 // transactionId
12098 *pBuf = 0;
12099 *( pBuf + 1 ) = 0;
12100 pBuf += sizeof(tANI_U16);
12101 // bssid
12102 status = palCopyMemory( pMac->hHdd, pMsg->bssId, bssId, sizeof( tSirMacAddr ) );
12103 pBuf = pBuf + sizeof ( tSirMacAddr );
12104 // bEnable
12105 *pBuf = (tANI_BOOLEAN)bEnable;
12106 if(!HAL_STATUS_SUCCESS(status))
12107 {
12108 palFreeMemory(pMac->hHdd, pMsg);
12109 break;
12110 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012111 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012112 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012113 return( status );
12114}
Jeff Johnson295189b2012-06-20 16:38:30 -070012115eHalStatus
12116csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
12117 VOS_MODULE_ID modId, tSirMacAddr bssId,
12118 void *pUsrContext, void *pfnSapEventCallback,
12119 tANI_U8 *pAssocStasBuf )
12120{
12121 eHalStatus status = eHAL_STATUS_SUCCESS;
12122 tSirSmeGetAssocSTAsReq *pMsg;
12123 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
12124 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012125 do
12126 {
12127 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeGetAssocSTAsReq ) );
12128 if (!HAL_STATUS_SUCCESS(status)) break;
12129 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirSmeGetAssocSTAsReq ) );
12130 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012131 pBuf = (tANI_U8 *)&pMsg->bssId;
12132 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012133 // bssId
12134 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr) );
12135 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012136 // modId
12137 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
12138 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
12139 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012140 // pUsrContext
12141 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
12142 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12143 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012144 // pfnSapEventCallback
12145 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
12146 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12147 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012148 // pAssocStasBuf
12149 dwTmp = pal_cpu_to_be32((tANI_U32)pAssocStasBuf);
12150 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12151 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012152 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070012153 status = palSendMBMessage( pMac->hHdd, pMsg );
12154 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012155 return( status );
12156 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012157eHalStatus
12158csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
12159 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
12160 {
12161 eHalStatus status = eHAL_STATUS_SUCCESS;
12162 tSirSmeGetWPSPBCSessionsReq *pMsg;
12163 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
12164 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012165 do
12166 {
12167 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirSmeGetWPSPBCSessionsReq) );
12168 if (!HAL_STATUS_SUCCESS(status)) break;
12169 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ) );
12170 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012171 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
12172 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012173 // pUsrContext
12174 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
12175 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12176 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012177 // pSapEventCallback
12178 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
12179 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12180 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012181 // bssId
12182 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr) );
12183 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012184 // MAC Address of STA in WPS session
12185 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
12186 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070012187 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070012188 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012189 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012190 return( status );
12191}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012192
12193eHalStatus
12194csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
12195{
12196 tpSirChangeBIParams pMsg;
12197 tANI_U16 len = 0;
12198 eHalStatus status = eHAL_STATUS_SUCCESS;
12199 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12200
12201 if(!pSession)
12202 {
12203 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12204 return eHAL_STATUS_FAILURE;
12205 }
12206
12207 //NO need to update the Beacon Params if update beacon parameter flag is not set
12208 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
12209 return eHAL_STATUS_SUCCESS;
12210
12211 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
12212
12213 /* Create the message and send to lim */
12214 len = sizeof(tSirChangeBIParams);
12215 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, len );
12216 if(HAL_STATUS_SUCCESS(status))
12217 {
12218 palZeroMemory(pMac->hHdd, pMsg, sizeof(tSirChangeBIParams) );
12219 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
12220 pMsg->length = len;
12221
12222 // bssId
12223 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
12224 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= %02x-%02x-%02x-%02x-%02x-%02x "),
12225 pMsg->bssId[ 0 ], pMsg->bssId[ 1 ], pMsg->bssId[ 2 ],
12226 pMsg->bssId[ 3 ], pMsg->bssId[ 4 ], pMsg->bssId[ 5 ] );
12227 pMsg->sessionId = sessionId;
12228 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d\n"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
12229 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
12230 status = palSendMBMessage(pMac->hHdd, pMsg);
12231 }
12232 return status;
12233}
12234
Jeff Johnson295189b2012-06-20 16:38:30 -070012235eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12236{
12237 eHalStatus status = eHAL_STATUS_SUCCESS;
12238 tSirSmeDeauthReq *pMsg;
12239 tANI_U8 *pBuf;
12240 tANI_U16 wTmp;
12241 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12242 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12243 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012244 do {
12245 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDeauthReq ));
12246 if ( !HAL_STATUS_SUCCESS(status) ) break;
12247 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDeauthReq ));
12248 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
12249 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
12250 //sessionId
12251 pBuf = &pMsg->sessionId;
12252 *pBuf++ = (tANI_U8)sessionId;
12253
12254 //tansactionId
12255 *pBuf = 0;
12256 *(pBuf + 1 ) = 0;
12257 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012258 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070012259 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070012260 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
12261 // Set the BSSID before sending the message to LIM
12262 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pSession->selfMacAddr, sizeof( pMsg->peerMacAddr ) );
12263 pBuf = pBuf + sizeof(tSirMacAddr);
12264 }
12265 else
12266 {
12267 // Set the BSSID before sending the message to LIM
12268 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
12269 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012270 }
12271 if(!HAL_STATUS_SUCCESS(status))
12272 {
12273 palFreeMemory(pMac->hHdd, pMsg);
12274 break;
12275 }
12276 // Set the peer MAC address before sending the message to LIM
12277 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
12278 pBuf = pBuf + sizeof(tSirMacAddr);
12279 if(!HAL_STATUS_SUCCESS(status))
12280 {
12281 palFreeMemory(pMac->hHdd, pMsg);
12282 break;
12283 }
12284 wTmp = pal_cpu_to_be16(reasonCode);
12285 status = palCopyMemory( pMac->hHdd, pBuf, &wTmp,sizeof( tANI_U16 ) );
12286 if(!HAL_STATUS_SUCCESS(status))
12287 {
12288 palFreeMemory(pMac->hHdd, pMsg);
12289 break;
12290 }
12291 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012292 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012293 return( status );
12294}
12295
Jeff Johnson295189b2012-06-20 16:38:30 -070012296eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
12297{
12298 eHalStatus status = eHAL_STATUS_SUCCESS;
12299 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070012300 do {
12301 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDisassocCnf ));
12302 if ( !HAL_STATUS_SUCCESS(status) ) break;
12303 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDisassocCnf ));
12304 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
12305 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12306 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
12307 status = palCopyMemory(pMac->hHdd, pMsg->peerMacAddr, pDisassocInd->peerMacAddr, sizeof(pMsg->peerMacAddr));
12308 if(!HAL_STATUS_SUCCESS(status))
12309 {
12310 palFreeMemory(pMac->hHdd, pMsg);
12311 break;
12312 }
12313//To test reconn
12314 status = palCopyMemory(pMac->hHdd, pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
12315 if(!HAL_STATUS_SUCCESS(status))
12316 {
12317 palFreeMemory(pMac->hHdd, pMsg);
12318 break;
12319 }
12320//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070012321 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012322 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012323 return( status );
12324}
12325
Jeff Johnson295189b2012-06-20 16:38:30 -070012326eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
12327{
12328 eHalStatus status = eHAL_STATUS_SUCCESS;
12329 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070012330 do {
12331 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDeauthCnf ));
12332 if ( !HAL_STATUS_SUCCESS(status) ) break;
12333 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDeauthCnf ));
12334 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
12335 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12336 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
12337 status = palCopyMemory(pMac->hHdd, pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
12338 if(!HAL_STATUS_SUCCESS(status))
12339 {
12340 palFreeMemory(pMac->hHdd, pMsg);
12341 break;
12342 }
12343 status = palCopyMemory(pMac->hHdd, pMsg->peerMacAddr, pDeauthInd->peerMacAddr, sizeof(pMsg->peerMacAddr));
12344 if(!HAL_STATUS_SUCCESS(status))
12345 {
12346 palFreeMemory(pMac->hHdd, pMsg);
12347 break;
12348 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012349 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012350 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012351 return( status );
12352}
Jeff Johnson295189b2012-06-20 16:38:30 -070012353eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
12354{
12355 eHalStatus status = eHAL_STATUS_SUCCESS;
12356 tSirSmeAssocCnf *pMsg;
12357 tANI_U8 *pBuf;
12358 tSirResultCodes statusCode;
12359 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012360 do {
12361 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeAssocCnf ));
12362 if ( !HAL_STATUS_SUCCESS(status) ) break;
12363 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeAssocCnf ));
12364 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
12365 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012366 pBuf = (tANI_U8 *)&pMsg->statusCode;
12367 if(HAL_STATUS_SUCCESS(Halstatus))
12368 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12369 else
12370 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
12371 palCopyMemory( pMac->hHdd, pBuf, &statusCode, sizeof(tSirResultCodes) );
12372 pBuf += sizeof(tSirResultCodes);
12373 // bssId
12374 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12375 pBuf += sizeof (tSirMacAddr);
12376 // peerMacAddr
12377 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
12378 pBuf += sizeof (tSirMacAddr);
12379 // aid
12380 wTmp = pal_cpu_to_be16(pAssocInd->aid);
12381 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12382 pBuf += sizeof (tANI_U16);
12383 // alternateBssId
12384 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12385 pBuf += sizeof (tSirMacAddr);
12386 // alternateChannelId
12387 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070012388 status = palSendMBMessage( pMac->hHdd, pMsg );
12389 if(!HAL_STATUS_SUCCESS(status))
12390 {
12391 //pMsg is freed by palSendMBMessage
12392 break;
12393 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012394 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012395 return( status );
12396}
Jeff Johnson295189b2012-06-20 16:38:30 -070012397eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
12398 tpSirSmeAssocInd pAssocInd,
12399 eHalStatus Halstatus,
12400 tANI_U8 sessionId)
12401{
12402 tSirMsgQ msgQ;
12403 eHalStatus status = eHAL_STATUS_SUCCESS;
12404 tSirSmeAssocIndToUpperLayerCnf *pMsg;
12405 tANI_U8 *pBuf;
12406 tSirResultCodes statusCode;
12407 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012408 do {
12409 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ));
12410 if ( !HAL_STATUS_SUCCESS(status) ) break;
12411 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ));
Jeff Johnsone7245742012-09-05 17:12:55 -070012412
Jeff Johnson295189b2012-06-20 16:38:30 -070012413 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
12414 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
12415
12416 pMsg->sessionId = sessionId;
12417
12418 pBuf = (tANI_U8 *)&pMsg->statusCode;
12419 if(HAL_STATUS_SUCCESS(Halstatus))
12420 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12421 else
12422 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
12423 palCopyMemory( pMac->hHdd, pBuf, &statusCode, sizeof(tSirResultCodes) );
12424 pBuf += sizeof(tSirResultCodes);
12425 // bssId
12426 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12427 pBuf += sizeof (tSirMacAddr);
12428 // peerMacAddr
12429 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
12430 pBuf += sizeof (tSirMacAddr);
12431 // StaId
12432 wTmp = pal_cpu_to_be16(pAssocInd->staId);
12433 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12434 pBuf += sizeof (tANI_U16);
12435 // alternateBssId
12436 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12437 pBuf += sizeof (tSirMacAddr);
12438 // alternateChannelId
12439 *pBuf = 11;
12440 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012441 // Instead of copying roam Info, we just copy only WmmEnabled , RsnIE information
12442 //Wmm
12443 *pBuf = pAssocInd->wmmEnabledSta;
12444 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012445 //RSN IE
12446 status = palCopyMemory(pMac->hHdd, (tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
12447 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070012448 //Additional IE
12449 status = palCopyMemory(pMac->hHdd, (void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
12450 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070012451 //reassocReq
12452 *pBuf = pAssocInd->reassocReq;
12453 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012454 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
12455 msgQ.bodyptr = pMsg;
12456 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012457 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012458 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012459 return( status );
12460}
Jeff Johnson295189b2012-06-20 16:38:30 -070012461
Jeff Johnson295189b2012-06-20 16:38:30 -070012462eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId ,
12463 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
12464 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
12465 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
12466 tANI_U8 *pKeyRsc )
12467{
12468 tSirSmeSetContextReq *pMsg;
12469 tANI_U16 msgLen;
12470 eHalStatus status = eHAL_STATUS_FAILURE;
12471 tAniEdType tmpEdType;
12472 tAniKeyDirection tmpDirection;
12473 tANI_U8 *pBuf;
12474 tANI_U8 *p;
12475 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012476 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070012477 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012478 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
12479 // key set. Since we only support upto one key, we always allocate memory for 1 key
12480 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
12481 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
12482 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
12483 ( sizeof( pMsg->keyMaterial.key ) );
12484
12485 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12486 if ( !HAL_STATUS_SUCCESS(status) ) break;
12487 palZeroMemory(pMac->hHdd, pMsg, msgLen);
12488 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
12489 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012490 //sessionId
12491 pBuf = &pMsg->sessionId;
12492 *pBuf = (tANI_U8)sessionId;
12493 pBuf++;
12494 // transactionId
12495 *pBuf = 0;
12496 *(pBuf + 1) = 0;
12497 pBuf += sizeof(tANI_U16);
12498 // peerMacAddr
12499 palCopyMemory( pMac->hHdd, pBuf,
12500 (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr) );
12501
12502 pBuf += sizeof(tSirMacAddr);
12503
12504 // bssId
12505 palCopyMemory( pMac->hHdd, pBuf,
12506 (tANI_U8 *)&pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
12507
12508 pBuf += sizeof(tSirMacAddr);
12509
12510 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012511 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
12512 // in the tSirKeyMaterial keyMaterial; field).
12513 //
12514 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
12515 // shorter than this max size. Is LIM interpreting this ok ?
12516 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 -070012517 // set pMsg->keyMaterial.edType
12518 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
12519 palCopyMemory( pMac->hHdd, p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType) );
12520 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070012521 // set the pMsg->keyMaterial.numKeys field
12522 *p = numKeys;
12523 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070012524 // set pSirKey->keyId = keyId;
12525 *p = keyId;
12526 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012527 // set pSirKey->unicast = (tANI_U8)fUnicast;
12528 *p = (tANI_U8)fUnicast;
12529 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070012530 // set pSirKey->keyDirection = aniKeyDirection;
12531 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
12532 palCopyMemory( pMac->hHdd, p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection) );
12533 p += sizeof(tAniKeyDirection);
12534 // pSirKey->keyRsc = ;;
12535 palCopyMemory( pMac->hHdd, p, pKeyRsc, CSR_MAX_RSC_LEN );
12536 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070012537 // set pSirKey->paeRole
12538 *p = paeRole; // 0 is Supplicant
12539 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012540 // set pSirKey->keyLength = keyLength;
12541 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070012542 if ( keyLength && pKey )
12543 {
12544 palCopyMemory( pMac->hHdd, p, pKey, keyLength );
12545 if(keyLength == 16)
12546 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -070012547 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\n",
Jeff Johnson295189b2012-06-20 16:38:30 -070012548 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
12549 pKey[5], pKey[6], pKey[7], pKey[8],
12550 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
12551 }
12552 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012553 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012554 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012555 return( status );
12556}
12557
Jeff Johnson295189b2012-06-20 16:38:30 -070012558eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
12559 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
12560{
12561 eHalStatus status;
12562 tSirSmeStartBssReq *pMsg;
12563 tANI_U8 *pBuf = NULL;
12564 tANI_U8 *wTmpBuf = NULL;
12565 tANI_U16 msgLen, wTmp;
12566 tANI_U32 dwTmp;
12567 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070012568 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012569 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070012570 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012571
12572 if(!pSession)
12573 {
12574 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12575 return eHAL_STATUS_FAILURE;
12576 }
12577
Jeff Johnson295189b2012-06-20 16:38:30 -070012578 do {
12579 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12580 pSession->joinFailStatusCode.reasonCode = 0;
12581 msgLen = sizeof(tSirSmeStartBssReq);
12582 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12583 if ( !HAL_STATUS_SUCCESS(status) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012584 palZeroMemory(pMac->hHdd, pMsg, msgLen);
12585 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012586 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012587 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012588 //sessionId
12589 *pBuf = (tANI_U8)sessionId;
12590 pBuf++;
12591 // transactionId
12592 *pBuf = 0;
12593 *(pBuf + 1) = 0;
12594 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012595 // bssid
12596 palCopyMemory( pMac->hHdd, pBuf, pParam->bssid, sizeof(tSirMacAddr) );
12597 pBuf += sizeof(tSirMacAddr);
12598 // selfMacAddr
12599 palCopyMemory( pMac->hHdd, pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr) );
12600 pBuf += sizeof(tSirMacAddr);
12601 // beaconInterval
12602 if( pBssDesc && pBssDesc->beaconInterval )
12603 {
12604 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
12605 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012606 else if(pParam->beaconInterval)
12607 {
12608 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
12609 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012610 else
12611 {
12612 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
12613 }
Jeff Johnsone7245742012-09-05 17:12:55 -070012614 if(csrIsconcurrentsessionValid (pMac, sessionId,
12615 pParam->bssPersona)
12616 == eHAL_STATUS_SUCCESS )
12617 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012618 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070012619 pParam->bssPersona);
12620 //Update the beacon Interval
12621 pParam->beaconInterval = wTmp;
12622 }
12623 else
12624 {
12625 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***\n"));
12626 status = eHAL_STATUS_FAILURE;
12627 return status;
12628 }
12629
Jeff Johnson295189b2012-06-20 16:38:30 -070012630 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof( tANI_U16 ) );
12631 pBuf += sizeof(tANI_U16);
12632 // dot11mode
12633 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
12634 pBuf += 1;
12635 // bssType
12636 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
12637 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tSirBssType) );
12638 pBuf += sizeof(tSirBssType);
12639 // ssId
12640 if( pParam->ssId.length )
12641 {
12642 // ssId len
12643 *pBuf = pParam->ssId.length;
12644 pBuf++;
12645 palCopyMemory( pMac->hHdd, pBuf, pParam->ssId.ssId, pParam->ssId.length );
12646 pBuf += pParam->ssId.length;
12647 }
12648 else
12649 {
12650 *pBuf = 0;
12651 pBuf++;
12652 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012653 // set the channel Id
12654 *pBuf = pParam->operationChn;
12655 pBuf++;
12656 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070012657 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
12658 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState) );
12659 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070012660
Jeff Johnson295189b2012-06-20 16:38:30 -070012661 // Set privacy
12662 *pBuf = pParam->privacy;
12663 pBuf++;
12664
12665 //Set Uapsd
12666 *pBuf = pParam->ApUapsdEnable;
12667 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012668 //Set SSID hidden
12669 *pBuf = pParam->ssidHidden;
12670 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012671 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
12672 pBuf++;
12673
12674 //Ht protection Enable/Disable
12675 *pBuf = (tANI_U8)pParam->protEnabled;
12676 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012677 //Enable Beacons to Receive for OBSS protection Enable/Disable
12678 *pBuf = (tANI_U8)pParam->obssProtEnabled;
12679 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012680 //set cfg related to protection
12681 wTmp = pal_cpu_to_be16( pParam->ht_protection );
12682 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof( tANI_U16 ) );
12683 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012684 // Set Auth type
12685 authType = pal_cpu_to_be32(pParam->authType);
12686 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
12687 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012688 // Set DTIM
12689 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
12690 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12691 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012692 // Set wps_state
12693 *pBuf = pParam->wps_state;
12694 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012695 //Persona
12696 *pBuf = (tANI_U8)pParam->bssPersona;
12697 pBuf++;
12698
Gopichand Nakkalab7ed0a62013-01-04 11:41:02 -080012699 //txLdpcIniFeatureEnabled
12700 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
12701 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070012702
Jeff Johnson295189b2012-06-20 16:38:30 -070012703
12704 // set RSN IE
12705 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
12706 {
12707 status = eHAL_STATUS_INVALID_PARAMETER;
12708 palFreeMemory( pMac->hHdd, pMsg );
12709 break;
12710 }
12711 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
12712 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12713 pBuf += sizeof(tANI_U16);
12714 if( wTmp )
12715 {
12716 wTmp = pParam->nRSNIELength;
12717 palCopyMemory( pMac->hHdd, pBuf, pParam->pRSNIE, wTmp );
12718 pBuf += wTmp;
12719 }
12720 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
12721 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType) );
12722 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012723 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
12724 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012725 palCopyMemory( pMac->hHdd, pBuf, pParam->operationalRateSet.rate, pParam->operationalRateSet.numRates );
12726 pBuf += pParam->operationalRateSet.numRates ;
12727 *pBuf++ = pParam->extendedRateSet.numRates;
12728 if(0 != pParam->extendedRateSet.numRates)
12729 {
12730 palCopyMemory( pMac->hHdd, pBuf, pParam->extendedRateSet.rate, pParam->extendedRateSet.numRates );
12731 pBuf += pParam->extendedRateSet.numRates;
12732 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012733 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
12734 pMsg->length = pal_cpu_to_be16(msgLen);
12735
12736 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012737 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012738 return( status );
12739}
12740
Jeff Johnson295189b2012-06-20 16:38:30 -070012741eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
12742{
12743 eHalStatus status = eHAL_STATUS_FAILURE;
12744 tSirSmeStopBssReq *pMsg;
12745 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12746 tANI_U8 *pBuf;
12747 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012748
12749 if(!pSession)
12750 {
12751 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12752 return eHAL_STATUS_FAILURE;
12753 }
12754
Jeff Johnson295189b2012-06-20 16:38:30 -070012755 do {
12756 status = palAllocateMemory(pMac, (void **)&pMsg, sizeof(tSirSmeStopBssReq));
12757 if ( !HAL_STATUS_SUCCESS(status) ) break;
12758 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeStopBssReq ));
12759 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
12760 pBuf = &pMsg->sessionId;
12761 //sessionId
12762 *pBuf = (tANI_U8)sessionId;
12763 pBuf++;
12764 // transactionId
12765 *pBuf = 0;
12766 pBuf += sizeof(tANI_U16);
12767 //reason code
12768 *pBuf = 0;
12769 pBuf += sizeof(tSirResultCodes);
12770 // bssid
12771 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
12772 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
12773 {
12774 palCopyMemory( pMac->hHdd, pBuf,(tANI_U8 *)&pSession->selfMacAddr, sizeof(tSirMacAddr) );
12775 }
12776 else
12777 {
12778 palCopyMemory( pMac->hHdd, pBuf,(tANI_U8 *)&pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
12779 }
12780 pBuf += sizeof(tSirMacAddr);
12781 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
12782 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012783 status = palSendMBMessage( pMac->hHdd, pMsg );
12784#if 0
12785 status = palAllocateMemory(pMac, (void **)&pMsg, sizeof(tSirSmeStopBssReq));
12786 if ( !HAL_STATUS_SUCCESS(status) ) break;
12787 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeStopBssReq ));
12788 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
12789 pMsg->reasonCode = 0;
12790 // bssid
12791 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
12792 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
12793 {
12794 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
12795 }
12796 else
12797 {
12798 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
12799 }
12800 palCopyMemory( pMac->hHdd, &pMsg->bssId, pbBssid, sizeof(tSirMacAddr) );
12801 pMsg->transactionId = 0;
12802 pMsg->sessionId = (tANI_U8)sessionId;
12803 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
12804 status = palSendMBMessage( pMac->hHdd, pMsg );
12805#endif
12806 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012807 return( status );
12808}
12809
Jeff Johnson295189b2012-06-20 16:38:30 -070012810eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
12811 tCsrRoamModifyProfileFields *pModProfileFields,
12812 tANI_U32 *pRoamId, v_BOOL_t fForce)
12813{
Jeff Johnson295189b2012-06-20 16:38:30 -070012814 eHalStatus status = eHAL_STATUS_FAILURE;
12815 tANI_U32 roamId = 0;
12816 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012817 if((csrIsConnStateConnected(pMac, sessionId)) &&
12818 (fForce || (!palEqualMemory(pMac->hHdd, &pModProfileFields,
12819 &pSession->connectedProfile.modifyProfileFields,
12820 sizeof(tCsrRoamModifyProfileFields)))) )
12821 {
12822 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
12823 if(pRoamId)
12824 {
12825 *pRoamId = roamId;
12826 }
12827
Jeff Johnson295189b2012-06-20 16:38:30 -070012828 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
12829 eCsrSmeIssuedReassocToSameAP, roamId,
12830 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012831 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012832 return status;
12833}
Jeff Johnson295189b2012-06-20 16:38:30 -070012834static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
12835{
12836 eHalStatus status = eHAL_STATUS_SUCCESS;
12837 tCsrRoamInfo roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070012838 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
12839 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
12840 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
12841 return (status);
12842}
Jeff Johnson295189b2012-06-20 16:38:30 -070012843eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
12844{
12845 eHalStatus status = eHAL_STATUS_SUCCESS;
12846 tListElem *pEntry = NULL;
12847 tSmeCmd *pCommand = NULL;
12848 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012849 do
12850 {
12851 if(pMsg == NULL)
12852 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012853 smsLog(pMac, LOGE, "in %s msg ptr is NULL\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012854 status = eHAL_STATUS_FAILURE;
12855 break;
12856 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012857 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
12858 if(pEntry)
12859 {
12860 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
12861 if(eSmeCommandAddStaSession == pCommand->command)
12862 {
12863 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
12864 smsLog( pMac, LOG1, "Add Sta rsp status = %d\n", pRsp->status );
12865 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070012866 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070012867 //Remove this command out of the active list
12868 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
12869 {
12870 //Now put this command back on the avilable command list
12871 csrReleaseCommand(pMac, pCommand);
12872 }
12873 smeProcessPendingQueue( pMac );
12874 }
12875 else
12876 {
12877 smsLog(pMac, LOGE, "in %s eWNI_SME_ADD_STA_SELF_RSP Received but NO Add sta session command are ACTIVE ...\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012878 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012879 status = eHAL_STATUS_FAILURE;
12880 break;
12881 }
12882 }
12883 else
12884 {
12885 smsLog(pMac, LOGE, "in %s eWNI_SME_ADD_STA_SELF_RSP Received but NO commands are ACTIVE ...\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012886 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012887 status = eHAL_STATUS_FAILURE;
12888 break;
12889 }
12890 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012891 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012892}
Jeff Johnson295189b2012-06-20 16:38:30 -070012893eHalStatus csrSendMBAddSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
12894{
12895 tSirSmeAddStaSelfReq *pMsg;
12896 tANI_U16 msgLen;
12897 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012898 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070012899 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
12900 sizeof( tSirBssType )*/;
Jeff Johnson295189b2012-06-20 16:38:30 -070012901 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12902 if ( !HAL_STATUS_SUCCESS(status) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012903 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012904 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
12905 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012906 // self station address
12907 palCopyMemory( pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr, sizeof(tSirMacAddr) );
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -070012908 smsLog( pMac, LOG1, FL("selfMac=%02x, %02x, %02x, %02x, %02x, %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -070012909 pMsg->selfMacAddr[0],
12910 pMsg->selfMacAddr[1],
12911 pMsg->selfMacAddr[2],
12912 pMsg->selfMacAddr[3],
12913 pMsg->selfMacAddr[4],
12914 pMsg->selfMacAddr[5]);
12915 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012916 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012917 return( status );
12918}
Jeff Johnson295189b2012-06-20 16:38:30 -070012919eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr sessionMacAddr)
12920{
12921 eHalStatus status = eHAL_STATUS_SUCCESS;
12922 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070012923 pCommand = csrGetCommandBuffer(pMac);
12924 if(NULL == pCommand)
12925 {
12926 status = eHAL_STATUS_RESOURCES;
12927 }
12928 else
12929 {
12930 pCommand->command = eSmeCommandAddStaSession;
12931 pCommand->sessionId = (tANI_U8)sessionId;
12932 palCopyMemory( pMac->hHdd, pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr, sizeof( tSirMacAddr ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070012933 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
12934 if( !HAL_STATUS_SUCCESS( status ) )
12935 {
12936 //Should be panic??
12937 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
12938 }
12939 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012940 return (status);
12941}
Jeff Johnson295189b2012-06-20 16:38:30 -070012942eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
12943{
12944 return csrSendMBAddSelfStaReqMsg( pMac,
12945 pCommand->u.addStaSessionCmd.selfMacAddr );
12946}
Jeff Johnson295189b2012-06-20 16:38:30 -070012947eHalStatus csrRoamOpenSession( tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext,
12948 tANI_U8 *pSelfMacAddr, tANI_U8 *pbSessionId )
12949{
12950 eHalStatus status = eHAL_STATUS_SUCCESS;
12951 tANI_U32 i;
12952 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070012953 *pbSessionId = CSR_SESSION_ID_INVALID;
12954 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
12955 {
12956 if( !CSR_IS_SESSION_VALID( pMac, i ) )
12957 {
12958 pSession = CSR_GET_SESSION( pMac, i );
12959 status = eHAL_STATUS_SUCCESS;
12960 pSession->sessionActive = eANI_BOOLEAN_TRUE;
12961 pSession->sessionId = (tANI_U8)i;
12962 pSession->callback = callback;
12963 pSession->pContext = pContext;
12964 palCopyMemory( pMac->hHdd, &pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid) );
12965 *pbSessionId = (tANI_U8)i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012966 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerRoaming, csrRoamRoamingTimerHandler,
12967 &pSession->roamingTimerInfo);
12968 if(!HAL_STATUS_SUCCESS(status))
12969 {
12970 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer\n"));
12971 break;
12972 }
12973#ifdef FEATURE_WLAN_BTAMP_UT_RF
12974 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerJoinRetry, csrRoamJoinRetryTimerHandler,
12975 &pSession->joinRetryTimerInfo);
12976 if(!HAL_STATUS_SUCCESS(status))
12977 {
12978 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer\n"));
12979 break;
12980 }
12981#endif
12982 pSession->ibssJoinTimerInfo.pMac = pMac;
12983 pSession->ibssJoinTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Jeff Johnson295189b2012-06-20 16:38:30 -070012984 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerIbssJoining, csrRoamIbssJoinTimerHandler,
12985 &pSession->ibssJoinTimerInfo);
12986 if(!HAL_STATUS_SUCCESS(status))
12987 {
12988 smsLog(pMac, LOGE, FL("cannot allocate memory for IbssJoining timer\n"));
12989 break;
12990 }
12991 status = csrIssueAddStaForSessionReq ( pMac, i, pSelfMacAddr );
12992 break;
12993 }
12994 }
12995 if( CSR_ROAM_SESSION_MAX == i )
12996 {
12997 //No session is available
12998 status = eHAL_STATUS_RESOURCES;
12999 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013000 return ( status );
13001}
Jeff Johnson295189b2012-06-20 16:38:30 -070013002eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13003{
13004 eHalStatus status = eHAL_STATUS_SUCCESS;
13005 tListElem *pEntry = NULL;
13006 tSmeCmd *pCommand = NULL;
13007 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013008 do
13009 {
13010 if(pMsg == NULL)
13011 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013012 smsLog(pMac, LOGE, "in %s msg ptr is NULL\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013013 status = eHAL_STATUS_FAILURE;
13014 break;
13015 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013016 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
13017 if(pEntry)
13018 {
13019 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13020 if(eSmeCommandDelStaSession == pCommand->command)
13021 {
13022 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013023 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
13024 smsLog( pMac, LOG1, "Del Sta rsp status = %d\n", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013025 //This session is done.
13026 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013027 if(pCommand->u.delStaSessionCmd.callback)
13028 {
13029
13030 status = sme_ReleaseGlobalLock( &pMac->sme );
13031 if ( HAL_STATUS_SUCCESS( status ) )
13032 {
13033 pCommand->u.delStaSessionCmd.callback(
13034 pCommand->u.delStaSessionCmd.pContext);
13035 status = sme_AcquireGlobalLock( &pMac->sme );
13036 if (! HAL_STATUS_SUCCESS( status ) )
13037 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013038 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013039 return status;
13040 }
13041 }
13042 else {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013043 smsLog(pMac, LOGE, "%s: Failed to Release Lock\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013044 }
13045 }
13046
13047 //Remove this command out of the active list
13048 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
13049 {
13050 //Now put this command back on the avilable command list
13051 csrReleaseCommand(pMac, pCommand);
13052 }
13053 smeProcessPendingQueue( pMac );
13054 }
13055 else
13056 {
13057 smsLog(pMac, LOGE, "in %s eWNI_SME_DEL_STA_SELF_RSP Received but NO Del sta session command are ACTIVE ...\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013058 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013059 status = eHAL_STATUS_FAILURE;
13060 break;
13061 }
13062 }
13063 else
13064 {
13065 smsLog(pMac, LOGE, "in %s eWNI_SME_DEL_STA_SELF_RSP Received but NO commands are ACTIVE ...\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013066 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013067 status = eHAL_STATUS_FAILURE;
13068 break;
13069 }
13070 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013071 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013072}
Jeff Johnson295189b2012-06-20 16:38:30 -070013073eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
13074{
13075 tSirSmeDelStaSelfReq *pMsg;
13076 tANI_U16 msgLen;
13077 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013078 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013079 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
13080 sizeof( tSirBssType )*/;
Jeff Johnson295189b2012-06-20 16:38:30 -070013081 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
13082 if ( !HAL_STATUS_SUCCESS(status) ) break;
13083
13084 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013085 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
13086 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013087 // self station address
13088 palCopyMemory( pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr, sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013089 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013090 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013091 return( status );
13092}
Jeff Johnson295189b2012-06-20 16:38:30 -070013093eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
13094 tSirMacAddr sessionMacAddr,
13095 csrRoamSessionCloseCallback callback,
13096 void *pContext)
13097{
13098 eHalStatus status = eHAL_STATUS_SUCCESS;
13099 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070013100 pCommand = csrGetCommandBuffer(pMac);
13101 if(NULL == pCommand)
13102 {
13103 status = eHAL_STATUS_RESOURCES;
13104 }
13105 else
13106 {
13107 pCommand->command = eSmeCommandDelStaSession;
13108 pCommand->sessionId = (tANI_U8)sessionId;
13109 pCommand->u.delStaSessionCmd.callback = callback;
13110 pCommand->u.delStaSessionCmd.pContext = pContext;
13111 palCopyMemory( pMac->hHdd, pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr, sizeof( tSirMacAddr ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013112 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
13113 if( !HAL_STATUS_SUCCESS( status ) )
13114 {
13115 //Should be panic??
13116 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
13117 }
13118 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013119 return (status);
13120}
Jeff Johnson295189b2012-06-20 16:38:30 -070013121eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
13122{
13123 return csrSendMBDelSelfStaReqMsg( pMac,
13124 pCommand->u.delStaSessionCmd.selfMacAddr );
13125}
Jeff Johnson295189b2012-06-20 16:38:30 -070013126static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
13127{
13128 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
13129 tListElem *pEntry, *pNext;
13130 tSmeCmd *pCommand;
13131 tDblLinkList localList;
13132
13133 vos_mem_zero(&localList, sizeof(tDblLinkList));
13134 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
13135 {
13136 smsLog(pMac, LOGE, FL(" failed to open list"));
13137 return;
13138 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013139 csrLLLock(pList);
13140 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
13141 while(pEntry != NULL)
13142 {
13143 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
13144 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13145 if(pCommand->sessionId == sessionId)
13146 {
13147 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
13148 {
13149 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
13150 }
13151 }
13152 pEntry = pNext;
13153 }
13154 csrLLUnlock(pList);
13155
13156 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
13157 {
13158 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13159 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
13160 }
13161 csrLLClose(&localList);
13162}
13163
Jeff Johnson295189b2012-06-20 16:38:30 -070013164void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
13165{
13166 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13167 {
13168 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013169 csrRoamStop(pMac, sessionId);
13170 csrFreeConnectBssDesc(pMac, sessionId);
13171 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
13172 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
13173 palTimerFree(pMac->hHdd, pSession->hTimerRoaming);
13174#ifdef FEATURE_WLAN_BTAMP_UT_RF
13175 palTimerFree(pMac->hHdd, pSession->hTimerJoinRetry);
13176#endif
13177 palTimerFree(pMac->hHdd, pSession->hTimerIbssJoining);
13178 purgeSmeSessionCmdList(pMac, sessionId);
13179 purgeCsrSessionCmdList(pMac, sessionId);
13180 csrInitSession(pMac, sessionId);
13181 }
13182}
13183
Jeff Johnson295189b2012-06-20 16:38:30 -070013184eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
13185 tANI_BOOLEAN fSync,
13186 csrRoamSessionCloseCallback callback,
13187 void *pContext )
13188{
13189 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013190 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13191 {
13192 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13193 if(fSync)
13194 {
13195 csrCleanupSession(pMac, sessionId);
13196 }
13197 else
13198 {
13199 purgeSmeSessionCmdList(pMac, sessionId);
13200 purgeCsrSessionCmdList(pMac, sessionId);
13201 status = csrIssueDelStaForSessionReq( pMac, sessionId,
13202 pSession->selfMacAddr, callback, pContext);
13203 }
13204 }
13205 else
13206 {
13207 status = eHAL_STATUS_INVALID_PARAMETER;
13208 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013209 return ( status );
13210}
13211
Jeff Johnson295189b2012-06-20 16:38:30 -070013212static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
13213{
13214 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013215
13216 if(!pSession)
13217 {
13218 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13219 return;
13220 }
13221
Jeff Johnson295189b2012-06-20 16:38:30 -070013222 pSession->sessionActive = eANI_BOOLEAN_FALSE;
13223 pSession->sessionId = CSR_SESSION_ID_INVALID;
13224 pSession->callback = NULL;
13225 pSession->pContext = NULL;
13226 pSession->ibss_join_pending = FALSE;
13227 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
13228 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
13229 csrFreeRoamProfile( pMac, sessionId );
13230 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
13231 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
13232 csrFreeConnectBssDesc(pMac, sessionId);
13233 csrScanEnable(pMac);
13234 palZeroMemory( pMac->hHdd, &pSession->selfMacAddr, sizeof(tCsrBssid) );
13235 if(pSession->pWpaRsnReqIE)
13236 {
13237 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
13238 pSession->pWpaRsnReqIE = NULL;
13239 }
13240 pSession->nWpaRsnReqIeLength = 0;
13241 if(pSession->pWpaRsnRspIE)
13242 {
13243 palFreeMemory(pMac->hHdd, pSession->pWpaRsnRspIE);
13244 pSession->pWpaRsnRspIE = NULL;
13245 }
13246 pSession->nWpaRsnRspIeLength = 0;
13247#ifdef FEATURE_WLAN_WAPI
13248 if(pSession->pWapiReqIE)
13249 {
13250 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
13251 pSession->pWapiReqIE = NULL;
13252 }
13253 pSession->nWapiReqIeLength = 0;
13254 if(pSession->pWapiRspIE)
13255 {
13256 palFreeMemory(pMac->hHdd, pSession->pWapiRspIE);
13257 pSession->pWapiRspIE = NULL;
13258 }
13259 pSession->nWapiRspIeLength = 0;
13260#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070013261 if(pSession->pAddIEScan)
13262 {
13263 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
13264 pSession->pAddIEScan = NULL;
13265 }
13266 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013267 if(pSession->pAddIEAssoc)
13268 {
13269 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
13270 pSession->pAddIEAssoc = NULL;
13271}
13272 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013273}
13274
Jeff Johnson295189b2012-06-20 16:38:30 -070013275eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
13276{
13277 eHalStatus status = eHAL_STATUS_FAILURE;
13278 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070013279 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13280 {
13281 if( CSR_IS_SESSION_VALID( pMac, i ) )
13282 {
13283 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
13284 {
13285 //Found it
13286 status = eHAL_STATUS_SUCCESS;
13287 *pSessionId = i;
13288 break;
13289 }
13290 }
13291 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013292 return( status );
13293}
13294
Jeff Johnson295189b2012-06-20 16:38:30 -070013295//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
13296//session because for IBSS, the bssid changes.
13297static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
13298{
13299 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
13300 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070013301 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13302 {
13303 if( CSR_IS_SESSION_VALID( pMac, i ) )
13304 {
13305 pSession = CSR_GET_SESSION( pMac, i );
13306 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
13307 {
13308 //Found it
13309 nRet = i;
13310 break;
13311 }
13312 }
13313 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013314 return (nRet);
13315}
Jeff Johnson295189b2012-06-20 16:38:30 -070013316static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
13317{
13318 /* Update the current BSS info in ho control block based on connected
13319 profile info from pmac global structure */
13320
Jeff Johnson295189b2012-06-20 16:38:30 -070013321 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= %02x-%02x-%02x-%02x-%02x-%02x\n",
13322 bssid[ 0 ], bssid[ 1 ], bssid[ 2 ],
13323 bssid[ 3 ], bssid[ 4 ], bssid[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -070013324 /* Check for user misconfig of RSSI trigger threshold */
13325 pMac->roam.configParam.vccRssiThreshold =
13326 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
13327 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
13328 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070013329 /* Check for user misconfig of UL MAC Loss trigger threshold */
13330 pMac->roam.configParam.vccUlMacLossThreshold =
13331 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
13332 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070013333#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13334 {
13335 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013336 /* Indicate the neighbor roal algorithm about the connect indication */
13337 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
13338 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
13339 }
13340#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013341}
13342
Jeff Johnson295189b2012-06-20 16:38:30 -070013343static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
13344{
13345 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013346
13347 if(!pSession)
13348 {
13349 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13350 return;
13351 }
13352
Jeff Johnson295189b2012-06-20 16:38:30 -070013353 //Only to handle the case for Handover on infra link
13354 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
13355 {
13356 return;
13357 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013358 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
13359 csrRoamDeregStatisticsReq(pMac);
13360 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
13361#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13362 /* Indicate the neighbor roal algorithm about the disconnect indication */
13363 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
13364#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070013365
13366 //Remove this code once SLM_Sessionization is supported
13367 //BMPS_WORKAROUND_NOT_NEEDED
13368 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070013369 csrIsInfraApStarted( pMac ) &&
13370 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070013371 {
13372 pMac->roam.configParam.doBMPSWorkaround = 0;
13373 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013374}
13375
Jeff Johnson295189b2012-06-20 16:38:30 -070013376void csrRoamTlStatsTimerHandler(void *pv)
13377{
13378 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
13379 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013380 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
13381
Jeff Johnsone7245742012-09-05 17:12:55 -070013382 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
13383
Jeff Johnson295189b2012-06-20 16:38:30 -070013384#if 0
13385 // TODO Persession .???
13386 //req TL for stats
13387 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
13388 {
13389 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL\n"));
13390 }
13391 else
13392 {
13393 //save in SME
13394 csrRoamSaveStatsFromTl(pMac, tlStats);
13395 }
13396#endif
13397 if(!pMac->roam.tlStatsReqInfo.timerRunning)
13398 {
13399 if(pMac->roam.tlStatsReqInfo.periodicity)
13400 {
13401 //start timer
13402 status = palTimerStart(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer,
13403 pMac->roam.tlStatsReqInfo.periodicity * PAL_TIMER_TO_MS_UNIT, eANI_BOOLEAN_FALSE);
13404 if(!HAL_STATUS_SUCCESS(status))
13405 {
13406 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer\n"));
13407 return;
13408 }
13409 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
13410 }
13411 }
13412}
Jeff Johnson295189b2012-06-20 16:38:30 -070013413void csrRoamPeStatsTimerHandler(void *pv)
13414{
13415 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
13416 eHalStatus status;
13417 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
13418 VOS_STATUS vosStatus;
13419 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070013420 pPeStatsReqListEntry->timerRunning = FALSE;
13421 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
13422 {
13423 // If we entered here, meaning the timer could not be successfully
13424 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
13425
13426 /* Destroy the timer */
13427 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
13428 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13429 {
13430 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer\n"));
13431 }
13432
13433 // Free the entry
13434 palFreeMemory(pMac->hHdd, pPeStatsReqListEntry);
13435 pPeStatsReqListEntry = NULL;
13436 }
13437 else
13438 {
13439 if(!pPeStatsReqListEntry->rspPending)
13440 {
13441 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
13442 pPeStatsReqListEntry->staId);
13443 if(!HAL_STATUS_SUCCESS(status))
13444 {
13445 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE\n"));
13446 }
13447 else
13448 {
13449 pPeStatsReqListEntry->rspPending = TRUE;
13450 }
13451 }
13452
13453 //send down a req
13454 if(pPeStatsReqListEntry->periodicity &&
13455 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
13456 {
13457 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
13458 if(ePMC_FULL_POWER == powerState)
13459 {
13460 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
13461 {
13462 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
13463 }
13464 }
13465 else
13466 {
13467 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
13468 {
13469 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
13470 }
13471 }
13472 //start timer
13473 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
13474 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13475 {
13476 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer\n"));
13477 return;
13478 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013479 pPeStatsReqListEntry->timerRunning = TRUE;
13480
13481 }
13482
13483 }
13484}
Jeff Johnson295189b2012-06-20 16:38:30 -070013485void csrRoamStatsClientTimerHandler(void *pv)
13486{
13487 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070013488 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
13489 {
13490#if 0
13491 // TODO Stats fix for multisession
13492 //start the timer
13493 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
13494
13495 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13496 {
13497 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013498 }
13499#endif
13500 }
13501#if 0
13502 //send up the stats report
13503 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
13504 pStaEntry->staId, pStaEntry->pContext);
13505#endif
13506}
13507
13508
13509
Jeff Johnson295189b2012-06-20 16:38:30 -070013510eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
13511{
13512 tAniGetPEStatsReq *pMsg;
13513 eHalStatus status = eHAL_STATUS_SUCCESS;
13514 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetPEStatsReq));
13515 if ( !HAL_STATUS_SUCCESS(status) )
13516 {
13517 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to allocate mem for stats req \n");
13518 return status;
13519 }
13520 // need to initiate a stats request to PE
13521 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
13522 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
13523 pMsg->staId = staId;
13524 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070013525 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013526 if(!HAL_STATUS_SUCCESS(status))
13527 {
13528 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to send down the stats req \n");
13529 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013530 return status;
13531}
Jeff Johnson295189b2012-06-20 16:38:30 -070013532void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
13533{
13534 tAniGetPEStatsRsp *pSmeStatsRsp;
13535 eHalStatus status = eHAL_STATUS_FAILURE;
13536 tListElem *pEntry = NULL;
13537 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
13538 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
13539 tANI_U32 tempMask = 0;
13540 tANI_U8 counter = 0;
13541 tANI_U8 *pStats = NULL;
13542 tANI_U32 length = 0;
13543 v_PVOID_t pvosGCtx;
13544 v_S7_t rssi = 0;
13545 tANI_U32 *pRssi = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013546 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
13547 if(pSmeStatsRsp->rc)
13548 {
13549 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure\n"));
13550 goto post_update;
13551 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013552 tempMask = pSmeStatsRsp->statsMask;
13553 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070013554 /* subtract all statistics from this length, and after processing the entire
13555 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
13556 * in this 'stats' message.
13557 */
13558 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070013559 //new stats info from PE, fill up the stats strucutres in PMAC
13560 while(tempMask)
13561 {
13562 if(tempMask & 1)
13563 {
13564 switch(counter)
13565 {
13566 case eCsrSummaryStats:
Mohit Khanna23863762012-09-11 17:40:09 -070013567 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013568 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
13569 pStats, sizeof(tCsrSummaryStatsInfo));
13570 if(!HAL_STATUS_SUCCESS(status))
13571 {
13572 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy summary stats\n"));
13573 }
13574 pStats += sizeof(tCsrSummaryStatsInfo);
13575 length -= sizeof(tCsrSummaryStatsInfo);
13576 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013577 case eCsrGlobalClassAStats:
Mohit Khanna23863762012-09-11 17:40:09 -070013578 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013579 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classAStatsInfo,
13580 pStats, sizeof(tCsrGlobalClassAStatsInfo));
13581 if(!HAL_STATUS_SUCCESS(status))
13582 {
13583 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassA stats\n"));
13584 }
13585 pStats += sizeof(tCsrGlobalClassAStatsInfo);
13586 length -= sizeof(tCsrGlobalClassAStatsInfo);
13587 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013588 case eCsrGlobalClassBStats:
Mohit Khanna23863762012-09-11 17:40:09 -070013589 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013590 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classBStatsInfo,
13591 pStats, sizeof(tCsrGlobalClassBStatsInfo));
13592 if(!HAL_STATUS_SUCCESS(status))
13593 {
13594 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassB stats\n"));
13595 }
13596 pStats += sizeof(tCsrGlobalClassBStatsInfo);
13597 length -= sizeof(tCsrGlobalClassBStatsInfo);
13598 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013599 case eCsrGlobalClassCStats:
Mohit Khanna23863762012-09-11 17:40:09 -070013600 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013601 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classCStatsInfo,
13602 pStats, sizeof(tCsrGlobalClassCStatsInfo));
13603 if(!HAL_STATUS_SUCCESS(status))
13604 {
13605 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassC stats\n"));
13606 }
13607 pStats += sizeof(tCsrGlobalClassCStatsInfo);
13608 length -= sizeof(tCsrGlobalClassCStatsInfo);
13609 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013610 case eCsrPerStaStats:
Mohit Khanna23863762012-09-11 17:40:09 -070013611 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013612 if( CSR_MAX_STA > pSmeStatsRsp->staId )
13613 {
13614 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
13615 pStats, sizeof(tCsrPerStaStatsInfo));
13616 }
13617 else
13618 {
13619 status = eHAL_STATUS_FAILURE;
13620 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d\n"), pSmeStatsRsp->staId);
13621 VOS_ASSERT( 0 );
13622 }
13623 if(!HAL_STATUS_SUCCESS(status))
13624 {
13625 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats\n"));
13626 }
13627 pStats += sizeof(tCsrPerStaStatsInfo);
13628 length -= sizeof(tCsrPerStaStatsInfo);
13629 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013630 default:
13631 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type\n"));
13632 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013633 }
13634 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013635 tempMask >>=1;
13636 counter++;
13637 }
13638 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
13639 if (length != 0)
13640 {
13641 pRssi = (tANI_U32*)pStats;
13642 rssi = (v_S7_t)*pRssi;
13643 }
13644 else
13645 {
13646 /* If riva is not sending rssi, continue to use the hack */
13647 rssi = RSSI_HACK_BMPS;
13648 }
13649 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Jeff Johnson295189b2012-06-20 16:38:30 -070013650post_update:
13651 //make sure to update the pe stats req list
13652 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
13653 if(pEntry)
13654 {
13655 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
13656 pPeStaEntry->rspPending = FALSE;
13657
13658 }
13659 //check the one timer cases
13660 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
13661 if(pEntry)
13662 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013663 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013664 if(pTempStaEntry->timerExpired)
13665 {
13666 //send up the stats report
13667 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
13668 pTempStaEntry->staId, pTempStaEntry->pContext);
13669 //also remove from the client list
13670 csrRoamRemoveStatListEntry(pMac, pEntry);
13671 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013672 }
13673 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013674}
Jeff Johnson295189b2012-06-20 16:38:30 -070013675tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
13676{
13677 tListElem *pEntry = NULL;
13678 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013679 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070013680 if(!pEntry)
13681 {
13682 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070013683 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE\n");
Jeff Johnson295189b2012-06-20 16:38:30 -070013684 return NULL;
13685 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013686 while( pEntry )
13687 {
13688 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013689 if(pTempStaEntry->statsMask == statsMask)
13690 {
Mohit Khanna23863762012-09-11 17:40:09 -070013691 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found\n");
Jeff Johnson295189b2012-06-20 16:38:30 -070013692 break;
13693 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013694 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
13695 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013696 return pEntry;
13697}
13698
Jeff Johnson295189b2012-06-20 16:38:30 -070013699tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
13700 tANI_BOOLEAN update)
13701{
13702 tListElem *pEntry;
13703 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070013704 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070013705 if(!pEntry)
13706 {
13707 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070013708 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Jeff Johnson295189b2012-06-20 16:38:30 -070013709 "upper layer client(s)\n");
13710 return NULL;
13711 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013712 while( pEntry )
13713 {
13714 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013715 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
13716 (pTempStaEntry->statsMask == pStaEntry->statsMask))
13717 {
Mohit Khanna23863762012-09-11 17:40:09 -070013718 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found\n");
Jeff Johnson295189b2012-06-20 16:38:30 -070013719 if(update)
13720 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013721 pTempStaEntry->periodicity = pStaEntry->periodicity;
13722 pTempStaEntry->callback = pStaEntry->callback;
13723 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070013724 }
13725 break;
13726 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013727 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
13728 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013729 return pEntry;
13730}
Jeff Johnson295189b2012-06-20 16:38:30 -070013731tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
13732{
13733 tListElem *pEntry;
13734 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070013735 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070013736 if(!pEntry)
13737 {
13738 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070013739 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Jeff Johnson295189b2012-06-20 16:38:30 -070013740 "upper layer client(s)\n");
13741 return NULL;
13742 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013743 while( pEntry )
13744 {
13745 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013746 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
13747 {
Mohit Khanna23863762012-09-11 17:40:09 -070013748 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found\n");
Jeff Johnson295189b2012-06-20 16:38:30 -070013749 break;
13750 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013751 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
13752 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013753 return pEntry;
13754}
Jeff Johnson295189b2012-06-20 16:38:30 -070013755eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
13756 csrRoamLinkQualityIndCallback callback,
13757 void *pContext)
13758{
13759 pMac->roam.linkQualityIndInfo.callback = callback;
13760 pMac->roam.linkQualityIndInfo.context = pContext;
13761 if( NULL == callback )
13762 {
13763 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
13764 }
13765 else
13766 {
13767 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070013768 /* do we need to invoke the callback to notify client of initial value ?? */
13769 }
13770 return eHAL_STATUS_SUCCESS;
13771}
Jeff Johnson295189b2012-06-20 16:38:30 -070013772void csrRoamVccTrigger(tpAniSirGlobal pMac)
13773{
13774 eCsrRoamLinkQualityInd newVccLinkQuality;
13775 tANI_U32 ul_mac_loss = 0;
13776 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070013777 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
13778 /*-------------------------------------------------------------------------
13779 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070013780 Check for a change in link quality and notify client if necessary
13781 -------------------------------------------------------------------------*/
13782 ul_mac_loss_trigger_threshold =
13783 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070013784 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013785 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d\n",
13786 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070013787 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
13788 {
13789 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR \n");
13790 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
13791 }
13792 else
13793 {
13794 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD\n");
13795 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
13796 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013797 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
13798 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070013799 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
13800 {
13801 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary\n");
13802 if(NULL != pMac->roam.linkQualityIndInfo.callback)
13803 {
13804 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d\n",
13805 newVccLinkQuality );
13806
13807 /* we now invoke the callback once to notify client of initial value */
13808 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
13809 pMac->roam.linkQualityIndInfo.context );
13810 //event: EVENT_WLAN_VCC
13811 }
13812 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013813 pMac->roam.vccLinkQuality = newVccLinkQuality;
13814
Jeff Johnson295189b2012-06-20 16:38:30 -070013815}
Jeff Johnson295189b2012-06-20 16:38:30 -070013816VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
13817 v_U8_t rssiNotification,
13818 void * context)
13819{
13820 tpAniSirGlobal pMac = PMAC_STRUCT( context );
13821 eCsrRoamLinkQualityInd newVccLinkQuality;
13822 // TODO : Session info unavailable
13823 tANI_U32 sessionId = 0;
13824 VOS_STATUS status = VOS_STATUS_SUCCESS;
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 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d\n",
13830 pMac->roam.configParam.vccRssiThreshold);
13831 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
13832 {
13833 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected\n");
13834 return VOS_STATUS_SUCCESS;
13835 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013836 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
13837 {
13838 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR\n");
13839 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
13840 }
13841 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
13842 {
13843 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD \n");
13844 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
13845 }
13846 else
13847 {
13848 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d\n", rssiNotification);
13849 //Set to this so the code below won't do anything
13850 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070013851 VOS_ASSERT(0);
13852 }
13853
Jeff Johnson295189b2012-06-20 16:38:30 -070013854 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
13855 {
13856 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary\n");
13857 if(NULL != pMac->roam.linkQualityIndInfo.callback)
13858 {
13859 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d\n",
13860 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070013861 /* we now invoke the callback once to notify client of initial value */
13862 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
13863 pMac->roam.linkQualityIndInfo.context );
13864 //event: EVENT_WLAN_VCC
13865 }
13866 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013867 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070013868 return status;
13869}
Jeff Johnson295189b2012-06-20 16:38:30 -070013870tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
13871 tDblLinkList *pStaList,
13872 tCsrStatsClientReqInfo *pStaEntry)
13873{
13874 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013875 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013876 //if same entity requested for same set of stats with different periodicity &
13877 // callback update it
13878 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
13879 {
13880
13881 status = palAllocateMemory(pMac->hHdd, (void **)&pNewStaEntry, sizeof(tCsrStatsClientReqInfo));
13882 if (!HAL_STATUS_SUCCESS(status))
13883 {
13884 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
13885 "entry\n");
13886 return NULL;
13887 }
13888
Jeff Johnson295189b2012-06-20 16:38:30 -070013889 pNewStaEntry->callback = pStaEntry->callback;
13890 pNewStaEntry->pContext = pStaEntry->pContext;
13891 pNewStaEntry->periodicity = pStaEntry->periodicity;
13892 pNewStaEntry->requesterId = pStaEntry->requesterId;
13893 pNewStaEntry->statsMask = pStaEntry->statsMask;
13894 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
13895 pNewStaEntry->pMac = pStaEntry->pMac;
13896 pNewStaEntry->staId = pStaEntry->staId;
13897 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
13898
13899 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
13900 }
13901 return pNewStaEntry;
13902}
13903
Jeff Johnson295189b2012-06-20 16:38:30 -070013904tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
13905 tDblLinkList *pStaList,
13906 tCsrPeStatsReqInfo *pStaEntry)
13907{
13908 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013909 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013910 status = palAllocateMemory(pMac->hHdd, (void **)&pNewStaEntry, sizeof(tCsrPeStatsReqInfo));
13911 if (!HAL_STATUS_SUCCESS(status))
13912 {
13913 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
13914 "entry\n");
13915 return NULL;
13916 }
13917
Jeff Johnson295189b2012-06-20 16:38:30 -070013918 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
13919 pNewStaEntry->numClient = pStaEntry->numClient;
13920 pNewStaEntry->periodicity = pStaEntry->periodicity;
13921 pNewStaEntry->statsMask = pStaEntry->statsMask;
13922 pNewStaEntry->pMac = pStaEntry->pMac;
13923 pNewStaEntry->staId = pStaEntry->staId;
13924 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
13925 pNewStaEntry->rspPending = pStaEntry->rspPending;
13926
13927 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070013928 return pNewStaEntry;
13929}
Jeff Johnson295189b2012-06-20 16:38:30 -070013930eHalStatus csrGetRssi(tpAniSirGlobal pMac,
13931 tCsrRssiCallback callback,
13932 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
13933{
13934 eHalStatus status = eHAL_STATUS_SUCCESS;
13935 vos_msg_t msg;
13936 tANI_U32 sessionId;
13937
13938 tAniGetRssiReq *pMsg;
13939 smsLog(pMac, LOG2, FL("called"));
13940 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetRssiReq));
13941 if ( !HAL_STATUS_SUCCESS(status) )
13942 {
13943 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req \n");
13944 return status;
13945 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013946 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
13947
13948 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
13949 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
13950 pMsg->sessionId = sessionId;
13951 pMsg->staId = staId;
13952 pMsg->rssiCallback = callback;
13953 pMsg->pDevContext = pContext;
13954 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070013955 msg.type = eWNI_SME_GET_RSSI_REQ;
13956 msg.bodyptr = pMsg;
13957 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013958 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
13959 {
13960 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self \n");
13961 palFreeMemory(pMac->hHdd, (void *)pMsg);
13962 status = eHAL_STATUS_FAILURE;
13963 }
13964 smsLog(pMac, LOG2, FL("returned"));
13965 return status;
13966}
Jeff Johnson295189b2012-06-20 16:38:30 -070013967eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
13968 tANI_U32 statsMask,
13969 tCsrStatsCallback callback,
13970 tANI_U32 periodicity, tANI_BOOLEAN cache,
13971 tANI_U8 staId, void *pContext)
13972{
13973 tCsrStatsClientReqInfo staEntry;
13974 tCsrStatsClientReqInfo *pStaEntry = NULL;
13975 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
13976 tListElem *pEntry = NULL;
13977 tANI_BOOLEAN found = FALSE;
13978 eHalStatus status = eHAL_STATUS_SUCCESS;
13979 tANI_BOOLEAN insertInClientList = FALSE;
13980 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070013981 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070013982
13983 if( csrIsAllSessionDisconnected(pMac) )
13984 {
13985 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected\n", pMac->roam.curState);
13986 return eHAL_STATUS_FAILURE;
13987 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013988 if((!statsMask) && (!callback))
13989 {
13990 //msg
13991 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request\n");
13992 return eHAL_STATUS_FAILURE;
13993 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013994 //for the search list method for deregister
13995 staEntry.requesterId = requesterId;
13996 staEntry.statsMask = statsMask;
13997 //requester wants to deregister or just an error
13998 if((statsMask) && (!callback))
13999 {
14000 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
14001 if(!pEntry)
14002 {
14003 //msg
14004 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
14005 "find any existing request in statsClientReqList\n");
14006 return eHAL_STATUS_FAILURE;
14007 }
14008 else
14009 {
14010 //clean up & return
14011 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070014012 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070014013 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014014 pStaEntry->pPeStaEntry->numClient--;
14015 //check if we need to delete the entry from peStatsReqList too
14016 if(!pStaEntry->pPeStaEntry->numClient)
14017 {
14018 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
14019 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014020 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070014021
Jeff Johnson295189b2012-06-20 16:38:30 -070014022 //check if we need to stop the tl stats timer too
14023 pMac->roam.tlStatsReqInfo.numClient--;
14024 if(!pMac->roam.tlStatsReqInfo.numClient)
14025 {
14026 if(pMac->roam.tlStatsReqInfo.timerRunning)
14027 {
14028 status = palTimerStop(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
14029 if(!HAL_STATUS_SUCCESS(status))
14030 {
14031 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer\n"));
14032 return eHAL_STATUS_FAILURE;
14033 }
14034 }
14035 pMac->roam.tlStatsReqInfo.periodicity = 0;
14036 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14037 }
14038 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070014039 // Destroy the vos timer...
14040 vosStatus = vos_timer_destroy( &pStaEntry->timer );
14041 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14042 {
14043 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer\n"));
14044 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014045 csrRoamRemoveStatListEntry(pMac, pEntry);
14046 pStaEntry = NULL;
14047 return eHAL_STATUS_SUCCESS;
14048 }
14049 }
14050
14051 if(cache && !periodicity)
14052 {
14053 //return the cached stats
14054 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
14055 }
14056 else
14057 {
14058 //add the request in the client req list
14059 staEntry.callback = callback;
14060 staEntry.pContext = pContext;
14061 staEntry.periodicity = periodicity;
14062 staEntry.pPeStaEntry = NULL;
14063 staEntry.staId = staId;
14064 staEntry.pMac = pMac;
14065 staEntry.timerExpired = FALSE;
14066
14067
Jeff Johnson295189b2012-06-20 16:38:30 -070014068 //if periodic report requested with non cached result from PE/TL
14069 if(periodicity)
14070 {
14071
14072 //if looking for stats from PE
14073 if(statsMask & ~(1 << eCsrGlobalClassDStats))
14074 {
14075
14076 //check if same request made already & waiting for rsp
14077 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
14078 periodicity, &found, staId);
14079 if(!pPeStaEntry)
14080 {
14081 //bail out, maxed out on number of req for PE
14082 return eHAL_STATUS_FAILURE;
14083 }
14084 else
14085 {
14086 staEntry.pPeStaEntry = pPeStaEntry;
14087 }
14088
14089 }
14090 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
14091 if(statsMask & (1 << eCsrGlobalClassDStats))
14092 {
14093 if(cache && pMac->roam.tlStatsReqInfo.numClient)
14094 {
14095 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL\n"));
14096 }
14097 else
14098 {
14099
14100 //update periodicity
14101 if(pMac->roam.tlStatsReqInfo.periodicity)
14102 {
14103 pMac->roam.tlStatsReqInfo.periodicity =
14104 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
14105 }
14106 else
14107 {
14108 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
14109 }
14110 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
14111 {
14112 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
14113 }
14114
14115 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14116 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014117 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
14118 if(NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014119 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014120 //req TL for class D stats
14121 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
14122 {
14123 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL\n"));
14124 }
14125 else
14126 {
14127 //save in SME
14128 csrRoamSaveStatsFromTl(pMac, pTlStats);
14129 }
14130 vos_mem_free(pTlStats);
14131 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014132 }
14133 else
14134 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014135 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014136 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014137
Jeff Johnson295189b2012-06-20 16:38:30 -070014138 if(pMac->roam.tlStatsReqInfo.periodicity)
14139 {
14140 //start timer
14141 status = palTimerStart(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14142 pMac->roam.tlStatsReqInfo.periodicity * PAL_TIMER_TO_MS_UNIT, eANI_BOOLEAN_FALSE);
14143 if(!HAL_STATUS_SUCCESS(status))
14144 {
14145 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer\n"));
14146 return eHAL_STATUS_FAILURE;
14147 }
14148 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14149 }
14150 }
14151 }
14152 pMac->roam.tlStatsReqInfo.numClient++;
14153 }
14154
14155 insertInClientList = TRUE;
14156 }
14157 //if one time report requested with non cached result from PE/TL
14158 else if(!cache && !periodicity)
14159 {
14160 if(statsMask & ~(1 << eCsrGlobalClassDStats))
14161 {
14162 //send down a req
14163 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
14164 if(!HAL_STATUS_SUCCESS(status))
14165 {
14166 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE\n"));
14167 }
14168 //so that when the stats rsp comes back from PE we respond to upper layer
14169 //right away
14170 staEntry.timerExpired = TRUE;
14171 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014172 }
14173 if(statsMask & (1 << eCsrGlobalClassDStats))
14174 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014175 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
14176 if(NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014177 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014178 //req TL for class D stats
14179 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
14180 {
14181 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL\n"));
14182 }
14183 else
14184 {
14185 //save in SME
14186 csrRoamSaveStatsFromTl(pMac, pTlStats);
14187 }
14188 vos_mem_free(pTlStats);
14189 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014190 }
14191 else
14192 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014193 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014194 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014195
14196 }
14197 //if looking for stats from TL only
14198 if(!insertInClientList)
14199 {
14200 //return the stats
14201 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
14202 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014203 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014204 if(insertInClientList)
14205 {
14206 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
14207 if(!pStaEntry)
14208 {
14209 //msg
14210 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList\n");
14211 return eHAL_STATUS_FAILURE;
14212 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014213 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070014214 //Init & start timer if needed
14215 if(periodicity)
14216 {
14217 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
14218 csrRoamStatsClientTimerHandler, pStaEntry );
14219 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14220 {
14221 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer\n"));
14222 return eHAL_STATUS_FAILURE;
14223 }
14224 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
14225 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14226 {
14227 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer\n"));
14228 return eHAL_STATUS_FAILURE;
14229 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014230 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014231 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014232 }
14233 return eHAL_STATUS_SUCCESS;
14234}
14235
Jeff Johnson295189b2012-06-20 16:38:30 -070014236tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
14237 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
14238{
14239 tANI_BOOLEAN found = FALSE;
14240 eHalStatus status = eHAL_STATUS_SUCCESS;
14241 tCsrPeStatsReqInfo staEntry;
14242 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
14243 tListElem *pStaEntry = NULL;
14244 VOS_STATUS vosStatus;
14245 tPmcPowerState powerState;
14246 *pFound = FALSE;
14247
14248 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
14249 if(pStaEntry)
14250 {
14251 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
14252 if(pTempStaEntry->periodicity)
14253 {
14254 pTempStaEntry->periodicity =
14255 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
14256 }
14257 else
14258 {
14259 pTempStaEntry->periodicity = periodicity;
14260 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014261 pTempStaEntry->numClient++;
14262 found = TRUE;
14263 }
14264 else
14265 {
14266 palZeroMemory(pMac->hHdd, &staEntry, sizeof(tCsrPeStatsReqInfo));
14267 staEntry.numClient = 1;
14268 staEntry.periodicity = periodicity;
14269 staEntry.pMac = pMac;
14270 staEntry.rspPending = FALSE;
14271 staEntry.staId = staId;
14272 staEntry.statsMask = statsMask;
14273 staEntry.timerRunning = FALSE;
14274 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
14275 if(!pTempStaEntry)
14276 {
14277 //msg
14278 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList\n");
14279 return NULL;
14280 }
14281 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014282 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
14283 if(ePMC_FULL_POWER == powerState)
14284 {
14285 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
14286 {
14287 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
14288 }
14289 }
14290 else
14291 {
14292 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
14293 {
14294 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
14295 }
14296 }
14297 if(!pTempStaEntry->timerRunning)
14298 {
14299 //send down a req in case of one time req, for periodic ones wait for timer to expire
14300 if(!pTempStaEntry->rspPending &&
14301 !pTempStaEntry->periodicity)
14302 {
14303 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
14304 if(!HAL_STATUS_SUCCESS(status))
14305 {
14306 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE\n"));
14307 }
14308 else
14309 {
14310 pTempStaEntry->rspPending = TRUE;
14311 }
14312 }
14313 if(pTempStaEntry->periodicity)
14314 {
14315 if(!found)
14316 {
14317
14318 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
14319 csrRoamPeStatsTimerHandler, pTempStaEntry );
14320 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14321 {
14322 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer\n"));
14323 return NULL;
14324 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014325 }
14326 //start timer
14327 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d\n", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070014328 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
14329 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14330 {
14331 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer\n"));
14332 return NULL;
14333 }
14334 pTempStaEntry->timerRunning = TRUE;
14335 }
14336 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014337 *pFound = found;
14338 return pTempStaEntry;
14339}
14340
Jeff Johnson295189b2012-06-20 16:38:30 -070014341/*
14342 pStaEntry is no longer invalid upon the return of this function.
14343*/
14344static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
14345{
14346 if(pEntry)
14347 {
14348 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
14349 {
14350 palFreeMemory(pMac->hHdd, GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070014351 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014352 }
14353 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014354
14355void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
14356{
14357 tListElem *pEntry;
14358 tCsrPeStatsReqInfo *pTempStaEntry;
14359 VOS_STATUS vosStatus;
14360 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014361 if(!pEntry)
14362 {
14363 //list empty
14364 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: List empty, no stats req for PE\n");
14365 return;
14366 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014367 while( pEntry )
14368 {
14369 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014370 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
14371 {
14372 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: match found\n");
14373 if(pTempStaEntry->timerRunning)
14374 {
14375 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
14376 /* If we are not able to stop the timer here, just remove
14377 * the entry from the linked list. Destroy the timer object
14378 * and free the memory in the timer CB
14379 */
14380 if( vosStatus == VOS_STATUS_SUCCESS )
14381 {
14382 /* the timer is successfully stopped */
14383 pTempStaEntry->timerRunning = FALSE;
14384
14385 /* Destroy the timer */
14386 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
14387 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14388 {
14389 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer\n"));
14390 }
14391 }
14392 else
14393 {
14394 // the timer could not be stopped. Hence destroy and free the
14395 // memory for the PE stat entry in the timer CB.
14396 pTempStaEntry->timerStopFailed = TRUE;
14397 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014398 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014399
14400 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
14401 {
14402 // Only free the memory if we could stop the timer successfully
14403 if(!pTempStaEntry->timerStopFailed)
14404 {
14405 palFreeMemory(pMac->hHdd, pTempStaEntry);
14406 pTempStaEntry = NULL;
14407 }
14408 break;
14409 }
14410
14411 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
14412 }
14413 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014414 return;
14415}
14416
14417
Jeff Johnsone7245742012-09-05 17:12:55 -070014418void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014419{
14420
Jeff Johnsone7245742012-09-05 17:12:55 -070014421 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
14422 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
14423 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
14424 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
14425 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
14426 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
14427 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070014428 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070014429 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
14430 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
14431 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
14432 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
14433 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
14434 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070014435 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070014436 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
14437 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070014438
14439}
14440
Jeff Johnson295189b2012-06-20 16:38:30 -070014441void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
14442 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
14443{
14444 tANI_U8 stats[500];
14445 tANI_U8 *pStats = NULL;
14446 tANI_U32 tempMask = 0;
14447 tANI_U8 counter = 0;
14448 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014449 if(!callback)
14450 {
14451 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report callback NULL\n"));
14452 return;
14453 }
14454 if(!statsMask)
14455 {
14456 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report statsMask is 0\n"));
14457 return;
14458 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014459 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070014460 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070014461 while(tempMask)
14462 {
14463 if(tempMask & 1)
14464 {
14465 //new stats info from PE, fill up the stats strucutres in PMAC
14466 switch(counter)
14467 {
14468 case eCsrSummaryStats:
Mohit Khanna23863762012-09-11 17:40:09 -070014469 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:summary stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014470 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
14471 sizeof(tCsrSummaryStatsInfo));
14472 if(!HAL_STATUS_SUCCESS(status))
14473 {
14474 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy summary stats\n"));
14475 }
14476 pStats += sizeof(tCsrSummaryStatsInfo);
14477 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014478 case eCsrGlobalClassAStats:
Mohit Khanna23863762012-09-11 17:40:09 -070014479 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassA stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014480 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
14481 sizeof(tCsrGlobalClassAStatsInfo));
14482 if(!HAL_STATUS_SUCCESS(status))
14483 {
14484 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassA stats\n"));
14485 }
14486 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070014487 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014488 case eCsrGlobalClassBStats:
Mohit Khanna23863762012-09-11 17:40:09 -070014489 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassB stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014490 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
14491 sizeof(tCsrGlobalClassBStatsInfo));
14492 if(!HAL_STATUS_SUCCESS(status))
14493 {
14494 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassB stats\n"));
14495 }
14496 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070014497 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014498 case eCsrGlobalClassCStats:
Mohit Khanna23863762012-09-11 17:40:09 -070014499 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassC stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014500 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
14501 sizeof(tCsrGlobalClassCStatsInfo));
14502 if(!HAL_STATUS_SUCCESS(status))
14503 {
14504 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassC stats\n"));
14505 }
14506 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070014507 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014508 case eCsrGlobalClassDStats:
Mohit Khanna23863762012-09-11 17:40:09 -070014509 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassD stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014510 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
14511 sizeof(tCsrGlobalClassDStatsInfo));
14512 if(!HAL_STATUS_SUCCESS(status))
14513 {
14514 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassD stats\n"));
14515 }
14516 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070014517 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014518 case eCsrPerStaStats:
Mohit Khanna23863762012-09-11 17:40:09 -070014519 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:PerSta stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014520 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
14521 sizeof(tCsrPerStaStatsInfo));
14522 if(!HAL_STATUS_SUCCESS(status))
14523 {
14524 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy PerSta stats\n"));
14525 }
14526 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070014527 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014528 default:
14529 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:unknown stats type\n"));
14530 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014531 }
14532 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014533 tempMask >>=1;
14534 counter++;
14535 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014536 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070014537}
14538
Jeff Johnson295189b2012-06-20 16:38:30 -070014539eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
14540{
14541 tListElem *pEntry = NULL;
14542 tListElem *pPrevEntry = NULL;
14543 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
14544 eHalStatus status = eHAL_STATUS_SUCCESS;
14545 VOS_STATUS vosStatus;
14546 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014547 if(!pEntry)
14548 {
14549 //list empty
14550 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
14551 "upper layer client(s)\n");
14552 return status;
14553 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014554 while( pEntry )
14555 {
14556 if(pPrevEntry)
14557 {
14558 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
14559 //send up the stats report
14560 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
14561 pTempStaEntry->staId, pTempStaEntry->pContext);
14562 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
14563 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014564 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014565 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
14566 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014567 pTempStaEntry->pPeStaEntry->numClient--;
14568 //check if we need to delete the entry from peStatsReqList too
14569 if(!pTempStaEntry->pPeStaEntry->numClient)
14570 {
14571 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
14572 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014573 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014574 //check if we need to stop the tl stats timer too
14575 pMac->roam.tlStatsReqInfo.numClient--;
14576 if(!pMac->roam.tlStatsReqInfo.numClient)
14577 {
14578 if(pMac->roam.tlStatsReqInfo.timerRunning)
14579 {
14580 status = palTimerStop(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
14581 if(!HAL_STATUS_SUCCESS(status))
14582 {
14583 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer\n"));
14584 //we will continue
14585 }
14586 }
14587 pMac->roam.tlStatsReqInfo.periodicity = 0;
14588 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14589 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014590 if (pTempStaEntry->periodicity)
14591 {
14592 //While creating StaEntry in csrGetStatistics,
14593 //Initializing and starting timer only when periodicity is set.
14594 //So Stop and Destroy timer only when periodicity is set.
14595
Jeff Johnsone7245742012-09-05 17:12:55 -070014596 vos_timer_stop( &pTempStaEntry->timer );
14597 // Destroy the vos timer...
14598 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
14599 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14600 {
14601 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer\n"));
14602 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014603 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014604
Jeff Johnson295189b2012-06-20 16:38:30 -070014605
14606 pPrevEntry = pEntry;
14607 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14608 }
14609 //the last one
14610 if(pPrevEntry)
14611 {
14612 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
14613 //send up the stats report
14614 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
14615 pTempStaEntry->staId, pTempStaEntry->pContext);
14616 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
14617 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014618 return status;
14619
14620}
14621
Jeff Johnson295189b2012-06-20 16:38:30 -070014622eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
14623 tRequestFullPowerReason *pReason,
14624 tANI_BOOLEAN *pfNeedPower )
14625{
14626 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
14627 tRequestFullPowerReason reason = eSME_REASON_OTHER;
14628 tPmcState pmcState;
14629 eHalStatus status = eHAL_STATUS_SUCCESS;
14630 // TODO : Session info unavailable
14631 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014632 if( pfNeedPower )
14633 {
14634 *pfNeedPower = eANI_BOOLEAN_FALSE;
14635 }
14636 //We only handle CSR commands
14637 if( !(eSmeCsrCommandMask & pCommand->command) )
14638 {
14639 return eHAL_STATUS_SUCCESS;
14640 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014641 //Check PMC state first
14642 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070014643 switch( pmcState )
14644 {
14645 case REQUEST_IMPS:
14646 case IMPS:
14647 if( eSmeCommandScan == pCommand->command )
14648 {
14649 switch( pCommand->u.scanCmd.reason )
14650 {
14651 case eCsrScanGetResult:
14652 case eCsrScanBGScanAbort:
14653 case eCsrScanBGScanEnable:
14654 case eCsrScanGetScanChnInfo:
14655 //Internal process, no need for full power
14656 fNeedFullPower = eANI_BOOLEAN_FALSE;
14657 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014658 default:
14659 //Other scans are real scan, ask for power
14660 fNeedFullPower = eANI_BOOLEAN_TRUE;
14661 break;
14662 } //switch
14663 }
14664 else
14665 {
14666 //ask for power for roam and status change
14667 fNeedFullPower = eANI_BOOLEAN_TRUE;
14668 }
14669 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014670 case REQUEST_BMPS:
14671 case BMPS:
14672 case REQUEST_START_UAPSD:
14673 case UAPSD:
14674 //We treat WOWL same as BMPS
14675 case REQUEST_ENTER_WOWL:
14676 case WOWL:
14677 if( eSmeCommandRoam == pCommand->command )
14678 {
14679 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
14680 tCsrScanResult *pScanResult;
14681 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014682 switch ( pCommand->u.roamCmd.roamReason )
14683 {
14684 case eCsrForcedDisassoc:
14685 case eCsrForcedDisassocMICFailure:
14686 reason = eSME_LINK_DISCONNECTED_BY_HDD;
14687 fNeedFullPower = eANI_BOOLEAN_TRUE;
14688 break;
14689 case eCsrSmeIssuedDisassocForHandoff:
14690 case eCsrForcedDeauth:
14691 case eCsrHddIssuedReassocToSameAP:
14692 case eCsrSmeIssuedReassocToSameAP:
14693 fNeedFullPower = eANI_BOOLEAN_TRUE;
14694 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014695 case eCsrCapsChange:
14696 fNeedFullPower = eANI_BOOLEAN_TRUE;
14697 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014698 default:
14699 //Check whether the profile is already connected. If so, no need for full power
14700 //Note: IBSS is ignored for now because we don't support powersave in IBSS
14701 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
14702 {
14703 //Only need to check the first one
14704 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
14705 if( pEntry )
14706 {
14707 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
14708#if 0
14709 // TODO : Session Specific info pConnectBssDesc
14710 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
14711 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
14712 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
14713 {
14714 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
14715 // with Authenticating first. To force this, stop the current association (Disassociate) and
14716 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
14717 // a new Association.
14718 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
14719 {
14720 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
14721 {
14722 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
14723 //No need for full power
14724 //Set the flag so the code later can avoid to do the above
14725 //check again.
14726 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
14727 break;
14728 }
14729 }
14730 }
14731#endif
14732 }
14733 }
14734 //If we are here, full power is needed
14735 fNeedFullPower = eANI_BOOLEAN_TRUE;
14736 break;
14737 }
14738 }
14739 else if( eSmeCommandWmStatusChange == pCommand->command )
14740 {
14741 //need full power for all
14742 fNeedFullPower = eANI_BOOLEAN_TRUE;
14743 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
14744 }
Mohit Khannac0b992f2012-12-04 15:08:18 -080014745#ifdef FEATURE_WLAN_TDLS
14746 else if( eSmeCommandTdlsAddPeer == pCommand->command )
14747 {
14748 //TDLS link is getting established. need full power
14749 fNeedFullPower = eANI_BOOLEAN_TRUE;
14750 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
14751 }
14752#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014753 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014754 case REQUEST_STOP_UAPSD:
14755 case REQUEST_EXIT_WOWL:
14756 if( eSmeCommandRoam == pCommand->command )
14757 {
14758 fNeedFullPower = eANI_BOOLEAN_TRUE;
14759 switch ( pCommand->u.roamCmd.roamReason )
14760 {
14761 case eCsrForcedDisassoc:
14762 case eCsrForcedDisassocMICFailure:
14763 reason = eSME_LINK_DISCONNECTED_BY_HDD;
14764 break;
14765 default:
14766 break;
14767 }
14768 }
14769 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014770 case STOPPED:
14771 case REQUEST_STANDBY:
14772 case STANDBY:
14773 case LOW_POWER:
14774 //We are not supposed to do anything
14775 smsLog( pMac, LOGE, FL( " cannot process because PMC is in stopped/standby state %d\n" ), pmcState );
14776 status = eHAL_STATUS_FAILURE;
14777 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014778 case FULL_POWER:
14779 case REQUEST_FULL_POWER:
14780 default:
14781 //No need to ask for full power. This has to be FULL_POWER state
14782 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014783 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070014784 if( pReason )
14785 {
14786 *pReason = reason;
14787 }
14788 if( pfNeedPower )
14789 {
14790 *pfNeedPower = fNeedFullPower;
14791 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014792 return ( status );
14793}
14794
Jeff Johnson295189b2012-06-20 16:38:30 -070014795static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14796{
14797 eHalStatus status = eHAL_STATUS_SUCCESS;
14798 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
14799 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070014800 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070014801 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
14802 {
14803 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
14804 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014805 return ( status );
14806}
14807
Jeff Johnson295189b2012-06-20 16:38:30 -070014808tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
14809{
14810 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070014811 if( pCmd )
14812 {
14813 pMac->roam.sPendingCommands++;
14814 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014815 return ( pCmd );
14816}
14817
Jeff Johnson295189b2012-06-20 16:38:30 -070014818void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
14819{
14820 if (pMac->roam.sPendingCommands > 0)
14821 {
14822 //All command allocated through csrGetCommandBuffer need to
14823 //decrement the pending count when releasing.
14824 pMac->roam.sPendingCommands--;
14825 smeReleaseCommand( pMac, pCommand );
14826 }
14827 else
14828 {
14829 smsLog(pMac, LOGE, FL( "no pending commands"));
14830 VOS_ASSERT(0);
14831 }
14832}
14833
Jeff Johnson295189b2012-06-20 16:38:30 -070014834//Return SUCCESS is the command is queued, failed
14835eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
14836{
14837 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014838 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
14839 {
14840 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
14841 pCommand->u.scanCmd.reason);
14842 return eHAL_STATUS_CSR_WRONG_STATE;
14843 }
14844
14845 //We can call request full power first before putting the command into pending Q
14846 //because we are holding SME lock at this point.
14847 status = csrRequestFullPower( pMac, pCommand );
14848 if( HAL_STATUS_SUCCESS( status ) )
14849 {
14850 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070014851 //make sure roamCmdPendingList is not empty first
14852 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
14853 if( fNoCmdPending )
14854 {
14855 smePushCommand( pMac, pCommand, fHighPriority );
14856 }
14857 else
14858 {
14859 //Other commands are waiting for PMC callback, queue the new command to the pending Q
14860 //no list lock is needed since SME lock is held
14861 if( !fHighPriority )
14862 {
14863 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
14864 }
14865 else {
14866 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
14867 }
14868 }
14869 }
14870 else if( eHAL_STATUS_PMC_PENDING == status )
14871 {
14872 //no list lock is needed since SME lock is held
14873 if( !fHighPriority )
14874 {
14875 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
14876 }
14877 else {
14878 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
14879 }
14880 //Let caller know the command is queue
14881 status = eHAL_STATUS_SUCCESS;
14882 }
14883 else
14884 {
14885 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
14886 //release the command.
14887 smsLog( pMac, LOGE, FL( " cannot queue command %d\n" ), pCommand->command );
14888 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014889 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014890}
Jeff Johnson295189b2012-06-20 16:38:30 -070014891eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
14892{
14893 eHalStatus status = eHAL_STATUS_SUCCESS;
14894 tSirUpdateAPWPSIEsReq *pMsg;
14895 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
14896
14897 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14898 if (NULL == pSession)
14899 {
14900 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
14901 return eHAL_STATUS_FAILURE;
14902 }
14903
Jeff Johnson295189b2012-06-20 16:38:30 -070014904 do
14905 {
14906 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirUpdateAPWPSIEsReq) );
14907 if (!HAL_STATUS_SUCCESS(status)) break;
14908 palZeroMemory( pMac->hHdd, pMsg, sizeof(tSirUpdateAPWPSIEsReq) );
14909 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
14910
14911 pBuf = (tANI_U8 *)&pMsg->transactionId;
14912 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014913 // transactionId
14914 *pBuf = 0;
14915 *( pBuf + 1 ) = 0;
14916 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014917 // bssId
14918 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
14919 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014920 //sessionId
14921 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014922 // APWPSIEs
14923 palCopyMemory( pMac->hHdd, (tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
14924 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070014925 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070014926 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014927 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014928 return ( status );
14929}
Jeff Johnson295189b2012-06-20 16:38:30 -070014930eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
14931{
14932 eHalStatus status = eHAL_STATUS_SUCCESS;
14933 tSirUpdateAPWPARSNIEsReq *pMsg;
14934 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014935 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14936 if (NULL == pSession)
14937 {
14938 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
14939 return eHAL_STATUS_FAILURE;
14940 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014941 do
14942 {
14943 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirUpdateAPWPARSNIEsReq) );
14944 if (!HAL_STATUS_SUCCESS(status)) break;
14945 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ) );
14946 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014947 pBuf = (tANI_U8 *)&pMsg->transactionId;
14948 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014949 // transactionId
14950 *pBuf = 0;
14951 *( pBuf + 1 ) = 0;
14952 pBuf += sizeof(tANI_U16);
14953
14954 // bssId
14955 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
14956 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014957 // sessionId
14958 *pBuf++ = (tANI_U8)sessionId;
14959
14960 // APWPARSNIEs
14961 palCopyMemory( pMac->hHdd, (tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
14962 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070014963 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070014964 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014965 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014966 return ( status );
14967}
Jeff Johnson295189b2012-06-20 16:38:30 -070014968
14969#ifdef WLAN_FEATURE_VOWIFI_11R
14970//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
14971eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
14972{
14973 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
14974 tpSirFTPreAuthReq pftPreAuthReq;
14975 tANI_U16 auth_req_len = 0;
14976 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014977 auth_req_len = sizeof(tSirFTPreAuthReq);
14978 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
14979 if (pftPreAuthReq == NULL)
14980 {
14981 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
14982 return eHAL_STATUS_RESOURCES;
14983 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014984 // Save the SME Session ID here. We need it while processing the preauth response
14985 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014986 vos_mem_zero(pftPreAuthReq, auth_req_len);
14987
14988 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
14989 sizeof(pBssDescription->length) + pBssDescription->length);
14990
14991 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
14992
14993 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
14994
Jeff Johnson295189b2012-06-20 16:38:30 -070014995 palCopyMemory(pMac->hHdd, (void *)&pftPreAuthReq->currbssId, (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014996 palCopyMemory(pMac->hHdd, (void *)&pftPreAuthReq->preAuthbssId, (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
14997
Jeff Johnson295189b2012-06-20 16:38:30 -070014998#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080014999 if (csrRoamIs11rAssoc(pMac) &&
15000 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070015001 {
15002 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
15003 palCopyMemory(pMac->hHdd, pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
15004 pMac->ft.ftSmeContext.auth_ft_ies_length);
15005 }
15006 else
15007#endif
15008 {
15009 pftPreAuthReq->ft_ies_length = 0;
15010 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070015011 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
15012 sizeof(pBssDescription->length) + pBssDescription->length);
15013 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070015014 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
15015}
Jeff Johnson295189b2012-06-20 16:38:30 -070015016/*--------------------------------------------------------------------------
15017 * This will receive and process the FT Pre Auth Rsp from the current
15018 * associated ap.
15019 *
15020 * This will invoke the hdd call back. This is so that hdd can now
15021 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
15022 ------------------------------------------------------------------------*/
15023void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
15024{
15025 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
15026 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015027#ifdef FEATURE_WLAN_LFR
15028 tCsrRoamInfo roamInfo;
15029#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015030
15031#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srikant Kuppa40b3c142013-02-20 07:24:43 -080015032 smsLog( pMac, LOGE, FL("Preauth response status code 0x%x"), pFTPreAuthRsp->status);
Jeff Johnson295189b2012-06-20 16:38:30 -070015033#endif
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070015034#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppa40b3c142013-02-20 07:24:43 -080015035 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070015036 if (status != eHAL_STATUS_SUCCESS) {
15037 /*
15038 * Bail out if pre-auth was not even processed.
15039 */
15040 smsLog(pMac, LOGW, FL("Preauth was not processed: %d"), status);
15041 return;
15042 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015043#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015044 /* The below function calls/timers should be invoked only if the pre-auth is successful */
15045 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
15046 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070015047 // Implies a success
15048 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015049 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
15050 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
15051 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070015052 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
15053 * actual transition from the current to handoff AP is triggered */
15054 status = palTimerStart(pMac->hHdd, pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
15055 60 * PAL_TIMER_TO_MS_UNIT,
15056 eANI_BOOLEAN_FALSE);
15057 if (eHAL_STATUS_SUCCESS != status)
15058 {
15059 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d\n"), status);
15060 return;
15061 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015062 // Save the received response
15063 palCopyMemory(pMac->hHdd, (void *)&pMac->ft.ftSmeContext.preAuthbssId, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
15064 if (csrRoamIs11rAssoc(pMac))
15065 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
15066 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
15067
15068 // Currently we dont do anything special for CCX connection.
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015069#ifdef FEATURE_WLAN_LFR
15070 // If Legacy Fast Roaming is enabled, signal the supplicant
15071 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053015072 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015073 {
15074 // Save the bssid from the received response
15075 palCopyMemory(pMac->hHdd, (void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
15076 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
15077 }
15078
15079#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015080
15081 // Done with it, init it.
15082 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
15083}
15084#endif
15085#ifdef FEATURE_WLAN_BTAMP_UT_RF
15086void csrRoamJoinRetryTimerHandler(void *pv)
15087{
15088 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
15089 tpAniSirGlobal pMac = pInfo->pMac;
15090 tANI_U32 sessionId = pInfo->sessionId;
15091 tCsrRoamSession *pSession;
15092
15093 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
15094 {
15095 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d\n" ), sessionId );
15096 pSession = CSR_GET_SESSION( pMac, sessionId );
15097 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
15098 {
15099 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
15100 {
15101 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile\n" ) );
15102 }
15103 }
15104 }
15105}
Jeff Johnson295189b2012-06-20 16:38:30 -070015106eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
15107{
15108 eHalStatus status = eHAL_STATUS_FAILURE;
15109 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15110
15111 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
15112 {
15113 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left\n "), sessionId, pSession->maxRetryCount);
15114 pSession->maxRetryCount--;
15115 pSession->joinRetryTimerInfo.pMac = pMac;
15116 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
15117 status = palTimerStart(pMac->hHdd, pSession->hTimerJoinRetry, interval, eANI_BOOLEAN_FALSE);
15118 if(!HAL_STATUS_SUCCESS(status))
15119 {
15120 smsLog(pMac, LOGE, FL(" fail to start timer status %s \n "), status);
15121 }
15122 }
15123 else
15124 {
15125 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)\n "),
15126 pSession->maxRetryCount);
15127 }
15128
15129 return (status);
15130}
Jeff Johnson295189b2012-06-20 16:38:30 -070015131eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
15132{
15133 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer \n ");
15134 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
15135 {
15136 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerJoinRetry));
15137 }
15138
15139 return eHAL_STATUS_SUCCESS;
15140}
15141#endif
15142
15143
15144/*
15145 pBuf points to the beginning of the message
15146 LIM packs disassoc rsp as below,
15147 messageType - 2 bytes
15148 messageLength - 2 bytes
15149 sessionId - 1 byte
15150 transactionId - 2 bytes (tANI_U16)
15151 reasonCode - 4 bytes (sizeof(tSirResultCodes))
15152 peerMacAddr - 6 bytes
15153 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
15154*/
15155static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
15156{
15157 if(pBuf && pRsp)
15158 {
15159 pBuf += 4; //skip type and length
15160 pRsp->sessionId = *pBuf++;
15161 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
15162 pBuf += 2;
15163 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
15164 pBuf += 4;
15165 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
15166 }
15167}
15168
Jeff Johnsond13512a2012-07-17 11:42:19 -070015169eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
15170{
15171 static uNvTables nvTables;
15172 eHalStatus status = eHAL_STATUS_SUCCESS;
15173 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
15174
15175 /* read the country code from NV and use it */
15176 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
15177 {
15178 palCopyMemory( pMac->hHdd, pCountry,
15179 nvTables.defaultCountryTable.countryCode,
15180 WNI_CFG_COUNTRY_CODE_LEN );
15181 return status;
15182 }
15183 else
15184 {
15185 palCopyMemory( pMac->hHdd, pCountry,
15186 "XXX",
15187 WNI_CFG_COUNTRY_CODE_LEN );
15188 status = eHAL_STATUS_FAILURE;
15189 return status;
15190 }
15191}
15192
15193eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
15194{
15195 palCopyMemory( pMac->hHdd, pCountry,
15196 pMac->scan.countryCode11d,
15197 WNI_CFG_COUNTRY_CODE_LEN );
15198 return eHAL_STATUS_SUCCESS;
15199}