blob: 35cfc6946b4b0a6d2fff7e8fd943d27405f17a63 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
42/** ------------------------------------------------------------------------- *
43 ------------------------------------------------------------------------- *
Jeff Johnsone7245742012-09-05 17:12:55 -070044
Jeff Johnson295189b2012-06-20 16:38:30 -070045
46 \file csrApiRoam.c
47
48 Implementation for the Common Roaming interfaces.
49
50 Copyright (C) 2008 Qualcomm, Incorporated
51
52
53 ========================================================================== */
Jeff Johnson295189b2012-06-20 16:38:30 -070054/*===========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070055 EDIT HISTORY FOR FILE
56
Jeff Johnson295189b2012-06-20 16:38:30 -070057 This section contains comments describing changes made to the module.
58 Notice that changes are listed in reverse chronological order.
59
Jeff Johnson295189b2012-06-20 16:38:30 -070060 when who what, where, why
61---------- --- --------------------------------------------------------
6206/03/10 js Added support to hostapd driven
63 * deauth/disassoc/mic failure
Jeff Johnson295189b2012-06-20 16:38:30 -070064===========================================================================*/
Jeff Johnson295189b2012-06-20 16:38:30 -070065#include "aniGlobal.h" //for tpAniSirGlobal
66#include "wlan_qct_wda.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070067#include "halMsgApi.h" //for HAL_STA_INVALID_IDX.
Jeff Johnsone7245742012-09-05 17:12:55 -070068#include "limUtils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070069#include "palApi.h"
70#include "csrInsideApi.h"
71#include "smsDebug.h"
72#include "logDump.h"
73#include "smeQosInternal.h"
74#include "wlan_qct_tl.h"
75#include "smeInside.h"
76#include "vos_diag_core_event.h"
77#include "vos_diag_core_log.h"
78#include "csrApi.h"
79#include "pmc.h"
80#include "vos_nvitem.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070081#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
82#include "csrNeighborRoam.h"
83#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
Jeff Johnson295189b2012-06-20 16:38:30 -070084#ifdef FEATURE_WLAN_CCX
85#include "csrCcx.h"
86#endif /* FEATURE_WLAN_CCX */
Jeff Johnson295189b2012-06-20 16:38:30 -070087#define CSR_NUM_IBSS_START_CHANNELS_50 4
88#define CSR_NUM_IBSS_START_CHANNELS_24 3
89#define CSR_DEF_IBSS_START_CHANNEL_50 36
90#define CSR_DEF_IBSS_START_CHANNEL_24 1
91#define CSR_IBSS_JOIN_TIMEOUT_PERIOD ( 1 * PAL_TIMER_TO_SEC_UNIT ) // 1 second
Srikant Kuppa2062aaf2012-12-27 17:36:41 -080092#define CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD ( 5 * PAL_TIMER_TO_SEC_UNIT ) // 5 seconds, for WPA, WPA2, CCKM
Jeff Johnson295189b2012-06-20 16:38:30 -070093#define CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD ( 120 * PAL_TIMER_TO_SEC_UNIT ) // 120 seconds, for WPS
94/*---------------------------------------------------------------------------
95 OBIWAN recommends [8 10]% : pick 9%
96---------------------------------------------------------------------------*/
97#define CSR_VCC_UL_MAC_LOSS_THRESHOLD 9
Jeff Johnson295189b2012-06-20 16:38:30 -070098/*---------------------------------------------------------------------------
99 OBIWAN recommends -85dBm
100---------------------------------------------------------------------------*/
101#define CSR_VCC_RSSI_THRESHOLD 80
102#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD 500 //ms
103#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS 2000 //ms
104#define CSR_MIN_TL_STAT_QUERY_PERIOD 500 //ms
105#define CSR_DIAG_LOG_STAT_PERIOD 3000 //ms
Jeff Johnson295189b2012-06-20 16:38:30 -0700106//We use constatnt 4 here
107//This macro returns true when higher AC parameter is bigger than lower AC for a difference
108//The bigger the number, the less chance of TX
109//It must put lower AC as the first parameter.
110#define SME_DETECT_AC_WEIGHT_DIFF(loAC, hiAC) (v_BOOL_t)(((hiAC) > (loAC)) ? (((hiAC)-(loAC)) > 4) : 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700111//Flag to send/do not send disassoc frame over the air
112#define CSR_DONT_SEND_DISASSOC_OVER_THE_AIR 1
Jeff Johnson295189b2012-06-20 16:38:30 -0700113#define RSSI_HACK_BMPS (-40)
Jeff Johnsone7245742012-09-05 17:12:55 -0700114#define MAX_CB_VALUE_IN_INI (2)
115
Jeff Johnson295189b2012-06-20 16:38:30 -0700116/*--------------------------------------------------------------------------
117 Static Type declarations
118 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800119static tCsrRoamSession csrRoamRoamSession[CSR_ROAM_SESSION_MAX];
Srinivas Girigowdade697412013-02-14 16:31:48 -0800120#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
121static const char KR_3[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
122 36, 40, 44, 48, 52, 56, 60, 64, 100, 104,
123 108, 112, 116, 120, 124, 149, 153, 157, 161};
124static const char KR_24[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
125 36, 40, 44, 48, 52, 56, 60, 64, 100, 104,
126 108, 112, 116, 120, 124, 149, 153, 157, 161};
127static const char KR_25[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
128 36, 40, 44, 48, 149, 153, 157, 161};
129#endif
130
Jeff Johnson295189b2012-06-20 16:38:30 -0700131/*--------------------------------------------------------------------------
132 Type declarations
133 ------------------------------------------------------------------------*/
134#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700135int diagAuthTypeFromCSRType(eCsrAuthType authType)
136{
137 int n = AUTH_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700138 switch(authType)
139 {
140 case eCSR_AUTH_TYPE_SHARED_KEY:
141 n = AUTH_SHARED;
142 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700143 case eCSR_AUTH_TYPE_WPA:
144 n = AUTH_WPA_EAP;
145 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700146 case eCSR_AUTH_TYPE_WPA_PSK:
147 n = AUTH_WPA_PSK;
148 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700149 case eCSR_AUTH_TYPE_RSN:
150 n = AUTH_WPA2_EAP;
151 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700152 case eCSR_AUTH_TYPE_RSN_PSK:
153 n = AUTH_WPA2_PSK;
154 break;
155#ifdef FEATURE_WLAN_WAPI
156 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
157 n = AUTH_WAPI_CERT;
158 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700159 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
160 n = AUTH_WAPI_PSK;
161 break;
162#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -0700163 default:
164 break;
165 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700166 return (n);
167}
Jeff Johnson295189b2012-06-20 16:38:30 -0700168int diagEncTypeFromCSRType(eCsrEncryptionType encType)
169{
170 int n = ENC_MODE_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700171 switch(encType)
172 {
173 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
174 case eCSR_ENCRYPT_TYPE_WEP40:
175 n = ENC_MODE_WEP40;
176 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700177 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
178 case eCSR_ENCRYPT_TYPE_WEP104:
179 n = ENC_MODE_WEP104;
180 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700181 case eCSR_ENCRYPT_TYPE_TKIP:
182 n = ENC_MODE_TKIP;
183 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700184 case eCSR_ENCRYPT_TYPE_AES:
185 n = ENC_MODE_AES;
186 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700187#ifdef FEATURE_WLAN_WAPI
188 case eCSR_ENCRYPT_TYPE_WPI:
189 n = ENC_MODE_SMS4;
190 break;
191#endif /* FEATURE_WLAN_WAPI */
192 default:
193 break;
194 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700195 return (n);
196}
Jeff Johnson295189b2012-06-20 16:38:30 -0700197#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700198static const tANI_U8 csrStartIbssChannels50[ CSR_NUM_IBSS_START_CHANNELS_50 ] = { 36, 40, 44, 48};
199static const tANI_U8 csrStartIbssChannels24[ CSR_NUM_IBSS_START_CHANNELS_24 ] = { 1, 6, 11 };
Jeff Johnson295189b2012-06-20 16:38:30 -0700200static void initConfigParam(tpAniSirGlobal pMac);
201static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
202 eCsrRoamCompleteResult Result, void *Context );
203static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId,
204 tCsrRoamProfile *pProfile,
205 tANI_BOOLEAN *pfSameIbss );
206static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirSmeNewBssInfo *pNewBss );
207static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -0700208 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes);
209static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700210eHalStatus csrInitGetChannels(tpAniSirGlobal pMac);
211static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result );
212eHalStatus csrRoamOpen(tpAniSirGlobal pMac);
213eHalStatus csrRoamClose(tpAniSirGlobal pMac);
214void csrRoamMICErrorTimerHandler(void *pv);
215void csrRoamTKIPCounterMeasureTimerHandler(void *pv);
216tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2);
217
218static eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval);
219static eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId);
220static void csrRoamRoamingTimerHandler(void *pv);
221eHalStatus csrRoamStartIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval);
222eHalStatus csrRoamStopIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId);
223static void csrRoamIbssJoinTimerHandler(void *pv);
224eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval);
225eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac);
226static void csrRoamWaitForKeyTimeOutHandler(void *pv);
227
228static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnsone7245742012-09-05 17:12:55 -0700229static eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700230static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo );
231eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
232 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
233 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
234 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
235 tANI_U8 *pKeyRsc );
236static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
237 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes,
238 tCsrRoamProfile *pProfile );
239void csrRoamStatisticsTimerHandler(void *pv);
240void csrRoamStatsGlobalClassDTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700241static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid);
242VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
243 v_U8_t rssiNotification,
244 void * context);
245static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId);
246void csrRoamVccTrigger(tpAniSirGlobal pMac);
247eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId);
248/*
249 pStaEntry is no longer invalid upon the return of this function.
250*/
251static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700252static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,tANI_U8 operationChn, eCsrBand *pBand );
Jeff Johnson295189b2012-06-20 16:38:30 -0700253static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700254tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
255 tDblLinkList *pStaList,
256 tCsrStatsClientReqInfo *pStaEntry);
257void csrRoamStatsClientTimerHandler(void *pv);
258tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
259 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId);
260void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
261 tCsrStatsCallback callback, tANI_U8 staId, void *pContext);
Jeff Johnsone7245742012-09-05 17:12:55 -0700262void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats);
Jeff Johnson295189b2012-06-20 16:38:30 -0700263void csrRoamTlStatsTimerHandler(void *pv);
264void csrRoamPeStatsTimerHandler(void *pv);
265tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
266void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry);
267tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
268eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac);
269static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac );
270static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc );
271static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId );
272static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
273 tCsrRoamSetKey *pSetKey, tANI_U32 roamId );
274//static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand );
275static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
276void csrRoamReissueRoamCommand(tpAniSirGlobal pMac);
277#ifdef FEATURE_WLAN_BTAMP_UT_RF
278void csrRoamJoinRetryTimerHandler(void *pv);
279#endif
280extern void SysProcessMmhMsg(tpAniSirGlobal pMac, tSirMsgQ* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700281extern void btampEstablishLogLinkHdlr(void* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700282static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700283void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand);
Jeff Johnson295189b2012-06-20 16:38:30 -0700284
285//Initialize global variables
286static void csrRoamInitGlobals(tpAniSirGlobal pMac)
287{
288 if(pMac)
289 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800290 vos_mem_zero(&csrRoamRoamSession, sizeof(csrRoamRoamSession));
291 pMac->roam.roamSession = csrRoamRoamSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700292 }
293 return;
294}
295
Jeff Johnson295189b2012-06-20 16:38:30 -0700296static void csrRoamDeInitGlobals(tpAniSirGlobal pMac)
297{
298 if(pMac)
299 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800300 pMac->roam.roamSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700301 }
302 return;
303}
Jeff Johnson295189b2012-06-20 16:38:30 -0700304eHalStatus csrOpen(tpAniSirGlobal pMac)
305{
306 eHalStatus status = eHAL_STATUS_SUCCESS;
307 static uNvTables nvTables;
308 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700309 v_REGDOMAIN_t regId;
310 tANI_U32 i;
311
312 do
313 {
314 /* Initialize CSR Roam Globals */
315 csrRoamInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700316 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
317 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i);
318
319 initConfigParam(pMac);
320 if(!HAL_STATUS_SUCCESS((status = csrScanOpen(pMac))))
321 break;
322 if(!HAL_STATUS_SUCCESS((status = csrRoamOpen(pMac))))
323 break;
324 pMac->roam.nextRoamId = 1; //Must not be 0
325 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.statsClientReqList)))
326 break;
327 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.peStatsReqList)))
328 break;
329 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.roamCmdPendingList)))
330 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700331 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
332 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
333 {
334 palCopyMemory( pMac->hHdd, pMac->scan.countryCodeDefault,
335 nvTables.defaultCountryTable.countryCode, WNI_CFG_COUNTRY_CODE_LEN );
336 status = eHAL_STATUS_SUCCESS;
337 }
338 else
339 {
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 Nakkalab9185f22012-12-21 08:03:42 -0800439
Jeff Johnson295189b2012-06-20 16:38:30 -0700440 csrStop(pMac);
441 csrRoamClose(pMac);
442 csrScanClose(pMac);
443 csrLLClose(&pMac->roam.statsClientReqList);
444 csrLLClose(&pMac->roam.peStatsReqList);
445 csrLLClose(&pMac->roam.roamCmdPendingList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700446 /* DeInit Globals */
447 csrRoamDeInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700448 return (status);
449}
Jeff Johnson295189b2012-06-20 16:38:30 -0700450eHalStatus csrStart(tpAniSirGlobal pMac)
451{
452 eHalStatus status = eHAL_STATUS_SUCCESS;
453 tANI_U32 i;
454
455 do
456 {
457 //save the global vos context
458 pMac->roam.gVosContext = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
459 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
460 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, i );
461
462 status = csrRoamStart(pMac);
463 if(!HAL_STATUS_SUCCESS(status)) break;
464 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE;
465 status = pmcRegisterPowerSaveCheck(pMac, csrCheckPSReady, pMac);
466 if(!HAL_STATUS_SUCCESS(status)) break;
467 pMac->roam.sPendingCommands = 0;
468 csrScanEnable(pMac);
469#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
470 status = csrNeighborRoamInit(pMac);
471#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
472 pMac->roam.tlStatsReqInfo.numClient = 0;
473 pMac->roam.tlStatsReqInfo.periodicity = 0;
474 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
475 //init the link quality indication also
476 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_MIN_IND;
477 if(!HAL_STATUS_SUCCESS(status))
478 {
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 Nakkalab9185f22012-12-21 08:03:42 -0800512 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700513
514 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
515 {
516 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP ,i );
517 pMac->roam.curSubState[i] = eCSR_ROAM_SUBSTATE_NONE;
518 }
519
520 return (eHAL_STATUS_SUCCESS);
521}
522
Jeff Johnson295189b2012-06-20 16:38:30 -0700523eHalStatus csrReady(tpAniSirGlobal pMac)
524{
525 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700526 csrScanGetSupportedChannels( pMac );
527 //WNI_CFG_VALID_CHANNEL_LIST should be set by this time
528 //use it to init the background scan list
529 csrInitBGScanChannelList(pMac);
530 /* HDD issues the init scan */
531 csrScanStartResultAgingTimer(pMac);
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -0800532 /* If the gScanAgingTime is set to '0' then scan results aging timeout
533 based on timer feature is not enabled*/
534 if(0 != pMac->scan.scanResultCfgAgingTime )
535 {
536 csrScanStartResultCfgAgingTimer(pMac);
537 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700538 //Store the AC weights in TL for later use
539 WLANTL_GetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
Jeff Johnson295189b2012-06-20 16:38:30 -0700540 status = csrInitChannelList( pMac );
541 if ( ! HAL_STATUS_SUCCESS( status ) )
542 {
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 Girigowdac84c57c2013-02-19 17:41:56 -0800635 if ( CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700636 {
637 status = eHAL_STATUS_SUCCESS;
638 *pState = pMac->roam.roamSession[sessionId].connectState;
639 }
640 return (status);
641}
642
Jeff Johnson295189b2012-06-20 16:38:30 -0700643eHalStatus csrRoamCopyConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
644{
645 eHalStatus status = eHAL_STATUS_FAILURE;
646 tANI_U32 size = 0;
647 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -0700648
649 if(!pSession)
650 {
651 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
652 return eHAL_STATUS_FAILURE;
653 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700654
655 if(pProfile)
656 {
657 if(pSession->pConnectBssDesc)
658 {
659 do
660 {
661 size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length);
662 if(size)
663 {
664 status = palAllocateMemory(pMac->hHdd, (void **)&pProfile->pBssDesc, size);
665 if(HAL_STATUS_SUCCESS(status))
666 {
667 palCopyMemory(pMac->hHdd, pProfile->pBssDesc, pSession->pConnectBssDesc, size);
668 }
669 else
670 break;
671 }
672 else
673 {
674 pProfile->pBssDesc = NULL;
675 }
676 pProfile->AuthType = pSession->connectedProfile.AuthType;
677 pProfile->EncryptionType = pSession->connectedProfile.EncryptionType;
678 pProfile->mcEncryptionType = pSession->connectedProfile.mcEncryptionType;
679 pProfile->BSSType = pSession->connectedProfile.BSSType;
680 pProfile->operationChannel = pSession->connectedProfile.operationChannel;
681 pProfile->CBMode = pSession->connectedProfile.CBMode;
682 palCopyMemory(pMac->hHdd, &pProfile->bssid, &pSession->connectedProfile.bssid, sizeof(tCsrBssid));
683 palCopyMemory(pMac->hHdd, &pProfile->SSID, &pSession->connectedProfile.SSID, sizeof(tSirMacSSid));
684#ifdef WLAN_FEATURE_VOWIFI_11R
685 if (pSession->connectedProfile.MDID.mdiePresent)
686 {
687 pProfile->MDID.mdiePresent = 1;
688 pProfile->MDID.mobilityDomain = pSession->connectedProfile.MDID.mobilityDomain;
689 }
690 else
691 {
692 pProfile->MDID.mdiePresent = 0;
693 pProfile->MDID.mobilityDomain = 0;
694 }
695#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700696#ifdef FEATURE_WLAN_CCX
697 pProfile->isCCXAssoc = pSession->connectedProfile.isCCXAssoc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700698 if (csrIsAuthTypeCCX(pSession->connectedProfile.AuthType))
699 {
700 palCopyMemory( pMac->hHdd, pProfile->ccxCckmInfo.krk,
701 pSession->connectedProfile.ccxCckmInfo.krk, CSR_KRK_KEY_LEN );
702 pProfile->ccxCckmInfo.reassoc_req_num=
703 pSession->connectedProfile.ccxCckmInfo.reassoc_req_num;
704 pProfile->ccxCckmInfo.krk_plumbed =
705 pSession->connectedProfile.ccxCckmInfo.krk_plumbed;
706 }
707#endif
708 }while(0);
709 }
710 }
711
712 return (status);
713}
714
Jeff Johnson295189b2012-06-20 16:38:30 -0700715eHalStatus csrRoamGetConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
716{
717 eHalStatus status = eHAL_STATUS_FAILURE;
718
719 if(csrIsConnStateConnected(pMac, sessionId))
720 {
721 if(pProfile)
722 {
723 status = csrRoamCopyConnectProfile(pMac, sessionId, pProfile);
724 }
725 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700726 return (status);
727}
Jeff Johnson295189b2012-06-20 16:38:30 -0700728eHalStatus csrRoamFreeConnectProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile)
729{
730 eHalStatus status = eHAL_STATUS_SUCCESS;
731
732 if(pProfile->pBssDesc)
733 {
734 palFreeMemory(pMac->hHdd, pProfile->pBssDesc);
735 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700736 if(pProfile->pAddIEAssoc)
737 {
738 palFreeMemory(pMac->hHdd, pProfile->pAddIEAssoc);
739 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700740 palZeroMemory(pMac->hHdd, pProfile, sizeof(tCsrRoamConnectedProfile));
741 pProfile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
742 return (status);
743}
744
Jeff Johnson295189b2012-06-20 16:38:30 -0700745static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo )
746{
747 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700748 if( pConnectedInfo->pbFrames )
749 {
750 palFreeMemory( pMac->hHdd, pConnectedInfo->pbFrames );
751 pConnectedInfo->pbFrames = NULL;
752 }
753 pConnectedInfo->nBeaconLength = 0;
754 pConnectedInfo->nAssocReqLength = 0;
755 pConnectedInfo->nAssocRspLength = 0;
756 pConnectedInfo->staId = 0;
757#ifdef WLAN_FEATURE_VOWIFI_11R
758 pConnectedInfo->nRICRspLength = 0;
759#endif
760#ifdef FEATURE_WLAN_CCX
761 pConnectedInfo->nTspecIeLength = 0;
762#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700763 return ( status );
764}
765
Jeff Johnson295189b2012-06-20 16:38:30 -0700766
767
Jeff Johnsone7245742012-09-05 17:12:55 -0700768
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700769void csrReleaseCommandPreauth(tpAniSirGlobal pMac, tSmeCmd *pCommand)
770{
771 csrReinitPreauthCmd(pMac, pCommand);
772 csrReleaseCommand( pMac, pCommand );
773}
774
Jeff Johnson295189b2012-06-20 16:38:30 -0700775void csrReleaseCommandRoam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
776{
777 csrReinitRoamCmd(pMac, pCommand);
778 csrReleaseCommand( pMac, pCommand );
779}
780
Jeff Johnson295189b2012-06-20 16:38:30 -0700781void csrReleaseCommandScan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
782{
783 csrReinitScanCmd(pMac, pCommand);
784 csrReleaseCommand( pMac, pCommand );
785}
786
Jeff Johnson295189b2012-06-20 16:38:30 -0700787void csrReleaseCommandWmStatusChange(tpAniSirGlobal pMac, tSmeCmd *pCommand)
788{
789 csrReinitWmStatusChangeCmd(pMac, pCommand);
790 csrReleaseCommand( pMac, pCommand );
791}
792
Jeff Johnson295189b2012-06-20 16:38:30 -0700793void csrReinitSetKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
794{
795 palZeroMemory(pMac->hHdd, &pCommand->u.setKeyCmd, sizeof(tSetKeyCmd));
796}
797
Jeff Johnson295189b2012-06-20 16:38:30 -0700798void csrReinitRemoveKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
799{
800 palZeroMemory(pMac->hHdd, &pCommand->u.removeKeyCmd, sizeof(tRemoveKeyCmd));
801}
802
Jeff Johnson295189b2012-06-20 16:38:30 -0700803void csrReleaseCommandSetKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
804{
805 csrReinitSetKeyCmd(pMac, pCommand);
806 csrReleaseCommand( pMac, pCommand );
807}
Jeff Johnson295189b2012-06-20 16:38:30 -0700808void csrReleaseCommandRemoveKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
809{
810 csrReinitRemoveKeyCmd(pMac, pCommand);
811 csrReleaseCommand( pMac, pCommand );
812}
Jeff Johnson295189b2012-06-20 16:38:30 -0700813void csrAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
814{
815
816 if( eSmeCsrCommandMask & pCommand->command )
817 {
818 switch (pCommand->command)
819 {
820 case eSmeCommandScan:
Jeff Johnson1250df42012-12-10 14:31:52 -0800821 // We need to inform the requester before dropping the scan command
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 Lokere3527f0c2013-02-24 22:21:28 -0800941 pMac->roam.configParam.nActiveMaxChnTimeBtc = CSR_ACTIVE_MAX_CHANNEL_TIME_BTC;
942 pMac->roam.configParam.nActiveMinChnTimeBtc = CSR_ACTIVE_MIN_CHANNEL_TIME_BTC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700943#ifdef WLAN_AP_STA_CONCURRENCY
944 pMac->roam.configParam.nActiveMaxChnTimeConc = CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
945 pMac->roam.configParam.nActiveMinChnTimeConc = CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
946 pMac->roam.configParam.nPassiveMaxChnTimeConc = CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
947 pMac->roam.configParam.nPassiveMinChnTimeConc = CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
948 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Vinay Malekal05fdc812012-12-17 13:04:30 -0800949 pMac->roam.configParam.nNumChanCombinedConc = CSR_NUM_CHAN_COMBINED_CONC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700950#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700951 pMac->roam.configParam.IsIdleScanEnabled = TRUE; //enable the idle scan by default
952 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
953 pMac->roam.configParam.statsReqPeriodicity = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
954 pMac->roam.configParam.statsReqPeriodicityInPS = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700955#ifdef WLAN_FEATURE_VOWIFI_11R
956 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
957#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700958#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
959 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
960 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold = 120;
961 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold = 125;
962 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
963 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
964 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = 200;
965 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels = 3;
966 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[0] = 1;
967 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[1] = 6;
968 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[2] = 11;
969 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; //20 seconds
Srinivas Girigowdade697412013-02-14 16:31:48 -0800970 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700971#endif
Jeff Johnsone7245742012-09-05 17:12:55 -0700972#ifdef WLAN_FEATURE_11AC
973 pMac->roam.configParam.nVhtChannelWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
974#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700975
976 pMac->roam.configParam.addTSWhenACMIsOff = 0;
977 pMac->roam.configParam.fScanTwice = eANI_BOOLEAN_FALSE;
Mohit Khanna349bc392012-09-11 17:24:52 -0700978
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -0700979 //Remove this code once SLM_Sessionization is supported
980 //BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnsone7245742012-09-05 17:12:55 -0700981 pMac->roam.configParam.doBMPSWorkaround = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700982
Jeff Johnsone7245742012-09-05 17:12:55 -0700983}
Jeff Johnson295189b2012-06-20 16:38:30 -0700984eCsrBand csrGetCurrentBand(tHalHandle hHal)
985{
986 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
987 return pMac->roam.configParam.bandCapability;
988}
Srinivas Girigowdade697412013-02-14 16:31:48 -0800989
990#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
991tANI_BOOLEAN csrIsChannelInCountryValidList(tpAniSirGlobal pMac, tANI_U8 channel)
992{
993 /* Get country code from CFG */
994 tANI_U8 *pCountryCode = pMac->scan.countryCodeCurrent;
995 tANI_U8 i = 0;
996 v_BOOL_t retVal = FALSE;
997 tANI_U8 *pCountryValidChannelList = pMac->roam.neighborRoamInfo.cfgParams.countryChannelInfo.countryValidChannelList.ChannelList;
998 tANI_U8 *pNumChannels = &pMac->roam.neighborRoamInfo.cfgParams.countryChannelInfo.countryValidChannelList.numOfChannels;
999
1000 /* Compare against KR valid list */
1001 if ((0 == strncmp(pCountryCode, "KR", 2)) &&
1002 (NULL != pCountryValidChannelList))
1003 {
1004 for (i = 0; i <(*pNumChannels); i++)
1005 {
1006 if (channel == pCountryValidChannelList[i])
1007 {
1008 retVal = TRUE;
1009 break;
1010 }
1011 }
1012 }
1013 else
1014 {
1015 retVal = csrRoamIsChannelValid(pMac, channel);
1016 }
1017
1018 return retVal;
1019}
1020
1021void csr_SetRevision(tpAniSirGlobal pMac, tANI_U8 revision)
1022{
1023 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1024 pNeighborRoamInfo->cfgParams.countryChannelInfo.revision = revision;
1025}
1026
1027/*
1028 This function flushes the roam scan cache and creates fresh cache
1029 based on the input channel list
1030*/
1031eHalStatus csrFlushAndCreateBgScanRoamChannelList(tpAniSirGlobal pMac,
1032 const tANI_U8 *pChannelList,
1033 const tANI_U8 numChannels)
1034{
1035 eHalStatus status = eHAL_STATUS_SUCCESS;
1036 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1037
1038 /* Free up the memory first (if required) */
1039 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1040 {
1041 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
1042 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
1043 }
1044 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1045
1046 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
1047 vos_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1048
1049 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1050 {
1051 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1052 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1053 return eHAL_STATUS_RESOURCES;
1054 }
1055
1056 /* Update the roam global structure */
1057 palCopyMemory(pMac->hHdd, pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
1058 pChannelList,
1059 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1060 return status;
1061}
1062
1063/* This function modifies the bgscan channel list set via config ini or
1064 runtime, whenever the band changes.
1065 if the band is auto, then no operation is performed on the channel list
1066 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1067 if the band is 5G, then make sure channel list contains only 5G valid channels
1068*/
1069eHalStatus csrUpdateBgScanConfigIniChannelList(tpAniSirGlobal pMac,
1070 eCsrBand eBand)
1071{
1072 eHalStatus status = eHAL_STATUS_SUCCESS;
1073 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1074 tANI_U8 outNumChannels = 0;
1075 tANI_U8 inNumChannels = 0;
1076 tANI_U8 *inPtr = NULL;
1077 tANI_U8 i = 0;
1078 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1079
1080 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1081
1082 {
1083 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1084 "No update required for channel list "
1085 "either cfg.ini channel list is not set up or "
1086 "auto band (Band %d)", eBand);
1087 return status;
1088 }
1089
1090 inNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
1091 inPtr = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
1092 if (eCSR_BAND_24 == eBand)
1093 {
1094 for (i = 0; i < inNumChannels; i++)
1095 {
1096 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrIsChannelInCountryValidList(pMac, inPtr[i]))
1097 {
1098 ChannelList[outNumChannels++] = inPtr[i];
1099 }
1100 }
1101 csrFlushAndCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
1102 }
1103 else if (eCSR_BAND_5G == eBand)
1104 {
1105 for (i = 0; i < inNumChannels; i++)
1106 {
1107 /* Add 5G Non-DFS channel */
1108 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
1109 csrIsChannelInCountryValidList(pMac, inPtr[i]) &&
1110 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1111 {
1112 ChannelList[outNumChannels++] = inPtr[i];
1113 }
1114 }
1115 csrFlushAndCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
1116 }
1117 else if (eCSR_BAND_ALL == eBand)
1118 {
1119 for (i = 0; i < inNumChannels; i++)
1120 {
1121 if (csrIsChannelInCountryValidList(pMac, inPtr[i]) &&
1122 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1123 {
1124 ChannelList[outNumChannels++] = inPtr[i];
1125 }
1126 }
1127 csrFlushAndCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
1128 }
1129 else
1130 {
1131 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1132 "Invalid band, No operation carried out (Band %d)", eBand);
1133 status = eHAL_STATUS_INVALID_PARAMETER;
1134 }
1135
1136 return status;
1137}
1138
1139/*
1140 This function initializes the valid channel list based on country code
1141*/
1142eHalStatus csrInitCountryValidChannelList(tpAniSirGlobal pMac,
1143 tANI_U8 Revision)
1144{
1145 eHalStatus status = eHAL_STATUS_SUCCESS;
1146 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1147 tANI_U8 *pOutChannelList = pNeighborRoamInfo->cfgParams.countryChannelInfo.countryValidChannelList.ChannelList;
1148 tANI_U8 *pNumChannels = &pNeighborRoamInfo->cfgParams.countryChannelInfo.countryValidChannelList.numOfChannels;
1149 const tANI_U8 *pChannelList = NULL;
1150
1151 if (SME_KR_3 == Revision)
1152 {
1153 pChannelList = KR_3;
1154 *pNumChannels = sizeof(KR_3)/sizeof(KR_3[0]);
1155 }
1156 else if (SME_KR_24 == Revision)
1157 {
1158 pChannelList = KR_24;
1159 *pNumChannels = sizeof(KR_24)/sizeof(KR_24[0]);
1160 }
1161 else if (SME_KR_25 == Revision)
1162 {
1163 pChannelList = KR_25;
1164 *pNumChannels = sizeof(KR_25)/sizeof(KR_25[0]);
1165 }
1166 else
1167 return eHAL_STATUS_INVALID_PARAMETER;
1168
1169 /* Free up the memory first */
1170 if (NULL != pOutChannelList)
1171 {
1172 vos_mem_free(pOutChannelList);
1173 pOutChannelList = NULL;
1174 }
1175
1176 pOutChannelList = vos_mem_malloc(*pNumChannels);
1177
1178 if (NULL == pOutChannelList)
1179 {
1180 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1181 *pNumChannels = 0;
1182 return eHAL_STATUS_RESOURCES;
1183 }
1184
1185 /* Update the roam global structure */
1186 palCopyMemory(pMac->hHdd, pOutChannelList, pChannelList, *pNumChannels);
1187 return status;
1188}
1189
1190#endif
1191
Jeff Johnson295189b2012-06-20 16:38:30 -07001192eHalStatus csrSetBand(tHalHandle hHal, eCsrBand eBand)
1193{
1194 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1195 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001196 if (CSR_IS_PHY_MODE_A_ONLY(pMac) &&
1197 (eBand == eCSR_BAND_24))
1198 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001199 /* DOT11 mode configured to 11a only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001200 request to change the band to 2.4 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001201 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
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 Girigowdade697412013-02-14 16:31:48 -08001210 /* DOT11 mode configured to 11b/11g only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001211 request to change the band to 5 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001212 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
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 Girigowdade697412013-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 Girigowdade697412013-02-14 16:31:48 -08001219 pMac->roam.configParam.eBand = eBand;
1220 pMac->roam.configParam.bandCapability = eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001221 csrScanGetSupportedChannels( pMac );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001222#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1223 csrUpdateBgScanConfigIniChannelList( pMac, eBand );
1224#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001225 status = csrInitGetChannels( pMac );
1226 if (eHAL_STATUS_SUCCESS == status)
1227 csrInitChannelList( hHal );
1228 return status;
1229}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001230
1231
Jeff Johnsone7245742012-09-05 17:12:55 -07001232/* The funcns csrConvertCBIniValueToPhyCBState and csrConvertPhyCBStateToIniValue have been
1233 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1234 * Ideally we should have kept the ini value and enum value same and representing the same
1235 * cb values as in 11n standard i.e.
1236 * Set to 1 (SCA) if the secondary channel is above the primary channel
1237 * Set to 3 (SCB) if the secondary channel is below the primary channel
1238 * Set to 0 (SCN) if no secondary channel is present
1239 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1240 * 0 - secondary none
1241 * 1 - secondary LOW
1242 * 2 - secondary HIGH
1243 * and convert to enum value used within the driver in csrChangeDefaultConfigParam using this funcn
1244 * The enum values are as follows:
1245 * PHY_SINGLE_CHANNEL_CENTERED = 0
1246 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1247 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1248 */
1249ePhyChanBondState csrConvertCBIniValueToPhyCBState(v_U32_t cbIniValue)
1250{
1251
1252 ePhyChanBondState phyCbState;
1253 switch (cbIniValue) {
1254 // secondary none
1255 case 0:
1256 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1257 break;
1258 // secondary LOW
1259 case 1:
1260 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1261 break;
1262 // secondary HIGH
1263 case 2:
1264 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1265 break;
1266#ifdef WLAN_FEATURE_11AC
1267 case 3:
1268 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
1269 break;
1270 case 4:
1271 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1272 break;
1273 case 5:
1274 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1275 break;
1276 case 6:
1277 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1278 break;
1279 case 7:
1280 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
1281 break;
1282 case 8:
1283 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1284 break;
1285 case 9:
1286 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
1287 break;
1288#endif
1289 default:
1290 // If an invalid value is passed, disable CHANNEL BONDING
1291 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1292 break;
1293 }
1294 return phyCbState;
1295}
1296
1297v_U32_t csrConvertPhyCBStateToIniValue(ePhyChanBondState phyCbState)
1298{
1299
1300 v_U32_t cbIniValue;
1301 switch (phyCbState) {
1302 // secondary none
1303 case PHY_SINGLE_CHANNEL_CENTERED:
1304 cbIniValue = 0;
1305 break;
1306 // secondary LOW
1307 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
1308 cbIniValue = 1;
1309 break;
1310 // secondary HIGH
1311 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
1312 cbIniValue = 2;
1313 break;
1314#ifdef WLAN_FEATURE_11AC
1315 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1316 cbIniValue = 3;
1317 break;
1318 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
1319 cbIniValue = 4;
1320 break;
1321 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1322 cbIniValue = 5;
1323 break;
1324 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
1325 cbIniValue = 6;
1326 break;
1327 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
1328 cbIniValue = 7;
1329 break;
1330 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
1331 cbIniValue = 8;
1332 break;
1333 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
1334 cbIniValue = 9;
1335 break;
1336#endif
1337 default:
1338 // return some invalid value
1339 cbIniValue = 10;
1340 break;
1341 }
1342 return cbIniValue;
1343}
Jeff Johnson295189b2012-06-20 16:38:30 -07001344
1345eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1346{
1347 eHalStatus status = eHAL_STATUS_SUCCESS;
1348
1349 if(pParam)
1350 {
1351 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1352 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1353 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1354 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1355 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1356 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1357
1358 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
Mohit Khanna7ed53f02012-09-11 17:52:10 -07001359 pMac->roam.configParam.fAllowMCCGODiffBI = pParam->fAllowMCCGODiffBI;
1360
Jeff Johnsone7245742012-09-05 17:12:55 -07001361 /* channelBondingMode5GHz plays a dual role right now
1362 * INFRA STA will use this non zero value as CB enabled and SOFTAP will use this non-zero value to determine the secondary channel offset
1363 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1364 */
1365 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
1366 {
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 Lokere3527f0c2013-02-24 22:21:28 -08001389 if (pParam->nActiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001390 {
1391 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
1392 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001393 if (pParam->nActiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001394 {
1395 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
1396 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001397 if (pParam->nPassiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001398 {
1399 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
1400 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001401 if (pParam->nPassiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001402 {
1403 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
1404 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001405 if (pParam->nActiveMaxChnTimeBtc)
1406 {
1407 pMac->roam.configParam.nActiveMaxChnTimeBtc = pParam->nActiveMaxChnTimeBtc;
1408 }
1409 if (pParam->nActiveMinChnTimeBtc)
1410 {
1411 pMac->roam.configParam.nActiveMinChnTimeBtc = pParam->nActiveMinChnTimeBtc;
1412 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001413#ifdef WLAN_AP_STA_CONCURRENCY
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001414 if (pParam->nActiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001415 {
1416 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1417 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001418 if (pParam->nActiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001419 {
1420 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1421 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001422 if (pParam->nPassiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001423 {
1424 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1425 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001426 if (pParam->nPassiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001427 {
1428 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1429 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001430 if (pParam->nRestTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001431 {
1432 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1433 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001434 if (pParam->nNumChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -08001435 {
1436 pMac->roam.configParam.nNumChanCombinedConc = pParam->nNumChanCombinedConc;
1437 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001438#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001439 //if upper layer wants to disable idle scan altogether set it to 0
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001440 if (pParam->impsSleepTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001441 {
1442 //Change the unit from second to microsecond
1443 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001444 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1445 {
1446 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1447 }
1448 else
1449 {
1450 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1451 }
1452 }
1453 else
1454 {
1455 pMac->roam.configParam.impsSleepTime = 0;
1456 }
1457 pMac->roam.configParam.eBand = pParam->eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001458 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1459 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07001460 //if HDD passed down non zero values for age params, then only update,
1461 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001462 if (pParam->nScanResultAgeCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07001463 {
1464 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1465 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001466 if(pParam->scanAgeTimeNCNPS)
1467 {
1468 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1469 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001470 if(pParam->scanAgeTimeNCPS)
1471 {
1472 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1473 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001474 if(pParam->scanAgeTimeCNPS)
1475 {
1476 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1477 }
1478 if(pParam->scanAgeTimeCPS)
1479 {
1480 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1481 }
1482
1483 csrAssignRssiForCategory(pMac, pParam->bCatRssiOffset);
1484 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1485 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1486 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1487 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1488 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001489 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1490 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001491 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1492 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1493 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1494 //Assign this before calling CsrInit11dInfo
1495 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001496 if( csrIs11dSupported( pMac ) )
1497 {
1498 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1499 }
1500 else
1501 {
1502 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1503 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001504
1505 /* Initialize the power + channel information if 11h is enabled.
1506 If 11d is enabled this information has already been initialized */
1507 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1508 {
1509 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1510 }
1511
1512
Jeff Johnson295189b2012-06-20 16:38:30 -07001513#ifdef WLAN_FEATURE_VOWIFI_11R
1514 palCopyMemory( pMac->hHdd, &pMac->roam.configParam.csr11rConfig, &pParam->csr11rConfig, sizeof(tCsr11rConfigParams) );
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 Koyyalamudi62b55b02012-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 Koyyalamudid5026072012-11-30 14:56:21 -08001523 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Jeff Johnson295189b2012-06-20 16:38:30 -07001524#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001525#ifdef FEATURE_WLAN_LFR
1526 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
1527#endif
1528
Jeff Johnson295189b2012-06-20 16:38:30 -07001529#ifdef FEATURE_WLAN_CCX
1530 pMac->roam.configParam.isCcxIniFeatureEnabled = pParam->isCcxIniFeatureEnabled;
1531#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001532#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1533 palCopyMemory( pMac->hHdd, &pMac->roam.configParam.neighborRoamConfig, &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams) );
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 Girigowdade697412013-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;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08001556 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001557 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001558 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
1559 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
1560 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
1561 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
1562 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
1563 * single session
1564 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001565 //Remove this code once SLM_Sessionization is supported
1566 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07001567 pMac->roam.configParam.doBMPSWorkaround = 0;
1568
Jeff Johnsone7245742012-09-05 17:12:55 -07001569#ifdef WLAN_FEATURE_11AC
1570 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001571 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001572 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Jeff Johnsone7245742012-09-05 17:12:55 -07001573#endif
Madan Mohan Koyyalamudi3f65e312012-11-06 15:31:12 -08001574 pMac->scan.fIgnore_chan165 = pParam->fIgnore_chan165;
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001575 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001576 }
1577
1578 return status;
1579}
1580
Jeff Johnson295189b2012-06-20 16:38:30 -07001581eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1582{
1583 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001584 if(pParam)
1585 {
1586 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
1587 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
1588 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
1589 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
1590 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
1591 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07001592 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
1593 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001594 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
1595 pParam->phyMode = pMac->roam.configParam.phyMode;
1596 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
1597 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
1598 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
1599 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
1600 pParam->TxRate = pMac->roam.configParam.TxRate;
1601 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
1602 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
1603 pParam->bandCapability = pMac->roam.configParam.bandCapability;
1604 pParam->cbChoice = pMac->roam.configParam.cbChoice;
1605 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07001606 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1607 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
1608 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
1609 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001610#ifdef WLAN_AP_STA_CONCURRENCY
1611 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
1612 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
1613 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
1614 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
1615 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08001616 pParam->nNumChanCombinedConc = pMac->roam.configParam.nNumChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001617#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001618 //Change the unit from microsecond to second
1619 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
1620 pParam->eBand = pMac->roam.configParam.eBand;
1621 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
1622 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
1623 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
1624 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
1625 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
1626 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
1627 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
1628 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
1629 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
1630 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
1631 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
1632 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
1633 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001634 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
1635 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
1636 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
1637 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001638 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
1639 pParam->fValidateList = pMac->roam.configParam.fValidateList;
1640 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
1641 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
Madan Mohan Koyyalamudi3f65e312012-11-06 15:31:12 -08001642 pParam->fIgnore_chan165= pMac->scan.fIgnore_chan165;
Jeff Johnson295189b2012-06-20 16:38:30 -07001643 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001644 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08001645 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08001646 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08001647 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001648
1649#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1650 palCopyMemory( pMac->hHdd, &pParam->neighborRoamConfig, &pMac->roam.configParam.neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams) );
1651#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001652#ifdef WLAN_FEATURE_11AC
1653 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001654 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001655 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Jeff Johnsone7245742012-09-05 17:12:55 -07001656#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001657
1658 csrSetChannels(pMac, pParam);
1659
1660 status = eHAL_STATUS_SUCCESS;
1661 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001662 return (status);
1663}
1664
Jeff Johnson295189b2012-06-20 16:38:30 -07001665eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
1666{
1667 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
1668 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1669 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
1670 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001671 do
1672 {
1673 if(eCSR_BAND_24 == eBand)
1674 {
1675 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
1676 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
1677 }
1678 if(eCSR_BAND_5G == eBand)
1679 {
1680 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
1681 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
1682 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
1683 )
1684 {
1685 break;
1686 }
1687 }
1688 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
1689 {
1690 newPhyMode = eCSR_DOT11_MODE_TAURUS;
1691 }
1692 else if(eCSR_DOT11_MODE_AUTO & phyMode)
1693 {
1694 newPhyMode = eCSR_DOT11_MODE_AUTO;
1695 }
1696 else
1697 {
1698 //Check for dual band and higher capability first
1699 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
1700 {
1701 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
1702 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
1703 }
1704 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
1705 {
1706 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
1707 if(eCSR_BAND_24 == eBand) break;
1708 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
1709 eBand = eCSR_BAND_5G;
1710 }
1711 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
1712 {
1713 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
1714 if(eCSR_BAND_5G == eBand) break;
1715 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
1716 eBand = eCSR_BAND_24;
1717 }
1718 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
1719 {
1720 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
1721 if(eCSR_BAND_5G == eBand) break;
1722 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
1723 eBand = eCSR_BAND_24;
1724 }
1725 else if(eCSR_DOT11_MODE_11n & phyMode)
1726 {
1727 newPhyMode = eCSR_DOT11_MODE_11n;
1728 }
1729 else if(eCSR_DOT11_MODE_abg & phyMode)
1730 {
1731 newPhyMode = eCSR_DOT11_MODE_abg;
1732 }
1733 else if(eCSR_DOT11_MODE_11a & phyMode)
1734 {
1735 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
1736 {
1737 if(eCSR_BAND_ALL == eBand)
1738 {
1739 newPhyMode = eCSR_DOT11_MODE_abg;
1740 }
1741 else
1742 {
1743 //bad setting
1744 break;
1745 }
1746 }
1747 else
1748 {
1749 newPhyMode = eCSR_DOT11_MODE_11a;
1750 eBand = eCSR_BAND_5G;
1751 }
1752 }
1753 else if(eCSR_DOT11_MODE_11g & phyMode)
1754 {
1755 newPhyMode = eCSR_DOT11_MODE_11g;
1756 eBand = eCSR_BAND_24;
1757 }
1758 else if(eCSR_DOT11_MODE_11b & phyMode)
1759 {
1760 newPhyMode = eCSR_DOT11_MODE_11b;
1761 eBand = eCSR_BAND_24;
1762 }
1763 else
1764 {
1765 //We will never be here
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}
Venkata Prathyusha Kuntupalli9778fb32013-02-26 22:16:52 -08001874
1875eHalStatus csrGet5GChannels(tpAniSirGlobal pMac)
1876{
1877 eHalStatus status = eHAL_STATUS_SUCCESS;
1878 tANI_U8 num20MHzChannelsFound = 0;
1879 VOS_STATUS vosStatus;
1880 tANI_U8 num40MHzChannelsFound = 0;
1881 tANI_U8 Index = 0;
1882
1883 vosStatus = vos_nv_get5GChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
1884 NULL, &num40MHzChannelsFound);
1885 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
1886 {
1887 smsLog( pMac, LOGE, FL("failed to get channels"));
1888 status = eHAL_STATUS_FAILURE;
1889 }
1890 else
1891 {
1892 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
1893 {
1894 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1895 }
1896 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
1897 // Move the channel list to the global data
1898 // structure -- this will be used as the scan list
1899 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
1900 {
1901 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
1902 }
1903 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
1904 if ( num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
1905 {
1906 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1907 }
1908 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
1909 {
1910 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
1911 }
1912 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
1913 }
1914 return status;
1915}
1916
Jeff Johnson295189b2012-06-20 16:38:30 -07001917eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
1918{
1919 eHalStatus status = eHAL_STATUS_SUCCESS;
1920 tANI_U8 num20MHzChannelsFound = 0;
1921 VOS_STATUS vosStatus;
1922 tANI_U8 Index = 0;
1923 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001924
Jeff Johnson295189b2012-06-20 16:38:30 -07001925
1926 //TODO: this interface changed to include the 40MHz channel list
1927 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
1928 // Read the scan channel list (including the power limit) from EEPROM
1929 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
1930 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
1931 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
1932 {
1933 smsLog( pMac, LOGE, FL("failed to get channels \n"));
1934 status = eHAL_STATUS_FAILURE;
1935 }
1936 else
1937 {
1938 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
1939 {
1940 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1941 }
1942 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
1943 // Move the channel list to the global data
1944 // structure -- this will be used as the scan list
1945 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
1946 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001947 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07001948 }
1949 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
1950 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
1951 {
1952 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1953 }
1954 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
1955 {
1956 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
1957 }
1958 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
1959 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001960 return (status);
1961}
1962
Jeff Johnson295189b2012-06-20 16:38:30 -07001963eHalStatus csrInitChannelList( tHalHandle hHal )
1964{
1965 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1966 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001967 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
1968 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08001969 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
1970 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001971 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08001972 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07001973
1974 return (status);
1975}
Jeff Johnson295189b2012-06-20 16:38:30 -07001976eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
1977 tCsrUpdateConfigParam *pUpdateConfigParam)
1978{
1979 eHalStatus status = eHAL_STATUS_FAILURE;
1980 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001981 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
1982 status = CsrInit11dInfo(pMac, ps11dinfo);
1983 return status;
1984}
1985
Jeff Johnson295189b2012-06-20 16:38:30 -07001986static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
1987{
1988 eHalStatus status = eHAL_STATUS_FAILURE;
1989 tANI_U8 index;
1990 tANI_U32 count=0;
1991 tSirMacChanInfo *pChanInfo;
1992 tSirMacChanInfo *pChanInfoStart;
1993 tANI_BOOLEAN applyConfig = TRUE;
1994
1995 if(!ps11dinfo)
1996 {
1997 return (status);
1998 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001999 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
2000 {
2001 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
2002 status = palCopyMemory(pMac->hHdd, pMac->scan.base20MHzChannels.channelList,
2003 ps11dinfo->Channels.channelList, ps11dinfo->Channels.numChannels);
2004 if(!HAL_STATUS_SUCCESS(status)) return (status);
2005 }
2006 else
2007 {
2008 //No change
2009 return (eHAL_STATUS_SUCCESS);
2010 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002011 //legacy maintenance
2012 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeDefault,
2013 ps11dinfo->countryCode, WNI_CFG_COUNTRY_CODE_LEN);
2014 if(!HAL_STATUS_SUCCESS(status)) return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -07002015 //Tush: at csropen get this initialized with default, during csr reset if this
2016 // already set with some value no need initilaize with default again
2017 if(0 == pMac->scan.countryCodeCurrent[0])
2018 {
2019 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent,
2020 ps11dinfo->countryCode, WNI_CFG_COUNTRY_CODE_LEN);
2021 if(!HAL_STATUS_SUCCESS(status)) return (status);
2022 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002023 // need to add the max power channel list
2024 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN)))
2025 {
2026 palZeroMemory(pMac->hHdd, pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2027 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07002028 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2029 {
2030 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2031 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2032 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2033 pChanInfo++;
2034 count++;
2035 }
2036 if(count)
2037 {
2038 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2039 }
2040 palFreeMemory(pMac->hHdd, pChanInfoStart);
2041 }
2042 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2043 if( HAL_STATUS_SUCCESS(status) )
2044 {
2045 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2046 {
2047 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2048 {
2049 applyConfig = FALSE;
2050 }
2051 }
2052
2053 if(TRUE == applyConfig)
2054 {
2055 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002056 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002057 }
2058
2059 }
2060 return (status);
2061}
2062/* Initialize the Channel + Power List in the local cache and in the CFG */
2063eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2064{
2065 tANI_U8 index;
2066 tANI_U32 count=0;
2067 tSirMacChanInfo *pChanInfo;
2068 tSirMacChanInfo *pChanInfoStart;
2069
2070 if(!ps11dinfo || !pMac)
2071 {
2072 return eHAL_STATUS_FAILURE;
2073 }
2074
2075 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN)))
2076 {
2077 palZeroMemory(pMac->hHdd, pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2078 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002079
2080 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2081 {
2082 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2083 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2084 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2085 pChanInfo++;
2086 count++;
2087 }
2088 if(count)
2089 {
2090 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2091 }
2092 palFreeMemory(pMac->hHdd, pChanInfoStart);
2093 }
2094
Jeff Johnsone7245742012-09-05 17:12:55 -07002095 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002096}
2097
2098//pCommand may be NULL
2099//Pass in sessionId in case pCommand is NULL. sessionId is not used in case pCommand is not NULL.
2100void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac, tANI_U32 sessionId, tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
2101{
2102 tListElem *pEntry, *pNextEntry;
2103 tSmeCmd *pDupCommand;
2104 tDblLinkList localList;
2105
2106 vos_mem_zero(&localList, sizeof(tDblLinkList));
2107 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
2108 {
2109 smsLog(pMac, LOGE, FL(" failed to open list"));
2110 return;
2111 }
2112 csrLLLock( &pMac->sme.smeCmdPendingList );
2113 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
2114 while( pEntry )
2115 {
2116 pNextEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
2117 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07002118 // Remove the previous command if..
2119 // - the new roam command is for the same RoamReason...
2120 // - the new roam command is a NewProfileList.
2121 // - the new roam command is a Forced Dissoc
2122 // - the new roam command is from an 802.11 OID (OID_SSID or OID_BSSID).
2123 if (
2124 (pCommand && ( pCommand->sessionId == pDupCommand->sessionId ) &&
2125 ((pCommand->command == pDupCommand->command) &&
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002126 /* This peermac check is requried for Softap/GO scenarios
2127 * For STA scenario below OR check will suffice as pCommand will
2128 * always be NULL for STA scenarios
2129 */
2130 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac, pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002131 (pCommand->u.roamCmd.roamReason == pDupCommand->u.roamCmd.roamReason ||
2132 eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason ||
2133 eCsrHddIssued == pCommand->u.roamCmd.roamReason)))
2134 ||
2135 //below the pCommand is NULL
Jeff Johnson43971f52012-07-17 12:26:56 -07002136 ( (sessionId == pDupCommand->sessionId) &&
2137 (eSmeCommandRoam == pDupCommand->command) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002138 ((eCsrForcedDisassoc == eRoamReason) ||
2139 (eCsrHddIssued == eRoamReason))
2140 )
2141 )
2142 {
2143 smsLog(pMac, LOGW, FL(" roamReason = %d\n"), pDupCommand->u.roamCmd.roamReason);
2144 // Remove the 'stale' roam command from the pending list...
2145 if(csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK ))
2146 {
2147 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
2148 }
2149 }
2150 pEntry = pNextEntry;
2151 }
2152 csrLLUnlock( &pMac->sme.smeCmdPendingList );
2153
2154 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
2155 {
2156 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
2157 //Tell caller that the command is cancelled
2158 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL, pDupCommand->u.roamCmd.roamId,
2159 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
2160 csrReleaseCommandRoam(pMac, pDupCommand);
2161 }
2162 csrLLClose(&localList);
2163}
Jeff Johnson295189b2012-06-20 16:38:30 -07002164eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2165 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2166{
2167 eHalStatus status = eHAL_STATUS_SUCCESS;
2168#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2169 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2170#endif
2171 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07002172 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2173 {
2174 pSession = CSR_GET_SESSION( pMac, sessionId );
2175 }
2176 else
2177 {
2178 smsLog(pMac, LOGE, "Session ID:%d is not valid\n", sessionId);
2179 VOS_ASSERT(0);
2180 return eHAL_STATUS_FAILURE;
2181 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002182 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
2183 {
2184 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d\n", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
2185 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002186 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2187 /*
2188 * Decrement bRefAssocStartCnt for FT reassoc failure.
2189 * Reason: For FT reassoc failures, we first call
2190 * csrRoamCallCallback before notifying a failed roam
2191 * completion through csrRoamComplete. The latter in
2192 * turn calls csrRoamProcessResults which tries to
2193 * once again call csrRoamCallCallback if bRefAssocStartCnt
2194 * is non-zero. Since this is redundant for FT reassoc
2195 * failure, decrement bRefAssocStartCnt.
2196 */
2197 pSession->bRefAssocStartCnt--;
2198 }
2199
Jeff Johnson295189b2012-06-20 16:38:30 -07002200 if ( (pSession == NULL) ||
2201 (eANI_BOOLEAN_FALSE == pSession->sessionActive) )
2202 {
2203 smsLog(pMac, LOG1, "Session ID is not valid\n");
2204 return eHAL_STATUS_FAILURE;
2205 }
2206
2207 if(NULL != pSession->callback)
2208 {
2209 if( pRoamInfo )
2210 {
2211 pRoamInfo->sessionId = (tANI_U8)sessionId;
2212 }
2213
2214 /* avoid holding the global lock when making the roaming callback , original change came
2215 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2216 is possible on other OS ports where the callback may need to take locks to protect
2217 HDD state
2218 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2219 that may actually depend on the lock being held */
2220 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2221 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2222 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2223 }
2224 //EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
2225 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
2226#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2227 palZeroMemory(pMac->hHdd, &connectionStatus, sizeof(vos_event_wlan_status_payload_type));
2228 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2))
2229 {
2230 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2231 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2232 if(NULL != pRoamInfo->pBssDesc)
2233 {
2234 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2235 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2236 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002237 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2238 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2239 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
2240 palCopyMemory(pMac->hHdd, connectionStatus.ssid, pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
2241 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
2242 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2243 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002244 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2245 {
2246 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2247 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
2248 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2249 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002250 if(eCSR_ROAM_RESULT_FORCED == u2)
2251 {
2252 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2253 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
2254 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2255 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002256 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2257 {
2258 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2259 connectionStatus.reason = eCSR_REASON_DISASSOC;
2260 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2261 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002262 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2263 {
2264 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2265 connectionStatus.reason = eCSR_REASON_DEAUTH;
2266 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2267 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002268#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2269
2270 return (status);
2271}
Jeff Johnson295189b2012-06-20 16:38:30 -07002272// Returns whether handoff is currently in progress or not
2273tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2274{
2275#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2276 return csrNeighborRoamIsHandoffInProgress(pMac);
2277#else
2278 return eANI_BOOLEAN_FALSE;
2279#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002280}
Jeff Johnson295189b2012-06-20 16:38:30 -07002281eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2282 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2283{
2284 eHalStatus status = eHAL_STATUS_SUCCESS;
2285 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2286 tANI_U16 reasonCode;
2287 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002288
2289 if(!pSession)
2290 {
2291 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2292 return eHAL_STATUS_FAILURE;
2293 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002294
2295 //Restore AC weight in case we change it
2296 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2297 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002298 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 -07002299 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2300 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2301 }
2302
2303 if ( fMICFailure )
2304 {
2305 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2306 }
2307 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2308 {
2309 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002310 }
2311 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002312 {
2313 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2314 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002315#ifdef WLAN_FEATURE_VOWIFI_11R
2316 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2317 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2318 {
2319 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2320 palCopyMemory(pMac->hHdd, &bssId, pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid, sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002321 }
2322 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002323#endif
2324 if(pSession->pConnectBssDesc)
2325 {
2326 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2327 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002328
Jeff Johnson295189b2012-06-20 16:38:30 -07002329
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002330 smsLog( pMac, LOG2, "CSR Attempting to Disassociate Bssid=%02x-%02x-%02x-%02x-%02x-%02x"
2331 "subState = %d reason=%d", bssId[ 0 ], bssId[ 1 ], bssId[ 2 ], bssId[ 3 ],
2332 bssId[ 4 ], bssId[ 5 ], NewSubstate, reasonCode);
2333
Jeff Johnson295189b2012-06-20 16:38:30 -07002334 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2335
2336 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2337
2338 if(HAL_STATUS_SUCCESS(status))
2339 {
2340 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002341#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2342 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2343 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2344 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002345 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07002346 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
2347 }
2348#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002349 }
2350 else
2351 {
2352 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
2353 }
2354
Jeff Johnson295189b2012-06-20 16:38:30 -07002355 return (status);
2356}
Jeff Johnson295189b2012-06-20 16:38:30 -07002357
Jeff Johnson295189b2012-06-20 16:38:30 -07002358/* ---------------------------------------------------------------------------
2359 \fn csrRoamIssueDisassociateStaCmd
2360 \brief csr function that HDD calls to disassociate a associated station
2361 \param sessionId - session Id for Soft AP
2362 \param pPeerMacAddr - MAC of associated station to delete
2363 \param reason - reason code, be one of the tSirMacReasonCodes
2364 \return eHalStatus
2365 ---------------------------------------------------------------------------*/
2366eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
2367 tANI_U32 sessionId,
2368 tANI_U8 *pPeerMacAddr,
2369 tANI_U32 reason)
2370{
2371 eHalStatus status = eHAL_STATUS_SUCCESS;
2372 tSmeCmd *pCommand;
2373
2374 do
2375 {
2376 pCommand = csrGetCommandBuffer( pMac );
2377 if ( !pCommand )
2378 {
2379 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2380 status = eHAL_STATUS_RESOURCES;
2381 break;
2382 }
2383 pCommand->command = eSmeCommandRoam;
2384 pCommand->sessionId = (tANI_U8)sessionId;
2385 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
2386 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2387 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2388 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2389 if( !HAL_STATUS_SUCCESS( status ) )
2390 {
2391 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
2392 csrReleaseCommandRoam( pMac, pCommand );
2393 }
2394 }while(0);
2395
2396 return status;
2397}
2398
2399
Jeff Johnson295189b2012-06-20 16:38:30 -07002400/* ---------------------------------------------------------------------------
2401 \fn csrRoamIssueDeauthSta
2402 \brief csr function that HDD calls to delete a associated station
2403 \param sessionId - session Id for Soft AP
2404 \param pPeerMacAddr - MAC of associated station to delete
2405 \param reason - reason code, be one of the tSirMacReasonCodes
2406 \return eHalStatus
2407 ---------------------------------------------------------------------------*/
2408eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
2409 tANI_U32 sessionId,
2410 tANI_U8 *pPeerMacAddr,
2411 tANI_U32 reason)
2412{
2413 eHalStatus status = eHAL_STATUS_SUCCESS;
2414 tSmeCmd *pCommand;
2415
2416 do
2417 {
2418 pCommand = csrGetCommandBuffer( pMac );
2419 if ( !pCommand )
2420 {
2421 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2422 status = eHAL_STATUS_RESOURCES;
2423 break;
2424 }
2425 pCommand->command = eSmeCommandRoam;
2426 pCommand->sessionId = (tANI_U8)sessionId;
2427 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
2428 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2429 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2430 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2431 if( !HAL_STATUS_SUCCESS( status ) )
2432 {
2433 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
2434 csrReleaseCommandRoam( pMac, pCommand );
2435 }
2436 }while(0);
2437
2438 return status;
2439}
Jeff Johnson295189b2012-06-20 16:38:30 -07002440eHalStatus
2441csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
2442 tANI_BOOLEAN bEnable )
2443{
2444 eHalStatus status = eHAL_STATUS_FAILURE;
2445 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2446 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002447 if (!pSession)
2448 {
2449 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found\n");
2450 return (status);
2451 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002452 if (pSession->pConnectBssDesc)
2453 {
2454 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2455 }
2456 else
2457 {
2458 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found\n");
2459 return (status);
2460 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002461 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = %02x-%02x-%02x-%02x-%02x-%02x, Enable = %d\n",
2462 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2463 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] , bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002464 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
2465 return (status);
2466}
Jeff Johnson295189b2012-06-20 16:38:30 -07002467eHalStatus
2468csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
2469 VOS_MODULE_ID modId, void *pUsrContext,
2470 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
2471{
2472 eHalStatus status = eHAL_STATUS_SUCCESS;
2473 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2474 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002475 if (!pSession)
2476 {
2477 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found\n");
2478 return (status);
2479 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002480 if(pSession->pConnectBssDesc)
2481 {
2482 palCopyMemory( pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid) );
2483 }
2484 else
2485 {
2486 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found\n");
2487 return (status);
2488 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002489 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = %02x-%02x-%02x-%02x-%02x-%02x\n",
2490 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2491 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002492 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2493 return (status);
2494}
Jeff Johnson295189b2012-06-20 16:38:30 -07002495eHalStatus
2496csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
2497 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
2498{
2499 eHalStatus status = eHAL_STATUS_SUCCESS;
2500 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2501 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2502
2503 if (!pSession)
2504 {
2505 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found\n");
2506 return (status);
2507 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002508 if(pSession->pConnectBssDesc)
2509 {
2510 palCopyMemory( pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid) );
2511 }
2512 else
2513 {
2514 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found\n");
2515 return (status);
2516 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002517 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = %02x-%02x-%02x-%02x-%02x-%02x\n",
2518 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2519 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
2520
2521 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2522
2523 return (status);
2524}
Jeff Johnson295189b2012-06-20 16:38:30 -07002525eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
2526{
2527 eHalStatus status = eHAL_STATUS_SUCCESS;
2528 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2529 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002530
2531 if (!pSession)
2532 {
2533 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2534 return eHAL_STATUS_FAILURE;
2535 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002536
2537 if(pSession->pConnectBssDesc)
2538 {
2539 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2540 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002541 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= %02x-%02x-%02x-%02x-%02x-%02x\n",
2542 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2543 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002544 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2545
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302546 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002547 if(!HAL_STATUS_SUCCESS(status))
2548 {
2549 smsLog(pMac, LOGW, FL("csrSendMBDeauthReqMsg failed with status %d"), status);
2550 }
2551
Jeff Johnson295189b2012-06-20 16:38:30 -07002552 return (status);
2553}
2554
Jeff Johnson295189b2012-06-20 16:38:30 -07002555eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
2556{
2557 eHalStatus status = eHAL_STATUS_SUCCESS;
2558 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2559 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002560
2561 if(!pSession)
2562 {
2563 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2564 return eHAL_STATUS_FAILURE;
2565 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002566
2567 // If no BSS description was found in this connection (happens with start IBSS), then
2568 // nix the BSS description that we keep around for the connected BSS) and get out...
2569 if(NULL == pBssDesc)
2570 {
2571 csrFreeConnectBssDesc(pMac, sessionId);
2572 }
2573 else
2574 {
2575 size = pBssDesc->length + sizeof( pBssDesc->length );
2576 if(NULL != pSession->pConnectBssDesc)
2577 {
2578 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
2579 {
2580 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
2581 csrFreeConnectBssDesc(pMac, sessionId);
2582 }
2583 }
2584 if(NULL == pSession->pConnectBssDesc)
2585 {
2586 status = palAllocateMemory( pMac->hHdd, (void **)&pSession->pConnectBssDesc, size);
2587 }
2588 if ( HAL_STATUS_SUCCESS(status) && pSession->pConnectBssDesc )
2589 {
2590 palCopyMemory( pMac->hHdd, pSession->pConnectBssDesc, pBssDesc, size );
2591 }
2592 }
2593
2594 return (status);
2595}
2596
Jeff Johnson295189b2012-06-20 16:38:30 -07002597eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2598 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
2599 tDot11fBeaconIEs *pIes)
2600{
2601 eHalStatus status = eHAL_STATUS_SUCCESS;
2602 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002603 VOS_ASSERT( pIes != NULL );
Jeff Johnsone7245742012-09-05 17:12:55 -07002604
Jeff Johnson295189b2012-06-20 16:38:30 -07002605 do
2606 {
2607 palCopyMemory(pMac->hHdd, &pBssConfig->BssCap, &pBssDesc->capabilityInfo, sizeof(tSirMacCapabilityInfo));
2608 //get qos
2609 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
2610 //get SSID
2611 if(pIes->SSID.present)
2612 {
2613 palCopyMemory(pMac->hHdd, &pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
2614 pBssConfig->SSID.length = pIes->SSID.num_ssid;
2615 }
2616 else
2617 pBssConfig->SSID.length = 0;
2618 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
2619 {
2620 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard\n");
2621 //Return failed if profile doesn't have an SSID either.
2622 if(pProfile->SSIDs.numOfSSIDs == 0)
2623 {
2624 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID\n");
2625 status = eHAL_STATUS_FAILURE;
2626 break;
2627 }
2628 }
2629 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
2630 {
2631 pBssConfig->eBand = eCSR_BAND_5G;
2632 }
2633 else
2634 {
2635 pBssConfig->eBand = eCSR_BAND_24;
2636 }
2637 //phymode
2638 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
2639 {
2640 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
2641 }
2642 else
2643 {
2644 smsLog(pMac, LOGW, " Can not find match phy mode\n");
2645 //force it
2646 if(eCSR_BAND_24 == pBssConfig->eBand)
2647 {
2648 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2649 }
2650 else
2651 {
2652 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2653 }
2654 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002655 //Qos
2656 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
2657 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
2658 {
2659 //Joining BSS is not 11n capable and WMM is disabled on client.
2660 //Disable QoS and WMM
2661 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2662 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302663
2664 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05302665 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302666 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
2667 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
2668 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
2669 {
2670 //Joining BSS is 11n capable and WMM is disabled on AP.
2671 //Assume all HT AP's are QOS AP's and enable WMM
2672 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2673 }
2674
Jeff Johnson295189b2012-06-20 16:38:30 -07002675 //auth type
2676 switch( pProfile->negotiatedAuthType )
2677 {
2678 default:
2679 case eCSR_AUTH_TYPE_WPA:
2680 case eCSR_AUTH_TYPE_WPA_PSK:
2681 case eCSR_AUTH_TYPE_WPA_NONE:
2682 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2683 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2684 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002685 case eCSR_AUTH_TYPE_SHARED_KEY:
2686 pBssConfig->authType = eSIR_SHARED_KEY;
2687 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002688 case eCSR_AUTH_TYPE_AUTOSWITCH:
2689 pBssConfig->authType = eSIR_AUTO_SWITCH;
2690 break;
2691 }
2692 //short slot time
2693 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
2694 {
2695 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2696 }
2697 else
2698 {
2699 pBssConfig->uShortSlotTime = 0;
2700 }
2701 if(pBssConfig->BssCap.ibss)
2702 {
2703 //We don't support 11h on IBSS
2704 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2705 }
2706 else
2707 {
2708 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
2709 }
2710 //power constraint
2711 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
2712 //heartbeat
2713 if ( CSR_IS_11A_BSS( pBssDesc ) )
2714 {
2715 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2716 }
2717 else
2718 {
2719 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2720 }
2721 //Join timeout
2722 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07002723 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07002724 if ( pBssDesc->beaconInterval )
2725 {
2726 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07002727 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002728 }
2729 else
2730 {
2731 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
2732 }
2733 //validate CB
2734 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
2735 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002736 return (status);
2737}
2738
Jeff Johnson295189b2012-06-20 16:38:30 -07002739static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2740 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
2741{
2742 eHalStatus status = eHAL_STATUS_SUCCESS;
2743 tANI_U8 operationChannel = 0;
2744 tANI_U8 qAPisEnabled = FALSE;
2745 //SSID
2746 pBssConfig->SSID.length = 0;
2747 if(pProfile->SSIDs.numOfSSIDs)
2748 {
2749 //only use the first one
2750 palCopyMemory(pMac->hHdd, &pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID, sizeof(tSirMacSSid));
2751 }
2752 else
2753 {
2754 //SSID must present
2755 return eHAL_STATUS_FAILURE;
2756 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002757 //Settomg up the capabilities
2758 if( csrIsBssTypeIBSS(pProfile->BSSType) )
2759 {
2760 pBssConfig->BssCap.ibss = 1;
2761 }
2762 else
2763 {
2764 pBssConfig->BssCap.ess = 1;
2765 }
2766 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
2767 {
2768 pBssConfig->BssCap.privacy = 1;
2769 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002770 pBssConfig->eBand = pMac->roam.configParam.eBand;
2771 //phymode
2772 if(pProfile->ChannelInfo.ChannelList)
2773 {
2774 operationChannel = pProfile->ChannelInfo.ChannelList[0];
2775 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002776 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
2777 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07002778 //QOS
2779 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07002780 if ( pBssConfig->BssCap.ess == 1 )
2781 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002782 /*For Softap case enable WMM*/
2783 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
2784 qAPisEnabled = TRUE;
2785 }
2786 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002787 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
2788 qAPisEnabled = TRUE;
2789 } else {
2790 qAPisEnabled = FALSE;
2791 }
2792 } else {
2793 qAPisEnabled = TRUE;
2794 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002795 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
2796 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
2797 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
2798 )
2799 {
2800 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2801 } else {
2802 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2803 }
2804
2805 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08002806 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07002807 {
2808 default:
2809 case eCSR_AUTH_TYPE_WPA:
2810 case eCSR_AUTH_TYPE_WPA_PSK:
2811 case eCSR_AUTH_TYPE_WPA_NONE:
2812 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2813 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2814 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002815 case eCSR_AUTH_TYPE_SHARED_KEY:
2816 pBssConfig->authType = eSIR_SHARED_KEY;
2817 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002818 case eCSR_AUTH_TYPE_AUTOSWITCH:
2819 pBssConfig->authType = eSIR_AUTO_SWITCH;
2820 break;
2821 }
2822 //short slot time
2823 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
2824 {
2825 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2826 }
2827 else
2828 {
2829 pBssConfig->uShortSlotTime = 0;
2830 }
2831 //power constraint. We don't support 11h on IBSS
2832 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2833 pBssConfig->uPowerLimit = 0;
2834 //heartbeat
2835 if ( eCSR_BAND_5G == pBssConfig->eBand )
2836 {
2837 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2838 }
2839 else
2840 {
2841 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2842 }
2843 //Join timeout
2844 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07002845
Jeff Johnson295189b2012-06-20 16:38:30 -07002846 return (status);
2847}
Jeff Johnson295189b2012-06-20 16:38:30 -07002848static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
2849{
2850 eHalStatus status = eHAL_STATUS_FAILURE;
2851 tDot11fBeaconIEs *pIes = NULL;
2852
2853 do
2854 {
2855 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
2856 {
2857 //err msg
2858 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
2859 "csrRoamGetQosInfoFromBss() failed\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07002860 break;
2861 }
2862 //check if the AP is QAP & it supports APSD
2863 if( CSR_IS_QOS_BSS(pIes) )
2864 {
2865 return eHAL_STATUS_SUCCESS;
2866 }
2867 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002868 return status;
2869}
2870
Jeff Johnson295189b2012-06-20 16:38:30 -07002871void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
2872{
Jeff Johnson295189b2012-06-20 16:38:30 -07002873 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
2874 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
2875 // See !!Note: below in this function...
2876 tANI_U32 PrivacyEnabled = 0;
2877 tANI_U32 RsnEnabled = 0;
2878 tANI_U32 WepDefaultKeyId = 0;
2879 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
2880 tANI_U32 Key0Length = 0;
2881 tANI_U32 Key1Length = 0;
2882 tANI_U32 Key2Length = 0;
2883 tANI_U32 Key3Length = 0;
2884
2885 // Reserve for the biggest key
2886 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
2887 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
2888 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
2889 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
2890
2891 switch ( pProfile->negotiatedUCEncryptionType )
2892 {
2893 case eCSR_ENCRYPT_TYPE_NONE:
2894
2895 // for NO encryption, turn off Privacy and Rsn.
2896 PrivacyEnabled = 0;
2897 RsnEnabled = 0;
2898
2899 // WEP key length and Wep Default Key ID don't matter in this case....
2900
2901 // clear out the WEP keys that may be hanging around.
2902 Key0Length = 0;
2903 Key1Length = 0;
2904 Key2Length = 0;
2905 Key3Length = 0;
2906
2907 break;
2908
2909 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
2910
2911 // Privacy is ON. NO RSN for Wep40 static key.
2912 PrivacyEnabled = 1;
2913 RsnEnabled = 0;
2914
2915 // Set the Wep default key ID.
2916 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07002917 // Wep key size if 5 bytes (40 bits).
2918 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
2919
2920 // set encryption keys in the CFG database or clear those that are not present in this profile.
2921 if ( pProfile->Keys.KeyLength[0] )
2922 {
2923 palCopyMemory( pMac->hHdd, Key0, pProfile->Keys.KeyMaterial[0], WNI_CFG_WEP_KEY_LENGTH_5 );
2924 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
2925 }
2926 else
2927 {
2928 Key0Length = 0;
2929 }
2930
2931 if ( pProfile->Keys.KeyLength[1] )
2932 {
2933 palCopyMemory( pMac->hHdd, Key1, pProfile->Keys.KeyMaterial[1], WNI_CFG_WEP_KEY_LENGTH_5 );
2934 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
2935 }
2936 else
2937 {
2938 Key1Length = 0;
2939 }
2940
2941 if ( pProfile->Keys.KeyLength[2] )
2942 {
2943 palCopyMemory( pMac->hHdd, Key2, pProfile->Keys.KeyMaterial[2], WNI_CFG_WEP_KEY_LENGTH_5 );
2944 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
2945 }
2946 else
2947 {
2948 Key2Length = 0;
2949 }
2950
2951 if ( pProfile->Keys.KeyLength[3] )
2952 {
2953 palCopyMemory( pMac->hHdd, Key3, pProfile->Keys.KeyMaterial[3], WNI_CFG_WEP_KEY_LENGTH_5 );
2954 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
2955 }
2956 else
2957 {
2958 Key3Length = 0;
2959 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002960 break;
2961
2962 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
2963
2964 // Privacy is ON. NO RSN for Wep40 static key.
2965 PrivacyEnabled = 1;
2966 RsnEnabled = 0;
2967
2968 // Set the Wep default key ID.
2969 WepDefaultKeyId = pProfile->Keys.defaultIndex;
2970
2971 // Wep key size if 13 bytes (104 bits).
2972 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
2973
2974 // set encryption keys in the CFG database or clear those that are not present in this profile.
2975 if ( pProfile->Keys.KeyLength[0] )
2976 {
2977 palCopyMemory( pMac->hHdd, Key0, pProfile->Keys.KeyMaterial[ 0 ], WNI_CFG_WEP_KEY_LENGTH_13 );
2978 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
2979 }
2980 else
2981 {
2982 Key0Length = 0;
2983 }
2984
2985 if ( pProfile->Keys.KeyLength[1] )
2986 {
2987 palCopyMemory( pMac->hHdd, Key1, pProfile->Keys.KeyMaterial[ 1 ], WNI_CFG_WEP_KEY_LENGTH_13 );
2988 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
2989 }
2990 else
2991 {
2992 Key1Length = 0;
2993 }
2994
2995 if ( pProfile->Keys.KeyLength[2] )
2996 {
2997 palCopyMemory( pMac->hHdd, Key2, pProfile->Keys.KeyMaterial[ 2 ], WNI_CFG_WEP_KEY_LENGTH_13 );
2998 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
2999 }
3000 else
3001 {
3002 Key2Length = 0;
3003 }
3004
3005 if ( pProfile->Keys.KeyLength[3] )
3006 {
3007 palCopyMemory( pMac->hHdd, Key3, pProfile->Keys.KeyMaterial[ 3 ], WNI_CFG_WEP_KEY_LENGTH_13 );
3008 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3009 }
3010 else
3011 {
3012 Key3Length = 0;
3013 }
3014
3015 break;
3016
3017 case eCSR_ENCRYPT_TYPE_WEP40:
3018 case eCSR_ENCRYPT_TYPE_WEP104:
3019 case eCSR_ENCRYPT_TYPE_TKIP:
3020 case eCSR_ENCRYPT_TYPE_AES:
3021#ifdef FEATURE_WLAN_WAPI
3022 case eCSR_ENCRYPT_TYPE_WPI:
3023#endif /* FEATURE_WLAN_WAPI */
3024 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3025 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3026 PrivacyEnabled = (0 != fPrivacy);
3027
3028 // turn on RSN enabled for WPA associations
3029 RsnEnabled = 1;
3030
3031 // WEP key length and Wep Default Key ID don't matter in this case....
3032
3033 // clear out the static WEP keys that may be hanging around.
3034 Key0Length = 0;
3035 Key1Length = 0;
3036 Key2Length = 0;
3037 Key3Length = 0;
3038
3039 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003040 default:
3041 PrivacyEnabled = 0;
3042 RsnEnabled = 0;
3043 break;
3044 }
3045
3046 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3047 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3048 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3049 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3050 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3051 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3052 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3053 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3054}
3055
Jeff Johnson295189b2012-06-20 16:38:30 -07003056static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3057{
3058 tANI_U32 len = 0;
3059 if(pSSID->length <= WNI_CFG_SSID_LEN)
3060 {
3061 len = pSSID->length;
3062 }
3063 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3064}
3065
Jeff Johnson295189b2012-06-20 16:38:30 -07003066eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3067{
3068 eHalStatus status = eHAL_STATUS_SUCCESS;
3069 tANI_U32 QoSEnabled;
3070 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003071 // set the CFG enable/disable variables based on the qosType being configured...
3072 switch( qosType )
3073 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003074 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3075 QoSEnabled = FALSE;
3076 WmeEnabled = TRUE;
3077 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003078 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3079 QoSEnabled = FALSE;
3080 WmeEnabled = TRUE;
3081 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003082 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3083 QoSEnabled = FALSE;
3084 WmeEnabled = TRUE;
3085 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003086 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3087 QoSEnabled = TRUE;
3088 WmeEnabled = FALSE;
3089 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003090 case eCSR_MEDIUM_ACCESS_11e_HCF:
3091 QoSEnabled = TRUE;
3092 WmeEnabled = FALSE;
3093 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003094 default:
3095 case eCSR_MEDIUM_ACCESS_DCF:
3096 QoSEnabled = FALSE;
3097 WmeEnabled = FALSE;
3098 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003099 }
3100 //save the WMM setting for later use
3101 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003102 status = ccmCfgSetInt(pMac, WNI_CFG_QOS_ENABLED, QoSEnabled, NULL, eANI_BOOLEAN_FALSE);
3103 status = ccmCfgSetInt(pMac, WNI_CFG_WME_ENABLED, WmeEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003104 return (status);
3105}
Jeff Johnson295189b2012-06-20 16:38:30 -07003106static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
3107 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet)
3108{
3109 eHalStatus status = eHAL_STATUS_FAILURE;
3110 int i;
3111 eCsrCfgDot11Mode cfgDot11Mode;
3112 tANI_U8 *pDstRate;
Jeff Johnson295189b2012-06-20 16:38:30 -07003113 palZeroMemory(pMac->hHdd, pOpRateSet, sizeof(tSirMacRateSet));
3114 palZeroMemory(pMac->hHdd, pExRateSet, sizeof(tSirMacRateSet));
Jeff Johnson295189b2012-06-20 16:38:30 -07003115 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003116
3117 if( NULL != pIes )
3118 {
3119 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003120 // Originally, we thought that for 11a networks, the 11a rates are always
3121 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3122 // appear in the Operational Rate set. Consequently, in either case, we
3123 // would blindly put the rates we support into our Operational Rate set
3124 // (including the basic rates, which we have already verified are
3125 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003126 // However, it turns out that this is not always the case. Some AP's
3127 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3128 // too. Now, we're a little more careful:
3129 pDstRate = pOpRateSet->rate;
3130 if(pIes->SuppRates.present)
3131 {
3132 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3133 {
3134 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3135 {
3136 *pDstRate++ = pIes->SuppRates.rates[ i ];
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003137 pOpRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003138 }
3139 }
3140 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003141 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3142 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3143 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3144 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3145 {
3146 // If there are Extended Rates in the beacon, we will reflect those
3147 // extended rates that we support in out Extended Operational Rate
3148 // set:
3149 pDstRate = pExRateSet->rate;
3150 if(pIes->ExtSuppRates.present)
3151 {
3152 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3153 {
3154 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) )
3155 {
3156 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3157 pExRateSet->numRates++;
3158 }
3159 }
3160 }
3161 }
3162 }//Parsing BSSDesc
3163 else
3164 {
3165 smsLog(pMac, LOGE, FL("failed to parse BssDesc\n"));
3166 }
3167 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3168 return status;
3169}
3170
3171static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3172 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3173{
3174 int i;
3175 tANI_U8 *pDstRate;
3176 eCsrCfgDot11Mode cfgDot11Mode;
3177 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3178 tANI_U32 OperationalRatesLength = 0;
3179 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3180 tANI_U32 ExtendedOperationalRatesLength = 0;
3181 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3182 tANI_U32 ProprietaryOperationalRatesLength = 0;
3183 tANI_U32 PropRatesEnable = 0;
3184 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3185 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003186 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003187 if( NULL != pIes )
3188 {
3189 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003190 // Originally, we thought that for 11a networks, the 11a rates are always
3191 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3192 // appear in the Operational Rate set. Consequently, in either case, we
3193 // would blindly put the rates we support into our Operational Rate set
3194 // (including the basic rates, which we have already verified are
3195 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003196 // However, it turns out that this is not always the case. Some AP's
3197 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3198 // too. Now, we're a little more careful:
3199 pDstRate = OperationalRates;
3200 if(pIes->SuppRates.present)
3201 {
3202 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3203 {
3204 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3205 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3206 {
3207 *pDstRate++ = pIes->SuppRates.rates[ i ];
3208 OperationalRatesLength++;
3209 }
3210 }
3211 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003212 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3213 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3214 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3215 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3216 {
3217 // If there are Extended Rates in the beacon, we will reflect those
3218 // extended rates that we support in out Extended Operational Rate
3219 // set:
3220 pDstRate = ExtendedOperationalRates;
3221 if(pIes->ExtSuppRates.present)
3222 {
3223 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3224 {
3225 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3226 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3227 {
3228 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3229 ExtendedOperationalRatesLength++;
3230 }
3231 }
3232 }
3233 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003234 // Enable proprietary MAC features if peer node is Airgo node and STA
3235 // user wants to use them
3236 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3237 {
3238 PropRatesEnable = 1;
3239 }
3240 else
3241 {
3242 PropRatesEnable = 0;
3243 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003244 // For ANI network companions, we need to populate the proprietary rate
3245 // set with any proprietary rates we found in the beacon, only if user
3246 // allows them...
3247 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3248 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3249 {
3250 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3251 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3252 {
3253 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3254 }
3255 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates, pIes->Airgo.PropSuppRates.rates, ProprietaryOperationalRatesLength );
3256 }
3257 else {
3258 // No proprietary modes...
3259 ProprietaryOperationalRatesLength = 0;
3260 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003261 /* Get MCS Rate */
3262 pDstRate = MCSRateIdxSet;
3263 if ( pIes->HTCaps.present )
3264 {
3265 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3266 {
3267 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3268 {
3269 MCSRateLength++;
3270 *pDstRate++ = i;
3271 }
3272 }
3273 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003274 // Set the operational rate set CFG variables...
3275 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3276 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3277 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3278 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3279 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3280 ProprietaryOperationalRates,
3281 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3282 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3283 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3284 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3285 }//Parsing BSSDesc
3286 else
3287 {
3288 smsLog(pMac, LOGE, FL("failed to parse BssDesc\n"));
3289 }
3290}
3291
Jeff Johnson295189b2012-06-20 16:38:30 -07003292static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3293 tCsrRoamProfile *pProfile )
3294{
3295 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3296 { 8,
3297 { SIR_MAC_RATE_6,
3298 SIR_MAC_RATE_9,
3299 SIR_MAC_RATE_12,
3300 SIR_MAC_RATE_18,
3301 SIR_MAC_RATE_24,
3302 SIR_MAC_RATE_36,
3303 SIR_MAC_RATE_48,
3304 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003305 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3306 { 4,
3307 { SIR_MAC_RATE_1,
3308 SIR_MAC_RATE_2,
3309 SIR_MAC_RATE_5_5,
3310 SIR_MAC_RATE_11 } } };
3311
3312
3313 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3314 { SIR_MAC_RATE_72,
3315 SIR_MAC_RATE_96,
3316 SIR_MAC_RATE_108 } };
3317 eCsrCfgDot11Mode cfgDot11Mode;
3318 eCsrBand eBand;
3319 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3320 tANI_U32 OperationalRatesLength = 0;
3321 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3322 tANI_U32 ExtendedOperationalRatesLength = 0;
3323 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3324 tANI_U32 ProprietaryOperationalRatesLength = 0;
3325 tANI_U32 PropRatesEnable = 0;
3326 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003327 if(pProfile->ChannelInfo.ChannelList)
3328 {
3329 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3330 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003331 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07003332 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3333 // networks, the 11b rates appear in the Operational Rate set. In either case,
3334 // we can blindly put the rates we support into our Operational Rate set
3335 // (including the basic rates, which we have already verified are supported
3336 // earlier in the roaming decision).
3337 if ( eCSR_BAND_5G == eBand )
3338 {
3339 // 11a rates into the Operational Rate Set.
3340 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3341 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
3342 palCopyMemory( pMac->hHdd, OperationalRates,
3343 DefaultSupportedRates11a.supportedRateSet.rate,
3344 OperationalRatesLength );
3345
3346 // Nothing in the Extended rate set.
3347 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003348 // populate proprietary rates if user allows them
3349 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3350 {
3351 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3352 sizeof(*DefaultSupportedPropRates.propRate);
3353 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates,
3354 DefaultSupportedPropRates.propRate,
3355 ProprietaryOperationalRatesLength );
3356 }
3357 else
3358 {
3359 // No proprietary modes
3360 ProprietaryOperationalRatesLength = 0;
3361 }
3362 }
3363 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3364 {
3365 // 11b rates into the Operational Rate Set.
3366 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3367 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
3368 palCopyMemory( pMac->hHdd, OperationalRates,
3369 DefaultSupportedRates11b.supportedRateSet.rate,
3370 OperationalRatesLength );
3371 // Nothing in the Extended rate set.
3372 ExtendedOperationalRatesLength = 0;
3373 // No proprietary modes
3374 ProprietaryOperationalRatesLength = 0;
3375 }
3376 else
3377 {
3378 // 11G
3379
3380 // 11b rates into the Operational Rate Set.
3381 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3382 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
3383 palCopyMemory( pMac->hHdd, OperationalRates,
3384 DefaultSupportedRates11b.supportedRateSet.rate,
3385 OperationalRatesLength );
3386
3387 // 11a rates go in the Extended rate set.
3388 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3389 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
3390 palCopyMemory( pMac->hHdd, ExtendedOperationalRates,
3391 DefaultSupportedRates11a.supportedRateSet.rate,
3392 ExtendedOperationalRatesLength );
3393
3394 // populate proprietary rates if user allows them
3395 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3396 {
3397 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3398 sizeof(*DefaultSupportedPropRates.propRate);
3399 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates,
3400 DefaultSupportedPropRates.propRate,
3401 ProprietaryOperationalRatesLength );
3402 }
3403 else
3404 {
3405 // No proprietary modes
3406 ProprietaryOperationalRatesLength = 0;
3407 }
3408 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003409 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3410 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3411 {
3412 PropRatesEnable = 1;
3413 }
3414 else
3415 {
3416 PropRatesEnable = 0;
3417 }
3418
3419 // Set the operational rate set CFG variables...
3420 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3421 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3422 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3423 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3424 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3425 ProprietaryOperationalRates,
3426 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3427 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003428}
Jeff Johnson295189b2012-06-20 16:38:30 -07003429void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3430{
3431 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07003432
Jeff Johnson295189b2012-06-20 16:38:30 -07003433 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3434 tANI_U32 sessionId;
3435 tSmeCmd *pCommand = NULL;
3436
3437 if(NULL == pEntry)
3438 {
3439 smsLog(pMac, LOGW, " CFG_CNF with active list empty\n");
3440 return;
3441 }
3442 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3443 sessionId = pCommand->sessionId;
3444
3445 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3446 {
3447 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3448 }
3449}
3450
Jeff Johnson295189b2012-06-20 16:38:30 -07003451//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3452tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3453{
3454 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3455 {
3456 return (WNI_CFG_PHY_MODE_11B);
3457 }
3458 else
3459 {
3460 if(eCSR_BAND_24 == band)
3461 return (WNI_CFG_PHY_MODE_11G);
3462 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003463 return (WNI_CFG_PHY_MODE_11A);
3464}
Jeff Johnson295189b2012-06-20 16:38:30 -07003465
Jeff Johnsone7245742012-09-05 17:12:55 -07003466
3467#ifdef WLAN_FEATURE_11AC
3468ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
3469{
3470 switch ( aniCBMode )
3471 {
3472 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
3473 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
3474 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
3475 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3476 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
3477 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
3478 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
3479 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3480 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003481 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07003482 return PHY_SINGLE_CHANNEL_CENTERED;
3483 }
3484}
3485#endif
3486
Jeff Johnson295189b2012-06-20 16:38:30 -07003487//pIes may be NULL
3488eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3489 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
3490 tDot11fBeaconIEs *pIes)
3491{
3492 eHalStatus status = eHAL_STATUS_SUCCESS;
3493 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3494 tANI_U8 channel = 0;
3495 //Make sure we have the domain info for the BSS we try to connect to.
3496 //Do we need to worry about sequence for OSs that are not Windows??
3497 if(pBssDesc)
3498 {
3499 if(csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
3500 {
3501 //Make sure the 11d info from this BSSDesc can be applied
3502 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
3503 csrApplyCountryInformation( pMac, TRUE );
3504 }
Kiran4a17ebe2013-01-31 10:43:43 -08003505 if ((csrIs11dSupported (pMac)) && pIes)
3506 {
3507 if (!pIes->Country.present)
3508 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
3509 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003510 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003511 //Qos
3512 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3513 //SSID
3514 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3515 //fragment threshold
3516 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3517 //RTS threshold
3518 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3519
3520 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
3521
3522 //Auth type
3523 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
3524 //encryption type
3525 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
3526 //short slot time
3527 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003528 //11d
3529 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
3530 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
3531 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003532 /*//11h
3533 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
3534 */
3535 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
3536 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07003537
Jeff Johnson295189b2012-06-20 16:38:30 -07003538 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile))
3539 {
3540 channel = pProfile->operationChannel;
3541 }
3542 else
3543 {
3544 if(pBssDesc)
3545 {
3546 channel = pBssDesc->channelId;
3547 }
3548 }
3549 if(0 != channel)
3550 {
3551 if(CSR_IS_CHANNEL_24GHZ(channel))
3552 {//for now if we are on 2.4 Ghz, CB will be always disabled
3553 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3554 }
3555 else
3556 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003557 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003558 }
3559 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003560#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08003561 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
3562 // in function csrConvertCBIniValueToPhyCBState()
3563 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
3564 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07003565 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003566 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003567 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003568 }
3569 else
3570 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003571 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003572 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003573 }
3574 else
3575#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003576 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
3577 //Rate
3578 //Fixed Rate
3579 if(pBssDesc)
3580 {
3581 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
3582 }
3583 else
3584 {
3585 csrSetCfgRateSetFromProfile(pMac, pProfile);
3586 }
3587 //Make this the last CFG to set. The callback will trigger a join_req
3588 //Join time out
3589 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
3590
3591 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003592 return (status);
3593}
3594
Jeff Johnson295189b2012-06-20 16:38:30 -07003595eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3596 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3597{
3598 eHalStatus status;
3599 tBssConfigParam *pBssConfig;
3600 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003601
3602 if(!pSession)
3603 {
3604 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3605 return eHAL_STATUS_FAILURE;
3606 }
3607
Jeff Johnson295189b2012-06-20 16:38:30 -07003608 status = palAllocateMemory(pMac->hHdd, (void **)&pBssConfig, sizeof(tBssConfigParam));
3609 if(HAL_STATUS_SUCCESS(status))
3610 {
3611 palZeroMemory(pMac->hHdd, pBssConfig, sizeof(tBssConfigParam));
3612 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
3613 if(HAL_STATUS_SUCCESS(status))
3614 {
3615 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003616 /* This will allow to pass cbMode during join req */
3617 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003618 //For IBSS, we need to prepare some more information
3619 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003620 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003621 )
3622 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003623 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07003624 }
3625 // If we are in an IBSS, then stop the IBSS...
3626 ////Not worry about WDS connection for now
3627 if ( csrIsConnStateIbss( pMac, sessionId ) )
3628 {
3629 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
3630 }
3631 else
3632 {
3633 // if we are in an Infrastructure association....
3634 if ( csrIsConnStateInfra( pMac, sessionId ) )
3635 {
3636 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
3637 // across SSIDs (roaming to a new SSID)... //
3638 //Not worry about WDS connection for now
3639 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
3640 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
3641 {
3642 // then we need to disassociate from the Infrastructure network...
3643 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
3644 }
3645 else
3646 {
3647 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
3648 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
3649 if ( pBssDesc )
3650 {
3651 // Set parameters for this Bss.
3652 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
3653 }
3654 }
3655 }
3656 else
3657 {
3658 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
3659 // Nothing to stop.
3660 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003661 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003662 )
3663 {
3664 // Set parameters for this Bss.
3665 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
3666 }
3667 }
3668 }
3669 }//Success getting BSS config info
3670 palFreeMemory(pMac->hHdd, pBssConfig);
3671 }//Allocate memory
3672
3673 return (status);
3674}
3675
Jeff Johnson295189b2012-06-20 16:38:30 -07003676eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
3677 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
3678{
3679 eCsrJoinState eRoamState = eCsrContinueRoaming;
3680 eHalStatus status;
3681 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
3682 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
3683 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003684
3685 if(!pSession)
3686 {
3687 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3688 return (eCsrStopRoaming);
3689 }
3690
Jeff Johnson295189b2012-06-20 16:38:30 -07003691 if( CSR_IS_WDS_STA( pProfile ) )
3692 {
3693 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
3694 if( !HAL_STATUS_SUCCESS( status ) )
3695 {
3696 eRoamState = eCsrStopRoaming;
3697 }
3698 }
3699 else
3700 {
3701 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
3702 {
3703 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
3704 return (eCsrStopRoaming);
3705 }
3706 if ( csrIsInfraBssDesc( pBssDesc ) )
3707 {
3708 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
3709 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
3710 // have changed and handle the changes (without disturbing the current association).
3711
3712 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
3713 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
3714 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
3715 )
3716 {
3717 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
3718 // with Authenticating first. To force this, stop the current association (Disassociate) and
3719 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
3720 // a new Association.
3721 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
3722 {
3723 smsLog(pMac, LOGW, FL(" detect same profile authType = %d encryType = %d\n"), pProfile->AuthType, pProfile->EncryptionType);
3724 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
3725 {
3726 eRoamState = eCsrReassocToSelfNoCapChange;
3727 }
3728 else
3729 {
3730 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07003731 //The key changes
3732 palZeroMemory(pMac->hHdd, &bssConfig, sizeof(bssConfig));
3733 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
3734 if(HAL_STATUS_SUCCESS(status))
3735 {
3736 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003737 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003738 //Reapply the config including Keys so reassoc is happening.
3739 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, pBssDesc, &bssConfig, pIesLocal);
3740 if(!HAL_STATUS_SUCCESS(status))
3741 {
3742 eRoamState = eCsrStopRoaming;
3743 }
3744 }
3745 else
3746 {
3747 eRoamState = eCsrStopRoaming;
3748 }
3749 }//same profile
3750 }
3751 else
3752 {
3753 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
3754 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
3755 {
3756 smsLog(pMac, LOGW, FL(" fail to issue disassociate\n"));
3757 eRoamState = eCsrStopRoaming;
3758 }
3759 }
3760 }
3761 else
3762 {
3763 // note: we used to pre-auth here with open authentication networks but that was not working so well.
3764 // we had a lot of join timeouts when testing at Samsung. removing this step helped associations
3765 // work much better.
3766 //
3767 //
3768 // stop the existing network before attempting to join the new network...
3769 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
3770 {
3771 eRoamState = eCsrStopRoaming;
3772 }
3773 }
3774 }//Infra
3775 else
3776 {
3777 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
3778 {
3779 eRoamState = eCsrStopRoaming;
3780 }
3781 }
3782 if( pIesLocal && !pScanResult->pvIes )
3783 {
3784 palFreeMemory(pMac->hHdd, pIesLocal);
3785 }
3786 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003787 return( eRoamState );
3788}
3789
Jeff Johnson295189b2012-06-20 16:38:30 -07003790eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
3791 tSirBssDescription *pBssDesc, tANI_U32 roamId)
3792{
3793 eHalStatus status = eHAL_STATUS_SUCCESS;
3794 tCsrRoamInfo roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07003795 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
3796 roamInfo.pBssDesc = pBssDesc;
3797 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
3798 return (status);
3799}
Jeff Johnson295189b2012-06-20 16:38:30 -07003800//In case no matching BSS is found, use whatever default we can find
3801static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
3802{
3803 //Need to get all negotiated types in place first
3804 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003805 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003806 {
3807 default:
3808 case eCSR_AUTH_TYPE_WPA:
3809 case eCSR_AUTH_TYPE_WPA_PSK:
3810 case eCSR_AUTH_TYPE_WPA_NONE:
3811 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3812 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3813 break;
3814
3815 case eCSR_AUTH_TYPE_SHARED_KEY:
3816 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
3817 break;
3818
3819 case eCSR_AUTH_TYPE_AUTOSWITCH:
3820 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
3821 break;
3822 }
3823 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
3824 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
3825 //In this case, the multicast encryption needs to follow the uncast ones.
3826 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
3827 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
3828}
3829
3830static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
3831{
3832 eHalStatus status;
3833 tCsrScanResult *pScanResult = NULL;
3834 eCsrJoinState eRoamState = eCsrStopRoaming;
3835 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
3836 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
3837 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
3838#ifndef WLAN_MDM_CODE_REDUCTION_OPT
3839 v_U8_t acm_mask = 0;
3840#endif
3841 tANI_U32 sessionId = pCommand->sessionId;
3842 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3843 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
3844 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07003845
3846 if(!pSession)
3847 {
3848 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3849 return (eCsrStopRoaming);
3850 }
3851
Jeff Johnson295189b2012-06-20 16:38:30 -07003852 do
3853 {
3854 // Check for Cardbus eject condition, before trying to Roam to any BSS
3855 //***if( !balIsCardPresent(pAdapter) ) break;
3856
3857 if(NULL != pBSSList)
3858 {
3859 // When handling AP's capability change, continue to associate to
3860 // same BSS and make sure pRoamBssEntry is not Null.
3861 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
3862 {
3863 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
3864 {
3865 //Try the first BSS
3866 pCommand->u.roamCmd.pLastRoamBss = NULL;
3867 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
3868 }
3869 else
3870 {
3871 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
3872 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
3873 {
3874 //Done with all the BSSs
3875 //In this case, will tell HDD the completion
3876 break;
3877 }
3878 else
3879 {
3880 //We need to indicate to HDD that we are done with this one.
3881 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
3882 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
3883 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
3884 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
3885 pRoamInfo = &roamInfo;
3886 }
3887 }
3888 while(pCommand->u.roamCmd.pRoamBssEntry)
3889 {
3890 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07003891 /*If concurrency enabled take the concurrent connected channel first. */
3892 /* Valid multichannel concurrent sessions exempted */
Jeff Johnsone7245742012-09-05 17:12:55 -07003893 if (vos_concurrent_sessions_running() &&
3894 !csrIsValidMcConcurrentSession(pMac, sessionId, &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07003895 {
3896 concurrentChannel =
3897 csrGetConcurrentOperationChannel(pMac);
3898 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003899 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07003900 if ((concurrentChannel) &&
3901 (concurrentChannel ==
3902 pScanResult->Result.BssDescriptor.channelId))
3903 {
3904 //make this 0 because we do not want the
3905 //below check to pass as we don't want to
3906 //connect on other channel
3907 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
3908 FL("Concurrent channel match =%d"),
3909 concurrentChannel);
3910 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003911 }
3912 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003913
3914 if (!concurrentChannel)
3915 {
3916
3917 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
3918 sessionId, &pScanResult->Result.BssDescriptor,
3919 pCommand->u.roamCmd.roamId)))
3920 {
3921 //Ok to roam this
3922 break;
3923 }
3924 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003925 else
3926 {
3927 eRoamState = eCsrStopRoamingDueToConcurrency;
3928 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003929 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
3930 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
3931 {
3932 //Done with all the BSSs
3933 fDone = eANI_BOOLEAN_TRUE;
3934 break;
3935 }
3936 }
3937 if(fDone)
3938 {
3939 break;
3940 }
3941 }
3942 }
3943 //We have something to roam, tell HDD when it is infra.
3944 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
3945 //For WDS, the indication is eCSR_ROAM_WDS_IND
3946 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
3947 {
3948 if(pRoamInfo)
3949 {
3950 pSession->bRefAssocStartCnt--;
3951 //Complete the last association attemp because a new one is about to be tried
3952 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
3953 eCSR_ROAM_ASSOCIATION_COMPLETION,
3954 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
3955 }
3956 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
3957 if(pScanResult)
3958 {
3959 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07003960 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
3961 {
3962 smsLog(pMac, LOGE, FL(" cannot parse IEs\n"));
3963 fDone = eANI_BOOLEAN_TRUE;
3964 eRoamState = eCsrStopRoaming;
3965 break;
3966 }
3967 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
3968 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
3969 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
3970 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
3971 CSR_IS_QOS_BSS(pIesLocal) &&
3972 CSR_IS_UAPSD_BSS(pIesLocal) )
3973 {
3974#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07003975 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
3976 pIesLocal);
3977 pCommand->u.roamCmd.roamProfile.uapsd_mask &= ~(acm_mask);
3978#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07003979 }
3980 else
3981 {
3982 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
3983 }
3984 if( pIesLocal && !pScanResult->Result.pvIes)
3985 {
3986 palFreeMemory(pMac->hHdd, pIesLocal);
3987 }
3988 }
3989 else
3990 {
3991 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
3992 }
3993 roamInfo.pProfile = pProfile;
3994 pSession->bRefAssocStartCnt++;
3995 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
3996 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
3997 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003998 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
3999 {
4000 // If this is a start IBSS profile, then we need to start the IBSS.
4001 if ( CSR_IS_START_IBSS(pProfile) )
4002 {
4003 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004004 // Attempt to start this IBSS...
4005 csrRoamAssignDefaultParam( pMac, pCommand );
4006 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4007 if(HAL_STATUS_SUCCESS(status))
4008 {
4009 if ( fSameIbss )
4010 {
4011 eRoamState = eCsrStartIbssSameIbss;
4012 }
4013 else
4014 {
4015 eRoamState = eCsrContinueRoaming;
4016 }
4017 }
4018 else
4019 {
4020 //it somehow fail need to stop
4021 eRoamState = eCsrStopRoaming;
4022 }
4023 break;
4024 }
4025 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004026 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004027 )
4028 {
4029 // Attempt to start this WDS...
4030 csrRoamAssignDefaultParam( pMac, pCommand );
4031 /* For AP WDS, we dont have any BSSDescription */
4032 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4033 if(HAL_STATUS_SUCCESS(status))
4034 {
4035 eRoamState = eCsrContinueRoaming;
4036 }
4037 else
4038 {
4039 //it somehow fail need to stop
4040 eRoamState = eCsrStopRoaming;
4041 }
4042 }
4043 else
4044 {
4045 //Nothing we can do
4046 smsLog(pMac, LOGW, FL("cannot continue without BSS list\n"));
4047 eRoamState = eCsrStopRoaming;
4048 break;
4049 }
4050 }
4051 else //We have BSS
4052 {
4053 //Need to assign these value because they are used in csrIsSameProfile
4054 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4055 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType = pScanResult->ucEncryptionType; //Negotiated while building scan result.
4056 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType = pScanResult->mcEncryptionType;
4057 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4058 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4059 {
4060 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4061 {
4062 eRoamState = eCsrStartIbssSameIbss;
4063 break;
4064 }
4065 }
4066 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4067 {
4068 //trying to connect to the one already connected
4069 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4070 eRoamState = eCsrReassocToSelfNoCapChange;
4071 break;
4072 }
4073 // Attempt to Join this Bss...
4074 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4075 break;
4076 }
4077
4078 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004079 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4080 {
4081 //Need to indicate association_completion if association_start has been done
4082 if(pSession->bRefAssocStartCnt > 0)
4083 {
4084 pSession->bRefAssocStartCnt--;
4085 //Complete the last association attemp because a new one is about to be tried
4086 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4087 eCSR_ROAM_ASSOCIATION_COMPLETION,
4088 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4089 }
4090 }
4091
4092 return( eRoamState );
4093}
4094
Jeff Johnson295189b2012-06-20 16:38:30 -07004095static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4096{
4097 eHalStatus status = eHAL_STATUS_SUCCESS;
4098 eCsrJoinState RoamState;
4099 tANI_U32 sessionId = pCommand->sessionId;
4100
Jeff Johnson295189b2012-06-20 16:38:30 -07004101 //***if( hddIsRadioStateOn( pAdapter ) )
4102 {
4103 // Attept to join a Bss...
4104 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004105
Jeff Johnson295189b2012-06-20 16:38:30 -07004106 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004107 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004108 {
4109 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004110 // and if connected in Infrastructure mode...
4111 if ( csrIsConnStateInfra(pMac, sessionId) )
4112 {
4113 //... then we need to issue a disassociation
4114 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4115 if(!HAL_STATUS_SUCCESS(status))
4116 {
4117 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d\n"), status);
4118 //roam command is completed by caller in the failed case
4119 fComplete = eANI_BOOLEAN_TRUE;
4120 }
4121 }
4122 else if( csrIsConnStateIbss(pMac, sessionId) )
4123 {
4124 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4125 if(!HAL_STATUS_SUCCESS(status))
4126 {
4127 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d\n"), status);
4128 //roam command is completed by caller in the failed case
4129 fComplete = eANI_BOOLEAN_TRUE;
4130 }
4131 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004132 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4133 {
4134 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4135 if(!HAL_STATUS_SUCCESS(status))
4136 {
4137 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d\n"), status);
4138 //roam command is completed by caller in the failed case
4139 fComplete = eANI_BOOLEAN_TRUE;
4140 }
4141 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004142 else
4143 {
4144 fComplete = eANI_BOOLEAN_TRUE;
4145 }
4146 if(fComplete)
4147 {
4148 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004149 if(eCsrStopRoamingDueToConcurrency == RoamState)
4150 {
4151 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4152 }
4153 else
4154 {
4155 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4156 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004157 }
4158 }
4159 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4160 {
4161 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4162 }
4163 else if ( eCsrStartIbssSameIbss == RoamState )
4164 {
4165 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4166 }
4167 }//hddIsRadioStateOn
4168
4169 return status;
4170}
Jeff Johnson295189b2012-06-20 16:38:30 -07004171eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4172{
4173 tANI_U32 sessionId;
4174 tCsrRoamSession *pSession;
4175 tCsrScanResult *pScanResult = NULL;
4176 tSirBssDescription *pBssDesc = NULL;
4177 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004178 sessionId = pCommand->sessionId;
4179 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 }
4186
Jeff Johnson295189b2012-06-20 16:38:30 -07004187 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4188 {
4189 //the roaming is cancelled. Simply complete the command
4190 smsLog(pMac, LOG1, FL(" Roam command cancelled\n"));
4191 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4192 return eHAL_STATUS_FAILURE;
4193 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004194 if (pCommand->u.roamCmd.pRoamBssEntry)
4195 {
4196 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4197 pBssDesc = &pScanResult->Result.BssDescriptor;
4198 }
4199 else
4200 {
4201 //the roaming is cancelled. Simply complete the command
4202 smsLog(pMac, LOG1, FL(" Roam command cancelled\n"));
4203 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4204 return eHAL_STATUS_FAILURE;
4205 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004206 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4207 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4208 return status;
4209}
4210
Jeff Johnson295189b2012-06-20 16:38:30 -07004211eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4212{
4213 eHalStatus status = eHAL_STATUS_SUCCESS;
4214 tCsrRoamInfo roamInfo;
4215 tANI_U32 sessionId = pCommand->sessionId;
4216 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004217
4218 if(!pSession)
4219 {
4220 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4221 return eHAL_STATUS_FAILURE;
4222 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004223
4224 switch ( pCommand->u.roamCmd.roamReason )
4225 {
4226 case eCsrForcedDisassoc:
4227 csrFreeRoamProfile(pMac, sessionId);
4228 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4229 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004230 case eCsrSmeIssuedDisassocForHandoff:
4231 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4232#if 0 // TODO : Confirm this change
4233 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4234#else
4235 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4236#endif
4237
4238 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004239 case eCsrForcedDisassocMICFailure:
4240 csrFreeRoamProfile(pMac, sessionId);
4241 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
4242 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004243 case eCsrForcedDeauth:
4244 csrFreeRoamProfile(pMac, sessionId);
4245 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
4246 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004247 case eCsrHddIssuedReassocToSameAP:
4248 case eCsrSmeIssuedReassocToSameAP:
4249 {
4250 tDot11fBeaconIEs *pIes = NULL;
4251
Jeff Johnson295189b2012-06-20 16:38:30 -07004252 if( pSession->pConnectBssDesc )
4253 {
4254 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4255 if(!HAL_STATUS_SUCCESS(status) )
4256 {
4257 smsLog(pMac, LOGE, FL(" fail to parse IEs\n"));
4258 }
4259 else
4260 {
4261 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4262 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4263 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004264 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4265 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4266 pSession->bRefAssocStartCnt++;
4267 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4268 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4269
4270 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate\n"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004271 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4272 &pCommand->u.roamCmd.roamProfile );
4273 if(!HAL_STATUS_SUCCESS(status))
4274 {
4275 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
4276 }
4277
Jeff Johnson295189b2012-06-20 16:38:30 -07004278 palFreeMemory(pMac->hHdd, pIes);
4279 pIes = NULL;
4280 }
4281 }
4282 break;
4283 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004284 case eCsrCapsChange:
4285 smsLog(pMac, LOGE, FL("received eCsrCapsChange \n"));
4286 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4287 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4288 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004289 case eCsrSmeIssuedFTReassoc:
4290 smsLog(pMac, LOGE, FL("received FT Reassoc Req \n"));
4291 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4292 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004293
Jeff Johnson295189b2012-06-20 16:38:30 -07004294 case eCsrStopBss:
4295 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4296 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4297 break;
4298
4299 case eCsrForcedDisassocSta:
4300 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4301 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4302 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4303 pCommand->u.roamCmd.reason);
4304 break;
4305
4306 case eCsrForcedDeauthSta:
4307 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4308 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4309 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4310 pCommand->u.roamCmd.reason);
4311 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004312
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004313 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08004314 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004315 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4316 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004317 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004318
4319 default:
4320 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4321
4322 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4323 {
4324 //Remember the roaming profile
4325 csrFreeRoamProfile(pMac, sessionId);
4326 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pSession->pCurRoamProfile, sizeof(tCsrRoamProfile))))
4327 {
4328 palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile));
4329 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4330 }
4331 }
4332
4333 //At this point, original uapsd_mask is saved in pCurRoamProfile
4334 //uapsd_mask in the pCommand may change from this point on.
4335
4336 // Attempt to roam with the new scan results (if we need to..)
4337 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004338 if(!HAL_STATUS_SUCCESS(status))
4339 {
4340 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X\n"), status);
4341 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004342 break;
4343 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004344 return (status);
4345}
4346
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004347void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4348{
4349 pCommand->u.roamCmd.pLastRoamBss = NULL;
4350 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4351 //Because u.roamCmd is union and share with scanCmd and StatusChange
4352 palZeroMemory(pMac->hHdd, &pCommand->u.roamCmd, sizeof(tRoamCmd));
4353}
4354
Jeff Johnson295189b2012-06-20 16:38:30 -07004355void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4356{
4357 if(pCommand->u.roamCmd.fReleaseBssList)
4358 {
4359 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4360 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4361 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4362 }
4363 if(pCommand->u.roamCmd.fReleaseProfile)
4364 {
4365 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4366 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4367 }
4368 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4369 //Because u.roamCmd is union and share with scanCmd and StatusChange
4370 palZeroMemory(pMac->hHdd, &pCommand->u.roamCmd, sizeof(tRoamCmd));
4371}
4372
Jeff Johnson295189b2012-06-20 16:38:30 -07004373void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4374{
4375 palZeroMemory(pMac->hHdd, &pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd));
4376}
Jeff Johnson295189b2012-06-20 16:38:30 -07004377void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4378{
4379 tListElem *pEntry;
4380 tSmeCmd *pCommand;
4381 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004382 smsLog( pMac, LOG2, "Roam Completion ...\n" );
Jeff Johnson295189b2012-06-20 16:38:30 -07004383 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4384 if ( pEntry )
4385 {
4386 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004387 // If the head of the queue is Active and it is a ROAM command, remove
4388 // and put this on the Free queue.
4389 if ( eSmeCommandRoam == pCommand->command )
4390 {
4391 //we need to process the result first before removing it from active list because state changes
4392 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4393 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4394 if( fReleaseCommand )
4395 {
4396 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4397 {
4398 csrReleaseCommandRoam( pMac, pCommand );
4399 }
4400 else
4401 {
4402 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d\n",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004403 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004404 }
4405 }
4406 else
4407 {
4408 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d\n",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004409 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004410 }
4411 }
4412 else
4413 {
4414 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ...\n" );
4415 }
4416 }
4417 else
4418 {
4419 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ...\n" );
4420 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004421 if( fReleaseCommand )
4422 {
4423 smeProcessPendingQueue( pMac );
4424 }
4425}
4426
Jeff Johnson295189b2012-06-20 16:38:30 -07004427void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4428{
4429 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004430 if(!pSession)
4431 {
4432 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4433 return;
4434 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004435 palZeroMemory( pMac->hHdd, &(pSession->PmkidCandidateInfo[0]), sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED );
4436 pSession->NumPmkidCandidate = 0;
4437}
Jeff Johnson295189b2012-06-20 16:38:30 -07004438#ifdef FEATURE_WLAN_WAPI
4439void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4440{
4441 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004442 if(!pSession)
4443 {
4444 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4445 return;
4446 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004447 palZeroMemory( pMac->hHdd, &(pSession->BkidCandidateInfo[0]), sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED );
4448 pSession->NumBkidCandidate = 0;
4449}
4450#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004451extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4452
Jeff Johnson295189b2012-06-20 16:38:30 -07004453static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4454 tSirBssDescription *pSirBssDesc,
4455 tDot11fBeaconIEs *pIes)
4456{
4457 eHalStatus status = eHAL_STATUS_SUCCESS;
4458 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4459 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004460
4461 if(!pSession)
4462 {
4463 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4464 return eHAL_STATUS_FAILURE;
4465 }
4466
Jeff Johnson295189b2012-06-20 16:38:30 -07004467 if((eCSR_AUTH_TYPE_WPA == authType) ||
4468 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
4469 (eCSR_AUTH_TYPE_RSN == authType) ||
4470 (eCSR_AUTH_TYPE_RSN_PSK == authType)
4471#if defined WLAN_FEATURE_VOWIFI_11R
4472 ||
4473 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4474 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
4475#endif /* FEATURE_WLAN_WAPI */
4476#ifdef FEATURE_WLAN_WAPI
4477 ||
4478 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4479 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
4480#endif /* FEATURE_WLAN_WAPI */
4481 )
4482 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004483 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4484 {
4485 smsLog(pMac, LOGE, FL(" cannot parse IEs\n"));
4486 }
4487 if( pIesLocal )
4488 {
4489 tANI_U32 nIeLen;
4490 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07004491 if((eCSR_AUTH_TYPE_RSN == authType) ||
4492#if defined WLAN_FEATURE_VOWIFI_11R
4493 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4494 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
4495#endif /* WLAN_FEATURE_VOWIFI_11R */
4496 (eCSR_AUTH_TYPE_RSN_PSK == authType))
4497 {
4498 if(pIesLocal->RSN.present)
4499 {
4500 //Calculate the actual length
4501 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
4502 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
4503 + 2 //akm_suite_count
4504 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
4505 + 2; //reserved
4506 if( pIesLocal->RSN.pmkid_count )
4507 {
4508 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
4509 }
4510 //nIeLen doesn't count EID and length fields
4511 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnRspIE, nIeLen + 2))))
4512 {
4513 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
4514 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4515 //copy upto akm_suites
4516 pIeBuf = pSession->pWpaRsnRspIE + 2;
4517 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.version, 8);
4518 pIeBuf += 8;
4519 if( pIesLocal->RSN.pwise_cipher_suite_count )
4520 {
4521 //copy pwise_cipher_suites
4522 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.pwise_cipher_suites,
4523 pIesLocal->RSN.pwise_cipher_suite_count * 4);
4524 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
4525 }
4526 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
4527 pIeBuf += 2;
4528 if( pIesLocal->RSN.akm_suite_count )
4529 {
4530 //copy akm_suites
4531 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.akm_suites,
4532 pIesLocal->RSN.akm_suite_count * 4);
4533 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
4534 }
4535 //copy the rest
4536 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.akm_suites +
4537 pIesLocal->RSN.akm_suite_count * 4,
4538 2 + pIesLocal->RSN.pmkid_count * 4);
4539 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4540 }
4541 }
4542 }
4543 else if((eCSR_AUTH_TYPE_WPA == authType) ||
4544 (eCSR_AUTH_TYPE_WPA_PSK == authType))
4545 {
4546 if(pIesLocal->WPA.present)
4547 {
4548 //Calculate the actual length
4549 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
4550 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
4551 + 2 //auth_suite_count
4552 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
4553 // The WPA capabilities follows the Auth Suite (two octects)--
4554 // this field is optional, and we always "send" zero, so just
4555 // remove it. This is consistent with our assumptions in the
4556 // frames compiler; c.f. bug 15234:
4557 //nIeLen doesn't count EID and length fields
4558 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnRspIE, nIeLen + 2))))
4559 {
4560 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
4561 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4562 pIeBuf = pSession->pWpaRsnRspIE + 2;
4563 //Copy WPA OUI
4564 palCopyMemory(pMac->hHdd, pIeBuf, &csrWpaOui[1], 4);
4565 pIeBuf += 4;
4566 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WPA.version, 8 +
4567 pIesLocal->WPA.unicast_cipher_count * 4);
4568 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
4569 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WPA.auth_suite_count, 2 +
4570 pIesLocal->WPA.auth_suite_count * 4);
4571 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
4572 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4573 }
4574 }
4575 }
4576#ifdef FEATURE_WLAN_WAPI
4577 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4578 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
4579 {
4580 if(pIesLocal->WAPI.present)
4581 {
4582 //Calculate the actual length
4583 nIeLen = 4 //version + akm_suite_count
4584 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
4585 + 2 //pwise_cipher_suite_count
4586 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
4587 + 6; //gp_cipher_suite + preauth + reserved
4588 if( pIesLocal->WAPI.bkid_count )
4589 {
4590 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
4591 }
4592
4593 //nIeLen doesn't count EID and length fields
4594 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWapiRspIE, nIeLen + 2))))
4595 {
4596 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
4597 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
4598 pIeBuf = pSession->pWapiRspIE + 2;
4599 //copy upto akm_suite_count
4600 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.version, 4);
4601 pIeBuf += 4;
4602 if( pIesLocal->WAPI.akm_suite_count )
4603 {
4604 //copy akm_suites
4605 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.akm_suites,
4606 pIesLocal->WAPI.akm_suite_count * 4);
4607 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
4608 }
4609 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.unicast_cipher_suite_count, 2);
4610 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004611 if( pIesLocal->WAPI.unicast_cipher_suite_count )
4612 {
4613 //copy pwise_cipher_suites
4614 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.unicast_cipher_suites,
4615 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
4616 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
4617 }
4618 //gp_cipher_suite + preauth + reserved + bkid_count
4619 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.multicast_cipher_suite, 8);
4620 pIeBuf += 8;
4621 if( pIesLocal->WAPI.bkid_count )
4622 {
4623 //copy akm_suites
4624 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.bkid, pIesLocal->WAPI.bkid_count * 4);
4625 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
4626 }
4627 pSession->nWapiRspIeLength = nIeLen + 2;
4628 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004629 }
4630 }
4631#endif /* FEATURE_WLAN_WAPI */
4632 if( !pIes )
4633 {
4634 //locally allocated
4635 palFreeMemory(pMac->hHdd, pIesLocal);
4636 }
4637 }
4638 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004639 return (status);
4640}
4641
Jeff Johnson295189b2012-06-20 16:38:30 -07004642static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
4643{
4644 v_U8_t bACWeights[WLANTL_MAX_AC];
4645 v_U8_t paramBk, paramBe, paramVi, paramVo;
4646 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004647 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
4648 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
4649 //of the higher AC one, make the higher AC has the same weight as the lower AC.
4650 //This doesn't address the case where the lower AC needs a real higher weight
4651 if( pIEs->WMMParams.present )
4652 {
4653 //no change to the lowest ones
4654 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
4655 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
4656 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
4657 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
4658 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
4659 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
4660 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
4661 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
4662 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
4663 {
4664 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
4665 fWeightChange = VOS_TRUE;
4666 }
4667 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
4668 {
4669 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
4670 fWeightChange = VOS_TRUE;
4671 }
4672 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
4673 {
4674 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
4675 fWeightChange = VOS_TRUE;
4676 }
4677 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
4678 {
4679 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
4680 fWeightChange = VOS_TRUE;
4681 }
4682 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
4683 {
4684 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
4685 fWeightChange = VOS_TRUE;
4686 }
4687 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
4688 {
4689 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
4690 fWeightChange = VOS_TRUE;
4691 }
4692 if(fWeightChange)
4693 {
4694 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)\n"), bACWeights[0], bACWeights[1],
4695 bACWeights[2], bACWeights[3]);
4696 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
4697 }
4698 }
4699}
Jeff Johnson295189b2012-06-20 16:38:30 -07004700#ifdef WLAN_FEATURE_VOWIFI_11R
4701//Returns whether the current association is a 11r assoc or not
4702tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
4703{
4704#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
4705 return csrNeighborRoamIs11rAssoc(pMac);
4706#else
4707 return eANI_BOOLEAN_FALSE;
4708#endif
4709}
4710#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004711#ifdef FEATURE_WLAN_CCX
4712//Returns whether the current association is a CCX assoc or not
4713tANI_BOOLEAN csrRoamIsCCXAssoc(tpAniSirGlobal pMac)
4714{
4715#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
4716 return csrNeighborRoamIsCCXAssoc(pMac);
4717#else
4718 return eANI_BOOLEAN_FALSE;
4719#endif
4720}
4721#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004722#ifdef FEATURE_WLAN_LFR
4723//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304724tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004725{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304726 tCsrRoamSession *pSession = NULL;
4727
4728 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
4729 {
4730 pSession = CSR_GET_SESSION( pMac, sessionId );
4731 if (NULL != pSession->pCurRoamProfile)
4732 {
4733 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
4734 {
4735 return eANI_BOOLEAN_FALSE;
4736 }
4737 }
4738 }
4739
Madan Mohan Koyyalamudi9ce36ec2012-10-15 16:03:17 -07004740 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07004741 (!csrIsConcurrentSessionRunning(pMac)));
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004742}
4743#endif
4744
Jeff Johnson295189b2012-06-20 16:38:30 -07004745//Return true means the command can be release, else not
4746static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
4747 eCsrRoamCompleteResult Result, void *Context )
4748{
4749 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
4750 tSirBssDescription *pSirBssDesc = NULL;
4751 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
4752 tCsrScanResult *pScanResult = NULL;
4753 tCsrRoamInfo roamInfo;
4754 sme_QosAssocInfo assocInfo;
4755 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
4756 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
4757 tDot11fBeaconIEs *pIes = NULL;
4758 tANI_U32 sessionId = pCommand->sessionId;
4759 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4760 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4761 eRoamCmdStatus roamStatus;
4762 eCsrRoamResult roamResult;
4763 eHalStatus status;
4764 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004765 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004766
Jeff Johnson32d95a32012-09-10 13:15:23 -07004767 if(!pSession)
4768 {
4769 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4770 return eANI_BOOLEAN_FALSE;
4771 }
4772
Jeff Johnson295189b2012-06-20 16:38:30 -07004773 smsLog( pMac, LOG1, FL("Processing ROAM results...\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004774 switch( Result )
4775 {
4776 case eCsrJoinSuccess:
4777 // reset the IDLE timer
4778 // !!
4779 // !! fall through to the next CASE statement here is intentional !!
4780 // !!
4781 case eCsrReassocSuccess:
4782 if(eCsrReassocSuccess == Result)
4783 {
4784 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
4785 }
4786 else
4787 {
4788 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
4789 }
4790 // Success Join Response from LIM. Tell NDIS we are connected and save the
4791 // Connected state...
4792 smsLog(pMac, LOGW, FL("receives association indication\n"));
4793 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
4794 //always free the memory here
4795 if(pSession->pWpaRsnRspIE)
4796 {
4797 pSession->nWpaRsnRspIeLength = 0;
4798 palFreeMemory(pMac->hHdd, pSession->pWpaRsnRspIE);
4799 pSession->pWpaRsnRspIE = NULL;
4800 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004801#ifdef FEATURE_WLAN_WAPI
4802 if(pSession->pWapiRspIE)
4803 {
4804 pSession->nWapiRspIeLength = 0;
4805 palFreeMemory(pMac->hHdd, pSession->pWapiRspIE);
4806 pSession->pWapiRspIE = NULL;
4807 }
4808#endif /* FEATURE_WLAN_WAPI */
4809#ifdef FEATURE_WLAN_BTAMP_UT_RF
4810 //Reset counter so no join retry is needed.
4811 pSession->maxRetryCount = 0;
4812 csrRoamStopJoinRetryTimer(pMac, sessionId);
4813#endif
4814 /* This creates problem since we have not saved the connected profile.
4815 So moving this after saving the profile
4816 */
4817 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
4818 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4819 {
4820 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
4821 }
4822 else
4823 {
4824 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
4825 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004826 //Use the last connected bssdesc for reassoc-ing to the same AP.
4827 //NOTE: What to do when reassoc to a different AP???
4828 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
4829 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
4830 {
4831 pSirBssDesc = pSession->pConnectBssDesc;
4832 if(pSirBssDesc)
4833 {
4834 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
4835 }
4836 }
4837 else
4838 {
4839
4840 if(pCommand->u.roamCmd.pRoamBssEntry)
4841 {
4842 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4843 if(pScanResult != NULL)
4844 {
4845 pSirBssDesc = &pScanResult->Result.BssDescriptor;
4846 //this can be NULL
4847 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
4848 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
4849 }
4850 }
4851 }
4852 if( pSirBssDesc )
4853 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004854 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07004855 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
4856 //Save WPA/RSN IE
4857 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
4858#ifdef FEATURE_WLAN_CCX
4859 roamInfo.isCCXAssoc = pSession->connectedProfile.isCCXAssoc;
4860#endif
4861
4862 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
4863 // substate change.
4864 // Moving even save profile above so that below mentioned conditon is also met.
4865 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
4866 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07004867 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
4868 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
4869 // will be dropped for the security context may not be set properly.
4870 //
4871 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
4872 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
4873 //
4874 // this reordering was done on titan_prod_usb branch and is being replicated here.
4875 //
4876
4877 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
4878 !pProfile->bWPSAssociation)
4879 {
4880 // Issue the set Context request to LIM to establish the Unicast STA context
4881 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
4882 pProfile->negotiatedUCEncryptionType,
4883 pSirBssDesc, &(pSirBssDesc->bssId),
4884 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
4885 {
4886 smsLog( pMac, LOGE, FL(" Set context for unicast fail\n") );
4887 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
4888 }
4889 // Issue the set Context request to LIM to establish the Broadcast STA context
4890 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
4891 pSirBssDesc, &BroadcastMac,
4892 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
4893 }
4894 else
4895 {
4896 //Need to wait for supplicant authtication
4897 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004898 //Set the subestate to WaitForKey in case authentiation is needed
4899 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
4900
Jeff Johnson295189b2012-06-20 16:38:30 -07004901 if(pProfile->bWPSAssociation)
4902 {
4903 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
4904 }
4905 else
4906 {
4907 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
4908 }
4909
4910 //Save sessionId in case of timeout
4911 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
4912 //This time should be long enough for the rest of the process plus setting key
4913 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
4914 {
4915 //Reset our state so nothting is blocked.
4916 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer\n") );
4917 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
4918 }
4919 }
4920
4921 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
4922 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004923 if(Context)
4924 {
4925 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
4926 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07004927 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
4928 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
4929#ifdef WLAN_FEATURE_VOWIFI_11R
4930 len += pJoinRsp->parsedRicRspLen;
4931#endif /* WLAN_FEATURE_VOWIFI_11R */
4932#ifdef FEATURE_WLAN_CCX
4933 len += pJoinRsp->tspecIeLen;
4934#endif
4935 if(len)
4936 {
4937 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
4938 (void **)&pSession->connectedInfo.pbFrames, len)))
4939 {
4940 if(HAL_STATUS_SUCCESS( palCopyMemory(pMac->hHdd,
4941 pSession->connectedInfo.pbFrames, pJoinRsp->frames, len) ))
4942 {
4943 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
4944 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
4945 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
4946#ifdef WLAN_FEATURE_VOWIFI_11R
4947 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
4948#endif /* WLAN_FEATURE_VOWIFI_11R */
4949#ifdef FEATURE_WLAN_CCX
4950 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
4951#endif
4952 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
4953 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
4954 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
4955 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
4956 }
4957 else
4958 {
4959 smsLog(pMac, LOGE, "%s: Copying of memory failed for %d bytes !!!\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004960 __func__, len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004961 palFreeMemory( pMac->hHdd, pSession->connectedInfo.pbFrames );
4962 pSession->connectedInfo.pbFrames = NULL;
4963 }
4964 }
4965 }
4966 if(pCommand->u.roamCmd.fReassoc)
4967 {
4968 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
4969 }
4970 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
4971 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
4972 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
4973 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
4974 }
4975 else
4976 {
4977 if(pCommand->u.roamCmd.fReassoc)
4978 {
4979 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
4980 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
4981 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
4982 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
4983 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
4984 }
4985 }
4986#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4987 // Indicate SME-QOS with reassoc success event, only after
4988 // copying the frames
4989 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
4990#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004991 roamInfo.pBssDesc = pSirBssDesc;
4992 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4993 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4994#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4995 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
4996#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
4997 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07004998#ifdef FEATURE_WLAN_UAPSD_FW_TRG_FRAMES
4999 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5000 //It may be better to let QoS do this????
5001 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5002 {
5003 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now\n",
5004 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5005 pmcStartUapsd( pMac, NULL, NULL );
5006 }
5007#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005008 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5009 if( pSession->bRefAssocStartCnt > 0 )
5010 {
5011 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005012 //Remove this code once SLM_Sessionization is supported
5013 //BMPS_WORKAROUND_NOT_NEEDED
5014 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005015 {
5016 pMac->roam.configParam.doBMPSWorkaround = 1;
5017 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005018 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5019 }
5020
5021 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005022 // reset the PMKID candidate list
5023 csrResetPMKIDCandidateList( pMac, sessionId );
5024 //Update TL's AC weight base on the current EDCA parameters
5025 //These parameters may change in the course of the connection, that sictuation
5026 //is not taken care here. This change is mainly to address a WIFI WMM test where
5027 //BE has a equal or higher TX priority than VI.
5028 //We only do this for infra link
5029 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5030 {
5031 csrCheckAndUpdateACWeight(pMac, pIes);
5032 }
5033#ifdef FEATURE_WLAN_WAPI
5034 // reset the BKID candidate list
5035 csrResetBKIDCandidateList( pMac, sessionId );
5036#endif /* FEATURE_WLAN_WAPI */
5037 }
5038 else
5039 {
5040 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc\n");
5041 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005042 csrScanCancelIdleScan(pMac);
5043 //Not to signal link up because keys are yet to be set.
5044 //The linkup function will overwrite the sub-state that we need to keep at this point.
5045 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5046 {
5047 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5048 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005049 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5050 //enough to let security and DHCP handshake succeed before entry into BMPS
5051 if (pmcShouldBmpsTimerRun(pMac))
5052 {
5053 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5054 != eHAL_STATUS_SUCCESS)
5055 {
5056 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5057 }
5058 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5059 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005060 break;
5061
Jeff Johnson295189b2012-06-20 16:38:30 -07005062 case eCsrStartBssSuccess:
5063 // on the StartBss Response, LIM is returning the Bss Description that we
5064 // are beaconing. Add this Bss Description to our scan results and
5065 // chain the Profile to this Bss Description. On a Start BSS, there was no
5066 // detected Bss description (no partner) so we issued the Start Bss to
5067 // start the Ibss without any Bss description. Lim was kind enough to return
5068 // the Bss Description that we start beaconing for the newly started Ibss.
5069 smsLog(pMac, LOG2, FL("receives start BSS ok indication\n"));
5070 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005071 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Jeff Johnson295189b2012-06-20 16:38:30 -07005072 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5073 if( CSR_IS_IBSS( pProfile ) )
5074 {
5075 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5076 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005077 else if (CSR_IS_INFRA_AP(pProfile))
5078 {
5079 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5080 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005081 else
5082 {
5083 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5084 }
5085 if( !CSR_IS_WDS_STA( pProfile ) )
5086 {
5087 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005088 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005089 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5090 {
5091 smsLog(pMac, LOG2, FL("cannot parse IBSS IEs\n"));
5092 roamInfo.pBssDesc = pSirBssDesc;
5093 //We need to associate_complete it first, becasue Associate_start already indicated.
5094 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5095 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5096 break;
5097 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005098 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005099 {
5100 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes );
5101 }
5102 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5103 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5104 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5105 if(pSirBssDesc)
5106 {
5107 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5108 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
5109 }
5110 //We are doen with the IEs so free it
5111 palFreeMemory(pMac->hHdd, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005112#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5113 {
5114 vos_log_ibss_pkt_type *pIbssLog;
5115 tANI_U32 bi;
5116
5117 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5118 if(pIbssLog)
5119 {
5120 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5121 {
5122 //We start the IBSS (didn't find any matched IBSS out there)
5123 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
5124 }
5125 else
5126 {
5127 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
5128 }
5129 if(pSirBssDesc)
5130 {
5131 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pSirBssDesc->bssId, 6);
5132 pIbssLog->operatingChannel = pSirBssDesc->channelId;
5133 }
5134 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
5135 {
5136 //***U8 is not enough for beacon interval
5137 pIbssLog->beaconInterval = (v_U8_t)bi;
5138 }
5139 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5140 }
5141 }
5142#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5143 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
5144 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07005145 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
5146 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005147 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
5148 csrRoamIssueSetContextReq( pMac, sessionId,
5149 pProfile->negotiatedMCEncryptionType,
5150 pSirBssDesc, &BroadcastMac,
5151 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5152 }
5153 }
5154 else
5155 {
5156 //Keep the state to eCSR_ROAMING_STATE_JOINING
5157 //Need to send join_req.
5158 if(pCommand->u.roamCmd.pRoamBssEntry)
5159 {
5160 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
5161 {
5162 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5163 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5164 // Set the roaming substate to 'join attempt'...
5165 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08005166 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005167 }
5168 }
5169 else
5170 {
5171 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc\n" );
5172 VOS_ASSERT( 0 );
5173 }
5174 }
5175 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5176 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5177 //trigger the connection start indication in Vista
5178 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
5179 {
5180 roamStatus = eCSR_ROAM_IBSS_IND;
5181 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5182 if( CSR_IS_WDS( pProfile ) )
5183 {
5184 roamStatus = eCSR_ROAM_WDS_IND;
5185 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5186 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005187 if( CSR_IS_INFRA_AP( pProfile ) )
5188 {
5189 roamStatus = eCSR_ROAM_INFRA_IND;
5190 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
5191 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005192
5193 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5194 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5195 //trigger the connection start indication in Vista
5196 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5197 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5198 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5199 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5200 {
5201 //We start the IBSS (didn't find any matched IBSS out there)
5202 roamInfo.pBssDesc = pSirBssDesc;
5203 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005204 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005205 //Remove this code once SLM_Sessionization is supported
5206 //BMPS_WORKAROUND_NOT_NEEDED
5207 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005208 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005209 {
5210 pMac->roam.configParam.doBMPSWorkaround = 1;
5211 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005212
Jeff Johnson295189b2012-06-20 16:38:30 -07005213 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5214 }
5215
5216 csrScanCancelIdleScan(pMac);
5217 //Only use this timer for ibss. BAP has its own timer for WDS
5218 if( CSR_IS_IBSS( pProfile) && CSR_INVALID_SCANRESULT_HANDLE != pCommand->u.roamCmd.hBSSList)
5219 {
5220 //start the join IBSS timer
5221 csrRoamStartIbssJoinTimer(pMac, sessionId, CSR_IBSS_JOIN_TIMEOUT_PERIOD); //interval
5222 pSession->ibss_join_pending = TRUE;
5223 }
5224 if( HAL_STATUS_SUCCESS( status ) )
5225 {
5226 //Already sent join_req for the WDS station
5227 fReleaseCommand = eANI_BOOLEAN_FALSE;
5228 }
5229 else if( CSR_IS_WDS_STA( pProfile ) )
5230 {
5231 //need to send stop BSS because we fail to send join_req
5232 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5233 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5234 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5235 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005236 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005237 case eCsrStartBssFailure:
5238#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5239 {
5240 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005241 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5242 if(pIbssLog)
5243 {
5244 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5245 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5246 }
5247 }
5248#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005249 roamStatus = eCSR_ROAM_IBSS_IND;
5250 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5251 if( CSR_IS_WDS( pProfile ) )
5252 {
5253 roamStatus = eCSR_ROAM_WDS_IND;
5254 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5255 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005256 if( CSR_IS_INFRA_AP( pProfile ) )
5257 {
5258 roamStatus = eCSR_ROAM_INFRA_IND;
5259 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5260 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005261 if(Context)
5262 {
5263 pSirBssDesc = (tSirBssDescription *)Context;
5264 }
5265 else
5266 {
5267 pSirBssDesc = NULL;
5268 }
5269 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5270 roamInfo.pBssDesc = pSirBssDesc;
5271 //We need to associate_complete it first, becasue Associate_start already indicated.
5272 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5273 csrSetDefaultDot11Mode( pMac );
5274 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005275 case eCsrSilentlyStopRoaming:
5276 // We are here because we try to start the same IBSS
5277 //No message to PE
5278 // return the roaming state to Joined.
5279 smsLog(pMac, LOGW, FL("receives silently roaming indication\n"));
5280 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5281 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5282 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5283 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5284 if( roamInfo.pBssDesc )
5285 {
5286 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &roamInfo.pBssDesc->bssId, sizeof(tCsrBssid));
5287 }
5288 //Since there is no change in the current state, simply pass back no result otherwise
5289 //HDD may be mistakenly mark to disconnected state.
5290 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5291 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005292 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005293 case eCsrSilentlyStopRoamingSaveState:
5294 //We are here because we try to connect to the same AP
5295 //No message to PE
5296 smsLog(pMac, LOGW, FL("receives silently stop roaming indication\n"));
5297 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
5298
5299 //to aviod resetting the substate to NONE
5300 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5301 //No need to change substate to wai_for_key because there is no state change
5302 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5303 if( roamInfo.pBssDesc )
5304 {
5305 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &roamInfo.pBssDesc->bssId, sizeof(tCsrBssid));
5306 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005307 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5308 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5309 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5310 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5311 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5312 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5313 roamInfo.staId = pSession->connectedInfo.staId;
5314 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005315 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005316 pSession->bRefAssocStartCnt--;
5317 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5318 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5319 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5320 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005321 case eCsrReassocFailure:
5322#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5323 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5324#endif
5325 case eCsrJoinWdsFailure:
5326 smsLog(pMac, LOGW, FL("failed to join WDS\n"));
5327 csrFreeConnectBssDesc(pMac, sessionId);
5328 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5329 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5330 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5331 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5332 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5333 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5334 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5335 eCSR_ROAM_WDS_IND,
5336 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5337 //Need to issue stop_bss
5338 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005339 case eCsrJoinFailure:
5340 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07005341 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07005342 default:
5343 {
5344 smsLog(pMac, LOGW, FL("receives no association indication\n"));
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07005345 smsLog(pMac, LOG1, FL("Assoc ref count %d\n"),
5346 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07005347 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
5348 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
5349 {
5350 //do not free for the other profiles as we need to send down stop BSS later
5351 csrFreeConnectBssDesc(pMac, sessionId);
5352 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5353 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5354 csrSetDefaultDot11Mode( pMac );
5355 }
5356
5357 switch( pCommand->u.roamCmd.roamReason )
5358 {
5359 // If this transition is because of an 802.11 OID, then we transition
5360 // back to INIT state so we sit waiting for more OIDs to be issued and
5361 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07005362 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005363 case eCsrSmeIssuedAssocToSimilarAP:
5364 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08005365 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07005366 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5367 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5368 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5369 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5370 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005371 /* Defeaturize this later if needed */
5372#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5373 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
5374 if (csrRoamIsHandoffInProgress(pMac))
5375 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005376 /* Should indicate neighbor roam algorithm about the connect failure here */
5377 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
5378 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005379#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005380 if(pSession->bRefAssocStartCnt > 0)
5381 {
5382 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07005383 if(eCsrJoinFailureDueToConcurrency == Result)
5384 {
5385 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5386 eCSR_ROAM_ASSOCIATION_COMPLETION,
5387 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
5388 }
5389 else
5390 {
5391 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005392 eCSR_ROAM_ASSOCIATION_COMPLETION,
5393 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07005394 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005395 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005396 else
5397 {
5398 /* bRefAssocStartCnt is not incremented when
5399 * eRoamState == eCsrStopRoamingDueToConcurrency
5400 * in csrRoamJoinNextBss API. so handle this in
5401 * else case by sending assoc failure
5402 */
5403 csrRoamCallCallback(pMac, sessionId, NULL,
5404 pCommand->u.scanCmd.roamId,
5405 eCSR_ROAM_ASSOCIATION_FAILURE,
5406 eCSR_ROAM_RESULT_FAILURE);
5407 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005408 smsLog(pMac, LOG1, FL(" roam(reason %d) failed\n"), pCommand->u.roamCmd.roamReason);
5409#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5410 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5411#endif
5412 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5413 csrScanStartIdleScan(pMac);
5414#ifdef FEATURE_WLAN_BTAMP_UT_RF
5415 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
5416 //BT activity and not able to recevie WLAN traffic. Retry the join
5417 if( CSR_IS_WDS_STA(pProfile) )
5418 {
5419 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
5420 }
5421#endif
5422 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005423 case eCsrHddIssuedReassocToSameAP:
5424 case eCsrSmeIssuedReassocToSameAP:
5425 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5426
5427 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5428#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5429 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5430#endif
5431 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5432 csrScanStartIdleScan(pMac);
5433 break;
5434 case eCsrForcedDisassoc:
5435 case eCsrForcedDeauth:
5436 case eCsrSmeIssuedIbssJoinFailure:
5437 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5438
5439 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
5440 {
5441 // Notify HDD that IBSS join failed
5442 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
5443 }
5444 else
5445 {
5446 csrRoamCallCallback(pMac, sessionId, NULL,
5447 pCommand->u.roamCmd.roamId,
5448 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5449 }
5450#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5451 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5452#endif
5453 csrRoamLinkDown(pMac, sessionId);
5454 csrScanStartIdleScan(pMac);
5455 break;
5456 case eCsrForcedIbssLeave:
5457 csrRoamCallCallback(pMac, sessionId, NULL,
5458 pCommand->u.roamCmd.roamId,
5459 eCSR_ROAM_IBSS_LEAVE,
5460 eCSR_ROAM_RESULT_IBSS_STOP);
5461 break;
5462 case eCsrForcedDisassocMICFailure:
5463 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5464
5465 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
5466#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5467 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
5468#endif
5469 csrScanStartIdleScan(pMac);
5470 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005471 case eCsrStopBss:
5472 csrRoamCallCallback(pMac, sessionId, NULL,
5473 pCommand->u.roamCmd.roamId,
5474 eCSR_ROAM_INFRA_IND,
5475 eCSR_ROAM_RESULT_INFRA_STOPPED);
5476 break;
5477 case eCsrForcedDisassocSta:
5478 case eCsrForcedDeauthSta:
5479 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
5480 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
5481 {
5482 pSession = CSR_GET_SESSION(pMac, sessionId);
5483 if (!pSession)
5484 break;
5485
5486 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
5487 {
5488 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5489 palCopyMemory(pMac->hHdd, roamInfo.peerMac,
5490 pCommand->u.roamCmd.peerMac, sizeof(tSirMacAddr));
5491 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
5492 roamInfo.statusCode = eSIR_SME_SUCCESS;
5493 status = csrRoamCallCallback(pMac, sessionId,
5494 &roamInfo, pCommand->u.roamCmd.roamId,
5495 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
5496 }
5497 }
5498 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005499 case eCsrLostLink1:
5500 // if lost link roam1 failed, then issue lost link Scan2 ...
5501 csrScanRequestLostLink2(pMac, sessionId);
5502 break;
5503 case eCsrLostLink2:
5504 // if lost link roam2 failed, then issue lost link scan3 ...
5505 csrScanRequestLostLink3(pMac, sessionId);
5506 break;
5507 case eCsrLostLink3:
5508 default:
5509 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5510
5511 //We are done with one round of lostlink roaming here
5512 csrScanHandleFailedLostlink3(pMac, sessionId);
5513 break;
5514 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005515 break;
5516 }
5517 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005518 return ( fReleaseCommand );
5519}
5520
Jeff Johnson295189b2012-06-20 16:38:30 -07005521eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
5522{
5523 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005524 return (status);
5525}
5526
Jeff Johnson295189b2012-06-20 16:38:30 -07005527eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
5528{
5529 eHalStatus status = eHAL_STATUS_SUCCESS;
5530 tANI_U32 size = 0;
5531
5532 do
5533 {
5534 palZeroMemory(pMac->hHdd, pDstProfile, sizeof(tCsrRoamProfile));
5535 if(pSrcProfile->BSSIDs.numOfBSSIDs)
5536 {
5537 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
5538 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->BSSIDs.bssid, size);
5539 if(!HAL_STATUS_SUCCESS(status))
5540 {
5541 break;
5542 }
5543 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
5544 palCopyMemory(pMac->hHdd, pDstProfile->BSSIDs.bssid, pSrcProfile->BSSIDs.bssid, size);
5545 }
5546 if(pSrcProfile->SSIDs.numOfSSIDs)
5547 {
5548 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
5549 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->SSIDs.SSIDList, size);
5550 if(!HAL_STATUS_SUCCESS(status))
5551 {
5552 break;
5553 }
5554 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
5555 palCopyMemory(pMac->hHdd, pDstProfile->SSIDs.SSIDList, pSrcProfile->SSIDs.SSIDList, size);
5556 }
5557 if(pSrcProfile->nWPAReqIELength)
5558 {
5559 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pWPAReqIE, pSrcProfile->nWPAReqIELength);
5560 if(!HAL_STATUS_SUCCESS(status))
5561 {
5562 break;
5563 }
5564 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
5565 palCopyMemory(pMac->hHdd, pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE, pSrcProfile->nWPAReqIELength);
5566 }
5567 if(pSrcProfile->nRSNReqIELength)
5568 {
5569 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pRSNReqIE, pSrcProfile->nRSNReqIELength);
5570 if(!HAL_STATUS_SUCCESS(status))
5571 {
5572 break;
5573 }
5574 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
5575 palCopyMemory(pMac->hHdd, pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE, pSrcProfile->nRSNReqIELength);
5576 }
5577#ifdef FEATURE_WLAN_WAPI
5578 if(pSrcProfile->nWAPIReqIELength)
5579 {
5580 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pWAPIReqIE, pSrcProfile->nWAPIReqIELength);
5581 if(!HAL_STATUS_SUCCESS(status))
5582 {
5583 break;
5584 }
5585 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
5586 palCopyMemory(pMac->hHdd, pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE, pSrcProfile->nWAPIReqIELength);
5587 }
5588#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07005589 if(pSrcProfile->nAddIEScanLength)
5590 {
5591 status = palAllocateMemory(pMac->hHdd,
5592 (void **)&pDstProfile->pAddIEScan, pSrcProfile->nAddIEScanLength);
5593 if(!HAL_STATUS_SUCCESS(status))
5594 {
5595 break;
5596 }
5597 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
5598 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEScan, pSrcProfile->pAddIEScan,
5599 pSrcProfile->nAddIEScanLength);
5600 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005601 if(pSrcProfile->nAddIEAssocLength)
5602 {
5603 status = palAllocateMemory(pMac->hHdd,
5604 (void **)&pDstProfile->pAddIEAssoc, pSrcProfile->nAddIEAssocLength);
5605 if(!HAL_STATUS_SUCCESS(status))
5606 {
5607 break;
5608 }
5609 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
5610 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
5611 pSrcProfile->nAddIEAssocLength);
5612 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005613 if(pSrcProfile->ChannelInfo.ChannelList)
5614 {
5615 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.numOfChannels);
5616 if(!HAL_STATUS_SUCCESS(status))
5617 {
5618 break;
5619 }
5620 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
5621 palCopyMemory(pMac->hHdd, pDstProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.numOfChannels);
5622 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005623 pDstProfile->AuthType = pSrcProfile->AuthType;
5624 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
5625 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
5626 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
5627 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
5628 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
5629 pDstProfile->BSSType = pSrcProfile->BSSType;
5630 pDstProfile->phyMode = pSrcProfile->phyMode;
5631 pDstProfile->csrPersona = pSrcProfile->csrPersona;
5632
5633#ifdef FEATURE_WLAN_WAPI
5634 if(csrIsProfileWapi(pSrcProfile))
5635 {
5636 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
5637 {
5638 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
5639 }
5640 }
5641#endif /* FEATURE_WLAN_WAPI */
5642 pDstProfile->CBMode = pSrcProfile->CBMode;
5643 /*Save the WPS info*/
5644 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
5645 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005646 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07005647 pDstProfile->privacy = pSrcProfile->privacy;
5648 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
5649 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
5650 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
5651 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
5652 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
5653 pDstProfile->protEnabled = pSrcProfile->protEnabled;
5654 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
5655 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
5656 pDstProfile->wps_state = pSrcProfile->wps_state;
5657 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Jeff Johnson295189b2012-06-20 16:38:30 -07005658 palCopyMemory(pMac->hHdd, &pDstProfile->Keys, &pSrcProfile->Keys, sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07005659#ifdef WLAN_FEATURE_VOWIFI_11R
5660 if (pSrcProfile->MDID.mdiePresent)
5661 {
5662 pDstProfile->MDID.mdiePresent = 1;
5663 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
5664 }
5665#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005666 }while(0);
5667
5668 if(!HAL_STATUS_SUCCESS(status))
5669 {
5670 csrReleaseProfile(pMac, pDstProfile);
5671 pDstProfile = NULL;
5672 }
5673
5674 return (status);
5675}
Jeff Johnson295189b2012-06-20 16:38:30 -07005676eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
5677{
5678 eHalStatus status = eHAL_STATUS_SUCCESS;
5679 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
5680 do
5681 {
5682 palZeroMemory(pMac->hHdd, pDstProfile, sizeof(tCsrRoamProfile));
5683 if(pSrcProfile->bssid)
5684 {
5685 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->BSSIDs.bssid, sizeof(tCsrBssid));
5686 if(!HAL_STATUS_SUCCESS(status))
5687 {
5688 break;
5689 }
5690 pDstProfile->BSSIDs.numOfBSSIDs = 1;
5691 palCopyMemory(pMac->hHdd, pDstProfile->BSSIDs.bssid, pSrcProfile->bssid, sizeof(tCsrBssid));
5692 }
5693 if(pSrcProfile->SSID.ssId)
5694 {
5695 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->SSIDs.SSIDList, sizeof(tCsrSSIDInfo));
5696 if(!HAL_STATUS_SUCCESS(status))
5697 {
5698 break;
5699 }
5700 pDstProfile->SSIDs.numOfSSIDs = 1;
5701 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
5702 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
5703 palCopyMemory(pMac->hHdd, &pDstProfile->SSIDs.SSIDList[0].SSID, &pSrcProfile->SSID, sizeof(tSirMacSSid));
5704 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07005705 if(pSrcProfile->nAddIEAssocLength)
5706 {
5707 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pAddIEAssoc, pSrcProfile->nAddIEAssocLength);
5708 if(!HAL_STATUS_SUCCESS(status))
5709 {
5710 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs \n") );
5711 break;
5712 }
5713 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
5714 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
5715 pSrcProfile->nAddIEAssocLength);
5716 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005717 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->ChannelInfo.ChannelList, 1);
5718 if(!HAL_STATUS_SUCCESS(status))
5719 {
5720 break;
5721 }
5722 pDstProfile->ChannelInfo.numOfChannels = 1;
5723 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07005724 pDstProfile->AuthType.numEntries = 1;
5725 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
5726 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
5727 pDstProfile->EncryptionType.numEntries = 1;
5728 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
5729 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
5730 pDstProfile->mcEncryptionType.numEntries = 1;
5731 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
5732 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
5733 pDstProfile->BSSType = pSrcProfile->BSSType;
5734 pDstProfile->CBMode = pSrcProfile->CBMode;
5735 palCopyMemory(pMac->hHdd, &pDstProfile->Keys, &pSrcProfile->Keys, sizeof(pDstProfile->Keys));
5736#ifdef WLAN_FEATURE_VOWIFI_11R
5737 if (pSrcProfile->MDID.mdiePresent)
5738 {
5739 pDstProfile->MDID.mdiePresent = 1;
5740 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
5741 }
5742#endif
5743
5744 }while(0);
5745
5746 if(!HAL_STATUS_SUCCESS(status))
5747 {
5748 csrReleaseProfile(pMac, pDstProfile);
5749 pDstProfile = NULL;
5750 }
5751
5752 return (status);
5753}
5754
Jeff Johnson295189b2012-06-20 16:38:30 -07005755eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5756 tScanResultHandle hBSSList,
5757 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
5758 tANI_BOOLEAN fClearScan)
5759{
5760 eHalStatus status = eHAL_STATUS_SUCCESS;
5761 tSmeCmd *pCommand;
5762
5763 pCommand = csrGetCommandBuffer(pMac);
5764 if(NULL == pCommand)
5765 {
5766 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
5767 status = eHAL_STATUS_RESOURCES;
5768 }
5769 else
5770 {
5771 if( fClearScan )
5772 {
5773 csrScanCancelIdleScan(pMac);
5774 csrScanAbortMacScanNotForConnect(pMac);
5775 }
5776 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
5777 if(NULL == pProfile)
5778 {
5779 //We can roam now
5780 //Since pProfile is NULL, we need to build our own profile, set everything to default
5781 //We can only support open and no encryption
5782 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
5783 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5784 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
5785 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5786 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
5787 }
5788 else
5789 {
5790 //make a copy of the profile
5791 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
5792 if(HAL_STATUS_SUCCESS(status))
5793 {
5794 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
5795 }
5796 }
5797 pCommand->command = eSmeCommandRoam;
5798 pCommand->sessionId = (tANI_U8)sessionId;
5799 pCommand->u.roamCmd.hBSSList = hBSSList;
5800 pCommand->u.roamCmd.roamId = roamId;
5801 pCommand->u.roamCmd.roamReason = reason;
5802 //We need to free the BssList when the command is done
5803 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
5804 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005805 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
5806 FL("CSR PERSONA=%d"),
5807 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07005808 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
5809 if( !HAL_STATUS_SUCCESS( status ) )
5810 {
5811 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
5812 csrReleaseCommandRoam( pMac, pCommand );
5813 }
5814 }
5815
5816 return (status);
5817}
Jeff Johnson295189b2012-06-20 16:38:30 -07005818eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5819 tCsrRoamModifyProfileFields *pMmodProfileFields,
5820 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
5821{
5822 eHalStatus status = eHAL_STATUS_SUCCESS;
5823 tSmeCmd *pCommand;
5824
5825 pCommand = csrGetCommandBuffer(pMac);
5826 if(NULL == pCommand)
5827 {
5828 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
5829 status = eHAL_STATUS_RESOURCES;
5830 }
5831 else
5832 {
5833 csrScanCancelIdleScan(pMac);
5834 csrScanAbortMacScanNotForConnect(pMac);
5835 if(pProfile)
5836 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005837 //This is likely trying to reassoc to different profile
5838 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
5839 //make a copy of the profile
5840 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
5841 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005842 }
5843 else
5844 {
5845 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
5846 //how to update WPA/WPA2 info in roamProfile??
5847 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005848 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005849 if(HAL_STATUS_SUCCESS(status))
5850 {
5851 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
5852 }
5853 pCommand->command = eSmeCommandRoam;
5854 pCommand->sessionId = (tANI_U8)sessionId;
5855 pCommand->u.roamCmd.roamId = roamId;
5856 pCommand->u.roamCmd.roamReason = reason;
5857 //We need to free the BssList when the command is done
5858 //For reassoc there is no BSS list, so the boolean set to false
5859 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
5860 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
5861 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005862 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
5863 if( !HAL_STATUS_SUCCESS( status ) )
5864 {
5865 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
5866 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5867 csrReleaseCommandRoam( pMac, pCommand );
5868 }
5869 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005870 return (status);
5871}
5872
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005873eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
5874 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
5875// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
5876{
5877 eHalStatus status = eHAL_STATUS_SUCCESS;
5878 tSmeCmd *pCommand;
5879
5880 pCommand = csrGetCommandBuffer(pMac);
5881 if(NULL == pCommand)
5882 {
5883 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
5884 status = eHAL_STATUS_RESOURCES;
5885 }
5886 else
5887 {
5888 if(pBssDescription)
5889 {
5890 //copy over the parameters we need later
5891 pCommand->command = eSmeCommandRoam;
5892 pCommand->sessionId = (tANI_U8)sessionId;
5893 pCommand->u.roamCmd.roamReason = reason;
5894 //this is the important parameter
5895 //in this case we are using this field for the "next" BSS
5896 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
5897 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
5898 if( !HAL_STATUS_SUCCESS( status ) )
5899 {
5900 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d\n"), status );
5901 csrReleaseCommandPreauth( pMac, pCommand );
5902 }
5903 }
5904 else
5905 {
5906 //Return failure
5907 status = eHAL_STATUS_RESOURCES;
5908 }
5909 }
5910 return (status);
5911}
5912
5913eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
5914{
5915 tListElem *pEntry;
5916 tSmeCmd *pCommand;
5917 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
5918 if ( pEntry )
5919 {
5920 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
5921 if ( (eSmeCommandRoam == pCommand->command) &&
5922 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
5923 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08005924 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005925 pCommand->command, pCommand->u.roamCmd.roamReason);
5926 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
5927 csrReleaseCommandPreauth( pMac, pCommand );
5928 }
5929 } else {
5930 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d \n"),
5931 pCommand->command, pCommand->u.roamCmd.roamReason);
5932 }
5933 }
5934 else {
5935 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP\n"));
5936 }
5937 smeProcessPendingQueue( pMac );
5938 return eHAL_STATUS_SUCCESS;
5939}
5940
Jeff Johnson295189b2012-06-20 16:38:30 -07005941eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5942 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
5943{
5944 eHalStatus status = eHAL_STATUS_FAILURE;
5945 tScanResultHandle hBSSList;
5946 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005947 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
5948 if(HAL_STATUS_SUCCESS(status))
5949 {
5950 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
5951 if(pRoamId)
5952 {
5953 *pRoamId = roamId;
5954 }
5955 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
5956 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
5957 if(!HAL_STATUS_SUCCESS(status))
5958 {
5959 smsLog(pMac, LOGE, FL("failed to start a join process\n"));
5960 csrScanResultPurge(pMac, hBSSList);
5961 }
5962 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005963 return (status);
5964}
5965
Jeff Johnson295189b2012-06-20 16:38:30 -07005966eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5967 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
5968{
5969 eHalStatus status = eHAL_STATUS_SUCCESS;
5970 tScanResultHandle hBSSList;
5971 tCsrScanResultFilter *pScanFilter;
5972 tANI_U32 roamId = 0;
5973 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
5974 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005975 if (NULL == pProfile)
5976 {
5977 smsLog(pMac, LOGP, FL("No profile specified"));
5978 return eHAL_STATUS_FAILURE;
5979 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005980 smsLog(pMac, LOG1, FL("called BSSType = %d authtype = %d encryType = %d\n"),
5981 pProfile->BSSType, pProfile->AuthType.authType[0], pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005982 if( CSR_IS_WDS( pProfile ) &&
5983 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
5984 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005985 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d\n"),
5986 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07005987 return status;
5988 }
5989 csrRoamCancelRoaming(pMac, sessionId);
5990 csrScanRemoveFreshScanCommand(pMac, sessionId);
5991 csrScanCancelIdleScan(pMac);
5992 //Only abort the scan if it is not used for other roam/connect purpose
5993 csrScanAbortMacScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07005994 if (!vos_concurrent_sessions_running() && (VOS_STA_SAP_MODE == pProfile->csrPersona))//In case of AP mode we do not want idle mode scan
5995 {
5996 csrScanDisable(pMac);
5997 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005998 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
5999 //Check whether ssid changes
6000 if(csrIsConnStateConnected(pMac, sessionId))
6001 {
6002 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6003 {
6004 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6005 }
6006 }
6007#ifdef FEATURE_WLAN_BTAMP_UT_RF
6008 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
6009#endif
6010 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
6011 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006012 smsLog(pMac, LOG1, FL("is called with BSSList\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006013 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
6014 if(pRoamId)
6015 {
6016 roamId = *pRoamId;
6017 }
6018 if(!HAL_STATUS_SUCCESS(status))
6019 {
6020 fCallCallback = eANI_BOOLEAN_TRUE;
6021 }
6022 }
6023 else
6024 {
6025 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
6026 if(HAL_STATUS_SUCCESS(status))
6027 {
6028 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
6029 //Try to connect to any BSS
6030 if(NULL == pProfile)
6031 {
6032 //No encryption
6033 pScanFilter->EncryptionType.numEntries = 1;
6034 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6035 }//we don't have a profile
6036 else
6037 {
6038 //Here is the profile we need to connect to
6039 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6040 }//We have a profile
6041 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6042 if(pRoamId)
6043 {
6044 *pRoamId = roamId;
6045 }
6046
6047 if(HAL_STATUS_SUCCESS(status))
6048 {
6049 /*Save the WPS info*/
6050 if(NULL != pProfile)
6051 {
6052 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
6053 }
6054 else
6055 {
6056 pScanFilter->bWPSAssociation = 0;
6057 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006058 do
6059 {
6060 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006061 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006062 )
6063 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006064 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07006065 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6066 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6067 if(!HAL_STATUS_SUCCESS(status))
6068 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006069 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X\n"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006070 fCallCallback = eANI_BOOLEAN_TRUE;
6071 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006072 else
6073 {
6074 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
6075 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006076 break;
6077 }
6078 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Mohit Khanna23863762012-09-11 17:40:09 -07006079 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d\n", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006080 if(HAL_STATUS_SUCCESS(status))
6081 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006082 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6083 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6084 if(!HAL_STATUS_SUCCESS(status))
6085 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006086 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X\n"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006087 csrScanResultPurge(pMac, hBSSList);
6088 fCallCallback = eANI_BOOLEAN_TRUE;
6089 }
6090 }//Have scan result
6091 else if(NULL != pProfile)
6092 {
6093 //Check whether it is for start ibss
6094 if(CSR_IS_START_IBSS(pProfile))
6095 {
6096 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6097 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6098 if(!HAL_STATUS_SUCCESS(status))
6099 {
6100 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X\n", status);
6101 fCallCallback = eANI_BOOLEAN_TRUE;
6102 }
6103 }
6104 else
6105 {
6106 //scan for this SSID
6107 status = csrScanForSSID(pMac, sessionId, pProfile, roamId);
6108 if(!HAL_STATUS_SUCCESS(status))
6109 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006110 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X\n"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006111 fCallCallback = eANI_BOOLEAN_TRUE;
6112 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006113 else
6114 {
6115 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
6116 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006117 }
6118 }
6119 else
6120 {
6121 fCallCallback = eANI_BOOLEAN_TRUE;
6122 }
6123 } while (0);
6124 if(NULL != pProfile)
6125 {
6126 //we need to free memory for filter if profile exists
6127 csrFreeScanFilter(pMac, pScanFilter);
6128 }
6129 }//Got the scan filter from profile
6130
6131 palFreeMemory(pMac->hHdd, pScanFilter);
6132 }//allocated memory for pScanFilter
6133 }//No Bsslist coming in
6134 //tell the caller if we fail to trigger a join request
6135 if( fCallCallback )
6136 {
6137 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6138 }
6139
6140 return (status);
6141}
Jeff Johnson295189b2012-06-20 16:38:30 -07006142eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6143 tCsrRoamModifyProfileFields modProfileFields,
6144 tANI_U32 *pRoamId)
6145{
6146 eHalStatus status = eHAL_STATUS_SUCCESS;
6147 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
6148 tANI_U32 roamId = 0;
6149 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006150 if (NULL == pProfile)
6151 {
6152 smsLog(pMac, LOGP, FL("No profile specified"));
6153 return eHAL_STATUS_FAILURE;
6154 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006155 smsLog(pMac, LOG1, FL("called BSSType = %d authtype = %d encryType = %d\n"), pProfile->BSSType, pProfile->AuthType.authType[0], pProfile->EncryptionType.encryptionType[0]);
6156 csrRoamCancelRoaming(pMac, sessionId);
6157 csrScanRemoveFreshScanCommand(pMac, sessionId);
6158 csrScanCancelIdleScan(pMac);
6159 csrScanAbortMacScanNotForConnect(pMac);
6160 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07006161 if(csrIsConnStateConnected(pMac, sessionId))
6162 {
6163 if(pProfile)
6164 {
6165 if(pProfile->SSIDs.numOfSSIDs &&
6166 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6167 {
6168 fCallCallback = eANI_BOOLEAN_FALSE;
6169 }
6170 else
6171 {
6172 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile\n"));
6173 }
6174 }
6175 else if(!palEqualMemory(pMac->hHdd, &modProfileFields,
6176 &pSession->connectedProfile.modifyProfileFields,
6177 sizeof(tCsrRoamModifyProfileFields)))
6178 {
6179 fCallCallback = eANI_BOOLEAN_FALSE;
6180 }
6181 else
6182 {
6183 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
6184 "in tCsrRoamModifyProfileFields got modified\n"));
6185 }
6186 }
6187 else
6188 {
6189 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc\n"));
6190 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006191 if(!fCallCallback)
6192 {
6193 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6194 if(pRoamId)
6195 {
6196 *pRoamId = roamId;
6197 }
6198
Jeff Johnson295189b2012-06-20 16:38:30 -07006199 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6200 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006201 }
6202 else
6203 {
6204 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6205 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6206 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006207 return status;
6208}
Jeff Johnson295189b2012-06-20 16:38:30 -07006209eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6210{
6211 eHalStatus status = eHAL_STATUS_FAILURE;
6212 tScanResultHandle hBSSList = NULL;
6213 tCsrScanResultFilter *pScanFilter = NULL;
6214 tANI_U32 roamId;
6215 tCsrRoamProfile *pProfile = NULL;
6216 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006217
6218 if(!pSession)
6219 {
6220 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6221 return eHAL_STATUS_FAILURE;
6222 }
6223
Jeff Johnson295189b2012-06-20 16:38:30 -07006224 do
6225 {
6226 if(pSession->pCurRoamProfile)
6227 {
6228 csrScanCancelIdleScan(pMac);
6229 csrScanAbortMacScanNotForConnect(pMac);
6230 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
6231 status = palAllocateMemory(pMac->hHdd, (void **)&pProfile, sizeof(tCsrRoamProfile));
6232 if(!HAL_STATUS_SUCCESS(status))
6233 break;
6234 palZeroMemory(pMac->hHdd, pProfile, sizeof(tCsrRoamProfile));
6235 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
6236 if(!HAL_STATUS_SUCCESS(status))
6237 break;
6238 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
6239 if(!HAL_STATUS_SUCCESS(status))
6240 {
6241 break;
6242 }
6243 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
6244 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6245 if(!HAL_STATUS_SUCCESS(status))
6246 {
6247 break;
6248 }
6249 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6250 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6251 if(HAL_STATUS_SUCCESS(status))
6252 {
6253 //we want to put the last connected BSS to the very beginning, if possible
6254 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
6255 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6256 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6257 if(!HAL_STATUS_SUCCESS(status))
6258 {
6259 csrScanResultPurge(pMac, hBSSList);
6260 break;
6261 }
6262 }
6263 else
6264 {
6265 //Do a scan on this profile
6266 //scan for this SSID only in case the AP suppresses SSID
6267 status = csrScanForSSID(pMac, sessionId, pProfile, roamId);
6268 if(!HAL_STATUS_SUCCESS(status))
6269 {
6270 break;
6271 }
6272 }
6273 }//We have a profile
6274 else
6275 {
6276 smsLog(pMac, LOGW, FL("cannot find a roaming profile\n"));
6277 break;
6278 }
6279 }while(0);
6280 if(pScanFilter)
6281 {
6282 csrFreeScanFilter(pMac, pScanFilter);
6283 palFreeMemory(pMac->hHdd, pScanFilter);
6284 }
6285 if(NULL != pProfile)
6286 {
6287 csrReleaseProfile(pMac, pProfile);
6288 palFreeMemory(pMac->hHdd, pProfile);
6289 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006290 return (status);
6291}
Jeff Johnson295189b2012-06-20 16:38:30 -07006292eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
6293{
6294 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006295 if(csrIsConnStateConnected(pMac, sessionId))
6296 {
6297 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6298 if(HAL_STATUS_SUCCESS(status))
6299 {
6300 status = csrRoamJoinLastProfile(pMac, sessionId);
6301 }
6302 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006303 return (status);
6304}
6305
Jeff Johnson295189b2012-06-20 16:38:30 -07006306eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6307{
6308 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006309 smsLog(pMac, LOGW, FL("is called\n"));
6310 csrRoamCancelRoaming(pMac, sessionId);
6311 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6312 if(csrIsConnStateDisconnected(pMac, sessionId))
6313 {
6314 status = csrRoamJoinLastProfile(pMac, sessionId);
6315 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006316 return (status);
6317}
6318
Jeff Johnson295189b2012-06-20 16:38:30 -07006319eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
6320{
6321 eHalStatus status = eHAL_STATUS_SUCCESS;
6322 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
6323 eCsrRoamSubState NewSubstate;
6324 tANI_U32 sessionId = pCommand->sessionId;
6325
6326 // change state to 'Roaming'...
6327 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
6328
6329 if ( csrIsConnStateIbss( pMac, sessionId ) )
6330 {
6331 // If we are in an IBSS, then stop the IBSS...
6332 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6333 fComplete = (!HAL_STATUS_SUCCESS(status));
6334 }
6335 else if ( csrIsConnStateInfra( pMac, sessionId ) )
6336 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07006337 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 -07006338 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
6339 //Restore AC weight in case we change it
6340 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
6341 // in Infrasturcture, we need to disassociate from the Infrastructure network...
6342 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
6343 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
6344 {
6345 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
6346 }
6347 if( fDisassoc )
6348 {
6349 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
6350 }
6351 else
6352 {
6353 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
6354 }
6355 fComplete = (!HAL_STATUS_SUCCESS(status));
6356 }
6357 else if ( csrIsConnStateWds( pMac, sessionId ) )
6358 {
6359 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
6360 {
6361 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6362 fComplete = (!HAL_STATUS_SUCCESS(status));
6363 }
6364 //This has to be WDS station
6365 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
6366 {
6367
6368 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6369 if( fDisassoc )
6370 {
6371 status = csrRoamIssueDisassociate( pMac, sessionId,
6372 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
6373 fComplete = (!HAL_STATUS_SUCCESS(status));
6374 }
6375 }
6376 } else {
6377 // we got a dis-assoc request while not connected to any peer
6378 // just complete the command
6379 fComplete = eANI_BOOLEAN_TRUE;
6380 status = eHAL_STATUS_FAILURE;
6381 }
6382 if(fComplete)
6383 {
6384 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6385 }
6386
6387 if(HAL_STATUS_SUCCESS(status))
6388 {
6389 if ( csrIsConnStateInfra( pMac, sessionId ) )
6390 {
6391 //Set the state to disconnect here
6392 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
6393 }
6394 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006395 else
6396 {
6397 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
6398 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006399 return (status);
6400}
6401
Jeff Johnson295189b2012-06-20 16:38:30 -07006402/* This is been removed from latest code base */
6403/*
6404static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
6405{
6406 eHalStatus status;
6407 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07006408 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
6409 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006410 return ( status );
6411}
6412*/
6413
Jeff Johnson295189b2012-06-20 16:38:30 -07006414eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
6415{
6416 eHalStatus status = eHAL_STATUS_SUCCESS;
6417 tSmeCmd *pCommand;
6418 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006419 do
6420 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006421 smsLog( pMac, LOG1, FL(" reason = %d"), reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07006422 pCommand = csrGetCommandBuffer( pMac );
6423 if ( !pCommand )
6424 {
6425 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
6426 status = eHAL_STATUS_RESOURCES;
6427 break;
6428 }
6429 //Change the substate in case it is wait-for-key
6430 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
6431 {
6432 csrRoamStopWaitForKeyTimer( pMac );
6433 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6434 }
6435 pCommand->command = eSmeCommandRoam;
6436 pCommand->sessionId = (tANI_U8)sessionId;
6437 switch ( reason )
6438 {
6439 case eCSR_DISCONNECT_REASON_MIC_ERROR:
6440 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
6441 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006442 case eCSR_DISCONNECT_REASON_DEAUTH:
6443 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
6444 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006445 case eCSR_DISCONNECT_REASON_HANDOFF:
6446 fHighPriority = eANI_BOOLEAN_TRUE;
6447 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
6448 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006449 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
6450 case eCSR_DISCONNECT_REASON_DISASSOC:
6451 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
6452 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006453 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
6454 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
6455 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006456 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
6457 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
6458 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006459 default:
6460 break;
6461 }
6462 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6463 if( !HAL_STATUS_SUCCESS( status ) )
6464 {
6465 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
6466 csrReleaseCommandRoam( pMac, pCommand );
6467 }
6468 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006469 return( status );
6470}
6471
Jeff Johnson295189b2012-06-20 16:38:30 -07006472eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
6473{
6474 eHalStatus status = eHAL_STATUS_SUCCESS;
6475 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07006476 pCommand = csrGetCommandBuffer( pMac );
6477 if ( NULL != pCommand )
6478 {
6479 //Change the substate in case it is wait-for-key
6480 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
6481 {
6482 csrRoamStopWaitForKeyTimer( pMac );
6483 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6484 }
6485 pCommand->command = eSmeCommandRoam;
6486 pCommand->sessionId = (tANI_U8)sessionId;
6487 pCommand->u.roamCmd.roamReason = eCsrStopBss;
6488 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6489 if( !HAL_STATUS_SUCCESS( status ) )
6490 {
6491 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
6492 csrReleaseCommandRoam( pMac, pCommand );
6493 }
6494 }
6495 else
6496 {
6497 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
6498 status = eHAL_STATUS_RESOURCES;
6499 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006500 return ( status );
6501}
6502
Jeff Johnson295189b2012-06-20 16:38:30 -07006503eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
6504{
6505 eHalStatus status = eHAL_STATUS_SUCCESS;
6506 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006507
6508 if(!pSession)
6509 {
6510 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6511 return eHAL_STATUS_FAILURE;
6512 }
6513
Jeff Johnson295189b2012-06-20 16:38:30 -07006514#ifdef FEATURE_WLAN_BTAMP_UT_RF
6515 //Stop te retry
6516 pSession->maxRetryCount = 0;
6517 csrRoamStopJoinRetryTimer(pMac, sessionId);
6518#endif
6519 //Not to call cancel roaming here
6520 //Only issue disconnect when necessary
6521 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
6522 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
6523 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
6524
6525 {
6526 smsLog(pMac, LOG2, FL("called\n"));
6527 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
6528 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006529 return (status);
6530}
6531
Jeff Johnson295189b2012-06-20 16:38:30 -07006532eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
6533{
6534 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006535
6536 if(!pSession)
6537 {
6538 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6539 return eHAL_STATUS_FAILURE;
6540 }
6541
Jeff Johnson295189b2012-06-20 16:38:30 -07006542 csrRoamCancelRoaming(pMac, sessionId);
6543 pSession->ibss_join_pending = FALSE;
6544 csrRoamStopIbssJoinTimer(pMac, sessionId);
6545 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
6546
6547 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
6548}
6549
Jeff Johnson295189b2012-06-20 16:38:30 -07006550eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6551 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
6552{
6553 eHalStatus status = eHAL_STATUS_SUCCESS;
6554 tDot11fBeaconIEs *pIesTemp = pIes;
6555 tANI_U8 index;
6556 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
6557 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07006558
6559 if(!pSession)
6560 {
6561 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6562 return eHAL_STATUS_FAILURE;
6563 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006564
6565 palZeroMemory(pMac->hHdd, &pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile));
6566 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
6567 pConnectProfile->AuthInfo = pProfile->AuthType;
6568 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
6569 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
6570 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
6571 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
6572 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
6573 pConnectProfile->BSSType = pProfile->BSSType;
6574 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
6575 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07006576 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
6577
Jeff Johnson295189b2012-06-20 16:38:30 -07006578 palCopyMemory(pMac->hHdd, &pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006579 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
6580 if(pProfile->nAddIEAssocLength)
6581 {
6582 status = palAllocateMemory(pMac->hHdd,
6583 (void **)&pConnectProfile->pAddIEAssoc, pProfile->nAddIEAssocLength);
6584 if(!HAL_STATUS_SUCCESS(status))
6585 {
6586 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
6587 return eHAL_STATUS_FAILURE;
6588 }
6589 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
6590 palCopyMemory(pMac->hHdd, pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
6591 pProfile->nAddIEAssocLength);
6592 }
6593
Jeff Johnson295189b2012-06-20 16:38:30 -07006594 //Save bssid
6595 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
6596#ifdef WLAN_FEATURE_VOWIFI_11R
6597 if (pSirBssDesc->mdiePresent)
6598 {
6599 pConnectProfile->MDID.mdiePresent = 1;
6600 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
6601 }
6602#endif
6603#ifdef FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006604 if ((csrIsProfileCCX(pProfile) ||
6605 ((pIesTemp->CCXVersion.present)
6606 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
6607 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
6608 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
6609 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Saurabh Gupta775073c2013-02-14 13:31:36 +05306610 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006611 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07006612 {
6613 pConnectProfile->isCCXAssoc = 1;
6614 }
6615#endif
6616 //save ssid
6617 if( NULL == pIesTemp )
6618 {
6619 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
6620 }
6621 if(HAL_STATUS_SUCCESS(status))
6622 {
6623 if(pIesTemp->SSID.present)
6624 {
6625 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
6626 palCopyMemory(pMac->hHdd, pConnectProfile->SSID.ssId,
6627 pIesTemp->SSID.ssid, pIesTemp->SSID.num_ssid);
6628 }
6629
6630 //Save the bss desc
6631 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05306632
6633 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07006634 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05306635 //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 -07006636 pConnectProfile->qap = TRUE;
6637 }
6638 else
6639 {
6640 pConnectProfile->qap = FALSE;
6641 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006642 if ( NULL == pIes )
6643 {
6644 //Free memory if it allocated locally
6645 palFreeMemory(pMac->hHdd, pIesTemp);
6646 }
6647 }
6648 //Save Qos connection
6649 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
6650
6651 if(!HAL_STATUS_SUCCESS(status))
6652 {
6653 csrFreeConnectBssDesc(pMac, sessionId);
6654 }
6655 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
6656 {
6657 if((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
6658 palEqualMemory(pMac->hHdd, pProfile->SSIDs.SSIDList[index].SSID.ssId,
6659 pConnectProfile->SSID.ssId, pConnectProfile->SSID.length))
6660 {
6661 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
6662 break;
6663 }
6664 pConnectProfile->handoffPermitted = FALSE;
6665 }
6666
6667 return (status);
6668}
6669
Jeff Johnson295189b2012-06-20 16:38:30 -07006670static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
6671{
6672 tListElem *pEntry = NULL;
6673 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006674 //The head of the active list is the request we sent
6675 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
6676 if(pEntry)
6677 {
6678 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6679 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006680 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
6681 {
6682 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
6683 {
6684#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6685 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
6686#endif
6687 }
6688 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
6689 }
6690 else
6691 {
6692 tANI_U32 roamId = 0;
6693 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006694 if(!pSession)
6695 {
6696 smsLog(pMac, LOGE, FL(" session %d not found "), pSmeJoinRsp->sessionId);
6697 return;
6698 }
6699
Jeff Johnson295189b2012-06-20 16:38:30 -07006700
6701 //The head of the active list is the request we sent
6702 //Try to get back the same profile and roam again
6703 if(pCommand)
6704 {
6705 roamId = pCommand->u.roamCmd.roamId;
6706 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006707 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
6708 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
6709 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08lX [%d]\n", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
6710#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
6711 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
6712 if (csrRoamIsHandoffInProgress(pMac))
6713 {
6714 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6715 /* Should indicate neighbor roam algorithm about the connect failure here */
6716 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
6717 }
6718#endif
6719 if (pCommand)
6720 {
6721 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
6722 {
6723 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6724 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
6725 csrRoamReissueRoamCommand(pMac);
6726 }
6727 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
6728 {
6729 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6730 }
6731 else
6732 {
6733 csrRoam(pMac, pCommand);
6734 }
6735 }
6736 else
6737 {
6738 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6739 }
6740 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
6741}
6742
Jeff Johnson295189b2012-06-20 16:38:30 -07006743eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
6744 tDot11fBeaconIEs *pIes,
6745 tCsrRoamProfile *pProfile, tANI_U32 roamId )
6746{
6747 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006748 smsLog( pMac, LOG1, "Attempting to Join Bssid= %02x-%02x-%02x-%02x-%02x-%02x\n",
6749 pSirBssDesc->bssId[ 0 ],pSirBssDesc->bssId[ 1 ],pSirBssDesc->bssId[ 2 ],
6750 pSirBssDesc->bssId[ 3 ],pSirBssDesc->bssId[ 4 ],pSirBssDesc->bssId[ 5 ] );
6751
6752 // Set the roaming substate to 'join attempt'...
6753 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006754 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08006755 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006756 return (status);
6757}
6758
Jeff Johnson295189b2012-06-20 16:38:30 -07006759static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
6760 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
6761{
6762 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006763 // Set the roaming substate to 'join attempt'...
6764 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
6765
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08006766 smsLog(pMac, LOGE, FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006767
6768 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08006769 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07006770}
6771
Jeff Johnson295189b2012-06-20 16:38:30 -07006772void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
6773{
6774 tListElem *pEntry;
6775 tSmeCmd *pCommand;
6776 tCsrRoamInfo roamInfo;
6777 tANI_U32 sessionId;
6778 tCsrRoamSession *pSession;
6779
6780 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
6781 if(pEntry)
6782 {
6783 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6784 if ( eSmeCommandRoam == pCommand->command )
6785 {
6786 sessionId = pCommand->sessionId;
6787 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006788
6789 if(!pSession)
6790 {
6791 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6792 return;
6793 }
6794
Jeff Johnson295189b2012-06-20 16:38:30 -07006795 if( pCommand->u.roamCmd.fStopWds )
6796 {
6797 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
6798 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
6799 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6800 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07006801 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07006802 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
6803 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6804 eCSR_ROAM_WDS_IND,
6805 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07006806 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
6807 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
6808 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6809 eCSR_ROAM_INFRA_IND,
6810 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
6811 }
6812
Jeff Johnson295189b2012-06-20 16:38:30 -07006813
Jeff Johnson295189b2012-06-20 16:38:30 -07006814 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
6815 {
6816 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated\n");
6817 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6818 }
6819 }
6820 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
6821 {
6822 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated\n");
6823 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6824 }
6825 }
6826 else
6827 {
6828 smsLog(pMac, LOGW, " Command is not roaming after disassociated\n");
6829 }
6830 }
6831 else
6832 {
6833 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available\n");
6834 }
6835}
6836
Jeff Johnson295189b2012-06-20 16:38:30 -07006837tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
6838{
6839 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
6840 tListElem *pEntry;
6841 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006842 //alwasy lock active list before locking pending list
6843 csrLLLock( &pMac->sme.smeCmdActiveList );
6844 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
6845 if(pEntry)
6846 {
6847 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6848 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
6849 {
6850 fRet = eANI_BOOLEAN_TRUE;
6851 }
6852 }
6853 if(eANI_BOOLEAN_FALSE == fRet)
6854 {
6855 csrLLLock(&pMac->sme.smeCmdPendingList);
6856 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
6857 while(pEntry)
6858 {
6859 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6860 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
6861 {
6862 fRet = eANI_BOOLEAN_TRUE;
6863 break;
6864 }
6865 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
6866 }
6867 csrLLUnlock(&pMac->sme.smeCmdPendingList);
6868 }
6869 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07006870 return (fRet);
6871}
6872
Jeff Johnson295189b2012-06-20 16:38:30 -07006873tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
6874{
6875 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
6876 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07006877 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
6878 {
6879 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
6880 {
6881 break;
6882 }
6883 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006884 return ( fRet );
6885}
6886
Jeff Johnson295189b2012-06-20 16:38:30 -07006887tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
6888{
6889 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006890 //alwasy lock active list before locking pending list
6891 csrLLLock( &pMac->sme.smeCmdActiveList );
6892 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
6893 if(eANI_BOOLEAN_FALSE == fRet)
6894 {
6895 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
6896 }
6897 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07006898 return (fRet);
6899}
6900
Jeff Johnson295189b2012-06-20 16:38:30 -07006901tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
6902{
6903 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
6904 tListElem *pEntry;
6905 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07006906 //alwasy lock active list before locking pending list
6907 csrLLLock( &pMac->sme.smeCmdActiveList );
6908 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
6909 if( pEntry )
6910 {
6911 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
6912 if( ( eCsrRoamCommandScan == pCommand->command ) &&
6913 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
6914 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
6915 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
6916 {
6917 fRet = eANI_BOOLEAN_TRUE;
6918 }
6919 }
6920 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07006921 return (fRet);
6922}
Jeff Johnson295189b2012-06-20 16:38:30 -07006923eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
6924{
6925 eHalStatus status = eHAL_STATUS_SUCCESS;
6926 tSmeCmd *pCommand = NULL;
6927 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
6928 tANI_BOOLEAN fRemoveCmd = FALSE;
6929 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07006930 // Delete the old assoc command. All is setup for reassoc to be serialized
6931 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6932 if ( pEntry )
6933 {
6934 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6935 if ( !pCommand )
6936 {
6937 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
6938 return eHAL_STATUS_RESOURCES;
6939 }
6940 if ( eSmeCommandRoam == pCommand->command )
6941 {
6942 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
6943 {
6944 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
6945 }
6946 else
6947 {
6948 smsLog( pMac, LOGE, FL(" Unexpected active roam command present \n") );
6949 }
6950 if (fRemoveCmd == FALSE)
6951 {
6952 // Implies we did not get the serialized assoc command we
6953 // were expecting
6954 pCommand = NULL;
6955 }
6956 }
6957 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006958 if(NULL == pCommand)
6959 {
6960 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command\n") );
6961 return eHAL_STATUS_RESOURCES;
6962 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006963 do
6964 {
6965 //Change the substate in case it is wait-for-key
6966 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
6967 {
6968 csrRoamStopWaitForKeyTimer( pMac );
6969 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
6970 }
6971 pCommand->command = eSmeCommandRoam;
6972 pCommand->sessionId = (tANI_U8)sessionId;
6973 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07006974 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6975 if( !HAL_STATUS_SUCCESS( status ) )
6976 {
6977 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
6978 csrReleaseCommandRoam( pMac, pCommand );
6979 }
6980 } while( 0 );
6981
Jeff Johnson295189b2012-06-20 16:38:30 -07006982 return( status );
6983}
6984static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
6985{
6986 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
6987 tCsrScanResult *pScanResult = NULL;
6988 tSirBssDescription *pBssDesc = NULL;
6989 tSmeCmd *pCommand = NULL;
6990 tANI_U32 sessionId;
6991 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07006992 if(NULL == pEntry)
6993 {
6994 smsLog(pMac, LOGW, " CFG_CNF with active list empty\n");
6995 return;
6996 }
6997 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6998 sessionId = pCommand->sessionId;
6999 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007000
7001 if(!pSession)
7002 {
7003 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7004 return;
7005 }
7006
Jeff Johnson295189b2012-06-20 16:38:30 -07007007 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
7008 {
7009 //the roaming is cancelled. Simply complete the command
7010 smsLog(pMac, LOGW, FL(" Roam command cancelled\n"));
7011 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7012 }
7013 else
7014 {
7015 if ( CCM_IS_RESULT_SUCCESS(result) )
7016 {
7017 smsLog(pMac, LOG2, "Cfg sequence complete\n");
7018 // Successfully set the configuration parameters for the new Bss. Attempt to
7019 // join the roaming Bss.
7020 if(pCommand->u.roamCmd.pRoamBssEntry)
7021 {
7022 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
7023 pBssDesc = &pScanResult->Result.BssDescriptor;
7024 }
7025 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
7026 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07007027 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07007028 )
7029 {
7030 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
7031 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
7032 pBssDesc, pCommand->u.roamCmd.roamId )))
7033 {
7034 smsLog(pMac, LOGW, " CSR start BSS failed\n");
7035 //We need to complete the command
7036 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7037 }
7038 }
7039 else
7040 {
7041 if (!pCommand->u.roamCmd.pRoamBssEntry)
7042 {
7043 smsLog(pMac, LOGW, " pRoamBssEntry is NULL\n");
7044 //We need to complete the command
7045 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
7046 return;
7047 }
7048 // If we are roaming TO an Infrastructure BSS...
7049 VOS_ASSERT(pScanResult != NULL);
7050 if ( csrIsInfraBssDesc( pBssDesc ) )
7051 {
7052 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07007053 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
7054 {
7055 // ..and currently in an Infrastructure connection....
7056 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
7057 {
7058 // ...and the SSIDs are equal, then we Reassoc.
7059 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
7060 pIesLocal ) )
7061 // ..and currently in an infrastructure connection
7062 {
7063 // then issue a Reassoc.
7064 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
7065 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
7066 &pCommand->u.roamCmd.roamProfile );
7067 }
7068 else
7069 {
7070
7071 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
7072 // previously associated AP.
7073 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7074 pIesLocal,
7075 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
7076 {
7077 //try something else
7078 csrRoam( pMac, pCommand );
7079 }
7080 }
7081 }
7082 else
7083 {
7084 eHalStatus status = eHAL_STATUS_SUCCESS;
7085
7086 /* We need to come with other way to figure out that this is because of HO in BMP
7087 The below API will be only available for Android as it uses a different HO algorithm */
7088 /* Reassoc request will be used only for CCX and 11r handoff whereas other legacy roaming should
7089 * use join request */
7090#ifdef WLAN_FEATURE_VOWIFI_11R
7091 if (csrRoamIsHandoffInProgress(pMac) &&
7092 csrRoamIs11rAssoc(pMac))
7093 {
7094 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
7095 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
7096 }
7097 else
7098#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007099#ifdef FEATURE_WLAN_CCX
7100 if (csrRoamIsHandoffInProgress(pMac) &&
7101 csrRoamIsCCXAssoc(pMac))
7102 {
7103 // Now serialize the reassoc command.
7104 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7105 }
7106 else
7107#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007108#ifdef FEATURE_WLAN_LFR
7109 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05307110 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007111 {
7112 // Now serialize the reassoc command.
7113 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7114 }
7115 else
7116#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007117 // else we are not connected and attempting to Join. Issue the
7118 // Join request.
7119 {
7120 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7121 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
7122 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
7123 }
7124 if(!HAL_STATUS_SUCCESS(status))
7125 {
7126 //try something else
7127 csrRoam( pMac, pCommand );
7128 }
7129 }
7130 if( !pScanResult->Result.pvIes )
7131 {
7132 //Locally allocated
7133 palFreeMemory(pMac->hHdd, pIesLocal);
7134 }
7135 }
7136 }//if ( csrIsInfraBssDesc( pBssDesc ) )
7137 else
7138 {
7139 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description\n"));
7140 }
7141 }//else
7142 }//if ( WNI_CFG_SUCCESS == result )
7143 else
7144 {
7145 // In the event the configuration failed, for infra let the roam processor
7146 //attempt to join something else...
7147 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
7148 {
7149 csrRoam(pMac, pCommand);
7150 }
7151 else
7152 {
7153 //We need to complete the command
7154 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
7155 {
7156 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7157 }
7158 else
7159 {
7160 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7161 }
7162 }
7163 }
7164 }//we have active entry
7165}
7166
Jeff Johnson295189b2012-06-20 16:38:30 -07007167static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
7168{
7169 //No one is sending eWNI_SME_AUTH_REQ to PE.
7170 smsLog(pMac, LOGW, FL("is no-op\n"));
7171 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
7172 {
7173 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful\n" );
7174 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
7175 // join the new one...
7176 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07007177 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
7178 }
7179 else {
7180 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08lX [%d]\n", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
7181 /***profHandleLostLinkAfterReset(pAdapter);
7182 // In the event the authenticate fails, let the roam processor attempt to join something else...
7183 roamRoam( pAdapter );***/
7184 }
7185}
7186
Jeff Johnson295189b2012-06-20 16:38:30 -07007187static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
7188{
7189 eCsrRoamCompleteResult result;
7190 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7191 tCsrRoamInfo roamInfo;
7192 tANI_U32 roamId = 0;
7193
7194 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7195 {
7196 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful\n" );
7197 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07007198 /* Defeaturize this part later if needed */
7199#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7200 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
7201 * we need the response contents while processing the result in csrRoamProcessResults() */
7202 if (csrRoamIsHandoffInProgress(pMac))
7203 {
7204 /* Need to dig more on indicating events to SME QoS module */
7205 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7206 csrRoamComplete( pMac, result, pSmeJoinRsp);
7207 }
7208 else
7209#endif
7210 {
7211 csrRoamComplete( pMac, result, NULL );
7212 }
7213 }
7214 /* Should we handle this similar to handling the join failure? Is it ok
7215 * to call csrRoamComplete() with state as CsrJoinFailure */
7216 else
7217 {
7218 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08lX [%d]\n", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
7219 result = eCsrReassocFailure;
7220#ifdef WLAN_FEATURE_VOWIFI_11R
7221 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
7222 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode))
7223 {
7224 // Inform HDD to turn off FT flag in HDD
7225 if (pNeighborRoamInfo)
7226 {
7227 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7228 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
7229 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07007230 /*
7231 * Since the above callback sends a disconnect
7232 * to HDD, we should clean-up our state
7233 * machine as well to be in sync with the upper
7234 * layers. There is no need to send a disassoc
7235 * since: 1) we will never reassoc to the current
7236 * AP in LFR, and 2) there is no need to issue a
7237 * disassoc to the AP with which we were trying
7238 * to reassoc.
7239 */
7240 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7241 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007242 }
7243 }
7244#endif
7245 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
7246 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
7247 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
7248 //The disassoc rsp message will remove the command from active list
7249 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
7250 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
7251 {
7252 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7253 }
7254 }
7255}
7256
Jeff Johnson295189b2012-06-20 16:38:30 -07007257static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
7258{
Jeff Johnson295189b2012-06-20 16:38:30 -07007259#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7260 {
7261 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07007262 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
7263 if(pIbssLog)
7264 {
7265 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
7266 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
7267 {
7268 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
7269 }
7270 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
7271 }
7272 }
7273#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007274 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7275 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
7276 {
7277 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7278 }
7279 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
7280 {
7281 csrRoamReissueRoamCommand(pMac);
7282 }
7283}
7284
Jeff Johnson295189b2012-06-20 16:38:30 -07007285void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
7286{
7287 tSirResultCodes statusCode;
7288#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7289 tScanResultHandle hBSSList;
7290 tANI_BOOLEAN fCallCallback, fRemoveCmd;
7291 eHalStatus status;
7292 tCsrRoamInfo roamInfo;
7293 tCsrScanResultFilter *pScanFilter = NULL;
7294 tANI_U32 roamId = 0;
7295 tCsrRoamProfile *pCurRoamProfile = NULL;
7296 tListElem *pEntry = NULL;
7297 tSmeCmd *pCommand = NULL;
7298#endif
7299 tANI_U32 sessionId;
7300 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07007301
Jeff Johnson295189b2012-06-20 16:38:30 -07007302 tSirSmeDisassocRsp SmeDisassocRsp;
7303
7304 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
7305 sessionId = SmeDisassocRsp.sessionId;
7306 statusCode = SmeDisassocRsp.statusCode;
7307
7308 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d\n", sessionId);
7309
7310 if ( csrIsConnStateInfra( pMac, sessionId ) )
7311 {
7312 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7313 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007314 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007315
7316 if(!pSession)
7317 {
7318 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7319 return;
7320 }
7321
Jeff Johnson295189b2012-06-20 16:38:30 -07007322 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
7323 {
7324 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7325 }
7326 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
7327 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
7328 {
7329 if ( eSIR_SME_SUCCESS == statusCode )
7330 {
7331 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully\n" );
7332 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
7333 }
7334 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7335 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007336 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
7337 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007338 smsLog( pMac, LOGE, "CSR SmeDisassocReq due to HO on session %d\n", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007339#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007340 /*
7341 * First ensure if the roam profile is in the scan cache.
7342 * If not, post a reassoc failure and disconnect.
7343 */
7344 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
7345 if(HAL_STATUS_SUCCESS(status))
7346 {
7347 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
7348 status = csrRoamPrepareFilterFromProfile(pMac,
7349 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
7350 if(!HAL_STATUS_SUCCESS(status))
7351 {
7352 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
7353 __func__, status);
7354 goto POST_ROAM_FAILURE;
7355 }
7356 else
7357 {
7358 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7359 if (!HAL_STATUS_SUCCESS(status))
7360 {
7361 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
7362 __func__, status);
7363 goto POST_ROAM_FAILURE;
7364 }
7365 }
7366 }
7367 else
7368 {
7369 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
7370 __func__, status);
7371 goto POST_ROAM_FAILURE;
7372 }
7373
7374 /*
7375 * After ensuring that the roam profile is in the scan result list,
7376 * dequeue the command from the active list.
7377 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007378 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7379 if ( pEntry )
7380 {
7381 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007382 /* If the head of the queue is Active and it is a ROAM command, remove
7383 * and put this on the Free queue.
7384 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007385 if ( eSmeCommandRoam == pCommand->command )
7386 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007387
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007388 /*
7389 * we need to process the result first before removing it from active list
7390 * because state changes still happening insides roamQProcessRoamResults so
7391 * no other roam command should be issued.
7392 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007393 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7394 if(pCommand->u.roamCmd.fReleaseProfile)
7395 {
7396 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
7397 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
7398 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007399 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07007400 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07007401 else
7402 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007403 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d\n",
7404 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07007405 }
7406 }
7407 else
7408 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007409 smsLog( pMac, LOGE, "%s: roam command not active\n", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007410 }
7411 }
7412 else
7413 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007414 smsLog( pMac, LOGE, "%s: NO commands are active\n", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007415 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007416
7417 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07007418 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
7419
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007420 palCopyMemory(pMac->hHdd, roamInfo.bssid,
7421 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
7422 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07007423
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007424 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
7425 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007426
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007427 /* Copy the connected profile to apply the same for this connection as well */
7428 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
7429 (void **)&pCurRoamProfile, sizeof(tCsrRoamProfile))))
Jeff Johnson295189b2012-06-20 16:38:30 -07007430 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007431 palZeroMemory(pMac->hHdd, pCurRoamProfile, sizeof(tCsrRoamProfile));
7432 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
7433 //make sure to put it at the head of the cmd queue
7434 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
7435 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
7436 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
7437
Jeff Johnson295189b2012-06-20 16:38:30 -07007438 if(!HAL_STATUS_SUCCESS(status))
7439 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007440 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
7441 __func__, status);
7442 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007443 }
7444
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007445 /* Notify sub-modules like QoS etc. that handoff happening */
7446 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
7447 palFreeMemory(pMac->hHdd, pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07007448 csrFreeScanFilter(pMac, pScanFilter);
7449 palFreeMemory( pMac->hHdd, pScanFilter );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007450 return;
7451 }
7452
7453POST_ROAM_FAILURE:
7454 if (pScanFilter)
7455 {
7456 csrFreeScanFilter(pMac, pScanFilter);
7457 palFreeMemory( pMac->hHdd, pScanFilter );
7458 }
7459 if (pCurRoamProfile)
7460 palFreeMemory(pMac->hHdd, pCurRoamProfile);
7461
7462 /* Inform the upper layers that the reassoc failed */
7463 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7464 csrRoamCallCallback(pMac, sessionId,
7465 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
7466
7467 /*
7468 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
7469 * Upon success, we would re-enter this routine after receiving the disassoc
7470 * response and will fall into the reassoc fail sub-state. And, eventually
7471 * call csrRoamComplete which would remove the roam command from SME active
7472 * queue.
7473 */
7474 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
7475 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
7476 {
7477 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
7478 __func__, status);
7479 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07007480 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007481#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07007482
Jeff Johnson295189b2012-06-20 16:38:30 -07007483 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
7484 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
7485 {
7486 // Disassoc due to Reassoc failure falls into this codepath....
7487 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7488 }
7489 else
7490 {
7491 if ( eSIR_SME_SUCCESS == statusCode )
7492 {
7493 // Successfully disassociated from the 'old' Bss...
7494 //
7495 // We get Disassociate response in three conditions.
7496 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
7497 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
7498 // Infrastructure network.
7499 // - Third is where we are doing an Infra to Infra roam between networks with different
7500 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
7501
7502 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully\n" );
7503 }
7504 else
7505 {
7506 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08lX\n", statusCode );
7507 }
7508 //We are not done yet. Get the data and continue roaming
7509 csrRoamReissueRoamCommand(pMac);
7510 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007511}
7512
Jeff Johnson295189b2012-06-20 16:38:30 -07007513static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
7514{
7515 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007516 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
7517 smsLog(pMac, LOGW, FL("is no-op\n"));
7518 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
7519 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
7520 {
7521 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7522 }
7523 else
7524 {
7525 if ( eSIR_SME_SUCCESS == statusCode )
7526 {
7527 // Successfully deauth from the 'old' Bss...
7528 //
7529 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully\n" );
7530 }
7531 else
7532 {
7533 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08lX\n", statusCode );
7534 }
7535 //We are not done yet. Get the data and continue roaming
7536 csrRoamReissueRoamCommand(pMac);
7537 }
7538}
7539
Jeff Johnson295189b2012-06-20 16:38:30 -07007540static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
7541{
7542 eCsrRoamCompleteResult result;
7543
7544 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
7545 {
7546 smsLog( pMac, LOGW, "SmeStartBssReq Successful\n" );
7547 result = eCsrStartBssSuccess;
7548 }
7549 else
7550 {
7551 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08lX\n", pSmeStartBssRsp->statusCode );
7552 //Let csrRoamComplete decide what to do
7553 result = eCsrStartBssFailure;
7554 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007555 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007556}
7557
Jeff Johnson295189b2012-06-20 16:38:30 -07007558/*
7559 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
7560 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
7561 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
7562 For the messages where sender allocates memory for specific structures, then it can be
7563 cast accordingly.
7564*/
7565void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
7566{
7567 tSirSmeRsp *pSmeRsp;
7568 tSmeIbssPeerInd *pIbssPeerInd;
7569 tCsrRoamInfo roamInfo;
7570 // TODO Session Id need to be acquired in this function
7571 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007572 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07007573 smsLog( pMac, LOG2, "Message %d[0x%04X] received in substate %d\n",
7574 pSmeRsp->messageType, pSmeRsp->messageType,
7575 pMac->roam.curSubState[pSmeRsp->sessionId] );
Jeff Johnson295189b2012-06-20 16:38:30 -07007576 pSmeRsp->messageType = (pSmeRsp->messageType);
7577 pSmeRsp->length = (pSmeRsp->length);
7578 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007579 switch (pSmeRsp->messageType)
7580 {
7581
7582 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
7583 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
7584 {
7585 //We sent a JOIN_REQ
7586 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
7587 }
7588 break;
7589
7590 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
7591 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
7592 {
7593 //We sent a AUTH_REQ
7594 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
7595 }
7596 break;
7597
7598 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
7599 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
7600 {
7601 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
7602 }
7603 break;
7604
7605 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
7606 {
7607 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
7608 }
7609 break;
7610
7611 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
7612 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
7613 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
7614 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
7615 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
7616 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
7617//HO
7618 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
7619 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07007620 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %d\n"), pMac->roam.curSubState[pSmeRsp->sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007621 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
7622 }
7623 break;
7624
7625 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
7626 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
7627 {
7628 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
7629 }
7630 break;
7631
7632 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
7633 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
7634 {
7635 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
7636 }
7637 break;
7638
7639 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
7640 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
7641 {
7642 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
7643 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007644 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007645 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
7646 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
7647 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
7648 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state\n");
7649 palZeroMemory( pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo) );
7650 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
7651 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
7652 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
7653 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
7654 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
7655 eCSR_ROAM_CONNECT_STATUS_UPDATE,
7656 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
7657 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007658 default:
7659 smsLog( pMac, LOG1, "Unexpected message type = %d[0x%X] received in substate %d\n",
7660 pSmeRsp->messageType, pSmeRsp->messageType,
7661 pMac->roam.curSubState[pSmeRsp->sessionId] );
7662
7663 //If we are connected, check the link status change
7664 if(!csrIsConnStateDisconnected(pMac, sessionId))
7665 {
7666 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
7667 }
7668 break;
7669 }
7670}
7671
Jeff Johnson295189b2012-06-20 16:38:30 -07007672void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
7673{
7674 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07007675 switch (pSirMsg->messageType)
7676 {
7677 case eWNI_SME_GET_STATISTICS_RSP:
Mohit Khanna23863762012-09-11 17:40:09 -07007678 smsLog( pMac, LOG2, FL("Stats rsp from PE\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007679 csrRoamStatsRspProcessor( pMac, pSirMsg );
7680 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007681 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
7682 {
7683 tCsrRoamSession *pSession;
7684 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
7685 tCsrRoamInfo roamInfo;
7686 tCsrRoamInfo *pRoamInfo = NULL;
7687 tANI_U32 sessionId;
7688 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007689 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer \n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007690 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
7691 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07007692 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
7693 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
7694 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07007695
7696 if(!pSession)
7697 {
7698 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7699 return;
7700 }
7701
Jeff Johnson295189b2012-06-20 16:38:30 -07007702 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
7703 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07007704 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
7705 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
7706 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07007707 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
7708 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07007709 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr, sizeof(tSirMacAddr));
7710 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pUpperLayerAssocCnf->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07007711 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07007712 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
7713 {
7714 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
7715 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
7716 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
7717 }
7718 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
7719 {
7720 vos_sleep( 100 );
7721 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
7722 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
7723 }
7724
Jeff Johnson295189b2012-06-20 16:38:30 -07007725 }
7726 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007727 default:
7728 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
7729 break;
7730 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007731}
7732
Jeff Johnson295189b2012-06-20 16:38:30 -07007733eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
7734 tSirBssDescription *pBssDescription,
7735 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
7736 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
7737 tANI_U8 keyId, tANI_U16 keyLength,
7738 tANI_U8 *pKey, tANI_U8 paeRole )
7739{
7740 eHalStatus status = eHAL_STATUS_SUCCESS;
7741 tAniEdType edType;
7742
7743 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
7744 {
7745 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
7746 }
7747
7748 edType = csrTranslateEncryptTypeToEdType( EncryptType );
7749
7750 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
7751 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
7752 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
7753 addKey )
7754 {
7755 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07007756 setKey.encType = EncryptType;
7757 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
7758 palCopyMemory( pMac->hHdd, &setKey.peerMac, bssId, sizeof(tCsrBssid) );
7759 setKey.paeRole = paeRole; //0 for supplicant
7760 setKey.keyId = keyId; // Kye index
7761 setKey.keyLength = keyLength;
7762 if( keyLength )
7763 {
7764 palCopyMemory( pMac->hHdd, setKey.Key, pKey, keyLength );
7765 }
7766 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
7767 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007768 return (status);
7769}
7770
Jeff Johnson295189b2012-06-20 16:38:30 -07007771static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
7772 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
7773{
7774 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
7775 tSmeCmd *pCommand = NULL;
7776#ifdef FEATURE_WLAN_CCX
7777 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7778#endif /* FEATURE_WLAN_CCX */
7779
7780 do
7781 {
7782 pCommand = csrGetCommandBuffer(pMac);
7783 if(NULL == pCommand)
7784 {
7785 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
7786 status = eHAL_STATUS_RESOURCES;
7787 break;
7788 }
7789 pCommand->command = eSmeCommandSetKey;
7790 pCommand->sessionId = (tANI_U8)sessionId;
7791 // validate the key length, Adjust if too long...
7792 // for static WEP the keys are not set thru' SetContextReq
7793 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
7794 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
7795 {
7796 //KeyLength maybe 0 for static WEP
7797 if( pSetKey->keyLength )
7798 {
7799 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
7800 {
7801 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7802 break;
7803 }
7804
7805 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
7806 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WEP40_KEY_LEN );
7807 }
7808 }
7809 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
7810 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
7811 {
7812 //KeyLength maybe 0 for static WEP
7813 if( pSetKey->keyLength )
7814 {
7815 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
7816 {
7817 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7818 break;
7819 }
7820
7821 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
7822 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WEP104_KEY_LEN );
7823 }
7824 }
7825 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
7826 {
7827 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
7828 {
7829 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7830 break;
7831 }
7832 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
7833 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_TKIP_KEY_LEN );
7834 }
7835 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
7836 {
7837 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
7838 {
7839 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7840 break;
7841 }
7842 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
7843 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN );
7844 }
7845#ifdef FEATURE_WLAN_WAPI
7846 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
7847 {
7848 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
7849 {
7850 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7851 break;
7852 }
7853 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
7854 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WAPI_KEY_LEN );
7855 }
7856#endif /* FEATURE_WLAN_WAPI */
7857#ifdef FEATURE_WLAN_CCX
7858 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
7859 {
7860 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
7861 {
7862 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7863 break;
7864 }
7865 palCopyMemory( pMac->hHdd, pSession->ccxCckmInfo.krk, pSetKey->Key, CSR_KRK_KEY_LEN );
7866 pSession->ccxCckmInfo.reassoc_req_num=1;
7867 pSession->ccxCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
7868 status = eHAL_STATUS_SUCCESS;
7869 break;
7870 }
7871#endif /* FEATURE_WLAN_CCX */
Jeff Johnsone7245742012-09-05 17:12:55 -07007872
Jeff Johnson295189b2012-06-20 16:38:30 -07007873#ifdef WLAN_FEATURE_11W
7874 //Check for 11w BIP
7875 else if ( eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType )
7876 {
7877 tANI_U16 count = 0;
7878 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
7879 {
7880 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7881 break;
7882 }
7883 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
7884 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN );
7885 }
7886#endif
7887 status = eHAL_STATUS_SUCCESS;
7888 pCommand->u.setKeyCmd.roamId = roamId;
7889 pCommand->u.setKeyCmd.encType = pSetKey->encType;
7890 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
7891 palCopyMemory( pMac->hHdd, &pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac, sizeof(tCsrBssid) );
7892 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
7893 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
7894 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN );
7895 //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
7896
7897 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
7898 if( !HAL_STATUS_SUCCESS( status ) )
7899 {
7900 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
7901 }
7902 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007903 // Free the command if there has been a failure, or it is a
7904 // "local" operation like the set CCX CCKM KRK key.
7905 if( (!HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ))
7906#ifdef FEATURE_WLAN_CCX
7907 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
7908#endif /* FEATURE_WLAN_CCX */
7909 )
7910 {
7911 csrReleaseCommandSetKey( pMac, pCommand );
7912 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007913 return( status );
7914}
7915
Jeff Johnson295189b2012-06-20 16:38:30 -07007916eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
7917 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
7918{
7919 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
7920 tSmeCmd *pCommand = NULL;
7921 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007922 do
7923 {
7924 if( !csrIsSetKeyAllowed(pMac, sessionId) )
7925 {
7926 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key\n") );
7927 status = eHAL_STATUS_CSR_WRONG_STATE;
7928 break;
7929 }
7930 pCommand = csrGetCommandBuffer(pMac);
7931 if(NULL == pCommand)
7932 {
7933 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
7934 status = eHAL_STATUS_RESOURCES;
7935 break;
7936 }
7937 pCommand->command = eSmeCommandRemoveKey;
7938 pCommand->sessionId = (tANI_U8)sessionId;
7939 pCommand->u.removeKeyCmd.roamId = roamId;
7940 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
7941 palCopyMemory( pMac->hHdd, &pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac, sizeof(tSirMacAddr) );
7942 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
7943 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7944 {
7945 //in this case, put it to the end of the Q incase there is a set key pending.
7946 fImediate = eANI_BOOLEAN_FALSE;
7947 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007948 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac=%02x, %02x, %02x, %02x, %02x, %02x\n"),
7949 pRemoveKey->encType, pRemoveKey->keyId,
7950 pCommand->u.removeKeyCmd.peerMac[0],
7951 pCommand->u.removeKeyCmd.peerMac[1],
7952 pCommand->u.removeKeyCmd.peerMac[2],
7953 pCommand->u.removeKeyCmd.peerMac[3],
7954 pCommand->u.removeKeyCmd.peerMac[4],
7955 pCommand->u.removeKeyCmd.peerMac[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007956 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
7957 if( !HAL_STATUS_SUCCESS( status ) )
7958 {
7959 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
7960 break;
7961 }
7962 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007963 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
7964 {
7965 csrReleaseCommandRemoveKey( pMac, pCommand );
7966 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007967 return (status );
7968}
7969
Jeff Johnson295189b2012-06-20 16:38:30 -07007970eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
7971{
7972 eHalStatus status;
7973 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
7974 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
7975 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
7976 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007977#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7978 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7979 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07007980 if(eCSR_ENCRYPT_TYPE_NONE != edType)
7981 {
7982 palZeroMemory(pMac->hHdd, &setKeyEvent, sizeof(vos_event_wlan_security_payload_type));
7983 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
7984 {
7985 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
7986 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
7987 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
7988 }
7989 else
7990 {
7991 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
7992 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
7993 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
7994 }
7995 palCopyMemory( pMac->hHdd, setKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
7996 if(CSR_IS_ENC_TYPE_STATIC(edType))
7997 {
7998 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007999 //It has to be static WEP here
8000 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
8001 {
8002 setKeyEvent.keyId = (v_U8_t)defKeyId;
8003 }
8004 }
8005 else
8006 {
8007 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
8008 }
8009 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8010 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8011 }
8012#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008013 if( csrIsSetKeyAllowed(pMac, sessionId) )
8014 {
8015 status = csrSendMBSetContextReqMsg( pMac, sessionId,
8016 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
8017 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
8018 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
8019 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
8020 pCommand->u.setKeyCmd.keyRsc);
8021 }
8022 else
8023 {
8024 smsLog( pMac, LOGW, FL(" cannot process not connected\n") );
8025 //Set this status so the error handling take care of the case.
8026 status = eHAL_STATUS_CSR_WRONG_STATE;
8027 }
8028 if( !HAL_STATUS_SUCCESS(status) )
8029 {
8030 smsLog( pMac, LOGE, FL(" error status %d\n"), status );
8031 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008032#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8033 if(eCSR_ENCRYPT_TYPE_NONE != edType)
8034 {
8035 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8036 {
8037 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8038 }
8039 else
8040 {
8041 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8042 }
8043 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8044 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8045 }
8046#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008047 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008048 return ( status );
8049}
8050
Jeff Johnson295189b2012-06-20 16:38:30 -07008051eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8052{
8053 eHalStatus status;
8054 tpSirSmeRemoveKeyReq pMsg = NULL;
8055 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
8056 tANI_U8 *p;
8057 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008058#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8059 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8060 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07008061 palZeroMemory(pMac->hHdd, &removeKeyEvent, sizeof(vos_event_wlan_security_payload_type));
8062 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
8063 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8064 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8065 palCopyMemory( pMac->hHdd, removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
8066 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
8067 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8068 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8069#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008070 if( csrIsSetKeyAllowed(pMac, sessionId) )
8071 {
8072 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, wMsgLen );
8073 }
8074 else
8075 {
8076 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key\n") );
8077 //Set the error status so error handling kicks in below
8078 status = eHAL_STATUS_CSR_WRONG_STATE;
8079 }
8080 if( HAL_STATUS_SUCCESS( status ) )
8081 {
8082 palZeroMemory(pMac->hHdd, pMsg, wMsgLen);
8083 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
8084 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008085 pMsg->sessionId = (tANI_U8)sessionId;
8086 pMsg->transactionId = 0;
8087 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
8088 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
8089 // bssId - copy from session Info
8090 palCopyMemory( pMac->hHdd, p, &pMac->roam.roamSession[sessionId].connectedProfile.bssid, sizeof(tSirMacAddr) );
8091 p += sizeof(tSirMacAddr);
8092 // peerMacAddr
8093 palCopyMemory( pMac->hHdd, p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr) );
8094 p += sizeof(tSirMacAddr);
8095 // edType
8096 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
8097 p++;
8098 // weptype
8099 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
8100 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
8101 {
8102 *p = (tANI_U8)eSIR_WEP_STATIC;
8103 }
8104 else
8105 {
8106 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
8107 }
8108 p++;
8109 //keyid
8110 *p = pCommand->u.removeKeyCmd.keyId;
8111 p++;
8112 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008113 status = palSendMBMessage(pMac->hHdd, pMsg);
8114 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008115 if( !HAL_STATUS_SUCCESS( status ) )
8116 {
8117 smsLog( pMac, LOGE, FL(" error status \n"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008118#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8119 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07008120 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008121 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8122#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008123 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
8124 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008125 return ( status );
8126}
8127
Jeff Johnson295189b2012-06-20 16:38:30 -07008128eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8129{
8130 eHalStatus status;
8131
8132 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8133 {
8134 status = eHAL_STATUS_CSR_WRONG_STATE;
8135 }
8136 else
8137 {
8138 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
8139 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008140 return ( status );
8141}
8142
Jeff Johnson295189b2012-06-20 16:38:30 -07008143/*
8144 Prepare a filter base on a profile for parsing the scan results.
8145 Upon successful return, caller MUST call csrFreeScanFilter on
8146 pScanFilter when it is done with the filter.
8147*/
8148eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
8149 tCsrScanResultFilter *pScanFilter)
8150{
8151 eHalStatus status = eHAL_STATUS_SUCCESS;
8152 tANI_U32 size = 0;
8153 tANI_U8 index = 0;
8154
8155 do
8156 {
8157 if(pProfile->BSSIDs.numOfBSSIDs)
8158 {
8159 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
8160 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->BSSIDs.bssid, size);
8161 if(!HAL_STATUS_SUCCESS(status))
8162 {
8163 break;
8164 }
8165 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
8166 palCopyMemory(pMac->hHdd, pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
8167 }
8168 if(pProfile->SSIDs.numOfSSIDs)
8169 {
8170 if( !CSR_IS_WDS_STA( pProfile ) )
8171 {
8172 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
8173 }
8174 else
8175 {
8176 //For WDS station
8177 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
8178 pScanFilter->SSIDs.numOfSSIDs = 1;
8179 }
8180 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
8181 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->SSIDs.SSIDList, size);
8182 if(!HAL_STATUS_SUCCESS(status))
8183 {
8184 break;
8185 }
8186 palCopyMemory(pMac->hHdd, pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList, size);
8187 }
8188 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
8189 {
8190 pScanFilter->ChannelInfo.numOfChannels = 0;
8191 pScanFilter->ChannelInfo.ChannelList = NULL;
8192 }
8193 else if(pProfile->ChannelInfo.numOfChannels)
8194 {
8195 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->ChannelInfo.ChannelList, sizeof(*pScanFilter->ChannelInfo.ChannelList) * pProfile->ChannelInfo.numOfChannels);
8196 pScanFilter->ChannelInfo.numOfChannels = 0;
8197 if(HAL_STATUS_SUCCESS(status))
8198 {
8199 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
8200 {
8201 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
8202 {
8203 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
8204 = pProfile->ChannelInfo.ChannelList[index];
8205 pScanFilter->ChannelInfo.numOfChannels++;
8206 }
8207 else
8208 {
8209 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid\n"), pProfile->ChannelInfo.ChannelList[index]);
8210 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008211 }
8212 }
8213 else
8214 {
8215 break;
8216 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008217 }
8218 else
8219 {
8220 smsLog(pMac, LOGW, FL("Channel list empty\n"));
8221 status = eHAL_STATUS_FAILURE;
8222 break;
8223 }
8224 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
8225 pScanFilter->authType = pProfile->AuthType;
8226 pScanFilter->EncryptionType = pProfile->EncryptionType;
8227 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
8228 pScanFilter->BSSType = pProfile->BSSType;
8229 pScanFilter->phyMode = pProfile->phyMode;
8230#ifdef FEATURE_WLAN_WAPI
8231 //check if user asked for WAPI with 11n or auto mode, in that case modify
8232 //the phymode to 11g
8233 if(csrIsProfileWapi(pProfile))
8234 {
8235 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
8236 {
8237 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
8238 }
8239 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
8240 {
8241 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
8242 }
8243 if(!pScanFilter->phyMode)
8244 {
8245 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
8246 }
8247 }
8248#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07008249 /*Save the WPS info*/
8250 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07008251 if( pProfile->countryCode[0] )
8252 {
8253 //This causes the matching function to use countryCode as one of the criteria.
8254 palCopyMemory( pMac->hHdd, pScanFilter->countryCode, pProfile->countryCode,
8255 WNI_CFG_COUNTRY_CODE_LEN );
8256 }
8257#ifdef WLAN_FEATURE_VOWIFI_11R
8258 if (pProfile->MDID.mdiePresent)
8259 {
8260 pScanFilter->MDID.mdiePresent = 1;
8261 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
8262 }
8263#endif
8264
8265 }while(0);
8266
8267 if(!HAL_STATUS_SUCCESS(status))
8268 {
8269 csrFreeScanFilter(pMac, pScanFilter);
8270 }
8271
8272 return(status);
8273}
8274
Jeff Johnson295189b2012-06-20 16:38:30 -07008275tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
8276 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
8277{
8278 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
8279 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008280 do
8281 {
8282 // Validate the type is ok...
8283 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
8284 pCommand = csrGetCommandBuffer( pMac );
8285 if ( !pCommand )
8286 {
8287 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
8288 break;
8289 }
8290 //Change the substate in case it is waiting for key
8291 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8292 {
8293 csrRoamStopWaitForKeyTimer( pMac );
8294 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
8295 }
8296 pCommand->command = eSmeCommandWmStatusChange;
8297 pCommand->sessionId = (tANI_U8)sessionId;
8298 pCommand->u.wmStatusChangeCmd.Type = Type;
8299 if ( eCsrDisassociated == Type )
8300 {
8301 palCopyMemory( pMac->hHdd, &pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg, pSmeRsp,
8302 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ) );
8303 }
8304 else
8305 {
8306 palCopyMemory( pMac->hHdd, &pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg, pSmeRsp,
8307 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ) );
8308 }
8309 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
8310 {
8311 fCommandQueued = eANI_BOOLEAN_TRUE;
8312 }
8313 else
8314 {
8315 smsLog( pMac, LOGE, FL(" fail to send message \n") );
8316 csrReleaseCommandWmStatusChange( pMac, pCommand );
8317 }
8318
Jeff Johnson295189b2012-06-20 16:38:30 -07008319 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
8320 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07008321 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07008322 return( fCommandQueued );
8323}
8324
Jeff Johnson295189b2012-06-20 16:38:30 -07008325static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
8326{
8327 v_S7_t rssi = 0;
8328 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
8329 if(pGetRssiReq)
8330 {
8331 if(NULL != pGetRssiReq->pVosContext)
8332 {
8333 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
8334 }
8335 else
8336 {
8337 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL\n"));
8338 return;
8339 }
8340
8341 if(NULL != pGetRssiReq->rssiCallback)
8342 {
8343 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
8344 }
8345 else
8346 {
8347 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL\n"));
8348 return;
8349 }
8350 }
8351 else
8352 {
8353 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL\n"));
8354 }
8355 return;
8356}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008357#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
8358void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
8359{
8360 v_S7_t rssi = 0;
8361 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
8362
8363 /* Get roam Rssi request is backed up and passed back to the response,
8364 Extract the request message to fetch callback */
8365 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
8366 if(pRoamRssiRsp)
8367 {
8368 rssi = pRoamRssiRsp->rssi;
8369 if((reqBkp) && (NULL != reqBkp->rssiCallback))
8370 {
8371 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
8372 reqBkp->rssiCallback = NULL;
8373 vos_mem_free(reqBkp);
8374 }
8375 else
8376 {
8377 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
8378 if (NULL != reqBkp)
8379 {
8380 vos_mem_free(reqBkp);
8381 }
8382 }
8383 }
8384 else
8385 {
8386 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
8387 }
8388 return;
8389}
8390#endif
8391
Jeff Johnsone7245742012-09-05 17:12:55 -07008392static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
8393{
8394 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
8395 if(pTlRssiInd)
8396 {
8397 if(NULL != pTlRssiInd->tlCallback)
8398 {
8399 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08008400 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07008401 }
8402 else
8403 {
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008404 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL\n"));
Jeff Johnsone7245742012-09-05 17:12:55 -07008405 }
8406 }
8407 else
8408 {
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008409 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL\n"));
Jeff Johnsone7245742012-09-05 17:12:55 -07008410 }
8411 return;
8412}
Jeff Johnson295189b2012-06-20 16:38:30 -07008413
8414void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
8415{
8416 tSirSmeAssocInd *pAssocInd;
8417 tSirSmeDisassocInd *pDisassocInd;
8418 tSirSmeDeauthInd *pDeauthInd;
8419 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
8420 tSirSmeNewBssInfo *pNewBss;
8421 tSmeIbssPeerInd *pIbssPeerInd;
8422 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
8423 tSirSmeApNewCaps *pApNewCaps;
8424 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
8425 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
8426 tCsrRoamInfo *pRoamInfo = NULL;
8427 tCsrRoamInfo roamInfo;
8428 eHalStatus status;
8429 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
8430 tCsrRoamSession *pSession = NULL;
8431 tpSirSmeSwitchChannelInd pSwitchChnInd;
8432 tSmeMaxAssocInd *pSmeMaxAssocInd;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08008433 tSmeCmd pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008434 pSirMsg->messageType = (pSirMsg->messageType);
8435 pSirMsg->length = (pSirMsg->length);
8436 pSirMsg->statusCode = (pSirMsg->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008437 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07008438 switch( pSirMsg->messageType )
8439 {
8440 case eWNI_SME_ASSOC_IND:
8441 {
8442 tCsrRoamSession *pSession;
8443 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME\n"));
8444 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
8445 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
8446 if( HAL_STATUS_SUCCESS( status ) )
8447 {
8448 pSession = CSR_GET_SESSION(pMac, sessionId);
8449
Jeff Johnson32d95a32012-09-10 13:15:23 -07008450 if(!pSession)
8451 {
8452 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8453 return;
8454 }
8455
Jeff Johnson295189b2012-06-20 16:38:30 -07008456 pRoamInfo = &roamInfo;
8457
8458 // Required for indicating the frames to upper layer
8459 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
8460 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
8461
8462 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
8463 pRoamInfo->beaconLength = pAssocInd->beaconLength;
8464 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8465 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8466
8467 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
8468 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
8469 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
8470
8471 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
8472 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008473 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
8474 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pAssocInd->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008475 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
8476 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07008477 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07008478 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
8479 {
8480 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
8481 {
8482 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
8483 pSession->pConnectBssDesc,
8484 &(pRoamInfo->peerMac),
8485 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
8486 pRoamInfo->fAuthRequired = FALSE;
8487 }
8488 else
8489 {
8490 pRoamInfo->fAuthRequired = TRUE;
8491 }
8492 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
8493 if (!HAL_STATUS_SUCCESS(status))
8494 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
8495 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008496 /* Send Association completion message to PE */
8497 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
8498
8499 /* send a message to CSR itself just to avoid the EAPOL frames going
8500 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07008501 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8502 {
8503 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
8504 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008505 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
8506 {
8507 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
8508 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8509 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
8510 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008511 }
8512 }
8513 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008514 case eWNI_SME_DISASSOC_IND:
8515 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008516 // Check if AP dis-associated us because of MIC failure. If so,
8517 // then we need to take action immediately and not wait till the
8518 // the WmStatusChange requests is pushed and processed
8519 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
8520 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDisassocInd->bssId, &sessionId );
8521 if( HAL_STATUS_SUCCESS( status ) )
8522 {
8523 // If we are in neighbor preauth done state then on receiving
8524 // disassoc or deauth we dont roam instead we just disassoc
8525 // from current ap and then go to disconnected state
8526 // This happens for CCX and 11r FT connections ONLY.
8527#ifdef WLAN_FEATURE_VOWIFI_11R
8528 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8529 {
8530 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8531 }
8532#endif
8533#ifdef FEATURE_WLAN_CCX
8534 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8535 {
8536 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8537 }
8538#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008539#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308540 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008541 {
8542 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8543 }
8544#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008545 pSession = CSR_GET_SESSION( pMac, sessionId );
8546
Jeff Johnson32d95a32012-09-10 13:15:23 -07008547 if(!pSession)
8548 {
8549 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8550 return;
8551 }
8552
Jeff Johnson295189b2012-06-20 16:38:30 -07008553 if ( csrIsConnStateInfra( pMac, sessionId ) )
8554 {
8555 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8556 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008557#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8558 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
8559#endif
8560 csrRoamLinkDown(pMac, sessionId);
8561 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07008562 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
8563 {
8564
8565 pRoamInfo = &roamInfo;
8566
8567 pRoamInfo->statusCode = pDisassocInd->statusCode;
8568 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8569
8570 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
8571
8572 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDisassocInd->peerMacAddr, sizeof(tSirMacAddr));
8573 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pDisassocInd->bssId, sizeof(tCsrBssid));
8574
8575 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08008576
8577 /*
8578 * STA/P2P client got disassociated so remove any pending deauth
8579 * commands in sme pending list
8580 */
8581 pCommand.command = eSmeCommandRoam;
8582 pCommand.sessionId = (tANI_U8)sessionId;
8583 pCommand.u.roamCmd.roamReason = eCsrForcedDeauthSta;
8584 vos_mem_copy(pCommand.u.roamCmd.peerMac, pDisassocInd->peerMacAddr, sizeof(tSirMacAddr));
8585 csrRoamRemoveDuplicateCommand(pMac, sessionId, &pCommand, eCsrForcedDeauthSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07008586 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008587 }
8588 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008589 case eWNI_SME_DEAUTH_IND:
8590 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC\n"));
8591 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
8592 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
8593 if( HAL_STATUS_SUCCESS( status ) )
8594 {
8595 // If we are in neighbor preauth done state then on receiving
8596 // disassoc or deauth we dont roam instead we just disassoc
8597 // from current ap and then go to disconnected state
8598 // This happens for CCX and 11r FT connections ONLY.
8599#ifdef WLAN_FEATURE_VOWIFI_11R
8600 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8601 {
8602 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8603 }
8604#endif
8605#ifdef FEATURE_WLAN_CCX
8606 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8607 {
8608 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8609 }
8610#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008611#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308612 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008613 {
8614 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8615 }
8616#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008617 pSession = CSR_GET_SESSION( pMac, sessionId );
8618
Jeff Johnson32d95a32012-09-10 13:15:23 -07008619 if(!pSession)
8620 {
8621 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8622 return;
8623 }
8624
Jeff Johnson295189b2012-06-20 16:38:30 -07008625 if ( csrIsConnStateInfra( pMac, sessionId ) )
8626 {
8627 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8628 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008629#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8630 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
8631#endif
8632 csrRoamLinkDown(pMac, sessionId);
8633 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07008634 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
8635 {
8636
8637 pRoamInfo = &roamInfo;
8638
8639 pRoamInfo->statusCode = pDeauthInd->statusCode;
8640 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8641
8642 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
8643
8644 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDeauthInd->peerMacAddr, sizeof(tSirMacAddr));
8645 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pDeauthInd->bssId, sizeof(tCsrBssid));
8646
8647 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
8648 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008649 }
8650 break;
8651
8652 case eWNI_SME_SWITCH_CHL_REQ: // in case of STA, the SWITCH_CHANNEL originates from its AP
8653 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME\n"));
8654 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
8655 //Update with the new channel id.
8656 //The channel id is hidden in the statusCode.
8657 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
8658 if( HAL_STATUS_SUCCESS( status ) )
8659 {
8660 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008661 if(!pSession)
8662 {
8663 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8664 return;
8665 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008666 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
8667 if(pSession->pConnectBssDesc)
8668 {
8669 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
8670 }
8671 }
8672 break;
8673
8674 case eWNI_SME_DEAUTH_RSP:
8675 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008676 {
8677 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
8678 sessionId = pDeauthRsp->sessionId;
8679 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
8680 {
8681 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008682 if(!pSession)
8683 {
8684 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8685 return;
8686 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008687 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
8688 {
8689 pRoamInfo = &roamInfo;
8690 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8691 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDeauthRsp->peerMacAddr, sizeof(tSirMacAddr));
8692 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
8693 pRoamInfo->statusCode = pDeauthRsp->statusCode;
8694 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
8695 }
8696 }
8697 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008698 break;
8699
8700 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07008701 /* session id is invalid here so cant use it to access the array curSubstate as index */
8702 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME \n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008703 {
8704 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
8705 sessionId = pDisassocRsp->sessionId;
8706 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
8707 {
8708 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008709 if(!pSession)
8710 {
8711 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8712 return;
8713 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008714 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
8715 {
8716 pRoamInfo = &roamInfo;
8717 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8718 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDisassocRsp->peerMacAddr, sizeof(tSirMacAddr));
8719 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
8720 pRoamInfo->statusCode = pDisassocRsp->statusCode;
8721 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
8722 }
8723 }
8724 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008725 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008726 case eWNI_SME_MIC_FAILURE_IND:
8727 {
8728 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
8729 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
8730 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Jeff Johnson295189b2012-06-20 16:38:30 -07008731#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8732 {
8733 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008734 if(!pSession)
8735 {
8736 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8737 return;
8738 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008739 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
8740 palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type));
8741 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
8742 secEvent.encryptionModeMulticast =
8743 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8744 secEvent.encryptionModeUnicast =
8745 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8746 secEvent.authMode =
8747 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8748 palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 );
8749 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
8750 }
8751#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008752 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
8753 if( HAL_STATUS_SUCCESS( status ) )
8754 {
8755 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
8756 roamInfo.u.pMICFailureInfo = &pMicInd->info;
8757 pRoamInfo = &roamInfo;
8758 if(pMicInd->info.multicast)
8759 {
8760 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
8761 }
8762 else
8763 {
8764 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
8765 }
8766 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
8767 }
8768 }
8769 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008770 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
8771 {
8772 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
8773 tCsrRoamInfo roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008774 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME\n"));
8775
8776 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
8777 if( HAL_STATUS_SUCCESS( status ) )
8778 {
8779 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
8780 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
8781 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
8782 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
8783 }
8784 }
8785 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008786
Jeff Johnson295189b2012-06-20 16:38:30 -07008787 case eWNI_SME_WM_STATUS_CHANGE_NTF:
8788 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
8789 switch( pStatusChangeMsg->statusChangeCode )
8790 {
8791 case eSIR_SME_IBSS_ACTIVE:
8792 sessionId = csrFindIbssSession( pMac );
8793 if( CSR_SESSION_ID_INVALID != sessionId )
8794 {
8795 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008796 if(!pSession)
8797 {
8798 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8799 return;
8800 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008801 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
8802 if(pSession->pConnectBssDesc)
8803 {
8804 palCopyMemory(pMac->hHdd, &roamInfo.bssid, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
8805 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
8806 pRoamInfo = &roamInfo;
8807 }
8808 else
8809 {
8810 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty\n");
8811 }
8812 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
8813 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
8814 }
8815 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008816 case eSIR_SME_IBSS_INACTIVE:
8817 sessionId = csrFindIbssSession( pMac );
8818 if( CSR_SESSION_ID_INVALID != sessionId )
8819 {
8820 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008821 if(!pSession)
8822 {
8823 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8824 return;
8825 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008826 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
8827 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
8828 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
8829 }
8830 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008831 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
8832 sessionId = csrFindIbssSession( pMac );
8833 if( CSR_SESSION_ID_INVALID != sessionId )
8834 {
8835 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008836 if(!pSession)
8837 {
8838 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8839 return;
8840 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008841 // update the connection state information
8842 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008843#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8844 {
8845 vos_log_ibss_pkt_type *pIbssLog;
8846 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07008847 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8848 if(pIbssLog)
8849 {
8850 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
8851 if(pNewBss)
8852 {
8853 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pNewBss->bssId, 6);
8854 if(pNewBss->ssId.length)
8855 {
8856 palCopyMemory(pMac->hHdd, pIbssLog->ssid, pNewBss->ssId.ssId, pNewBss->ssId.length);
8857 }
8858 pIbssLog->operatingChannel = pNewBss->channelNumber;
8859 }
8860 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
8861 {
8862 //***U8 is not enough for beacon interval
8863 pIbssLog->beaconInterval = (v_U8_t)bi;
8864 }
8865 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
8866 }
8867 }
8868#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008869 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
8870 csrRoamIssueSetContextReq( pMac, sessionId, pSession->connectedProfile.EncryptionType,
8871 pSession->pConnectBssDesc,
8872 &Broadcastaddr,
8873 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
8874 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
8875 roamStatus = eCSR_ROAM_IBSS_IND;
8876 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pNewBss->bssId, sizeof(tCsrBssid));
8877 pRoamInfo = &roamInfo;
8878 //This BSSID is th ereal BSSID, let's save it
8879 if(pSession->pConnectBssDesc)
8880 {
8881 palCopyMemory(pMac->hHdd, pSession->pConnectBssDesc->bssId, &pNewBss->bssId, sizeof(tCsrBssid));
8882 }
8883 // Stop the join IBSS timer in case of join, for
8884 // genuine merge do nothing
8885 if(pSession->ibss_join_pending)
8886 {
8887 pSession->ibss_join_pending = FALSE;
8888 csrRoamStopIbssJoinTimer(pMac, sessionId);
8889 result = eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS;
8890 }
8891 }
8892 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE\n");
8893 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008894 // detection by LIM that the capabilities of the associated AP have changed.
8895 case eSIR_SME_AP_CAPS_CHANGED:
8896 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
8897 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED\n");
8898 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
8899 if( HAL_STATUS_SUCCESS( status ) )
8900 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08008901 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
8902 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
8903 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
8904 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
8905 )
8906 {
8907 csrScanForCapabilityChange( pMac, pApNewCaps );
8908 result = eCSR_ROAM_RESULT_CAP_CHANGED;
8909 roamStatus = eCSR_ROAM_GEN_INFO;
8910 }
8911 else
8912 {
8913 smsLog(pMac, LOGW,
8914 "Skipping csrScanForCapabilityChange as "
8915 "CSR is in state %d and sub-state %d\n",
8916 pMac->roam.curState[sessionId],
8917 pMac->roam.curSubState[sessionId]);
8918 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008919 }
8920 break;
8921
8922 default:
8923 roamStatus = eCSR_ROAM_FAILED;
8924 result = eCSR_ROAM_RESULT_NONE;
8925 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008926 } // end switch on statusChangeCode
8927 if(eCSR_ROAM_RESULT_NONE != result)
8928 {
8929 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
8930 }
8931 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008932 case eWNI_SME_IBSS_NEW_PEER_IND:
8933 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07008934#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8935 {
8936 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07008937 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8938 if(pIbssLog)
8939 {
8940 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
8941 palCopyMemory(pMac->hHdd, pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
8942 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
8943 }
8944 }
8945#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008946 sessionId = csrFindIbssSession( pMac );
8947 if( CSR_SESSION_ID_INVALID != sessionId )
8948 {
8949 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008950
8951 if(!pSession)
8952 {
8953 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8954 return;
8955 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008956 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
8957 if(pSession->pConnectBssDesc)
8958 {
8959 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
8960 palCopyMemory(pMac->hHdd, &roamInfo.bssid, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
8961 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
8962 {
8963 status = palAllocateMemory(pMac->hHdd, (void **)&roamInfo.pbFrames,
8964 (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd)));
8965 if(HAL_STATUS_SUCCESS(status))
8966 {
8967 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
8968 palCopyMemory(pMac->hHdd, roamInfo.pbFrames, ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
8969 roamInfo.nBeaconLength);
8970 }
8971 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
8972 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8973 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
8974 status = palAllocateMemory(pMac->hHdd, (void **)&roamInfo.pBssDesc,
8975 pSession->pConnectBssDesc->length);
8976 if(HAL_STATUS_SUCCESS(status))
8977 {
8978 palCopyMemory(pMac->hHdd, roamInfo.pBssDesc, pSession->pConnectBssDesc,
8979 pSession->pConnectBssDesc->length);
8980 }
8981 if(HAL_STATUS_SUCCESS(status))
8982 {
8983 pRoamInfo = &roamInfo;
8984 }
8985 else
8986 {
8987 if(roamInfo.pbFrames)
8988 {
8989 palFreeMemory(pMac->hHdd, roamInfo.pbFrames);
8990 }
8991 if(roamInfo.pBssDesc)
8992 {
8993 palFreeMemory(pMac->hHdd, roamInfo.pBssDesc);
8994 }
8995 }
8996 }
8997 else
8998 {
8999 pRoamInfo = &roamInfo;
9000 }
9001 csrRoamIssueSetContextReq( pMac, sessionId, pSession->connectedProfile.EncryptionType,
9002 pSession->pConnectBssDesc,
9003 &(pIbssPeerInd->peerAddr),
9004 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9005 }
9006 else
9007 {
9008 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty\n");
9009 }
9010 //send up the sec type for the new peer
9011 if (pRoamInfo)
9012 {
9013 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9014 }
9015 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9016 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
9017 if(pRoamInfo)
9018 {
9019 if(roamInfo.pbFrames)
9020 {
9021 palFreeMemory(pMac->hHdd, roamInfo.pbFrames);
9022 }
9023 if(roamInfo.pBssDesc)
9024 {
9025 palFreeMemory(pMac->hHdd, roamInfo.pBssDesc);
9026 }
9027 }
9028 }
9029 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009030 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
9031 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
9032 sessionId = csrFindIbssSession( pMac );
9033 if( CSR_SESSION_ID_INVALID != sessionId )
9034 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009035#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9036 {
9037 vos_log_ibss_pkt_type *pIbssLog;
9038
9039 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9040 if(pIbssLog)
9041 {
9042 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
9043 if(pIbssPeerInd)
9044 {
9045 palCopyMemory(pMac->hHdd, pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
9046 }
9047 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9048 }
9049 }
9050#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009051 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM\n");
9052 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9053 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9054 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
9055 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
9056 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9057 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
9058 }
9059 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009060 case eWNI_SME_SETCONTEXT_RSP:
9061 {
9062 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
9063 tListElem *pEntry;
9064 tSmeCmd *pCommand;
9065
9066 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9067 if ( pEntry )
9068 {
9069 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9070 if ( eSmeCommandSetKey == pCommand->command )
9071 {
9072 sessionId = pCommand->sessionId;
9073 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009074
9075 if(!pSession)
9076 {
9077 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9078 return;
9079 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009080
9081#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9082 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
9083 {
9084 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
9085 palZeroMemory(pMac->hHdd, &setKeyEvent, sizeof(vos_event_wlan_security_payload_type));
9086 if( pRsp->peerMacAddr[0] & 0x01 )
9087 {
9088 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
9089 }
9090 else
9091 {
9092 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
9093 }
9094 setKeyEvent.encryptionModeMulticast =
9095 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9096 setKeyEvent.encryptionModeUnicast =
9097 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9098 palCopyMemory( pMac->hHdd, setKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
9099 setKeyEvent.authMode =
9100 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9101 if( eSIR_SUCCESS != pRsp->statusCode )
9102 {
9103 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9104 }
9105 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9106 }
9107#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
9108 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
9109 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009110 csrRoamStopWaitForKeyTimer( pMac );
9111
Jeff Johnson295189b2012-06-20 16:38:30 -07009112 //We are done with authentication, whethere succeed or not
9113 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009114 //We do it here because this linkup function is not called after association
9115 //when a key needs to be set.
9116 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
9117 {
9118 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9119 }
9120 }
Jeff Johnson43971f52012-07-17 12:26:56 -07009121 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009122 {
9123 palCopyMemory( pMac, &roamInfo.peerMac, &pRsp->peerMacAddr, sizeof(tCsrBssid) );
Jeff Johnsone7245742012-09-05 17:12:55 -07009124 //Make sure we install the GTK before indicating to HDD as authenticated
9125 //This is to prevent broadcast packets go out after PTK and before GTK.
9126 if( palEqualMemory( pMac->hHdd, &Broadcastaddr, pRsp->peerMacAddr,
9127 sizeof(tSirMacAddr) ) )
9128 {
Yathish9f22e662012-12-10 14:21:35 -08009129#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
9130 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
9131 {
9132 tpSirSetActiveModeSetBncFilterReq pMsg;
9133 palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tSirSetActiveModeSetBncFilterReq));
9134 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
9135 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
9136 pMsg->seesionId = sessionId;
9137 status = palSendMBMessage(pMac->hHdd, pMsg );
9138 }
9139#endif
9140 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -07009141 }
9142 else
9143 {
9144 result = eCSR_ROAM_RESULT_NONE;
9145 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009146 pRoamInfo = &roamInfo;
9147 }
9148 else
9149 {
9150 result = eCSR_ROAM_RESULT_FAILURE;
9151 smsLog( pMac, LOGE, "CSR: Roam Completion setkey command failed(%d) PeerMac %02X-%02X-%02X-%02X-%02X-%02X...\n",
9152 pRsp->statusCode, pRsp->peerMacAddr[0], pRsp->peerMacAddr[1], pRsp->peerMacAddr[2],
9153 pRsp->peerMacAddr[3], pRsp->peerMacAddr[4], pRsp->peerMacAddr[5] );
9154 }
9155 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9156 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -07009157 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
9158 // can go ahead and initiate the TSPEC if any are pending
9159 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009160#ifdef FEATURE_WLAN_CCX
9161 //Send Adjacent AP repot to new AP.
9162 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
9163 pSession->isPrevApInfoValid &&
9164 pSession->connectedProfile.isCCXAssoc)
9165 {
9166#ifdef WLAN_FEATURE_VOWIFI
9167 csrCcxSendAdjacentApRepMsg(pMac, pSession);
9168#endif
9169 pSession->isPrevApInfoValid = FALSE;
9170 }
9171#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009172 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9173 {
9174 csrReleaseCommandSetKey( pMac, pCommand );
9175 }
9176 }
9177 else
9178 {
9179 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ...\n" );
9180 }
9181 }
9182 else
9183 {
9184 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ...\n" );
9185 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009186 smeProcessPendingQueue( pMac );
9187 }
9188 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009189 case eWNI_SME_REMOVEKEY_RSP:
9190 {
9191 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
9192 tListElem *pEntry;
9193 tSmeCmd *pCommand;
9194
9195 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9196 if ( pEntry )
9197 {
9198 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9199 if ( eSmeCommandRemoveKey == pCommand->command )
9200 {
9201 sessionId = pCommand->sessionId;
9202 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009203
9204 if(!pSession)
9205 {
9206 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9207 return;
9208 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009209#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9210 {
9211 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
9212 palZeroMemory(pMac->hHdd, &removeKeyEvent, sizeof(vos_event_wlan_security_payload_type));
9213 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
9214 removeKeyEvent.encryptionModeMulticast =
9215 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9216 removeKeyEvent.encryptionModeUnicast =
9217 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9218 palCopyMemory( pMac->hHdd, removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
9219 removeKeyEvent.authMode =
9220 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9221 if( eSIR_SUCCESS != pRsp->statusCode )
9222 {
9223 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9224 }
9225 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9226 }
9227#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -07009228 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009229 {
9230 palCopyMemory( pMac, &roamInfo.peerMac, &pRsp->peerMacAddr, sizeof(tCsrBssid) );
9231 result = eCSR_ROAM_RESULT_NONE;
9232 pRoamInfo = &roamInfo;
9233 }
9234 else
9235 {
9236 result = eCSR_ROAM_RESULT_FAILURE;
9237 }
9238 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9239 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
9240 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9241 {
9242 csrReleaseCommandRemoveKey( pMac, pCommand );
9243 }
9244 }
9245 else
9246 {
9247 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ...\n" );
9248 }
9249 }
9250 else
9251 {
9252 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ...\n" );
9253 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009254 smeProcessPendingQueue( pMac );
9255 }
9256 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009257 case eWNI_SME_GET_STATISTICS_RSP:
Mohit Khanna23863762012-09-11 17:40:09 -07009258 smsLog( pMac, LOG2, FL("Stats rsp from PE\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009259 csrRoamStatsRspProcessor( pMac, pSirMsg );
9260 break;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009261#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
9262 case eWNI_SME_GET_ROAM_RSSI_RSP:
9263 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
9264 csrRoamRssiRspProcessor( pMac, pSirMsg );
9265 break;
9266#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009267 case eWNI_SME_GET_RSSI_REQ:
Mohit Khanna23863762012-09-11 17:40:09 -07009268 smsLog( pMac, LOG2, FL("GetRssiReq from self\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009269 csrUpdateRssi( pMac, pSirMsg );
9270 break;
9271
Jeff Johnson295189b2012-06-20 16:38:30 -07009272#ifdef WLAN_FEATURE_VOWIFI_11R
9273 case eWNI_SME_FT_PRE_AUTH_RSP:
9274 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
9275 break;
9276#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009277 case eWNI_SME_MAX_ASSOC_EXCEEDED:
9278 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
9279 smsLog( pMac, LOG1, FL("send indication that max assoc have been reached and the new peer cannot be accepted\n"));
9280 sessionId = pSmeMaxAssocInd->sessionId;
9281 roamInfo.sessionId = sessionId;
9282 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pSmeMaxAssocInd->peerMac, sizeof(tCsrBssid));
9283 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9284 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
9285 break;
9286
9287 case eWNI_SME_BTAMP_LOG_LINK_IND:
9288 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread\n"));
9289 btampEstablishLogLinkHdlr( pSirMsg );
9290 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07009291 case eWNI_SME_RSSI_IND:
9292 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread\n"));
9293 csrRoamRssiIndHdlr( pMac, pSirMsg );
9294 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009295
9296 default:
9297 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009298 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -07009299}
9300
Jeff Johnson295189b2012-06-20 16:38:30 -07009301void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
9302 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
9303{
9304 if(pSession)
9305 {
9306 if(pSession->bRefAssocStartCnt)
9307 {
9308 pSession->bRefAssocStartCnt--;
9309 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
9310 //Need to call association_completion because there is an assoc_start pending.
9311 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
9312 eCSR_ROAM_ASSOCIATION_COMPLETION,
9313 eCSR_ROAM_RESULT_FAILURE);
9314 }
9315 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
9316 }
9317 else
9318 {
9319 smsLog(pMac, LOGW, FL(" pSession is NULL"));
9320 }
9321}
9322
9323
9324eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
9325{
9326 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009327 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
9328 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
9329 {
9330 status = csrScanRequestLostLink1( pMac, sessionId );
9331 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009332 return(status);
9333}
9334
Jeff Johnson295189b2012-06-20 16:38:30 -07009335//return a boolean to indicate whether roaming completed or continue.
9336tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
9337 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
9338{
9339 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
9340 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
9341 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
9342 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009343 if(!pSession)
9344 {
9345 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9346 return eANI_BOOLEAN_FALSE;
9347 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009348 //Check whether time is up
9349 if(pSession->fCancelRoaming || fForce ||
9350 ((curTime - pSession->roamingStartTime) > roamTime) ||
9351 eCsrReassocRoaming == pSession->roamingReason ||
9352 eCsrDynamicRoaming == pSession->roamingReason)
9353 {
9354 smsLog(pMac, LOGW, FL(" indicates roaming completion\n"));
9355 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
9356 {
9357 //roaming is cancelled, tell HDD to indicate disconnect
9358 //Because LIM overload deauth_ind for both deauth frame and missed beacon
9359 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
9360 //to be eSIR_BEACON_MISSED
9361 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
9362 {
9363 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
9364 }
9365 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
9366 {
9367 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
9368 }
9369 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
9370 {
9371 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
9372 }
9373 else
9374 {
9375 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
9376 }
9377 }
9378 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
9379 pSession->roamingReason = eCsrNotRoaming;
9380 }
9381 else
9382 {
9383 pSession->roamResult = roamResult;
9384 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
9385 {
9386 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
9387 pSession->roamingReason = eCsrNotRoaming;
9388 }
9389 else
9390 {
9391 fCompleted = eANI_BOOLEAN_FALSE;
9392 }
9393 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009394 return(fCompleted);
9395}
9396
Jeff Johnson295189b2012-06-20 16:38:30 -07009397void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
9398{
9399 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009400
9401 if(!pSession)
9402 {
9403 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9404 return;
9405 }
9406
Jeff Johnson295189b2012-06-20 16:38:30 -07009407 if(CSR_IS_ROAMING(pSession))
9408 {
9409 smsLog(pMac, LOGW, " Cancelling roaming\n");
9410 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
9411 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
9412 {
9413 //No need to do anything in here because the handler takes care of it
9414 }
9415 else
9416 {
9417 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
9418 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
9419 //Roaming is stopped after here
9420 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
9421 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
9422 csrScanAbortMacScan(pMac);
9423 csrRoamStopRoamingTimer(pMac, sessionId);
9424 }
9425 }
9426}
9427
Jeff Johnson295189b2012-06-20 16:38:30 -07009428void csrRoamRoamingTimerHandler(void *pv)
9429{
9430 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9431 tpAniSirGlobal pMac = pInfo->pMac;
9432 tANI_U32 sessionId = pInfo->sessionId;
9433 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009434
9435 if(!pSession)
9436 {
9437 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9438 return;
9439 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009440
9441 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
9442 {
9443 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
9444 {
9445 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
9446 pSession->roamingReason = eCsrNotRoaming;
9447 }
9448 }
9449}
9450
Jeff Johnson295189b2012-06-20 16:38:30 -07009451eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
9452{
9453 eHalStatus status;
9454 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009455
9456 if(!pSession)
9457 {
9458 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9459 return eHAL_STATUS_FAILURE;
9460 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009461
9462 smsLog(pMac, LOG1, " csrScanStartRoamingTimer \n ");
9463 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
9464 status = palTimerStart(pMac->hHdd, pSession->hTimerRoaming, interval, eANI_BOOLEAN_FALSE);
9465
9466 return (status);
9467}
9468
Jeff Johnson295189b2012-06-20 16:38:30 -07009469eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
9470{
9471 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerRoaming));
9472}
9473
Jeff Johnson295189b2012-06-20 16:38:30 -07009474void csrRoamWaitForKeyTimeOutHandler(void *pv)
9475{
9476 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9477 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009478 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
9479
9480 smsLog(pMac, LOGW, "WaitForKey timer expired in state=%d sub-state=%d\n",
9481 pMac->roam.neighborRoamInfo.neighborRoamState,
9482 pMac->roam.curSubState[pInfo->sessionId]);
9483
Jeff Johnson295189b2012-06-20 16:38:30 -07009484 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
9485 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009486#ifdef FEATURE_WLAN_LFR
9487 if (csrNeighborRoamIsHandoffInProgress(pMac))
9488 {
9489 /*
9490 * Enable heartbeat timer when hand-off is in progress
9491 * and Key Wait timer expired.
9492 */
9493 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
9494 " (nHBCount=%d)\n",
9495 pMac->roam.configParam.HeartbeatThresh24);
9496 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
9497 pMac->roam.configParam.HeartbeatThresh24,
9498 NULL, eANI_BOOLEAN_FALSE);
9499 }
9500#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009501 smsLog(pMac, LOGW, " SME pre-auth state timeout. \n ");
9502 //Change the substate so command queue is unblocked.
9503 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, pInfo->sessionId);
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009504 if (pSession)
9505 {
9506 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
9507 {
9508 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9509 smeProcessPendingQueue(pMac);
9510 }
9511 else
9512 {
9513 smsLog(pMac, LOGW, "%s: could not post link up\n",
9514 __func__);
9515 }
9516 }
9517 else
9518 {
9519 smsLog(pMac, LOGW, "%s: session not found\n", __func__);
9520 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009521 }
9522
9523}
9524
Jeff Johnson295189b2012-06-20 16:38:30 -07009525eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
9526{
9527 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009528#ifdef FEATURE_WLAN_LFR
9529 if (csrNeighborRoamIsHandoffInProgress(pMac))
9530 {
9531 /* Disable heartbeat timer when hand-off is in progress */
9532 smsLog(pMac, LOG2, "%s: disabling HB timer in state=%d sub-state=%d\n",
9533 __func__,
9534 pMac->roam.neighborRoamInfo.neighborRoamState,
9535 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
9536 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
9537 }
9538#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009539 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer \n ");
9540 status = palTimerStart(pMac->hHdd, pMac->roam.hTimerWaitForKey, interval, eANI_BOOLEAN_FALSE);
9541
9542 return (status);
9543}
9544
Jeff Johnson295189b2012-06-20 16:38:30 -07009545eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
9546{
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009547 smsLog(pMac, LOG2, "WaitForKey timer stopped in state=%d sub-state=%d\n",
9548 pMac->roam.neighborRoamInfo.neighborRoamState,
9549 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
9550#ifdef FEATURE_WLAN_LFR
9551 if (csrNeighborRoamIsHandoffInProgress(pMac))
9552 {
9553 /*
9554 * Enable heartbeat timer when hand-off is in progress
9555 * and Key Wait timer got stopped for some reason
9556 */
9557 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
9558 " (nHBCount=%d)\n",
9559 pMac->roam.configParam.HeartbeatThresh24);
9560 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
9561 pMac->roam.configParam.HeartbeatThresh24,
9562 NULL, eANI_BOOLEAN_FALSE);
9563 }
9564#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009565 return (palTimerStop(pMac->hHdd, pMac->roam.hTimerWaitForKey));
9566}
9567
Jeff Johnson295189b2012-06-20 16:38:30 -07009568void csrRoamIbssJoinTimerHandler(void *pv)
9569{
9570 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9571 tpAniSirGlobal pMac = pInfo->pMac;
9572 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE;
9573 tANI_U32 sessionId = pInfo->sessionId;
9574 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009575
9576 if(!pSession)
9577 {
9578 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9579 return;
9580 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009581
9582 pSession->ibss_join_pending = FALSE;
9583 // JEZ100225: As of main/latest "tip", we are no longer doing this. Check on this.
9584 //csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
9585 // Send an IBSS stop request to PE
9586 csrRoamDisconnectInternal(pMac, sessionId, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07009587}
Jeff Johnson295189b2012-06-20 16:38:30 -07009588eHalStatus csrRoamStartIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
9589{
9590 eHalStatus status;
9591 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009592
9593 if(!pSession)
9594 {
9595 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9596 return eHAL_STATUS_FAILURE;
9597 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009598
9599 smsLog(pMac, LOG1, " csrRoamStartIbssJoinTimer \n ");
9600 pSession->ibssJoinTimerInfo.sessionId = (tANI_U8)sessionId;
9601 status = palTimerStart(pMac->hHdd, pSession->hTimerIbssJoining, interval, eANI_BOOLEAN_FALSE);
9602
9603 return (status);
9604}
Jeff Johnson295189b2012-06-20 16:38:30 -07009605eHalStatus csrRoamStopIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
9606{
9607 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerIbssJoining));
9608}
Jeff Johnson295189b2012-06-20 16:38:30 -07009609void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
9610 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
9611{
9612 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
9613 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009614 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9615 /* To silence the KW tool Null chaeck is added */
9616 if(!pSession)
9617 {
9618 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9619 return;
9620 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009621
9622 if(pCommand)
9623 {
9624 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009625 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009626 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009627 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
9628 {
9629 //if success, force roaming completion
9630 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
9631 }
9632 else
9633 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009634 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009635 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d\n"), roamResult);
9636 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
9637 }
9638}
9639
Jeff Johnson295189b2012-06-20 16:38:30 -07009640eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
9641{
9642 eHalStatus status = eHAL_STATUS_SUCCESS;
9643 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
9644 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
9645 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
9646 tCsrRoamInfo *pRoamInfo = NULL;
9647 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009648 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -07009649 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009650 /* To silence the KW tool Null chaeck is added */
9651 if(!pSession)
9652 {
9653 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9654 return eHAL_STATUS_FAILURE;
9655 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009656 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009657 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07009658 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
9659 if ( eWNI_SME_DISASSOC_IND == type )
9660 {
9661 result = eCSR_ROAM_RESULT_DISASSOC_IND;
9662 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
9663 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -07009664 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07009665 }
9666 else if ( eWNI_SME_DEAUTH_IND == type )
9667 {
9668 result = eCSR_ROAM_RESULT_DEAUTH_IND;
9669 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
9670 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -08009671 /* Convert into proper reason code */
9672 pSession->joinFailStatusCode.reasonCode =
9673 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
9674 eSIR_MAC_DISASSOC_LEAVING_BSS_REASON : pDeauthIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07009675 }
9676 else
9677 {
9678 smsLog(pMac, LOGW, FL("gets an unknown type (%d)\n"), type);
9679 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -07009680 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07009681 }
9682
9683 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -07009684 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07009685 {
9686 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
9687 }
9688
9689 if ( eWNI_SME_DISASSOC_IND == type )
9690 {
9691 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
9692 }
9693 else if ( eWNI_SME_DEAUTH_IND == type )
9694 {
9695 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
9696 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009697 if(!HAL_STATUS_SUCCESS(status))
9698 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009699 //If fail to send confirmation to PE, not to trigger roaming
9700 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009701 }
9702
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009703 //prepare to tell HDD to disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -07009704 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9705 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
9706 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07009707 if( eWNI_SME_DISASSOC_IND == type)
9708 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009709 //staMacAddr
9710 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDisassocIndMsg->peerMacAddr, sizeof(tSirMacAddr));
9711 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
9712 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009713 else if( eWNI_SME_DEAUTH_IND == type )
9714 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009715 //staMacAddr
9716 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDeauthIndMsg->peerMacAddr, sizeof(tSirMacAddr));
9717 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
9718 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009719 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)\n"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009720
9721 /* See if we can possibly roam. If so, start the roaming process and notify HDD
9722 that we are roaming. But if we cannot possibly roam, or if we are unable to
9723 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -07009724 if(fToRoam)
9725 {
9726 //Only remove the connected BSS in infrastructure mode
9727 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
9728 //Not to do anying for lostlink with WDS
9729 if( pMac->roam.configParam.nRoamingTime )
9730 {
9731 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
9732 ( eWNI_SME_DEAUTH_IND == type ) ?
9733 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
9734 {
9735 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9736 //For IBSS, we need to give some more info to HDD
9737 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
9738 {
9739 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9740 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
9741 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
9742 }
9743 else
9744 {
9745 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
9746 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009747 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009748 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
9749 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
9750 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
9751 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
9752 }
9753 else
9754 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009755 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07009756 fToRoam = eANI_BOOLEAN_FALSE;
9757 }
9758 }
9759 else
9760 {
9761 //We are told not to roam, indicate lostlink
9762 fToRoam = eANI_BOOLEAN_FALSE;
9763 }
9764 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009765 if(!fToRoam)
9766 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -07009767 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009768 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009769 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009770 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
9771 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
9772 * csrRoamCheckForLinkStatusChange API.
9773 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009774 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
9775 }
9776
9777 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -07009778 Still enable idle scan for polling in case concurrent sessions are running */
9779 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
9780 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009781 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07009782 }
9783 }
9784
9785 return (status);
9786}
9787
Jeff Johnson295189b2012-06-20 16:38:30 -07009788eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
9789{
9790 eHalStatus status = eHAL_STATUS_SUCCESS;
9791 tListElem *pEntry = NULL;
9792 tSmeCmd *pCommand = NULL;
9793 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009794
9795 if(!pSession)
9796 {
9797 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9798 return eHAL_STATUS_FAILURE;
9799 }
9800
Jeff Johnson295189b2012-06-20 16:38:30 -07009801 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009802 //Only remove the connected BSS in infrastructure mode
9803 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
9804 if(pMac->roam.configParam.nRoamingTime)
9805 {
9806 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
9807 {
9808 //before starting the lost link logic release the roam command for handoff
9809 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
9810 if(pEntry)
9811 {
9812 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
9813 }
9814 if(pCommand)
9815 {
9816 if (( eSmeCommandRoam == pCommand->command ) &&
9817 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
9818 {
9819 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9820 {
9821 csrReleaseCommandRoam( pMac, pCommand );
9822 }
9823 }
9824 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009825 smsLog( pMac, LOGW, "Lost link roaming started ...\n");
9826 }
9827 }
9828 else
9829 {
9830 //We are told not to roam, indicate lostlink
9831 status = eHAL_STATUS_FAILURE;
9832 }
9833
9834 return (status);
9835}
Jeff Johnson295189b2012-06-20 16:38:30 -07009836void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
9837{
9838 tListElem *pEntry;
9839 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07009840 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9841 if ( pEntry )
9842 {
9843 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9844 if ( eSmeCommandWmStatusChange == pCommand->command )
9845 {
9846 // Nothing to process in a Lost Link completion.... It just kicks off a
9847 // roaming sequence.
9848 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9849 {
9850 csrReleaseCommandWmStatusChange( pMac, pCommand );
9851 }
9852 else
9853 {
9854 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command\n");
9855 }
9856
9857 }
9858 else
9859 {
9860 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ...\n" );
9861 }
9862 }
9863 else
9864 {
9865 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ...\n" );
9866 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009867 smeProcessPendingQueue( pMac );
9868}
9869
Jeff Johnson295189b2012-06-20 16:38:30 -07009870void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
9871{
9872 eHalStatus status = eHAL_STATUS_FAILURE;
9873 tSirSmeRsp *pSirSmeMsg;
9874 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009875
9876 if(!pSession)
9877 {
9878 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
9879 return;
9880 }
9881
Jeff Johnson295189b2012-06-20 16:38:30 -07009882 switch ( pCommand->u.wmStatusChangeCmd.Type )
9883 {
9884 case eCsrDisassociated:
9885 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
9886 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
9887 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009888 case eCsrDeauthenticated:
9889 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
9890 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
9891 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009892 default:
9893 smsLog(pMac, LOGW, FL("gets an unknown command %d\n"), pCommand->u.wmStatusChangeCmd.Type);
9894 break;
9895 }
9896 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
9897 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
9898 {
9899 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
9900 {
9901 //This is not good
9902 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command\n"));
9903 }
9904 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009905 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
9906 // command here since there is nothing else to do.
9907 csrRoamWmStatusChangeComplete( pMac );
9908}
9909
Jeff Johnson295189b2012-06-20 16:38:30 -07009910//This function returns band and mode information.
9911//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
9912//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -07009913static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
9914 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -07009915{
Jeff Johnson295189b2012-06-20 16:38:30 -07009916 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
9917 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
9918 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07009919 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07009920
Jeff Johnson295189b2012-06-20 16:38:30 -07009921 //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 -07009922 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
9923 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
9924 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
9925 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009926 {
9927 switch( pMac->roam.configParam.uCfgDot11Mode )
9928 {
9929 case eCSR_CFG_DOT11_MODE_11A:
9930 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
9931 eBand = eCSR_BAND_5G;
9932 break;
9933 case eCSR_CFG_DOT11_MODE_11B:
9934 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
9935 eBand = eCSR_BAND_24;
9936 break;
9937 case eCSR_CFG_DOT11_MODE_11G:
9938 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
9939 eBand = eCSR_BAND_24;
9940 break;
9941 case eCSR_CFG_DOT11_MODE_11N:
9942 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
9943 eBand = eCSR_BAND_24;
9944 break;
9945 //case eCSR_CFG_DOT11_MODE_BEST:
9946 // cfgDot11Mode = eCSR_CFG_DOT11_MODE_BEST;
9947 // eBand = eCSR_BAND_24;
9948 // break;
9949 default:
9950 // Global dot11 Mode setting is 11a/b/g.
9951 // use the channel number to determine the Mode setting.
9952 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
9953 {
9954 eBand = pMac->roam.configParam.eBand;
9955 if(eCSR_BAND_24 == eBand)
9956 {
9957 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
9958 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
9959 }
9960 else
9961 {
9962 //prefer 5GHz
9963 eBand = eCSR_BAND_5G;
9964 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
9965 }
9966 }
9967 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
9968 {
9969 // channel is a 2.4GHz channel. Set mode to 11g.
9970 //
9971 // !!LAC - WiFi tests require IBSS networks to start in 11b mode without any change to the
9972 // default parameter settings on the adapter. We use ACU to start an IBSS through creation
9973 // of a startIBSS profile. this startIBSS profile has Auto MACProtocol and the
9974 // adapter property setting for dot11Mode is also AUTO. So in this case, let's start
9975 // the IBSS network in 11b mode instead of 11g mode.
9976 //
9977 // so this is for Auto=profile->MacProtocol && Auto=Global.dot11Mode && profile->channel is < 14,
9978 // then start the IBSS in b mode.
9979 //
9980 // Note: we used to have this start as an 11g IBSS for best performance... now to specify that
9981 // the user will have to set the do11Mode in the property page to 11g to force it.
9982 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
9983 eBand = eCSR_BAND_24;
9984 }
9985 else
9986 {
9987 // else, it's a 5.0GHz channel. Set mode to 11a.
9988 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
9989 eBand = eCSR_BAND_5G;
9990 }
9991 break;
9992 }//switch
9993 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
9994 else
9995 {
9996 //dot11 mode is set, lets pick the band
9997 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
9998 {
9999 // channel is Auto also.
10000 eBand = pMac->roam.configParam.eBand;
10001 if(eCSR_BAND_ALL == eBand)
10002 {
10003 //prefer 5GHz
10004 eBand = eCSR_BAND_5G;
10005 }
10006 }
10007 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10008 {
10009 eBand = eCSR_BAND_24;
10010 }
10011 else
10012 {
10013 eBand = eCSR_BAND_5G;
10014 }
10015 }
10016 if(pBand)
10017 {
10018 *pBand = eBand;
10019 }
10020
10021 if (operationChn == 14){
10022 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode \n"));
10023 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10024 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010025
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080010026 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
10027 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 -070010028 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010029#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010030 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010031#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010032 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
10033 {
10034 //We cannot do 11n here
10035 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10036 {
10037 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10038 }
10039 else
10040 {
10041 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10042 }
10043 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010044 return( cfgDot11Mode );
10045}
10046
Jeff Johnson295189b2012-06-20 16:38:30 -070010047eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
10048{
10049 eHalStatus status;
10050 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010051
10052 if(!pSession)
10053 {
10054 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10055 return eHAL_STATUS_FAILURE;
10056 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010057
10058#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10059 {
10060 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010061 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10062 if(pIbssLog)
10063 {
10064 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
10065 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10066 }
10067 }
10068#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010069 pSession->ibss_join_pending = FALSE;
10070 csrRoamStopIbssJoinTimer(pMac, sessionId );
10071 // Set the roaming substate to 'stop Bss request'...
10072 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
10073
10074 // attempt to stop the Bss (reason code is ignored...)
10075 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080010076 if(!HAL_STATUS_SUCCESS(status))
10077 {
10078 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
10079 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010080 return (status);
10081}
10082
Jeff Johnson295189b2012-06-20 16:38:30 -070010083//pNumChan is a caller allocated space with the sizeof pChannels
10084eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
10085{
10086
10087 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
10088 (tANI_U8 *)pChannels,
10089 pNumChan));
10090}
10091
Kiran4a17ebe2013-01-31 10:43:43 -080010092tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
10093{
10094 tANI_U32 cfgLength = 0;
10095 tANI_U16 cfgId = 0;
10096 tPowerdBm maxTxPwr = 0;
10097 tANI_U8 *pCountryInfo = NULL;
10098 eHalStatus status;
10099 tANI_U8 count = 0;
10100 tANI_U8 firstChannel;
10101 tANI_U8 maxChannels;
10102
10103 if (CSR_IS_CHANNEL_5GHZ(channel))
10104 {
10105 cfgId = WNI_CFG_MAX_TX_POWER_5;
10106 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
10107 }
10108 else if (CSR_IS_CHANNEL_24GHZ(channel))
10109 {
10110 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
10111 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
10112 }
10113 else
10114 return maxTxPwr;
10115
10116 status = palAllocateMemory(pMac->hHdd, (void **)&pCountryInfo, cfgLength);
10117 if (status != eHAL_STATUS_SUCCESS)
10118 {
10119 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10120 FL("%s: palAllocateMemory() failed, status = %d"),
10121 __FUNCTION__, status);
10122 goto error;
10123 }
10124 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
10125 if (status != eHAL_STATUS_SUCCESS)
10126 {
10127 goto error;
10128 }
10129 /* Identify the channel and maxtxpower */
10130 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
10131 {
10132 firstChannel = pCountryInfo[count++];
10133 maxChannels = pCountryInfo[count++];
10134 maxTxPwr = pCountryInfo[count++];
10135
10136 if ((channel >= firstChannel) &&
10137 (channel < (firstChannel + maxChannels)))
10138 {
10139 break;
10140 }
10141 }
10142
10143error:
10144 if (NULL != pCountryInfo)
10145 palFreeMemory(pMac->hHdd, pCountryInfo);
10146
10147 return maxTxPwr;
10148}
10149
10150
Jeff Johnson295189b2012-06-20 16:38:30 -070010151tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
10152{
10153 tANI_BOOLEAN fValid = FALSE;
10154 tANI_U32 idxValidChannels;
10155 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10156
10157 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
10158 {
10159 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
10160 {
10161 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
10162 {
10163 fValid = TRUE;
10164 break;
10165 }
10166 }
10167 }
10168 pMac->roam.numValidChannels = len;
10169 return fValid;
10170}
10171
Jeff Johnson295189b2012-06-20 16:38:30 -070010172tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
10173{
10174 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
10175 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010176 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
10177 {
10178 if(channel == pMac->scan.base40MHzChannels.channelList[i])
10179 {
10180 fValid = eANI_BOOLEAN_TRUE;
10181 break;
10182 }
10183 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010184 return (fValid);
10185}
10186
Jeff Johnson295189b2012-06-20 16:38:30 -070010187//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070010188 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070010189{
Jeff Johnsone7245742012-09-05 17:12:55 -070010190 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010191 tANI_U8 centerChn;
10192 tANI_U32 ChannelBondingMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010193 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
10194 {
10195 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
10196 }
10197 else
10198 {
10199 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
10200 }
10201 //Figure what the other side's CB mode
10202 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
10203 {
10204 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
10205 {
10206 if(pIes->HTInfo.present)
10207 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010208 /* This is called during INFRA STA/CLIENT and should use the merged value of
10209 * supported channel width and recommended tx width as per standard
10210 */
10211 smsLog(pMac, LOG1, "scws %u rtws %u sco %u\n",
10212 pIes->HTCaps.supportedChannelWidthSet,
10213 pIes->HTInfo.recommendedTxWidthSet,
10214 pIes->HTInfo.secondaryChannelOffset);
10215
10216 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
10217 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010218 else
Jeff Johnsone7245742012-09-05 17:12:55 -070010219 eRet = PHY_SINGLE_CHANNEL_CENTERED;
10220 switch (eRet) {
10221 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
10222 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
10223 break;
10224 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
10225 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
10226 break;
10227 case PHY_SINGLE_CHANNEL_CENTERED:
10228 default:
10229 centerChn = primaryChn;
10230 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010231 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010232 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070010233 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010234 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode\n", centerChn);
10235 //eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010236 }
10237 }
10238 }
10239 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010240 return eRet;
10241}
Jeff Johnson295189b2012-06-20 16:38:30 -070010242tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
10243{
10244 tANI_BOOLEAN fFound = FALSE;
10245 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010246 for( idx = 0; idx < pCipherList->numEntries; idx++ )
10247 {
10248 if( pCipherList->encryptionType[idx] == encryptionType )
10249 {
10250 fFound = TRUE;
10251 break;
10252 }
10253 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010254 return fFound;
10255}
Jeff Johnson295189b2012-06-20 16:38:30 -070010256tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
10257{
10258 tANI_BOOLEAN fFound = FALSE;
10259 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010260 for( idx = 0; idx < pAuthList->numEntries; idx++ )
10261 {
10262 if( pAuthList->authType[idx] == authType )
10263 {
10264 fFound = TRUE;
10265 break;
10266 }
10267 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010268 return fFound;
10269}
Jeff Johnson295189b2012-06-20 16:38:30 -070010270tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
10271{
10272 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
10273 tCsrScanResultFilter *pScanFilter = NULL;
10274 eHalStatus status = eHAL_STATUS_SUCCESS;
10275
10276 if(pProfile1 && pProfile2)
10277 {
10278 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
10279 if(HAL_STATUS_SUCCESS(status))
10280 {
10281 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
10282 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
10283 if(HAL_STATUS_SUCCESS(status))
10284 {
10285 fCheck = eANI_BOOLEAN_FALSE;
10286 do
10287 {
10288 tANI_U32 i;
10289 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
10290 {
10291 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
10292 pScanFilter->SSIDs.SSIDList[i].SSID.length,
10293 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
10294 if ( fCheck ) break;
10295 }
10296 if(!fCheck)
10297 {
10298 break;
10299 }
10300 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
10301 || pProfile2->BSSType != pProfile1->BSSType
10302 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
10303 )
10304 {
10305 fCheck = eANI_BOOLEAN_FALSE;
10306 break;
10307 }
10308#ifdef WLAN_FEATURE_VOWIFI_11R
10309 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
10310 {
10311 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
10312 {
10313 fCheck = eANI_BOOLEAN_FALSE;
10314 break;
10315 }
10316 }
10317#endif
10318 //Match found
10319 fCheck = eANI_BOOLEAN_TRUE;
10320 }while(0);
10321 csrFreeScanFilter(pMac, pScanFilter);
10322 }
10323 palFreeMemory(pMac->hHdd, pScanFilter);
10324 }
10325 }
10326
10327 return (fCheck);
10328}
10329
Jeff Johnson295189b2012-06-20 16:38:30 -070010330tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
10331{
10332 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
10333 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010334 do
10335 {
10336 //Only check for static WEP
10337 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
10338 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
10339 {
10340 fCheck = eANI_BOOLEAN_TRUE;
10341 break;
10342 }
10343 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
10344 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
10345 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
10346 {
10347 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
10348 if(!palEqualMemory(pMac->hHdd, &pConnProfile->Keys.KeyMaterial[i],
10349 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
10350 {
10351 break;
10352 }
10353 }
10354 if( i == CSR_MAX_NUM_KEY)
10355 {
10356 fCheck = eANI_BOOLEAN_TRUE;
10357 }
10358 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010359 return (fCheck);
10360}
10361
Jeff Johnson295189b2012-06-20 16:38:30 -070010362//IBSS
10363
Jeff Johnson295189b2012-06-20 16:38:30 -070010364tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
10365{
10366 tANI_U8 channel = 0;
10367 tANI_U32 idx;
10368 tANI_U32 idxValidChannels;
10369 tANI_BOOLEAN fFound = FALSE;
10370 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10371
10372 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
10373 {
10374 channel = pMac->roam.configParam.AdHocChannel5G;
10375 if(!csrRoamIsChannelValid(pMac, channel))
10376 {
10377 channel = 0;
10378 }
10379 }
10380 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
10381 {
10382 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
10383 {
10384 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
10385 {
10386 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
10387 {
10388 fFound = TRUE;
10389 channel = csrStartIbssChannels50[ idx ];
10390 }
10391 }
10392 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010393 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
10394 if (!fFound)
10395 {
10396 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
10397 {
10398 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idx ]) ) // the max channel# in 11g is 14
10399 {
10400 channel = csrStartIbssChannels50[ idx ];
10401 break;
10402 }
10403 }
10404 }
10405 }//if
10406
10407 return( channel );
10408}
10409
Jeff Johnson295189b2012-06-20 16:38:30 -070010410tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
10411{
10412 tANI_U8 channel = 1;
10413 tANI_U32 idx;
10414 tANI_U32 idxValidChannels;
10415 tANI_BOOLEAN fFound = FALSE;
10416 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10417
10418 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
10419 {
10420 channel = pMac->roam.configParam.AdHocChannel24;
10421 if(!csrRoamIsChannelValid(pMac, channel))
10422 {
10423 channel = 0;
10424 }
10425 }
10426
10427 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
10428 {
10429 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
10430 {
10431 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
10432 {
10433 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
10434 {
10435 fFound = TRUE;
10436 channel = csrStartIbssChannels24[ idx ];
10437 }
10438 }
10439 }
10440 }
10441
10442 return( channel );
10443}
10444
Jeff Johnson295189b2012-06-20 16:38:30 -070010445static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10446 tCsrRoamStartBssParams *pParam )
10447{
10448 eCsrCfgDot11Mode cfgDot11Mode;
10449 eCsrBand eBand;
10450 tANI_U8 channel = 0;
10451 tSirNwType nwType;
10452 tANI_U8 operationChannel = 0;
10453
10454 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
10455 {
10456 operationChannel = pProfile->ChannelInfo.ChannelList[0];
10457 }
10458
Jeff Johnson295189b2012-06-20 16:38:30 -070010459 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070010460
Jeff Johnson295189b2012-06-20 16:38:30 -070010461 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
10462 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
10463 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
10464 )
10465 {
10466 /* This should never happen */
10467 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
10468 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B\n"),
10469 pProfile->csrPersona);
10470 VOS_ASSERT(0);
10471 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010472 switch( cfgDot11Mode )
10473 {
10474 case eCSR_CFG_DOT11_MODE_11G:
10475 nwType = eSIR_11G_NW_TYPE;
10476 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010477 case eCSR_CFG_DOT11_MODE_11B:
10478 nwType = eSIR_11B_NW_TYPE;
10479 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010480 case eCSR_CFG_DOT11_MODE_11A:
10481 nwType = eSIR_11A_NW_TYPE;
10482 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010483 default:
10484 case eCSR_CFG_DOT11_MODE_11N:
10485 case eCSR_CFG_DOT11_MODE_TAURUS:
10486 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
10487 if(eCSR_BAND_24 == eBand)
10488 {
10489 nwType = eSIR_11G_NW_TYPE;
10490 }
10491 else
10492 {
10493 nwType = eSIR_11A_NW_TYPE;
10494 }
10495 break;
10496 }
10497
10498 pParam->extendedRateSet.numRates = 0;
10499
10500 switch ( nwType )
10501 {
10502 default:
10503 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)\n"), nwType);
10504 case eSIR_11A_NW_TYPE:
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 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10518 {
10519 channel = csrRoamGetIbssStartChannelNumber50( pMac );
10520 if( 0 == channel &&
10521 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
10522 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
10523 )
10524 {
10525 //We could not find a 5G channel by auto pick, let's try 2.4G channels
10526 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
10527 nwType = eSIR_11B_NW_TYPE;
10528 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10529 pParam->operationalRateSet.numRates = 4;
10530 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10531 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10532 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10533 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
10534 }
10535 }
10536 else
10537 {
10538 channel = operationChannel;
10539 }
10540 break;
10541
10542 case eSIR_11B_NW_TYPE:
10543 pParam->operationalRateSet.numRates = 4;
10544 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10545 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10546 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10547 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070010548 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10549 {
10550 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10551 }
10552 else
10553 {
10554 channel = operationChannel;
10555 }
10556
10557 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010558 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070010559 /* For P2P Client and P2P GO, disable 11b rates */
10560 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
10561 (pProfile->csrPersona == VOS_P2P_GO_MODE)
10562 )
10563 {
10564 pParam->operationalRateSet.numRates = 8;
10565
10566 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
10567 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
10568 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
10569 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
10570 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
10571 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
10572 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
10573 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
10574 }
10575 else
Jeff Johnson295189b2012-06-20 16:38:30 -070010576 {
10577 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070010578 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10579 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10580 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10581 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
10582
10583 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070010584 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
10585 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
10586 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
10587 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
10588 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
10589 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
10590 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
10591 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
10592 }
10593
10594 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10595 {
10596 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10597 }
10598 else
10599 {
10600 channel = operationChannel;
10601 }
10602
10603 break;
10604 }
10605 pParam->operationChn = channel;
10606 pParam->sirNwType = nwType;
10607}
10608
Jeff Johnson295189b2012-06-20 16:38:30 -070010609static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
10610 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
10611{
10612
10613 if( pParam )
10614 {
10615 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070010616 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010617 pParam->operationChn = pBssDesc->channelId;
10618 palCopyMemory( pMac->hHdd, &pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid) );
10619
10620 if( pIes )
10621 {
10622 if(pIes->SuppRates.present)
10623 {
10624 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
10625 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
10626 {
10627 smsLog(pMac, LOGE, FL("num_rates :%d is more than SIR_MAC_RATESET_EID_MAX, resetting to SIR_MAC_RATESET_EID_MAX\n"),
10628 pIes->SuppRates.num_rates);
10629 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
10630 }
10631 palCopyMemory(pMac->hHdd, pParam->operationalRateSet.rate, pIes->SuppRates.rates,
10632 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
10633 }
10634 if( pIes->SSID.present )
10635 {
10636 pParam->ssId.length = pIes->SSID.num_ssid;
10637 palCopyMemory(pMac->hHdd, pParam->ssId.ssId, pIes->SSID.ssid, pParam->ssId.length);
10638 }
10639 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070010640 }
10641 else
10642 {
10643 pParam->ssId.length = 0;
10644 pParam->operationalRateSet.numRates = 0;
10645 }
10646 }
10647}
10648
Jeff Johnson295189b2012-06-20 16:38:30 -070010649static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
10650{
10651 tANI_U8 MaxRate = 0;
10652 tANI_U32 i;
10653 tANI_U8 *pRate;
10654
10655 pRate = pSirRateSet->rate;
10656 for ( i = 0; i < pSirRateSet->numRates; i++ )
10657 {
10658 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
10659 }
10660
10661 // Save the max rate in the connected state information...
10662
10663 // modify LastRates variable as well
10664
10665 return;
10666}
10667
Jeff Johnson295189b2012-06-20 16:38:30 -070010668//this function finds a valid secondary channel for channel bonding with "channel".
10669//Param: channel -- primary channel, caller must validate it
10670// cbChoice -- CB directory
10671//Return: if 0, no secondary channel is found. Otherwise a valid secondary channel.
10672static tANI_U8 csrRoamGetSecondaryChannel(tpAniSirGlobal pMac, tANI_U8 channel, eCsrCBChoice cbChoice)
10673{
10674 tANI_U8 chnUp = 0, chnDown = 0, chnRet = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010675 switch (cbChoice)
10676 {
10677 case eCSR_CB_OFF:
10678 chnUp = 0;
10679 chnDown = 0;
10680 break;
10681 case eCSR_CB_DOWN:
10682 chnUp = 0;
10683 chnDown = channel - CSR_CB_CHANNEL_GAP;
10684 break;
10685 case eCSR_CB_UP:
10686 chnUp = channel + CSR_CB_CHANNEL_GAP;
10687 chnDown = 0;
10688 break;
10689 case eCSR_CB_AUTO:
10690 //consider every other value means auto
10691 default:
10692 chnUp = channel + CSR_CB_CHANNEL_GAP;
10693 chnDown = channel - CSR_CB_CHANNEL_GAP;
10694 break;
10695 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010696 //if CB_UP or auto, try channel up first
10697 if(chnUp && CSR_IS_SAME_BAND_CHANNELS(chnUp, channel) && csrRoamIsChannelValid(pMac, chnUp))
10698 {
10699 //found a valid up channel for channel bonding
10700 //check whether the center channel is valid
10701 if(csrRoamIsValid40MhzChannel(pMac, channel + CSR_CB_CENTER_CHANNEL_OFFSET))
10702 {
10703 chnRet = chnUp;
10704 }
10705 }
10706 if(chnRet == 0 && chnDown && CSR_IS_SAME_BAND_CHANNELS(chnDown, channel) && csrRoamIsChannelValid(pMac, chnDown))
10707 {
10708 //found a valid down channel for channel bonding
10709 if(csrRoamIsValid40MhzChannel(pMac, channel - CSR_CB_CENTER_CHANNEL_OFFSET))
10710 {
10711 chnRet = chnDown;
10712 }
10713 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010714 return chnRet;
10715}
10716
Jeff Johnson295189b2012-06-20 16:38:30 -070010717eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
10718 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
10719{
10720 eHalStatus status = eHAL_STATUS_SUCCESS;
10721 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010722 // Set the roaming substate to 'Start BSS attempt'...
10723 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010724#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10725 //Need to figure out whether we need to log WDS???
10726 if( CSR_IS_IBSS( pProfile ) )
10727 {
10728 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010729 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10730 if(pIbssLog)
10731 {
10732 if(pBssDesc)
10733 {
10734 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
10735 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pBssDesc->bssId, 6);
10736 }
10737 else
10738 {
10739 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
10740 }
10741 palCopyMemory(pMac->hHdd, pIbssLog->ssid, pParam->ssId.ssId,
10742 pParam->ssId.length);
10743 if(pProfile->ChannelInfo.numOfChannels == 0)
10744 {
10745 pIbssLog->channelSetting = AUTO_PICK;
10746 }
10747 else
10748 {
10749 pIbssLog->channelSetting = SPECIFIED;
10750 }
10751 pIbssLog->operatingChannel = pParam->operationChn;
10752 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10753 }
10754 }
10755#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
10756 //Put RSN information in for Starting BSS
10757 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
10758 pParam->pRSNIE = pProfile->pRSNReqIE;
10759
Jeff Johnson295189b2012-06-20 16:38:30 -070010760 pParam->privacy = pProfile->privacy;
10761 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
10762 pParam->authType = pProfile->csr80211AuthType;
10763 pParam->beaconInterval = pProfile->beaconInterval;
10764 pParam->dtimPeriod = pProfile->dtimPeriod;
10765 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
10766 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
10767 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
10768 {
10769 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
10770 {
10771 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
10772 }
10773 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010774 pParam->protEnabled = pProfile->protEnabled;
10775 pParam->obssProtEnabled = pProfile->obssProtEnabled;
10776 pParam->ht_protection = pProfile->cfg_protection;
10777 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080010778
Jeff Johnson295189b2012-06-20 16:38:30 -070010779 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
10780 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070010781 pParam->bssPersona = pProfile->csrPersona;
10782 // When starting an IBSS, start on the channel from the Profile.
10783 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070010784 return (status);
10785}
10786
Jeff Johnson295189b2012-06-20 16:38:30 -070010787static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070010788 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070010789{
10790 tANI_U8 Channel, SecondChn;
Jeff Johnsone7245742012-09-05 17:12:55 -070010791 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010792 eCsrCBChoice cbChoice;
10793 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010794
10795 if(!pSession)
10796 {
10797 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10798 return;
10799 }
10800
Jeff Johnson295189b2012-06-20 16:38:30 -070010801 if( pBssDesc )
10802 {
10803 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
10804 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
10805 //The following code has to be do after that.
10806 //For WDS station, use selfMac as the self BSSID
10807 if( CSR_IS_WDS_STA( pProfile ) )
10808 {
10809 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, &pSession->selfMacAddr, sizeof(tCsrBssid));
10810 }
10811 }
10812 else
10813 {
10814 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070010815 //Use the first SSID
10816 if(pProfile->SSIDs.numOfSSIDs)
10817 {
10818 palCopyMemory(pMac->hHdd, &pSession->bssParams.ssId, pProfile->SSIDs.SSIDList, sizeof(tSirMacSSid));
10819 }
10820 //For WDS station, use selfMac as the self BSSID
10821 if( CSR_IS_WDS_STA( pProfile ) )
10822 {
10823 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, &pSession->selfMacAddr, sizeof(tCsrBssid));
10824 }
10825 //Use the first BSSID
10826 else if( pProfile->BSSIDs.numOfBSSIDs )
10827 {
10828 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, pProfile->BSSIDs.bssid, sizeof(tCsrBssid));
10829 }
10830 else
10831 {
10832 palZeroMemory( pMac->hHdd, &pSession->bssParams.bssid, sizeof(tCsrBssid) );
10833 }
10834 }
10835 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070010836 //Set operating channel in pProfile which will be used
10837 //in csrRoamSetBssConfigCfg() to determine channel bonding
10838 //mode and will be configured in CFG later
10839 pProfile->operationChannel = Channel;
10840
10841 if(Channel == 0)
10842 {
10843 smsLog(pMac, LOGW, " CSR cannot find a channel to start IBSS\n");
10844 }
10845 else
10846 {
10847
10848 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Jeff Johnsone7245742012-09-05 17:12:55 -070010849 if (CSR_IS_INFRA_AP(pProfile))
10850 {
10851 if(CSR_IS_CHANNEL_24GHZ(Channel))
10852 {
10853 cbMode = pMac->roam.configParam.channelBondingMode24GHz;
10854 }
10855 else
10856 {
10857 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
10858 }
10859 smsLog(pMac, LOG1, "##softap cbMode %d\n", cbMode);
10860 pBssConfig->cbMode = cbMode;
10861 pSession->bssParams.cbMode = cbMode;
10862 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010863
10864 if( CSR_IS_START_IBSS( pProfile ) )
10865 {
10866 //TBH: channel bonding is not supported for Libra
10867 if( pProfile->ChannelInfo.ChannelList && eCSR_OPERATING_CHANNEL_AUTO != pProfile->ChannelInfo.ChannelList[0] )
10868 {
10869 Channel = pProfile->ChannelInfo.ChannelList[0];
10870 cbChoice = pProfile->CBMode;
10871 }
10872 else {
10873 cbChoice = pMac->roam.configParam.cbChoice;
10874 }
10875 pSession->bssParams.operationChn = Channel;
10876 //make sure channel is valid
10877 if(!csrRoamIsChannelValid(pMac, Channel))
10878 {
10879 //set Channel to 0 to let lim know this is invalid
10880 //We still send this request down to lim even though we know the channel is wrong because
10881 //lim will response with error and hdd's eWNI_SME_START_BSS_RSP handler will roam other profile (if any)
10882 Channel = 0;
10883 pSession->bssParams.operationChn = 0;
10884 }
10885 else {
10886 tANI_U32 ChannelBondingMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010887 if(CSR_IS_CHANNEL_24GHZ(Channel))
10888 {
10889 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
10890 }
10891 else
10892 {
10893 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
10894 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010895 //now we have a valid channel
10896 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
10897 {
10898 //let's pick a secondard channel
10899 SecondChn = csrRoamGetSecondaryChannel(pMac, Channel, cbChoice);
Jeff Johnson295189b2012-06-20 16:38:30 -070010900 if(SecondChn > Channel)
10901 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010902 cbMode = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010903 }
10904 else if(SecondChn && SecondChn < Channel)
10905 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010906 cbMode = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010907 }
10908 else
10909 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010910 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010911 }
10912 pSession->bssParams.cbMode = cbMode;
10913 }
10914 else
10915 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010916 pSession->bssParams.cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010917 }
10918 }
10919 }
10920 }
10921}
10922
Jeff Johnson295189b2012-06-20 16:38:30 -070010923static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
10924 tANI_BOOLEAN *pfSameIbss )
10925{
10926 eHalStatus status = eHAL_STATUS_SUCCESS;
10927 tANI_BOOLEAN fSameIbss = FALSE;
10928
10929 if ( csrIsConnStateIbss( pMac, sessionId ) )
10930 {
10931 // Check if any profile parameter has changed ? If any profile parameter
10932 // has changed then stop old BSS and start a new one with new parameters
10933 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
10934 {
10935 fSameIbss = TRUE;
10936 }
10937 else
10938 {
10939 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
10940 }
10941 }
10942 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
10943 {
10944 // Disassociate from the connected Infrastructure network...
10945 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
10946 }
10947 else
10948 {
10949 tBssConfigParam *pBssConfig;
10950
10951 status = palAllocateMemory(pMac->hHdd, (void **)&pBssConfig, sizeof(tBssConfigParam));
10952 if(HAL_STATUS_SUCCESS(status))
10953 {
10954 palZeroMemory(pMac->hHdd, pBssConfig, sizeof(tBssConfigParam));
10955 // there is no Bss description before we start an IBSS so we need to adopt
10956 // all Bss configuration parameters from the Profile.
10957 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
10958 if(HAL_STATUS_SUCCESS(status))
10959 {
10960 //save dotMode
10961 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
10962 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070010963 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070010964 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
10965 }
10966
10967 palFreeMemory(pMac->hHdd, pBssConfig);
10968 }//Allocate memory
10969 }
10970
10971 if(pfSameIbss)
10972 {
10973 *pfSameIbss = fSameIbss;
10974 }
10975 return( status );
10976}
10977
Jeff Johnson295189b2012-06-20 16:38:30 -070010978static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
10979 tSirSmeNewBssInfo *pNewBss )
10980{
10981 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010982
10983 if(!pSession)
10984 {
10985 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10986 return;
10987 }
10988
Jeff Johnson295189b2012-06-20 16:38:30 -070010989 if( pNewBss )
10990 {
10991 // Set the operating channel.
10992 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
10993 // move the BSSId from the BSS description into the connected state information.
10994 palCopyMemory( pMac->hHdd, &pSession->connectedProfile.bssid,
10995 &(pNewBss->bssId), sizeof( tCsrBssid ) );
10996 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010997 return;
10998}
10999
Jeff Johnson295189b2012-06-20 16:38:30 -070011000#ifdef FEATURE_WLAN_WAPI
11001eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
11002 tANI_U32 numItems )
11003{
11004 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11005 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011006 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11007 {
11008 smsLog(pMac, LOGE, FL(" Invalid session ID\n"));
11009 return status;
11010 }
11011 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d\n", numItems);
11012 pSession = CSR_GET_SESSION( pMac, sessionId );
11013 if(numItems <= CSR_MAX_BKID_ALLOWED)
11014 {
11015 status = eHAL_STATUS_SUCCESS;
11016 //numItems may be 0 to clear the cache
11017 pSession->NumBkidCache = (tANI_U16)numItems;
11018 if(numItems && pBKIDCache)
11019 {
11020 status = palCopyMemory( pMac->hHdd, pSession->BkidCacheInfo, pBKIDCache,
11021 sizeof(tBkidCacheInfo) * numItems );
11022 }
11023 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011024 return (status);
11025}
Jeff Johnson295189b2012-06-20 16:38:30 -070011026eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
11027 tBkidCacheInfo *pBkidCache)
11028{
11029 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11030 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011031 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11032 {
11033 smsLog(pMac, LOGE, FL(" Invalid session ID\n"));
11034 return status;
11035 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011036 pSession = CSR_GET_SESSION( pMac, sessionId );
11037 if(pNum && pBkidCache)
11038 {
11039 if(pSession->NumBkidCache == 0)
11040 {
11041 *pNum = 0;
11042 status = eHAL_STATUS_SUCCESS;
11043 }
11044 else if(*pNum >= pSession->NumBkidCache)
11045 {
11046 if(pSession->NumBkidCache > CSR_MAX_PMKID_ALLOWED)
11047 {
11048 smsLog(pMac, LOGE, FL("NumPmkidCache :%d is more than CSR_MAX_PMKID_ALLOWED, resetting to CSR_MAX_PMKID_ALLOWED\n"),
11049 pSession->NumBkidCache);
11050 pSession->NumBkidCache = CSR_MAX_PMKID_ALLOWED;
11051 }
11052 palCopyMemory( pMac->hHdd, pBkidCache, pSession->BkidCacheInfo,
11053 sizeof(tBkidCacheInfo) * pSession->NumBkidCache );
11054 *pNum = pSession->NumBkidCache;
11055 status = eHAL_STATUS_SUCCESS;
11056 }
11057 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011058 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070011059}
Jeff Johnson295189b2012-06-20 16:38:30 -070011060tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11061{
11062 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011063}
11064#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011065eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
11066 tPmkidCacheInfo *pPMKIDCache, tANI_U32 numItems )
11067{
11068 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11069 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011070
11071 if(!pSession)
11072 {
11073 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11074 return eHAL_STATUS_FAILURE;
11075 }
11076
Jeff Johnson295189b2012-06-20 16:38:30 -070011077 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d\n", numItems);
11078 if(numItems <= CSR_MAX_PMKID_ALLOWED)
11079 {
11080#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11081 {
11082 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
11083 palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type));
11084 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
11085 secEvent.encryptionModeMulticast =
11086 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
11087 secEvent.encryptionModeUnicast =
11088 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
11089 palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 );
11090 secEvent.authMode =
11091 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
11092 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
11093 }
11094#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011095 status = eHAL_STATUS_SUCCESS;
11096 //numItems may be 0 to clear the cache
11097 pSession->NumPmkidCache = (tANI_U16)numItems;
11098 if(numItems && pPMKIDCache)
11099 {
11100 status = palCopyMemory( pMac->hHdd, pSession->PmkidCacheInfo, pPMKIDCache,
11101 sizeof(tPmkidCacheInfo) * numItems );
11102 }
11103 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011104 return (status);
11105}
11106
Jeff Johnson295189b2012-06-20 16:38:30 -070011107tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11108{
11109 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
11110}
11111
Jeff Johnson295189b2012-06-20 16:38:30 -070011112eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
11113{
11114 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11115 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011116
11117 if(!pSession)
11118 {
11119 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11120 return eHAL_STATUS_FAILURE;
11121 }
11122
Jeff Johnson295189b2012-06-20 16:38:30 -070011123 if(pNum && pPmkidCache)
11124 {
11125 if(pSession->NumPmkidCache == 0)
11126 {
11127 *pNum = 0;
11128 status = eHAL_STATUS_SUCCESS;
11129 }
11130 else if(*pNum >= pSession->NumPmkidCache)
11131 {
11132 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
11133 {
11134 smsLog(pMac, LOGE, FL("NumPmkidCache :%d is more than CSR_MAX_PMKID_ALLOWED, resetting to CSR_MAX_PMKID_ALLOWED\n"),
11135 pSession->NumPmkidCache);
11136 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
11137 }
11138 palCopyMemory( pMac->hHdd, pPmkidCache, pSession->PmkidCacheInfo,
11139 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache );
11140 *pNum = pSession->NumPmkidCache;
11141 status = eHAL_STATUS_SUCCESS;
11142 }
11143 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011144 return (status);
11145}
11146
Jeff Johnson295189b2012-06-20 16:38:30 -070011147eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11148{
11149 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11150 tANI_U32 len;
11151 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011152
11153 if(!pSession)
11154 {
11155 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11156 return eHAL_STATUS_FAILURE;
11157 }
11158
Jeff Johnson295189b2012-06-20 16:38:30 -070011159 if(pLen)
11160 {
11161 len = *pLen;
11162 *pLen = pSession->nWpaRsnReqIeLength;
11163 if(pBuf)
11164 {
11165 if(len >= pSession->nWpaRsnReqIeLength)
11166 {
11167 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWpaRsnReqIE, pSession->nWpaRsnReqIeLength);
11168 }
11169 }
11170 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011171 return (status);
11172}
11173
Jeff Johnson295189b2012-06-20 16:38:30 -070011174eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11175{
11176 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11177 tANI_U32 len;
11178 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011179
11180 if(!pSession)
11181 {
11182 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11183 return eHAL_STATUS_FAILURE;
11184 }
11185
Jeff Johnson295189b2012-06-20 16:38:30 -070011186 if(pLen)
11187 {
11188 len = *pLen;
11189 *pLen = pSession->nWpaRsnRspIeLength;
11190 if(pBuf)
11191 {
11192 if(len >= pSession->nWpaRsnRspIeLength)
11193 {
11194 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWpaRsnRspIE, pSession->nWpaRsnRspIeLength);
11195 }
11196 }
11197 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011198 return (status);
11199}
Jeff Johnson295189b2012-06-20 16:38:30 -070011200#ifdef FEATURE_WLAN_WAPI
11201eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11202{
11203 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11204 tANI_U32 len;
11205 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011206
11207 if(!pSession)
11208 {
11209 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11210 return eHAL_STATUS_FAILURE;
11211 }
11212
Jeff Johnson295189b2012-06-20 16:38:30 -070011213 if(pLen)
11214 {
11215 len = *pLen;
11216 *pLen = pSession->nWapiReqIeLength;
11217 if(pBuf)
11218 {
11219 if(len >= pSession->nWapiReqIeLength)
11220 {
11221 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWapiReqIE, pSession->nWapiReqIeLength);
11222 }
11223 }
11224 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011225 return (status);
11226}
Jeff Johnson295189b2012-06-20 16:38:30 -070011227eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11228{
11229 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11230 tANI_U32 len;
11231 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011232
11233 if(!pSession)
11234 {
11235 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11236 return eHAL_STATUS_FAILURE;
11237 }
11238
Jeff Johnson295189b2012-06-20 16:38:30 -070011239 if(pLen)
11240 {
11241 len = *pLen;
11242 *pLen = pSession->nWapiRspIeLength;
11243 if(pBuf)
11244 {
11245 if(len >= pSession->nWapiRspIeLength)
11246 {
11247 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWapiRspIE, pSession->nWapiRspIeLength);
11248 }
11249 }
11250 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011251 return (status);
11252}
11253#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011254eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
11255{
11256 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
11257 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011258
11259 if(!pSession)
11260 {
11261 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11262 return (retStatus);
11263 }
11264
Jeff Johnson295189b2012-06-20 16:38:30 -070011265 if(CSR_IS_ROAMING(pSession))
11266 {
11267 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
11268 pSession->fRoaming = eANI_BOOLEAN_FALSE;
11269 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011270 return (retStatus);
11271}
11272
Jeff Johnson295189b2012-06-20 16:38:30 -070011273//This function remove the connected BSS from te cached scan result
11274eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
11275 tCsrRoamConnectedProfile *pConnProfile)
11276{
11277 eHalStatus status = eHAL_STATUS_FAILURE;
11278 tCsrScanResultFilter *pScanFilter = NULL;
11279 tListElem *pEntry;
11280 tCsrScanResult *pResult;
11281 tDot11fBeaconIEs *pIes;
11282 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070011283 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
11284 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
11285 {
11286 do
11287 {
11288 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
11289 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
11290 if(!HAL_STATUS_SUCCESS(status)) break;
11291 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
11292 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->BSSIDs.bssid, sizeof(tCsrBssid));
11293 if(!HAL_STATUS_SUCCESS(status)) break;
11294 palCopyMemory(pMac->hHdd, pScanFilter->BSSIDs.bssid, &pConnProfile->bssid, sizeof(tCsrBssid));
11295 pScanFilter->BSSIDs.numOfBSSIDs = 1;
11296 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
11297 {
11298 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->SSIDs.SSIDList, sizeof(tCsrSSIDInfo));
11299 if(!HAL_STATUS_SUCCESS(status)) break;
11300 palCopyMemory(pMac->hHdd, &pScanFilter->SSIDs.SSIDList[0].SSID, &pConnProfile->SSID, sizeof(tSirMacSSid));
11301 }
11302 pScanFilter->authType.numEntries = 1;
11303 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
11304 pScanFilter->BSSType = pConnProfile->BSSType;
11305 pScanFilter->EncryptionType.numEntries = 1;
11306 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
11307 pScanFilter->mcEncryptionType.numEntries = 1;
11308 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
11309 //We ignore the channel for now, BSSID should be enough
11310 pScanFilter->ChannelInfo.numOfChannels = 0;
11311 //Also ignore the following fields
11312 pScanFilter->uapsd_mask = 0;
11313 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
11314 pScanFilter->countryCode[0] = 0;
11315 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011316 csrLLLock(&pMac->scan.scanResultList);
11317 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
11318 while( pEntry )
11319 {
11320 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
11321 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
11322 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
11323 pScanFilter, NULL, NULL, NULL, &pIes);
11324 //Release the IEs allocated by csrMatchBSS is needed
11325 if( !pResult->Result.pvIes )
11326 {
11327 //need to free the IEs since it is allocated by csrMatchBSS
11328 palFreeMemory(pMac->hHdd, pIes);
11329 }
11330 if(fMatch)
11331 {
11332 //We found the one
11333 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
11334 {
11335 //Free the memory
11336 csrFreeScanResultEntry( pMac, pResult );
11337 }
11338 break;
11339 }
11340 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
11341 }//while
11342 csrLLUnlock(&pMac->scan.scanResultList);
11343 }while(0);
11344 if(pScanFilter)
11345 {
11346 csrFreeScanFilter(pMac, pScanFilter);
11347 palFreeMemory(pMac->hHdd, pScanFilter);
11348 }
11349 }
11350 return (status);
11351}
11352
Jeff Johnson295189b2012-06-20 16:38:30 -070011353//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070011354eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
11355{
11356 eHalStatus status = eHAL_STATUS_SUCCESS;
11357 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011358 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
11359 {
11360 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
11361 {
11362 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
11363 {
11364 //co-exist with IBSS or BT-AMP is not supported
11365 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d\n", sessionId );
11366 status = eHAL_STATUS_CSR_WRONG_STATE;
11367 break;
11368 }
11369 if( csrIsConnStateInfra( pMac, sessionId ) )
11370 {
11371 if( chnId &&
11372 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
11373 {
11374 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)\n",
11375 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
11376 status = eHAL_STATUS_CSR_WRONG_STATE;
11377 break;
11378 }
11379 }
11380 }
11381 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011382 return ( status );
11383}
11384
Jeff Johnson295189b2012-06-20 16:38:30 -070011385static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
11386{
11387 eHalStatus status = eHAL_STATUS_SUCCESS;
11388 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11389 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070011390
11391 if(!pSession)
11392 {
11393 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11394 return eHAL_STATUS_FAILURE;
11395 }
11396
Jeff Johnson295189b2012-06-20 16:38:30 -070011397 if ( csrIsConnStateIbss( pMac, sessionId ) )
11398 {
11399 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11400 }
11401 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11402 {
11403 // Disassociate from the connected Infrastructure network...
11404 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11405 }
11406 else
11407 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011408 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
11409 //Otherwise we need to add code to handle the
11410 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
11411 //send stop_bss to PE, before we can continue.
11412 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070011413 palZeroMemory(pMac->hHdd, &bssConfig, sizeof(tBssConfigParam));
11414 /* Assume HDD provide bssid in profile */
11415 palCopyMemory( pMac->hHdd, &pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0], sizeof(tCsrBssid) );
11416 // there is no Bss description before we start an WDS so we need
11417 // to adopt all Bss configuration parameters from the Profile.
11418 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
11419 if(HAL_STATUS_SUCCESS(status))
11420 {
11421 //Save profile for late use
11422 csrFreeRoamProfile( pMac, sessionId );
11423 if (HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
11424 (void **)&pSession->pCurRoamProfile,
11425 sizeof(tCsrRoamProfile))))
11426 {
11427 palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile));
11428 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
11429 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011430 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070011431 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070011432 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
11433 }
11434 }
11435
11436 return( status );
11437}
11438
Jeff Johnson295189b2012-06-20 16:38:30 -070011439////////////////////Mail box
11440
Jeff Johnson295189b2012-06-20 16:38:30 -070011441//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
11442//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
11443static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
11444 tSirBssDescription *pBssDescription,
11445 tANI_U8 *pBuf, tANI_U8 uapsdMask)
11446{
11447 tCsrChannelSet channelGroup;
11448 tSirMacCapabilityInfo *pAP_capabilityInfo;
11449 tAniBool fTmp;
11450 tANI_BOOLEAN found = FALSE;
11451 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080011452 tANI_S8 pwrLimit = 0;
11453 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011454 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
11455 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
11456 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
11457 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070011458 // 802.11h
11459 //We can do this because it is in HOST CPU order for now.
11460 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080011461 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
11462 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
11463 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011464 fTmp = (tAniBool)pal_cpu_to_be32(1);
11465 }
11466 else
11467 fTmp = (tAniBool)0;
11468
11469 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
11470 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool) );
11471 pBuf += sizeof(tAniBool);
11472 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080011473 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070011474 // This is required for 11k test VoWiFi Ent: Test 2.
11475 // We need the power capabilities for Assoc Req.
11476 // This macro is provided by the halPhyCfg.h. We pick our
11477 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080011478 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
11479 if (0 != pwrLimit)
11480 {
11481 *pBuf++ = pwrLimit;
11482 }
11483 else
11484 {
11485 *pBuf++ = MAX_STA_PWR_CAP_DBM;
11486 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011487 size = sizeof(pMac->roam.validChannelList);
11488 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
11489 {
11490 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
11491 for ( i = 0; i < size; i++)
11492 {
11493 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
11494
11495 }
11496 }
11497 else
11498 {
11499 smsLog(pMac, LOGE, FL("can not find any valid channel\n"));
11500 *pBuf++ = 0; //tSirSupChnl->numChnl
11501 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011502 //Check whether it is ok to enter UAPSD
11503#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11504 if( btcIsReadyForUapsd(pMac) )
11505#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
11506 {
11507 *pBuf++ = uapsdMask;
11508 }
11509#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11510 else
11511 {
11512 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)\n"), uapsdMask);
11513 *pBuf++ = 0;
11514 }
11515#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
11516
Jeff Johnson295189b2012-06-20 16:38:30 -070011517 // move the entire BssDescription into the join request.
11518 palCopyMemory( pMac->hHdd, pBuf, pBssDescription,
11519 pBssDescription->length + sizeof( pBssDescription->length ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070011520 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
11521}
11522
Jeff Johnson295189b2012-06-20 16:38:30 -070011523/*
11524 * The communication between HDD and LIM is thru mailbox (MB).
11525 * Both sides will access the data structure "tSirSmeJoinReq".
11526 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
11527 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
11528 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
11529 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
11530 */
11531eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011532 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011533{
11534 eHalStatus status = eHAL_STATUS_SUCCESS;
11535 tSirSmeJoinReq *pMsg;
11536 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011537 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070011538 tANI_U16 msgLen, wTmp, ieLen;
11539 tSirMacRateSet OpRateSet;
11540 tSirMacRateSet ExRateSet;
11541 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11542 tANI_U32 dwTmp;
11543 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Jeff Johnson32d95a32012-09-10 13:15:23 -070011544
11545 if(!pSession)
11546 {
11547 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11548 return eHAL_STATUS_FAILURE;
11549 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011550 /* To satisfy klockworks */
11551 if (NULL == pBssDescription)
11552 {
11553 smsLog(pMac, LOGE, FL(" pBssDescription is NULL\n"));
11554 return eHAL_STATUS_FAILURE;
11555 }
11556
Jeff Johnson295189b2012-06-20 16:38:30 -070011557 do {
11558 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
11559 pSession->joinFailStatusCode.reasonCode = 0;
11560 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
11561 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
11562 // IE fields, but the length field in the bssDescription needs to be interpreted to
11563 // determine length of the IE fields.
11564 //
11565 // So, take the size of the JoinReq, subtract the size of the bssDescription and
11566 // add in the length from the bssDescription (then add the size of the 'length' field
11567 // itself because that is NOT included in the length field).
11568 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
11569 pBssDescription->length + sizeof( pBssDescription->length ) +
11570 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 -070011571 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
11572 if ( !HAL_STATUS_SUCCESS(status) ) break;
11573 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011574 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011575 pMsg->length = pal_cpu_to_be16(msgLen);
11576 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011577 // sessionId
11578 *pBuf = (tANI_U8)sessionId;
11579 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011580 // transactionId
11581 *pBuf = 0;
11582 *( pBuf + 1 ) = 0;
11583 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070011584 // ssId
11585 if( pIes->SSID.present && pIes->SSID.num_ssid )
11586 {
11587 // ssId len
11588 *pBuf = pIes->SSID.num_ssid;
11589 pBuf++;
11590 palCopyMemory( pMac->hHdd, pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid );
11591 pBuf += pIes->SSID.num_ssid;
11592 }
11593 else
11594 {
11595 *pBuf = 0;
11596 pBuf++;
11597 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011598 // selfMacAddr
11599 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
11600 pBuf += sizeof(tSirMacAddr);
11601 // bsstype
11602 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
11603 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
11604 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tSirBssType) );
11605 pBuf += sizeof(tSirBssType);
11606 // dot11mode
11607 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
11608 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011609 //Persona
11610 *pBuf = (tANI_U8)pProfile->csrPersona;
11611 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070011612 //CBMode
11613 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
11614 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011615
11616 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070011617 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
11618
Jeff Johnson295189b2012-06-20 16:38:30 -070011619 // uapsdPerAcBitmask
11620 *pBuf = pProfile->uapsd_mask;
11621 pBuf++;
11622
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011623
11624
Jeff Johnson295189b2012-06-20 16:38:30 -070011625 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011626 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011627 {
11628 // OperationalRateSet
11629 if (OpRateSet.numRates) {
11630 *pBuf++ = OpRateSet.numRates;
11631 palCopyMemory(pMac->hHdd, pBuf, OpRateSet.rate, OpRateSet.numRates);
11632 pBuf += OpRateSet.numRates;
11633 } else *pBuf++ = 0;
11634 // ExtendedRateSet
11635 if (ExRateSet.numRates) {
11636 *pBuf++ = ExRateSet.numRates;
11637 palCopyMemory(pMac->hHdd, pBuf, ExRateSet.rate, ExRateSet.numRates);
11638 pBuf += ExRateSet.numRates;
11639 } else *pBuf++ = 0;
11640 }
11641 else
11642 {
11643 *pBuf++ = 0;
11644 *pBuf++ = 0;
11645 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011646 // rsnIE
11647 if ( csrIsProfileWpa( pProfile ) )
11648 {
11649 // Insert the Wpa IE into the join request
11650 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
11651 (tCsrWpaIe *)( wpaRsnIE ) );
11652 }
11653 else if( csrIsProfileRSN( pProfile ) )
11654 {
11655 // Insert the RSN IE into the join request
11656 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11657 (tCsrRSNIe *)( wpaRsnIE ) );
11658 }
11659#ifdef FEATURE_WLAN_WAPI
11660 else if( csrIsProfileWapi( pProfile ) )
11661 {
11662 // Insert the WAPI IE into the join request
11663 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11664 (tCsrWapiIe *)( wpaRsnIE ) );
11665 }
11666#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011667 else
11668 {
11669 ieLen = 0;
11670 }
11671 //remember the IE for future use
11672 if( ieLen )
11673 {
11674 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
11675 {
11676 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);
11677 ieLen = DOT11F_IE_RSN_MAX_LEN;
11678 }
11679#ifdef FEATURE_WLAN_WAPI
11680 if( csrIsProfileWapi( pProfile ) )
11681 {
11682 //Check whether we need to allocate more memory
11683 if(ieLen > pSession->nWapiReqIeLength)
11684 {
11685 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
11686 {
11687 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
11688 }
11689 status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWapiReqIE, ieLen);
11690 if(!HAL_STATUS_SUCCESS(status)) break;
11691 }
11692 pSession->nWapiReqIeLength = ieLen;
11693 palCopyMemory(pMac->hHdd, pSession->pWapiReqIE, wpaRsnIE, ieLen);
11694 wTmp = pal_cpu_to_be16( ieLen );
11695 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11696 pBuf += sizeof(tANI_U16);
11697 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11698 pBuf += ieLen;
11699 }
11700 else//should be WPA/WPA2 otherwise
11701#endif /* FEATURE_WLAN_WAPI */
11702 {
11703 //Check whether we need to allocate more memory
11704 if(ieLen > pSession->nWpaRsnReqIeLength)
11705 {
11706 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
11707 {
11708 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
11709 }
11710 status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnReqIE, ieLen);
11711 if(!HAL_STATUS_SUCCESS(status)) break;
11712 }
11713 pSession->nWpaRsnReqIeLength = ieLen;
11714 palCopyMemory(pMac->hHdd, pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
11715 wTmp = pal_cpu_to_be16( ieLen );
11716 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11717 pBuf += sizeof(tANI_U16);
11718 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11719 pBuf += ieLen;
11720 }
11721 }
11722 else
11723 {
11724 //free whatever old info
11725 pSession->nWpaRsnReqIeLength = 0;
11726 if(pSession->pWpaRsnReqIE)
11727 {
11728 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
11729 pSession->pWpaRsnReqIE = NULL;
11730 }
11731#ifdef FEATURE_WLAN_WAPI
11732 pSession->nWapiReqIeLength = 0;
11733 if(pSession->pWapiReqIE)
11734 {
11735 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
11736 pSession->pWapiReqIE = NULL;
11737 }
11738#endif /* FEATURE_WLAN_WAPI */
11739 //length is two bytes
11740 *pBuf = 0;
11741 *(pBuf + 1) = 0;
11742 pBuf += 2;
11743 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011744#ifdef FEATURE_WLAN_CCX
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011745 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011746 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011747 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070011748 //length is two bytes
11749 *pBuf = 0;
11750 *(pBuf + 1) = 0;
11751 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011752 }
11753 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011754 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011755 // cckmIE
11756 if( csrIsProfileCCX( pProfile ) )
11757 {
11758 // Insert the CCKM IE into the join request
11759 ieLen = csrConstructCcxCckmIe( pMac,
11760 pSession,
11761 pProfile,
11762 pBssDescription,
11763 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070011764 pSession->nWpaRsnReqIeLength,
11765 (void *)( wpaRsnIE ) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011766 }
11767 else
11768 {
11769 ieLen = 0;
11770 }
11771 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
11772 if( ieLen )
11773 {
11774 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
11775 wTmp = pal_cpu_to_be16( ieLen );
11776 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11777 pBuf += sizeof(tANI_U16);
11778 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11779 pBuf += ieLen;
11780 }
11781 else
11782 {
11783 //Indicate you have no CCKM IE
11784 //length is two bytes
11785 *pBuf = 0;
11786 *(pBuf + 1) = 0;
11787 pBuf += 2;
11788 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011789 }
11790#endif /* FEATURE_WLAN_CCX */
Jeff Johnson295189b2012-06-20 16:38:30 -070011791 // addIEScan
11792 if(pProfile->nAddIEScanLength && pProfile->pAddIEScan)
11793 {
11794 ieLen = pProfile->nAddIEScanLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070011795 if(ieLen > pSession->nAddIEScanLength)
11796 {
11797 if(pSession->pAddIEScan && pSession->nAddIEScanLength)
11798 {
11799 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
11800 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011801 status = palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070011802 (void **)&pSession->pAddIEScan, ieLen);
11803 if(!HAL_STATUS_SUCCESS(status)) break;
11804 }
11805 pSession->nAddIEScanLength = ieLen;
11806 palCopyMemory(pMac->hHdd, pSession->pAddIEScan,
11807 pProfile->pAddIEScan, ieLen);
11808 wTmp = pal_cpu_to_be16( ieLen );
11809 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11810 pBuf += sizeof(tANI_U16);
11811 palCopyMemory( pMac->hHdd, pBuf, pProfile->pAddIEScan, ieLen );
11812 pBuf += ieLen;
11813 }
11814 else
11815 {
11816 pSession->nAddIEScanLength = 0;
11817 if(pSession->pAddIEScan)
11818 {
11819 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
11820 pSession->pAddIEScan = NULL;
11821 }
11822 *pBuf = 0;
11823 *(pBuf + 1) = 0;
11824 pBuf += 2;
11825 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011826 // addIEAssoc
11827 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
11828 {
11829 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070011830 if(ieLen > pSession->nAddIEAssocLength)
11831 {
11832 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
11833 {
11834 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
11835 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011836 status = palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070011837 (void **)&pSession->pAddIEAssoc, ieLen);
11838 if(!HAL_STATUS_SUCCESS(status)) break;
11839 }
11840 pSession->nAddIEAssocLength = ieLen;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011841 palCopyMemory(pMac->hHdd, pSession->pAddIEAssoc,
Jeff Johnson295189b2012-06-20 16:38:30 -070011842 pProfile->pAddIEAssoc, ieLen);
11843 wTmp = pal_cpu_to_be16( ieLen );
11844 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11845 pBuf += sizeof(tANI_U16);
11846 palCopyMemory( pMac->hHdd, pBuf, pProfile->pAddIEAssoc, ieLen );
11847 pBuf += ieLen;
11848 }
11849 else
11850 {
11851 pSession->nAddIEAssocLength = 0;
11852 if(pSession->pAddIEAssoc)
11853 {
11854 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
11855 pSession->pAddIEAssoc = NULL;
11856 }
11857 *pBuf = 0;
11858 *(pBuf + 1) = 0;
11859 pBuf += 2;
11860 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011861
11862 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011863 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011864 //Unmask any AC in reassoc that is ACM-set
11865 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
11866 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011867 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011868 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
11869 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011870#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011871 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070011872#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011873 uapsd_mask &= ~(acm_mask);
11874 }
11875 else
11876 {
11877 uapsd_mask = 0;
11878 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011879 }
11880 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011881
Jeff Johnson295189b2012-06-20 16:38:30 -070011882 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
11883 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011884 pBuf += sizeof(tANI_U32);
11885
Jeff Johnson295189b2012-06-20 16:38:30 -070011886 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
11887 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011888 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070011889#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011890 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053011891 if (csrIsProfile11r( pProfile )
11892#ifdef FEATURE_WLAN_CCX
11893 && !((pIes->CCXVersion.present) && (pMac->roam.configParam.isCcxIniFeatureEnabled))
11894#endif
11895 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011896 {
11897 // is11Rconnection;
11898 dwTmp = pal_cpu_to_be32(TRUE);
11899 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11900 pBuf += sizeof(tAniBool);
11901 }
11902 else
11903 {
11904 // is11Rconnection;
11905 dwTmp = pal_cpu_to_be32(FALSE);
11906 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11907 pBuf += sizeof(tAniBool);
11908 }
11909#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011910#ifdef FEATURE_WLAN_CCX
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011911 /* A profile can not be both CCX and 11R. But an 802.11R AP
11912 * may be advertising support for CCX as well. So if we are
11913 * associating Open or explicitly CCX then we will get CCX.
11914 * If we are associating explictly 11R only then we will get
11915 * 11R.
11916 */
11917 if ((csrIsProfileCCX(pProfile) ||
11918 ((pIes->CCXVersion.present)
11919 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011920 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
11921 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
11922 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011923 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011924 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
11925 {
11926 // isCCXconnection;
11927 dwTmp = pal_cpu_to_be32(TRUE);
11928 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11929 pBuf += sizeof(tAniBool);
11930 }
11931 else
11932 {
11933 //isCCXconnection;
11934 dwTmp = pal_cpu_to_be32(FALSE);
11935 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11936 pBuf += sizeof(tAniBool);
11937 }
11938
11939 if (eWNI_SME_JOIN_REQ == messageType)
11940 {
11941 tCCXTspecInfo ccxTspec;
11942 // CCX-Tspec IEs in the ASSOC request is presently not supported
11943 // so nullify the TSPEC parameters
11944 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
11945 palCopyMemory( pMac->hHdd, pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
11946 pBuf += sizeof(tCCXTspecInfo);
11947 }
11948 else if (eWNI_SME_REASSOC_REQ == messageType)
11949 {
11950 if ((csrIsProfileCCX(pProfile) ||
11951 ((pIes->CCXVersion.present)
11952 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011953 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
11954 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
11955 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011956 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011957 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070011958 {
11959 tCCXTspecInfo ccxTspec;
Jeff Johnson295189b2012-06-20 16:38:30 -070011960 // CCX Tspec information
11961 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
11962 ccxTspec.numTspecs = sme_QosCCxRetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &ccxTspec.tspec[0]);
11963 *pBuf = ccxTspec.numTspecs;
11964 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070011965 // Copy the TSPEC information only if present
11966 if (ccxTspec.numTspecs) {
11967 palCopyMemory(pMac->hHdd, pBuf, (void*)&ccxTspec.tspec[0], (ccxTspec.numTspecs*sizeof(tTspecInfo)));
11968 }
11969 pBuf += sizeof(ccxTspec.tspec);
11970 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011971 else
Jeff Johnson295189b2012-06-20 16:38:30 -070011972 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011973 tCCXTspecInfo ccxTspec;
11974 // CCX-Tspec IEs in the ASSOC request is presently not supported
11975 // so nullify the TSPEC parameters
11976 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
11977 palCopyMemory( pMac->hHdd, pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
11978 pBuf += sizeof(tCCXTspecInfo);
11979 }
11980 }
11981#endif // FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011982#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070011983 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011984 if (pMac->roam.configParam.isFastTransitionEnabled
11985#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053011986 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011987#endif
11988 )
Jeff Johnson295189b2012-06-20 16:38:30 -070011989 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011990 dwTmp = pal_cpu_to_be32(TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011991 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011992 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070011993 }
11994 else
11995 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011996 dwTmp = pal_cpu_to_be32(FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011997 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011998 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070011999 }
12000#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070012001#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012002 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070012003 {
12004 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012005 dwTmp = pal_cpu_to_be32(TRUE);
Jeff Johnson43971f52012-07-17 12:26:56 -070012006 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012007 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012008 }
12009 else
12010 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012011 dwTmp = pal_cpu_to_be32(FALSE);
Jeff Johnson43971f52012-07-17 12:26:56 -070012012 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012013 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012014 }
12015#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012016
12017 // txLdpcIniFeatureEnabled
12018 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
12019 pBuf++;
12020
Kiran4a17ebe2013-01-31 10:43:43 -080012021 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
12022 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
12023 {
12024 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
12025 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
12026 csrApplyPower2Current(pMac);
12027 }
12028
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012029#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080012030 // txBFIniFeatureEnabled
12031 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
12032 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080012033
12034 // txBFCsnValue
12035 *pBuf = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
12036 pBuf++;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012037#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012038 //BssDesc
12039 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
12040 (tANI_U8)pProfile->uapsd_mask);
12041 status = palSendMBMessage(pMac->hHdd, pMsg );
12042 if(!HAL_STATUS_SUCCESS(status))
12043 {
12044 break;
12045 }
12046 else
12047 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012048#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012049 if (eWNI_SME_JOIN_REQ == messageType)
12050 {
12051 //Tush-QoS: notify QoS module that join happening
12052 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
12053 }
12054 else if (eWNI_SME_REASSOC_REQ == messageType)
12055 {
12056 //Tush-QoS: notify QoS module that reassoc happening
12057 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
12058 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012059#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012060 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012061 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012062 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070012063}
12064
Jeff Johnson295189b2012-06-20 16:38:30 -070012065//
12066eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12067{
12068 eHalStatus status = eHAL_STATUS_SUCCESS;
12069 tSirSmeDisassocReq *pMsg;
12070 tANI_U8 *pBuf;
12071 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012072 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12073 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12074 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012075 do {
12076 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDisassocReq ));
12077 if ( !HAL_STATUS_SUCCESS(status) ) break;
12078 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDisassocReq ));
12079 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
12080 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012081 pBuf = &pMsg->sessionId;
12082 // sessionId
12083 *pBuf++ = (tANI_U8)sessionId;
12084 // transactionId
12085 *pBuf = 0;
12086 *( pBuf + 1 ) = 0;
12087 pBuf += sizeof(tANI_U16);
12088
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053012089 if ( (pSession->pCurRoamProfile != NULL) &&
12090 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
12091 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012092 {
12093 // Set the bssid address before sending the message to LIM
12094 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pSession->selfMacAddr, sizeof( tSirMacAddr ) );
12095 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012096 // Set the peer MAC address before sending the message to LIM
12097 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ) ); //perMacAddr is passed as bssId for softAP
12098 pBuf = pBuf + sizeof ( tSirMacAddr );
12099 }
12100 else
12101 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012102 // Set the peer MAC address before sending the message to LIM
12103 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ) );
12104 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012105 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ) );
12106 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012107 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012108 if(!HAL_STATUS_SUCCESS(status))
12109 {
12110 palFreeMemory(pMac->hHdd, pMsg);
12111 break;
12112 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012113 // reasonCode
12114 wTmp = pal_cpu_to_be16(reasonCode);
12115 status = palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12116 if(!HAL_STATUS_SUCCESS(status))
12117 {
12118 palFreeMemory(pMac->hHdd, pMsg);
12119 break;
12120 }
12121 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012122 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
12123 Here we should not send the disassoc over the air to the AP */
12124 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
12125#ifdef WLAN_FEATURE_VOWIFI_11R
12126 && csrRoamIs11rAssoc(pMac)
12127#endif
12128 )
12129 {
12130 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
12131 }
12132 pBuf += sizeof(tANI_U8);
12133 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012134 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012135 return( status );
12136}
Jeff Johnson295189b2012-06-20 16:38:30 -070012137eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
12138{
12139 eHalStatus status = eHAL_STATUS_SUCCESS;
12140 tSirSmeTkipCntrMeasReq *pMsg;
12141 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012142 do
12143 {
12144 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeTkipCntrMeasReq ));
12145 if ( !HAL_STATUS_SUCCESS(status) ) break;
12146 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeTkipCntrMeasReq ));
12147 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
12148 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012149 pBuf = &pMsg->sessionId;
12150 // sessionId
12151 *pBuf++ = (tANI_U8)sessionId;
12152 // transactionId
12153 *pBuf = 0;
12154 *( pBuf + 1 ) = 0;
12155 pBuf += sizeof(tANI_U16);
12156 // bssid
12157 status = palCopyMemory( pMac->hHdd, pMsg->bssId, bssId, sizeof( tSirMacAddr ) );
12158 pBuf = pBuf + sizeof ( tSirMacAddr );
12159 // bEnable
12160 *pBuf = (tANI_BOOLEAN)bEnable;
12161 if(!HAL_STATUS_SUCCESS(status))
12162 {
12163 palFreeMemory(pMac->hHdd, pMsg);
12164 break;
12165 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012166 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012167 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012168 return( status );
12169}
Jeff Johnson295189b2012-06-20 16:38:30 -070012170eHalStatus
12171csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
12172 VOS_MODULE_ID modId, tSirMacAddr bssId,
12173 void *pUsrContext, void *pfnSapEventCallback,
12174 tANI_U8 *pAssocStasBuf )
12175{
12176 eHalStatus status = eHAL_STATUS_SUCCESS;
12177 tSirSmeGetAssocSTAsReq *pMsg;
12178 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
12179 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012180 do
12181 {
12182 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeGetAssocSTAsReq ) );
12183 if (!HAL_STATUS_SUCCESS(status)) break;
12184 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirSmeGetAssocSTAsReq ) );
12185 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012186 pBuf = (tANI_U8 *)&pMsg->bssId;
12187 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012188 // bssId
12189 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr) );
12190 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012191 // modId
12192 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
12193 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
12194 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012195 // pUsrContext
12196 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
12197 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12198 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012199 // pfnSapEventCallback
12200 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
12201 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12202 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012203 // pAssocStasBuf
12204 dwTmp = pal_cpu_to_be32((tANI_U32)pAssocStasBuf);
12205 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12206 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012207 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070012208 status = palSendMBMessage( pMac->hHdd, pMsg );
12209 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012210 return( status );
12211 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012212eHalStatus
12213csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
12214 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
12215 {
12216 eHalStatus status = eHAL_STATUS_SUCCESS;
12217 tSirSmeGetWPSPBCSessionsReq *pMsg;
12218 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
12219 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012220 do
12221 {
12222 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirSmeGetWPSPBCSessionsReq) );
12223 if (!HAL_STATUS_SUCCESS(status)) break;
12224 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ) );
12225 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012226 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
12227 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012228 // pUsrContext
12229 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
12230 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12231 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012232 // pSapEventCallback
12233 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
12234 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12235 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012236 // bssId
12237 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr) );
12238 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012239 // MAC Address of STA in WPS session
12240 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
12241 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070012242 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070012243 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012244 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012245 return( status );
12246}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012247
12248eHalStatus
12249csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
12250{
12251 tpSirChangeBIParams pMsg;
12252 tANI_U16 len = 0;
12253 eHalStatus status = eHAL_STATUS_SUCCESS;
12254 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12255
12256 if(!pSession)
12257 {
12258 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12259 return eHAL_STATUS_FAILURE;
12260 }
12261
12262 //NO need to update the Beacon Params if update beacon parameter flag is not set
12263 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
12264 return eHAL_STATUS_SUCCESS;
12265
12266 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
12267
12268 /* Create the message and send to lim */
12269 len = sizeof(tSirChangeBIParams);
12270 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, len );
12271 if(HAL_STATUS_SUCCESS(status))
12272 {
12273 palZeroMemory(pMac->hHdd, pMsg, sizeof(tSirChangeBIParams) );
12274 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
12275 pMsg->length = len;
12276
12277 // bssId
12278 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
12279 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= %02x-%02x-%02x-%02x-%02x-%02x "),
12280 pMsg->bssId[ 0 ], pMsg->bssId[ 1 ], pMsg->bssId[ 2 ],
12281 pMsg->bssId[ 3 ], pMsg->bssId[ 4 ], pMsg->bssId[ 5 ] );
12282 pMsg->sessionId = sessionId;
12283 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d\n"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
12284 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
12285 status = palSendMBMessage(pMac->hHdd, pMsg);
12286 }
12287 return status;
12288}
12289
Jeff Johnson295189b2012-06-20 16:38:30 -070012290eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12291{
12292 eHalStatus status = eHAL_STATUS_SUCCESS;
12293 tSirSmeDeauthReq *pMsg;
12294 tANI_U8 *pBuf;
12295 tANI_U16 wTmp;
12296 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12297 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12298 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012299 do {
12300 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDeauthReq ));
12301 if ( !HAL_STATUS_SUCCESS(status) ) break;
12302 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDeauthReq ));
12303 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
12304 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
12305 //sessionId
12306 pBuf = &pMsg->sessionId;
12307 *pBuf++ = (tANI_U8)sessionId;
12308
12309 //tansactionId
12310 *pBuf = 0;
12311 *(pBuf + 1 ) = 0;
12312 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012313 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070012314 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070012315 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
12316 // Set the BSSID before sending the message to LIM
12317 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pSession->selfMacAddr, sizeof( pMsg->peerMacAddr ) );
12318 pBuf = pBuf + sizeof(tSirMacAddr);
12319 }
12320 else
12321 {
12322 // Set the BSSID before sending the message to LIM
12323 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
12324 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012325 }
12326 if(!HAL_STATUS_SUCCESS(status))
12327 {
12328 palFreeMemory(pMac->hHdd, pMsg);
12329 break;
12330 }
12331 // Set the peer MAC address before sending the message to LIM
12332 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
12333 pBuf = pBuf + sizeof(tSirMacAddr);
12334 if(!HAL_STATUS_SUCCESS(status))
12335 {
12336 palFreeMemory(pMac->hHdd, pMsg);
12337 break;
12338 }
12339 wTmp = pal_cpu_to_be16(reasonCode);
12340 status = palCopyMemory( pMac->hHdd, pBuf, &wTmp,sizeof( tANI_U16 ) );
12341 if(!HAL_STATUS_SUCCESS(status))
12342 {
12343 palFreeMemory(pMac->hHdd, pMsg);
12344 break;
12345 }
12346 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012347 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012348 return( status );
12349}
12350
Jeff Johnson295189b2012-06-20 16:38:30 -070012351eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
12352{
12353 eHalStatus status = eHAL_STATUS_SUCCESS;
12354 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070012355 do {
12356 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDisassocCnf ));
12357 if ( !HAL_STATUS_SUCCESS(status) ) break;
12358 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDisassocCnf ));
12359 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
12360 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12361 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
12362 status = palCopyMemory(pMac->hHdd, pMsg->peerMacAddr, pDisassocInd->peerMacAddr, sizeof(pMsg->peerMacAddr));
12363 if(!HAL_STATUS_SUCCESS(status))
12364 {
12365 palFreeMemory(pMac->hHdd, pMsg);
12366 break;
12367 }
12368//To test reconn
12369 status = palCopyMemory(pMac->hHdd, pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
12370 if(!HAL_STATUS_SUCCESS(status))
12371 {
12372 palFreeMemory(pMac->hHdd, pMsg);
12373 break;
12374 }
12375//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070012376 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012377 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012378 return( status );
12379}
12380
Jeff Johnson295189b2012-06-20 16:38:30 -070012381eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
12382{
12383 eHalStatus status = eHAL_STATUS_SUCCESS;
12384 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070012385 do {
12386 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDeauthCnf ));
12387 if ( !HAL_STATUS_SUCCESS(status) ) break;
12388 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDeauthCnf ));
12389 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
12390 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12391 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
12392 status = palCopyMemory(pMac->hHdd, pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
12393 if(!HAL_STATUS_SUCCESS(status))
12394 {
12395 palFreeMemory(pMac->hHdd, pMsg);
12396 break;
12397 }
12398 status = palCopyMemory(pMac->hHdd, pMsg->peerMacAddr, pDeauthInd->peerMacAddr, sizeof(pMsg->peerMacAddr));
12399 if(!HAL_STATUS_SUCCESS(status))
12400 {
12401 palFreeMemory(pMac->hHdd, pMsg);
12402 break;
12403 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012404 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012405 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012406 return( status );
12407}
Jeff Johnson295189b2012-06-20 16:38:30 -070012408eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
12409{
12410 eHalStatus status = eHAL_STATUS_SUCCESS;
12411 tSirSmeAssocCnf *pMsg;
12412 tANI_U8 *pBuf;
12413 tSirResultCodes statusCode;
12414 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012415 do {
12416 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeAssocCnf ));
12417 if ( !HAL_STATUS_SUCCESS(status) ) break;
12418 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeAssocCnf ));
12419 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
12420 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012421 pBuf = (tANI_U8 *)&pMsg->statusCode;
12422 if(HAL_STATUS_SUCCESS(Halstatus))
12423 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12424 else
12425 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
12426 palCopyMemory( pMac->hHdd, pBuf, &statusCode, sizeof(tSirResultCodes) );
12427 pBuf += sizeof(tSirResultCodes);
12428 // bssId
12429 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12430 pBuf += sizeof (tSirMacAddr);
12431 // peerMacAddr
12432 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
12433 pBuf += sizeof (tSirMacAddr);
12434 // aid
12435 wTmp = pal_cpu_to_be16(pAssocInd->aid);
12436 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12437 pBuf += sizeof (tANI_U16);
12438 // alternateBssId
12439 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12440 pBuf += sizeof (tSirMacAddr);
12441 // alternateChannelId
12442 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070012443 status = palSendMBMessage( pMac->hHdd, pMsg );
12444 if(!HAL_STATUS_SUCCESS(status))
12445 {
12446 //pMsg is freed by palSendMBMessage
12447 break;
12448 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012449 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012450 return( status );
12451}
Jeff Johnson295189b2012-06-20 16:38:30 -070012452eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
12453 tpSirSmeAssocInd pAssocInd,
12454 eHalStatus Halstatus,
12455 tANI_U8 sessionId)
12456{
12457 tSirMsgQ msgQ;
12458 eHalStatus status = eHAL_STATUS_SUCCESS;
12459 tSirSmeAssocIndToUpperLayerCnf *pMsg;
12460 tANI_U8 *pBuf;
12461 tSirResultCodes statusCode;
12462 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012463 do {
12464 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ));
12465 if ( !HAL_STATUS_SUCCESS(status) ) break;
12466 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ));
Jeff Johnsone7245742012-09-05 17:12:55 -070012467
Jeff Johnson295189b2012-06-20 16:38:30 -070012468 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
12469 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
12470
12471 pMsg->sessionId = sessionId;
12472
12473 pBuf = (tANI_U8 *)&pMsg->statusCode;
12474 if(HAL_STATUS_SUCCESS(Halstatus))
12475 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12476 else
12477 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
12478 palCopyMemory( pMac->hHdd, pBuf, &statusCode, sizeof(tSirResultCodes) );
12479 pBuf += sizeof(tSirResultCodes);
12480 // bssId
12481 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12482 pBuf += sizeof (tSirMacAddr);
12483 // peerMacAddr
12484 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
12485 pBuf += sizeof (tSirMacAddr);
12486 // StaId
12487 wTmp = pal_cpu_to_be16(pAssocInd->staId);
12488 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12489 pBuf += sizeof (tANI_U16);
12490 // alternateBssId
12491 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12492 pBuf += sizeof (tSirMacAddr);
12493 // alternateChannelId
12494 *pBuf = 11;
12495 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012496 // Instead of copying roam Info, we just copy only WmmEnabled , RsnIE information
12497 //Wmm
12498 *pBuf = pAssocInd->wmmEnabledSta;
12499 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012500 //RSN IE
12501 status = palCopyMemory(pMac->hHdd, (tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
12502 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070012503 //Additional IE
12504 status = palCopyMemory(pMac->hHdd, (void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
12505 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070012506 //reassocReq
12507 *pBuf = pAssocInd->reassocReq;
12508 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012509 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
12510 msgQ.bodyptr = pMsg;
12511 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012512 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012513 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012514 return( status );
12515}
Jeff Johnson295189b2012-06-20 16:38:30 -070012516
Jeff Johnson295189b2012-06-20 16:38:30 -070012517eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId ,
12518 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
12519 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
12520 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
12521 tANI_U8 *pKeyRsc )
12522{
12523 tSirSmeSetContextReq *pMsg;
12524 tANI_U16 msgLen;
12525 eHalStatus status = eHAL_STATUS_FAILURE;
12526 tAniEdType tmpEdType;
12527 tAniKeyDirection tmpDirection;
12528 tANI_U8 *pBuf;
12529 tANI_U8 *p;
12530 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012531 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070012532 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012533 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
12534 // key set. Since we only support upto one key, we always allocate memory for 1 key
12535 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
12536 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
12537 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
12538 ( sizeof( pMsg->keyMaterial.key ) );
12539
12540 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12541 if ( !HAL_STATUS_SUCCESS(status) ) break;
12542 palZeroMemory(pMac->hHdd, pMsg, msgLen);
12543 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
12544 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012545 //sessionId
12546 pBuf = &pMsg->sessionId;
12547 *pBuf = (tANI_U8)sessionId;
12548 pBuf++;
12549 // transactionId
12550 *pBuf = 0;
12551 *(pBuf + 1) = 0;
12552 pBuf += sizeof(tANI_U16);
12553 // peerMacAddr
12554 palCopyMemory( pMac->hHdd, pBuf,
12555 (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr) );
12556
12557 pBuf += sizeof(tSirMacAddr);
12558
12559 // bssId
12560 palCopyMemory( pMac->hHdd, pBuf,
12561 (tANI_U8 *)&pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
12562
12563 pBuf += sizeof(tSirMacAddr);
12564
12565 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012566 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
12567 // in the tSirKeyMaterial keyMaterial; field).
12568 //
12569 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
12570 // shorter than this max size. Is LIM interpreting this ok ?
12571 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 -070012572 // set pMsg->keyMaterial.edType
12573 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
12574 palCopyMemory( pMac->hHdd, p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType) );
12575 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070012576 // set the pMsg->keyMaterial.numKeys field
12577 *p = numKeys;
12578 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070012579 // set pSirKey->keyId = keyId;
12580 *p = keyId;
12581 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012582 // set pSirKey->unicast = (tANI_U8)fUnicast;
12583 *p = (tANI_U8)fUnicast;
12584 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070012585 // set pSirKey->keyDirection = aniKeyDirection;
12586 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
12587 palCopyMemory( pMac->hHdd, p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection) );
12588 p += sizeof(tAniKeyDirection);
12589 // pSirKey->keyRsc = ;;
12590 palCopyMemory( pMac->hHdd, p, pKeyRsc, CSR_MAX_RSC_LEN );
12591 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070012592 // set pSirKey->paeRole
12593 *p = paeRole; // 0 is Supplicant
12594 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012595 // set pSirKey->keyLength = keyLength;
12596 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070012597 if ( keyLength && pKey )
12598 {
12599 palCopyMemory( pMac->hHdd, p, pKey, keyLength );
12600 if(keyLength == 16)
12601 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -070012602 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 -070012603 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
12604 pKey[5], pKey[6], pKey[7], pKey[8],
12605 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
12606 }
12607 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012608 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012609 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012610 return( status );
12611}
12612
Jeff Johnson295189b2012-06-20 16:38:30 -070012613eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
12614 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
12615{
12616 eHalStatus status;
12617 tSirSmeStartBssReq *pMsg;
12618 tANI_U8 *pBuf = NULL;
12619 tANI_U8 *wTmpBuf = NULL;
12620 tANI_U16 msgLen, wTmp;
12621 tANI_U32 dwTmp;
12622 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070012623 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012624 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070012625 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012626
12627 if(!pSession)
12628 {
12629 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12630 return eHAL_STATUS_FAILURE;
12631 }
12632
Jeff Johnson295189b2012-06-20 16:38:30 -070012633 do {
12634 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12635 pSession->joinFailStatusCode.reasonCode = 0;
12636 msgLen = sizeof(tSirSmeStartBssReq);
12637 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12638 if ( !HAL_STATUS_SUCCESS(status) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012639 palZeroMemory(pMac->hHdd, pMsg, msgLen);
12640 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012641 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012642 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012643 //sessionId
12644 *pBuf = (tANI_U8)sessionId;
12645 pBuf++;
12646 // transactionId
12647 *pBuf = 0;
12648 *(pBuf + 1) = 0;
12649 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012650 // bssid
12651 palCopyMemory( pMac->hHdd, pBuf, pParam->bssid, sizeof(tSirMacAddr) );
12652 pBuf += sizeof(tSirMacAddr);
12653 // selfMacAddr
12654 palCopyMemory( pMac->hHdd, pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr) );
12655 pBuf += sizeof(tSirMacAddr);
12656 // beaconInterval
12657 if( pBssDesc && pBssDesc->beaconInterval )
12658 {
12659 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
12660 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012661 else if(pParam->beaconInterval)
12662 {
12663 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
12664 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012665 else
12666 {
12667 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
12668 }
Jeff Johnsone7245742012-09-05 17:12:55 -070012669 if(csrIsconcurrentsessionValid (pMac, sessionId,
12670 pParam->bssPersona)
12671 == eHAL_STATUS_SUCCESS )
12672 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012673 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070012674 pParam->bssPersona);
12675 //Update the beacon Interval
12676 pParam->beaconInterval = wTmp;
12677 }
12678 else
12679 {
12680 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***\n"));
12681 status = eHAL_STATUS_FAILURE;
12682 return status;
12683 }
12684
Jeff Johnson295189b2012-06-20 16:38:30 -070012685 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof( tANI_U16 ) );
12686 pBuf += sizeof(tANI_U16);
12687 // dot11mode
12688 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
12689 pBuf += 1;
12690 // bssType
12691 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
12692 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tSirBssType) );
12693 pBuf += sizeof(tSirBssType);
12694 // ssId
12695 if( pParam->ssId.length )
12696 {
12697 // ssId len
12698 *pBuf = pParam->ssId.length;
12699 pBuf++;
12700 palCopyMemory( pMac->hHdd, pBuf, pParam->ssId.ssId, pParam->ssId.length );
12701 pBuf += pParam->ssId.length;
12702 }
12703 else
12704 {
12705 *pBuf = 0;
12706 pBuf++;
12707 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012708 // set the channel Id
12709 *pBuf = pParam->operationChn;
12710 pBuf++;
12711 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070012712 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
12713 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState) );
12714 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070012715
Jeff Johnson295189b2012-06-20 16:38:30 -070012716 // Set privacy
12717 *pBuf = pParam->privacy;
12718 pBuf++;
12719
12720 //Set Uapsd
12721 *pBuf = pParam->ApUapsdEnable;
12722 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012723 //Set SSID hidden
12724 *pBuf = pParam->ssidHidden;
12725 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012726 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
12727 pBuf++;
12728
12729 //Ht protection Enable/Disable
12730 *pBuf = (tANI_U8)pParam->protEnabled;
12731 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012732 //Enable Beacons to Receive for OBSS protection Enable/Disable
12733 *pBuf = (tANI_U8)pParam->obssProtEnabled;
12734 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012735 //set cfg related to protection
12736 wTmp = pal_cpu_to_be16( pParam->ht_protection );
12737 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof( tANI_U16 ) );
12738 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012739 // Set Auth type
12740 authType = pal_cpu_to_be32(pParam->authType);
12741 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
12742 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012743 // Set DTIM
12744 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
12745 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12746 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012747 // Set wps_state
12748 *pBuf = pParam->wps_state;
12749 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012750 //Persona
12751 *pBuf = (tANI_U8)pParam->bssPersona;
12752 pBuf++;
12753
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080012754 //txLdpcIniFeatureEnabled
12755 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
12756 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070012757
Jeff Johnson295189b2012-06-20 16:38:30 -070012758
12759 // set RSN IE
12760 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
12761 {
12762 status = eHAL_STATUS_INVALID_PARAMETER;
12763 palFreeMemory( pMac->hHdd, pMsg );
12764 break;
12765 }
12766 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
12767 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12768 pBuf += sizeof(tANI_U16);
12769 if( wTmp )
12770 {
12771 wTmp = pParam->nRSNIELength;
12772 palCopyMemory( pMac->hHdd, pBuf, pParam->pRSNIE, wTmp );
12773 pBuf += wTmp;
12774 }
12775 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
12776 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType) );
12777 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012778 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
12779 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012780 palCopyMemory( pMac->hHdd, pBuf, pParam->operationalRateSet.rate, pParam->operationalRateSet.numRates );
12781 pBuf += pParam->operationalRateSet.numRates ;
12782 *pBuf++ = pParam->extendedRateSet.numRates;
12783 if(0 != pParam->extendedRateSet.numRates)
12784 {
12785 palCopyMemory( pMac->hHdd, pBuf, pParam->extendedRateSet.rate, pParam->extendedRateSet.numRates );
12786 pBuf += pParam->extendedRateSet.numRates;
12787 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012788 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
12789 pMsg->length = pal_cpu_to_be16(msgLen);
12790
12791 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012792 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012793 return( status );
12794}
12795
Jeff Johnson295189b2012-06-20 16:38:30 -070012796eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
12797{
12798 eHalStatus status = eHAL_STATUS_FAILURE;
12799 tSirSmeStopBssReq *pMsg;
12800 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12801 tANI_U8 *pBuf;
12802 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012803
12804 if(!pSession)
12805 {
12806 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12807 return eHAL_STATUS_FAILURE;
12808 }
12809
Jeff Johnson295189b2012-06-20 16:38:30 -070012810 do {
12811 status = palAllocateMemory(pMac, (void **)&pMsg, sizeof(tSirSmeStopBssReq));
12812 if ( !HAL_STATUS_SUCCESS(status) ) break;
12813 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeStopBssReq ));
12814 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
12815 pBuf = &pMsg->sessionId;
12816 //sessionId
12817 *pBuf = (tANI_U8)sessionId;
12818 pBuf++;
12819 // transactionId
12820 *pBuf = 0;
12821 pBuf += sizeof(tANI_U16);
12822 //reason code
12823 *pBuf = 0;
12824 pBuf += sizeof(tSirResultCodes);
12825 // bssid
12826 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
12827 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
12828 {
12829 palCopyMemory( pMac->hHdd, pBuf,(tANI_U8 *)&pSession->selfMacAddr, sizeof(tSirMacAddr) );
12830 }
12831 else
12832 {
12833 palCopyMemory( pMac->hHdd, pBuf,(tANI_U8 *)&pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
12834 }
12835 pBuf += sizeof(tSirMacAddr);
12836 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
12837 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012838 status = palSendMBMessage( pMac->hHdd, pMsg );
12839#if 0
12840 status = palAllocateMemory(pMac, (void **)&pMsg, sizeof(tSirSmeStopBssReq));
12841 if ( !HAL_STATUS_SUCCESS(status) ) break;
12842 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeStopBssReq ));
12843 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
12844 pMsg->reasonCode = 0;
12845 // bssid
12846 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
12847 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
12848 {
12849 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
12850 }
12851 else
12852 {
12853 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
12854 }
12855 palCopyMemory( pMac->hHdd, &pMsg->bssId, pbBssid, sizeof(tSirMacAddr) );
12856 pMsg->transactionId = 0;
12857 pMsg->sessionId = (tANI_U8)sessionId;
12858 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
12859 status = palSendMBMessage( pMac->hHdd, pMsg );
12860#endif
12861 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012862 return( status );
12863}
12864
Jeff Johnson295189b2012-06-20 16:38:30 -070012865eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
12866 tCsrRoamModifyProfileFields *pModProfileFields,
12867 tANI_U32 *pRoamId, v_BOOL_t fForce)
12868{
Jeff Johnson295189b2012-06-20 16:38:30 -070012869 eHalStatus status = eHAL_STATUS_FAILURE;
12870 tANI_U32 roamId = 0;
12871 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012872 if((csrIsConnStateConnected(pMac, sessionId)) &&
12873 (fForce || (!palEqualMemory(pMac->hHdd, &pModProfileFields,
12874 &pSession->connectedProfile.modifyProfileFields,
12875 sizeof(tCsrRoamModifyProfileFields)))) )
12876 {
12877 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
12878 if(pRoamId)
12879 {
12880 *pRoamId = roamId;
12881 }
12882
Jeff Johnson295189b2012-06-20 16:38:30 -070012883 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
12884 eCsrSmeIssuedReassocToSameAP, roamId,
12885 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012886 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012887 return status;
12888}
Jeff Johnson295189b2012-06-20 16:38:30 -070012889static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
12890{
12891 eHalStatus status = eHAL_STATUS_SUCCESS;
12892 tCsrRoamInfo roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070012893 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
12894 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
12895 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
12896 return (status);
12897}
Jeff Johnson295189b2012-06-20 16:38:30 -070012898eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
12899{
12900 eHalStatus status = eHAL_STATUS_SUCCESS;
12901 tListElem *pEntry = NULL;
12902 tSmeCmd *pCommand = NULL;
12903 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012904 do
12905 {
12906 if(pMsg == NULL)
12907 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012908 smsLog(pMac, LOGE, "in %s msg ptr is NULL\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012909 status = eHAL_STATUS_FAILURE;
12910 break;
12911 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012912 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
12913 if(pEntry)
12914 {
12915 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
12916 if(eSmeCommandAddStaSession == pCommand->command)
12917 {
12918 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
12919 smsLog( pMac, LOG1, "Add Sta rsp status = %d\n", pRsp->status );
12920 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070012921 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070012922 //Remove this command out of the active list
12923 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
12924 {
12925 //Now put this command back on the avilable command list
12926 csrReleaseCommand(pMac, pCommand);
12927 }
12928 smeProcessPendingQueue( pMac );
12929 }
12930 else
12931 {
12932 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 -070012933 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012934 status = eHAL_STATUS_FAILURE;
12935 break;
12936 }
12937 }
12938 else
12939 {
12940 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 -070012941 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012942 status = eHAL_STATUS_FAILURE;
12943 break;
12944 }
12945 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012946 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012947}
Jeff Johnson295189b2012-06-20 16:38:30 -070012948eHalStatus csrSendMBAddSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
12949{
12950 tSirSmeAddStaSelfReq *pMsg;
12951 tANI_U16 msgLen;
12952 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012953 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070012954 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
12955 sizeof( tSirBssType )*/;
Jeff Johnson295189b2012-06-20 16:38:30 -070012956 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12957 if ( !HAL_STATUS_SUCCESS(status) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012958 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012959 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
12960 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012961 // self station address
12962 palCopyMemory( pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr, sizeof(tSirMacAddr) );
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -070012963 smsLog( pMac, LOG1, FL("selfMac=%02x, %02x, %02x, %02x, %02x, %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -070012964 pMsg->selfMacAddr[0],
12965 pMsg->selfMacAddr[1],
12966 pMsg->selfMacAddr[2],
12967 pMsg->selfMacAddr[3],
12968 pMsg->selfMacAddr[4],
12969 pMsg->selfMacAddr[5]);
12970 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012971 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012972 return( status );
12973}
Jeff Johnson295189b2012-06-20 16:38:30 -070012974eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr sessionMacAddr)
12975{
12976 eHalStatus status = eHAL_STATUS_SUCCESS;
12977 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070012978 pCommand = csrGetCommandBuffer(pMac);
12979 if(NULL == pCommand)
12980 {
12981 status = eHAL_STATUS_RESOURCES;
12982 }
12983 else
12984 {
12985 pCommand->command = eSmeCommandAddStaSession;
12986 pCommand->sessionId = (tANI_U8)sessionId;
12987 palCopyMemory( pMac->hHdd, pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr, sizeof( tSirMacAddr ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070012988 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
12989 if( !HAL_STATUS_SUCCESS( status ) )
12990 {
12991 //Should be panic??
12992 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
12993 }
12994 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012995 return (status);
12996}
Jeff Johnson295189b2012-06-20 16:38:30 -070012997eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
12998{
12999 return csrSendMBAddSelfStaReqMsg( pMac,
13000 pCommand->u.addStaSessionCmd.selfMacAddr );
13001}
Jeff Johnson295189b2012-06-20 16:38:30 -070013002eHalStatus csrRoamOpenSession( tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext,
13003 tANI_U8 *pSelfMacAddr, tANI_U8 *pbSessionId )
13004{
13005 eHalStatus status = eHAL_STATUS_SUCCESS;
13006 tANI_U32 i;
13007 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070013008 *pbSessionId = CSR_SESSION_ID_INVALID;
13009 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13010 {
13011 if( !CSR_IS_SESSION_VALID( pMac, i ) )
13012 {
13013 pSession = CSR_GET_SESSION( pMac, i );
13014 status = eHAL_STATUS_SUCCESS;
13015 pSession->sessionActive = eANI_BOOLEAN_TRUE;
13016 pSession->sessionId = (tANI_U8)i;
13017 pSession->callback = callback;
13018 pSession->pContext = pContext;
13019 palCopyMemory( pMac->hHdd, &pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid) );
13020 *pbSessionId = (tANI_U8)i;
Jeff Johnson295189b2012-06-20 16:38:30 -070013021 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerRoaming, csrRoamRoamingTimerHandler,
13022 &pSession->roamingTimerInfo);
13023 if(!HAL_STATUS_SUCCESS(status))
13024 {
13025 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer\n"));
13026 break;
13027 }
13028#ifdef FEATURE_WLAN_BTAMP_UT_RF
13029 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerJoinRetry, csrRoamJoinRetryTimerHandler,
13030 &pSession->joinRetryTimerInfo);
13031 if(!HAL_STATUS_SUCCESS(status))
13032 {
13033 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer\n"));
13034 break;
13035 }
13036#endif
13037 pSession->ibssJoinTimerInfo.pMac = pMac;
13038 pSession->ibssJoinTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Jeff Johnson295189b2012-06-20 16:38:30 -070013039 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerIbssJoining, csrRoamIbssJoinTimerHandler,
13040 &pSession->ibssJoinTimerInfo);
13041 if(!HAL_STATUS_SUCCESS(status))
13042 {
13043 smsLog(pMac, LOGE, FL("cannot allocate memory for IbssJoining timer\n"));
13044 break;
13045 }
13046 status = csrIssueAddStaForSessionReq ( pMac, i, pSelfMacAddr );
13047 break;
13048 }
13049 }
13050 if( CSR_ROAM_SESSION_MAX == i )
13051 {
13052 //No session is available
13053 status = eHAL_STATUS_RESOURCES;
13054 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013055 return ( status );
13056}
Jeff Johnson295189b2012-06-20 16:38:30 -070013057eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13058{
13059 eHalStatus status = eHAL_STATUS_SUCCESS;
13060 tListElem *pEntry = NULL;
13061 tSmeCmd *pCommand = NULL;
13062 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013063 do
13064 {
13065 if(pMsg == NULL)
13066 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013067 smsLog(pMac, LOGE, "in %s msg ptr is NULL\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013068 status = eHAL_STATUS_FAILURE;
13069 break;
13070 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013071 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
13072 if(pEntry)
13073 {
13074 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13075 if(eSmeCommandDelStaSession == pCommand->command)
13076 {
13077 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013078 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
13079 smsLog( pMac, LOG1, "Del Sta rsp status = %d\n", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013080 //This session is done.
13081 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013082 if(pCommand->u.delStaSessionCmd.callback)
13083 {
13084
13085 status = sme_ReleaseGlobalLock( &pMac->sme );
13086 if ( HAL_STATUS_SUCCESS( status ) )
13087 {
13088 pCommand->u.delStaSessionCmd.callback(
13089 pCommand->u.delStaSessionCmd.pContext);
13090 status = sme_AcquireGlobalLock( &pMac->sme );
13091 if (! HAL_STATUS_SUCCESS( status ) )
13092 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013093 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013094 return status;
13095 }
13096 }
13097 else {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013098 smsLog(pMac, LOGE, "%s: Failed to Release Lock\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013099 }
13100 }
13101
13102 //Remove this command out of the active list
13103 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
13104 {
13105 //Now put this command back on the avilable command list
13106 csrReleaseCommand(pMac, pCommand);
13107 }
13108 smeProcessPendingQueue( pMac );
13109 }
13110 else
13111 {
13112 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 -070013113 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013114 status = eHAL_STATUS_FAILURE;
13115 break;
13116 }
13117 }
13118 else
13119 {
13120 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 -070013121 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013122 status = eHAL_STATUS_FAILURE;
13123 break;
13124 }
13125 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013126 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013127}
Jeff Johnson295189b2012-06-20 16:38:30 -070013128eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
13129{
13130 tSirSmeDelStaSelfReq *pMsg;
13131 tANI_U16 msgLen;
13132 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013133 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013134 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
13135 sizeof( tSirBssType )*/;
Jeff Johnson295189b2012-06-20 16:38:30 -070013136 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
13137 if ( !HAL_STATUS_SUCCESS(status) ) break;
13138
13139 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013140 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
13141 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013142 // self station address
13143 palCopyMemory( pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr, sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013144 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013145 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013146 return( status );
13147}
Jeff Johnson295189b2012-06-20 16:38:30 -070013148eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
13149 tSirMacAddr sessionMacAddr,
13150 csrRoamSessionCloseCallback callback,
13151 void *pContext)
13152{
13153 eHalStatus status = eHAL_STATUS_SUCCESS;
13154 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070013155 pCommand = csrGetCommandBuffer(pMac);
13156 if(NULL == pCommand)
13157 {
13158 status = eHAL_STATUS_RESOURCES;
13159 }
13160 else
13161 {
13162 pCommand->command = eSmeCommandDelStaSession;
13163 pCommand->sessionId = (tANI_U8)sessionId;
13164 pCommand->u.delStaSessionCmd.callback = callback;
13165 pCommand->u.delStaSessionCmd.pContext = pContext;
13166 palCopyMemory( pMac->hHdd, pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr, sizeof( tSirMacAddr ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013167 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
13168 if( !HAL_STATUS_SUCCESS( status ) )
13169 {
13170 //Should be panic??
13171 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
13172 }
13173 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013174 return (status);
13175}
Jeff Johnson295189b2012-06-20 16:38:30 -070013176eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
13177{
13178 return csrSendMBDelSelfStaReqMsg( pMac,
13179 pCommand->u.delStaSessionCmd.selfMacAddr );
13180}
Jeff Johnson295189b2012-06-20 16:38:30 -070013181static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
13182{
13183 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
13184 tListElem *pEntry, *pNext;
13185 tSmeCmd *pCommand;
13186 tDblLinkList localList;
13187
13188 vos_mem_zero(&localList, sizeof(tDblLinkList));
13189 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
13190 {
13191 smsLog(pMac, LOGE, FL(" failed to open list"));
13192 return;
13193 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013194 csrLLLock(pList);
13195 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
13196 while(pEntry != NULL)
13197 {
13198 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
13199 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13200 if(pCommand->sessionId == sessionId)
13201 {
13202 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
13203 {
13204 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
13205 }
13206 }
13207 pEntry = pNext;
13208 }
13209 csrLLUnlock(pList);
13210
13211 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
13212 {
13213 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13214 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
13215 }
13216 csrLLClose(&localList);
13217}
13218
Jeff Johnson295189b2012-06-20 16:38:30 -070013219void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
13220{
13221 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13222 {
13223 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013224 csrRoamStop(pMac, sessionId);
13225 csrFreeConnectBssDesc(pMac, sessionId);
13226 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
13227 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
13228 palTimerFree(pMac->hHdd, pSession->hTimerRoaming);
13229#ifdef FEATURE_WLAN_BTAMP_UT_RF
13230 palTimerFree(pMac->hHdd, pSession->hTimerJoinRetry);
13231#endif
13232 palTimerFree(pMac->hHdd, pSession->hTimerIbssJoining);
13233 purgeSmeSessionCmdList(pMac, sessionId);
13234 purgeCsrSessionCmdList(pMac, sessionId);
13235 csrInitSession(pMac, sessionId);
13236 }
13237}
13238
Jeff Johnson295189b2012-06-20 16:38:30 -070013239eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
13240 tANI_BOOLEAN fSync,
13241 csrRoamSessionCloseCallback callback,
13242 void *pContext )
13243{
13244 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013245 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13246 {
13247 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13248 if(fSync)
13249 {
13250 csrCleanupSession(pMac, sessionId);
13251 }
13252 else
13253 {
13254 purgeSmeSessionCmdList(pMac, sessionId);
13255 purgeCsrSessionCmdList(pMac, sessionId);
13256 status = csrIssueDelStaForSessionReq( pMac, sessionId,
13257 pSession->selfMacAddr, callback, pContext);
13258 }
13259 }
13260 else
13261 {
13262 status = eHAL_STATUS_INVALID_PARAMETER;
13263 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013264 return ( status );
13265}
13266
Jeff Johnson295189b2012-06-20 16:38:30 -070013267static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
13268{
13269 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013270
13271 if(!pSession)
13272 {
13273 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13274 return;
13275 }
13276
Jeff Johnson295189b2012-06-20 16:38:30 -070013277 pSession->sessionActive = eANI_BOOLEAN_FALSE;
13278 pSession->sessionId = CSR_SESSION_ID_INVALID;
13279 pSession->callback = NULL;
13280 pSession->pContext = NULL;
13281 pSession->ibss_join_pending = FALSE;
13282 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
13283 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
13284 csrFreeRoamProfile( pMac, sessionId );
13285 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
13286 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
13287 csrFreeConnectBssDesc(pMac, sessionId);
13288 csrScanEnable(pMac);
13289 palZeroMemory( pMac->hHdd, &pSession->selfMacAddr, sizeof(tCsrBssid) );
13290 if(pSession->pWpaRsnReqIE)
13291 {
13292 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
13293 pSession->pWpaRsnReqIE = NULL;
13294 }
13295 pSession->nWpaRsnReqIeLength = 0;
13296 if(pSession->pWpaRsnRspIE)
13297 {
13298 palFreeMemory(pMac->hHdd, pSession->pWpaRsnRspIE);
13299 pSession->pWpaRsnRspIE = NULL;
13300 }
13301 pSession->nWpaRsnRspIeLength = 0;
13302#ifdef FEATURE_WLAN_WAPI
13303 if(pSession->pWapiReqIE)
13304 {
13305 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
13306 pSession->pWapiReqIE = NULL;
13307 }
13308 pSession->nWapiReqIeLength = 0;
13309 if(pSession->pWapiRspIE)
13310 {
13311 palFreeMemory(pMac->hHdd, pSession->pWapiRspIE);
13312 pSession->pWapiRspIE = NULL;
13313 }
13314 pSession->nWapiRspIeLength = 0;
13315#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070013316 if(pSession->pAddIEScan)
13317 {
13318 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
13319 pSession->pAddIEScan = NULL;
13320 }
13321 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013322 if(pSession->pAddIEAssoc)
13323 {
13324 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
13325 pSession->pAddIEAssoc = NULL;
13326}
13327 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013328}
13329
Jeff Johnson295189b2012-06-20 16:38:30 -070013330eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
13331{
13332 eHalStatus status = eHAL_STATUS_FAILURE;
13333 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070013334 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13335 {
13336 if( CSR_IS_SESSION_VALID( pMac, i ) )
13337 {
13338 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
13339 {
13340 //Found it
13341 status = eHAL_STATUS_SUCCESS;
13342 *pSessionId = i;
13343 break;
13344 }
13345 }
13346 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013347 return( status );
13348}
13349
Jeff Johnson295189b2012-06-20 16:38:30 -070013350//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
13351//session because for IBSS, the bssid changes.
13352static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
13353{
13354 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
13355 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070013356 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13357 {
13358 if( CSR_IS_SESSION_VALID( pMac, i ) )
13359 {
13360 pSession = CSR_GET_SESSION( pMac, i );
13361 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
13362 {
13363 //Found it
13364 nRet = i;
13365 break;
13366 }
13367 }
13368 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013369 return (nRet);
13370}
Jeff Johnson295189b2012-06-20 16:38:30 -070013371static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
13372{
13373 /* Update the current BSS info in ho control block based on connected
13374 profile info from pmac global structure */
13375
Jeff Johnson295189b2012-06-20 16:38:30 -070013376 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= %02x-%02x-%02x-%02x-%02x-%02x\n",
13377 bssid[ 0 ], bssid[ 1 ], bssid[ 2 ],
13378 bssid[ 3 ], bssid[ 4 ], bssid[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -070013379 /* Check for user misconfig of RSSI trigger threshold */
13380 pMac->roam.configParam.vccRssiThreshold =
13381 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
13382 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
13383 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070013384 /* Check for user misconfig of UL MAC Loss trigger threshold */
13385 pMac->roam.configParam.vccUlMacLossThreshold =
13386 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
13387 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070013388#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13389 {
13390 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013391 /* Indicate the neighbor roal algorithm about the connect indication */
13392 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
13393 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
13394 }
13395#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013396}
13397
Jeff Johnson295189b2012-06-20 16:38:30 -070013398static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
13399{
13400 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013401
13402 if(!pSession)
13403 {
13404 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13405 return;
13406 }
13407
Jeff Johnson295189b2012-06-20 16:38:30 -070013408 //Only to handle the case for Handover on infra link
13409 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
13410 {
13411 return;
13412 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013413 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
13414 csrRoamDeregStatisticsReq(pMac);
13415 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
13416#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13417 /* Indicate the neighbor roal algorithm about the disconnect indication */
13418 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
13419#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070013420
13421 //Remove this code once SLM_Sessionization is supported
13422 //BMPS_WORKAROUND_NOT_NEEDED
13423 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070013424 csrIsInfraApStarted( pMac ) &&
13425 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070013426 {
13427 pMac->roam.configParam.doBMPSWorkaround = 0;
13428 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013429}
13430
Jeff Johnson295189b2012-06-20 16:38:30 -070013431void csrRoamTlStatsTimerHandler(void *pv)
13432{
13433 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
13434 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013435 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
13436
Jeff Johnsone7245742012-09-05 17:12:55 -070013437 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
13438
Jeff Johnson295189b2012-06-20 16:38:30 -070013439#if 0
13440 // TODO Persession .???
13441 //req TL for stats
13442 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
13443 {
13444 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL\n"));
13445 }
13446 else
13447 {
13448 //save in SME
13449 csrRoamSaveStatsFromTl(pMac, tlStats);
13450 }
13451#endif
13452 if(!pMac->roam.tlStatsReqInfo.timerRunning)
13453 {
13454 if(pMac->roam.tlStatsReqInfo.periodicity)
13455 {
13456 //start timer
13457 status = palTimerStart(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer,
13458 pMac->roam.tlStatsReqInfo.periodicity * PAL_TIMER_TO_MS_UNIT, eANI_BOOLEAN_FALSE);
13459 if(!HAL_STATUS_SUCCESS(status))
13460 {
13461 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer\n"));
13462 return;
13463 }
13464 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
13465 }
13466 }
13467}
Jeff Johnson295189b2012-06-20 16:38:30 -070013468void csrRoamPeStatsTimerHandler(void *pv)
13469{
13470 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
13471 eHalStatus status;
13472 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
13473 VOS_STATUS vosStatus;
13474 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070013475 pPeStatsReqListEntry->timerRunning = FALSE;
13476 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
13477 {
13478 // If we entered here, meaning the timer could not be successfully
13479 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
13480
13481 /* Destroy the timer */
13482 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
13483 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13484 {
13485 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer\n"));
13486 }
13487
13488 // Free the entry
13489 palFreeMemory(pMac->hHdd, pPeStatsReqListEntry);
13490 pPeStatsReqListEntry = NULL;
13491 }
13492 else
13493 {
13494 if(!pPeStatsReqListEntry->rspPending)
13495 {
13496 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
13497 pPeStatsReqListEntry->staId);
13498 if(!HAL_STATUS_SUCCESS(status))
13499 {
13500 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE\n"));
13501 }
13502 else
13503 {
13504 pPeStatsReqListEntry->rspPending = TRUE;
13505 }
13506 }
13507
13508 //send down a req
13509 if(pPeStatsReqListEntry->periodicity &&
13510 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
13511 {
13512 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
13513 if(ePMC_FULL_POWER == powerState)
13514 {
13515 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
13516 {
13517 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
13518 }
13519 }
13520 else
13521 {
13522 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
13523 {
13524 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
13525 }
13526 }
13527 //start timer
13528 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
13529 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13530 {
13531 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer\n"));
13532 return;
13533 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013534 pPeStatsReqListEntry->timerRunning = TRUE;
13535
13536 }
13537
13538 }
13539}
Jeff Johnson295189b2012-06-20 16:38:30 -070013540void csrRoamStatsClientTimerHandler(void *pv)
13541{
13542 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070013543 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
13544 {
13545#if 0
13546 // TODO Stats fix for multisession
13547 //start the timer
13548 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
13549
13550 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13551 {
13552 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013553 }
13554#endif
13555 }
13556#if 0
13557 //send up the stats report
13558 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
13559 pStaEntry->staId, pStaEntry->pContext);
13560#endif
13561}
13562
13563
13564
Jeff Johnson295189b2012-06-20 16:38:30 -070013565eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
13566{
13567 tAniGetPEStatsReq *pMsg;
13568 eHalStatus status = eHAL_STATUS_SUCCESS;
13569 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetPEStatsReq));
13570 if ( !HAL_STATUS_SUCCESS(status) )
13571 {
13572 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to allocate mem for stats req \n");
13573 return status;
13574 }
13575 // need to initiate a stats request to PE
13576 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
13577 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
13578 pMsg->staId = staId;
13579 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070013580 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013581 if(!HAL_STATUS_SUCCESS(status))
13582 {
13583 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to send down the stats req \n");
13584 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013585 return status;
13586}
Jeff Johnson295189b2012-06-20 16:38:30 -070013587void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
13588{
13589 tAniGetPEStatsRsp *pSmeStatsRsp;
13590 eHalStatus status = eHAL_STATUS_FAILURE;
13591 tListElem *pEntry = NULL;
13592 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
13593 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
13594 tANI_U32 tempMask = 0;
13595 tANI_U8 counter = 0;
13596 tANI_U8 *pStats = NULL;
13597 tANI_U32 length = 0;
13598 v_PVOID_t pvosGCtx;
13599 v_S7_t rssi = 0;
13600 tANI_U32 *pRssi = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013601 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
13602 if(pSmeStatsRsp->rc)
13603 {
13604 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure\n"));
13605 goto post_update;
13606 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013607 tempMask = pSmeStatsRsp->statsMask;
13608 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070013609 /* subtract all statistics from this length, and after processing the entire
13610 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
13611 * in this 'stats' message.
13612 */
13613 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070013614 //new stats info from PE, fill up the stats strucutres in PMAC
13615 while(tempMask)
13616 {
13617 if(tempMask & 1)
13618 {
13619 switch(counter)
13620 {
13621 case eCsrSummaryStats:
Mohit Khanna23863762012-09-11 17:40:09 -070013622 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013623 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
13624 pStats, sizeof(tCsrSummaryStatsInfo));
13625 if(!HAL_STATUS_SUCCESS(status))
13626 {
13627 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy summary stats\n"));
13628 }
13629 pStats += sizeof(tCsrSummaryStatsInfo);
13630 length -= sizeof(tCsrSummaryStatsInfo);
13631 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013632 case eCsrGlobalClassAStats:
Mohit Khanna23863762012-09-11 17:40:09 -070013633 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013634 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classAStatsInfo,
13635 pStats, sizeof(tCsrGlobalClassAStatsInfo));
13636 if(!HAL_STATUS_SUCCESS(status))
13637 {
13638 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassA stats\n"));
13639 }
13640 pStats += sizeof(tCsrGlobalClassAStatsInfo);
13641 length -= sizeof(tCsrGlobalClassAStatsInfo);
13642 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013643 case eCsrGlobalClassBStats:
Mohit Khanna23863762012-09-11 17:40:09 -070013644 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013645 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classBStatsInfo,
13646 pStats, sizeof(tCsrGlobalClassBStatsInfo));
13647 if(!HAL_STATUS_SUCCESS(status))
13648 {
13649 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassB stats\n"));
13650 }
13651 pStats += sizeof(tCsrGlobalClassBStatsInfo);
13652 length -= sizeof(tCsrGlobalClassBStatsInfo);
13653 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013654 case eCsrGlobalClassCStats:
Mohit Khanna23863762012-09-11 17:40:09 -070013655 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013656 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classCStatsInfo,
13657 pStats, sizeof(tCsrGlobalClassCStatsInfo));
13658 if(!HAL_STATUS_SUCCESS(status))
13659 {
13660 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassC stats\n"));
13661 }
13662 pStats += sizeof(tCsrGlobalClassCStatsInfo);
13663 length -= sizeof(tCsrGlobalClassCStatsInfo);
13664 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013665 case eCsrPerStaStats:
Mohit Khanna23863762012-09-11 17:40:09 -070013666 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013667 if( CSR_MAX_STA > pSmeStatsRsp->staId )
13668 {
13669 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
13670 pStats, sizeof(tCsrPerStaStatsInfo));
13671 }
13672 else
13673 {
13674 status = eHAL_STATUS_FAILURE;
13675 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d\n"), pSmeStatsRsp->staId);
13676 VOS_ASSERT( 0 );
13677 }
13678 if(!HAL_STATUS_SUCCESS(status))
13679 {
13680 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats\n"));
13681 }
13682 pStats += sizeof(tCsrPerStaStatsInfo);
13683 length -= sizeof(tCsrPerStaStatsInfo);
13684 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013685 default:
13686 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type\n"));
13687 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013688 }
13689 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013690 tempMask >>=1;
13691 counter++;
13692 }
13693 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
13694 if (length != 0)
13695 {
13696 pRssi = (tANI_U32*)pStats;
13697 rssi = (v_S7_t)*pRssi;
13698 }
13699 else
13700 {
13701 /* If riva is not sending rssi, continue to use the hack */
13702 rssi = RSSI_HACK_BMPS;
13703 }
13704 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Jeff Johnson295189b2012-06-20 16:38:30 -070013705post_update:
13706 //make sure to update the pe stats req list
13707 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
13708 if(pEntry)
13709 {
13710 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
13711 pPeStaEntry->rspPending = FALSE;
13712
13713 }
13714 //check the one timer cases
13715 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
13716 if(pEntry)
13717 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013718 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013719 if(pTempStaEntry->timerExpired)
13720 {
13721 //send up the stats report
13722 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
13723 pTempStaEntry->staId, pTempStaEntry->pContext);
13724 //also remove from the client list
13725 csrRoamRemoveStatListEntry(pMac, pEntry);
13726 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013727 }
13728 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013729}
Jeff Johnson295189b2012-06-20 16:38:30 -070013730tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
13731{
13732 tListElem *pEntry = NULL;
13733 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013734 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070013735 if(!pEntry)
13736 {
13737 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070013738 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE\n");
Jeff Johnson295189b2012-06-20 16:38:30 -070013739 return NULL;
13740 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013741 while( pEntry )
13742 {
13743 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013744 if(pTempStaEntry->statsMask == statsMask)
13745 {
Mohit Khanna23863762012-09-11 17:40:09 -070013746 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found\n");
Jeff Johnson295189b2012-06-20 16:38:30 -070013747 break;
13748 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013749 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
13750 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013751 return pEntry;
13752}
13753
Jeff Johnson295189b2012-06-20 16:38:30 -070013754tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
13755 tANI_BOOLEAN update)
13756{
13757 tListElem *pEntry;
13758 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070013759 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070013760 if(!pEntry)
13761 {
13762 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070013763 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Jeff Johnson295189b2012-06-20 16:38:30 -070013764 "upper layer client(s)\n");
13765 return NULL;
13766 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013767 while( pEntry )
13768 {
13769 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013770 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
13771 (pTempStaEntry->statsMask == pStaEntry->statsMask))
13772 {
Mohit Khanna23863762012-09-11 17:40:09 -070013773 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found\n");
Jeff Johnson295189b2012-06-20 16:38:30 -070013774 if(update)
13775 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013776 pTempStaEntry->periodicity = pStaEntry->periodicity;
13777 pTempStaEntry->callback = pStaEntry->callback;
13778 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070013779 }
13780 break;
13781 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013782 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
13783 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013784 return pEntry;
13785}
Jeff Johnson295189b2012-06-20 16:38:30 -070013786tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
13787{
13788 tListElem *pEntry;
13789 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070013790 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070013791 if(!pEntry)
13792 {
13793 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070013794 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Jeff Johnson295189b2012-06-20 16:38:30 -070013795 "upper layer client(s)\n");
13796 return NULL;
13797 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013798 while( pEntry )
13799 {
13800 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013801 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
13802 {
Mohit Khanna23863762012-09-11 17:40:09 -070013803 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found\n");
Jeff Johnson295189b2012-06-20 16:38:30 -070013804 break;
13805 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013806 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
13807 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013808 return pEntry;
13809}
Jeff Johnson295189b2012-06-20 16:38:30 -070013810eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
13811 csrRoamLinkQualityIndCallback callback,
13812 void *pContext)
13813{
13814 pMac->roam.linkQualityIndInfo.callback = callback;
13815 pMac->roam.linkQualityIndInfo.context = pContext;
13816 if( NULL == callback )
13817 {
13818 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
13819 }
13820 else
13821 {
13822 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070013823 /* do we need to invoke the callback to notify client of initial value ?? */
13824 }
13825 return eHAL_STATUS_SUCCESS;
13826}
Jeff Johnson295189b2012-06-20 16:38:30 -070013827void csrRoamVccTrigger(tpAniSirGlobal pMac)
13828{
13829 eCsrRoamLinkQualityInd newVccLinkQuality;
13830 tANI_U32 ul_mac_loss = 0;
13831 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070013832 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
13833 /*-------------------------------------------------------------------------
13834 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070013835 Check for a change in link quality and notify client if necessary
13836 -------------------------------------------------------------------------*/
13837 ul_mac_loss_trigger_threshold =
13838 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070013839 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013840 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d\n",
13841 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070013842 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
13843 {
13844 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR \n");
13845 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
13846 }
13847 else
13848 {
13849 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD\n");
13850 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
13851 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013852 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
13853 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070013854 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
13855 {
13856 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary\n");
13857 if(NULL != pMac->roam.linkQualityIndInfo.callback)
13858 {
13859 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d\n",
13860 newVccLinkQuality );
13861
13862 /* we now invoke the callback once to notify client of initial value */
13863 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
13864 pMac->roam.linkQualityIndInfo.context );
13865 //event: EVENT_WLAN_VCC
13866 }
13867 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013868 pMac->roam.vccLinkQuality = newVccLinkQuality;
13869
Jeff Johnson295189b2012-06-20 16:38:30 -070013870}
Jeff Johnson295189b2012-06-20 16:38:30 -070013871VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
13872 v_U8_t rssiNotification,
13873 void * context)
13874{
13875 tpAniSirGlobal pMac = PMAC_STRUCT( context );
13876 eCsrRoamLinkQualityInd newVccLinkQuality;
13877 // TODO : Session info unavailable
13878 tANI_U32 sessionId = 0;
13879 VOS_STATUS status = VOS_STATUS_SUCCESS;
13880 /*-------------------------------------------------------------------------
13881 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070013882 Check for a change in link quality and notify client if necessary
13883 -------------------------------------------------------------------------*/
13884 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d\n",
13885 pMac->roam.configParam.vccRssiThreshold);
13886 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
13887 {
13888 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected\n");
13889 return VOS_STATUS_SUCCESS;
13890 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013891 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
13892 {
13893 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR\n");
13894 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
13895 }
13896 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
13897 {
13898 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD \n");
13899 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
13900 }
13901 else
13902 {
13903 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d\n", rssiNotification);
13904 //Set to this so the code below won't do anything
13905 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070013906 VOS_ASSERT(0);
13907 }
13908
Jeff Johnson295189b2012-06-20 16:38:30 -070013909 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
13910 {
13911 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary\n");
13912 if(NULL != pMac->roam.linkQualityIndInfo.callback)
13913 {
13914 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d\n",
13915 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070013916 /* we now invoke the callback once to notify client of initial value */
13917 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
13918 pMac->roam.linkQualityIndInfo.context );
13919 //event: EVENT_WLAN_VCC
13920 }
13921 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013922 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070013923 return status;
13924}
Jeff Johnson295189b2012-06-20 16:38:30 -070013925tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
13926 tDblLinkList *pStaList,
13927 tCsrStatsClientReqInfo *pStaEntry)
13928{
13929 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013930 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013931 //if same entity requested for same set of stats with different periodicity &
13932 // callback update it
13933 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
13934 {
13935
13936 status = palAllocateMemory(pMac->hHdd, (void **)&pNewStaEntry, sizeof(tCsrStatsClientReqInfo));
13937 if (!HAL_STATUS_SUCCESS(status))
13938 {
13939 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
13940 "entry\n");
13941 return NULL;
13942 }
13943
Jeff Johnson295189b2012-06-20 16:38:30 -070013944 pNewStaEntry->callback = pStaEntry->callback;
13945 pNewStaEntry->pContext = pStaEntry->pContext;
13946 pNewStaEntry->periodicity = pStaEntry->periodicity;
13947 pNewStaEntry->requesterId = pStaEntry->requesterId;
13948 pNewStaEntry->statsMask = pStaEntry->statsMask;
13949 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
13950 pNewStaEntry->pMac = pStaEntry->pMac;
13951 pNewStaEntry->staId = pStaEntry->staId;
13952 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
13953
13954 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
13955 }
13956 return pNewStaEntry;
13957}
13958
Jeff Johnson295189b2012-06-20 16:38:30 -070013959tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
13960 tDblLinkList *pStaList,
13961 tCsrPeStatsReqInfo *pStaEntry)
13962{
13963 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013964 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013965 status = palAllocateMemory(pMac->hHdd, (void **)&pNewStaEntry, sizeof(tCsrPeStatsReqInfo));
13966 if (!HAL_STATUS_SUCCESS(status))
13967 {
13968 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
13969 "entry\n");
13970 return NULL;
13971 }
13972
Jeff Johnson295189b2012-06-20 16:38:30 -070013973 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
13974 pNewStaEntry->numClient = pStaEntry->numClient;
13975 pNewStaEntry->periodicity = pStaEntry->periodicity;
13976 pNewStaEntry->statsMask = pStaEntry->statsMask;
13977 pNewStaEntry->pMac = pStaEntry->pMac;
13978 pNewStaEntry->staId = pStaEntry->staId;
13979 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
13980 pNewStaEntry->rspPending = pStaEntry->rspPending;
13981
13982 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070013983 return pNewStaEntry;
13984}
Jeff Johnson295189b2012-06-20 16:38:30 -070013985eHalStatus csrGetRssi(tpAniSirGlobal pMac,
13986 tCsrRssiCallback callback,
13987 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
13988{
13989 eHalStatus status = eHAL_STATUS_SUCCESS;
13990 vos_msg_t msg;
13991 tANI_U32 sessionId;
13992
13993 tAniGetRssiReq *pMsg;
13994 smsLog(pMac, LOG2, FL("called"));
13995 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetRssiReq));
13996 if ( !HAL_STATUS_SUCCESS(status) )
13997 {
13998 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req \n");
13999 return status;
14000 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014001 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
14002
14003 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
14004 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
14005 pMsg->sessionId = sessionId;
14006 pMsg->staId = staId;
14007 pMsg->rssiCallback = callback;
14008 pMsg->pDevContext = pContext;
14009 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014010 msg.type = eWNI_SME_GET_RSSI_REQ;
14011 msg.bodyptr = pMsg;
14012 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014013 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
14014 {
14015 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self \n");
14016 palFreeMemory(pMac->hHdd, (void *)pMsg);
14017 status = eHAL_STATUS_FAILURE;
14018 }
14019 smsLog(pMac, LOG2, FL("returned"));
14020 return status;
14021}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014022
14023#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
14024eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
14025 tCsrRssiCallback callback,
14026 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
14027{
14028 eHalStatus status = eHAL_STATUS_SUCCESS;
14029 tAniGetRssiReq *pMsg;
14030
14031 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetRssiReq));
14032 if ( !HAL_STATUS_SUCCESS(status) )
14033 {
14034 smsLog(pMac, LOGE, " csrGetRoamRssi: failed to allocate mem for req");
14035 return status;
14036 }
14037 // need to initiate a stats request to PE
14038 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
14039 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
14040 pMsg->staId = staId;
14041 pMsg->rssiCallback = callback;
14042 pMsg->pDevContext = pContext;
14043 pMsg->pVosContext = pVosContext;
14044 status = palSendMBMessage(pMac->hHdd, pMsg );
14045 if(!HAL_STATUS_SUCCESS(status))
14046 {
14047 smsLog(pMac, LOG1, " csrGetRoamRssi: failed to send down the stats req");
14048 palFreeMemory(pMac->hHdd, (void *)pMsg);
14049 status = eHAL_STATUS_FAILURE;
14050 }
14051 return status;
14052}
14053#endif
14054
Jeff Johnson295189b2012-06-20 16:38:30 -070014055eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
14056 tANI_U32 statsMask,
14057 tCsrStatsCallback callback,
14058 tANI_U32 periodicity, tANI_BOOLEAN cache,
14059 tANI_U8 staId, void *pContext)
14060{
14061 tCsrStatsClientReqInfo staEntry;
14062 tCsrStatsClientReqInfo *pStaEntry = NULL;
14063 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
14064 tListElem *pEntry = NULL;
14065 tANI_BOOLEAN found = FALSE;
14066 eHalStatus status = eHAL_STATUS_SUCCESS;
14067 tANI_BOOLEAN insertInClientList = FALSE;
14068 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070014069 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070014070
14071 if( csrIsAllSessionDisconnected(pMac) )
14072 {
14073 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected\n", pMac->roam.curState);
14074 return eHAL_STATUS_FAILURE;
14075 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014076 if((!statsMask) && (!callback))
14077 {
14078 //msg
14079 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request\n");
14080 return eHAL_STATUS_FAILURE;
14081 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014082 //for the search list method for deregister
14083 staEntry.requesterId = requesterId;
14084 staEntry.statsMask = statsMask;
14085 //requester wants to deregister or just an error
14086 if((statsMask) && (!callback))
14087 {
14088 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
14089 if(!pEntry)
14090 {
14091 //msg
14092 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
14093 "find any existing request in statsClientReqList\n");
14094 return eHAL_STATUS_FAILURE;
14095 }
14096 else
14097 {
14098 //clean up & return
14099 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070014100 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070014101 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014102 pStaEntry->pPeStaEntry->numClient--;
14103 //check if we need to delete the entry from peStatsReqList too
14104 if(!pStaEntry->pPeStaEntry->numClient)
14105 {
14106 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
14107 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014108 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070014109
Jeff Johnson295189b2012-06-20 16:38:30 -070014110 //check if we need to stop the tl stats timer too
14111 pMac->roam.tlStatsReqInfo.numClient--;
14112 if(!pMac->roam.tlStatsReqInfo.numClient)
14113 {
14114 if(pMac->roam.tlStatsReqInfo.timerRunning)
14115 {
14116 status = palTimerStop(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
14117 if(!HAL_STATUS_SUCCESS(status))
14118 {
14119 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer\n"));
14120 return eHAL_STATUS_FAILURE;
14121 }
14122 }
14123 pMac->roam.tlStatsReqInfo.periodicity = 0;
14124 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14125 }
14126 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070014127 // Destroy the vos timer...
14128 vosStatus = vos_timer_destroy( &pStaEntry->timer );
14129 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14130 {
14131 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer\n"));
14132 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014133 csrRoamRemoveStatListEntry(pMac, pEntry);
14134 pStaEntry = NULL;
14135 return eHAL_STATUS_SUCCESS;
14136 }
14137 }
14138
14139 if(cache && !periodicity)
14140 {
14141 //return the cached stats
14142 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
14143 }
14144 else
14145 {
14146 //add the request in the client req list
14147 staEntry.callback = callback;
14148 staEntry.pContext = pContext;
14149 staEntry.periodicity = periodicity;
14150 staEntry.pPeStaEntry = NULL;
14151 staEntry.staId = staId;
14152 staEntry.pMac = pMac;
14153 staEntry.timerExpired = FALSE;
14154
14155
Jeff Johnson295189b2012-06-20 16:38:30 -070014156 //if periodic report requested with non cached result from PE/TL
14157 if(periodicity)
14158 {
14159
14160 //if looking for stats from PE
14161 if(statsMask & ~(1 << eCsrGlobalClassDStats))
14162 {
14163
14164 //check if same request made already & waiting for rsp
14165 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
14166 periodicity, &found, staId);
14167 if(!pPeStaEntry)
14168 {
14169 //bail out, maxed out on number of req for PE
14170 return eHAL_STATUS_FAILURE;
14171 }
14172 else
14173 {
14174 staEntry.pPeStaEntry = pPeStaEntry;
14175 }
14176
14177 }
14178 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
14179 if(statsMask & (1 << eCsrGlobalClassDStats))
14180 {
14181 if(cache && pMac->roam.tlStatsReqInfo.numClient)
14182 {
14183 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL\n"));
14184 }
14185 else
14186 {
14187
14188 //update periodicity
14189 if(pMac->roam.tlStatsReqInfo.periodicity)
14190 {
14191 pMac->roam.tlStatsReqInfo.periodicity =
14192 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
14193 }
14194 else
14195 {
14196 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
14197 }
14198 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
14199 {
14200 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
14201 }
14202
14203 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14204 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014205 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
14206 if(NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014207 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014208 //req TL for class D stats
14209 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
14210 {
14211 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL\n"));
14212 }
14213 else
14214 {
14215 //save in SME
14216 csrRoamSaveStatsFromTl(pMac, pTlStats);
14217 }
14218 vos_mem_free(pTlStats);
14219 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014220 }
14221 else
14222 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014223 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014224 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014225
Jeff Johnson295189b2012-06-20 16:38:30 -070014226 if(pMac->roam.tlStatsReqInfo.periodicity)
14227 {
14228 //start timer
14229 status = palTimerStart(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14230 pMac->roam.tlStatsReqInfo.periodicity * PAL_TIMER_TO_MS_UNIT, eANI_BOOLEAN_FALSE);
14231 if(!HAL_STATUS_SUCCESS(status))
14232 {
14233 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer\n"));
14234 return eHAL_STATUS_FAILURE;
14235 }
14236 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14237 }
14238 }
14239 }
14240 pMac->roam.tlStatsReqInfo.numClient++;
14241 }
14242
14243 insertInClientList = TRUE;
14244 }
14245 //if one time report requested with non cached result from PE/TL
14246 else if(!cache && !periodicity)
14247 {
14248 if(statsMask & ~(1 << eCsrGlobalClassDStats))
14249 {
14250 //send down a req
14251 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
14252 if(!HAL_STATUS_SUCCESS(status))
14253 {
14254 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE\n"));
14255 }
14256 //so that when the stats rsp comes back from PE we respond to upper layer
14257 //right away
14258 staEntry.timerExpired = TRUE;
14259 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014260 }
14261 if(statsMask & (1 << eCsrGlobalClassDStats))
14262 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014263 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
14264 if(NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014265 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014266 //req TL for class D stats
14267 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
14268 {
14269 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL\n"));
14270 }
14271 else
14272 {
14273 //save in SME
14274 csrRoamSaveStatsFromTl(pMac, pTlStats);
14275 }
14276 vos_mem_free(pTlStats);
14277 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014278 }
14279 else
14280 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014281 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014282 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014283
14284 }
14285 //if looking for stats from TL only
14286 if(!insertInClientList)
14287 {
14288 //return the stats
14289 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
14290 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014291 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014292 if(insertInClientList)
14293 {
14294 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
14295 if(!pStaEntry)
14296 {
14297 //msg
14298 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList\n");
14299 return eHAL_STATUS_FAILURE;
14300 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014301 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070014302 //Init & start timer if needed
14303 if(periodicity)
14304 {
14305 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
14306 csrRoamStatsClientTimerHandler, pStaEntry );
14307 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14308 {
14309 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer\n"));
14310 return eHAL_STATUS_FAILURE;
14311 }
14312 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
14313 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14314 {
14315 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer\n"));
14316 return eHAL_STATUS_FAILURE;
14317 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014318 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014319 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014320 }
14321 return eHAL_STATUS_SUCCESS;
14322}
14323
Jeff Johnson295189b2012-06-20 16:38:30 -070014324tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
14325 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
14326{
14327 tANI_BOOLEAN found = FALSE;
14328 eHalStatus status = eHAL_STATUS_SUCCESS;
14329 tCsrPeStatsReqInfo staEntry;
14330 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
14331 tListElem *pStaEntry = NULL;
14332 VOS_STATUS vosStatus;
14333 tPmcPowerState powerState;
14334 *pFound = FALSE;
14335
14336 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
14337 if(pStaEntry)
14338 {
14339 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
14340 if(pTempStaEntry->periodicity)
14341 {
14342 pTempStaEntry->periodicity =
14343 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
14344 }
14345 else
14346 {
14347 pTempStaEntry->periodicity = periodicity;
14348 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014349 pTempStaEntry->numClient++;
14350 found = TRUE;
14351 }
14352 else
14353 {
14354 palZeroMemory(pMac->hHdd, &staEntry, sizeof(tCsrPeStatsReqInfo));
14355 staEntry.numClient = 1;
14356 staEntry.periodicity = periodicity;
14357 staEntry.pMac = pMac;
14358 staEntry.rspPending = FALSE;
14359 staEntry.staId = staId;
14360 staEntry.statsMask = statsMask;
14361 staEntry.timerRunning = FALSE;
14362 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
14363 if(!pTempStaEntry)
14364 {
14365 //msg
14366 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList\n");
14367 return NULL;
14368 }
14369 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014370 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
14371 if(ePMC_FULL_POWER == powerState)
14372 {
14373 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
14374 {
14375 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
14376 }
14377 }
14378 else
14379 {
14380 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
14381 {
14382 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
14383 }
14384 }
14385 if(!pTempStaEntry->timerRunning)
14386 {
14387 //send down a req in case of one time req, for periodic ones wait for timer to expire
14388 if(!pTempStaEntry->rspPending &&
14389 !pTempStaEntry->periodicity)
14390 {
14391 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
14392 if(!HAL_STATUS_SUCCESS(status))
14393 {
14394 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE\n"));
14395 }
14396 else
14397 {
14398 pTempStaEntry->rspPending = TRUE;
14399 }
14400 }
14401 if(pTempStaEntry->periodicity)
14402 {
14403 if(!found)
14404 {
14405
14406 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
14407 csrRoamPeStatsTimerHandler, pTempStaEntry );
14408 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14409 {
14410 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer\n"));
14411 return NULL;
14412 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014413 }
14414 //start timer
14415 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d\n", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070014416 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
14417 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14418 {
14419 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer\n"));
14420 return NULL;
14421 }
14422 pTempStaEntry->timerRunning = TRUE;
14423 }
14424 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014425 *pFound = found;
14426 return pTempStaEntry;
14427}
14428
Jeff Johnson295189b2012-06-20 16:38:30 -070014429/*
14430 pStaEntry is no longer invalid upon the return of this function.
14431*/
14432static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
14433{
14434 if(pEntry)
14435 {
14436 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
14437 {
14438 palFreeMemory(pMac->hHdd, GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070014439 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014440 }
14441 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014442
14443void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
14444{
14445 tListElem *pEntry;
14446 tCsrPeStatsReqInfo *pTempStaEntry;
14447 VOS_STATUS vosStatus;
14448 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014449 if(!pEntry)
14450 {
14451 //list empty
14452 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: List empty, no stats req for PE\n");
14453 return;
14454 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014455 while( pEntry )
14456 {
14457 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014458 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
14459 {
14460 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: match found\n");
14461 if(pTempStaEntry->timerRunning)
14462 {
14463 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
14464 /* If we are not able to stop the timer here, just remove
14465 * the entry from the linked list. Destroy the timer object
14466 * and free the memory in the timer CB
14467 */
14468 if( vosStatus == VOS_STATUS_SUCCESS )
14469 {
14470 /* the timer is successfully stopped */
14471 pTempStaEntry->timerRunning = FALSE;
14472
14473 /* Destroy the timer */
14474 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
14475 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14476 {
14477 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer\n"));
14478 }
14479 }
14480 else
14481 {
14482 // the timer could not be stopped. Hence destroy and free the
14483 // memory for the PE stat entry in the timer CB.
14484 pTempStaEntry->timerStopFailed = TRUE;
14485 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014486 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014487
14488 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
14489 {
14490 // Only free the memory if we could stop the timer successfully
14491 if(!pTempStaEntry->timerStopFailed)
14492 {
14493 palFreeMemory(pMac->hHdd, pTempStaEntry);
14494 pTempStaEntry = NULL;
14495 }
14496 break;
14497 }
14498
14499 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
14500 }
14501 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014502 return;
14503}
14504
14505
Jeff Johnsone7245742012-09-05 17:12:55 -070014506void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014507{
14508
Jeff Johnsone7245742012-09-05 17:12:55 -070014509 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
14510 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
14511 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
14512 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
14513 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
14514 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
14515 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070014516 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070014517 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
14518 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
14519 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
14520 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
14521 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
14522 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070014523 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070014524 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
14525 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070014526
14527}
14528
Jeff Johnson295189b2012-06-20 16:38:30 -070014529void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
14530 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
14531{
14532 tANI_U8 stats[500];
14533 tANI_U8 *pStats = NULL;
14534 tANI_U32 tempMask = 0;
14535 tANI_U8 counter = 0;
14536 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014537 if(!callback)
14538 {
14539 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report callback NULL\n"));
14540 return;
14541 }
14542 if(!statsMask)
14543 {
14544 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report statsMask is 0\n"));
14545 return;
14546 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014547 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070014548 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070014549 while(tempMask)
14550 {
14551 if(tempMask & 1)
14552 {
14553 //new stats info from PE, fill up the stats strucutres in PMAC
14554 switch(counter)
14555 {
14556 case eCsrSummaryStats:
Mohit Khanna23863762012-09-11 17:40:09 -070014557 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:summary stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014558 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
14559 sizeof(tCsrSummaryStatsInfo));
14560 if(!HAL_STATUS_SUCCESS(status))
14561 {
14562 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy summary stats\n"));
14563 }
14564 pStats += sizeof(tCsrSummaryStatsInfo);
14565 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014566 case eCsrGlobalClassAStats:
Mohit Khanna23863762012-09-11 17:40:09 -070014567 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassA stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014568 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
14569 sizeof(tCsrGlobalClassAStatsInfo));
14570 if(!HAL_STATUS_SUCCESS(status))
14571 {
14572 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassA stats\n"));
14573 }
14574 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070014575 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014576 case eCsrGlobalClassBStats:
Mohit Khanna23863762012-09-11 17:40:09 -070014577 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassB stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014578 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
14579 sizeof(tCsrGlobalClassBStatsInfo));
14580 if(!HAL_STATUS_SUCCESS(status))
14581 {
14582 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassB stats\n"));
14583 }
14584 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070014585 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014586 case eCsrGlobalClassCStats:
Mohit Khanna23863762012-09-11 17:40:09 -070014587 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassC stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014588 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
14589 sizeof(tCsrGlobalClassCStatsInfo));
14590 if(!HAL_STATUS_SUCCESS(status))
14591 {
14592 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassC stats\n"));
14593 }
14594 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070014595 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014596 case eCsrGlobalClassDStats:
Mohit Khanna23863762012-09-11 17:40:09 -070014597 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassD stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014598 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
14599 sizeof(tCsrGlobalClassDStatsInfo));
14600 if(!HAL_STATUS_SUCCESS(status))
14601 {
14602 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassD stats\n"));
14603 }
14604 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070014605 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014606 case eCsrPerStaStats:
Mohit Khanna23863762012-09-11 17:40:09 -070014607 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:PerSta stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014608 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
14609 sizeof(tCsrPerStaStatsInfo));
14610 if(!HAL_STATUS_SUCCESS(status))
14611 {
14612 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy PerSta stats\n"));
14613 }
14614 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070014615 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014616 default:
14617 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:unknown stats type\n"));
14618 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014619 }
14620 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014621 tempMask >>=1;
14622 counter++;
14623 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014624 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070014625}
14626
Jeff Johnson295189b2012-06-20 16:38:30 -070014627eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
14628{
14629 tListElem *pEntry = NULL;
14630 tListElem *pPrevEntry = NULL;
14631 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
14632 eHalStatus status = eHAL_STATUS_SUCCESS;
14633 VOS_STATUS vosStatus;
14634 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014635 if(!pEntry)
14636 {
14637 //list empty
14638 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
14639 "upper layer client(s)\n");
14640 return status;
14641 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014642 while( pEntry )
14643 {
14644 if(pPrevEntry)
14645 {
14646 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
14647 //send up the stats report
14648 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
14649 pTempStaEntry->staId, pTempStaEntry->pContext);
14650 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
14651 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014652 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014653 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
14654 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014655 pTempStaEntry->pPeStaEntry->numClient--;
14656 //check if we need to delete the entry from peStatsReqList too
14657 if(!pTempStaEntry->pPeStaEntry->numClient)
14658 {
14659 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
14660 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014661 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014662 //check if we need to stop the tl stats timer too
14663 pMac->roam.tlStatsReqInfo.numClient--;
14664 if(!pMac->roam.tlStatsReqInfo.numClient)
14665 {
14666 if(pMac->roam.tlStatsReqInfo.timerRunning)
14667 {
14668 status = palTimerStop(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
14669 if(!HAL_STATUS_SUCCESS(status))
14670 {
14671 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer\n"));
14672 //we will continue
14673 }
14674 }
14675 pMac->roam.tlStatsReqInfo.periodicity = 0;
14676 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14677 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014678 if (pTempStaEntry->periodicity)
14679 {
14680 //While creating StaEntry in csrGetStatistics,
14681 //Initializing and starting timer only when periodicity is set.
14682 //So Stop and Destroy timer only when periodicity is set.
14683
Jeff Johnsone7245742012-09-05 17:12:55 -070014684 vos_timer_stop( &pTempStaEntry->timer );
14685 // Destroy the vos timer...
14686 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
14687 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14688 {
14689 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer\n"));
14690 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014691 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014692
Jeff Johnson295189b2012-06-20 16:38:30 -070014693
14694 pPrevEntry = pEntry;
14695 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14696 }
14697 //the last one
14698 if(pPrevEntry)
14699 {
14700 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
14701 //send up the stats report
14702 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
14703 pTempStaEntry->staId, pTempStaEntry->pContext);
14704 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
14705 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014706 return status;
14707
14708}
14709
Jeff Johnson295189b2012-06-20 16:38:30 -070014710eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
14711 tRequestFullPowerReason *pReason,
14712 tANI_BOOLEAN *pfNeedPower )
14713{
14714 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
14715 tRequestFullPowerReason reason = eSME_REASON_OTHER;
14716 tPmcState pmcState;
14717 eHalStatus status = eHAL_STATUS_SUCCESS;
14718 // TODO : Session info unavailable
14719 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014720 if( pfNeedPower )
14721 {
14722 *pfNeedPower = eANI_BOOLEAN_FALSE;
14723 }
14724 //We only handle CSR commands
14725 if( !(eSmeCsrCommandMask & pCommand->command) )
14726 {
14727 return eHAL_STATUS_SUCCESS;
14728 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014729 //Check PMC state first
14730 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070014731 switch( pmcState )
14732 {
14733 case REQUEST_IMPS:
14734 case IMPS:
14735 if( eSmeCommandScan == pCommand->command )
14736 {
14737 switch( pCommand->u.scanCmd.reason )
14738 {
14739 case eCsrScanGetResult:
14740 case eCsrScanBGScanAbort:
14741 case eCsrScanBGScanEnable:
14742 case eCsrScanGetScanChnInfo:
14743 //Internal process, no need for full power
14744 fNeedFullPower = eANI_BOOLEAN_FALSE;
14745 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014746 default:
14747 //Other scans are real scan, ask for power
14748 fNeedFullPower = eANI_BOOLEAN_TRUE;
14749 break;
14750 } //switch
14751 }
14752 else
14753 {
14754 //ask for power for roam and status change
14755 fNeedFullPower = eANI_BOOLEAN_TRUE;
14756 }
14757 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014758 case REQUEST_BMPS:
14759 case BMPS:
14760 case REQUEST_START_UAPSD:
14761 case UAPSD:
14762 //We treat WOWL same as BMPS
14763 case REQUEST_ENTER_WOWL:
14764 case WOWL:
14765 if( eSmeCommandRoam == pCommand->command )
14766 {
14767 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
14768 tCsrScanResult *pScanResult;
14769 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014770 switch ( pCommand->u.roamCmd.roamReason )
14771 {
14772 case eCsrForcedDisassoc:
14773 case eCsrForcedDisassocMICFailure:
14774 reason = eSME_LINK_DISCONNECTED_BY_HDD;
14775 fNeedFullPower = eANI_BOOLEAN_TRUE;
14776 break;
14777 case eCsrSmeIssuedDisassocForHandoff:
14778 case eCsrForcedDeauth:
14779 case eCsrHddIssuedReassocToSameAP:
14780 case eCsrSmeIssuedReassocToSameAP:
14781 fNeedFullPower = eANI_BOOLEAN_TRUE;
14782 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014783 case eCsrCapsChange:
14784 fNeedFullPower = eANI_BOOLEAN_TRUE;
14785 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014786 default:
14787 //Check whether the profile is already connected. If so, no need for full power
14788 //Note: IBSS is ignored for now because we don't support powersave in IBSS
14789 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
14790 {
14791 //Only need to check the first one
14792 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
14793 if( pEntry )
14794 {
14795 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
14796#if 0
14797 // TODO : Session Specific info pConnectBssDesc
14798 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
14799 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
14800 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
14801 {
14802 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
14803 // with Authenticating first. To force this, stop the current association (Disassociate) and
14804 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
14805 // a new Association.
14806 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
14807 {
14808 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
14809 {
14810 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
14811 //No need for full power
14812 //Set the flag so the code later can avoid to do the above
14813 //check again.
14814 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
14815 break;
14816 }
14817 }
14818 }
14819#endif
14820 }
14821 }
14822 //If we are here, full power is needed
14823 fNeedFullPower = eANI_BOOLEAN_TRUE;
14824 break;
14825 }
14826 }
14827 else if( eSmeCommandWmStatusChange == pCommand->command )
14828 {
14829 //need full power for all
14830 fNeedFullPower = eANI_BOOLEAN_TRUE;
14831 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
14832 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014833#ifdef FEATURE_WLAN_TDLS
14834 else if( eSmeCommandTdlsAddPeer == pCommand->command )
14835 {
14836 //TDLS link is getting established. need full power
14837 fNeedFullPower = eANI_BOOLEAN_TRUE;
14838 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
14839 }
14840#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014841 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014842 case REQUEST_STOP_UAPSD:
14843 case REQUEST_EXIT_WOWL:
14844 if( eSmeCommandRoam == pCommand->command )
14845 {
14846 fNeedFullPower = eANI_BOOLEAN_TRUE;
14847 switch ( pCommand->u.roamCmd.roamReason )
14848 {
14849 case eCsrForcedDisassoc:
14850 case eCsrForcedDisassocMICFailure:
14851 reason = eSME_LINK_DISCONNECTED_BY_HDD;
14852 break;
14853 default:
14854 break;
14855 }
14856 }
14857 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014858 case STOPPED:
14859 case REQUEST_STANDBY:
14860 case STANDBY:
14861 case LOW_POWER:
14862 //We are not supposed to do anything
14863 smsLog( pMac, LOGE, FL( " cannot process because PMC is in stopped/standby state %d\n" ), pmcState );
14864 status = eHAL_STATUS_FAILURE;
14865 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014866 case FULL_POWER:
14867 case REQUEST_FULL_POWER:
14868 default:
14869 //No need to ask for full power. This has to be FULL_POWER state
14870 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014871 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070014872 if( pReason )
14873 {
14874 *pReason = reason;
14875 }
14876 if( pfNeedPower )
14877 {
14878 *pfNeedPower = fNeedFullPower;
14879 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014880 return ( status );
14881}
14882
Jeff Johnson295189b2012-06-20 16:38:30 -070014883static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14884{
14885 eHalStatus status = eHAL_STATUS_SUCCESS;
14886 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
14887 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070014888 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070014889 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
14890 {
14891 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
14892 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014893 return ( status );
14894}
14895
Jeff Johnson295189b2012-06-20 16:38:30 -070014896tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
14897{
14898 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070014899 if( pCmd )
14900 {
14901 pMac->roam.sPendingCommands++;
14902 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014903 return ( pCmd );
14904}
14905
Jeff Johnson295189b2012-06-20 16:38:30 -070014906void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
14907{
14908 if (pMac->roam.sPendingCommands > 0)
14909 {
14910 //All command allocated through csrGetCommandBuffer need to
14911 //decrement the pending count when releasing.
14912 pMac->roam.sPendingCommands--;
14913 smeReleaseCommand( pMac, pCommand );
14914 }
14915 else
14916 {
14917 smsLog(pMac, LOGE, FL( "no pending commands"));
14918 VOS_ASSERT(0);
14919 }
14920}
14921
Jeff Johnson295189b2012-06-20 16:38:30 -070014922//Return SUCCESS is the command is queued, failed
14923eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
14924{
14925 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014926 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
14927 {
14928 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
14929 pCommand->u.scanCmd.reason);
14930 return eHAL_STATUS_CSR_WRONG_STATE;
14931 }
14932
14933 //We can call request full power first before putting the command into pending Q
14934 //because we are holding SME lock at this point.
14935 status = csrRequestFullPower( pMac, pCommand );
14936 if( HAL_STATUS_SUCCESS( status ) )
14937 {
14938 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070014939 //make sure roamCmdPendingList is not empty first
14940 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
14941 if( fNoCmdPending )
14942 {
14943 smePushCommand( pMac, pCommand, fHighPriority );
14944 }
14945 else
14946 {
14947 //Other commands are waiting for PMC callback, queue the new command to the pending Q
14948 //no list lock is needed since SME lock is held
14949 if( !fHighPriority )
14950 {
14951 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
14952 }
14953 else {
14954 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
14955 }
14956 }
14957 }
14958 else if( eHAL_STATUS_PMC_PENDING == status )
14959 {
14960 //no list lock is needed since SME lock is held
14961 if( !fHighPriority )
14962 {
14963 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
14964 }
14965 else {
14966 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
14967 }
14968 //Let caller know the command is queue
14969 status = eHAL_STATUS_SUCCESS;
14970 }
14971 else
14972 {
14973 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
14974 //release the command.
14975 smsLog( pMac, LOGE, FL( " cannot queue command %d\n" ), pCommand->command );
14976 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014977 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014978}
Jeff Johnson295189b2012-06-20 16:38:30 -070014979eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
14980{
14981 eHalStatus status = eHAL_STATUS_SUCCESS;
14982 tSirUpdateAPWPSIEsReq *pMsg;
14983 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
14984
14985 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14986 if (NULL == pSession)
14987 {
14988 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
14989 return eHAL_STATUS_FAILURE;
14990 }
14991
Jeff Johnson295189b2012-06-20 16:38:30 -070014992 do
14993 {
14994 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirUpdateAPWPSIEsReq) );
14995 if (!HAL_STATUS_SUCCESS(status)) break;
14996 palZeroMemory( pMac->hHdd, pMsg, sizeof(tSirUpdateAPWPSIEsReq) );
14997 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
14998
14999 pBuf = (tANI_U8 *)&pMsg->transactionId;
15000 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015001 // transactionId
15002 *pBuf = 0;
15003 *( pBuf + 1 ) = 0;
15004 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070015005 // bssId
15006 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
15007 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015008 //sessionId
15009 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015010 // APWPSIEs
15011 palCopyMemory( pMac->hHdd, (tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
15012 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070015013 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070015014 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015015 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015016 return ( status );
15017}
Jeff Johnson295189b2012-06-20 16:38:30 -070015018eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
15019{
15020 eHalStatus status = eHAL_STATUS_SUCCESS;
15021 tSirUpdateAPWPARSNIEsReq *pMsg;
15022 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015023 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15024 if (NULL == pSession)
15025 {
15026 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
15027 return eHAL_STATUS_FAILURE;
15028 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015029 do
15030 {
15031 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirUpdateAPWPARSNIEsReq) );
15032 if (!HAL_STATUS_SUCCESS(status)) break;
15033 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ) );
15034 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070015035 pBuf = (tANI_U8 *)&pMsg->transactionId;
15036 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070015037 // transactionId
15038 *pBuf = 0;
15039 *( pBuf + 1 ) = 0;
15040 pBuf += sizeof(tANI_U16);
15041
15042 // bssId
15043 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
15044 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015045 // sessionId
15046 *pBuf++ = (tANI_U8)sessionId;
15047
15048 // APWPARSNIEs
15049 palCopyMemory( pMac->hHdd, (tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
15050 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070015051 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070015052 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015053 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015054 return ( status );
15055}
Jeff Johnson295189b2012-06-20 16:38:30 -070015056
15057#ifdef WLAN_FEATURE_VOWIFI_11R
15058//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
15059eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
15060{
15061 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
15062 tpSirFTPreAuthReq pftPreAuthReq;
15063 tANI_U16 auth_req_len = 0;
15064 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015065 auth_req_len = sizeof(tSirFTPreAuthReq);
15066 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
15067 if (pftPreAuthReq == NULL)
15068 {
15069 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
15070 return eHAL_STATUS_RESOURCES;
15071 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015072 // Save the SME Session ID here. We need it while processing the preauth response
15073 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015074 vos_mem_zero(pftPreAuthReq, auth_req_len);
15075
15076 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
15077 sizeof(pBssDescription->length) + pBssDescription->length);
15078
15079 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
15080
15081 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
15082
Jeff Johnson295189b2012-06-20 16:38:30 -070015083 palCopyMemory(pMac->hHdd, (void *)&pftPreAuthReq->currbssId, (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015084 palCopyMemory(pMac->hHdd, (void *)&pftPreAuthReq->preAuthbssId, (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
15085
Jeff Johnson295189b2012-06-20 16:38:30 -070015086#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080015087 if (csrRoamIs11rAssoc(pMac) &&
15088 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070015089 {
15090 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
15091 palCopyMemory(pMac->hHdd, pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
15092 pMac->ft.ftSmeContext.auth_ft_ies_length);
15093 }
15094 else
15095#endif
15096 {
15097 pftPreAuthReq->ft_ies_length = 0;
15098 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070015099 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
15100 sizeof(pBssDescription->length) + pBssDescription->length);
15101 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070015102 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
15103}
Jeff Johnson295189b2012-06-20 16:38:30 -070015104/*--------------------------------------------------------------------------
15105 * This will receive and process the FT Pre Auth Rsp from the current
15106 * associated ap.
15107 *
15108 * This will invoke the hdd call back. This is so that hdd can now
15109 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
15110 ------------------------------------------------------------------------*/
15111void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
15112{
15113 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
15114 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015115#ifdef FEATURE_WLAN_LFR
15116 tCsrRoamInfo roamInfo;
15117#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015118
15119#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080015120 smsLog( pMac, LOGE, FL("Preauth response status code 0x%x"), pFTPreAuthRsp->status);
Jeff Johnson295189b2012-06-20 16:38:30 -070015121#endif
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070015122#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080015123 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070015124 if (status != eHAL_STATUS_SUCCESS) {
15125 /*
15126 * Bail out if pre-auth was not even processed.
15127 */
15128 smsLog(pMac, LOGW, FL("Preauth was not processed: %d"), status);
15129 return;
15130 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015131#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015132 /* The below function calls/timers should be invoked only if the pre-auth is successful */
15133 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
15134 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070015135 // Implies a success
15136 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015137 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
15138 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
15139 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070015140 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
15141 * actual transition from the current to handoff AP is triggered */
15142 status = palTimerStart(pMac->hHdd, pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
15143 60 * PAL_TIMER_TO_MS_UNIT,
15144 eANI_BOOLEAN_FALSE);
15145 if (eHAL_STATUS_SUCCESS != status)
15146 {
15147 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d\n"), status);
15148 return;
15149 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015150 // Save the received response
15151 palCopyMemory(pMac->hHdd, (void *)&pMac->ft.ftSmeContext.preAuthbssId, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
15152 if (csrRoamIs11rAssoc(pMac))
15153 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
15154 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
15155
15156 // Currently we dont do anything special for CCX connection.
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015157#ifdef FEATURE_WLAN_LFR
15158 // If Legacy Fast Roaming is enabled, signal the supplicant
15159 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053015160 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015161 {
15162 // Save the bssid from the received response
15163 palCopyMemory(pMac->hHdd, (void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
15164 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
15165 }
15166
15167#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015168
15169 // Done with it, init it.
15170 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
15171}
15172#endif
15173#ifdef FEATURE_WLAN_BTAMP_UT_RF
15174void csrRoamJoinRetryTimerHandler(void *pv)
15175{
15176 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
15177 tpAniSirGlobal pMac = pInfo->pMac;
15178 tANI_U32 sessionId = pInfo->sessionId;
15179 tCsrRoamSession *pSession;
15180
15181 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
15182 {
15183 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d\n" ), sessionId );
15184 pSession = CSR_GET_SESSION( pMac, sessionId );
15185 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
15186 {
15187 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
15188 {
15189 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile\n" ) );
15190 }
15191 }
15192 }
15193}
Jeff Johnson295189b2012-06-20 16:38:30 -070015194eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
15195{
15196 eHalStatus status = eHAL_STATUS_FAILURE;
15197 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15198
15199 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
15200 {
15201 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left\n "), sessionId, pSession->maxRetryCount);
15202 pSession->maxRetryCount--;
15203 pSession->joinRetryTimerInfo.pMac = pMac;
15204 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
15205 status = palTimerStart(pMac->hHdd, pSession->hTimerJoinRetry, interval, eANI_BOOLEAN_FALSE);
15206 if(!HAL_STATUS_SUCCESS(status))
15207 {
15208 smsLog(pMac, LOGE, FL(" fail to start timer status %s \n "), status);
15209 }
15210 }
15211 else
15212 {
15213 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)\n "),
15214 pSession->maxRetryCount);
15215 }
15216
15217 return (status);
15218}
Jeff Johnson295189b2012-06-20 16:38:30 -070015219eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
15220{
15221 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer \n ");
15222 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
15223 {
15224 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerJoinRetry));
15225 }
15226
15227 return eHAL_STATUS_SUCCESS;
15228}
15229#endif
15230
15231
15232/*
15233 pBuf points to the beginning of the message
15234 LIM packs disassoc rsp as below,
15235 messageType - 2 bytes
15236 messageLength - 2 bytes
15237 sessionId - 1 byte
15238 transactionId - 2 bytes (tANI_U16)
15239 reasonCode - 4 bytes (sizeof(tSirResultCodes))
15240 peerMacAddr - 6 bytes
15241 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
15242*/
15243static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
15244{
15245 if(pBuf && pRsp)
15246 {
15247 pBuf += 4; //skip type and length
15248 pRsp->sessionId = *pBuf++;
15249 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
15250 pBuf += 2;
15251 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
15252 pBuf += 4;
15253 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
15254 }
15255}
15256
Jeff Johnsond13512a2012-07-17 11:42:19 -070015257eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
15258{
15259 static uNvTables nvTables;
15260 eHalStatus status = eHAL_STATUS_SUCCESS;
15261 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
15262
15263 /* read the country code from NV and use it */
15264 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
15265 {
15266 palCopyMemory( pMac->hHdd, pCountry,
15267 nvTables.defaultCountryTable.countryCode,
15268 WNI_CFG_COUNTRY_CODE_LEN );
15269 return status;
15270 }
15271 else
15272 {
15273 palCopyMemory( pMac->hHdd, pCountry,
15274 "XXX",
15275 WNI_CFG_COUNTRY_CODE_LEN );
15276 status = eHAL_STATUS_FAILURE;
15277 return status;
15278 }
15279}
15280
15281eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
15282{
15283 palCopyMemory( pMac->hHdd, pCountry,
15284 pMac->scan.countryCode11d,
15285 WNI_CFG_COUNTRY_CODE_LEN );
15286 return eHAL_STATUS_SUCCESS;
15287}