blob: af26251633c1ea57bee1e4d86d119bd6f3834b42 [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}
Jeff Johnson295189b2012-06-20 16:38:30 -07001874eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
1875{
1876 eHalStatus status = eHAL_STATUS_SUCCESS;
1877 tANI_U8 num20MHzChannelsFound = 0;
1878 VOS_STATUS vosStatus;
1879 tANI_U8 Index = 0;
1880 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001881
Jeff Johnson295189b2012-06-20 16:38:30 -07001882
1883 //TODO: this interface changed to include the 40MHz channel list
1884 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
1885 // Read the scan channel list (including the power limit) from EEPROM
1886 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
1887 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
1888 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
1889 {
1890 smsLog( pMac, LOGE, FL("failed to get channels \n"));
1891 status = eHAL_STATUS_FAILURE;
1892 }
1893 else
1894 {
1895 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
1896 {
1897 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1898 }
1899 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
1900 // Move the channel list to the global data
1901 // structure -- this will be used as the scan list
1902 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
1903 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001904 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07001905 }
1906 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
1907 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
1908 {
1909 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1910 }
1911 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
1912 {
1913 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
1914 }
1915 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
1916 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001917 return (status);
1918}
1919
Jeff Johnson295189b2012-06-20 16:38:30 -07001920eHalStatus csrInitChannelList( tHalHandle hHal )
1921{
1922 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1923 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001924 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
1925 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08001926 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
1927 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001928 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08001929 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07001930
1931 return (status);
1932}
Jeff Johnson295189b2012-06-20 16:38:30 -07001933eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
1934 tCsrUpdateConfigParam *pUpdateConfigParam)
1935{
1936 eHalStatus status = eHAL_STATUS_FAILURE;
1937 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001938 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
1939 status = CsrInit11dInfo(pMac, ps11dinfo);
1940 return status;
1941}
1942
Jeff Johnson295189b2012-06-20 16:38:30 -07001943static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
1944{
1945 eHalStatus status = eHAL_STATUS_FAILURE;
1946 tANI_U8 index;
1947 tANI_U32 count=0;
1948 tSirMacChanInfo *pChanInfo;
1949 tSirMacChanInfo *pChanInfoStart;
1950 tANI_BOOLEAN applyConfig = TRUE;
1951
1952 if(!ps11dinfo)
1953 {
1954 return (status);
1955 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001956 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
1957 {
1958 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
1959 status = palCopyMemory(pMac->hHdd, pMac->scan.base20MHzChannels.channelList,
1960 ps11dinfo->Channels.channelList, ps11dinfo->Channels.numChannels);
1961 if(!HAL_STATUS_SUCCESS(status)) return (status);
1962 }
1963 else
1964 {
1965 //No change
1966 return (eHAL_STATUS_SUCCESS);
1967 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001968 //legacy maintenance
1969 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeDefault,
1970 ps11dinfo->countryCode, WNI_CFG_COUNTRY_CODE_LEN);
1971 if(!HAL_STATUS_SUCCESS(status)) return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -07001972 //Tush: at csropen get this initialized with default, during csr reset if this
1973 // already set with some value no need initilaize with default again
1974 if(0 == pMac->scan.countryCodeCurrent[0])
1975 {
1976 status = palCopyMemory(pMac->hHdd, pMac->scan.countryCodeCurrent,
1977 ps11dinfo->countryCode, WNI_CFG_COUNTRY_CODE_LEN);
1978 if(!HAL_STATUS_SUCCESS(status)) return (status);
1979 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001980 // need to add the max power channel list
1981 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN)))
1982 {
1983 palZeroMemory(pMac->hHdd, pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
1984 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07001985 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
1986 {
1987 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
1988 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
1989 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
1990 pChanInfo++;
1991 count++;
1992 }
1993 if(count)
1994 {
1995 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
1996 }
1997 palFreeMemory(pMac->hHdd, pChanInfoStart);
1998 }
1999 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2000 if( HAL_STATUS_SUCCESS(status) )
2001 {
2002 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2003 {
2004 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2005 {
2006 applyConfig = FALSE;
2007 }
2008 }
2009
2010 if(TRUE == applyConfig)
2011 {
2012 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002013 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002014 }
2015
2016 }
2017 return (status);
2018}
2019/* Initialize the Channel + Power List in the local cache and in the CFG */
2020eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2021{
2022 tANI_U8 index;
2023 tANI_U32 count=0;
2024 tSirMacChanInfo *pChanInfo;
2025 tSirMacChanInfo *pChanInfoStart;
2026
2027 if(!ps11dinfo || !pMac)
2028 {
2029 return eHAL_STATUS_FAILURE;
2030 }
2031
2032 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN)))
2033 {
2034 palZeroMemory(pMac->hHdd, pChanInfo, sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2035 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002036
2037 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2038 {
2039 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2040 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2041 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2042 pChanInfo++;
2043 count++;
2044 }
2045 if(count)
2046 {
2047 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2048 }
2049 palFreeMemory(pMac->hHdd, pChanInfoStart);
2050 }
2051
Jeff Johnsone7245742012-09-05 17:12:55 -07002052 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002053}
2054
2055//pCommand may be NULL
2056//Pass in sessionId in case pCommand is NULL. sessionId is not used in case pCommand is not NULL.
2057void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac, tANI_U32 sessionId, tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
2058{
2059 tListElem *pEntry, *pNextEntry;
2060 tSmeCmd *pDupCommand;
2061 tDblLinkList localList;
2062
2063 vos_mem_zero(&localList, sizeof(tDblLinkList));
2064 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
2065 {
2066 smsLog(pMac, LOGE, FL(" failed to open list"));
2067 return;
2068 }
2069 csrLLLock( &pMac->sme.smeCmdPendingList );
2070 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
2071 while( pEntry )
2072 {
2073 pNextEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
2074 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07002075 // Remove the previous command if..
2076 // - the new roam command is for the same RoamReason...
2077 // - the new roam command is a NewProfileList.
2078 // - the new roam command is a Forced Dissoc
2079 // - the new roam command is from an 802.11 OID (OID_SSID or OID_BSSID).
2080 if (
2081 (pCommand && ( pCommand->sessionId == pDupCommand->sessionId ) &&
2082 ((pCommand->command == pDupCommand->command) &&
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002083 /* This peermac check is requried for Softap/GO scenarios
2084 * For STA scenario below OR check will suffice as pCommand will
2085 * always be NULL for STA scenarios
2086 */
2087 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac, pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002088 (pCommand->u.roamCmd.roamReason == pDupCommand->u.roamCmd.roamReason ||
2089 eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason ||
2090 eCsrHddIssued == pCommand->u.roamCmd.roamReason)))
2091 ||
2092 //below the pCommand is NULL
Jeff Johnson43971f52012-07-17 12:26:56 -07002093 ( (sessionId == pDupCommand->sessionId) &&
2094 (eSmeCommandRoam == pDupCommand->command) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002095 ((eCsrForcedDisassoc == eRoamReason) ||
2096 (eCsrHddIssued == eRoamReason))
2097 )
2098 )
2099 {
2100 smsLog(pMac, LOGW, FL(" roamReason = %d\n"), pDupCommand->u.roamCmd.roamReason);
2101 // Remove the 'stale' roam command from the pending list...
2102 if(csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK ))
2103 {
2104 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
2105 }
2106 }
2107 pEntry = pNextEntry;
2108 }
2109 csrLLUnlock( &pMac->sme.smeCmdPendingList );
2110
2111 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
2112 {
2113 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
2114 //Tell caller that the command is cancelled
2115 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL, pDupCommand->u.roamCmd.roamId,
2116 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
2117 csrReleaseCommandRoam(pMac, pDupCommand);
2118 }
2119 csrLLClose(&localList);
2120}
Jeff Johnson295189b2012-06-20 16:38:30 -07002121eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2122 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2123{
2124 eHalStatus status = eHAL_STATUS_SUCCESS;
2125#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2126 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2127#endif
2128 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07002129 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2130 {
2131 pSession = CSR_GET_SESSION( pMac, sessionId );
2132 }
2133 else
2134 {
2135 smsLog(pMac, LOGE, "Session ID:%d is not valid\n", sessionId);
2136 VOS_ASSERT(0);
2137 return eHAL_STATUS_FAILURE;
2138 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002139 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
2140 {
2141 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d\n", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
2142 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002143 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2144 /*
2145 * Decrement bRefAssocStartCnt for FT reassoc failure.
2146 * Reason: For FT reassoc failures, we first call
2147 * csrRoamCallCallback before notifying a failed roam
2148 * completion through csrRoamComplete. The latter in
2149 * turn calls csrRoamProcessResults which tries to
2150 * once again call csrRoamCallCallback if bRefAssocStartCnt
2151 * is non-zero. Since this is redundant for FT reassoc
2152 * failure, decrement bRefAssocStartCnt.
2153 */
2154 pSession->bRefAssocStartCnt--;
2155 }
2156
Jeff Johnson295189b2012-06-20 16:38:30 -07002157 if ( (pSession == NULL) ||
2158 (eANI_BOOLEAN_FALSE == pSession->sessionActive) )
2159 {
2160 smsLog(pMac, LOG1, "Session ID is not valid\n");
2161 return eHAL_STATUS_FAILURE;
2162 }
2163
2164 if(NULL != pSession->callback)
2165 {
2166 if( pRoamInfo )
2167 {
2168 pRoamInfo->sessionId = (tANI_U8)sessionId;
2169 }
2170
2171 /* avoid holding the global lock when making the roaming callback , original change came
2172 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2173 is possible on other OS ports where the callback may need to take locks to protect
2174 HDD state
2175 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2176 that may actually depend on the lock being held */
2177 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2178 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2179 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2180 }
2181 //EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
2182 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
2183#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2184 palZeroMemory(pMac->hHdd, &connectionStatus, sizeof(vos_event_wlan_status_payload_type));
2185 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2))
2186 {
2187 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2188 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2189 if(NULL != pRoamInfo->pBssDesc)
2190 {
2191 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2192 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2193 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002194 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2195 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2196 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
2197 palCopyMemory(pMac->hHdd, connectionStatus.ssid, pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
2198 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
2199 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2200 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002201 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2202 {
2203 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2204 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
2205 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2206 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002207 if(eCSR_ROAM_RESULT_FORCED == u2)
2208 {
2209 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2210 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
2211 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2212 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002213 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2214 {
2215 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2216 connectionStatus.reason = eCSR_REASON_DISASSOC;
2217 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2218 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002219 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2220 {
2221 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2222 connectionStatus.reason = eCSR_REASON_DEAUTH;
2223 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2224 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002225#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2226
2227 return (status);
2228}
Jeff Johnson295189b2012-06-20 16:38:30 -07002229// Returns whether handoff is currently in progress or not
2230tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2231{
2232#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2233 return csrNeighborRoamIsHandoffInProgress(pMac);
2234#else
2235 return eANI_BOOLEAN_FALSE;
2236#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002237}
Jeff Johnson295189b2012-06-20 16:38:30 -07002238eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2239 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2240{
2241 eHalStatus status = eHAL_STATUS_SUCCESS;
2242 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2243 tANI_U16 reasonCode;
2244 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002245
2246 if(!pSession)
2247 {
2248 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2249 return eHAL_STATUS_FAILURE;
2250 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002251
2252 //Restore AC weight in case we change it
2253 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2254 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002255 smsLog(pMac, LOG1, FL(" restore AC weights (%d-%d-%d-%d)"), pMac->roam.ucACWeights[0], pMac->roam.ucACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07002256 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2257 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2258 }
2259
2260 if ( fMICFailure )
2261 {
2262 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2263 }
2264 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2265 {
2266 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002267 }
2268 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002269 {
2270 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2271 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002272#ifdef WLAN_FEATURE_VOWIFI_11R
2273 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2274 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2275 {
2276 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
2277 palCopyMemory(pMac->hHdd, &bssId, pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid, sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002278 }
2279 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002280#endif
2281 if(pSession->pConnectBssDesc)
2282 {
2283 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2284 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002285
Jeff Johnson295189b2012-06-20 16:38:30 -07002286
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002287 smsLog( pMac, LOG2, "CSR Attempting to Disassociate Bssid=%02x-%02x-%02x-%02x-%02x-%02x"
2288 "subState = %d reason=%d", bssId[ 0 ], bssId[ 1 ], bssId[ 2 ], bssId[ 3 ],
2289 bssId[ 4 ], bssId[ 5 ], NewSubstate, reasonCode);
2290
Jeff Johnson295189b2012-06-20 16:38:30 -07002291 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2292
2293 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2294
2295 if(HAL_STATUS_SUCCESS(status))
2296 {
2297 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002298#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2299 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2300 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2301 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002302 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07002303 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
2304 }
2305#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002306 }
2307 else
2308 {
2309 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
2310 }
2311
Jeff Johnson295189b2012-06-20 16:38:30 -07002312 return (status);
2313}
Jeff Johnson295189b2012-06-20 16:38:30 -07002314
Jeff Johnson295189b2012-06-20 16:38:30 -07002315/* ---------------------------------------------------------------------------
2316 \fn csrRoamIssueDisassociateStaCmd
2317 \brief csr function that HDD calls to disassociate a associated station
2318 \param sessionId - session Id for Soft AP
2319 \param pPeerMacAddr - MAC of associated station to delete
2320 \param reason - reason code, be one of the tSirMacReasonCodes
2321 \return eHalStatus
2322 ---------------------------------------------------------------------------*/
2323eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
2324 tANI_U32 sessionId,
2325 tANI_U8 *pPeerMacAddr,
2326 tANI_U32 reason)
2327{
2328 eHalStatus status = eHAL_STATUS_SUCCESS;
2329 tSmeCmd *pCommand;
2330
2331 do
2332 {
2333 pCommand = csrGetCommandBuffer( pMac );
2334 if ( !pCommand )
2335 {
2336 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2337 status = eHAL_STATUS_RESOURCES;
2338 break;
2339 }
2340 pCommand->command = eSmeCommandRoam;
2341 pCommand->sessionId = (tANI_U8)sessionId;
2342 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
2343 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2344 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2345 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2346 if( !HAL_STATUS_SUCCESS( status ) )
2347 {
2348 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
2349 csrReleaseCommandRoam( pMac, pCommand );
2350 }
2351 }while(0);
2352
2353 return status;
2354}
2355
2356
Jeff Johnson295189b2012-06-20 16:38:30 -07002357/* ---------------------------------------------------------------------------
2358 \fn csrRoamIssueDeauthSta
2359 \brief csr function that HDD calls to delete a associated station
2360 \param sessionId - session Id for Soft AP
2361 \param pPeerMacAddr - MAC of associated station to delete
2362 \param reason - reason code, be one of the tSirMacReasonCodes
2363 \return eHalStatus
2364 ---------------------------------------------------------------------------*/
2365eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
2366 tANI_U32 sessionId,
2367 tANI_U8 *pPeerMacAddr,
2368 tANI_U32 reason)
2369{
2370 eHalStatus status = eHAL_STATUS_SUCCESS;
2371 tSmeCmd *pCommand;
2372
2373 do
2374 {
2375 pCommand = csrGetCommandBuffer( pMac );
2376 if ( !pCommand )
2377 {
2378 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2379 status = eHAL_STATUS_RESOURCES;
2380 break;
2381 }
2382 pCommand->command = eSmeCommandRoam;
2383 pCommand->sessionId = (tANI_U8)sessionId;
2384 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
2385 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2386 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2387 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2388 if( !HAL_STATUS_SUCCESS( status ) )
2389 {
2390 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
2391 csrReleaseCommandRoam( pMac, pCommand );
2392 }
2393 }while(0);
2394
2395 return status;
2396}
Jeff Johnson295189b2012-06-20 16:38:30 -07002397eHalStatus
2398csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
2399 tANI_BOOLEAN bEnable )
2400{
2401 eHalStatus status = eHAL_STATUS_FAILURE;
2402 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2403 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002404 if (!pSession)
2405 {
2406 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found\n");
2407 return (status);
2408 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002409 if (pSession->pConnectBssDesc)
2410 {
2411 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2412 }
2413 else
2414 {
2415 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found\n");
2416 return (status);
2417 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002418 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = %02x-%02x-%02x-%02x-%02x-%02x, Enable = %d\n",
2419 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2420 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] , bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002421 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
2422 return (status);
2423}
Jeff Johnson295189b2012-06-20 16:38:30 -07002424eHalStatus
2425csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
2426 VOS_MODULE_ID modId, void *pUsrContext,
2427 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
2428{
2429 eHalStatus status = eHAL_STATUS_SUCCESS;
2430 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2431 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002432 if (!pSession)
2433 {
2434 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found\n");
2435 return (status);
2436 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002437 if(pSession->pConnectBssDesc)
2438 {
2439 palCopyMemory( pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid) );
2440 }
2441 else
2442 {
2443 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found\n");
2444 return (status);
2445 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002446 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = %02x-%02x-%02x-%02x-%02x-%02x\n",
2447 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2448 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002449 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2450 return (status);
2451}
Jeff Johnson295189b2012-06-20 16:38:30 -07002452eHalStatus
2453csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
2454 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
2455{
2456 eHalStatus status = eHAL_STATUS_SUCCESS;
2457 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2458 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2459
2460 if (!pSession)
2461 {
2462 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found\n");
2463 return (status);
2464 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002465 if(pSession->pConnectBssDesc)
2466 {
2467 palCopyMemory( pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid) );
2468 }
2469 else
2470 {
2471 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found\n");
2472 return (status);
2473 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002474 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = %02x-%02x-%02x-%02x-%02x-%02x\n",
2475 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2476 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
2477
2478 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2479
2480 return (status);
2481}
Jeff Johnson295189b2012-06-20 16:38:30 -07002482eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
2483{
2484 eHalStatus status = eHAL_STATUS_SUCCESS;
2485 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2486 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002487
2488 if (!pSession)
2489 {
2490 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2491 return eHAL_STATUS_FAILURE;
2492 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002493
2494 if(pSession->pConnectBssDesc)
2495 {
2496 palCopyMemory(pMac->hHdd, &bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
2497 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002498 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= %02x-%02x-%02x-%02x-%02x-%02x\n",
2499 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2500 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002501 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2502
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302503 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002504 if(!HAL_STATUS_SUCCESS(status))
2505 {
2506 smsLog(pMac, LOGW, FL("csrSendMBDeauthReqMsg failed with status %d"), status);
2507 }
2508
Jeff Johnson295189b2012-06-20 16:38:30 -07002509 return (status);
2510}
2511
Jeff Johnson295189b2012-06-20 16:38:30 -07002512eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
2513{
2514 eHalStatus status = eHAL_STATUS_SUCCESS;
2515 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2516 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002517
2518 if(!pSession)
2519 {
2520 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2521 return eHAL_STATUS_FAILURE;
2522 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002523
2524 // If no BSS description was found in this connection (happens with start IBSS), then
2525 // nix the BSS description that we keep around for the connected BSS) and get out...
2526 if(NULL == pBssDesc)
2527 {
2528 csrFreeConnectBssDesc(pMac, sessionId);
2529 }
2530 else
2531 {
2532 size = pBssDesc->length + sizeof( pBssDesc->length );
2533 if(NULL != pSession->pConnectBssDesc)
2534 {
2535 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
2536 {
2537 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
2538 csrFreeConnectBssDesc(pMac, sessionId);
2539 }
2540 }
2541 if(NULL == pSession->pConnectBssDesc)
2542 {
2543 status = palAllocateMemory( pMac->hHdd, (void **)&pSession->pConnectBssDesc, size);
2544 }
2545 if ( HAL_STATUS_SUCCESS(status) && pSession->pConnectBssDesc )
2546 {
2547 palCopyMemory( pMac->hHdd, pSession->pConnectBssDesc, pBssDesc, size );
2548 }
2549 }
2550
2551 return (status);
2552}
2553
Jeff Johnson295189b2012-06-20 16:38:30 -07002554eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2555 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
2556 tDot11fBeaconIEs *pIes)
2557{
2558 eHalStatus status = eHAL_STATUS_SUCCESS;
2559 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002560#if defined(VOSS_ENABLED)
2561 VOS_ASSERT( pIes != NULL );
2562#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002563
Jeff Johnson295189b2012-06-20 16:38:30 -07002564 do
2565 {
2566 palCopyMemory(pMac->hHdd, &pBssConfig->BssCap, &pBssDesc->capabilityInfo, sizeof(tSirMacCapabilityInfo));
2567 //get qos
2568 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
2569 //get SSID
2570 if(pIes->SSID.present)
2571 {
2572 palCopyMemory(pMac->hHdd, &pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
2573 pBssConfig->SSID.length = pIes->SSID.num_ssid;
2574 }
2575 else
2576 pBssConfig->SSID.length = 0;
2577 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
2578 {
2579 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard\n");
2580 //Return failed if profile doesn't have an SSID either.
2581 if(pProfile->SSIDs.numOfSSIDs == 0)
2582 {
2583 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID\n");
2584 status = eHAL_STATUS_FAILURE;
2585 break;
2586 }
2587 }
2588 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
2589 {
2590 pBssConfig->eBand = eCSR_BAND_5G;
2591 }
2592 else
2593 {
2594 pBssConfig->eBand = eCSR_BAND_24;
2595 }
2596 //phymode
2597 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
2598 {
2599 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
2600 }
2601 else
2602 {
2603 smsLog(pMac, LOGW, " Can not find match phy mode\n");
2604 //force it
2605 if(eCSR_BAND_24 == pBssConfig->eBand)
2606 {
2607 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2608 }
2609 else
2610 {
2611 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2612 }
2613 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002614 //Qos
2615 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
2616 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
2617 {
2618 //Joining BSS is not 11n capable and WMM is disabled on client.
2619 //Disable QoS and WMM
2620 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2621 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302622
2623 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05302624 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302625 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
2626 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
2627 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
2628 {
2629 //Joining BSS is 11n capable and WMM is disabled on AP.
2630 //Assume all HT AP's are QOS AP's and enable WMM
2631 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2632 }
2633
Jeff Johnson295189b2012-06-20 16:38:30 -07002634 //auth type
2635 switch( pProfile->negotiatedAuthType )
2636 {
2637 default:
2638 case eCSR_AUTH_TYPE_WPA:
2639 case eCSR_AUTH_TYPE_WPA_PSK:
2640 case eCSR_AUTH_TYPE_WPA_NONE:
2641 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2642 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2643 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002644 case eCSR_AUTH_TYPE_SHARED_KEY:
2645 pBssConfig->authType = eSIR_SHARED_KEY;
2646 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002647 case eCSR_AUTH_TYPE_AUTOSWITCH:
2648 pBssConfig->authType = eSIR_AUTO_SWITCH;
2649 break;
2650 }
2651 //short slot time
2652 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
2653 {
2654 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2655 }
2656 else
2657 {
2658 pBssConfig->uShortSlotTime = 0;
2659 }
2660 if(pBssConfig->BssCap.ibss)
2661 {
2662 //We don't support 11h on IBSS
2663 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2664 }
2665 else
2666 {
2667 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
2668 }
2669 //power constraint
2670 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
2671 //heartbeat
2672 if ( CSR_IS_11A_BSS( pBssDesc ) )
2673 {
2674 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2675 }
2676 else
2677 {
2678 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2679 }
2680 //Join timeout
2681 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07002682 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07002683 if ( pBssDesc->beaconInterval )
2684 {
2685 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07002686 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002687 }
2688 else
2689 {
2690 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
2691 }
2692 //validate CB
2693 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
2694 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002695 return (status);
2696}
2697
Jeff Johnson295189b2012-06-20 16:38:30 -07002698static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2699 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
2700{
2701 eHalStatus status = eHAL_STATUS_SUCCESS;
2702 tANI_U8 operationChannel = 0;
2703 tANI_U8 qAPisEnabled = FALSE;
2704 //SSID
2705 pBssConfig->SSID.length = 0;
2706 if(pProfile->SSIDs.numOfSSIDs)
2707 {
2708 //only use the first one
2709 palCopyMemory(pMac->hHdd, &pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID, sizeof(tSirMacSSid));
2710 }
2711 else
2712 {
2713 //SSID must present
2714 return eHAL_STATUS_FAILURE;
2715 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002716 //Settomg up the capabilities
2717 if( csrIsBssTypeIBSS(pProfile->BSSType) )
2718 {
2719 pBssConfig->BssCap.ibss = 1;
2720 }
2721 else
2722 {
2723 pBssConfig->BssCap.ess = 1;
2724 }
2725 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
2726 {
2727 pBssConfig->BssCap.privacy = 1;
2728 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002729 pBssConfig->eBand = pMac->roam.configParam.eBand;
2730 //phymode
2731 if(pProfile->ChannelInfo.ChannelList)
2732 {
2733 operationChannel = pProfile->ChannelInfo.ChannelList[0];
2734 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002735 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
2736 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07002737 //QOS
2738 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07002739 if ( pBssConfig->BssCap.ess == 1 )
2740 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002741 /*For Softap case enable WMM*/
2742 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
2743 qAPisEnabled = TRUE;
2744 }
2745 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002746 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
2747 qAPisEnabled = TRUE;
2748 } else {
2749 qAPisEnabled = FALSE;
2750 }
2751 } else {
2752 qAPisEnabled = TRUE;
2753 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002754 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
2755 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
2756 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
2757 )
2758 {
2759 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2760 } else {
2761 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2762 }
2763
2764 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08002765 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07002766 {
2767 default:
2768 case eCSR_AUTH_TYPE_WPA:
2769 case eCSR_AUTH_TYPE_WPA_PSK:
2770 case eCSR_AUTH_TYPE_WPA_NONE:
2771 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2772 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2773 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002774 case eCSR_AUTH_TYPE_SHARED_KEY:
2775 pBssConfig->authType = eSIR_SHARED_KEY;
2776 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002777 case eCSR_AUTH_TYPE_AUTOSWITCH:
2778 pBssConfig->authType = eSIR_AUTO_SWITCH;
2779 break;
2780 }
2781 //short slot time
2782 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
2783 {
2784 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2785 }
2786 else
2787 {
2788 pBssConfig->uShortSlotTime = 0;
2789 }
2790 //power constraint. We don't support 11h on IBSS
2791 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2792 pBssConfig->uPowerLimit = 0;
2793 //heartbeat
2794 if ( eCSR_BAND_5G == pBssConfig->eBand )
2795 {
2796 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2797 }
2798 else
2799 {
2800 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2801 }
2802 //Join timeout
2803 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07002804
Jeff Johnson295189b2012-06-20 16:38:30 -07002805 return (status);
2806}
Jeff Johnson295189b2012-06-20 16:38:30 -07002807static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
2808{
2809 eHalStatus status = eHAL_STATUS_FAILURE;
2810 tDot11fBeaconIEs *pIes = NULL;
2811
2812 do
2813 {
2814 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
2815 {
2816 //err msg
2817 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
2818 "csrRoamGetQosInfoFromBss() failed\n");
Jeff Johnson295189b2012-06-20 16:38:30 -07002819 break;
2820 }
2821 //check if the AP is QAP & it supports APSD
2822 if( CSR_IS_QOS_BSS(pIes) )
2823 {
2824 return eHAL_STATUS_SUCCESS;
2825 }
2826 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002827 return status;
2828}
2829
Jeff Johnson295189b2012-06-20 16:38:30 -07002830void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
2831{
Jeff Johnson295189b2012-06-20 16:38:30 -07002832 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
2833 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
2834 // See !!Note: below in this function...
2835 tANI_U32 PrivacyEnabled = 0;
2836 tANI_U32 RsnEnabled = 0;
2837 tANI_U32 WepDefaultKeyId = 0;
2838 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
2839 tANI_U32 Key0Length = 0;
2840 tANI_U32 Key1Length = 0;
2841 tANI_U32 Key2Length = 0;
2842 tANI_U32 Key3Length = 0;
2843
2844 // Reserve for the biggest key
2845 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
2846 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
2847 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
2848 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
2849
2850 switch ( pProfile->negotiatedUCEncryptionType )
2851 {
2852 case eCSR_ENCRYPT_TYPE_NONE:
2853
2854 // for NO encryption, turn off Privacy and Rsn.
2855 PrivacyEnabled = 0;
2856 RsnEnabled = 0;
2857
2858 // WEP key length and Wep Default Key ID don't matter in this case....
2859
2860 // clear out the WEP keys that may be hanging around.
2861 Key0Length = 0;
2862 Key1Length = 0;
2863 Key2Length = 0;
2864 Key3Length = 0;
2865
2866 break;
2867
2868 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
2869
2870 // Privacy is ON. NO RSN for Wep40 static key.
2871 PrivacyEnabled = 1;
2872 RsnEnabled = 0;
2873
2874 // Set the Wep default key ID.
2875 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07002876 // Wep key size if 5 bytes (40 bits).
2877 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
2878
2879 // set encryption keys in the CFG database or clear those that are not present in this profile.
2880 if ( pProfile->Keys.KeyLength[0] )
2881 {
2882 palCopyMemory( pMac->hHdd, Key0, pProfile->Keys.KeyMaterial[0], WNI_CFG_WEP_KEY_LENGTH_5 );
2883 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
2884 }
2885 else
2886 {
2887 Key0Length = 0;
2888 }
2889
2890 if ( pProfile->Keys.KeyLength[1] )
2891 {
2892 palCopyMemory( pMac->hHdd, Key1, pProfile->Keys.KeyMaterial[1], WNI_CFG_WEP_KEY_LENGTH_5 );
2893 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
2894 }
2895 else
2896 {
2897 Key1Length = 0;
2898 }
2899
2900 if ( pProfile->Keys.KeyLength[2] )
2901 {
2902 palCopyMemory( pMac->hHdd, Key2, pProfile->Keys.KeyMaterial[2], WNI_CFG_WEP_KEY_LENGTH_5 );
2903 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
2904 }
2905 else
2906 {
2907 Key2Length = 0;
2908 }
2909
2910 if ( pProfile->Keys.KeyLength[3] )
2911 {
2912 palCopyMemory( pMac->hHdd, Key3, pProfile->Keys.KeyMaterial[3], WNI_CFG_WEP_KEY_LENGTH_5 );
2913 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
2914 }
2915 else
2916 {
2917 Key3Length = 0;
2918 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002919 break;
2920
2921 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
2922
2923 // Privacy is ON. NO RSN for Wep40 static key.
2924 PrivacyEnabled = 1;
2925 RsnEnabled = 0;
2926
2927 // Set the Wep default key ID.
2928 WepDefaultKeyId = pProfile->Keys.defaultIndex;
2929
2930 // Wep key size if 13 bytes (104 bits).
2931 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
2932
2933 // set encryption keys in the CFG database or clear those that are not present in this profile.
2934 if ( pProfile->Keys.KeyLength[0] )
2935 {
2936 palCopyMemory( pMac->hHdd, Key0, pProfile->Keys.KeyMaterial[ 0 ], WNI_CFG_WEP_KEY_LENGTH_13 );
2937 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
2938 }
2939 else
2940 {
2941 Key0Length = 0;
2942 }
2943
2944 if ( pProfile->Keys.KeyLength[1] )
2945 {
2946 palCopyMemory( pMac->hHdd, Key1, pProfile->Keys.KeyMaterial[ 1 ], WNI_CFG_WEP_KEY_LENGTH_13 );
2947 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
2948 }
2949 else
2950 {
2951 Key1Length = 0;
2952 }
2953
2954 if ( pProfile->Keys.KeyLength[2] )
2955 {
2956 palCopyMemory( pMac->hHdd, Key2, pProfile->Keys.KeyMaterial[ 2 ], WNI_CFG_WEP_KEY_LENGTH_13 );
2957 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
2958 }
2959 else
2960 {
2961 Key2Length = 0;
2962 }
2963
2964 if ( pProfile->Keys.KeyLength[3] )
2965 {
2966 palCopyMemory( pMac->hHdd, Key3, pProfile->Keys.KeyMaterial[ 3 ], WNI_CFG_WEP_KEY_LENGTH_13 );
2967 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
2968 }
2969 else
2970 {
2971 Key3Length = 0;
2972 }
2973
2974 break;
2975
2976 case eCSR_ENCRYPT_TYPE_WEP40:
2977 case eCSR_ENCRYPT_TYPE_WEP104:
2978 case eCSR_ENCRYPT_TYPE_TKIP:
2979 case eCSR_ENCRYPT_TYPE_AES:
2980#ifdef FEATURE_WLAN_WAPI
2981 case eCSR_ENCRYPT_TYPE_WPI:
2982#endif /* FEATURE_WLAN_WAPI */
2983 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
2984 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
2985 PrivacyEnabled = (0 != fPrivacy);
2986
2987 // turn on RSN enabled for WPA associations
2988 RsnEnabled = 1;
2989
2990 // WEP key length and Wep Default Key ID don't matter in this case....
2991
2992 // clear out the static WEP keys that may be hanging around.
2993 Key0Length = 0;
2994 Key1Length = 0;
2995 Key2Length = 0;
2996 Key3Length = 0;
2997
2998 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002999 default:
3000 PrivacyEnabled = 0;
3001 RsnEnabled = 0;
3002 break;
3003 }
3004
3005 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3006 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3007 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3008 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3009 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3010 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3011 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3012 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3013}
3014
Jeff Johnson295189b2012-06-20 16:38:30 -07003015static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3016{
3017 tANI_U32 len = 0;
3018 if(pSSID->length <= WNI_CFG_SSID_LEN)
3019 {
3020 len = pSSID->length;
3021 }
3022 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3023}
3024
Jeff Johnson295189b2012-06-20 16:38:30 -07003025eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3026{
3027 eHalStatus status = eHAL_STATUS_SUCCESS;
3028 tANI_U32 QoSEnabled;
3029 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003030 // set the CFG enable/disable variables based on the qosType being configured...
3031 switch( qosType )
3032 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003033 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3034 QoSEnabled = FALSE;
3035 WmeEnabled = TRUE;
3036 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003037 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3038 QoSEnabled = FALSE;
3039 WmeEnabled = TRUE;
3040 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003041 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3042 QoSEnabled = FALSE;
3043 WmeEnabled = TRUE;
3044 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003045 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3046 QoSEnabled = TRUE;
3047 WmeEnabled = FALSE;
3048 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003049 case eCSR_MEDIUM_ACCESS_11e_HCF:
3050 QoSEnabled = TRUE;
3051 WmeEnabled = FALSE;
3052 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003053 default:
3054 case eCSR_MEDIUM_ACCESS_DCF:
3055 QoSEnabled = FALSE;
3056 WmeEnabled = FALSE;
3057 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003058 }
3059 //save the WMM setting for later use
3060 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003061 status = ccmCfgSetInt(pMac, WNI_CFG_QOS_ENABLED, QoSEnabled, NULL, eANI_BOOLEAN_FALSE);
3062 status = ccmCfgSetInt(pMac, WNI_CFG_WME_ENABLED, WmeEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003063 return (status);
3064}
Jeff Johnson295189b2012-06-20 16:38:30 -07003065static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
3066 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet)
3067{
3068 eHalStatus status = eHAL_STATUS_FAILURE;
3069 int i;
3070 eCsrCfgDot11Mode cfgDot11Mode;
3071 tANI_U8 *pDstRate;
Jeff Johnson295189b2012-06-20 16:38:30 -07003072 palZeroMemory(pMac->hHdd, pOpRateSet, sizeof(tSirMacRateSet));
3073 palZeroMemory(pMac->hHdd, pExRateSet, sizeof(tSirMacRateSet));
Jeff Johnson295189b2012-06-20 16:38:30 -07003074#if defined(VOSS_ENABLED)
3075 VOS_ASSERT( pIes != NULL );
3076#endif
3077
3078 if( NULL != pIes )
3079 {
3080 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003081 // Originally, we thought that for 11a networks, the 11a rates are always
3082 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3083 // appear in the Operational Rate set. Consequently, in either case, we
3084 // would blindly put the rates we support into our Operational Rate set
3085 // (including the basic rates, which we have already verified are
3086 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003087 // However, it turns out that this is not always the case. Some AP's
3088 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3089 // too. Now, we're a little more careful:
3090 pDstRate = pOpRateSet->rate;
3091 if(pIes->SuppRates.present)
3092 {
3093 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3094 {
3095 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3096 {
3097 *pDstRate++ = pIes->SuppRates.rates[ i ];
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003098 pOpRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003099 }
3100 }
3101 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003102 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3103 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3104 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3105 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3106 {
3107 // If there are Extended Rates in the beacon, we will reflect those
3108 // extended rates that we support in out Extended Operational Rate
3109 // set:
3110 pDstRate = pExRateSet->rate;
3111 if(pIes->ExtSuppRates.present)
3112 {
3113 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3114 {
3115 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) )
3116 {
3117 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3118 pExRateSet->numRates++;
3119 }
3120 }
3121 }
3122 }
3123 }//Parsing BSSDesc
3124 else
3125 {
3126 smsLog(pMac, LOGE, FL("failed to parse BssDesc\n"));
3127 }
3128 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3129 return status;
3130}
3131
3132static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3133 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3134{
3135 int i;
3136 tANI_U8 *pDstRate;
3137 eCsrCfgDot11Mode cfgDot11Mode;
3138 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3139 tANI_U32 OperationalRatesLength = 0;
3140 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3141 tANI_U32 ExtendedOperationalRatesLength = 0;
3142 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3143 tANI_U32 ProprietaryOperationalRatesLength = 0;
3144 tANI_U32 PropRatesEnable = 0;
3145 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3146 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003147#if defined(VOSS_ENABLED)
3148 VOS_ASSERT( pIes != NULL );
3149#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003150 if( NULL != pIes )
3151 {
3152 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003153 // Originally, we thought that for 11a networks, the 11a rates are always
3154 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3155 // appear in the Operational Rate set. Consequently, in either case, we
3156 // would blindly put the rates we support into our Operational Rate set
3157 // (including the basic rates, which we have already verified are
3158 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003159 // However, it turns out that this is not always the case. Some AP's
3160 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3161 // too. Now, we're a little more careful:
3162 pDstRate = OperationalRates;
3163 if(pIes->SuppRates.present)
3164 {
3165 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3166 {
3167 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3168 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3169 {
3170 *pDstRate++ = pIes->SuppRates.rates[ i ];
3171 OperationalRatesLength++;
3172 }
3173 }
3174 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003175 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3176 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3177 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3178 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3179 {
3180 // If there are Extended Rates in the beacon, we will reflect those
3181 // extended rates that we support in out Extended Operational Rate
3182 // set:
3183 pDstRate = ExtendedOperationalRates;
3184 if(pIes->ExtSuppRates.present)
3185 {
3186 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3187 {
3188 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3189 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3190 {
3191 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3192 ExtendedOperationalRatesLength++;
3193 }
3194 }
3195 }
3196 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003197 // Enable proprietary MAC features if peer node is Airgo node and STA
3198 // user wants to use them
3199 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3200 {
3201 PropRatesEnable = 1;
3202 }
3203 else
3204 {
3205 PropRatesEnable = 0;
3206 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003207 // For ANI network companions, we need to populate the proprietary rate
3208 // set with any proprietary rates we found in the beacon, only if user
3209 // allows them...
3210 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3211 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3212 {
3213 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3214 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3215 {
3216 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3217 }
3218 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates, pIes->Airgo.PropSuppRates.rates, ProprietaryOperationalRatesLength );
3219 }
3220 else {
3221 // No proprietary modes...
3222 ProprietaryOperationalRatesLength = 0;
3223 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003224 /* Get MCS Rate */
3225 pDstRate = MCSRateIdxSet;
3226 if ( pIes->HTCaps.present )
3227 {
3228 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3229 {
3230 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3231 {
3232 MCSRateLength++;
3233 *pDstRate++ = i;
3234 }
3235 }
3236 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003237 // Set the operational rate set CFG variables...
3238 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3239 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3240 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3241 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3242 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3243 ProprietaryOperationalRates,
3244 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3245 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3246 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3247 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3248 }//Parsing BSSDesc
3249 else
3250 {
3251 smsLog(pMac, LOGE, FL("failed to parse BssDesc\n"));
3252 }
3253}
3254
Jeff Johnson295189b2012-06-20 16:38:30 -07003255static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3256 tCsrRoamProfile *pProfile )
3257{
3258 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3259 { 8,
3260 { SIR_MAC_RATE_6,
3261 SIR_MAC_RATE_9,
3262 SIR_MAC_RATE_12,
3263 SIR_MAC_RATE_18,
3264 SIR_MAC_RATE_24,
3265 SIR_MAC_RATE_36,
3266 SIR_MAC_RATE_48,
3267 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003268 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3269 { 4,
3270 { SIR_MAC_RATE_1,
3271 SIR_MAC_RATE_2,
3272 SIR_MAC_RATE_5_5,
3273 SIR_MAC_RATE_11 } } };
3274
3275
3276 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3277 { SIR_MAC_RATE_72,
3278 SIR_MAC_RATE_96,
3279 SIR_MAC_RATE_108 } };
3280 eCsrCfgDot11Mode cfgDot11Mode;
3281 eCsrBand eBand;
3282 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3283 tANI_U32 OperationalRatesLength = 0;
3284 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3285 tANI_U32 ExtendedOperationalRatesLength = 0;
3286 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3287 tANI_U32 ProprietaryOperationalRatesLength = 0;
3288 tANI_U32 PropRatesEnable = 0;
3289 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003290 if(pProfile->ChannelInfo.ChannelList)
3291 {
3292 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3293 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003294 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07003295 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3296 // networks, the 11b rates appear in the Operational Rate set. In either case,
3297 // we can blindly put the rates we support into our Operational Rate set
3298 // (including the basic rates, which we have already verified are supported
3299 // earlier in the roaming decision).
3300 if ( eCSR_BAND_5G == eBand )
3301 {
3302 // 11a rates into the Operational Rate Set.
3303 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3304 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
3305 palCopyMemory( pMac->hHdd, OperationalRates,
3306 DefaultSupportedRates11a.supportedRateSet.rate,
3307 OperationalRatesLength );
3308
3309 // Nothing in the Extended rate set.
3310 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003311 // populate proprietary rates if user allows them
3312 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3313 {
3314 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3315 sizeof(*DefaultSupportedPropRates.propRate);
3316 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates,
3317 DefaultSupportedPropRates.propRate,
3318 ProprietaryOperationalRatesLength );
3319 }
3320 else
3321 {
3322 // No proprietary modes
3323 ProprietaryOperationalRatesLength = 0;
3324 }
3325 }
3326 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3327 {
3328 // 11b rates into the Operational Rate Set.
3329 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3330 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
3331 palCopyMemory( pMac->hHdd, OperationalRates,
3332 DefaultSupportedRates11b.supportedRateSet.rate,
3333 OperationalRatesLength );
3334 // Nothing in the Extended rate set.
3335 ExtendedOperationalRatesLength = 0;
3336 // No proprietary modes
3337 ProprietaryOperationalRatesLength = 0;
3338 }
3339 else
3340 {
3341 // 11G
3342
3343 // 11b rates into the Operational Rate Set.
3344 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3345 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
3346 palCopyMemory( pMac->hHdd, OperationalRates,
3347 DefaultSupportedRates11b.supportedRateSet.rate,
3348 OperationalRatesLength );
3349
3350 // 11a rates go in the Extended rate set.
3351 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3352 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
3353 palCopyMemory( pMac->hHdd, ExtendedOperationalRates,
3354 DefaultSupportedRates11a.supportedRateSet.rate,
3355 ExtendedOperationalRatesLength );
3356
3357 // populate proprietary rates if user allows them
3358 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3359 {
3360 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3361 sizeof(*DefaultSupportedPropRates.propRate);
3362 palCopyMemory( pMac->hHdd, ProprietaryOperationalRates,
3363 DefaultSupportedPropRates.propRate,
3364 ProprietaryOperationalRatesLength );
3365 }
3366 else
3367 {
3368 // No proprietary modes
3369 ProprietaryOperationalRatesLength = 0;
3370 }
3371 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003372 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3373 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3374 {
3375 PropRatesEnable = 1;
3376 }
3377 else
3378 {
3379 PropRatesEnable = 0;
3380 }
3381
3382 // Set the operational rate set CFG variables...
3383 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3384 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3385 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3386 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3387 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3388 ProprietaryOperationalRates,
3389 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3390 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003391}
Jeff Johnson295189b2012-06-20 16:38:30 -07003392void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3393{
3394 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07003395
Jeff Johnson295189b2012-06-20 16:38:30 -07003396 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3397 tANI_U32 sessionId;
3398 tSmeCmd *pCommand = NULL;
3399
3400 if(NULL == pEntry)
3401 {
3402 smsLog(pMac, LOGW, " CFG_CNF with active list empty\n");
3403 return;
3404 }
3405 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3406 sessionId = pCommand->sessionId;
3407
3408 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3409 {
3410 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3411 }
3412}
3413
Jeff Johnson295189b2012-06-20 16:38:30 -07003414//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3415tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3416{
3417 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3418 {
3419 return (WNI_CFG_PHY_MODE_11B);
3420 }
3421 else
3422 {
3423 if(eCSR_BAND_24 == band)
3424 return (WNI_CFG_PHY_MODE_11G);
3425 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003426 return (WNI_CFG_PHY_MODE_11A);
3427}
Jeff Johnson295189b2012-06-20 16:38:30 -07003428
Jeff Johnsone7245742012-09-05 17:12:55 -07003429
3430#ifdef WLAN_FEATURE_11AC
3431ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
3432{
3433 switch ( aniCBMode )
3434 {
3435 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
3436 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
3437 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
3438 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3439 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
3440 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
3441 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
3442 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3443 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003444 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07003445 return PHY_SINGLE_CHANNEL_CENTERED;
3446 }
3447}
3448#endif
3449
Jeff Johnson295189b2012-06-20 16:38:30 -07003450//pIes may be NULL
3451eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3452 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
3453 tDot11fBeaconIEs *pIes)
3454{
3455 eHalStatus status = eHAL_STATUS_SUCCESS;
3456 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3457 tANI_U8 channel = 0;
3458 //Make sure we have the domain info for the BSS we try to connect to.
3459 //Do we need to worry about sequence for OSs that are not Windows??
3460 if(pBssDesc)
3461 {
3462 if(csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
3463 {
3464 //Make sure the 11d info from this BSSDesc can be applied
3465 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
3466 csrApplyCountryInformation( pMac, TRUE );
3467 }
Kiran4a17ebe2013-01-31 10:43:43 -08003468 if ((csrIs11dSupported (pMac)) && pIes)
3469 {
3470 if (!pIes->Country.present)
3471 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
3472 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003473 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003474 //Qos
3475 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3476 //SSID
3477 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3478 //fragment threshold
3479 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3480 //RTS threshold
3481 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3482
3483 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
3484
3485 //Auth type
3486 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
3487 //encryption type
3488 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
3489 //short slot time
3490 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003491 //11d
3492 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
3493 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
3494 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003495 /*//11h
3496 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
3497 */
3498 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
3499 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07003500
Jeff Johnson295189b2012-06-20 16:38:30 -07003501 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile))
3502 {
3503 channel = pProfile->operationChannel;
3504 }
3505 else
3506 {
3507 if(pBssDesc)
3508 {
3509 channel = pBssDesc->channelId;
3510 }
3511 }
3512 if(0 != channel)
3513 {
3514 if(CSR_IS_CHANNEL_24GHZ(channel))
3515 {//for now if we are on 2.4 Ghz, CB will be always disabled
3516 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3517 }
3518 else
3519 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003520 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003521 }
3522 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003523#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08003524 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
3525 // in function csrConvertCBIniValueToPhyCBState()
3526 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
3527 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07003528 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003529 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003530 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003531 }
3532 else
3533 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003534 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003535 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003536 }
3537 else
3538#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003539 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
3540 //Rate
3541 //Fixed Rate
3542 if(pBssDesc)
3543 {
3544 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
3545 }
3546 else
3547 {
3548 csrSetCfgRateSetFromProfile(pMac, pProfile);
3549 }
3550 //Make this the last CFG to set. The callback will trigger a join_req
3551 //Join time out
3552 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
3553
3554 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003555 return (status);
3556}
3557
Jeff Johnson295189b2012-06-20 16:38:30 -07003558eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3559 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3560{
3561 eHalStatus status;
3562 tBssConfigParam *pBssConfig;
3563 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003564
3565 if(!pSession)
3566 {
3567 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3568 return eHAL_STATUS_FAILURE;
3569 }
3570
Jeff Johnson295189b2012-06-20 16:38:30 -07003571 status = palAllocateMemory(pMac->hHdd, (void **)&pBssConfig, sizeof(tBssConfigParam));
3572 if(HAL_STATUS_SUCCESS(status))
3573 {
3574 palZeroMemory(pMac->hHdd, pBssConfig, sizeof(tBssConfigParam));
3575 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
3576 if(HAL_STATUS_SUCCESS(status))
3577 {
3578 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003579 /* This will allow to pass cbMode during join req */
3580 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003581 //For IBSS, we need to prepare some more information
3582 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003583 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003584 )
3585 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003586 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07003587 }
3588 // If we are in an IBSS, then stop the IBSS...
3589 ////Not worry about WDS connection for now
3590 if ( csrIsConnStateIbss( pMac, sessionId ) )
3591 {
3592 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
3593 }
3594 else
3595 {
3596 // if we are in an Infrastructure association....
3597 if ( csrIsConnStateInfra( pMac, sessionId ) )
3598 {
3599 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
3600 // across SSIDs (roaming to a new SSID)... //
3601 //Not worry about WDS connection for now
3602 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
3603 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
3604 {
3605 // then we need to disassociate from the Infrastructure network...
3606 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
3607 }
3608 else
3609 {
3610 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
3611 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
3612 if ( pBssDesc )
3613 {
3614 // Set parameters for this Bss.
3615 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
3616 }
3617 }
3618 }
3619 else
3620 {
3621 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
3622 // Nothing to stop.
3623 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003624 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003625 )
3626 {
3627 // Set parameters for this Bss.
3628 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
3629 }
3630 }
3631 }
3632 }//Success getting BSS config info
3633 palFreeMemory(pMac->hHdd, pBssConfig);
3634 }//Allocate memory
3635
3636 return (status);
3637}
3638
Jeff Johnson295189b2012-06-20 16:38:30 -07003639eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
3640 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
3641{
3642 eCsrJoinState eRoamState = eCsrContinueRoaming;
3643 eHalStatus status;
3644 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
3645 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
3646 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003647
3648 if(!pSession)
3649 {
3650 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3651 return (eCsrStopRoaming);
3652 }
3653
Jeff Johnson295189b2012-06-20 16:38:30 -07003654 if( CSR_IS_WDS_STA( pProfile ) )
3655 {
3656 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
3657 if( !HAL_STATUS_SUCCESS( status ) )
3658 {
3659 eRoamState = eCsrStopRoaming;
3660 }
3661 }
3662 else
3663 {
3664 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
3665 {
3666 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
3667 return (eCsrStopRoaming);
3668 }
3669 if ( csrIsInfraBssDesc( pBssDesc ) )
3670 {
3671 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
3672 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
3673 // have changed and handle the changes (without disturbing the current association).
3674
3675 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
3676 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
3677 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
3678 )
3679 {
3680 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
3681 // with Authenticating first. To force this, stop the current association (Disassociate) and
3682 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
3683 // a new Association.
3684 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
3685 {
3686 smsLog(pMac, LOGW, FL(" detect same profile authType = %d encryType = %d\n"), pProfile->AuthType, pProfile->EncryptionType);
3687 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
3688 {
3689 eRoamState = eCsrReassocToSelfNoCapChange;
3690 }
3691 else
3692 {
3693 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07003694 //The key changes
3695 palZeroMemory(pMac->hHdd, &bssConfig, sizeof(bssConfig));
3696 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
3697 if(HAL_STATUS_SUCCESS(status))
3698 {
3699 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003700 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003701 //Reapply the config including Keys so reassoc is happening.
3702 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, pBssDesc, &bssConfig, pIesLocal);
3703 if(!HAL_STATUS_SUCCESS(status))
3704 {
3705 eRoamState = eCsrStopRoaming;
3706 }
3707 }
3708 else
3709 {
3710 eRoamState = eCsrStopRoaming;
3711 }
3712 }//same profile
3713 }
3714 else
3715 {
3716 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
3717 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
3718 {
3719 smsLog(pMac, LOGW, FL(" fail to issue disassociate\n"));
3720 eRoamState = eCsrStopRoaming;
3721 }
3722 }
3723 }
3724 else
3725 {
3726 // note: we used to pre-auth here with open authentication networks but that was not working so well.
3727 // we had a lot of join timeouts when testing at Samsung. removing this step helped associations
3728 // work much better.
3729 //
3730 //
3731 // stop the existing network before attempting to join the new network...
3732 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
3733 {
3734 eRoamState = eCsrStopRoaming;
3735 }
3736 }
3737 }//Infra
3738 else
3739 {
3740 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
3741 {
3742 eRoamState = eCsrStopRoaming;
3743 }
3744 }
3745 if( pIesLocal && !pScanResult->pvIes )
3746 {
3747 palFreeMemory(pMac->hHdd, pIesLocal);
3748 }
3749 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003750 return( eRoamState );
3751}
3752
Jeff Johnson295189b2012-06-20 16:38:30 -07003753eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
3754 tSirBssDescription *pBssDesc, tANI_U32 roamId)
3755{
3756 eHalStatus status = eHAL_STATUS_SUCCESS;
3757 tCsrRoamInfo roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07003758 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
3759 roamInfo.pBssDesc = pBssDesc;
3760 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
3761 return (status);
3762}
Jeff Johnson295189b2012-06-20 16:38:30 -07003763//In case no matching BSS is found, use whatever default we can find
3764static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
3765{
3766 //Need to get all negotiated types in place first
3767 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003768 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003769 {
3770 default:
3771 case eCSR_AUTH_TYPE_WPA:
3772 case eCSR_AUTH_TYPE_WPA_PSK:
3773 case eCSR_AUTH_TYPE_WPA_NONE:
3774 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3775 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3776 break;
3777
3778 case eCSR_AUTH_TYPE_SHARED_KEY:
3779 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
3780 break;
3781
3782 case eCSR_AUTH_TYPE_AUTOSWITCH:
3783 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
3784 break;
3785 }
3786 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
3787 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
3788 //In this case, the multicast encryption needs to follow the uncast ones.
3789 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
3790 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
3791}
3792
3793static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
3794{
3795 eHalStatus status;
3796 tCsrScanResult *pScanResult = NULL;
3797 eCsrJoinState eRoamState = eCsrStopRoaming;
3798 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
3799 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
3800 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
3801#ifndef WLAN_MDM_CODE_REDUCTION_OPT
3802 v_U8_t acm_mask = 0;
3803#endif
3804 tANI_U32 sessionId = pCommand->sessionId;
3805 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3806 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
3807 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07003808
3809 if(!pSession)
3810 {
3811 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3812 return (eCsrStopRoaming);
3813 }
3814
Jeff Johnson295189b2012-06-20 16:38:30 -07003815 do
3816 {
3817 // Check for Cardbus eject condition, before trying to Roam to any BSS
3818 //***if( !balIsCardPresent(pAdapter) ) break;
3819
3820 if(NULL != pBSSList)
3821 {
3822 // When handling AP's capability change, continue to associate to
3823 // same BSS and make sure pRoamBssEntry is not Null.
3824 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
3825 {
3826 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
3827 {
3828 //Try the first BSS
3829 pCommand->u.roamCmd.pLastRoamBss = NULL;
3830 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
3831 }
3832 else
3833 {
3834 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
3835 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
3836 {
3837 //Done with all the BSSs
3838 //In this case, will tell HDD the completion
3839 break;
3840 }
3841 else
3842 {
3843 //We need to indicate to HDD that we are done with this one.
3844 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
3845 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
3846 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
3847 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
3848 pRoamInfo = &roamInfo;
3849 }
3850 }
3851 while(pCommand->u.roamCmd.pRoamBssEntry)
3852 {
3853 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07003854 /*If concurrency enabled take the concurrent connected channel first. */
3855 /* Valid multichannel concurrent sessions exempted */
Jeff Johnsone7245742012-09-05 17:12:55 -07003856 if (vos_concurrent_sessions_running() &&
3857 !csrIsValidMcConcurrentSession(pMac, sessionId, &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07003858 {
3859 concurrentChannel =
3860 csrGetConcurrentOperationChannel(pMac);
3861 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003862 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07003863 if ((concurrentChannel) &&
3864 (concurrentChannel ==
3865 pScanResult->Result.BssDescriptor.channelId))
3866 {
3867 //make this 0 because we do not want the
3868 //below check to pass as we don't want to
3869 //connect on other channel
3870 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
3871 FL("Concurrent channel match =%d"),
3872 concurrentChannel);
3873 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003874 }
3875 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003876
3877 if (!concurrentChannel)
3878 {
3879
3880 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
3881 sessionId, &pScanResult->Result.BssDescriptor,
3882 pCommand->u.roamCmd.roamId)))
3883 {
3884 //Ok to roam this
3885 break;
3886 }
3887 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003888 else
3889 {
3890 eRoamState = eCsrStopRoamingDueToConcurrency;
3891 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003892 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
3893 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
3894 {
3895 //Done with all the BSSs
3896 fDone = eANI_BOOLEAN_TRUE;
3897 break;
3898 }
3899 }
3900 if(fDone)
3901 {
3902 break;
3903 }
3904 }
3905 }
3906 //We have something to roam, tell HDD when it is infra.
3907 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
3908 //For WDS, the indication is eCSR_ROAM_WDS_IND
3909 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
3910 {
3911 if(pRoamInfo)
3912 {
3913 pSession->bRefAssocStartCnt--;
3914 //Complete the last association attemp because a new one is about to be tried
3915 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
3916 eCSR_ROAM_ASSOCIATION_COMPLETION,
3917 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
3918 }
3919 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
3920 if(pScanResult)
3921 {
3922 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07003923 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
3924 {
3925 smsLog(pMac, LOGE, FL(" cannot parse IEs\n"));
3926 fDone = eANI_BOOLEAN_TRUE;
3927 eRoamState = eCsrStopRoaming;
3928 break;
3929 }
3930 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
3931 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
3932 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
3933 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
3934 CSR_IS_QOS_BSS(pIesLocal) &&
3935 CSR_IS_UAPSD_BSS(pIesLocal) )
3936 {
3937#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07003938 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
3939 pIesLocal);
3940 pCommand->u.roamCmd.roamProfile.uapsd_mask &= ~(acm_mask);
3941#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07003942 }
3943 else
3944 {
3945 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
3946 }
3947 if( pIesLocal && !pScanResult->Result.pvIes)
3948 {
3949 palFreeMemory(pMac->hHdd, pIesLocal);
3950 }
3951 }
3952 else
3953 {
3954 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
3955 }
3956 roamInfo.pProfile = pProfile;
3957 pSession->bRefAssocStartCnt++;
3958 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
3959 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
3960 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003961 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
3962 {
3963 // If this is a start IBSS profile, then we need to start the IBSS.
3964 if ( CSR_IS_START_IBSS(pProfile) )
3965 {
3966 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003967 // Attempt to start this IBSS...
3968 csrRoamAssignDefaultParam( pMac, pCommand );
3969 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
3970 if(HAL_STATUS_SUCCESS(status))
3971 {
3972 if ( fSameIbss )
3973 {
3974 eRoamState = eCsrStartIbssSameIbss;
3975 }
3976 else
3977 {
3978 eRoamState = eCsrContinueRoaming;
3979 }
3980 }
3981 else
3982 {
3983 //it somehow fail need to stop
3984 eRoamState = eCsrStopRoaming;
3985 }
3986 break;
3987 }
3988 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07003989 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07003990 )
3991 {
3992 // Attempt to start this WDS...
3993 csrRoamAssignDefaultParam( pMac, pCommand );
3994 /* For AP WDS, we dont have any BSSDescription */
3995 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
3996 if(HAL_STATUS_SUCCESS(status))
3997 {
3998 eRoamState = eCsrContinueRoaming;
3999 }
4000 else
4001 {
4002 //it somehow fail need to stop
4003 eRoamState = eCsrStopRoaming;
4004 }
4005 }
4006 else
4007 {
4008 //Nothing we can do
4009 smsLog(pMac, LOGW, FL("cannot continue without BSS list\n"));
4010 eRoamState = eCsrStopRoaming;
4011 break;
4012 }
4013 }
4014 else //We have BSS
4015 {
4016 //Need to assign these value because they are used in csrIsSameProfile
4017 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4018 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType = pScanResult->ucEncryptionType; //Negotiated while building scan result.
4019 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType = pScanResult->mcEncryptionType;
4020 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4021 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4022 {
4023 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4024 {
4025 eRoamState = eCsrStartIbssSameIbss;
4026 break;
4027 }
4028 }
4029 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4030 {
4031 //trying to connect to the one already connected
4032 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4033 eRoamState = eCsrReassocToSelfNoCapChange;
4034 break;
4035 }
4036 // Attempt to Join this Bss...
4037 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4038 break;
4039 }
4040
4041 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004042 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4043 {
4044 //Need to indicate association_completion if association_start has been done
4045 if(pSession->bRefAssocStartCnt > 0)
4046 {
4047 pSession->bRefAssocStartCnt--;
4048 //Complete the last association attemp because a new one is about to be tried
4049 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4050 eCSR_ROAM_ASSOCIATION_COMPLETION,
4051 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4052 }
4053 }
4054
4055 return( eRoamState );
4056}
4057
Jeff Johnson295189b2012-06-20 16:38:30 -07004058static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4059{
4060 eHalStatus status = eHAL_STATUS_SUCCESS;
4061 eCsrJoinState RoamState;
4062 tANI_U32 sessionId = pCommand->sessionId;
4063
Jeff Johnson295189b2012-06-20 16:38:30 -07004064 //***if( hddIsRadioStateOn( pAdapter ) )
4065 {
4066 // Attept to join a Bss...
4067 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004068
Jeff Johnson295189b2012-06-20 16:38:30 -07004069 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004070 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004071 {
4072 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004073 // and if connected in Infrastructure mode...
4074 if ( csrIsConnStateInfra(pMac, sessionId) )
4075 {
4076 //... then we need to issue a disassociation
4077 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4078 if(!HAL_STATUS_SUCCESS(status))
4079 {
4080 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d\n"), status);
4081 //roam command is completed by caller in the failed case
4082 fComplete = eANI_BOOLEAN_TRUE;
4083 }
4084 }
4085 else if( csrIsConnStateIbss(pMac, sessionId) )
4086 {
4087 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4088 if(!HAL_STATUS_SUCCESS(status))
4089 {
4090 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d\n"), status);
4091 //roam command is completed by caller in the failed case
4092 fComplete = eANI_BOOLEAN_TRUE;
4093 }
4094 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004095 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4096 {
4097 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4098 if(!HAL_STATUS_SUCCESS(status))
4099 {
4100 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d\n"), status);
4101 //roam command is completed by caller in the failed case
4102 fComplete = eANI_BOOLEAN_TRUE;
4103 }
4104 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004105 else
4106 {
4107 fComplete = eANI_BOOLEAN_TRUE;
4108 }
4109 if(fComplete)
4110 {
4111 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004112 if(eCsrStopRoamingDueToConcurrency == RoamState)
4113 {
4114 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4115 }
4116 else
4117 {
4118 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4119 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004120 }
4121 }
4122 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4123 {
4124 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4125 }
4126 else if ( eCsrStartIbssSameIbss == RoamState )
4127 {
4128 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4129 }
4130 }//hddIsRadioStateOn
4131
4132 return status;
4133}
Jeff Johnson295189b2012-06-20 16:38:30 -07004134eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4135{
4136 tANI_U32 sessionId;
4137 tCsrRoamSession *pSession;
4138 tCsrScanResult *pScanResult = NULL;
4139 tSirBssDescription *pBssDesc = NULL;
4140 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004141 sessionId = pCommand->sessionId;
4142 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004143
4144 if(!pSession)
4145 {
4146 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4147 return eHAL_STATUS_FAILURE;
4148 }
4149
Jeff Johnson295189b2012-06-20 16:38:30 -07004150 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4151 {
4152 //the roaming is cancelled. Simply complete the command
4153 smsLog(pMac, LOG1, FL(" Roam command cancelled\n"));
4154 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4155 return eHAL_STATUS_FAILURE;
4156 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004157 if (pCommand->u.roamCmd.pRoamBssEntry)
4158 {
4159 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4160 pBssDesc = &pScanResult->Result.BssDescriptor;
4161 }
4162 else
4163 {
4164 //the roaming is cancelled. Simply complete the command
4165 smsLog(pMac, LOG1, FL(" Roam command cancelled\n"));
4166 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4167 return eHAL_STATUS_FAILURE;
4168 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004169 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4170 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4171 return status;
4172}
4173
Jeff Johnson295189b2012-06-20 16:38:30 -07004174eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4175{
4176 eHalStatus status = eHAL_STATUS_SUCCESS;
4177 tCsrRoamInfo roamInfo;
4178 tANI_U32 sessionId = pCommand->sessionId;
4179 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004180
4181 if(!pSession)
4182 {
4183 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4184 return eHAL_STATUS_FAILURE;
4185 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004186
4187 switch ( pCommand->u.roamCmd.roamReason )
4188 {
4189 case eCsrForcedDisassoc:
4190 csrFreeRoamProfile(pMac, sessionId);
4191 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4192 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004193 case eCsrSmeIssuedDisassocForHandoff:
4194 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4195#if 0 // TODO : Confirm this change
4196 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4197#else
4198 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4199#endif
4200
4201 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004202 case eCsrForcedDisassocMICFailure:
4203 csrFreeRoamProfile(pMac, sessionId);
4204 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
4205 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004206 case eCsrForcedDeauth:
4207 csrFreeRoamProfile(pMac, sessionId);
4208 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
4209 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004210 case eCsrHddIssuedReassocToSameAP:
4211 case eCsrSmeIssuedReassocToSameAP:
4212 {
4213 tDot11fBeaconIEs *pIes = NULL;
4214
Jeff Johnson295189b2012-06-20 16:38:30 -07004215 if( pSession->pConnectBssDesc )
4216 {
4217 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4218 if(!HAL_STATUS_SUCCESS(status) )
4219 {
4220 smsLog(pMac, LOGE, FL(" fail to parse IEs\n"));
4221 }
4222 else
4223 {
4224 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4225 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4226 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004227 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4228 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4229 pSession->bRefAssocStartCnt++;
4230 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4231 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4232
4233 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate\n"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004234 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4235 &pCommand->u.roamCmd.roamProfile );
4236 if(!HAL_STATUS_SUCCESS(status))
4237 {
4238 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
4239 }
4240
Jeff Johnson295189b2012-06-20 16:38:30 -07004241 palFreeMemory(pMac->hHdd, pIes);
4242 pIes = NULL;
4243 }
4244 }
4245 break;
4246 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004247 case eCsrCapsChange:
4248 smsLog(pMac, LOGE, FL("received eCsrCapsChange \n"));
4249 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4250 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4251 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004252 case eCsrSmeIssuedFTReassoc:
4253 smsLog(pMac, LOGE, FL("received FT Reassoc Req \n"));
4254 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4255 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004256
Jeff Johnson295189b2012-06-20 16:38:30 -07004257 case eCsrStopBss:
4258 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4259 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4260 break;
4261
4262 case eCsrForcedDisassocSta:
4263 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4264 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4265 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4266 pCommand->u.roamCmd.reason);
4267 break;
4268
4269 case eCsrForcedDeauthSta:
4270 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4271 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4272 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4273 pCommand->u.roamCmd.reason);
4274 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004275
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004276 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08004277 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004278 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4279 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004280 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004281
4282 default:
4283 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4284
4285 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4286 {
4287 //Remember the roaming profile
4288 csrFreeRoamProfile(pMac, sessionId);
4289 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd, (void **)&pSession->pCurRoamProfile, sizeof(tCsrRoamProfile))))
4290 {
4291 palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile));
4292 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4293 }
4294 }
4295
4296 //At this point, original uapsd_mask is saved in pCurRoamProfile
4297 //uapsd_mask in the pCommand may change from this point on.
4298
4299 // Attempt to roam with the new scan results (if we need to..)
4300 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004301 if(!HAL_STATUS_SUCCESS(status))
4302 {
4303 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X\n"), status);
4304 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004305 break;
4306 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004307 return (status);
4308}
4309
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004310void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4311{
4312 pCommand->u.roamCmd.pLastRoamBss = NULL;
4313 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4314 //Because u.roamCmd is union and share with scanCmd and StatusChange
4315 palZeroMemory(pMac->hHdd, &pCommand->u.roamCmd, sizeof(tRoamCmd));
4316}
4317
Jeff Johnson295189b2012-06-20 16:38:30 -07004318void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4319{
4320 if(pCommand->u.roamCmd.fReleaseBssList)
4321 {
4322 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4323 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4324 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4325 }
4326 if(pCommand->u.roamCmd.fReleaseProfile)
4327 {
4328 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4329 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4330 }
4331 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4332 //Because u.roamCmd is union and share with scanCmd and StatusChange
4333 palZeroMemory(pMac->hHdd, &pCommand->u.roamCmd, sizeof(tRoamCmd));
4334}
4335
Jeff Johnson295189b2012-06-20 16:38:30 -07004336void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4337{
4338 palZeroMemory(pMac->hHdd, &pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd));
4339}
Jeff Johnson295189b2012-06-20 16:38:30 -07004340void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4341{
4342 tListElem *pEntry;
4343 tSmeCmd *pCommand;
4344 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004345 smsLog( pMac, LOG2, "Roam Completion ...\n" );
Jeff Johnson295189b2012-06-20 16:38:30 -07004346 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4347 if ( pEntry )
4348 {
4349 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004350 // If the head of the queue is Active and it is a ROAM command, remove
4351 // and put this on the Free queue.
4352 if ( eSmeCommandRoam == pCommand->command )
4353 {
4354 //we need to process the result first before removing it from active list because state changes
4355 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4356 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4357 if( fReleaseCommand )
4358 {
4359 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4360 {
4361 csrReleaseCommandRoam( pMac, pCommand );
4362 }
4363 else
4364 {
4365 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d\n",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004366 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004367 }
4368 }
4369 else
4370 {
4371 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d\n",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004372 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004373 }
4374 }
4375 else
4376 {
4377 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ...\n" );
4378 }
4379 }
4380 else
4381 {
4382 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ...\n" );
4383 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004384 if( fReleaseCommand )
4385 {
4386 smeProcessPendingQueue( pMac );
4387 }
4388}
4389
Jeff Johnson295189b2012-06-20 16:38:30 -07004390void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4391{
4392 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004393 if(!pSession)
4394 {
4395 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4396 return;
4397 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004398 palZeroMemory( pMac->hHdd, &(pSession->PmkidCandidateInfo[0]), sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED );
4399 pSession->NumPmkidCandidate = 0;
4400}
Jeff Johnson295189b2012-06-20 16:38:30 -07004401#ifdef FEATURE_WLAN_WAPI
4402void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4403{
4404 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004405 if(!pSession)
4406 {
4407 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4408 return;
4409 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004410 palZeroMemory( pMac->hHdd, &(pSession->BkidCandidateInfo[0]), sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED );
4411 pSession->NumBkidCandidate = 0;
4412}
4413#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004414extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4415
Jeff Johnson295189b2012-06-20 16:38:30 -07004416static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4417 tSirBssDescription *pSirBssDesc,
4418 tDot11fBeaconIEs *pIes)
4419{
4420 eHalStatus status = eHAL_STATUS_SUCCESS;
4421 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4422 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004423
4424 if(!pSession)
4425 {
4426 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4427 return eHAL_STATUS_FAILURE;
4428 }
4429
Jeff Johnson295189b2012-06-20 16:38:30 -07004430 if((eCSR_AUTH_TYPE_WPA == authType) ||
4431 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
4432 (eCSR_AUTH_TYPE_RSN == authType) ||
4433 (eCSR_AUTH_TYPE_RSN_PSK == authType)
4434#if defined WLAN_FEATURE_VOWIFI_11R
4435 ||
4436 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4437 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
4438#endif /* FEATURE_WLAN_WAPI */
4439#ifdef FEATURE_WLAN_WAPI
4440 ||
4441 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4442 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
4443#endif /* FEATURE_WLAN_WAPI */
4444 )
4445 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004446 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4447 {
4448 smsLog(pMac, LOGE, FL(" cannot parse IEs\n"));
4449 }
4450 if( pIesLocal )
4451 {
4452 tANI_U32 nIeLen;
4453 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07004454 if((eCSR_AUTH_TYPE_RSN == authType) ||
4455#if defined WLAN_FEATURE_VOWIFI_11R
4456 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4457 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
4458#endif /* WLAN_FEATURE_VOWIFI_11R */
4459 (eCSR_AUTH_TYPE_RSN_PSK == authType))
4460 {
4461 if(pIesLocal->RSN.present)
4462 {
4463 //Calculate the actual length
4464 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
4465 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
4466 + 2 //akm_suite_count
4467 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
4468 + 2; //reserved
4469 if( pIesLocal->RSN.pmkid_count )
4470 {
4471 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
4472 }
4473 //nIeLen doesn't count EID and length fields
4474 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnRspIE, nIeLen + 2))))
4475 {
4476 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
4477 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4478 //copy upto akm_suites
4479 pIeBuf = pSession->pWpaRsnRspIE + 2;
4480 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.version, 8);
4481 pIeBuf += 8;
4482 if( pIesLocal->RSN.pwise_cipher_suite_count )
4483 {
4484 //copy pwise_cipher_suites
4485 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.pwise_cipher_suites,
4486 pIesLocal->RSN.pwise_cipher_suite_count * 4);
4487 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
4488 }
4489 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
4490 pIeBuf += 2;
4491 if( pIesLocal->RSN.akm_suite_count )
4492 {
4493 //copy akm_suites
4494 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.akm_suites,
4495 pIesLocal->RSN.akm_suite_count * 4);
4496 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
4497 }
4498 //copy the rest
4499 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->RSN.akm_suites +
4500 pIesLocal->RSN.akm_suite_count * 4,
4501 2 + pIesLocal->RSN.pmkid_count * 4);
4502 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4503 }
4504 }
4505 }
4506 else if((eCSR_AUTH_TYPE_WPA == authType) ||
4507 (eCSR_AUTH_TYPE_WPA_PSK == authType))
4508 {
4509 if(pIesLocal->WPA.present)
4510 {
4511 //Calculate the actual length
4512 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
4513 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
4514 + 2 //auth_suite_count
4515 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
4516 // The WPA capabilities follows the Auth Suite (two octects)--
4517 // this field is optional, and we always "send" zero, so just
4518 // remove it. This is consistent with our assumptions in the
4519 // frames compiler; c.f. bug 15234:
4520 //nIeLen doesn't count EID and length fields
4521 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnRspIE, nIeLen + 2))))
4522 {
4523 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
4524 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4525 pIeBuf = pSession->pWpaRsnRspIE + 2;
4526 //Copy WPA OUI
4527 palCopyMemory(pMac->hHdd, pIeBuf, &csrWpaOui[1], 4);
4528 pIeBuf += 4;
4529 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WPA.version, 8 +
4530 pIesLocal->WPA.unicast_cipher_count * 4);
4531 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
4532 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WPA.auth_suite_count, 2 +
4533 pIesLocal->WPA.auth_suite_count * 4);
4534 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
4535 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4536 }
4537 }
4538 }
4539#ifdef FEATURE_WLAN_WAPI
4540 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4541 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
4542 {
4543 if(pIesLocal->WAPI.present)
4544 {
4545 //Calculate the actual length
4546 nIeLen = 4 //version + akm_suite_count
4547 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
4548 + 2 //pwise_cipher_suite_count
4549 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
4550 + 6; //gp_cipher_suite + preauth + reserved
4551 if( pIesLocal->WAPI.bkid_count )
4552 {
4553 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
4554 }
4555
4556 //nIeLen doesn't count EID and length fields
4557 if(HAL_STATUS_SUCCESS((status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWapiRspIE, nIeLen + 2))))
4558 {
4559 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
4560 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
4561 pIeBuf = pSession->pWapiRspIE + 2;
4562 //copy upto akm_suite_count
4563 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.version, 4);
4564 pIeBuf += 4;
4565 if( pIesLocal->WAPI.akm_suite_count )
4566 {
4567 //copy akm_suites
4568 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.akm_suites,
4569 pIesLocal->WAPI.akm_suite_count * 4);
4570 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
4571 }
4572 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.unicast_cipher_suite_count, 2);
4573 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004574 if( pIesLocal->WAPI.unicast_cipher_suite_count )
4575 {
4576 //copy pwise_cipher_suites
4577 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.unicast_cipher_suites,
4578 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
4579 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
4580 }
4581 //gp_cipher_suite + preauth + reserved + bkid_count
4582 palCopyMemory(pMac->hHdd, pIeBuf, &pIesLocal->WAPI.multicast_cipher_suite, 8);
4583 pIeBuf += 8;
4584 if( pIesLocal->WAPI.bkid_count )
4585 {
4586 //copy akm_suites
4587 palCopyMemory(pMac->hHdd, pIeBuf, pIesLocal->WAPI.bkid, pIesLocal->WAPI.bkid_count * 4);
4588 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
4589 }
4590 pSession->nWapiRspIeLength = nIeLen + 2;
4591 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004592 }
4593 }
4594#endif /* FEATURE_WLAN_WAPI */
4595 if( !pIes )
4596 {
4597 //locally allocated
4598 palFreeMemory(pMac->hHdd, pIesLocal);
4599 }
4600 }
4601 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004602 return (status);
4603}
4604
Jeff Johnson295189b2012-06-20 16:38:30 -07004605static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
4606{
4607 v_U8_t bACWeights[WLANTL_MAX_AC];
4608 v_U8_t paramBk, paramBe, paramVi, paramVo;
4609 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004610 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
4611 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
4612 //of the higher AC one, make the higher AC has the same weight as the lower AC.
4613 //This doesn't address the case where the lower AC needs a real higher weight
4614 if( pIEs->WMMParams.present )
4615 {
4616 //no change to the lowest ones
4617 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
4618 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
4619 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
4620 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
4621 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
4622 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
4623 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
4624 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
4625 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
4626 {
4627 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
4628 fWeightChange = VOS_TRUE;
4629 }
4630 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
4631 {
4632 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
4633 fWeightChange = VOS_TRUE;
4634 }
4635 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
4636 {
4637 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
4638 fWeightChange = VOS_TRUE;
4639 }
4640 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
4641 {
4642 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
4643 fWeightChange = VOS_TRUE;
4644 }
4645 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
4646 {
4647 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
4648 fWeightChange = VOS_TRUE;
4649 }
4650 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
4651 {
4652 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
4653 fWeightChange = VOS_TRUE;
4654 }
4655 if(fWeightChange)
4656 {
4657 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)\n"), bACWeights[0], bACWeights[1],
4658 bACWeights[2], bACWeights[3]);
4659 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
4660 }
4661 }
4662}
Jeff Johnson295189b2012-06-20 16:38:30 -07004663#ifdef WLAN_FEATURE_VOWIFI_11R
4664//Returns whether the current association is a 11r assoc or not
4665tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
4666{
4667#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
4668 return csrNeighborRoamIs11rAssoc(pMac);
4669#else
4670 return eANI_BOOLEAN_FALSE;
4671#endif
4672}
4673#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004674#ifdef FEATURE_WLAN_CCX
4675//Returns whether the current association is a CCX assoc or not
4676tANI_BOOLEAN csrRoamIsCCXAssoc(tpAniSirGlobal pMac)
4677{
4678#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
4679 return csrNeighborRoamIsCCXAssoc(pMac);
4680#else
4681 return eANI_BOOLEAN_FALSE;
4682#endif
4683}
4684#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004685#ifdef FEATURE_WLAN_LFR
4686//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304687tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004688{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05304689 tCsrRoamSession *pSession = NULL;
4690
4691 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
4692 {
4693 pSession = CSR_GET_SESSION( pMac, sessionId );
4694 if (NULL != pSession->pCurRoamProfile)
4695 {
4696 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
4697 {
4698 return eANI_BOOLEAN_FALSE;
4699 }
4700 }
4701 }
4702
Madan Mohan Koyyalamudi9ce36ec2012-10-15 16:03:17 -07004703 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07004704 (!csrIsConcurrentSessionRunning(pMac)));
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004705}
4706#endif
4707
Jeff Johnson295189b2012-06-20 16:38:30 -07004708//Return true means the command can be release, else not
4709static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
4710 eCsrRoamCompleteResult Result, void *Context )
4711{
4712 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
4713 tSirBssDescription *pSirBssDesc = NULL;
4714 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
4715 tCsrScanResult *pScanResult = NULL;
4716 tCsrRoamInfo roamInfo;
4717 sme_QosAssocInfo assocInfo;
4718 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
4719 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
4720 tDot11fBeaconIEs *pIes = NULL;
4721 tANI_U32 sessionId = pCommand->sessionId;
4722 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4723 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4724 eRoamCmdStatus roamStatus;
4725 eCsrRoamResult roamResult;
4726 eHalStatus status;
4727 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004728 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004729
Jeff Johnson32d95a32012-09-10 13:15:23 -07004730 if(!pSession)
4731 {
4732 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4733 return eANI_BOOLEAN_FALSE;
4734 }
4735
Jeff Johnson295189b2012-06-20 16:38:30 -07004736 smsLog( pMac, LOG1, FL("Processing ROAM results...\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004737 switch( Result )
4738 {
4739 case eCsrJoinSuccess:
4740 // reset the IDLE timer
4741 // !!
4742 // !! fall through to the next CASE statement here is intentional !!
4743 // !!
4744 case eCsrReassocSuccess:
4745 if(eCsrReassocSuccess == Result)
4746 {
4747 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
4748 }
4749 else
4750 {
4751 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
4752 }
4753 // Success Join Response from LIM. Tell NDIS we are connected and save the
4754 // Connected state...
4755 smsLog(pMac, LOGW, FL("receives association indication\n"));
4756 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
4757 //always free the memory here
4758 if(pSession->pWpaRsnRspIE)
4759 {
4760 pSession->nWpaRsnRspIeLength = 0;
4761 palFreeMemory(pMac->hHdd, pSession->pWpaRsnRspIE);
4762 pSession->pWpaRsnRspIE = NULL;
4763 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004764#ifdef FEATURE_WLAN_WAPI
4765 if(pSession->pWapiRspIE)
4766 {
4767 pSession->nWapiRspIeLength = 0;
4768 palFreeMemory(pMac->hHdd, pSession->pWapiRspIE);
4769 pSession->pWapiRspIE = NULL;
4770 }
4771#endif /* FEATURE_WLAN_WAPI */
4772#ifdef FEATURE_WLAN_BTAMP_UT_RF
4773 //Reset counter so no join retry is needed.
4774 pSession->maxRetryCount = 0;
4775 csrRoamStopJoinRetryTimer(pMac, sessionId);
4776#endif
4777 /* This creates problem since we have not saved the connected profile.
4778 So moving this after saving the profile
4779 */
4780 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
4781 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4782 {
4783 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
4784 }
4785 else
4786 {
4787 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
4788 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004789 //Use the last connected bssdesc for reassoc-ing to the same AP.
4790 //NOTE: What to do when reassoc to a different AP???
4791 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
4792 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
4793 {
4794 pSirBssDesc = pSession->pConnectBssDesc;
4795 if(pSirBssDesc)
4796 {
4797 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
4798 }
4799 }
4800 else
4801 {
4802
4803 if(pCommand->u.roamCmd.pRoamBssEntry)
4804 {
4805 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4806 if(pScanResult != NULL)
4807 {
4808 pSirBssDesc = &pScanResult->Result.BssDescriptor;
4809 //this can be NULL
4810 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
4811 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
4812 }
4813 }
4814 }
4815 if( pSirBssDesc )
4816 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004817 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07004818 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
4819 //Save WPA/RSN IE
4820 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
4821#ifdef FEATURE_WLAN_CCX
4822 roamInfo.isCCXAssoc = pSession->connectedProfile.isCCXAssoc;
4823#endif
4824
4825 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
4826 // substate change.
4827 // Moving even save profile above so that below mentioned conditon is also met.
4828 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
4829 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07004830 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
4831 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
4832 // will be dropped for the security context may not be set properly.
4833 //
4834 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
4835 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
4836 //
4837 // this reordering was done on titan_prod_usb branch and is being replicated here.
4838 //
4839
4840 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
4841 !pProfile->bWPSAssociation)
4842 {
4843 // Issue the set Context request to LIM to establish the Unicast STA context
4844 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
4845 pProfile->negotiatedUCEncryptionType,
4846 pSirBssDesc, &(pSirBssDesc->bssId),
4847 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
4848 {
4849 smsLog( pMac, LOGE, FL(" Set context for unicast fail\n") );
4850 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
4851 }
4852 // Issue the set Context request to LIM to establish the Broadcast STA context
4853 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
4854 pSirBssDesc, &BroadcastMac,
4855 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
4856 }
4857 else
4858 {
4859 //Need to wait for supplicant authtication
4860 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004861 //Set the subestate to WaitForKey in case authentiation is needed
4862 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
4863
Jeff Johnson295189b2012-06-20 16:38:30 -07004864 if(pProfile->bWPSAssociation)
4865 {
4866 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
4867 }
4868 else
4869 {
4870 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
4871 }
4872
4873 //Save sessionId in case of timeout
4874 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
4875 //This time should be long enough for the rest of the process plus setting key
4876 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
4877 {
4878 //Reset our state so nothting is blocked.
4879 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer\n") );
4880 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
4881 }
4882 }
4883
4884 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
4885 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004886 if(Context)
4887 {
4888 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
4889 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07004890 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
4891 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
4892#ifdef WLAN_FEATURE_VOWIFI_11R
4893 len += pJoinRsp->parsedRicRspLen;
4894#endif /* WLAN_FEATURE_VOWIFI_11R */
4895#ifdef FEATURE_WLAN_CCX
4896 len += pJoinRsp->tspecIeLen;
4897#endif
4898 if(len)
4899 {
4900 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
4901 (void **)&pSession->connectedInfo.pbFrames, len)))
4902 {
4903 if(HAL_STATUS_SUCCESS( palCopyMemory(pMac->hHdd,
4904 pSession->connectedInfo.pbFrames, pJoinRsp->frames, len) ))
4905 {
4906 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
4907 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
4908 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
4909#ifdef WLAN_FEATURE_VOWIFI_11R
4910 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
4911#endif /* WLAN_FEATURE_VOWIFI_11R */
4912#ifdef FEATURE_WLAN_CCX
4913 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
4914#endif
4915 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
4916 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
4917 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
4918 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
4919 }
4920 else
4921 {
4922 smsLog(pMac, LOGE, "%s: Copying of memory failed for %d bytes !!!\n",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004923 __func__, len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004924 palFreeMemory( pMac->hHdd, pSession->connectedInfo.pbFrames );
4925 pSession->connectedInfo.pbFrames = NULL;
4926 }
4927 }
4928 }
4929 if(pCommand->u.roamCmd.fReassoc)
4930 {
4931 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
4932 }
4933 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
4934 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
4935 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
4936 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
4937 }
4938 else
4939 {
4940 if(pCommand->u.roamCmd.fReassoc)
4941 {
4942 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
4943 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
4944 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
4945 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
4946 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
4947 }
4948 }
4949#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4950 // Indicate SME-QOS with reassoc success event, only after
4951 // copying the frames
4952 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
4953#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004954 roamInfo.pBssDesc = pSirBssDesc;
4955 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4956 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4957#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4958 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
4959#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
4960 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07004961#ifdef FEATURE_WLAN_UAPSD_FW_TRG_FRAMES
4962 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
4963 //It may be better to let QoS do this????
4964 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
4965 {
4966 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now\n",
4967 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
4968 pmcStartUapsd( pMac, NULL, NULL );
4969 }
4970#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004971 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
4972 if( pSession->bRefAssocStartCnt > 0 )
4973 {
4974 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07004975 //Remove this code once SLM_Sessionization is supported
4976 //BMPS_WORKAROUND_NOT_NEEDED
4977 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07004978 {
4979 pMac->roam.configParam.doBMPSWorkaround = 1;
4980 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004981 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
4982 }
4983
4984 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004985 // reset the PMKID candidate list
4986 csrResetPMKIDCandidateList( pMac, sessionId );
4987 //Update TL's AC weight base on the current EDCA parameters
4988 //These parameters may change in the course of the connection, that sictuation
4989 //is not taken care here. This change is mainly to address a WIFI WMM test where
4990 //BE has a equal or higher TX priority than VI.
4991 //We only do this for infra link
4992 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
4993 {
4994 csrCheckAndUpdateACWeight(pMac, pIes);
4995 }
4996#ifdef FEATURE_WLAN_WAPI
4997 // reset the BKID candidate list
4998 csrResetBKIDCandidateList( pMac, sessionId );
4999#endif /* FEATURE_WLAN_WAPI */
5000 }
5001 else
5002 {
5003 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc\n");
5004 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005005 csrScanCancelIdleScan(pMac);
5006 //Not to signal link up because keys are yet to be set.
5007 //The linkup function will overwrite the sub-state that we need to keep at this point.
5008 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5009 {
5010 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5011 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005012 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5013 //enough to let security and DHCP handshake succeed before entry into BMPS
5014 if (pmcShouldBmpsTimerRun(pMac))
5015 {
5016 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5017 != eHAL_STATUS_SUCCESS)
5018 {
5019 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5020 }
5021 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5022 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005023 break;
5024
Jeff Johnson295189b2012-06-20 16:38:30 -07005025 case eCsrStartBssSuccess:
5026 // on the StartBss Response, LIM is returning the Bss Description that we
5027 // are beaconing. Add this Bss Description to our scan results and
5028 // chain the Profile to this Bss Description. On a Start BSS, there was no
5029 // detected Bss description (no partner) so we issued the Start Bss to
5030 // start the Ibss without any Bss description. Lim was kind enough to return
5031 // the Bss Description that we start beaconing for the newly started Ibss.
5032 smsLog(pMac, LOG2, FL("receives start BSS ok indication\n"));
5033 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005034 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Jeff Johnson295189b2012-06-20 16:38:30 -07005035 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5036 if( CSR_IS_IBSS( pProfile ) )
5037 {
5038 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5039 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005040 else if (CSR_IS_INFRA_AP(pProfile))
5041 {
5042 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5043 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005044 else
5045 {
5046 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5047 }
5048 if( !CSR_IS_WDS_STA( pProfile ) )
5049 {
5050 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005051 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005052 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5053 {
5054 smsLog(pMac, LOG2, FL("cannot parse IBSS IEs\n"));
5055 roamInfo.pBssDesc = pSirBssDesc;
5056 //We need to associate_complete it first, becasue Associate_start already indicated.
5057 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5058 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5059 break;
5060 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005061 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005062 {
5063 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes );
5064 }
5065 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5066 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5067 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5068 if(pSirBssDesc)
5069 {
5070 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5071 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pSirBssDesc->bssId, sizeof(tCsrBssid));
5072 }
5073 //We are doen with the IEs so free it
5074 palFreeMemory(pMac->hHdd, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005075#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5076 {
5077 vos_log_ibss_pkt_type *pIbssLog;
5078 tANI_U32 bi;
5079
5080 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5081 if(pIbssLog)
5082 {
5083 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5084 {
5085 //We start the IBSS (didn't find any matched IBSS out there)
5086 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
5087 }
5088 else
5089 {
5090 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
5091 }
5092 if(pSirBssDesc)
5093 {
5094 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pSirBssDesc->bssId, 6);
5095 pIbssLog->operatingChannel = pSirBssDesc->channelId;
5096 }
5097 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
5098 {
5099 //***U8 is not enough for beacon interval
5100 pIbssLog->beaconInterval = (v_U8_t)bi;
5101 }
5102 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5103 }
5104 }
5105#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5106 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
5107 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07005108 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
5109 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005110 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
5111 csrRoamIssueSetContextReq( pMac, sessionId,
5112 pProfile->negotiatedMCEncryptionType,
5113 pSirBssDesc, &BroadcastMac,
5114 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5115 }
5116 }
5117 else
5118 {
5119 //Keep the state to eCSR_ROAMING_STATE_JOINING
5120 //Need to send join_req.
5121 if(pCommand->u.roamCmd.pRoamBssEntry)
5122 {
5123 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
5124 {
5125 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5126 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5127 // Set the roaming substate to 'join attempt'...
5128 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08005129 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005130 }
5131 }
5132 else
5133 {
5134 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc\n" );
5135 VOS_ASSERT( 0 );
5136 }
5137 }
5138 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5139 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5140 //trigger the connection start indication in Vista
5141 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
5142 {
5143 roamStatus = eCSR_ROAM_IBSS_IND;
5144 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5145 if( CSR_IS_WDS( pProfile ) )
5146 {
5147 roamStatus = eCSR_ROAM_WDS_IND;
5148 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5149 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005150 if( CSR_IS_INFRA_AP( pProfile ) )
5151 {
5152 roamStatus = eCSR_ROAM_INFRA_IND;
5153 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
5154 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005155
5156 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5157 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5158 //trigger the connection start indication in Vista
5159 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5160 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5161 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5162 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5163 {
5164 //We start the IBSS (didn't find any matched IBSS out there)
5165 roamInfo.pBssDesc = pSirBssDesc;
5166 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005167 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005168 //Remove this code once SLM_Sessionization is supported
5169 //BMPS_WORKAROUND_NOT_NEEDED
5170 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005171 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005172 {
5173 pMac->roam.configParam.doBMPSWorkaround = 1;
5174 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005175
Jeff Johnson295189b2012-06-20 16:38:30 -07005176 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5177 }
5178
5179 csrScanCancelIdleScan(pMac);
5180 //Only use this timer for ibss. BAP has its own timer for WDS
5181 if( CSR_IS_IBSS( pProfile) && CSR_INVALID_SCANRESULT_HANDLE != pCommand->u.roamCmd.hBSSList)
5182 {
5183 //start the join IBSS timer
5184 csrRoamStartIbssJoinTimer(pMac, sessionId, CSR_IBSS_JOIN_TIMEOUT_PERIOD); //interval
5185 pSession->ibss_join_pending = TRUE;
5186 }
5187 if( HAL_STATUS_SUCCESS( status ) )
5188 {
5189 //Already sent join_req for the WDS station
5190 fReleaseCommand = eANI_BOOLEAN_FALSE;
5191 }
5192 else if( CSR_IS_WDS_STA( pProfile ) )
5193 {
5194 //need to send stop BSS because we fail to send join_req
5195 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5196 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5197 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5198 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005199 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005200 case eCsrStartBssFailure:
5201#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5202 {
5203 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005204 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5205 if(pIbssLog)
5206 {
5207 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5208 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5209 }
5210 }
5211#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005212 roamStatus = eCSR_ROAM_IBSS_IND;
5213 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5214 if( CSR_IS_WDS( pProfile ) )
5215 {
5216 roamStatus = eCSR_ROAM_WDS_IND;
5217 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5218 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005219 if( CSR_IS_INFRA_AP( pProfile ) )
5220 {
5221 roamStatus = eCSR_ROAM_INFRA_IND;
5222 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5223 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005224 if(Context)
5225 {
5226 pSirBssDesc = (tSirBssDescription *)Context;
5227 }
5228 else
5229 {
5230 pSirBssDesc = NULL;
5231 }
5232 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5233 roamInfo.pBssDesc = pSirBssDesc;
5234 //We need to associate_complete it first, becasue Associate_start already indicated.
5235 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5236 csrSetDefaultDot11Mode( pMac );
5237 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005238 case eCsrSilentlyStopRoaming:
5239 // We are here because we try to start the same IBSS
5240 //No message to PE
5241 // return the roaming state to Joined.
5242 smsLog(pMac, LOGW, FL("receives silently roaming indication\n"));
5243 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5244 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5245 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5246 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5247 if( roamInfo.pBssDesc )
5248 {
5249 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &roamInfo.pBssDesc->bssId, sizeof(tCsrBssid));
5250 }
5251 //Since there is no change in the current state, simply pass back no result otherwise
5252 //HDD may be mistakenly mark to disconnected state.
5253 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5254 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005255 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005256 case eCsrSilentlyStopRoamingSaveState:
5257 //We are here because we try to connect to the same AP
5258 //No message to PE
5259 smsLog(pMac, LOGW, FL("receives silently stop roaming indication\n"));
5260 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
5261
5262 //to aviod resetting the substate to NONE
5263 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5264 //No need to change substate to wai_for_key because there is no state change
5265 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5266 if( roamInfo.pBssDesc )
5267 {
5268 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &roamInfo.pBssDesc->bssId, sizeof(tCsrBssid));
5269 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005270 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5271 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5272 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5273 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5274 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5275 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5276 roamInfo.staId = pSession->connectedInfo.staId;
5277 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5278#if defined(VOSS_ENABLED)
5279 VOS_ASSERT( roamInfo.staId != 0 );
5280#endif
5281 pSession->bRefAssocStartCnt--;
5282 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5283 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5284 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5285 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005286 case eCsrReassocFailure:
5287#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5288 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5289#endif
5290 case eCsrJoinWdsFailure:
5291 smsLog(pMac, LOGW, FL("failed to join WDS\n"));
5292 csrFreeConnectBssDesc(pMac, sessionId);
5293 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5294 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5295 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5296 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5297 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5298 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5299 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5300 eCSR_ROAM_WDS_IND,
5301 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5302 //Need to issue stop_bss
5303 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005304 case eCsrJoinFailure:
5305 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07005306 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07005307 default:
5308 {
5309 smsLog(pMac, LOGW, FL("receives no association indication\n"));
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07005310 smsLog(pMac, LOG1, FL("Assoc ref count %d\n"),
5311 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07005312 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
5313 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
5314 {
5315 //do not free for the other profiles as we need to send down stop BSS later
5316 csrFreeConnectBssDesc(pMac, sessionId);
5317 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5318 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5319 csrSetDefaultDot11Mode( pMac );
5320 }
5321
5322 switch( pCommand->u.roamCmd.roamReason )
5323 {
5324 // If this transition is because of an 802.11 OID, then we transition
5325 // back to INIT state so we sit waiting for more OIDs to be issued and
5326 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07005327 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005328 case eCsrSmeIssuedAssocToSimilarAP:
5329 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08005330 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07005331 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5332 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
5333 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5334 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5335 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005336 /* Defeaturize this later if needed */
5337#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5338 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
5339 if (csrRoamIsHandoffInProgress(pMac))
5340 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005341 /* Should indicate neighbor roam algorithm about the connect failure here */
5342 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
5343 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005344#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005345 if(pSession->bRefAssocStartCnt > 0)
5346 {
5347 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07005348 if(eCsrJoinFailureDueToConcurrency == Result)
5349 {
5350 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5351 eCSR_ROAM_ASSOCIATION_COMPLETION,
5352 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
5353 }
5354 else
5355 {
5356 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005357 eCSR_ROAM_ASSOCIATION_COMPLETION,
5358 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07005359 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005360 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005361 else
5362 {
5363 /* bRefAssocStartCnt is not incremented when
5364 * eRoamState == eCsrStopRoamingDueToConcurrency
5365 * in csrRoamJoinNextBss API. so handle this in
5366 * else case by sending assoc failure
5367 */
5368 csrRoamCallCallback(pMac, sessionId, NULL,
5369 pCommand->u.scanCmd.roamId,
5370 eCSR_ROAM_ASSOCIATION_FAILURE,
5371 eCSR_ROAM_RESULT_FAILURE);
5372 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005373 smsLog(pMac, LOG1, FL(" roam(reason %d) failed\n"), pCommand->u.roamCmd.roamReason);
5374#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5375 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5376#endif
5377 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5378 csrScanStartIdleScan(pMac);
5379#ifdef FEATURE_WLAN_BTAMP_UT_RF
5380 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
5381 //BT activity and not able to recevie WLAN traffic. Retry the join
5382 if( CSR_IS_WDS_STA(pProfile) )
5383 {
5384 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
5385 }
5386#endif
5387 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005388 case eCsrHddIssuedReassocToSameAP:
5389 case eCsrSmeIssuedReassocToSameAP:
5390 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5391
5392 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5393#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5394 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5395#endif
5396 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5397 csrScanStartIdleScan(pMac);
5398 break;
5399 case eCsrForcedDisassoc:
5400 case eCsrForcedDeauth:
5401 case eCsrSmeIssuedIbssJoinFailure:
5402 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5403
5404 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
5405 {
5406 // Notify HDD that IBSS join failed
5407 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
5408 }
5409 else
5410 {
5411 csrRoamCallCallback(pMac, sessionId, NULL,
5412 pCommand->u.roamCmd.roamId,
5413 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5414 }
5415#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5416 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5417#endif
5418 csrRoamLinkDown(pMac, sessionId);
5419 csrScanStartIdleScan(pMac);
5420 break;
5421 case eCsrForcedIbssLeave:
5422 csrRoamCallCallback(pMac, sessionId, NULL,
5423 pCommand->u.roamCmd.roamId,
5424 eCSR_ROAM_IBSS_LEAVE,
5425 eCSR_ROAM_RESULT_IBSS_STOP);
5426 break;
5427 case eCsrForcedDisassocMICFailure:
5428 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5429
5430 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
5431#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5432 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
5433#endif
5434 csrScanStartIdleScan(pMac);
5435 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005436 case eCsrStopBss:
5437 csrRoamCallCallback(pMac, sessionId, NULL,
5438 pCommand->u.roamCmd.roamId,
5439 eCSR_ROAM_INFRA_IND,
5440 eCSR_ROAM_RESULT_INFRA_STOPPED);
5441 break;
5442 case eCsrForcedDisassocSta:
5443 case eCsrForcedDeauthSta:
5444 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
5445 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
5446 {
5447 pSession = CSR_GET_SESSION(pMac, sessionId);
5448 if (!pSession)
5449 break;
5450
5451 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
5452 {
5453 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5454 palCopyMemory(pMac->hHdd, roamInfo.peerMac,
5455 pCommand->u.roamCmd.peerMac, sizeof(tSirMacAddr));
5456 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
5457 roamInfo.statusCode = eSIR_SME_SUCCESS;
5458 status = csrRoamCallCallback(pMac, sessionId,
5459 &roamInfo, pCommand->u.roamCmd.roamId,
5460 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
5461 }
5462 }
5463 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005464 case eCsrLostLink1:
5465 // if lost link roam1 failed, then issue lost link Scan2 ...
5466 csrScanRequestLostLink2(pMac, sessionId);
5467 break;
5468 case eCsrLostLink2:
5469 // if lost link roam2 failed, then issue lost link scan3 ...
5470 csrScanRequestLostLink3(pMac, sessionId);
5471 break;
5472 case eCsrLostLink3:
5473 default:
5474 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5475
5476 //We are done with one round of lostlink roaming here
5477 csrScanHandleFailedLostlink3(pMac, sessionId);
5478 break;
5479 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005480 break;
5481 }
5482 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005483 return ( fReleaseCommand );
5484}
5485
Jeff Johnson295189b2012-06-20 16:38:30 -07005486eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
5487{
5488 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005489 return (status);
5490}
5491
Jeff Johnson295189b2012-06-20 16:38:30 -07005492eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
5493{
5494 eHalStatus status = eHAL_STATUS_SUCCESS;
5495 tANI_U32 size = 0;
5496
5497 do
5498 {
5499 palZeroMemory(pMac->hHdd, pDstProfile, sizeof(tCsrRoamProfile));
5500 if(pSrcProfile->BSSIDs.numOfBSSIDs)
5501 {
5502 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
5503 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->BSSIDs.bssid, size);
5504 if(!HAL_STATUS_SUCCESS(status))
5505 {
5506 break;
5507 }
5508 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
5509 palCopyMemory(pMac->hHdd, pDstProfile->BSSIDs.bssid, pSrcProfile->BSSIDs.bssid, size);
5510 }
5511 if(pSrcProfile->SSIDs.numOfSSIDs)
5512 {
5513 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
5514 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->SSIDs.SSIDList, size);
5515 if(!HAL_STATUS_SUCCESS(status))
5516 {
5517 break;
5518 }
5519 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
5520 palCopyMemory(pMac->hHdd, pDstProfile->SSIDs.SSIDList, pSrcProfile->SSIDs.SSIDList, size);
5521 }
5522 if(pSrcProfile->nWPAReqIELength)
5523 {
5524 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pWPAReqIE, pSrcProfile->nWPAReqIELength);
5525 if(!HAL_STATUS_SUCCESS(status))
5526 {
5527 break;
5528 }
5529 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
5530 palCopyMemory(pMac->hHdd, pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE, pSrcProfile->nWPAReqIELength);
5531 }
5532 if(pSrcProfile->nRSNReqIELength)
5533 {
5534 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pRSNReqIE, pSrcProfile->nRSNReqIELength);
5535 if(!HAL_STATUS_SUCCESS(status))
5536 {
5537 break;
5538 }
5539 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
5540 palCopyMemory(pMac->hHdd, pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE, pSrcProfile->nRSNReqIELength);
5541 }
5542#ifdef FEATURE_WLAN_WAPI
5543 if(pSrcProfile->nWAPIReqIELength)
5544 {
5545 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pWAPIReqIE, pSrcProfile->nWAPIReqIELength);
5546 if(!HAL_STATUS_SUCCESS(status))
5547 {
5548 break;
5549 }
5550 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
5551 palCopyMemory(pMac->hHdd, pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE, pSrcProfile->nWAPIReqIELength);
5552 }
5553#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07005554 if(pSrcProfile->nAddIEScanLength)
5555 {
5556 status = palAllocateMemory(pMac->hHdd,
5557 (void **)&pDstProfile->pAddIEScan, pSrcProfile->nAddIEScanLength);
5558 if(!HAL_STATUS_SUCCESS(status))
5559 {
5560 break;
5561 }
5562 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
5563 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEScan, pSrcProfile->pAddIEScan,
5564 pSrcProfile->nAddIEScanLength);
5565 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005566 if(pSrcProfile->nAddIEAssocLength)
5567 {
5568 status = palAllocateMemory(pMac->hHdd,
5569 (void **)&pDstProfile->pAddIEAssoc, pSrcProfile->nAddIEAssocLength);
5570 if(!HAL_STATUS_SUCCESS(status))
5571 {
5572 break;
5573 }
5574 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
5575 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
5576 pSrcProfile->nAddIEAssocLength);
5577 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005578 if(pSrcProfile->ChannelInfo.ChannelList)
5579 {
5580 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.numOfChannels);
5581 if(!HAL_STATUS_SUCCESS(status))
5582 {
5583 break;
5584 }
5585 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
5586 palCopyMemory(pMac->hHdd, pDstProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.ChannelList, pSrcProfile->ChannelInfo.numOfChannels);
5587 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005588 pDstProfile->AuthType = pSrcProfile->AuthType;
5589 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
5590 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
5591 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
5592 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
5593 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
5594 pDstProfile->BSSType = pSrcProfile->BSSType;
5595 pDstProfile->phyMode = pSrcProfile->phyMode;
5596 pDstProfile->csrPersona = pSrcProfile->csrPersona;
5597
5598#ifdef FEATURE_WLAN_WAPI
5599 if(csrIsProfileWapi(pSrcProfile))
5600 {
5601 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
5602 {
5603 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
5604 }
5605 }
5606#endif /* FEATURE_WLAN_WAPI */
5607 pDstProfile->CBMode = pSrcProfile->CBMode;
5608 /*Save the WPS info*/
5609 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
5610 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005611 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07005612 pDstProfile->privacy = pSrcProfile->privacy;
5613 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
5614 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
5615 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
5616 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
5617 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
5618 pDstProfile->protEnabled = pSrcProfile->protEnabled;
5619 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
5620 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
5621 pDstProfile->wps_state = pSrcProfile->wps_state;
5622 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Jeff Johnson295189b2012-06-20 16:38:30 -07005623 palCopyMemory(pMac->hHdd, &pDstProfile->Keys, &pSrcProfile->Keys, sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07005624#ifdef WLAN_FEATURE_VOWIFI_11R
5625 if (pSrcProfile->MDID.mdiePresent)
5626 {
5627 pDstProfile->MDID.mdiePresent = 1;
5628 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
5629 }
5630#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005631 }while(0);
5632
5633 if(!HAL_STATUS_SUCCESS(status))
5634 {
5635 csrReleaseProfile(pMac, pDstProfile);
5636 pDstProfile = NULL;
5637 }
5638
5639 return (status);
5640}
Jeff Johnson295189b2012-06-20 16:38:30 -07005641eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
5642{
5643 eHalStatus status = eHAL_STATUS_SUCCESS;
5644 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
5645 do
5646 {
5647 palZeroMemory(pMac->hHdd, pDstProfile, sizeof(tCsrRoamProfile));
5648 if(pSrcProfile->bssid)
5649 {
5650 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->BSSIDs.bssid, sizeof(tCsrBssid));
5651 if(!HAL_STATUS_SUCCESS(status))
5652 {
5653 break;
5654 }
5655 pDstProfile->BSSIDs.numOfBSSIDs = 1;
5656 palCopyMemory(pMac->hHdd, pDstProfile->BSSIDs.bssid, pSrcProfile->bssid, sizeof(tCsrBssid));
5657 }
5658 if(pSrcProfile->SSID.ssId)
5659 {
5660 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->SSIDs.SSIDList, sizeof(tCsrSSIDInfo));
5661 if(!HAL_STATUS_SUCCESS(status))
5662 {
5663 break;
5664 }
5665 pDstProfile->SSIDs.numOfSSIDs = 1;
5666 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
5667 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
5668 palCopyMemory(pMac->hHdd, &pDstProfile->SSIDs.SSIDList[0].SSID, &pSrcProfile->SSID, sizeof(tSirMacSSid));
5669 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07005670 if(pSrcProfile->nAddIEAssocLength)
5671 {
5672 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->pAddIEAssoc, pSrcProfile->nAddIEAssocLength);
5673 if(!HAL_STATUS_SUCCESS(status))
5674 {
5675 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs \n") );
5676 break;
5677 }
5678 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
5679 palCopyMemory(pMac->hHdd, pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
5680 pSrcProfile->nAddIEAssocLength);
5681 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005682 status = palAllocateMemory(pMac->hHdd, (void **)&pDstProfile->ChannelInfo.ChannelList, 1);
5683 if(!HAL_STATUS_SUCCESS(status))
5684 {
5685 break;
5686 }
5687 pDstProfile->ChannelInfo.numOfChannels = 1;
5688 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07005689 pDstProfile->AuthType.numEntries = 1;
5690 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
5691 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
5692 pDstProfile->EncryptionType.numEntries = 1;
5693 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
5694 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
5695 pDstProfile->mcEncryptionType.numEntries = 1;
5696 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
5697 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
5698 pDstProfile->BSSType = pSrcProfile->BSSType;
5699 pDstProfile->CBMode = pSrcProfile->CBMode;
5700 palCopyMemory(pMac->hHdd, &pDstProfile->Keys, &pSrcProfile->Keys, sizeof(pDstProfile->Keys));
5701#ifdef WLAN_FEATURE_VOWIFI_11R
5702 if (pSrcProfile->MDID.mdiePresent)
5703 {
5704 pDstProfile->MDID.mdiePresent = 1;
5705 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
5706 }
5707#endif
5708
5709 }while(0);
5710
5711 if(!HAL_STATUS_SUCCESS(status))
5712 {
5713 csrReleaseProfile(pMac, pDstProfile);
5714 pDstProfile = NULL;
5715 }
5716
5717 return (status);
5718}
5719
Jeff Johnson295189b2012-06-20 16:38:30 -07005720eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5721 tScanResultHandle hBSSList,
5722 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
5723 tANI_BOOLEAN fClearScan)
5724{
5725 eHalStatus status = eHAL_STATUS_SUCCESS;
5726 tSmeCmd *pCommand;
5727
5728 pCommand = csrGetCommandBuffer(pMac);
5729 if(NULL == pCommand)
5730 {
5731 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
5732 status = eHAL_STATUS_RESOURCES;
5733 }
5734 else
5735 {
5736 if( fClearScan )
5737 {
5738 csrScanCancelIdleScan(pMac);
5739 csrScanAbortMacScanNotForConnect(pMac);
5740 }
5741 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
5742 if(NULL == pProfile)
5743 {
5744 //We can roam now
5745 //Since pProfile is NULL, we need to build our own profile, set everything to default
5746 //We can only support open and no encryption
5747 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
5748 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5749 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
5750 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
5751 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
5752 }
5753 else
5754 {
5755 //make a copy of the profile
5756 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
5757 if(HAL_STATUS_SUCCESS(status))
5758 {
5759 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
5760 }
5761 }
5762 pCommand->command = eSmeCommandRoam;
5763 pCommand->sessionId = (tANI_U8)sessionId;
5764 pCommand->u.roamCmd.hBSSList = hBSSList;
5765 pCommand->u.roamCmd.roamId = roamId;
5766 pCommand->u.roamCmd.roamReason = reason;
5767 //We need to free the BssList when the command is done
5768 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
5769 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005770 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
5771 FL("CSR PERSONA=%d"),
5772 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07005773 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
5774 if( !HAL_STATUS_SUCCESS( status ) )
5775 {
5776 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
5777 csrReleaseCommandRoam( pMac, pCommand );
5778 }
5779 }
5780
5781 return (status);
5782}
Jeff Johnson295189b2012-06-20 16:38:30 -07005783eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5784 tCsrRoamModifyProfileFields *pMmodProfileFields,
5785 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
5786{
5787 eHalStatus status = eHAL_STATUS_SUCCESS;
5788 tSmeCmd *pCommand;
5789
5790 pCommand = csrGetCommandBuffer(pMac);
5791 if(NULL == pCommand)
5792 {
5793 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
5794 status = eHAL_STATUS_RESOURCES;
5795 }
5796 else
5797 {
5798 csrScanCancelIdleScan(pMac);
5799 csrScanAbortMacScanNotForConnect(pMac);
5800 if(pProfile)
5801 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005802 //This is likely trying to reassoc to different profile
5803 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
5804 //make a copy of the profile
5805 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
5806 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005807 }
5808 else
5809 {
5810 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
5811 //how to update WPA/WPA2 info in roamProfile??
5812 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005813 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005814 if(HAL_STATUS_SUCCESS(status))
5815 {
5816 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
5817 }
5818 pCommand->command = eSmeCommandRoam;
5819 pCommand->sessionId = (tANI_U8)sessionId;
5820 pCommand->u.roamCmd.roamId = roamId;
5821 pCommand->u.roamCmd.roamReason = reason;
5822 //We need to free the BssList when the command is done
5823 //For reassoc there is no BSS list, so the boolean set to false
5824 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
5825 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
5826 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005827 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
5828 if( !HAL_STATUS_SUCCESS( status ) )
5829 {
5830 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
5831 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5832 csrReleaseCommandRoam( pMac, pCommand );
5833 }
5834 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005835 return (status);
5836}
5837
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005838eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
5839 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
5840// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
5841{
5842 eHalStatus status = eHAL_STATUS_SUCCESS;
5843 tSmeCmd *pCommand;
5844
5845 pCommand = csrGetCommandBuffer(pMac);
5846 if(NULL == pCommand)
5847 {
5848 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
5849 status = eHAL_STATUS_RESOURCES;
5850 }
5851 else
5852 {
5853 if(pBssDescription)
5854 {
5855 //copy over the parameters we need later
5856 pCommand->command = eSmeCommandRoam;
5857 pCommand->sessionId = (tANI_U8)sessionId;
5858 pCommand->u.roamCmd.roamReason = reason;
5859 //this is the important parameter
5860 //in this case we are using this field for the "next" BSS
5861 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
5862 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
5863 if( !HAL_STATUS_SUCCESS( status ) )
5864 {
5865 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d\n"), status );
5866 csrReleaseCommandPreauth( pMac, pCommand );
5867 }
5868 }
5869 else
5870 {
5871 //Return failure
5872 status = eHAL_STATUS_RESOURCES;
5873 }
5874 }
5875 return (status);
5876}
5877
5878eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
5879{
5880 tListElem *pEntry;
5881 tSmeCmd *pCommand;
5882 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
5883 if ( pEntry )
5884 {
5885 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
5886 if ( (eSmeCommandRoam == pCommand->command) &&
5887 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
5888 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08005889 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005890 pCommand->command, pCommand->u.roamCmd.roamReason);
5891 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
5892 csrReleaseCommandPreauth( pMac, pCommand );
5893 }
5894 } else {
5895 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d \n"),
5896 pCommand->command, pCommand->u.roamCmd.roamReason);
5897 }
5898 }
5899 else {
5900 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP\n"));
5901 }
5902 smeProcessPendingQueue( pMac );
5903 return eHAL_STATUS_SUCCESS;
5904}
5905
Jeff Johnson295189b2012-06-20 16:38:30 -07005906eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5907 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
5908{
5909 eHalStatus status = eHAL_STATUS_FAILURE;
5910 tScanResultHandle hBSSList;
5911 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005912 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
5913 if(HAL_STATUS_SUCCESS(status))
5914 {
5915 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
5916 if(pRoamId)
5917 {
5918 *pRoamId = roamId;
5919 }
5920 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
5921 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
5922 if(!HAL_STATUS_SUCCESS(status))
5923 {
5924 smsLog(pMac, LOGE, FL("failed to start a join process\n"));
5925 csrScanResultPurge(pMac, hBSSList);
5926 }
5927 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005928 return (status);
5929}
5930
Jeff Johnson295189b2012-06-20 16:38:30 -07005931eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
5932 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
5933{
5934 eHalStatus status = eHAL_STATUS_SUCCESS;
5935 tScanResultHandle hBSSList;
5936 tCsrScanResultFilter *pScanFilter;
5937 tANI_U32 roamId = 0;
5938 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
5939 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005940 if (NULL == pProfile)
5941 {
5942 smsLog(pMac, LOGP, FL("No profile specified"));
5943 return eHAL_STATUS_FAILURE;
5944 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005945 smsLog(pMac, LOG1, FL("called BSSType = %d authtype = %d encryType = %d\n"),
5946 pProfile->BSSType, pProfile->AuthType.authType[0], pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005947 if( CSR_IS_WDS( pProfile ) &&
5948 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
5949 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005950 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d\n"),
5951 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07005952 return status;
5953 }
5954 csrRoamCancelRoaming(pMac, sessionId);
5955 csrScanRemoveFreshScanCommand(pMac, sessionId);
5956 csrScanCancelIdleScan(pMac);
5957 //Only abort the scan if it is not used for other roam/connect purpose
5958 csrScanAbortMacScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07005959 if (!vos_concurrent_sessions_running() && (VOS_STA_SAP_MODE == pProfile->csrPersona))//In case of AP mode we do not want idle mode scan
5960 {
5961 csrScanDisable(pMac);
5962 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005963 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
5964 //Check whether ssid changes
5965 if(csrIsConnStateConnected(pMac, sessionId))
5966 {
5967 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
5968 {
5969 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
5970 }
5971 }
5972#ifdef FEATURE_WLAN_BTAMP_UT_RF
5973 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
5974#endif
5975 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
5976 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005977 smsLog(pMac, LOG1, FL("is called with BSSList\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005978 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
5979 if(pRoamId)
5980 {
5981 roamId = *pRoamId;
5982 }
5983 if(!HAL_STATUS_SUCCESS(status))
5984 {
5985 fCallCallback = eANI_BOOLEAN_TRUE;
5986 }
5987 }
5988 else
5989 {
5990 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
5991 if(HAL_STATUS_SUCCESS(status))
5992 {
5993 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
5994 //Try to connect to any BSS
5995 if(NULL == pProfile)
5996 {
5997 //No encryption
5998 pScanFilter->EncryptionType.numEntries = 1;
5999 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6000 }//we don't have a profile
6001 else
6002 {
6003 //Here is the profile we need to connect to
6004 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6005 }//We have a profile
6006 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6007 if(pRoamId)
6008 {
6009 *pRoamId = roamId;
6010 }
6011
6012 if(HAL_STATUS_SUCCESS(status))
6013 {
6014 /*Save the WPS info*/
6015 if(NULL != pProfile)
6016 {
6017 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
6018 }
6019 else
6020 {
6021 pScanFilter->bWPSAssociation = 0;
6022 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006023 do
6024 {
6025 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006026 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006027 )
6028 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006029 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07006030 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6031 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6032 if(!HAL_STATUS_SUCCESS(status))
6033 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006034 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X\n"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006035 fCallCallback = eANI_BOOLEAN_TRUE;
6036 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006037 else
6038 {
6039 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
6040 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006041 break;
6042 }
6043 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Mohit Khanna23863762012-09-11 17:40:09 -07006044 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d\n", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006045 if(HAL_STATUS_SUCCESS(status))
6046 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006047 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6048 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6049 if(!HAL_STATUS_SUCCESS(status))
6050 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006051 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X\n"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006052 csrScanResultPurge(pMac, hBSSList);
6053 fCallCallback = eANI_BOOLEAN_TRUE;
6054 }
6055 }//Have scan result
6056 else if(NULL != pProfile)
6057 {
6058 //Check whether it is for start ibss
6059 if(CSR_IS_START_IBSS(pProfile))
6060 {
6061 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6062 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6063 if(!HAL_STATUS_SUCCESS(status))
6064 {
6065 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X\n", status);
6066 fCallCallback = eANI_BOOLEAN_TRUE;
6067 }
6068 }
6069 else
6070 {
6071 //scan for this SSID
6072 status = csrScanForSSID(pMac, sessionId, pProfile, roamId);
6073 if(!HAL_STATUS_SUCCESS(status))
6074 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006075 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X\n"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006076 fCallCallback = eANI_BOOLEAN_TRUE;
6077 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006078 else
6079 {
6080 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
6081 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006082 }
6083 }
6084 else
6085 {
6086 fCallCallback = eANI_BOOLEAN_TRUE;
6087 }
6088 } while (0);
6089 if(NULL != pProfile)
6090 {
6091 //we need to free memory for filter if profile exists
6092 csrFreeScanFilter(pMac, pScanFilter);
6093 }
6094 }//Got the scan filter from profile
6095
6096 palFreeMemory(pMac->hHdd, pScanFilter);
6097 }//allocated memory for pScanFilter
6098 }//No Bsslist coming in
6099 //tell the caller if we fail to trigger a join request
6100 if( fCallCallback )
6101 {
6102 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6103 }
6104
6105 return (status);
6106}
Jeff Johnson295189b2012-06-20 16:38:30 -07006107eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6108 tCsrRoamModifyProfileFields modProfileFields,
6109 tANI_U32 *pRoamId)
6110{
6111 eHalStatus status = eHAL_STATUS_SUCCESS;
6112 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
6113 tANI_U32 roamId = 0;
6114 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006115 if (NULL == pProfile)
6116 {
6117 smsLog(pMac, LOGP, FL("No profile specified"));
6118 return eHAL_STATUS_FAILURE;
6119 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006120 smsLog(pMac, LOG1, FL("called BSSType = %d authtype = %d encryType = %d\n"), pProfile->BSSType, pProfile->AuthType.authType[0], pProfile->EncryptionType.encryptionType[0]);
6121 csrRoamCancelRoaming(pMac, sessionId);
6122 csrScanRemoveFreshScanCommand(pMac, sessionId);
6123 csrScanCancelIdleScan(pMac);
6124 csrScanAbortMacScanNotForConnect(pMac);
6125 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07006126 if(csrIsConnStateConnected(pMac, sessionId))
6127 {
6128 if(pProfile)
6129 {
6130 if(pProfile->SSIDs.numOfSSIDs &&
6131 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6132 {
6133 fCallCallback = eANI_BOOLEAN_FALSE;
6134 }
6135 else
6136 {
6137 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile\n"));
6138 }
6139 }
6140 else if(!palEqualMemory(pMac->hHdd, &modProfileFields,
6141 &pSession->connectedProfile.modifyProfileFields,
6142 sizeof(tCsrRoamModifyProfileFields)))
6143 {
6144 fCallCallback = eANI_BOOLEAN_FALSE;
6145 }
6146 else
6147 {
6148 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
6149 "in tCsrRoamModifyProfileFields got modified\n"));
6150 }
6151 }
6152 else
6153 {
6154 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc\n"));
6155 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006156 if(!fCallCallback)
6157 {
6158 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6159 if(pRoamId)
6160 {
6161 *pRoamId = roamId;
6162 }
6163
Jeff Johnson295189b2012-06-20 16:38:30 -07006164 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6165 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006166 }
6167 else
6168 {
6169 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6170 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6171 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006172 return status;
6173}
Jeff Johnson295189b2012-06-20 16:38:30 -07006174eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6175{
6176 eHalStatus status = eHAL_STATUS_FAILURE;
6177 tScanResultHandle hBSSList = NULL;
6178 tCsrScanResultFilter *pScanFilter = NULL;
6179 tANI_U32 roamId;
6180 tCsrRoamProfile *pProfile = NULL;
6181 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006182
6183 if(!pSession)
6184 {
6185 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6186 return eHAL_STATUS_FAILURE;
6187 }
6188
Jeff Johnson295189b2012-06-20 16:38:30 -07006189 do
6190 {
6191 if(pSession->pCurRoamProfile)
6192 {
6193 csrScanCancelIdleScan(pMac);
6194 csrScanAbortMacScanNotForConnect(pMac);
6195 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
6196 status = palAllocateMemory(pMac->hHdd, (void **)&pProfile, sizeof(tCsrRoamProfile));
6197 if(!HAL_STATUS_SUCCESS(status))
6198 break;
6199 palZeroMemory(pMac->hHdd, pProfile, sizeof(tCsrRoamProfile));
6200 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
6201 if(!HAL_STATUS_SUCCESS(status))
6202 break;
6203 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
6204 if(!HAL_STATUS_SUCCESS(status))
6205 {
6206 break;
6207 }
6208 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
6209 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6210 if(!HAL_STATUS_SUCCESS(status))
6211 {
6212 break;
6213 }
6214 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6215 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6216 if(HAL_STATUS_SUCCESS(status))
6217 {
6218 //we want to put the last connected BSS to the very beginning, if possible
6219 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
6220 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6221 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6222 if(!HAL_STATUS_SUCCESS(status))
6223 {
6224 csrScanResultPurge(pMac, hBSSList);
6225 break;
6226 }
6227 }
6228 else
6229 {
6230 //Do a scan on this profile
6231 //scan for this SSID only in case the AP suppresses SSID
6232 status = csrScanForSSID(pMac, sessionId, pProfile, roamId);
6233 if(!HAL_STATUS_SUCCESS(status))
6234 {
6235 break;
6236 }
6237 }
6238 }//We have a profile
6239 else
6240 {
6241 smsLog(pMac, LOGW, FL("cannot find a roaming profile\n"));
6242 break;
6243 }
6244 }while(0);
6245 if(pScanFilter)
6246 {
6247 csrFreeScanFilter(pMac, pScanFilter);
6248 palFreeMemory(pMac->hHdd, pScanFilter);
6249 }
6250 if(NULL != pProfile)
6251 {
6252 csrReleaseProfile(pMac, pProfile);
6253 palFreeMemory(pMac->hHdd, pProfile);
6254 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006255 return (status);
6256}
Jeff Johnson295189b2012-06-20 16:38:30 -07006257eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
6258{
6259 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006260 if(csrIsConnStateConnected(pMac, sessionId))
6261 {
6262 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6263 if(HAL_STATUS_SUCCESS(status))
6264 {
6265 status = csrRoamJoinLastProfile(pMac, sessionId);
6266 }
6267 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006268 return (status);
6269}
6270
Jeff Johnson295189b2012-06-20 16:38:30 -07006271eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6272{
6273 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006274 smsLog(pMac, LOGW, FL("is called\n"));
6275 csrRoamCancelRoaming(pMac, sessionId);
6276 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6277 if(csrIsConnStateDisconnected(pMac, sessionId))
6278 {
6279 status = csrRoamJoinLastProfile(pMac, sessionId);
6280 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006281 return (status);
6282}
6283
Jeff Johnson295189b2012-06-20 16:38:30 -07006284eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
6285{
6286 eHalStatus status = eHAL_STATUS_SUCCESS;
6287 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
6288 eCsrRoamSubState NewSubstate;
6289 tANI_U32 sessionId = pCommand->sessionId;
6290
6291 // change state to 'Roaming'...
6292 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
6293
6294 if ( csrIsConnStateIbss( pMac, sessionId ) )
6295 {
6296 // If we are in an IBSS, then stop the IBSS...
6297 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6298 fComplete = (!HAL_STATUS_SUCCESS(status));
6299 }
6300 else if ( csrIsConnStateInfra( pMac, sessionId ) )
6301 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07006302 smsLog(pMac, LOG1, FL(" restore AC weights (%d-%d-%d-%d)\n"), pMac->roam.ucACWeights[0], pMac->roam.ucACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07006303 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
6304 //Restore AC weight in case we change it
6305 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
6306 // in Infrasturcture, we need to disassociate from the Infrastructure network...
6307 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
6308 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
6309 {
6310 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
6311 }
6312 if( fDisassoc )
6313 {
6314 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
6315 }
6316 else
6317 {
6318 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
6319 }
6320 fComplete = (!HAL_STATUS_SUCCESS(status));
6321 }
6322 else if ( csrIsConnStateWds( pMac, sessionId ) )
6323 {
6324 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
6325 {
6326 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6327 fComplete = (!HAL_STATUS_SUCCESS(status));
6328 }
6329 //This has to be WDS station
6330 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
6331 {
6332
6333 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6334 if( fDisassoc )
6335 {
6336 status = csrRoamIssueDisassociate( pMac, sessionId,
6337 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
6338 fComplete = (!HAL_STATUS_SUCCESS(status));
6339 }
6340 }
6341 } else {
6342 // we got a dis-assoc request while not connected to any peer
6343 // just complete the command
6344 fComplete = eANI_BOOLEAN_TRUE;
6345 status = eHAL_STATUS_FAILURE;
6346 }
6347 if(fComplete)
6348 {
6349 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6350 }
6351
6352 if(HAL_STATUS_SUCCESS(status))
6353 {
6354 if ( csrIsConnStateInfra( pMac, sessionId ) )
6355 {
6356 //Set the state to disconnect here
6357 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
6358 }
6359 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006360 else
6361 {
6362 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
6363 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006364 return (status);
6365}
6366
Jeff Johnson295189b2012-06-20 16:38:30 -07006367/* This is been removed from latest code base */
6368/*
6369static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
6370{
6371 eHalStatus status;
6372 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07006373 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
6374 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006375 return ( status );
6376}
6377*/
6378
Jeff Johnson295189b2012-06-20 16:38:30 -07006379eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
6380{
6381 eHalStatus status = eHAL_STATUS_SUCCESS;
6382 tSmeCmd *pCommand;
6383 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006384 do
6385 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006386 smsLog( pMac, LOG1, FL(" reason = %d"), reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07006387 pCommand = csrGetCommandBuffer( pMac );
6388 if ( !pCommand )
6389 {
6390 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
6391 status = eHAL_STATUS_RESOURCES;
6392 break;
6393 }
6394 //Change the substate in case it is wait-for-key
6395 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
6396 {
6397 csrRoamStopWaitForKeyTimer( pMac );
6398 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6399 }
6400 pCommand->command = eSmeCommandRoam;
6401 pCommand->sessionId = (tANI_U8)sessionId;
6402 switch ( reason )
6403 {
6404 case eCSR_DISCONNECT_REASON_MIC_ERROR:
6405 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
6406 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006407 case eCSR_DISCONNECT_REASON_DEAUTH:
6408 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
6409 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006410 case eCSR_DISCONNECT_REASON_HANDOFF:
6411 fHighPriority = eANI_BOOLEAN_TRUE;
6412 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
6413 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006414 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
6415 case eCSR_DISCONNECT_REASON_DISASSOC:
6416 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
6417 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006418 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
6419 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
6420 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006421 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
6422 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
6423 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006424 default:
6425 break;
6426 }
6427 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6428 if( !HAL_STATUS_SUCCESS( status ) )
6429 {
6430 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
6431 csrReleaseCommandRoam( pMac, pCommand );
6432 }
6433 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006434 return( status );
6435}
6436
Jeff Johnson295189b2012-06-20 16:38:30 -07006437eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
6438{
6439 eHalStatus status = eHAL_STATUS_SUCCESS;
6440 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07006441 pCommand = csrGetCommandBuffer( pMac );
6442 if ( NULL != pCommand )
6443 {
6444 //Change the substate in case it is wait-for-key
6445 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
6446 {
6447 csrRoamStopWaitForKeyTimer( pMac );
6448 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6449 }
6450 pCommand->command = eSmeCommandRoam;
6451 pCommand->sessionId = (tANI_U8)sessionId;
6452 pCommand->u.roamCmd.roamReason = eCsrStopBss;
6453 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6454 if( !HAL_STATUS_SUCCESS( status ) )
6455 {
6456 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
6457 csrReleaseCommandRoam( pMac, pCommand );
6458 }
6459 }
6460 else
6461 {
6462 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
6463 status = eHAL_STATUS_RESOURCES;
6464 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006465 return ( status );
6466}
6467
Jeff Johnson295189b2012-06-20 16:38:30 -07006468eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
6469{
6470 eHalStatus status = eHAL_STATUS_SUCCESS;
6471 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006472
6473 if(!pSession)
6474 {
6475 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6476 return eHAL_STATUS_FAILURE;
6477 }
6478
Jeff Johnson295189b2012-06-20 16:38:30 -07006479#ifdef FEATURE_WLAN_BTAMP_UT_RF
6480 //Stop te retry
6481 pSession->maxRetryCount = 0;
6482 csrRoamStopJoinRetryTimer(pMac, sessionId);
6483#endif
6484 //Not to call cancel roaming here
6485 //Only issue disconnect when necessary
6486 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
6487 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
6488 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
6489
6490 {
6491 smsLog(pMac, LOG2, FL("called\n"));
6492 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
6493 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006494 return (status);
6495}
6496
Jeff Johnson295189b2012-06-20 16:38:30 -07006497eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
6498{
6499 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006500
6501 if(!pSession)
6502 {
6503 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6504 return eHAL_STATUS_FAILURE;
6505 }
6506
Jeff Johnson295189b2012-06-20 16:38:30 -07006507 csrRoamCancelRoaming(pMac, sessionId);
6508 pSession->ibss_join_pending = FALSE;
6509 csrRoamStopIbssJoinTimer(pMac, sessionId);
6510 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
6511
6512 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
6513}
6514
Jeff Johnson295189b2012-06-20 16:38:30 -07006515eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6516 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
6517{
6518 eHalStatus status = eHAL_STATUS_SUCCESS;
6519 tDot11fBeaconIEs *pIesTemp = pIes;
6520 tANI_U8 index;
6521 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
6522 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07006523
6524 if(!pSession)
6525 {
6526 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6527 return eHAL_STATUS_FAILURE;
6528 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006529
6530 palZeroMemory(pMac->hHdd, &pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile));
6531 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
6532 pConnectProfile->AuthInfo = pProfile->AuthType;
6533 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
6534 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
6535 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
6536 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
6537 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
6538 pConnectProfile->BSSType = pProfile->BSSType;
6539 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
6540 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07006541 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
6542
Jeff Johnson295189b2012-06-20 16:38:30 -07006543 palCopyMemory(pMac->hHdd, &pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006544 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
6545 if(pProfile->nAddIEAssocLength)
6546 {
6547 status = palAllocateMemory(pMac->hHdd,
6548 (void **)&pConnectProfile->pAddIEAssoc, pProfile->nAddIEAssocLength);
6549 if(!HAL_STATUS_SUCCESS(status))
6550 {
6551 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
6552 return eHAL_STATUS_FAILURE;
6553 }
6554 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
6555 palCopyMemory(pMac->hHdd, pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
6556 pProfile->nAddIEAssocLength);
6557 }
6558
Jeff Johnson295189b2012-06-20 16:38:30 -07006559 //Save bssid
6560 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
6561#ifdef WLAN_FEATURE_VOWIFI_11R
6562 if (pSirBssDesc->mdiePresent)
6563 {
6564 pConnectProfile->MDID.mdiePresent = 1;
6565 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
6566 }
6567#endif
6568#ifdef FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006569 if ((csrIsProfileCCX(pProfile) ||
6570 ((pIesTemp->CCXVersion.present)
6571 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
6572 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
6573 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
6574 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Saurabh Gupta775073c2013-02-14 13:31:36 +05306575 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006576 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07006577 {
6578 pConnectProfile->isCCXAssoc = 1;
6579 }
6580#endif
6581 //save ssid
6582 if( NULL == pIesTemp )
6583 {
6584 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
6585 }
6586 if(HAL_STATUS_SUCCESS(status))
6587 {
6588 if(pIesTemp->SSID.present)
6589 {
6590 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
6591 palCopyMemory(pMac->hHdd, pConnectProfile->SSID.ssId,
6592 pIesTemp->SSID.ssid, pIesTemp->SSID.num_ssid);
6593 }
6594
6595 //Save the bss desc
6596 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05306597
6598 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07006599 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05306600 //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 -07006601 pConnectProfile->qap = TRUE;
6602 }
6603 else
6604 {
6605 pConnectProfile->qap = FALSE;
6606 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006607 if ( NULL == pIes )
6608 {
6609 //Free memory if it allocated locally
6610 palFreeMemory(pMac->hHdd, pIesTemp);
6611 }
6612 }
6613 //Save Qos connection
6614 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
6615
6616 if(!HAL_STATUS_SUCCESS(status))
6617 {
6618 csrFreeConnectBssDesc(pMac, sessionId);
6619 }
6620 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
6621 {
6622 if((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
6623 palEqualMemory(pMac->hHdd, pProfile->SSIDs.SSIDList[index].SSID.ssId,
6624 pConnectProfile->SSID.ssId, pConnectProfile->SSID.length))
6625 {
6626 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
6627 break;
6628 }
6629 pConnectProfile->handoffPermitted = FALSE;
6630 }
6631
6632 return (status);
6633}
6634
Jeff Johnson295189b2012-06-20 16:38:30 -07006635static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
6636{
6637 tListElem *pEntry = NULL;
6638 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006639 //The head of the active list is the request we sent
6640 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
6641 if(pEntry)
6642 {
6643 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6644 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006645 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
6646 {
6647 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
6648 {
6649#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6650 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
6651#endif
6652 }
6653 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
6654 }
6655 else
6656 {
6657 tANI_U32 roamId = 0;
6658 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006659 if(!pSession)
6660 {
6661 smsLog(pMac, LOGE, FL(" session %d not found "), pSmeJoinRsp->sessionId);
6662 return;
6663 }
6664
Jeff Johnson295189b2012-06-20 16:38:30 -07006665
6666 //The head of the active list is the request we sent
6667 //Try to get back the same profile and roam again
6668 if(pCommand)
6669 {
6670 roamId = pCommand->u.roamCmd.roamId;
6671 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006672 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
6673 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
6674 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08lX [%d]\n", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
6675#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
6676 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
6677 if (csrRoamIsHandoffInProgress(pMac))
6678 {
6679 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6680 /* Should indicate neighbor roam algorithm about the connect failure here */
6681 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
6682 }
6683#endif
6684 if (pCommand)
6685 {
6686 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
6687 {
6688 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6689 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
6690 csrRoamReissueRoamCommand(pMac);
6691 }
6692 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
6693 {
6694 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6695 }
6696 else
6697 {
6698 csrRoam(pMac, pCommand);
6699 }
6700 }
6701 else
6702 {
6703 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6704 }
6705 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
6706}
6707
Jeff Johnson295189b2012-06-20 16:38:30 -07006708eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
6709 tDot11fBeaconIEs *pIes,
6710 tCsrRoamProfile *pProfile, tANI_U32 roamId )
6711{
6712 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006713 smsLog( pMac, LOG1, "Attempting to Join Bssid= %02x-%02x-%02x-%02x-%02x-%02x\n",
6714 pSirBssDesc->bssId[ 0 ],pSirBssDesc->bssId[ 1 ],pSirBssDesc->bssId[ 2 ],
6715 pSirBssDesc->bssId[ 3 ],pSirBssDesc->bssId[ 4 ],pSirBssDesc->bssId[ 5 ] );
6716
6717 // Set the roaming substate to 'join attempt'...
6718 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006719 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08006720 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006721 return (status);
6722}
6723
Jeff Johnson295189b2012-06-20 16:38:30 -07006724static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
6725 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
6726{
6727 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006728 // Set the roaming substate to 'join attempt'...
6729 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
6730
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08006731 smsLog(pMac, LOGE, FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006732
6733 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08006734 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07006735}
6736
Jeff Johnson295189b2012-06-20 16:38:30 -07006737void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
6738{
6739 tListElem *pEntry;
6740 tSmeCmd *pCommand;
6741 tCsrRoamInfo roamInfo;
6742 tANI_U32 sessionId;
6743 tCsrRoamSession *pSession;
6744
6745 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
6746 if(pEntry)
6747 {
6748 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6749 if ( eSmeCommandRoam == pCommand->command )
6750 {
6751 sessionId = pCommand->sessionId;
6752 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006753
6754 if(!pSession)
6755 {
6756 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6757 return;
6758 }
6759
Jeff Johnson295189b2012-06-20 16:38:30 -07006760 if( pCommand->u.roamCmd.fStopWds )
6761 {
6762 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
6763 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
6764 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6765 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07006766 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07006767 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
6768 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6769 eCSR_ROAM_WDS_IND,
6770 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07006771 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
6772 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
6773 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6774 eCSR_ROAM_INFRA_IND,
6775 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
6776 }
6777
Jeff Johnson295189b2012-06-20 16:38:30 -07006778
Jeff Johnson295189b2012-06-20 16:38:30 -07006779 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
6780 {
6781 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated\n");
6782 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6783 }
6784 }
6785 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
6786 {
6787 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated\n");
6788 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6789 }
6790 }
6791 else
6792 {
6793 smsLog(pMac, LOGW, " Command is not roaming after disassociated\n");
6794 }
6795 }
6796 else
6797 {
6798 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available\n");
6799 }
6800}
6801
Jeff Johnson295189b2012-06-20 16:38:30 -07006802tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
6803{
6804 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
6805 tListElem *pEntry;
6806 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006807 //alwasy lock active list before locking pending list
6808 csrLLLock( &pMac->sme.smeCmdActiveList );
6809 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
6810 if(pEntry)
6811 {
6812 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6813 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
6814 {
6815 fRet = eANI_BOOLEAN_TRUE;
6816 }
6817 }
6818 if(eANI_BOOLEAN_FALSE == fRet)
6819 {
6820 csrLLLock(&pMac->sme.smeCmdPendingList);
6821 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
6822 while(pEntry)
6823 {
6824 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6825 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
6826 {
6827 fRet = eANI_BOOLEAN_TRUE;
6828 break;
6829 }
6830 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
6831 }
6832 csrLLUnlock(&pMac->sme.smeCmdPendingList);
6833 }
6834 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07006835 return (fRet);
6836}
6837
Jeff Johnson295189b2012-06-20 16:38:30 -07006838tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
6839{
6840 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
6841 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07006842 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
6843 {
6844 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
6845 {
6846 break;
6847 }
6848 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006849 return ( fRet );
6850}
6851
Jeff Johnson295189b2012-06-20 16:38:30 -07006852tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
6853{
6854 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006855 //alwasy lock active list before locking pending list
6856 csrLLLock( &pMac->sme.smeCmdActiveList );
6857 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
6858 if(eANI_BOOLEAN_FALSE == fRet)
6859 {
6860 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
6861 }
6862 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07006863 return (fRet);
6864}
6865
Jeff Johnson295189b2012-06-20 16:38:30 -07006866tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
6867{
6868 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
6869 tListElem *pEntry;
6870 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07006871 //alwasy lock active list before locking pending list
6872 csrLLLock( &pMac->sme.smeCmdActiveList );
6873 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
6874 if( pEntry )
6875 {
6876 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
6877 if( ( eCsrRoamCommandScan == pCommand->command ) &&
6878 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
6879 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
6880 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
6881 {
6882 fRet = eANI_BOOLEAN_TRUE;
6883 }
6884 }
6885 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07006886 return (fRet);
6887}
Jeff Johnson295189b2012-06-20 16:38:30 -07006888eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
6889{
6890 eHalStatus status = eHAL_STATUS_SUCCESS;
6891 tSmeCmd *pCommand = NULL;
6892 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
6893 tANI_BOOLEAN fRemoveCmd = FALSE;
6894 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07006895 // Delete the old assoc command. All is setup for reassoc to be serialized
6896 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6897 if ( pEntry )
6898 {
6899 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6900 if ( !pCommand )
6901 {
6902 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
6903 return eHAL_STATUS_RESOURCES;
6904 }
6905 if ( eSmeCommandRoam == pCommand->command )
6906 {
6907 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
6908 {
6909 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
6910 }
6911 else
6912 {
6913 smsLog( pMac, LOGE, FL(" Unexpected active roam command present \n") );
6914 }
6915 if (fRemoveCmd == FALSE)
6916 {
6917 // Implies we did not get the serialized assoc command we
6918 // were expecting
6919 pCommand = NULL;
6920 }
6921 }
6922 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006923 if(NULL == pCommand)
6924 {
6925 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command\n") );
6926 return eHAL_STATUS_RESOURCES;
6927 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006928 do
6929 {
6930 //Change the substate in case it is wait-for-key
6931 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
6932 {
6933 csrRoamStopWaitForKeyTimer( pMac );
6934 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
6935 }
6936 pCommand->command = eSmeCommandRoam;
6937 pCommand->sessionId = (tANI_U8)sessionId;
6938 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07006939 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6940 if( !HAL_STATUS_SUCCESS( status ) )
6941 {
6942 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
6943 csrReleaseCommandRoam( pMac, pCommand );
6944 }
6945 } while( 0 );
6946
Jeff Johnson295189b2012-06-20 16:38:30 -07006947 return( status );
6948}
6949static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
6950{
6951 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
6952 tCsrScanResult *pScanResult = NULL;
6953 tSirBssDescription *pBssDesc = NULL;
6954 tSmeCmd *pCommand = NULL;
6955 tANI_U32 sessionId;
6956 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07006957 if(NULL == pEntry)
6958 {
6959 smsLog(pMac, LOGW, " CFG_CNF with active list empty\n");
6960 return;
6961 }
6962 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
6963 sessionId = pCommand->sessionId;
6964 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006965
6966 if(!pSession)
6967 {
6968 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6969 return;
6970 }
6971
Jeff Johnson295189b2012-06-20 16:38:30 -07006972 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
6973 {
6974 //the roaming is cancelled. Simply complete the command
6975 smsLog(pMac, LOGW, FL(" Roam command cancelled\n"));
6976 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
6977 }
6978 else
6979 {
6980 if ( CCM_IS_RESULT_SUCCESS(result) )
6981 {
6982 smsLog(pMac, LOG2, "Cfg sequence complete\n");
6983 // Successfully set the configuration parameters for the new Bss. Attempt to
6984 // join the roaming Bss.
6985 if(pCommand->u.roamCmd.pRoamBssEntry)
6986 {
6987 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
6988 pBssDesc = &pScanResult->Result.BssDescriptor;
6989 }
6990 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
6991 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07006992 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07006993 )
6994 {
6995 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
6996 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
6997 pBssDesc, pCommand->u.roamCmd.roamId )))
6998 {
6999 smsLog(pMac, LOGW, " CSR start BSS failed\n");
7000 //We need to complete the command
7001 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7002 }
7003 }
7004 else
7005 {
7006 if (!pCommand->u.roamCmd.pRoamBssEntry)
7007 {
7008 smsLog(pMac, LOGW, " pRoamBssEntry is NULL\n");
7009 //We need to complete the command
7010 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
7011 return;
7012 }
7013 // If we are roaming TO an Infrastructure BSS...
7014 VOS_ASSERT(pScanResult != NULL);
7015 if ( csrIsInfraBssDesc( pBssDesc ) )
7016 {
7017 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07007018 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
7019 {
7020 // ..and currently in an Infrastructure connection....
7021 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
7022 {
7023 // ...and the SSIDs are equal, then we Reassoc.
7024 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
7025 pIesLocal ) )
7026 // ..and currently in an infrastructure connection
7027 {
7028 // then issue a Reassoc.
7029 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
7030 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
7031 &pCommand->u.roamCmd.roamProfile );
7032 }
7033 else
7034 {
7035
7036 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
7037 // previously associated AP.
7038 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7039 pIesLocal,
7040 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
7041 {
7042 //try something else
7043 csrRoam( pMac, pCommand );
7044 }
7045 }
7046 }
7047 else
7048 {
7049 eHalStatus status = eHAL_STATUS_SUCCESS;
7050
7051 /* We need to come with other way to figure out that this is because of HO in BMP
7052 The below API will be only available for Android as it uses a different HO algorithm */
7053 /* Reassoc request will be used only for CCX and 11r handoff whereas other legacy roaming should
7054 * use join request */
7055#ifdef WLAN_FEATURE_VOWIFI_11R
7056 if (csrRoamIsHandoffInProgress(pMac) &&
7057 csrRoamIs11rAssoc(pMac))
7058 {
7059 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
7060 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
7061 }
7062 else
7063#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007064#ifdef FEATURE_WLAN_CCX
7065 if (csrRoamIsHandoffInProgress(pMac) &&
7066 csrRoamIsCCXAssoc(pMac))
7067 {
7068 // Now serialize the reassoc command.
7069 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7070 }
7071 else
7072#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007073#ifdef FEATURE_WLAN_LFR
7074 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05307075 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007076 {
7077 // Now serialize the reassoc command.
7078 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7079 }
7080 else
7081#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007082 // else we are not connected and attempting to Join. Issue the
7083 // Join request.
7084 {
7085 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7086 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
7087 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
7088 }
7089 if(!HAL_STATUS_SUCCESS(status))
7090 {
7091 //try something else
7092 csrRoam( pMac, pCommand );
7093 }
7094 }
7095 if( !pScanResult->Result.pvIes )
7096 {
7097 //Locally allocated
7098 palFreeMemory(pMac->hHdd, pIesLocal);
7099 }
7100 }
7101 }//if ( csrIsInfraBssDesc( pBssDesc ) )
7102 else
7103 {
7104 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description\n"));
7105 }
7106 }//else
7107 }//if ( WNI_CFG_SUCCESS == result )
7108 else
7109 {
7110 // In the event the configuration failed, for infra let the roam processor
7111 //attempt to join something else...
7112 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
7113 {
7114 csrRoam(pMac, pCommand);
7115 }
7116 else
7117 {
7118 //We need to complete the command
7119 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
7120 {
7121 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7122 }
7123 else
7124 {
7125 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7126 }
7127 }
7128 }
7129 }//we have active entry
7130}
7131
Jeff Johnson295189b2012-06-20 16:38:30 -07007132static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
7133{
7134 //No one is sending eWNI_SME_AUTH_REQ to PE.
7135 smsLog(pMac, LOGW, FL("is no-op\n"));
7136 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
7137 {
7138 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful\n" );
7139 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
7140 // join the new one...
7141 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07007142 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
7143 }
7144 else {
7145 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08lX [%d]\n", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
7146 /***profHandleLostLinkAfterReset(pAdapter);
7147 // In the event the authenticate fails, let the roam processor attempt to join something else...
7148 roamRoam( pAdapter );***/
7149 }
7150}
7151
Jeff Johnson295189b2012-06-20 16:38:30 -07007152static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
7153{
7154 eCsrRoamCompleteResult result;
7155 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7156 tCsrRoamInfo roamInfo;
7157 tANI_U32 roamId = 0;
7158
7159 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7160 {
7161 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful\n" );
7162 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07007163 /* Defeaturize this part later if needed */
7164#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7165 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
7166 * we need the response contents while processing the result in csrRoamProcessResults() */
7167 if (csrRoamIsHandoffInProgress(pMac))
7168 {
7169 /* Need to dig more on indicating events to SME QoS module */
7170 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7171 csrRoamComplete( pMac, result, pSmeJoinRsp);
7172 }
7173 else
7174#endif
7175 {
7176 csrRoamComplete( pMac, result, NULL );
7177 }
7178 }
7179 /* Should we handle this similar to handling the join failure? Is it ok
7180 * to call csrRoamComplete() with state as CsrJoinFailure */
7181 else
7182 {
7183 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08lX [%d]\n", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
7184 result = eCsrReassocFailure;
7185#ifdef WLAN_FEATURE_VOWIFI_11R
7186 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
7187 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode))
7188 {
7189 // Inform HDD to turn off FT flag in HDD
7190 if (pNeighborRoamInfo)
7191 {
7192 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7193 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
7194 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07007195 /*
7196 * Since the above callback sends a disconnect
7197 * to HDD, we should clean-up our state
7198 * machine as well to be in sync with the upper
7199 * layers. There is no need to send a disassoc
7200 * since: 1) we will never reassoc to the current
7201 * AP in LFR, and 2) there is no need to issue a
7202 * disassoc to the AP with which we were trying
7203 * to reassoc.
7204 */
7205 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7206 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007207 }
7208 }
7209#endif
7210 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
7211 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
7212 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
7213 //The disassoc rsp message will remove the command from active list
7214 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
7215 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
7216 {
7217 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7218 }
7219 }
7220}
7221
Jeff Johnson295189b2012-06-20 16:38:30 -07007222static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
7223{
Jeff Johnson295189b2012-06-20 16:38:30 -07007224#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7225 {
7226 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07007227 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
7228 if(pIbssLog)
7229 {
7230 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
7231 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
7232 {
7233 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
7234 }
7235 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
7236 }
7237 }
7238#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007239 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7240 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
7241 {
7242 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7243 }
7244 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
7245 {
7246 csrRoamReissueRoamCommand(pMac);
7247 }
7248}
7249
Jeff Johnson295189b2012-06-20 16:38:30 -07007250void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
7251{
7252 tSirResultCodes statusCode;
7253#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7254 tScanResultHandle hBSSList;
7255 tANI_BOOLEAN fCallCallback, fRemoveCmd;
7256 eHalStatus status;
7257 tCsrRoamInfo roamInfo;
7258 tCsrScanResultFilter *pScanFilter = NULL;
7259 tANI_U32 roamId = 0;
7260 tCsrRoamProfile *pCurRoamProfile = NULL;
7261 tListElem *pEntry = NULL;
7262 tSmeCmd *pCommand = NULL;
7263#endif
7264 tANI_U32 sessionId;
7265 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07007266
Jeff Johnson295189b2012-06-20 16:38:30 -07007267 tSirSmeDisassocRsp SmeDisassocRsp;
7268
7269 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
7270 sessionId = SmeDisassocRsp.sessionId;
7271 statusCode = SmeDisassocRsp.statusCode;
7272
7273 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d\n", sessionId);
7274
7275 if ( csrIsConnStateInfra( pMac, sessionId ) )
7276 {
7277 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7278 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007279 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007280
7281 if(!pSession)
7282 {
7283 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7284 return;
7285 }
7286
Jeff Johnson295189b2012-06-20 16:38:30 -07007287 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
7288 {
7289 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7290 }
7291 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
7292 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
7293 {
7294 if ( eSIR_SME_SUCCESS == statusCode )
7295 {
7296 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully\n" );
7297 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
7298 }
7299 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7300 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007301 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
7302 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007303 smsLog( pMac, LOGE, "CSR SmeDisassocReq due to HO on session %d\n", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007304#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007305 /*
7306 * First ensure if the roam profile is in the scan cache.
7307 * If not, post a reassoc failure and disconnect.
7308 */
7309 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
7310 if(HAL_STATUS_SUCCESS(status))
7311 {
7312 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
7313 status = csrRoamPrepareFilterFromProfile(pMac,
7314 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
7315 if(!HAL_STATUS_SUCCESS(status))
7316 {
7317 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
7318 __func__, status);
7319 goto POST_ROAM_FAILURE;
7320 }
7321 else
7322 {
7323 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7324 if (!HAL_STATUS_SUCCESS(status))
7325 {
7326 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
7327 __func__, status);
7328 goto POST_ROAM_FAILURE;
7329 }
7330 }
7331 }
7332 else
7333 {
7334 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
7335 __func__, status);
7336 goto POST_ROAM_FAILURE;
7337 }
7338
7339 /*
7340 * After ensuring that the roam profile is in the scan result list,
7341 * dequeue the command from the active list.
7342 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007343 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7344 if ( pEntry )
7345 {
7346 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007347 /* If the head of the queue is Active and it is a ROAM command, remove
7348 * and put this on the Free queue.
7349 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007350 if ( eSmeCommandRoam == pCommand->command )
7351 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007352
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007353 /*
7354 * we need to process the result first before removing it from active list
7355 * because state changes still happening insides roamQProcessRoamResults so
7356 * no other roam command should be issued.
7357 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007358 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7359 if(pCommand->u.roamCmd.fReleaseProfile)
7360 {
7361 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
7362 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
7363 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007364 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07007365 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07007366 else
7367 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007368 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d\n",
7369 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07007370 }
7371 }
7372 else
7373 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007374 smsLog( pMac, LOGE, "%s: roam command not active\n", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007375 }
7376 }
7377 else
7378 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007379 smsLog( pMac, LOGE, "%s: NO commands are active\n", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007380 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007381
7382 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07007383 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
7384
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007385 palCopyMemory(pMac->hHdd, roamInfo.bssid,
7386 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
7387 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07007388
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007389 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
7390 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007391
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007392 /* Copy the connected profile to apply the same for this connection as well */
7393 if(HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
7394 (void **)&pCurRoamProfile, sizeof(tCsrRoamProfile))))
Jeff Johnson295189b2012-06-20 16:38:30 -07007395 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007396 palZeroMemory(pMac->hHdd, pCurRoamProfile, sizeof(tCsrRoamProfile));
7397 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
7398 //make sure to put it at the head of the cmd queue
7399 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
7400 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
7401 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
7402
Jeff Johnson295189b2012-06-20 16:38:30 -07007403 if(!HAL_STATUS_SUCCESS(status))
7404 {
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007405 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
7406 __func__, status);
7407 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007408 }
7409
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007410 /* Notify sub-modules like QoS etc. that handoff happening */
7411 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
7412 palFreeMemory(pMac->hHdd, pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07007413 csrFreeScanFilter(pMac, pScanFilter);
7414 palFreeMemory( pMac->hHdd, pScanFilter );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007415 return;
7416 }
7417
7418POST_ROAM_FAILURE:
7419 if (pScanFilter)
7420 {
7421 csrFreeScanFilter(pMac, pScanFilter);
7422 palFreeMemory( pMac->hHdd, pScanFilter );
7423 }
7424 if (pCurRoamProfile)
7425 palFreeMemory(pMac->hHdd, pCurRoamProfile);
7426
7427 /* Inform the upper layers that the reassoc failed */
7428 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7429 csrRoamCallCallback(pMac, sessionId,
7430 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
7431
7432 /*
7433 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
7434 * Upon success, we would re-enter this routine after receiving the disassoc
7435 * response and will fall into the reassoc fail sub-state. And, eventually
7436 * call csrRoamComplete which would remove the roam command from SME active
7437 * queue.
7438 */
7439 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
7440 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
7441 {
7442 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
7443 __func__, status);
7444 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07007445 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007446#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07007447
Jeff Johnson295189b2012-06-20 16:38:30 -07007448 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
7449 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
7450 {
7451 // Disassoc due to Reassoc failure falls into this codepath....
7452 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7453 }
7454 else
7455 {
7456 if ( eSIR_SME_SUCCESS == statusCode )
7457 {
7458 // Successfully disassociated from the 'old' Bss...
7459 //
7460 // We get Disassociate response in three conditions.
7461 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
7462 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
7463 // Infrastructure network.
7464 // - Third is where we are doing an Infra to Infra roam between networks with different
7465 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
7466
7467 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully\n" );
7468 }
7469 else
7470 {
7471 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08lX\n", statusCode );
7472 }
7473 //We are not done yet. Get the data and continue roaming
7474 csrRoamReissueRoamCommand(pMac);
7475 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007476}
7477
Jeff Johnson295189b2012-06-20 16:38:30 -07007478static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
7479{
7480 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007481 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
7482 smsLog(pMac, LOGW, FL("is no-op\n"));
7483 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
7484 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
7485 {
7486 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7487 }
7488 else
7489 {
7490 if ( eSIR_SME_SUCCESS == statusCode )
7491 {
7492 // Successfully deauth from the 'old' Bss...
7493 //
7494 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully\n" );
7495 }
7496 else
7497 {
7498 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08lX\n", statusCode );
7499 }
7500 //We are not done yet. Get the data and continue roaming
7501 csrRoamReissueRoamCommand(pMac);
7502 }
7503}
7504
Jeff Johnson295189b2012-06-20 16:38:30 -07007505static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
7506{
7507 eCsrRoamCompleteResult result;
7508
7509 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
7510 {
7511 smsLog( pMac, LOGW, "SmeStartBssReq Successful\n" );
7512 result = eCsrStartBssSuccess;
7513 }
7514 else
7515 {
7516 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08lX\n", pSmeStartBssRsp->statusCode );
7517 //Let csrRoamComplete decide what to do
7518 result = eCsrStartBssFailure;
7519 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007520 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007521}
7522
Jeff Johnson295189b2012-06-20 16:38:30 -07007523/*
7524 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
7525 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
7526 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
7527 For the messages where sender allocates memory for specific structures, then it can be
7528 cast accordingly.
7529*/
7530void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
7531{
7532 tSirSmeRsp *pSmeRsp;
7533 tSmeIbssPeerInd *pIbssPeerInd;
7534 tCsrRoamInfo roamInfo;
7535 // TODO Session Id need to be acquired in this function
7536 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007537 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07007538 smsLog( pMac, LOG2, "Message %d[0x%04X] received in substate %d\n",
7539 pSmeRsp->messageType, pSmeRsp->messageType,
7540 pMac->roam.curSubState[pSmeRsp->sessionId] );
Jeff Johnson295189b2012-06-20 16:38:30 -07007541 pSmeRsp->messageType = (pSmeRsp->messageType);
7542 pSmeRsp->length = (pSmeRsp->length);
7543 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007544 switch (pSmeRsp->messageType)
7545 {
7546
7547 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
7548 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
7549 {
7550 //We sent a JOIN_REQ
7551 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
7552 }
7553 break;
7554
7555 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
7556 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
7557 {
7558 //We sent a AUTH_REQ
7559 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
7560 }
7561 break;
7562
7563 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
7564 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
7565 {
7566 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
7567 }
7568 break;
7569
7570 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
7571 {
7572 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
7573 }
7574 break;
7575
7576 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
7577 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
7578 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
7579 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
7580 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
7581 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
7582//HO
7583 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
7584 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07007585 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %d\n"), pMac->roam.curSubState[pSmeRsp->sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007586 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
7587 }
7588 break;
7589
7590 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
7591 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
7592 {
7593 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
7594 }
7595 break;
7596
7597 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
7598 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
7599 {
7600 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
7601 }
7602 break;
7603
7604 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
7605 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
7606 {
7607 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
7608 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007609 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007610 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
7611 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
7612 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
7613 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state\n");
7614 palZeroMemory( pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo) );
7615 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
7616 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
7617 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
7618 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
7619 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
7620 eCSR_ROAM_CONNECT_STATUS_UPDATE,
7621 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
7622 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007623 default:
7624 smsLog( pMac, LOG1, "Unexpected message type = %d[0x%X] received in substate %d\n",
7625 pSmeRsp->messageType, pSmeRsp->messageType,
7626 pMac->roam.curSubState[pSmeRsp->sessionId] );
7627
7628 //If we are connected, check the link status change
7629 if(!csrIsConnStateDisconnected(pMac, sessionId))
7630 {
7631 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
7632 }
7633 break;
7634 }
7635}
7636
Jeff Johnson295189b2012-06-20 16:38:30 -07007637void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
7638{
7639 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07007640 switch (pSirMsg->messageType)
7641 {
7642 case eWNI_SME_GET_STATISTICS_RSP:
Mohit Khanna23863762012-09-11 17:40:09 -07007643 smsLog( pMac, LOG2, FL("Stats rsp from PE\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007644 csrRoamStatsRspProcessor( pMac, pSirMsg );
7645 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007646 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
7647 {
7648 tCsrRoamSession *pSession;
7649 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
7650 tCsrRoamInfo roamInfo;
7651 tCsrRoamInfo *pRoamInfo = NULL;
7652 tANI_U32 sessionId;
7653 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007654 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer \n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007655 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
7656 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07007657 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
7658 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
7659 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07007660
7661 if(!pSession)
7662 {
7663 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7664 return;
7665 }
7666
Jeff Johnson295189b2012-06-20 16:38:30 -07007667 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
7668 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07007669 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
7670 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
7671 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07007672 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
7673 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07007674 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr, sizeof(tSirMacAddr));
7675 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pUpperLayerAssocCnf->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07007676 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07007677 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
7678 {
7679 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
7680 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
7681 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
7682 }
7683 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
7684 {
7685 vos_sleep( 100 );
7686 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
7687 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
7688 }
7689
Jeff Johnson295189b2012-06-20 16:38:30 -07007690 }
7691 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007692 default:
7693 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
7694 break;
7695 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007696}
7697
Jeff Johnson295189b2012-06-20 16:38:30 -07007698eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
7699 tSirBssDescription *pBssDescription,
7700 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
7701 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
7702 tANI_U8 keyId, tANI_U16 keyLength,
7703 tANI_U8 *pKey, tANI_U8 paeRole )
7704{
7705 eHalStatus status = eHAL_STATUS_SUCCESS;
7706 tAniEdType edType;
7707
7708 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
7709 {
7710 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
7711 }
7712
7713 edType = csrTranslateEncryptTypeToEdType( EncryptType );
7714
7715 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
7716 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
7717 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
7718 addKey )
7719 {
7720 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07007721 setKey.encType = EncryptType;
7722 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
7723 palCopyMemory( pMac->hHdd, &setKey.peerMac, bssId, sizeof(tCsrBssid) );
7724 setKey.paeRole = paeRole; //0 for supplicant
7725 setKey.keyId = keyId; // Kye index
7726 setKey.keyLength = keyLength;
7727 if( keyLength )
7728 {
7729 palCopyMemory( pMac->hHdd, setKey.Key, pKey, keyLength );
7730 }
7731 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
7732 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007733 return (status);
7734}
7735
Jeff Johnson295189b2012-06-20 16:38:30 -07007736static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
7737 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
7738{
7739 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
7740 tSmeCmd *pCommand = NULL;
7741#ifdef FEATURE_WLAN_CCX
7742 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7743#endif /* FEATURE_WLAN_CCX */
7744
7745 do
7746 {
7747 pCommand = csrGetCommandBuffer(pMac);
7748 if(NULL == pCommand)
7749 {
7750 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
7751 status = eHAL_STATUS_RESOURCES;
7752 break;
7753 }
7754 pCommand->command = eSmeCommandSetKey;
7755 pCommand->sessionId = (tANI_U8)sessionId;
7756 // validate the key length, Adjust if too long...
7757 // for static WEP the keys are not set thru' SetContextReq
7758 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
7759 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
7760 {
7761 //KeyLength maybe 0 for static WEP
7762 if( pSetKey->keyLength )
7763 {
7764 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
7765 {
7766 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7767 break;
7768 }
7769
7770 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
7771 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WEP40_KEY_LEN );
7772 }
7773 }
7774 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
7775 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
7776 {
7777 //KeyLength maybe 0 for static WEP
7778 if( pSetKey->keyLength )
7779 {
7780 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
7781 {
7782 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7783 break;
7784 }
7785
7786 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
7787 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WEP104_KEY_LEN );
7788 }
7789 }
7790 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
7791 {
7792 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
7793 {
7794 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7795 break;
7796 }
7797 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
7798 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_TKIP_KEY_LEN );
7799 }
7800 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
7801 {
7802 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
7803 {
7804 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7805 break;
7806 }
7807 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
7808 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN );
7809 }
7810#ifdef FEATURE_WLAN_WAPI
7811 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
7812 {
7813 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
7814 {
7815 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7816 break;
7817 }
7818 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
7819 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_WAPI_KEY_LEN );
7820 }
7821#endif /* FEATURE_WLAN_WAPI */
7822#ifdef FEATURE_WLAN_CCX
7823 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
7824 {
7825 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
7826 {
7827 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7828 break;
7829 }
7830 palCopyMemory( pMac->hHdd, pSession->ccxCckmInfo.krk, pSetKey->Key, CSR_KRK_KEY_LEN );
7831 pSession->ccxCckmInfo.reassoc_req_num=1;
7832 pSession->ccxCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
7833 status = eHAL_STATUS_SUCCESS;
7834 break;
7835 }
7836#endif /* FEATURE_WLAN_CCX */
Jeff Johnsone7245742012-09-05 17:12:55 -07007837
Jeff Johnson295189b2012-06-20 16:38:30 -07007838#ifdef WLAN_FEATURE_11W
7839 //Check for 11w BIP
7840 else if ( eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType )
7841 {
7842 tANI_U16 count = 0;
7843 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
7844 {
7845 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call\n", pSetKey->keyLength );
7846 break;
7847 }
7848 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
7849 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN );
7850 }
7851#endif
7852 status = eHAL_STATUS_SUCCESS;
7853 pCommand->u.setKeyCmd.roamId = roamId;
7854 pCommand->u.setKeyCmd.encType = pSetKey->encType;
7855 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
7856 palCopyMemory( pMac->hHdd, &pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac, sizeof(tCsrBssid) );
7857 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
7858 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
7859 palCopyMemory( pMac->hHdd, pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN );
7860 //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
7861
7862 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
7863 if( !HAL_STATUS_SUCCESS( status ) )
7864 {
7865 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
7866 }
7867 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007868 // Free the command if there has been a failure, or it is a
7869 // "local" operation like the set CCX CCKM KRK key.
7870 if( (!HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ))
7871#ifdef FEATURE_WLAN_CCX
7872 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
7873#endif /* FEATURE_WLAN_CCX */
7874 )
7875 {
7876 csrReleaseCommandSetKey( pMac, pCommand );
7877 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007878 return( status );
7879}
7880
Jeff Johnson295189b2012-06-20 16:38:30 -07007881eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
7882 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
7883{
7884 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
7885 tSmeCmd *pCommand = NULL;
7886 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007887 do
7888 {
7889 if( !csrIsSetKeyAllowed(pMac, sessionId) )
7890 {
7891 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key\n") );
7892 status = eHAL_STATUS_CSR_WRONG_STATE;
7893 break;
7894 }
7895 pCommand = csrGetCommandBuffer(pMac);
7896 if(NULL == pCommand)
7897 {
7898 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
7899 status = eHAL_STATUS_RESOURCES;
7900 break;
7901 }
7902 pCommand->command = eSmeCommandRemoveKey;
7903 pCommand->sessionId = (tANI_U8)sessionId;
7904 pCommand->u.removeKeyCmd.roamId = roamId;
7905 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
7906 palCopyMemory( pMac->hHdd, &pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac, sizeof(tSirMacAddr) );
7907 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
7908 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7909 {
7910 //in this case, put it to the end of the Q incase there is a set key pending.
7911 fImediate = eANI_BOOLEAN_FALSE;
7912 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007913 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac=%02x, %02x, %02x, %02x, %02x, %02x\n"),
7914 pRemoveKey->encType, pRemoveKey->keyId,
7915 pCommand->u.removeKeyCmd.peerMac[0],
7916 pCommand->u.removeKeyCmd.peerMac[1],
7917 pCommand->u.removeKeyCmd.peerMac[2],
7918 pCommand->u.removeKeyCmd.peerMac[3],
7919 pCommand->u.removeKeyCmd.peerMac[4],
7920 pCommand->u.removeKeyCmd.peerMac[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007921 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
7922 if( !HAL_STATUS_SUCCESS( status ) )
7923 {
7924 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
7925 break;
7926 }
7927 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007928 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
7929 {
7930 csrReleaseCommandRemoveKey( pMac, pCommand );
7931 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007932 return (status );
7933}
7934
Jeff Johnson295189b2012-06-20 16:38:30 -07007935eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
7936{
7937 eHalStatus status;
7938 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
7939 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
7940 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
7941 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007942#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7943 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7944 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07007945 if(eCSR_ENCRYPT_TYPE_NONE != edType)
7946 {
7947 palZeroMemory(pMac->hHdd, &setKeyEvent, sizeof(vos_event_wlan_security_payload_type));
7948 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
7949 {
7950 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
7951 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
7952 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
7953 }
7954 else
7955 {
7956 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
7957 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
7958 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
7959 }
7960 palCopyMemory( pMac->hHdd, setKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
7961 if(CSR_IS_ENC_TYPE_STATIC(edType))
7962 {
7963 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007964 //It has to be static WEP here
7965 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
7966 {
7967 setKeyEvent.keyId = (v_U8_t)defKeyId;
7968 }
7969 }
7970 else
7971 {
7972 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
7973 }
7974 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
7975 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
7976 }
7977#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007978 if( csrIsSetKeyAllowed(pMac, sessionId) )
7979 {
7980 status = csrSendMBSetContextReqMsg( pMac, sessionId,
7981 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
7982 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
7983 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
7984 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
7985 pCommand->u.setKeyCmd.keyRsc);
7986 }
7987 else
7988 {
7989 smsLog( pMac, LOGW, FL(" cannot process not connected\n") );
7990 //Set this status so the error handling take care of the case.
7991 status = eHAL_STATUS_CSR_WRONG_STATE;
7992 }
7993 if( !HAL_STATUS_SUCCESS(status) )
7994 {
7995 smsLog( pMac, LOGE, FL(" error status %d\n"), status );
7996 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007997#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7998 if(eCSR_ENCRYPT_TYPE_NONE != edType)
7999 {
8000 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8001 {
8002 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8003 }
8004 else
8005 {
8006 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8007 }
8008 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8009 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8010 }
8011#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008012 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008013 return ( status );
8014}
8015
Jeff Johnson295189b2012-06-20 16:38:30 -07008016eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8017{
8018 eHalStatus status;
8019 tpSirSmeRemoveKeyReq pMsg = NULL;
8020 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
8021 tANI_U8 *p;
8022 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008023#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8024 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8025 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07008026 palZeroMemory(pMac->hHdd, &removeKeyEvent, sizeof(vos_event_wlan_security_payload_type));
8027 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
8028 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8029 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8030 palCopyMemory( pMac->hHdd, removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
8031 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
8032 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8033 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8034#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008035 if( csrIsSetKeyAllowed(pMac, sessionId) )
8036 {
8037 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, wMsgLen );
8038 }
8039 else
8040 {
8041 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key\n") );
8042 //Set the error status so error handling kicks in below
8043 status = eHAL_STATUS_CSR_WRONG_STATE;
8044 }
8045 if( HAL_STATUS_SUCCESS( status ) )
8046 {
8047 palZeroMemory(pMac->hHdd, pMsg, wMsgLen);
8048 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
8049 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008050 pMsg->sessionId = (tANI_U8)sessionId;
8051 pMsg->transactionId = 0;
8052 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
8053 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
8054 // bssId - copy from session Info
8055 palCopyMemory( pMac->hHdd, p, &pMac->roam.roamSession[sessionId].connectedProfile.bssid, sizeof(tSirMacAddr) );
8056 p += sizeof(tSirMacAddr);
8057 // peerMacAddr
8058 palCopyMemory( pMac->hHdd, p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr) );
8059 p += sizeof(tSirMacAddr);
8060 // edType
8061 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
8062 p++;
8063 // weptype
8064 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
8065 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
8066 {
8067 *p = (tANI_U8)eSIR_WEP_STATIC;
8068 }
8069 else
8070 {
8071 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
8072 }
8073 p++;
8074 //keyid
8075 *p = pCommand->u.removeKeyCmd.keyId;
8076 p++;
8077 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008078 status = palSendMBMessage(pMac->hHdd, pMsg);
8079 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008080 if( !HAL_STATUS_SUCCESS( status ) )
8081 {
8082 smsLog( pMac, LOGE, FL(" error status \n"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008083#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8084 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07008085 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008086 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8087#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008088 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
8089 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008090 return ( status );
8091}
8092
Jeff Johnson295189b2012-06-20 16:38:30 -07008093eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8094{
8095 eHalStatus status;
8096
8097 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8098 {
8099 status = eHAL_STATUS_CSR_WRONG_STATE;
8100 }
8101 else
8102 {
8103 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
8104 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008105 return ( status );
8106}
8107
Jeff Johnson295189b2012-06-20 16:38:30 -07008108/*
8109 Prepare a filter base on a profile for parsing the scan results.
8110 Upon successful return, caller MUST call csrFreeScanFilter on
8111 pScanFilter when it is done with the filter.
8112*/
8113eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
8114 tCsrScanResultFilter *pScanFilter)
8115{
8116 eHalStatus status = eHAL_STATUS_SUCCESS;
8117 tANI_U32 size = 0;
8118 tANI_U8 index = 0;
8119
8120 do
8121 {
8122 if(pProfile->BSSIDs.numOfBSSIDs)
8123 {
8124 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
8125 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->BSSIDs.bssid, size);
8126 if(!HAL_STATUS_SUCCESS(status))
8127 {
8128 break;
8129 }
8130 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
8131 palCopyMemory(pMac->hHdd, pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
8132 }
8133 if(pProfile->SSIDs.numOfSSIDs)
8134 {
8135 if( !CSR_IS_WDS_STA( pProfile ) )
8136 {
8137 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
8138 }
8139 else
8140 {
8141 //For WDS station
8142 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
8143 pScanFilter->SSIDs.numOfSSIDs = 1;
8144 }
8145 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
8146 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->SSIDs.SSIDList, size);
8147 if(!HAL_STATUS_SUCCESS(status))
8148 {
8149 break;
8150 }
8151 palCopyMemory(pMac->hHdd, pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList, size);
8152 }
8153 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
8154 {
8155 pScanFilter->ChannelInfo.numOfChannels = 0;
8156 pScanFilter->ChannelInfo.ChannelList = NULL;
8157 }
8158 else if(pProfile->ChannelInfo.numOfChannels)
8159 {
8160 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->ChannelInfo.ChannelList, sizeof(*pScanFilter->ChannelInfo.ChannelList) * pProfile->ChannelInfo.numOfChannels);
8161 pScanFilter->ChannelInfo.numOfChannels = 0;
8162 if(HAL_STATUS_SUCCESS(status))
8163 {
8164 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
8165 {
8166 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
8167 {
8168 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
8169 = pProfile->ChannelInfo.ChannelList[index];
8170 pScanFilter->ChannelInfo.numOfChannels++;
8171 }
8172 else
8173 {
8174 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid\n"), pProfile->ChannelInfo.ChannelList[index]);
8175 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008176 }
8177 }
8178 else
8179 {
8180 break;
8181 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008182 }
8183 else
8184 {
8185 smsLog(pMac, LOGW, FL("Channel list empty\n"));
8186 status = eHAL_STATUS_FAILURE;
8187 break;
8188 }
8189 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
8190 pScanFilter->authType = pProfile->AuthType;
8191 pScanFilter->EncryptionType = pProfile->EncryptionType;
8192 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
8193 pScanFilter->BSSType = pProfile->BSSType;
8194 pScanFilter->phyMode = pProfile->phyMode;
8195#ifdef FEATURE_WLAN_WAPI
8196 //check if user asked for WAPI with 11n or auto mode, in that case modify
8197 //the phymode to 11g
8198 if(csrIsProfileWapi(pProfile))
8199 {
8200 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
8201 {
8202 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
8203 }
8204 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
8205 {
8206 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
8207 }
8208 if(!pScanFilter->phyMode)
8209 {
8210 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
8211 }
8212 }
8213#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07008214 /*Save the WPS info*/
8215 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07008216 if( pProfile->countryCode[0] )
8217 {
8218 //This causes the matching function to use countryCode as one of the criteria.
8219 palCopyMemory( pMac->hHdd, pScanFilter->countryCode, pProfile->countryCode,
8220 WNI_CFG_COUNTRY_CODE_LEN );
8221 }
8222#ifdef WLAN_FEATURE_VOWIFI_11R
8223 if (pProfile->MDID.mdiePresent)
8224 {
8225 pScanFilter->MDID.mdiePresent = 1;
8226 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
8227 }
8228#endif
8229
8230 }while(0);
8231
8232 if(!HAL_STATUS_SUCCESS(status))
8233 {
8234 csrFreeScanFilter(pMac, pScanFilter);
8235 }
8236
8237 return(status);
8238}
8239
Jeff Johnson295189b2012-06-20 16:38:30 -07008240tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
8241 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
8242{
8243 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
8244 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008245 do
8246 {
8247 // Validate the type is ok...
8248 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
8249 pCommand = csrGetCommandBuffer( pMac );
8250 if ( !pCommand )
8251 {
8252 smsLog( pMac, LOGE, FL(" fail to get command buffer\n") );
8253 break;
8254 }
8255 //Change the substate in case it is waiting for key
8256 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8257 {
8258 csrRoamStopWaitForKeyTimer( pMac );
8259 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
8260 }
8261 pCommand->command = eSmeCommandWmStatusChange;
8262 pCommand->sessionId = (tANI_U8)sessionId;
8263 pCommand->u.wmStatusChangeCmd.Type = Type;
8264 if ( eCsrDisassociated == Type )
8265 {
8266 palCopyMemory( pMac->hHdd, &pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg, pSmeRsp,
8267 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ) );
8268 }
8269 else
8270 {
8271 palCopyMemory( pMac->hHdd, &pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg, pSmeRsp,
8272 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ) );
8273 }
8274 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
8275 {
8276 fCommandQueued = eANI_BOOLEAN_TRUE;
8277 }
8278 else
8279 {
8280 smsLog( pMac, LOGE, FL(" fail to send message \n") );
8281 csrReleaseCommandWmStatusChange( pMac, pCommand );
8282 }
8283
Jeff Johnson295189b2012-06-20 16:38:30 -07008284 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
8285 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07008286 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07008287 return( fCommandQueued );
8288}
8289
Jeff Johnson295189b2012-06-20 16:38:30 -07008290static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
8291{
8292 v_S7_t rssi = 0;
8293 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
8294 if(pGetRssiReq)
8295 {
8296 if(NULL != pGetRssiReq->pVosContext)
8297 {
8298 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
8299 }
8300 else
8301 {
8302 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL\n"));
8303 return;
8304 }
8305
8306 if(NULL != pGetRssiReq->rssiCallback)
8307 {
8308 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
8309 }
8310 else
8311 {
8312 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL\n"));
8313 return;
8314 }
8315 }
8316 else
8317 {
8318 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL\n"));
8319 }
8320 return;
8321}
Jeff Johnsone7245742012-09-05 17:12:55 -07008322static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
8323{
8324 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
8325 if(pTlRssiInd)
8326 {
8327 if(NULL != pTlRssiInd->tlCallback)
8328 {
8329 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08008330 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07008331 }
8332 else
8333 {
8334 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL\n"));
8335 }
8336 }
8337 else
8338 {
8339 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL\n"));
8340 }
8341 return;
8342}
Jeff Johnson295189b2012-06-20 16:38:30 -07008343
8344void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
8345{
8346 tSirSmeAssocInd *pAssocInd;
8347 tSirSmeDisassocInd *pDisassocInd;
8348 tSirSmeDeauthInd *pDeauthInd;
8349 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
8350 tSirSmeNewBssInfo *pNewBss;
8351 tSmeIbssPeerInd *pIbssPeerInd;
8352 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
8353 tSirSmeApNewCaps *pApNewCaps;
8354 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
8355 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
8356 tCsrRoamInfo *pRoamInfo = NULL;
8357 tCsrRoamInfo roamInfo;
8358 eHalStatus status;
8359 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
8360 tCsrRoamSession *pSession = NULL;
8361 tpSirSmeSwitchChannelInd pSwitchChnInd;
8362 tSmeMaxAssocInd *pSmeMaxAssocInd;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08008363 tSmeCmd pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008364 pSirMsg->messageType = (pSirMsg->messageType);
8365 pSirMsg->length = (pSirMsg->length);
8366 pSirMsg->statusCode = (pSirMsg->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008367 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(roamInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07008368 switch( pSirMsg->messageType )
8369 {
8370 case eWNI_SME_ASSOC_IND:
8371 {
8372 tCsrRoamSession *pSession;
8373 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME\n"));
8374 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
8375 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
8376 if( HAL_STATUS_SUCCESS( status ) )
8377 {
8378 pSession = CSR_GET_SESSION(pMac, sessionId);
8379
Jeff Johnson32d95a32012-09-10 13:15:23 -07008380 if(!pSession)
8381 {
8382 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8383 return;
8384 }
8385
Jeff Johnson295189b2012-06-20 16:38:30 -07008386 pRoamInfo = &roamInfo;
8387
8388 // Required for indicating the frames to upper layer
8389 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
8390 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
8391
8392 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
8393 pRoamInfo->beaconLength = pAssocInd->beaconLength;
8394 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8395 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8396
8397 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
8398 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
8399 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
8400
8401 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
8402 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008403 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
8404 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pAssocInd->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008405 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
8406 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07008407 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07008408 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
8409 {
8410 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
8411 {
8412 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
8413 pSession->pConnectBssDesc,
8414 &(pRoamInfo->peerMac),
8415 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
8416 pRoamInfo->fAuthRequired = FALSE;
8417 }
8418 else
8419 {
8420 pRoamInfo->fAuthRequired = TRUE;
8421 }
8422 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
8423 if (!HAL_STATUS_SUCCESS(status))
8424 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
8425 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008426 /* Send Association completion message to PE */
8427 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
8428
8429 /* send a message to CSR itself just to avoid the EAPOL frames going
8430 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07008431 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8432 {
8433 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
8434 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008435 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
8436 {
8437 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
8438 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8439 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
8440 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008441 }
8442 }
8443 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008444 case eWNI_SME_DISASSOC_IND:
8445 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008446 // Check if AP dis-associated us because of MIC failure. If so,
8447 // then we need to take action immediately and not wait till the
8448 // the WmStatusChange requests is pushed and processed
8449 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
8450 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDisassocInd->bssId, &sessionId );
8451 if( HAL_STATUS_SUCCESS( status ) )
8452 {
8453 // If we are in neighbor preauth done state then on receiving
8454 // disassoc or deauth we dont roam instead we just disassoc
8455 // from current ap and then go to disconnected state
8456 // This happens for CCX and 11r FT connections ONLY.
8457#ifdef WLAN_FEATURE_VOWIFI_11R
8458 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8459 {
8460 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8461 }
8462#endif
8463#ifdef FEATURE_WLAN_CCX
8464 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8465 {
8466 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8467 }
8468#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008469#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308470 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008471 {
8472 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8473 }
8474#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008475 pSession = CSR_GET_SESSION( pMac, sessionId );
8476
Jeff Johnson32d95a32012-09-10 13:15:23 -07008477 if(!pSession)
8478 {
8479 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8480 return;
8481 }
8482
Jeff Johnson295189b2012-06-20 16:38:30 -07008483 if ( csrIsConnStateInfra( pMac, sessionId ) )
8484 {
8485 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8486 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008487#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8488 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
8489#endif
8490 csrRoamLinkDown(pMac, sessionId);
8491 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07008492 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
8493 {
8494
8495 pRoamInfo = &roamInfo;
8496
8497 pRoamInfo->statusCode = pDisassocInd->statusCode;
8498 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8499
8500 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
8501
8502 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDisassocInd->peerMacAddr, sizeof(tSirMacAddr));
8503 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pDisassocInd->bssId, sizeof(tCsrBssid));
8504
8505 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08008506
8507 /*
8508 * STA/P2P client got disassociated so remove any pending deauth
8509 * commands in sme pending list
8510 */
8511 pCommand.command = eSmeCommandRoam;
8512 pCommand.sessionId = (tANI_U8)sessionId;
8513 pCommand.u.roamCmd.roamReason = eCsrForcedDeauthSta;
8514 vos_mem_copy(pCommand.u.roamCmd.peerMac, pDisassocInd->peerMacAddr, sizeof(tSirMacAddr));
8515 csrRoamRemoveDuplicateCommand(pMac, sessionId, &pCommand, eCsrForcedDeauthSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07008516 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008517 }
8518 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008519 case eWNI_SME_DEAUTH_IND:
8520 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC\n"));
8521 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
8522 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
8523 if( HAL_STATUS_SUCCESS( status ) )
8524 {
8525 // If we are in neighbor preauth done state then on receiving
8526 // disassoc or deauth we dont roam instead we just disassoc
8527 // from current ap and then go to disconnected state
8528 // This happens for CCX and 11r FT connections ONLY.
8529#ifdef WLAN_FEATURE_VOWIFI_11R
8530 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8531 {
8532 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8533 }
8534#endif
8535#ifdef FEATURE_WLAN_CCX
8536 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
8537 {
8538 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8539 }
8540#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008541#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308542 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008543 {
8544 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
8545 }
8546#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008547 pSession = CSR_GET_SESSION( pMac, sessionId );
8548
Jeff Johnson32d95a32012-09-10 13:15:23 -07008549 if(!pSession)
8550 {
8551 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8552 return;
8553 }
8554
Jeff Johnson295189b2012-06-20 16:38:30 -07008555 if ( csrIsConnStateInfra( pMac, sessionId ) )
8556 {
8557 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8558 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008559#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8560 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
8561#endif
8562 csrRoamLinkDown(pMac, sessionId);
8563 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07008564 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
8565 {
8566
8567 pRoamInfo = &roamInfo;
8568
8569 pRoamInfo->statusCode = pDeauthInd->statusCode;
8570 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8571
8572 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
8573
8574 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDeauthInd->peerMacAddr, sizeof(tSirMacAddr));
8575 palCopyMemory(pMac->hHdd, &pRoamInfo->bssid, pDeauthInd->bssId, sizeof(tCsrBssid));
8576
8577 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
8578 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008579 }
8580 break;
8581
8582 case eWNI_SME_SWITCH_CHL_REQ: // in case of STA, the SWITCH_CHANNEL originates from its AP
8583 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME\n"));
8584 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
8585 //Update with the new channel id.
8586 //The channel id is hidden in the statusCode.
8587 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
8588 if( HAL_STATUS_SUCCESS( status ) )
8589 {
8590 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008591 if(!pSession)
8592 {
8593 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8594 return;
8595 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008596 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
8597 if(pSession->pConnectBssDesc)
8598 {
8599 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
8600 }
8601 }
8602 break;
8603
8604 case eWNI_SME_DEAUTH_RSP:
8605 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008606 {
8607 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
8608 sessionId = pDeauthRsp->sessionId;
8609 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
8610 {
8611 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008612 if(!pSession)
8613 {
8614 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8615 return;
8616 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008617 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
8618 {
8619 pRoamInfo = &roamInfo;
8620 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8621 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDeauthRsp->peerMacAddr, sizeof(tSirMacAddr));
8622 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
8623 pRoamInfo->statusCode = pDeauthRsp->statusCode;
8624 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
8625 }
8626 }
8627 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008628 break;
8629
8630 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07008631 /* session id is invalid here so cant use it to access the array curSubstate as index */
8632 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME \n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008633 {
8634 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
8635 sessionId = pDisassocRsp->sessionId;
8636 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
8637 {
8638 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008639 if(!pSession)
8640 {
8641 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8642 return;
8643 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008644 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
8645 {
8646 pRoamInfo = &roamInfo;
8647 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8648 palCopyMemory(pMac->hHdd, pRoamInfo->peerMac, pDisassocRsp->peerMacAddr, sizeof(tSirMacAddr));
8649 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
8650 pRoamInfo->statusCode = pDisassocRsp->statusCode;
8651 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
8652 }
8653 }
8654 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008655 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008656 case eWNI_SME_MIC_FAILURE_IND:
8657 {
8658 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
8659 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
8660 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Jeff Johnson295189b2012-06-20 16:38:30 -07008661#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8662 {
8663 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008664 if(!pSession)
8665 {
8666 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8667 return;
8668 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008669 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
8670 palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type));
8671 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
8672 secEvent.encryptionModeMulticast =
8673 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8674 secEvent.encryptionModeUnicast =
8675 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8676 secEvent.authMode =
8677 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8678 palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 );
8679 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
8680 }
8681#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008682 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
8683 if( HAL_STATUS_SUCCESS( status ) )
8684 {
8685 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
8686 roamInfo.u.pMICFailureInfo = &pMicInd->info;
8687 pRoamInfo = &roamInfo;
8688 if(pMicInd->info.multicast)
8689 {
8690 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
8691 }
8692 else
8693 {
8694 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
8695 }
8696 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
8697 }
8698 }
8699 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008700 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
8701 {
8702 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
8703 tCsrRoamInfo roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008704 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME\n"));
8705
8706 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
8707 if( HAL_STATUS_SUCCESS( status ) )
8708 {
8709 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
8710 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
8711 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
8712 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
8713 }
8714 }
8715 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008716
Jeff Johnson295189b2012-06-20 16:38:30 -07008717 case eWNI_SME_WM_STATUS_CHANGE_NTF:
8718 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
8719 switch( pStatusChangeMsg->statusChangeCode )
8720 {
8721 case eSIR_SME_IBSS_ACTIVE:
8722 sessionId = csrFindIbssSession( pMac );
8723 if( CSR_SESSION_ID_INVALID != sessionId )
8724 {
8725 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008726 if(!pSession)
8727 {
8728 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8729 return;
8730 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008731 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
8732 if(pSession->pConnectBssDesc)
8733 {
8734 palCopyMemory(pMac->hHdd, &roamInfo.bssid, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
8735 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
8736 pRoamInfo = &roamInfo;
8737 }
8738 else
8739 {
8740 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty\n");
8741 }
8742 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
8743 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
8744 }
8745 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008746 case eSIR_SME_IBSS_INACTIVE:
8747 sessionId = csrFindIbssSession( pMac );
8748 if( CSR_SESSION_ID_INVALID != sessionId )
8749 {
8750 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008751 if(!pSession)
8752 {
8753 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8754 return;
8755 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008756 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
8757 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
8758 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
8759 }
8760 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008761 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
8762 sessionId = csrFindIbssSession( pMac );
8763 if( CSR_SESSION_ID_INVALID != sessionId )
8764 {
8765 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008766 if(!pSession)
8767 {
8768 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8769 return;
8770 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008771 // update the connection state information
8772 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008773#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8774 {
8775 vos_log_ibss_pkt_type *pIbssLog;
8776 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07008777 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8778 if(pIbssLog)
8779 {
8780 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
8781 if(pNewBss)
8782 {
8783 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pNewBss->bssId, 6);
8784 if(pNewBss->ssId.length)
8785 {
8786 palCopyMemory(pMac->hHdd, pIbssLog->ssid, pNewBss->ssId.ssId, pNewBss->ssId.length);
8787 }
8788 pIbssLog->operatingChannel = pNewBss->channelNumber;
8789 }
8790 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
8791 {
8792 //***U8 is not enough for beacon interval
8793 pIbssLog->beaconInterval = (v_U8_t)bi;
8794 }
8795 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
8796 }
8797 }
8798#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008799 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
8800 csrRoamIssueSetContextReq( pMac, sessionId, pSession->connectedProfile.EncryptionType,
8801 pSession->pConnectBssDesc,
8802 &Broadcastaddr,
8803 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
8804 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
8805 roamStatus = eCSR_ROAM_IBSS_IND;
8806 palCopyMemory(pMac->hHdd, &roamInfo.bssid, &pNewBss->bssId, sizeof(tCsrBssid));
8807 pRoamInfo = &roamInfo;
8808 //This BSSID is th ereal BSSID, let's save it
8809 if(pSession->pConnectBssDesc)
8810 {
8811 palCopyMemory(pMac->hHdd, pSession->pConnectBssDesc->bssId, &pNewBss->bssId, sizeof(tCsrBssid));
8812 }
8813 // Stop the join IBSS timer in case of join, for
8814 // genuine merge do nothing
8815 if(pSession->ibss_join_pending)
8816 {
8817 pSession->ibss_join_pending = FALSE;
8818 csrRoamStopIbssJoinTimer(pMac, sessionId);
8819 result = eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS;
8820 }
8821 }
8822 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE\n");
8823 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008824 // detection by LIM that the capabilities of the associated AP have changed.
8825 case eSIR_SME_AP_CAPS_CHANGED:
8826 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
8827 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED\n");
8828 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
8829 if( HAL_STATUS_SUCCESS( status ) )
8830 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08008831 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
8832 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
8833 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
8834 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
8835 )
8836 {
8837 csrScanForCapabilityChange( pMac, pApNewCaps );
8838 result = eCSR_ROAM_RESULT_CAP_CHANGED;
8839 roamStatus = eCSR_ROAM_GEN_INFO;
8840 }
8841 else
8842 {
8843 smsLog(pMac, LOGW,
8844 "Skipping csrScanForCapabilityChange as "
8845 "CSR is in state %d and sub-state %d\n",
8846 pMac->roam.curState[sessionId],
8847 pMac->roam.curSubState[sessionId]);
8848 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008849 }
8850 break;
8851
8852 default:
8853 roamStatus = eCSR_ROAM_FAILED;
8854 result = eCSR_ROAM_RESULT_NONE;
8855 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008856 } // end switch on statusChangeCode
8857 if(eCSR_ROAM_RESULT_NONE != result)
8858 {
8859 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
8860 }
8861 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008862 case eWNI_SME_IBSS_NEW_PEER_IND:
8863 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07008864#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8865 {
8866 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07008867 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8868 if(pIbssLog)
8869 {
8870 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
8871 palCopyMemory(pMac->hHdd, pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
8872 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
8873 }
8874 }
8875#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008876 sessionId = csrFindIbssSession( pMac );
8877 if( CSR_SESSION_ID_INVALID != sessionId )
8878 {
8879 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008880
8881 if(!pSession)
8882 {
8883 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8884 return;
8885 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008886 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
8887 if(pSession->pConnectBssDesc)
8888 {
8889 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
8890 palCopyMemory(pMac->hHdd, &roamInfo.bssid, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
8891 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
8892 {
8893 status = palAllocateMemory(pMac->hHdd, (void **)&roamInfo.pbFrames,
8894 (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd)));
8895 if(HAL_STATUS_SUCCESS(status))
8896 {
8897 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
8898 palCopyMemory(pMac->hHdd, roamInfo.pbFrames, ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
8899 roamInfo.nBeaconLength);
8900 }
8901 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
8902 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8903 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
8904 status = palAllocateMemory(pMac->hHdd, (void **)&roamInfo.pBssDesc,
8905 pSession->pConnectBssDesc->length);
8906 if(HAL_STATUS_SUCCESS(status))
8907 {
8908 palCopyMemory(pMac->hHdd, roamInfo.pBssDesc, pSession->pConnectBssDesc,
8909 pSession->pConnectBssDesc->length);
8910 }
8911 if(HAL_STATUS_SUCCESS(status))
8912 {
8913 pRoamInfo = &roamInfo;
8914 }
8915 else
8916 {
8917 if(roamInfo.pbFrames)
8918 {
8919 palFreeMemory(pMac->hHdd, roamInfo.pbFrames);
8920 }
8921 if(roamInfo.pBssDesc)
8922 {
8923 palFreeMemory(pMac->hHdd, roamInfo.pBssDesc);
8924 }
8925 }
8926 }
8927 else
8928 {
8929 pRoamInfo = &roamInfo;
8930 }
8931 csrRoamIssueSetContextReq( pMac, sessionId, pSession->connectedProfile.EncryptionType,
8932 pSession->pConnectBssDesc,
8933 &(pIbssPeerInd->peerAddr),
8934 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
8935 }
8936 else
8937 {
8938 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty\n");
8939 }
8940 //send up the sec type for the new peer
8941 if (pRoamInfo)
8942 {
8943 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
8944 }
8945 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
8946 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
8947 if(pRoamInfo)
8948 {
8949 if(roamInfo.pbFrames)
8950 {
8951 palFreeMemory(pMac->hHdd, roamInfo.pbFrames);
8952 }
8953 if(roamInfo.pBssDesc)
8954 {
8955 palFreeMemory(pMac->hHdd, roamInfo.pBssDesc);
8956 }
8957 }
8958 }
8959 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008960 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
8961 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
8962 sessionId = csrFindIbssSession( pMac );
8963 if( CSR_SESSION_ID_INVALID != sessionId )
8964 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008965#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8966 {
8967 vos_log_ibss_pkt_type *pIbssLog;
8968
8969 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8970 if(pIbssLog)
8971 {
8972 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
8973 if(pIbssPeerInd)
8974 {
8975 palCopyMemory(pMac->hHdd, pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
8976 }
8977 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
8978 }
8979 }
8980#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008981 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM\n");
8982 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
8983 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8984 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
8985 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pIbssPeerInd->peerAddr, sizeof(tCsrBssid));
8986 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
8987 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
8988 }
8989 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008990 case eWNI_SME_SETCONTEXT_RSP:
8991 {
8992 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
8993 tListElem *pEntry;
8994 tSmeCmd *pCommand;
8995
8996 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
8997 if ( pEntry )
8998 {
8999 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9000 if ( eSmeCommandSetKey == pCommand->command )
9001 {
9002 sessionId = pCommand->sessionId;
9003 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009004
9005 if(!pSession)
9006 {
9007 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9008 return;
9009 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009010
9011#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9012 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
9013 {
9014 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
9015 palZeroMemory(pMac->hHdd, &setKeyEvent, sizeof(vos_event_wlan_security_payload_type));
9016 if( pRsp->peerMacAddr[0] & 0x01 )
9017 {
9018 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
9019 }
9020 else
9021 {
9022 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
9023 }
9024 setKeyEvent.encryptionModeMulticast =
9025 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9026 setKeyEvent.encryptionModeUnicast =
9027 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9028 palCopyMemory( pMac->hHdd, setKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
9029 setKeyEvent.authMode =
9030 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9031 if( eSIR_SUCCESS != pRsp->statusCode )
9032 {
9033 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9034 }
9035 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9036 }
9037#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
9038 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
9039 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009040 csrRoamStopWaitForKeyTimer( pMac );
9041
Jeff Johnson295189b2012-06-20 16:38:30 -07009042 //We are done with authentication, whethere succeed or not
9043 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009044 //We do it here because this linkup function is not called after association
9045 //when a key needs to be set.
9046 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
9047 {
9048 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9049 }
9050 }
Jeff Johnson43971f52012-07-17 12:26:56 -07009051 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009052 {
9053 palCopyMemory( pMac, &roamInfo.peerMac, &pRsp->peerMacAddr, sizeof(tCsrBssid) );
Jeff Johnsone7245742012-09-05 17:12:55 -07009054 //Make sure we install the GTK before indicating to HDD as authenticated
9055 //This is to prevent broadcast packets go out after PTK and before GTK.
9056 if( palEqualMemory( pMac->hHdd, &Broadcastaddr, pRsp->peerMacAddr,
9057 sizeof(tSirMacAddr) ) )
9058 {
Yathish9f22e662012-12-10 14:21:35 -08009059#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
9060 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
9061 {
9062 tpSirSetActiveModeSetBncFilterReq pMsg;
9063 palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tSirSetActiveModeSetBncFilterReq));
9064 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
9065 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
9066 pMsg->seesionId = sessionId;
9067 status = palSendMBMessage(pMac->hHdd, pMsg );
9068 }
9069#endif
9070 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -07009071 }
9072 else
9073 {
9074 result = eCSR_ROAM_RESULT_NONE;
9075 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009076 pRoamInfo = &roamInfo;
9077 }
9078 else
9079 {
9080 result = eCSR_ROAM_RESULT_FAILURE;
9081 smsLog( pMac, LOGE, "CSR: Roam Completion setkey command failed(%d) PeerMac %02X-%02X-%02X-%02X-%02X-%02X...\n",
9082 pRsp->statusCode, pRsp->peerMacAddr[0], pRsp->peerMacAddr[1], pRsp->peerMacAddr[2],
9083 pRsp->peerMacAddr[3], pRsp->peerMacAddr[4], pRsp->peerMacAddr[5] );
9084 }
9085 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9086 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -07009087 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
9088 // can go ahead and initiate the TSPEC if any are pending
9089 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009090#ifdef FEATURE_WLAN_CCX
9091 //Send Adjacent AP repot to new AP.
9092 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
9093 pSession->isPrevApInfoValid &&
9094 pSession->connectedProfile.isCCXAssoc)
9095 {
9096#ifdef WLAN_FEATURE_VOWIFI
9097 csrCcxSendAdjacentApRepMsg(pMac, pSession);
9098#endif
9099 pSession->isPrevApInfoValid = FALSE;
9100 }
9101#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009102 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9103 {
9104 csrReleaseCommandSetKey( pMac, pCommand );
9105 }
9106 }
9107 else
9108 {
9109 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ...\n" );
9110 }
9111 }
9112 else
9113 {
9114 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ...\n" );
9115 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009116 smeProcessPendingQueue( pMac );
9117 }
9118 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009119 case eWNI_SME_REMOVEKEY_RSP:
9120 {
9121 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
9122 tListElem *pEntry;
9123 tSmeCmd *pCommand;
9124
9125 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9126 if ( pEntry )
9127 {
9128 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9129 if ( eSmeCommandRemoveKey == pCommand->command )
9130 {
9131 sessionId = pCommand->sessionId;
9132 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009133
9134 if(!pSession)
9135 {
9136 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9137 return;
9138 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009139#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9140 {
9141 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
9142 palZeroMemory(pMac->hHdd, &removeKeyEvent, sizeof(vos_event_wlan_security_payload_type));
9143 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
9144 removeKeyEvent.encryptionModeMulticast =
9145 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9146 removeKeyEvent.encryptionModeUnicast =
9147 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9148 palCopyMemory( pMac->hHdd, removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6 );
9149 removeKeyEvent.authMode =
9150 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9151 if( eSIR_SUCCESS != pRsp->statusCode )
9152 {
9153 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9154 }
9155 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9156 }
9157#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -07009158 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009159 {
9160 palCopyMemory( pMac, &roamInfo.peerMac, &pRsp->peerMacAddr, sizeof(tCsrBssid) );
9161 result = eCSR_ROAM_RESULT_NONE;
9162 pRoamInfo = &roamInfo;
9163 }
9164 else
9165 {
9166 result = eCSR_ROAM_RESULT_FAILURE;
9167 }
9168 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9169 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
9170 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9171 {
9172 csrReleaseCommandRemoveKey( pMac, pCommand );
9173 }
9174 }
9175 else
9176 {
9177 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ...\n" );
9178 }
9179 }
9180 else
9181 {
9182 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ...\n" );
9183 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009184 smeProcessPendingQueue( pMac );
9185 }
9186 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009187 case eWNI_SME_GET_STATISTICS_RSP:
Mohit Khanna23863762012-09-11 17:40:09 -07009188 smsLog( pMac, LOG2, FL("Stats rsp from PE\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009189 csrRoamStatsRspProcessor( pMac, pSirMsg );
9190 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009191 case eWNI_SME_GET_RSSI_REQ:
Mohit Khanna23863762012-09-11 17:40:09 -07009192 smsLog( pMac, LOG2, FL("GetRssiReq from self\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009193 csrUpdateRssi( pMac, pSirMsg );
9194 break;
9195
Jeff Johnson295189b2012-06-20 16:38:30 -07009196#ifdef WLAN_FEATURE_VOWIFI_11R
9197 case eWNI_SME_FT_PRE_AUTH_RSP:
9198 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
9199 break;
9200#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009201 case eWNI_SME_MAX_ASSOC_EXCEEDED:
9202 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
9203 smsLog( pMac, LOG1, FL("send indication that max assoc have been reached and the new peer cannot be accepted\n"));
9204 sessionId = pSmeMaxAssocInd->sessionId;
9205 roamInfo.sessionId = sessionId;
9206 palCopyMemory(pMac->hHdd, &roamInfo.peerMac, pSmeMaxAssocInd->peerMac, sizeof(tCsrBssid));
9207 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9208 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
9209 break;
9210
9211 case eWNI_SME_BTAMP_LOG_LINK_IND:
9212 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread\n"));
9213 btampEstablishLogLinkHdlr( pSirMsg );
9214 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07009215 case eWNI_SME_RSSI_IND:
9216 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread\n"));
9217 csrRoamRssiIndHdlr( pMac, pSirMsg );
9218 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009219
9220 default:
9221 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009222 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -07009223}
9224
Jeff Johnson295189b2012-06-20 16:38:30 -07009225void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
9226 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
9227{
9228 if(pSession)
9229 {
9230 if(pSession->bRefAssocStartCnt)
9231 {
9232 pSession->bRefAssocStartCnt--;
9233 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
9234 //Need to call association_completion because there is an assoc_start pending.
9235 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
9236 eCSR_ROAM_ASSOCIATION_COMPLETION,
9237 eCSR_ROAM_RESULT_FAILURE);
9238 }
9239 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
9240 }
9241 else
9242 {
9243 smsLog(pMac, LOGW, FL(" pSession is NULL"));
9244 }
9245}
9246
9247
9248eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
9249{
9250 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009251 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
9252 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
9253 {
9254 status = csrScanRequestLostLink1( pMac, sessionId );
9255 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009256 return(status);
9257}
9258
Jeff Johnson295189b2012-06-20 16:38:30 -07009259//return a boolean to indicate whether roaming completed or continue.
9260tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
9261 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
9262{
9263 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
9264 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
9265 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
9266 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009267 if(!pSession)
9268 {
9269 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9270 return eANI_BOOLEAN_FALSE;
9271 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009272 //Check whether time is up
9273 if(pSession->fCancelRoaming || fForce ||
9274 ((curTime - pSession->roamingStartTime) > roamTime) ||
9275 eCsrReassocRoaming == pSession->roamingReason ||
9276 eCsrDynamicRoaming == pSession->roamingReason)
9277 {
9278 smsLog(pMac, LOGW, FL(" indicates roaming completion\n"));
9279 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
9280 {
9281 //roaming is cancelled, tell HDD to indicate disconnect
9282 //Because LIM overload deauth_ind for both deauth frame and missed beacon
9283 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
9284 //to be eSIR_BEACON_MISSED
9285 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
9286 {
9287 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
9288 }
9289 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
9290 {
9291 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
9292 }
9293 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
9294 {
9295 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
9296 }
9297 else
9298 {
9299 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
9300 }
9301 }
9302 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
9303 pSession->roamingReason = eCsrNotRoaming;
9304 }
9305 else
9306 {
9307 pSession->roamResult = roamResult;
9308 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
9309 {
9310 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
9311 pSession->roamingReason = eCsrNotRoaming;
9312 }
9313 else
9314 {
9315 fCompleted = eANI_BOOLEAN_FALSE;
9316 }
9317 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009318 return(fCompleted);
9319}
9320
Jeff Johnson295189b2012-06-20 16:38:30 -07009321void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
9322{
9323 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009324
9325 if(!pSession)
9326 {
9327 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9328 return;
9329 }
9330
Jeff Johnson295189b2012-06-20 16:38:30 -07009331 if(CSR_IS_ROAMING(pSession))
9332 {
9333 smsLog(pMac, LOGW, " Cancelling roaming\n");
9334 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
9335 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
9336 {
9337 //No need to do anything in here because the handler takes care of it
9338 }
9339 else
9340 {
9341 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
9342 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
9343 //Roaming is stopped after here
9344 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
9345 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
9346 csrScanAbortMacScan(pMac);
9347 csrRoamStopRoamingTimer(pMac, sessionId);
9348 }
9349 }
9350}
9351
Jeff Johnson295189b2012-06-20 16:38:30 -07009352void csrRoamRoamingTimerHandler(void *pv)
9353{
9354 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9355 tpAniSirGlobal pMac = pInfo->pMac;
9356 tANI_U32 sessionId = pInfo->sessionId;
9357 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009358
9359 if(!pSession)
9360 {
9361 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9362 return;
9363 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009364
9365 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
9366 {
9367 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
9368 {
9369 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
9370 pSession->roamingReason = eCsrNotRoaming;
9371 }
9372 }
9373}
9374
Jeff Johnson295189b2012-06-20 16:38:30 -07009375eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
9376{
9377 eHalStatus status;
9378 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009379
9380 if(!pSession)
9381 {
9382 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9383 return eHAL_STATUS_FAILURE;
9384 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009385
9386 smsLog(pMac, LOG1, " csrScanStartRoamingTimer \n ");
9387 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
9388 status = palTimerStart(pMac->hHdd, pSession->hTimerRoaming, interval, eANI_BOOLEAN_FALSE);
9389
9390 return (status);
9391}
9392
Jeff Johnson295189b2012-06-20 16:38:30 -07009393eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
9394{
9395 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerRoaming));
9396}
9397
Jeff Johnson295189b2012-06-20 16:38:30 -07009398void csrRoamWaitForKeyTimeOutHandler(void *pv)
9399{
9400 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9401 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009402 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
9403
9404 smsLog(pMac, LOGW, "WaitForKey timer expired in state=%d sub-state=%d\n",
9405 pMac->roam.neighborRoamInfo.neighborRoamState,
9406 pMac->roam.curSubState[pInfo->sessionId]);
9407
Jeff Johnson295189b2012-06-20 16:38:30 -07009408 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
9409 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009410#ifdef FEATURE_WLAN_LFR
9411 if (csrNeighborRoamIsHandoffInProgress(pMac))
9412 {
9413 /*
9414 * Enable heartbeat timer when hand-off is in progress
9415 * and Key Wait timer expired.
9416 */
9417 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
9418 " (nHBCount=%d)\n",
9419 pMac->roam.configParam.HeartbeatThresh24);
9420 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
9421 pMac->roam.configParam.HeartbeatThresh24,
9422 NULL, eANI_BOOLEAN_FALSE);
9423 }
9424#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009425 smsLog(pMac, LOGW, " SME pre-auth state timeout. \n ");
9426 //Change the substate so command queue is unblocked.
9427 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, pInfo->sessionId);
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009428 if (pSession)
9429 {
9430 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
9431 {
9432 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9433 smeProcessPendingQueue(pMac);
9434 }
9435 else
9436 {
9437 smsLog(pMac, LOGW, "%s: could not post link up\n",
9438 __func__);
9439 }
9440 }
9441 else
9442 {
9443 smsLog(pMac, LOGW, "%s: session not found\n", __func__);
9444 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009445 }
9446
9447}
9448
Jeff Johnson295189b2012-06-20 16:38:30 -07009449eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
9450{
9451 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009452#ifdef FEATURE_WLAN_LFR
9453 if (csrNeighborRoamIsHandoffInProgress(pMac))
9454 {
9455 /* Disable heartbeat timer when hand-off is in progress */
9456 smsLog(pMac, LOG2, "%s: disabling HB timer in state=%d sub-state=%d\n",
9457 __func__,
9458 pMac->roam.neighborRoamInfo.neighborRoamState,
9459 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
9460 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
9461 }
9462#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009463 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer \n ");
9464 status = palTimerStart(pMac->hHdd, pMac->roam.hTimerWaitForKey, interval, eANI_BOOLEAN_FALSE);
9465
9466 return (status);
9467}
9468
Jeff Johnson295189b2012-06-20 16:38:30 -07009469eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
9470{
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009471 smsLog(pMac, LOG2, "WaitForKey timer stopped in state=%d sub-state=%d\n",
9472 pMac->roam.neighborRoamInfo.neighborRoamState,
9473 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
9474#ifdef FEATURE_WLAN_LFR
9475 if (csrNeighborRoamIsHandoffInProgress(pMac))
9476 {
9477 /*
9478 * Enable heartbeat timer when hand-off is in progress
9479 * and Key Wait timer got stopped for some reason
9480 */
9481 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
9482 " (nHBCount=%d)\n",
9483 pMac->roam.configParam.HeartbeatThresh24);
9484 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
9485 pMac->roam.configParam.HeartbeatThresh24,
9486 NULL, eANI_BOOLEAN_FALSE);
9487 }
9488#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009489 return (palTimerStop(pMac->hHdd, pMac->roam.hTimerWaitForKey));
9490}
9491
Jeff Johnson295189b2012-06-20 16:38:30 -07009492void csrRoamIbssJoinTimerHandler(void *pv)
9493{
9494 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
9495 tpAniSirGlobal pMac = pInfo->pMac;
9496 eCsrRoamDisconnectReason reason = eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE;
9497 tANI_U32 sessionId = pInfo->sessionId;
9498 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009499
9500 if(!pSession)
9501 {
9502 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9503 return;
9504 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009505
9506 pSession->ibss_join_pending = FALSE;
9507 // JEZ100225: As of main/latest "tip", we are no longer doing this. Check on this.
9508 //csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
9509 // Send an IBSS stop request to PE
9510 csrRoamDisconnectInternal(pMac, sessionId, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07009511}
Jeff Johnson295189b2012-06-20 16:38:30 -07009512eHalStatus csrRoamStartIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
9513{
9514 eHalStatus status;
9515 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009516
9517 if(!pSession)
9518 {
9519 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9520 return eHAL_STATUS_FAILURE;
9521 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009522
9523 smsLog(pMac, LOG1, " csrRoamStartIbssJoinTimer \n ");
9524 pSession->ibssJoinTimerInfo.sessionId = (tANI_U8)sessionId;
9525 status = palTimerStart(pMac->hHdd, pSession->hTimerIbssJoining, interval, eANI_BOOLEAN_FALSE);
9526
9527 return (status);
9528}
Jeff Johnson295189b2012-06-20 16:38:30 -07009529eHalStatus csrRoamStopIbssJoinTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
9530{
9531 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerIbssJoining));
9532}
Jeff Johnson295189b2012-06-20 16:38:30 -07009533void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
9534 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
9535{
9536 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
9537 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009538 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9539 /* To silence the KW tool Null chaeck is added */
9540 if(!pSession)
9541 {
9542 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9543 return;
9544 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009545
9546 if(pCommand)
9547 {
9548 roamId = pCommand->u.roamCmd.roamId;
9549#if defined(VOSS_ENABLED)
9550 VOS_ASSERT( sessionId == pCommand->sessionId );
9551#endif
9552 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009553 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
9554 {
9555 //if success, force roaming completion
9556 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
9557 }
9558 else
9559 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009560 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009561 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d\n"), roamResult);
9562 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
9563 }
9564}
9565
Jeff Johnson295189b2012-06-20 16:38:30 -07009566eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
9567{
9568 eHalStatus status = eHAL_STATUS_SUCCESS;
9569 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
9570 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
9571 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
9572 tCsrRoamInfo *pRoamInfo = NULL;
9573 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009574 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -07009575 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009576 /* To silence the KW tool Null chaeck is added */
9577 if(!pSession)
9578 {
9579 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9580 return eHAL_STATUS_FAILURE;
9581 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009582 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009583 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07009584 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
9585 if ( eWNI_SME_DISASSOC_IND == type )
9586 {
9587 result = eCSR_ROAM_RESULT_DISASSOC_IND;
9588 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
9589 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -07009590 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07009591 }
9592 else if ( eWNI_SME_DEAUTH_IND == type )
9593 {
9594 result = eCSR_ROAM_RESULT_DEAUTH_IND;
9595 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
9596 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -08009597 /* Convert into proper reason code */
9598 pSession->joinFailStatusCode.reasonCode =
9599 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
9600 eSIR_MAC_DISASSOC_LEAVING_BSS_REASON : pDeauthIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07009601 }
9602 else
9603 {
9604 smsLog(pMac, LOGW, FL("gets an unknown type (%d)\n"), type);
9605 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -07009606 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07009607 }
9608
9609 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -07009610 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07009611 {
9612 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
9613 }
9614
9615 if ( eWNI_SME_DISASSOC_IND == type )
9616 {
9617 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
9618 }
9619 else if ( eWNI_SME_DEAUTH_IND == type )
9620 {
9621 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
9622 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009623 if(!HAL_STATUS_SUCCESS(status))
9624 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009625 //If fail to send confirmation to PE, not to trigger roaming
9626 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009627 }
9628
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009629 //prepare to tell HDD to disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -07009630 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9631 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
9632 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07009633 if( eWNI_SME_DISASSOC_IND == type)
9634 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009635 //staMacAddr
9636 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDisassocIndMsg->peerMacAddr, sizeof(tSirMacAddr));
9637 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
9638 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009639 else if( eWNI_SME_DEAUTH_IND == type )
9640 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009641 //staMacAddr
9642 palCopyMemory(pMac->hHdd, roamInfo.peerMac, pDeauthIndMsg->peerMacAddr, sizeof(tSirMacAddr));
9643 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
9644 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009645 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)\n"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009646
9647 /* See if we can possibly roam. If so, start the roaming process and notify HDD
9648 that we are roaming. But if we cannot possibly roam, or if we are unable to
9649 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -07009650 if(fToRoam)
9651 {
9652 //Only remove the connected BSS in infrastructure mode
9653 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
9654 //Not to do anying for lostlink with WDS
9655 if( pMac->roam.configParam.nRoamingTime )
9656 {
9657 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
9658 ( eWNI_SME_DEAUTH_IND == type ) ?
9659 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
9660 {
9661 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9662 //For IBSS, we need to give some more info to HDD
9663 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
9664 {
9665 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9666 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
9667 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
9668 }
9669 else
9670 {
9671 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
9672 }
Jeff Johnsone7245742012-09-05 17:12:55 -07009673 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009674 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
9675 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
9676 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
9677 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
9678 }
9679 else
9680 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009681 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07009682 fToRoam = eANI_BOOLEAN_FALSE;
9683 }
9684 }
9685 else
9686 {
9687 //We are told not to roam, indicate lostlink
9688 fToRoam = eANI_BOOLEAN_FALSE;
9689 }
9690 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009691 if(!fToRoam)
9692 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -07009693 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009694 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009695 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009696 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
9697 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
9698 * csrRoamCheckForLinkStatusChange API.
9699 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009700 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
9701 }
9702
9703 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -07009704 Still enable idle scan for polling in case concurrent sessions are running */
9705 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
9706 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -08009707 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07009708 }
9709 }
9710
9711 return (status);
9712}
9713
Jeff Johnson295189b2012-06-20 16:38:30 -07009714eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
9715{
9716 eHalStatus status = eHAL_STATUS_SUCCESS;
9717 tListElem *pEntry = NULL;
9718 tSmeCmd *pCommand = NULL;
9719 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009720
9721 if(!pSession)
9722 {
9723 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9724 return eHAL_STATUS_FAILURE;
9725 }
9726
Jeff Johnson295189b2012-06-20 16:38:30 -07009727 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009728 //Only remove the connected BSS in infrastructure mode
9729 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
9730 if(pMac->roam.configParam.nRoamingTime)
9731 {
9732 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
9733 {
9734 //before starting the lost link logic release the roam command for handoff
9735 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
9736 if(pEntry)
9737 {
9738 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
9739 }
9740 if(pCommand)
9741 {
9742 if (( eSmeCommandRoam == pCommand->command ) &&
9743 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
9744 {
9745 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9746 {
9747 csrReleaseCommandRoam( pMac, pCommand );
9748 }
9749 }
9750 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009751 smsLog( pMac, LOGW, "Lost link roaming started ...\n");
9752 }
9753 }
9754 else
9755 {
9756 //We are told not to roam, indicate lostlink
9757 status = eHAL_STATUS_FAILURE;
9758 }
9759
9760 return (status);
9761}
Jeff Johnson295189b2012-06-20 16:38:30 -07009762void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
9763{
9764 tListElem *pEntry;
9765 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07009766 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9767 if ( pEntry )
9768 {
9769 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9770 if ( eSmeCommandWmStatusChange == pCommand->command )
9771 {
9772 // Nothing to process in a Lost Link completion.... It just kicks off a
9773 // roaming sequence.
9774 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9775 {
9776 csrReleaseCommandWmStatusChange( pMac, pCommand );
9777 }
9778 else
9779 {
9780 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command\n");
9781 }
9782
9783 }
9784 else
9785 {
9786 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ...\n" );
9787 }
9788 }
9789 else
9790 {
9791 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ...\n" );
9792 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009793 smeProcessPendingQueue( pMac );
9794}
9795
Jeff Johnson295189b2012-06-20 16:38:30 -07009796void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
9797{
9798 eHalStatus status = eHAL_STATUS_FAILURE;
9799 tSirSmeRsp *pSirSmeMsg;
9800 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009801
9802 if(!pSession)
9803 {
9804 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
9805 return;
9806 }
9807
Jeff Johnson295189b2012-06-20 16:38:30 -07009808 switch ( pCommand->u.wmStatusChangeCmd.Type )
9809 {
9810 case eCsrDisassociated:
9811 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
9812 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
9813 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009814 case eCsrDeauthenticated:
9815 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
9816 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
9817 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009818 default:
9819 smsLog(pMac, LOGW, FL("gets an unknown command %d\n"), pCommand->u.wmStatusChangeCmd.Type);
9820 break;
9821 }
9822 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
9823 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
9824 {
9825 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
9826 {
9827 //This is not good
9828 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command\n"));
9829 }
9830 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009831 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
9832 // command here since there is nothing else to do.
9833 csrRoamWmStatusChangeComplete( pMac );
9834}
9835
Jeff Johnson295189b2012-06-20 16:38:30 -07009836//This function returns band and mode information.
9837//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
9838//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -07009839static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
9840 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -07009841{
Jeff Johnson295189b2012-06-20 16:38:30 -07009842 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
9843 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
9844 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07009845 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07009846
Jeff Johnson295189b2012-06-20 16:38:30 -07009847 //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 -07009848 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
9849 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
9850 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
9851 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009852 {
9853 switch( pMac->roam.configParam.uCfgDot11Mode )
9854 {
9855 case eCSR_CFG_DOT11_MODE_11A:
9856 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
9857 eBand = eCSR_BAND_5G;
9858 break;
9859 case eCSR_CFG_DOT11_MODE_11B:
9860 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
9861 eBand = eCSR_BAND_24;
9862 break;
9863 case eCSR_CFG_DOT11_MODE_11G:
9864 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
9865 eBand = eCSR_BAND_24;
9866 break;
9867 case eCSR_CFG_DOT11_MODE_11N:
9868 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
9869 eBand = eCSR_BAND_24;
9870 break;
9871 //case eCSR_CFG_DOT11_MODE_BEST:
9872 // cfgDot11Mode = eCSR_CFG_DOT11_MODE_BEST;
9873 // eBand = eCSR_BAND_24;
9874 // break;
9875 default:
9876 // Global dot11 Mode setting is 11a/b/g.
9877 // use the channel number to determine the Mode setting.
9878 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
9879 {
9880 eBand = pMac->roam.configParam.eBand;
9881 if(eCSR_BAND_24 == eBand)
9882 {
9883 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
9884 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
9885 }
9886 else
9887 {
9888 //prefer 5GHz
9889 eBand = eCSR_BAND_5G;
9890 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
9891 }
9892 }
9893 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
9894 {
9895 // channel is a 2.4GHz channel. Set mode to 11g.
9896 //
9897 // !!LAC - WiFi tests require IBSS networks to start in 11b mode without any change to the
9898 // default parameter settings on the adapter. We use ACU to start an IBSS through creation
9899 // of a startIBSS profile. this startIBSS profile has Auto MACProtocol and the
9900 // adapter property setting for dot11Mode is also AUTO. So in this case, let's start
9901 // the IBSS network in 11b mode instead of 11g mode.
9902 //
9903 // so this is for Auto=profile->MacProtocol && Auto=Global.dot11Mode && profile->channel is < 14,
9904 // then start the IBSS in b mode.
9905 //
9906 // Note: we used to have this start as an 11g IBSS for best performance... now to specify that
9907 // the user will have to set the do11Mode in the property page to 11g to force it.
9908 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
9909 eBand = eCSR_BAND_24;
9910 }
9911 else
9912 {
9913 // else, it's a 5.0GHz channel. Set mode to 11a.
9914 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
9915 eBand = eCSR_BAND_5G;
9916 }
9917 break;
9918 }//switch
9919 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
9920 else
9921 {
9922 //dot11 mode is set, lets pick the band
9923 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
9924 {
9925 // channel is Auto also.
9926 eBand = pMac->roam.configParam.eBand;
9927 if(eCSR_BAND_ALL == eBand)
9928 {
9929 //prefer 5GHz
9930 eBand = eCSR_BAND_5G;
9931 }
9932 }
9933 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
9934 {
9935 eBand = eCSR_BAND_24;
9936 }
9937 else
9938 {
9939 eBand = eCSR_BAND_5G;
9940 }
9941 }
9942 if(pBand)
9943 {
9944 *pBand = eBand;
9945 }
9946
9947 if (operationChn == 14){
9948 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode \n"));
9949 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
9950 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -07009951
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -08009952 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
9953 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 -07009954 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -07009955#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -07009956 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -07009957#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -07009958 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
9959 {
9960 //We cannot do 11n here
9961 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
9962 {
9963 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
9964 }
9965 else
9966 {
9967 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
9968 }
9969 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009970 return( cfgDot11Mode );
9971}
9972
Jeff Johnson295189b2012-06-20 16:38:30 -07009973eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
9974{
9975 eHalStatus status;
9976 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009977
9978 if(!pSession)
9979 {
9980 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9981 return eHAL_STATUS_FAILURE;
9982 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009983
9984#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9985 {
9986 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07009987 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9988 if(pIbssLog)
9989 {
9990 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
9991 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9992 }
9993 }
9994#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009995 pSession->ibss_join_pending = FALSE;
9996 csrRoamStopIbssJoinTimer(pMac, sessionId );
9997 // Set the roaming substate to 'stop Bss request'...
9998 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
9999
10000 // attempt to stop the Bss (reason code is ignored...)
10001 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080010002 if(!HAL_STATUS_SUCCESS(status))
10003 {
10004 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
10005 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010006 return (status);
10007}
10008
Jeff Johnson295189b2012-06-20 16:38:30 -070010009//pNumChan is a caller allocated space with the sizeof pChannels
10010eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
10011{
10012
10013 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
10014 (tANI_U8 *)pChannels,
10015 pNumChan));
10016}
10017
Kiran4a17ebe2013-01-31 10:43:43 -080010018tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
10019{
10020 tANI_U32 cfgLength = 0;
10021 tANI_U16 cfgId = 0;
10022 tPowerdBm maxTxPwr = 0;
10023 tANI_U8 *pCountryInfo = NULL;
10024 eHalStatus status;
10025 tANI_U8 count = 0;
10026 tANI_U8 firstChannel;
10027 tANI_U8 maxChannels;
10028
10029 if (CSR_IS_CHANNEL_5GHZ(channel))
10030 {
10031 cfgId = WNI_CFG_MAX_TX_POWER_5;
10032 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
10033 }
10034 else if (CSR_IS_CHANNEL_24GHZ(channel))
10035 {
10036 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
10037 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
10038 }
10039 else
10040 return maxTxPwr;
10041
10042 status = palAllocateMemory(pMac->hHdd, (void **)&pCountryInfo, cfgLength);
10043 if (status != eHAL_STATUS_SUCCESS)
10044 {
10045 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
10046 FL("%s: palAllocateMemory() failed, status = %d"),
10047 __FUNCTION__, status);
10048 goto error;
10049 }
10050 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
10051 if (status != eHAL_STATUS_SUCCESS)
10052 {
10053 goto error;
10054 }
10055 /* Identify the channel and maxtxpower */
10056 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
10057 {
10058 firstChannel = pCountryInfo[count++];
10059 maxChannels = pCountryInfo[count++];
10060 maxTxPwr = pCountryInfo[count++];
10061
10062 if ((channel >= firstChannel) &&
10063 (channel < (firstChannel + maxChannels)))
10064 {
10065 break;
10066 }
10067 }
10068
10069error:
10070 if (NULL != pCountryInfo)
10071 palFreeMemory(pMac->hHdd, pCountryInfo);
10072
10073 return maxTxPwr;
10074}
10075
10076
Jeff Johnson295189b2012-06-20 16:38:30 -070010077tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
10078{
10079 tANI_BOOLEAN fValid = FALSE;
10080 tANI_U32 idxValidChannels;
10081 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10082
10083 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
10084 {
10085 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
10086 {
10087 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
10088 {
10089 fValid = TRUE;
10090 break;
10091 }
10092 }
10093 }
10094 pMac->roam.numValidChannels = len;
10095 return fValid;
10096}
10097
Jeff Johnson295189b2012-06-20 16:38:30 -070010098tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
10099{
10100 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
10101 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010102 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
10103 {
10104 if(channel == pMac->scan.base40MHzChannels.channelList[i])
10105 {
10106 fValid = eANI_BOOLEAN_TRUE;
10107 break;
10108 }
10109 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010110 return (fValid);
10111}
10112
Jeff Johnson295189b2012-06-20 16:38:30 -070010113//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070010114 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070010115{
Jeff Johnsone7245742012-09-05 17:12:55 -070010116 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010117 tANI_U8 centerChn;
10118 tANI_U32 ChannelBondingMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010119 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
10120 {
10121 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
10122 }
10123 else
10124 {
10125 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
10126 }
10127 //Figure what the other side's CB mode
10128 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
10129 {
10130 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
10131 {
10132 if(pIes->HTInfo.present)
10133 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010134 /* This is called during INFRA STA/CLIENT and should use the merged value of
10135 * supported channel width and recommended tx width as per standard
10136 */
10137 smsLog(pMac, LOG1, "scws %u rtws %u sco %u\n",
10138 pIes->HTCaps.supportedChannelWidthSet,
10139 pIes->HTInfo.recommendedTxWidthSet,
10140 pIes->HTInfo.secondaryChannelOffset);
10141
10142 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
10143 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070010144 else
Jeff Johnsone7245742012-09-05 17:12:55 -070010145 eRet = PHY_SINGLE_CHANNEL_CENTERED;
10146 switch (eRet) {
10147 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
10148 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
10149 break;
10150 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
10151 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
10152 break;
10153 case PHY_SINGLE_CHANNEL_CENTERED:
10154 default:
10155 centerChn = primaryChn;
10156 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010157 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010158 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070010159 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010160 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode\n", centerChn);
10161 //eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010162 }
10163 }
10164 }
10165 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010166 return eRet;
10167}
Jeff Johnson295189b2012-06-20 16:38:30 -070010168tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
10169{
10170 tANI_BOOLEAN fFound = FALSE;
10171 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010172 for( idx = 0; idx < pCipherList->numEntries; idx++ )
10173 {
10174 if( pCipherList->encryptionType[idx] == encryptionType )
10175 {
10176 fFound = TRUE;
10177 break;
10178 }
10179 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010180 return fFound;
10181}
Jeff Johnson295189b2012-06-20 16:38:30 -070010182tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
10183{
10184 tANI_BOOLEAN fFound = FALSE;
10185 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010186 for( idx = 0; idx < pAuthList->numEntries; idx++ )
10187 {
10188 if( pAuthList->authType[idx] == authType )
10189 {
10190 fFound = TRUE;
10191 break;
10192 }
10193 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010194 return fFound;
10195}
Jeff Johnson295189b2012-06-20 16:38:30 -070010196tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
10197{
10198 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
10199 tCsrScanResultFilter *pScanFilter = NULL;
10200 eHalStatus status = eHAL_STATUS_SUCCESS;
10201
10202 if(pProfile1 && pProfile2)
10203 {
10204 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
10205 if(HAL_STATUS_SUCCESS(status))
10206 {
10207 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
10208 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
10209 if(HAL_STATUS_SUCCESS(status))
10210 {
10211 fCheck = eANI_BOOLEAN_FALSE;
10212 do
10213 {
10214 tANI_U32 i;
10215 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
10216 {
10217 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
10218 pScanFilter->SSIDs.SSIDList[i].SSID.length,
10219 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
10220 if ( fCheck ) break;
10221 }
10222 if(!fCheck)
10223 {
10224 break;
10225 }
10226 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
10227 || pProfile2->BSSType != pProfile1->BSSType
10228 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
10229 )
10230 {
10231 fCheck = eANI_BOOLEAN_FALSE;
10232 break;
10233 }
10234#ifdef WLAN_FEATURE_VOWIFI_11R
10235 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
10236 {
10237 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
10238 {
10239 fCheck = eANI_BOOLEAN_FALSE;
10240 break;
10241 }
10242 }
10243#endif
10244 //Match found
10245 fCheck = eANI_BOOLEAN_TRUE;
10246 }while(0);
10247 csrFreeScanFilter(pMac, pScanFilter);
10248 }
10249 palFreeMemory(pMac->hHdd, pScanFilter);
10250 }
10251 }
10252
10253 return (fCheck);
10254}
10255
Jeff Johnson295189b2012-06-20 16:38:30 -070010256tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
10257{
10258 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
10259 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070010260 do
10261 {
10262 //Only check for static WEP
10263 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
10264 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
10265 {
10266 fCheck = eANI_BOOLEAN_TRUE;
10267 break;
10268 }
10269 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
10270 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
10271 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
10272 {
10273 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
10274 if(!palEqualMemory(pMac->hHdd, &pConnProfile->Keys.KeyMaterial[i],
10275 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
10276 {
10277 break;
10278 }
10279 }
10280 if( i == CSR_MAX_NUM_KEY)
10281 {
10282 fCheck = eANI_BOOLEAN_TRUE;
10283 }
10284 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010285 return (fCheck);
10286}
10287
Jeff Johnson295189b2012-06-20 16:38:30 -070010288//IBSS
10289
Jeff Johnson295189b2012-06-20 16:38:30 -070010290tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
10291{
10292 tANI_U8 channel = 0;
10293 tANI_U32 idx;
10294 tANI_U32 idxValidChannels;
10295 tANI_BOOLEAN fFound = FALSE;
10296 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10297
10298 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
10299 {
10300 channel = pMac->roam.configParam.AdHocChannel5G;
10301 if(!csrRoamIsChannelValid(pMac, channel))
10302 {
10303 channel = 0;
10304 }
10305 }
10306 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
10307 {
10308 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
10309 {
10310 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
10311 {
10312 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
10313 {
10314 fFound = TRUE;
10315 channel = csrStartIbssChannels50[ idx ];
10316 }
10317 }
10318 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010319 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
10320 if (!fFound)
10321 {
10322 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
10323 {
10324 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idx ]) ) // the max channel# in 11g is 14
10325 {
10326 channel = csrStartIbssChannels50[ idx ];
10327 break;
10328 }
10329 }
10330 }
10331 }//if
10332
10333 return( channel );
10334}
10335
Jeff Johnson295189b2012-06-20 16:38:30 -070010336tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
10337{
10338 tANI_U8 channel = 1;
10339 tANI_U32 idx;
10340 tANI_U32 idxValidChannels;
10341 tANI_BOOLEAN fFound = FALSE;
10342 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10343
10344 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
10345 {
10346 channel = pMac->roam.configParam.AdHocChannel24;
10347 if(!csrRoamIsChannelValid(pMac, channel))
10348 {
10349 channel = 0;
10350 }
10351 }
10352
10353 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
10354 {
10355 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
10356 {
10357 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
10358 {
10359 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
10360 {
10361 fFound = TRUE;
10362 channel = csrStartIbssChannels24[ idx ];
10363 }
10364 }
10365 }
10366 }
10367
10368 return( channel );
10369}
10370
Jeff Johnson295189b2012-06-20 16:38:30 -070010371static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10372 tCsrRoamStartBssParams *pParam )
10373{
10374 eCsrCfgDot11Mode cfgDot11Mode;
10375 eCsrBand eBand;
10376 tANI_U8 channel = 0;
10377 tSirNwType nwType;
10378 tANI_U8 operationChannel = 0;
10379
10380 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
10381 {
10382 operationChannel = pProfile->ChannelInfo.ChannelList[0];
10383 }
10384
Jeff Johnson295189b2012-06-20 16:38:30 -070010385 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070010386
10387#ifdef WLAN_FEATURE_P2P
10388 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
10389 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
10390 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
10391 )
10392 {
10393 /* This should never happen */
10394 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
10395 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B\n"),
10396 pProfile->csrPersona);
10397 VOS_ASSERT(0);
10398 }
10399#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010400 switch( cfgDot11Mode )
10401 {
10402 case eCSR_CFG_DOT11_MODE_11G:
10403 nwType = eSIR_11G_NW_TYPE;
10404 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010405 case eCSR_CFG_DOT11_MODE_11B:
10406 nwType = eSIR_11B_NW_TYPE;
10407 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010408 case eCSR_CFG_DOT11_MODE_11A:
10409 nwType = eSIR_11A_NW_TYPE;
10410 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010411 default:
10412 case eCSR_CFG_DOT11_MODE_11N:
10413 case eCSR_CFG_DOT11_MODE_TAURUS:
10414 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
10415 if(eCSR_BAND_24 == eBand)
10416 {
10417 nwType = eSIR_11G_NW_TYPE;
10418 }
10419 else
10420 {
10421 nwType = eSIR_11A_NW_TYPE;
10422 }
10423 break;
10424 }
10425
10426 pParam->extendedRateSet.numRates = 0;
10427
10428 switch ( nwType )
10429 {
10430 default:
10431 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)\n"), nwType);
10432 case eSIR_11A_NW_TYPE:
10433
10434 pParam->operationalRateSet.numRates = 8;
10435
10436 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
10437 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
10438 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
10439 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
10440 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
10441 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
10442 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
10443 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
10444
10445 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10446 {
10447 channel = csrRoamGetIbssStartChannelNumber50( pMac );
10448 if( 0 == channel &&
10449 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
10450 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
10451 )
10452 {
10453 //We could not find a 5G channel by auto pick, let's try 2.4G channels
10454 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
10455 nwType = eSIR_11B_NW_TYPE;
10456 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10457 pParam->operationalRateSet.numRates = 4;
10458 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10459 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10460 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10461 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
10462 }
10463 }
10464 else
10465 {
10466 channel = operationChannel;
10467 }
10468 break;
10469
10470 case eSIR_11B_NW_TYPE:
10471 pParam->operationalRateSet.numRates = 4;
10472 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10473 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10474 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10475 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070010476 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10477 {
10478 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10479 }
10480 else
10481 {
10482 channel = operationChannel;
10483 }
10484
10485 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010486 case eSIR_11G_NW_TYPE:
10487#ifdef WLAN_FEATURE_P2P
10488 /* For P2P Client and P2P GO, disable 11b rates */
10489 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
10490 (pProfile->csrPersona == VOS_P2P_GO_MODE)
10491 )
10492 {
10493 pParam->operationalRateSet.numRates = 8;
10494
10495 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
10496 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
10497 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
10498 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
10499 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
10500 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
10501 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
10502 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
10503 }
10504 else
10505#endif
10506 {
10507 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070010508 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
10509 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
10510 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
10511 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
10512
10513 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070010514 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
10515 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
10516 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
10517 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
10518 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
10519 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
10520 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
10521 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
10522 }
10523
10524 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
10525 {
10526 channel = csrRoamGetIbssStartChannelNumber24( pMac );
10527 }
10528 else
10529 {
10530 channel = operationChannel;
10531 }
10532
10533 break;
10534 }
10535 pParam->operationChn = channel;
10536 pParam->sirNwType = nwType;
10537}
10538
Jeff Johnson295189b2012-06-20 16:38:30 -070010539static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
10540 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
10541{
10542
10543 if( pParam )
10544 {
10545 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070010546 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010547 pParam->operationChn = pBssDesc->channelId;
10548 palCopyMemory( pMac->hHdd, &pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid) );
10549
10550 if( pIes )
10551 {
10552 if(pIes->SuppRates.present)
10553 {
10554 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
10555 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
10556 {
10557 smsLog(pMac, LOGE, FL("num_rates :%d is more than SIR_MAC_RATESET_EID_MAX, resetting to SIR_MAC_RATESET_EID_MAX\n"),
10558 pIes->SuppRates.num_rates);
10559 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
10560 }
10561 palCopyMemory(pMac->hHdd, pParam->operationalRateSet.rate, pIes->SuppRates.rates,
10562 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
10563 }
10564 if( pIes->SSID.present )
10565 {
10566 pParam->ssId.length = pIes->SSID.num_ssid;
10567 palCopyMemory(pMac->hHdd, pParam->ssId.ssId, pIes->SSID.ssid, pParam->ssId.length);
10568 }
10569 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070010570 }
10571 else
10572 {
10573 pParam->ssId.length = 0;
10574 pParam->operationalRateSet.numRates = 0;
10575 }
10576 }
10577}
10578
Jeff Johnson295189b2012-06-20 16:38:30 -070010579static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
10580{
10581 tANI_U8 MaxRate = 0;
10582 tANI_U32 i;
10583 tANI_U8 *pRate;
10584
10585 pRate = pSirRateSet->rate;
10586 for ( i = 0; i < pSirRateSet->numRates; i++ )
10587 {
10588 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
10589 }
10590
10591 // Save the max rate in the connected state information...
10592
10593 // modify LastRates variable as well
10594
10595 return;
10596}
10597
Jeff Johnson295189b2012-06-20 16:38:30 -070010598//this function finds a valid secondary channel for channel bonding with "channel".
10599//Param: channel -- primary channel, caller must validate it
10600// cbChoice -- CB directory
10601//Return: if 0, no secondary channel is found. Otherwise a valid secondary channel.
10602static tANI_U8 csrRoamGetSecondaryChannel(tpAniSirGlobal pMac, tANI_U8 channel, eCsrCBChoice cbChoice)
10603{
10604 tANI_U8 chnUp = 0, chnDown = 0, chnRet = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010605 switch (cbChoice)
10606 {
10607 case eCSR_CB_OFF:
10608 chnUp = 0;
10609 chnDown = 0;
10610 break;
10611 case eCSR_CB_DOWN:
10612 chnUp = 0;
10613 chnDown = channel - CSR_CB_CHANNEL_GAP;
10614 break;
10615 case eCSR_CB_UP:
10616 chnUp = channel + CSR_CB_CHANNEL_GAP;
10617 chnDown = 0;
10618 break;
10619 case eCSR_CB_AUTO:
10620 //consider every other value means auto
10621 default:
10622 chnUp = channel + CSR_CB_CHANNEL_GAP;
10623 chnDown = channel - CSR_CB_CHANNEL_GAP;
10624 break;
10625 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010626 //if CB_UP or auto, try channel up first
10627 if(chnUp && CSR_IS_SAME_BAND_CHANNELS(chnUp, channel) && csrRoamIsChannelValid(pMac, chnUp))
10628 {
10629 //found a valid up channel for channel bonding
10630 //check whether the center channel is valid
10631 if(csrRoamIsValid40MhzChannel(pMac, channel + CSR_CB_CENTER_CHANNEL_OFFSET))
10632 {
10633 chnRet = chnUp;
10634 }
10635 }
10636 if(chnRet == 0 && chnDown && CSR_IS_SAME_BAND_CHANNELS(chnDown, channel) && csrRoamIsChannelValid(pMac, chnDown))
10637 {
10638 //found a valid down channel for channel bonding
10639 if(csrRoamIsValid40MhzChannel(pMac, channel - CSR_CB_CENTER_CHANNEL_OFFSET))
10640 {
10641 chnRet = chnDown;
10642 }
10643 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010644 return chnRet;
10645}
10646
Jeff Johnson295189b2012-06-20 16:38:30 -070010647eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
10648 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
10649{
10650 eHalStatus status = eHAL_STATUS_SUCCESS;
10651 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010652 // Set the roaming substate to 'Start BSS attempt'...
10653 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010654#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10655 //Need to figure out whether we need to log WDS???
10656 if( CSR_IS_IBSS( pProfile ) )
10657 {
10658 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010659 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10660 if(pIbssLog)
10661 {
10662 if(pBssDesc)
10663 {
10664 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
10665 palCopyMemory(pMac->hHdd, pIbssLog->bssid, pBssDesc->bssId, 6);
10666 }
10667 else
10668 {
10669 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
10670 }
10671 palCopyMemory(pMac->hHdd, pIbssLog->ssid, pParam->ssId.ssId,
10672 pParam->ssId.length);
10673 if(pProfile->ChannelInfo.numOfChannels == 0)
10674 {
10675 pIbssLog->channelSetting = AUTO_PICK;
10676 }
10677 else
10678 {
10679 pIbssLog->channelSetting = SPECIFIED;
10680 }
10681 pIbssLog->operatingChannel = pParam->operationChn;
10682 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10683 }
10684 }
10685#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
10686 //Put RSN information in for Starting BSS
10687 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
10688 pParam->pRSNIE = pProfile->pRSNReqIE;
10689
Jeff Johnson295189b2012-06-20 16:38:30 -070010690 pParam->privacy = pProfile->privacy;
10691 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
10692 pParam->authType = pProfile->csr80211AuthType;
10693 pParam->beaconInterval = pProfile->beaconInterval;
10694 pParam->dtimPeriod = pProfile->dtimPeriod;
10695 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
10696 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
10697 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
10698 {
10699 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
10700 {
10701 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
10702 }
10703 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010704 pParam->protEnabled = pProfile->protEnabled;
10705 pParam->obssProtEnabled = pProfile->obssProtEnabled;
10706 pParam->ht_protection = pProfile->cfg_protection;
10707 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080010708
Jeff Johnson295189b2012-06-20 16:38:30 -070010709 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
10710 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070010711 pParam->bssPersona = pProfile->csrPersona;
10712 // When starting an IBSS, start on the channel from the Profile.
10713 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070010714 return (status);
10715}
10716
Jeff Johnson295189b2012-06-20 16:38:30 -070010717static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070010718 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070010719{
10720 tANI_U8 Channel, SecondChn;
Jeff Johnsone7245742012-09-05 17:12:55 -070010721 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010722 eCsrCBChoice cbChoice;
10723 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010724
10725 if(!pSession)
10726 {
10727 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10728 return;
10729 }
10730
Jeff Johnson295189b2012-06-20 16:38:30 -070010731 if( pBssDesc )
10732 {
10733 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
10734 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
10735 //The following code has to be do after that.
10736 //For WDS station, use selfMac as the self BSSID
10737 if( CSR_IS_WDS_STA( pProfile ) )
10738 {
10739 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, &pSession->selfMacAddr, sizeof(tCsrBssid));
10740 }
10741 }
10742 else
10743 {
10744 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070010745 //Use the first SSID
10746 if(pProfile->SSIDs.numOfSSIDs)
10747 {
10748 palCopyMemory(pMac->hHdd, &pSession->bssParams.ssId, pProfile->SSIDs.SSIDList, sizeof(tSirMacSSid));
10749 }
10750 //For WDS station, use selfMac as the self BSSID
10751 if( CSR_IS_WDS_STA( pProfile ) )
10752 {
10753 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, &pSession->selfMacAddr, sizeof(tCsrBssid));
10754 }
10755 //Use the first BSSID
10756 else if( pProfile->BSSIDs.numOfBSSIDs )
10757 {
10758 palCopyMemory(pMac->hHdd, &pSession->bssParams.bssid, pProfile->BSSIDs.bssid, sizeof(tCsrBssid));
10759 }
10760 else
10761 {
10762 palZeroMemory( pMac->hHdd, &pSession->bssParams.bssid, sizeof(tCsrBssid) );
10763 }
10764 }
10765 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070010766 //Set operating channel in pProfile which will be used
10767 //in csrRoamSetBssConfigCfg() to determine channel bonding
10768 //mode and will be configured in CFG later
10769 pProfile->operationChannel = Channel;
10770
10771 if(Channel == 0)
10772 {
10773 smsLog(pMac, LOGW, " CSR cannot find a channel to start IBSS\n");
10774 }
10775 else
10776 {
10777
10778 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Jeff Johnsone7245742012-09-05 17:12:55 -070010779 if (CSR_IS_INFRA_AP(pProfile))
10780 {
10781 if(CSR_IS_CHANNEL_24GHZ(Channel))
10782 {
10783 cbMode = pMac->roam.configParam.channelBondingMode24GHz;
10784 }
10785 else
10786 {
10787 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
10788 }
10789 smsLog(pMac, LOG1, "##softap cbMode %d\n", cbMode);
10790 pBssConfig->cbMode = cbMode;
10791 pSession->bssParams.cbMode = cbMode;
10792 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010793
10794 if( CSR_IS_START_IBSS( pProfile ) )
10795 {
10796 //TBH: channel bonding is not supported for Libra
10797 if( pProfile->ChannelInfo.ChannelList && eCSR_OPERATING_CHANNEL_AUTO != pProfile->ChannelInfo.ChannelList[0] )
10798 {
10799 Channel = pProfile->ChannelInfo.ChannelList[0];
10800 cbChoice = pProfile->CBMode;
10801 }
10802 else {
10803 cbChoice = pMac->roam.configParam.cbChoice;
10804 }
10805 pSession->bssParams.operationChn = Channel;
10806 //make sure channel is valid
10807 if(!csrRoamIsChannelValid(pMac, Channel))
10808 {
10809 //set Channel to 0 to let lim know this is invalid
10810 //We still send this request down to lim even though we know the channel is wrong because
10811 //lim will response with error and hdd's eWNI_SME_START_BSS_RSP handler will roam other profile (if any)
10812 Channel = 0;
10813 pSession->bssParams.operationChn = 0;
10814 }
10815 else {
10816 tANI_U32 ChannelBondingMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010817 if(CSR_IS_CHANNEL_24GHZ(Channel))
10818 {
10819 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
10820 }
10821 else
10822 {
10823 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
10824 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010825 //now we have a valid channel
10826 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
10827 {
10828 //let's pick a secondard channel
10829 SecondChn = csrRoamGetSecondaryChannel(pMac, Channel, cbChoice);
Jeff Johnson295189b2012-06-20 16:38:30 -070010830 if(SecondChn > Channel)
10831 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010832 cbMode = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010833 }
10834 else if(SecondChn && SecondChn < Channel)
10835 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010836 cbMode = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010837 }
10838 else
10839 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010840 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010841 }
10842 pSession->bssParams.cbMode = cbMode;
10843 }
10844 else
10845 {
Jeff Johnsone7245742012-09-05 17:12:55 -070010846 pSession->bssParams.cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010847 }
10848 }
10849 }
10850 }
10851}
10852
Jeff Johnson295189b2012-06-20 16:38:30 -070010853static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
10854 tANI_BOOLEAN *pfSameIbss )
10855{
10856 eHalStatus status = eHAL_STATUS_SUCCESS;
10857 tANI_BOOLEAN fSameIbss = FALSE;
10858
10859 if ( csrIsConnStateIbss( pMac, sessionId ) )
10860 {
10861 // Check if any profile parameter has changed ? If any profile parameter
10862 // has changed then stop old BSS and start a new one with new parameters
10863 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
10864 {
10865 fSameIbss = TRUE;
10866 }
10867 else
10868 {
10869 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
10870 }
10871 }
10872 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
10873 {
10874 // Disassociate from the connected Infrastructure network...
10875 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
10876 }
10877 else
10878 {
10879 tBssConfigParam *pBssConfig;
10880
10881 status = palAllocateMemory(pMac->hHdd, (void **)&pBssConfig, sizeof(tBssConfigParam));
10882 if(HAL_STATUS_SUCCESS(status))
10883 {
10884 palZeroMemory(pMac->hHdd, pBssConfig, sizeof(tBssConfigParam));
10885 // there is no Bss description before we start an IBSS so we need to adopt
10886 // all Bss configuration parameters from the Profile.
10887 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
10888 if(HAL_STATUS_SUCCESS(status))
10889 {
10890 //save dotMode
10891 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
10892 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070010893 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070010894 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
10895 }
10896
10897 palFreeMemory(pMac->hHdd, pBssConfig);
10898 }//Allocate memory
10899 }
10900
10901 if(pfSameIbss)
10902 {
10903 *pfSameIbss = fSameIbss;
10904 }
10905 return( status );
10906}
10907
Jeff Johnson295189b2012-06-20 16:38:30 -070010908static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
10909 tSirSmeNewBssInfo *pNewBss )
10910{
10911 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010912
10913 if(!pSession)
10914 {
10915 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10916 return;
10917 }
10918
Jeff Johnson295189b2012-06-20 16:38:30 -070010919 if( pNewBss )
10920 {
10921 // Set the operating channel.
10922 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
10923 // move the BSSId from the BSS description into the connected state information.
10924 palCopyMemory( pMac->hHdd, &pSession->connectedProfile.bssid,
10925 &(pNewBss->bssId), sizeof( tCsrBssid ) );
10926 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010927 return;
10928}
10929
Jeff Johnson295189b2012-06-20 16:38:30 -070010930#ifdef FEATURE_WLAN_WAPI
10931eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
10932 tANI_U32 numItems )
10933{
10934 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
10935 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070010936 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
10937 {
10938 smsLog(pMac, LOGE, FL(" Invalid session ID\n"));
10939 return status;
10940 }
10941 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d\n", numItems);
10942 pSession = CSR_GET_SESSION( pMac, sessionId );
10943 if(numItems <= CSR_MAX_BKID_ALLOWED)
10944 {
10945 status = eHAL_STATUS_SUCCESS;
10946 //numItems may be 0 to clear the cache
10947 pSession->NumBkidCache = (tANI_U16)numItems;
10948 if(numItems && pBKIDCache)
10949 {
10950 status = palCopyMemory( pMac->hHdd, pSession->BkidCacheInfo, pBKIDCache,
10951 sizeof(tBkidCacheInfo) * numItems );
10952 }
10953 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010954 return (status);
10955}
Jeff Johnson295189b2012-06-20 16:38:30 -070010956eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
10957 tBkidCacheInfo *pBkidCache)
10958{
10959 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
10960 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070010961 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
10962 {
10963 smsLog(pMac, LOGE, FL(" Invalid session ID\n"));
10964 return status;
10965 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010966 pSession = CSR_GET_SESSION( pMac, sessionId );
10967 if(pNum && pBkidCache)
10968 {
10969 if(pSession->NumBkidCache == 0)
10970 {
10971 *pNum = 0;
10972 status = eHAL_STATUS_SUCCESS;
10973 }
10974 else if(*pNum >= pSession->NumBkidCache)
10975 {
10976 if(pSession->NumBkidCache > CSR_MAX_PMKID_ALLOWED)
10977 {
10978 smsLog(pMac, LOGE, FL("NumPmkidCache :%d is more than CSR_MAX_PMKID_ALLOWED, resetting to CSR_MAX_PMKID_ALLOWED\n"),
10979 pSession->NumBkidCache);
10980 pSession->NumBkidCache = CSR_MAX_PMKID_ALLOWED;
10981 }
10982 palCopyMemory( pMac->hHdd, pBkidCache, pSession->BkidCacheInfo,
10983 sizeof(tBkidCacheInfo) * pSession->NumBkidCache );
10984 *pNum = pSession->NumBkidCache;
10985 status = eHAL_STATUS_SUCCESS;
10986 }
10987 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010988 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010989}
Jeff Johnson295189b2012-06-20 16:38:30 -070010990tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
10991{
10992 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070010993}
10994#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070010995eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
10996 tPmkidCacheInfo *pPMKIDCache, tANI_U32 numItems )
10997{
10998 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
10999 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011000
11001 if(!pSession)
11002 {
11003 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11004 return eHAL_STATUS_FAILURE;
11005 }
11006
Jeff Johnson295189b2012-06-20 16:38:30 -070011007 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d\n", numItems);
11008 if(numItems <= CSR_MAX_PMKID_ALLOWED)
11009 {
11010#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11011 {
11012 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
11013 palZeroMemory(pMac->hHdd, &secEvent, sizeof(vos_event_wlan_security_payload_type));
11014 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
11015 secEvent.encryptionModeMulticast =
11016 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
11017 secEvent.encryptionModeUnicast =
11018 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
11019 palCopyMemory( pMac->hHdd, secEvent.bssid, pSession->connectedProfile.bssid, 6 );
11020 secEvent.authMode =
11021 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
11022 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
11023 }
11024#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011025 status = eHAL_STATUS_SUCCESS;
11026 //numItems may be 0 to clear the cache
11027 pSession->NumPmkidCache = (tANI_U16)numItems;
11028 if(numItems && pPMKIDCache)
11029 {
11030 status = palCopyMemory( pMac->hHdd, pSession->PmkidCacheInfo, pPMKIDCache,
11031 sizeof(tPmkidCacheInfo) * numItems );
11032 }
11033 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011034 return (status);
11035}
11036
Jeff Johnson295189b2012-06-20 16:38:30 -070011037tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11038{
11039 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
11040}
11041
Jeff Johnson295189b2012-06-20 16:38:30 -070011042eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
11043{
11044 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11045 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011046
11047 if(!pSession)
11048 {
11049 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11050 return eHAL_STATUS_FAILURE;
11051 }
11052
Jeff Johnson295189b2012-06-20 16:38:30 -070011053 if(pNum && pPmkidCache)
11054 {
11055 if(pSession->NumPmkidCache == 0)
11056 {
11057 *pNum = 0;
11058 status = eHAL_STATUS_SUCCESS;
11059 }
11060 else if(*pNum >= pSession->NumPmkidCache)
11061 {
11062 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
11063 {
11064 smsLog(pMac, LOGE, FL("NumPmkidCache :%d is more than CSR_MAX_PMKID_ALLOWED, resetting to CSR_MAX_PMKID_ALLOWED\n"),
11065 pSession->NumPmkidCache);
11066 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
11067 }
11068 palCopyMemory( pMac->hHdd, pPmkidCache, pSession->PmkidCacheInfo,
11069 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache );
11070 *pNum = pSession->NumPmkidCache;
11071 status = eHAL_STATUS_SUCCESS;
11072 }
11073 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011074 return (status);
11075}
11076
Jeff Johnson295189b2012-06-20 16:38:30 -070011077eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11078{
11079 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11080 tANI_U32 len;
11081 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011082
11083 if(!pSession)
11084 {
11085 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11086 return eHAL_STATUS_FAILURE;
11087 }
11088
Jeff Johnson295189b2012-06-20 16:38:30 -070011089 if(pLen)
11090 {
11091 len = *pLen;
11092 *pLen = pSession->nWpaRsnReqIeLength;
11093 if(pBuf)
11094 {
11095 if(len >= pSession->nWpaRsnReqIeLength)
11096 {
11097 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWpaRsnReqIE, pSession->nWpaRsnReqIeLength);
11098 }
11099 }
11100 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011101 return (status);
11102}
11103
Jeff Johnson295189b2012-06-20 16:38:30 -070011104eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11105{
11106 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11107 tANI_U32 len;
11108 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011109
11110 if(!pSession)
11111 {
11112 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11113 return eHAL_STATUS_FAILURE;
11114 }
11115
Jeff Johnson295189b2012-06-20 16:38:30 -070011116 if(pLen)
11117 {
11118 len = *pLen;
11119 *pLen = pSession->nWpaRsnRspIeLength;
11120 if(pBuf)
11121 {
11122 if(len >= pSession->nWpaRsnRspIeLength)
11123 {
11124 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWpaRsnRspIE, pSession->nWpaRsnRspIeLength);
11125 }
11126 }
11127 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011128 return (status);
11129}
Jeff Johnson295189b2012-06-20 16:38:30 -070011130#ifdef FEATURE_WLAN_WAPI
11131eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11132{
11133 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11134 tANI_U32 len;
11135 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011136
11137 if(!pSession)
11138 {
11139 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11140 return eHAL_STATUS_FAILURE;
11141 }
11142
Jeff Johnson295189b2012-06-20 16:38:30 -070011143 if(pLen)
11144 {
11145 len = *pLen;
11146 *pLen = pSession->nWapiReqIeLength;
11147 if(pBuf)
11148 {
11149 if(len >= pSession->nWapiReqIeLength)
11150 {
11151 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWapiReqIE, pSession->nWapiReqIeLength);
11152 }
11153 }
11154 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011155 return (status);
11156}
Jeff Johnson295189b2012-06-20 16:38:30 -070011157eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11158{
11159 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11160 tANI_U32 len;
11161 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011162
11163 if(!pSession)
11164 {
11165 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11166 return eHAL_STATUS_FAILURE;
11167 }
11168
Jeff Johnson295189b2012-06-20 16:38:30 -070011169 if(pLen)
11170 {
11171 len = *pLen;
11172 *pLen = pSession->nWapiRspIeLength;
11173 if(pBuf)
11174 {
11175 if(len >= pSession->nWapiRspIeLength)
11176 {
11177 status = palCopyMemory(pMac->hHdd, pBuf, pSession->pWapiRspIE, pSession->nWapiRspIeLength);
11178 }
11179 }
11180 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011181 return (status);
11182}
11183#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011184eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
11185{
11186 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
11187 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011188
11189 if(!pSession)
11190 {
11191 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11192 return (retStatus);
11193 }
11194
Jeff Johnson295189b2012-06-20 16:38:30 -070011195 if(CSR_IS_ROAMING(pSession))
11196 {
11197 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
11198 pSession->fRoaming = eANI_BOOLEAN_FALSE;
11199 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011200 return (retStatus);
11201}
11202
Jeff Johnson295189b2012-06-20 16:38:30 -070011203//This function remove the connected BSS from te cached scan result
11204eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
11205 tCsrRoamConnectedProfile *pConnProfile)
11206{
11207 eHalStatus status = eHAL_STATUS_FAILURE;
11208 tCsrScanResultFilter *pScanFilter = NULL;
11209 tListElem *pEntry;
11210 tCsrScanResult *pResult;
11211 tDot11fBeaconIEs *pIes;
11212 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070011213 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
11214 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
11215 {
11216 do
11217 {
11218 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
11219 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter, sizeof(tCsrScanResultFilter));
11220 if(!HAL_STATUS_SUCCESS(status)) break;
11221 palZeroMemory(pMac->hHdd, pScanFilter, sizeof(tCsrScanResultFilter));
11222 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->BSSIDs.bssid, sizeof(tCsrBssid));
11223 if(!HAL_STATUS_SUCCESS(status)) break;
11224 palCopyMemory(pMac->hHdd, pScanFilter->BSSIDs.bssid, &pConnProfile->bssid, sizeof(tCsrBssid));
11225 pScanFilter->BSSIDs.numOfBSSIDs = 1;
11226 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
11227 {
11228 status = palAllocateMemory(pMac->hHdd, (void **)&pScanFilter->SSIDs.SSIDList, sizeof(tCsrSSIDInfo));
11229 if(!HAL_STATUS_SUCCESS(status)) break;
11230 palCopyMemory(pMac->hHdd, &pScanFilter->SSIDs.SSIDList[0].SSID, &pConnProfile->SSID, sizeof(tSirMacSSid));
11231 }
11232 pScanFilter->authType.numEntries = 1;
11233 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
11234 pScanFilter->BSSType = pConnProfile->BSSType;
11235 pScanFilter->EncryptionType.numEntries = 1;
11236 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
11237 pScanFilter->mcEncryptionType.numEntries = 1;
11238 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
11239 //We ignore the channel for now, BSSID should be enough
11240 pScanFilter->ChannelInfo.numOfChannels = 0;
11241 //Also ignore the following fields
11242 pScanFilter->uapsd_mask = 0;
11243 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
11244 pScanFilter->countryCode[0] = 0;
11245 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011246 csrLLLock(&pMac->scan.scanResultList);
11247 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
11248 while( pEntry )
11249 {
11250 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
11251 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
11252 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
11253 pScanFilter, NULL, NULL, NULL, &pIes);
11254 //Release the IEs allocated by csrMatchBSS is needed
11255 if( !pResult->Result.pvIes )
11256 {
11257 //need to free the IEs since it is allocated by csrMatchBSS
11258 palFreeMemory(pMac->hHdd, pIes);
11259 }
11260 if(fMatch)
11261 {
11262 //We found the one
11263 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
11264 {
11265 //Free the memory
11266 csrFreeScanResultEntry( pMac, pResult );
11267 }
11268 break;
11269 }
11270 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
11271 }//while
11272 csrLLUnlock(&pMac->scan.scanResultList);
11273 }while(0);
11274 if(pScanFilter)
11275 {
11276 csrFreeScanFilter(pMac, pScanFilter);
11277 palFreeMemory(pMac->hHdd, pScanFilter);
11278 }
11279 }
11280 return (status);
11281}
11282
Jeff Johnson295189b2012-06-20 16:38:30 -070011283//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070011284eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
11285{
11286 eHalStatus status = eHAL_STATUS_SUCCESS;
11287 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011288 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
11289 {
11290 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
11291 {
11292 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
11293 {
11294 //co-exist with IBSS or BT-AMP is not supported
11295 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d\n", sessionId );
11296 status = eHAL_STATUS_CSR_WRONG_STATE;
11297 break;
11298 }
11299 if( csrIsConnStateInfra( pMac, sessionId ) )
11300 {
11301 if( chnId &&
11302 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
11303 {
11304 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)\n",
11305 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
11306 status = eHAL_STATUS_CSR_WRONG_STATE;
11307 break;
11308 }
11309 }
11310 }
11311 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011312 return ( status );
11313}
11314
Jeff Johnson295189b2012-06-20 16:38:30 -070011315static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
11316{
11317 eHalStatus status = eHAL_STATUS_SUCCESS;
11318 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11319 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070011320
11321 if(!pSession)
11322 {
11323 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11324 return eHAL_STATUS_FAILURE;
11325 }
11326
Jeff Johnson295189b2012-06-20 16:38:30 -070011327 if ( csrIsConnStateIbss( pMac, sessionId ) )
11328 {
11329 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11330 }
11331 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11332 {
11333 // Disassociate from the connected Infrastructure network...
11334 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11335 }
11336 else
11337 {
11338#if defined(VOSS_ENABLED)
11339 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
11340 //Otherwise we need to add code to handle the
11341 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
11342 //send stop_bss to PE, before we can continue.
11343 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
11344#endif
11345 palZeroMemory(pMac->hHdd, &bssConfig, sizeof(tBssConfigParam));
11346 /* Assume HDD provide bssid in profile */
11347 palCopyMemory( pMac->hHdd, &pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0], sizeof(tCsrBssid) );
11348 // there is no Bss description before we start an WDS so we need
11349 // to adopt all Bss configuration parameters from the Profile.
11350 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
11351 if(HAL_STATUS_SUCCESS(status))
11352 {
11353 //Save profile for late use
11354 csrFreeRoamProfile( pMac, sessionId );
11355 if (HAL_STATUS_SUCCESS(palAllocateMemory(pMac->hHdd,
11356 (void **)&pSession->pCurRoamProfile,
11357 sizeof(tCsrRoamProfile))))
11358 {
11359 palZeroMemory(pMac->hHdd, pSession->pCurRoamProfile, sizeof(tCsrRoamProfile));
11360 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
11361 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011362 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070011363 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070011364 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
11365 }
11366 }
11367
11368 return( status );
11369}
11370
Jeff Johnson295189b2012-06-20 16:38:30 -070011371////////////////////Mail box
11372
Jeff Johnson295189b2012-06-20 16:38:30 -070011373//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
11374//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
11375static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
11376 tSirBssDescription *pBssDescription,
11377 tANI_U8 *pBuf, tANI_U8 uapsdMask)
11378{
11379 tCsrChannelSet channelGroup;
11380 tSirMacCapabilityInfo *pAP_capabilityInfo;
11381 tAniBool fTmp;
11382 tANI_BOOLEAN found = FALSE;
11383 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080011384 tANI_S8 pwrLimit = 0;
11385 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011386 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
11387 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
11388 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
11389 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070011390 // 802.11h
11391 //We can do this because it is in HOST CPU order for now.
11392 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080011393 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
11394 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
11395 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011396 fTmp = (tAniBool)pal_cpu_to_be32(1);
11397 }
11398 else
11399 fTmp = (tAniBool)0;
11400
11401 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
11402 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool) );
11403 pBuf += sizeof(tAniBool);
11404 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080011405 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070011406 // This is required for 11k test VoWiFi Ent: Test 2.
11407 // We need the power capabilities for Assoc Req.
11408 // This macro is provided by the halPhyCfg.h. We pick our
11409 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080011410 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
11411 if (0 != pwrLimit)
11412 {
11413 *pBuf++ = pwrLimit;
11414 }
11415 else
11416 {
11417 *pBuf++ = MAX_STA_PWR_CAP_DBM;
11418 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011419 size = sizeof(pMac->roam.validChannelList);
11420 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
11421 {
11422 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
11423 for ( i = 0; i < size; i++)
11424 {
11425 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
11426
11427 }
11428 }
11429 else
11430 {
11431 smsLog(pMac, LOGE, FL("can not find any valid channel\n"));
11432 *pBuf++ = 0; //tSirSupChnl->numChnl
11433 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011434 //Check whether it is ok to enter UAPSD
11435#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11436 if( btcIsReadyForUapsd(pMac) )
11437#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
11438 {
11439 *pBuf++ = uapsdMask;
11440 }
11441#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11442 else
11443 {
11444 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)\n"), uapsdMask);
11445 *pBuf++ = 0;
11446 }
11447#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
11448
Jeff Johnson295189b2012-06-20 16:38:30 -070011449 // move the entire BssDescription into the join request.
11450 palCopyMemory( pMac->hHdd, pBuf, pBssDescription,
11451 pBssDescription->length + sizeof( pBssDescription->length ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070011452 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
11453}
11454
Jeff Johnson295189b2012-06-20 16:38:30 -070011455/*
11456 * The communication between HDD and LIM is thru mailbox (MB).
11457 * Both sides will access the data structure "tSirSmeJoinReq".
11458 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
11459 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
11460 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
11461 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
11462 */
11463eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011464 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011465{
11466 eHalStatus status = eHAL_STATUS_SUCCESS;
11467 tSirSmeJoinReq *pMsg;
11468 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011469 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070011470 tANI_U16 msgLen, wTmp, ieLen;
11471 tSirMacRateSet OpRateSet;
11472 tSirMacRateSet ExRateSet;
11473 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11474 tANI_U32 dwTmp;
11475 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Jeff Johnson32d95a32012-09-10 13:15:23 -070011476
11477 if(!pSession)
11478 {
11479 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11480 return eHAL_STATUS_FAILURE;
11481 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011482 /* To satisfy klockworks */
11483 if (NULL == pBssDescription)
11484 {
11485 smsLog(pMac, LOGE, FL(" pBssDescription is NULL\n"));
11486 return eHAL_STATUS_FAILURE;
11487 }
11488
Jeff Johnson295189b2012-06-20 16:38:30 -070011489 do {
11490 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
11491 pSession->joinFailStatusCode.reasonCode = 0;
11492 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
11493 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
11494 // IE fields, but the length field in the bssDescription needs to be interpreted to
11495 // determine length of the IE fields.
11496 //
11497 // So, take the size of the JoinReq, subtract the size of the bssDescription and
11498 // add in the length from the bssDescription (then add the size of the 'length' field
11499 // itself because that is NOT included in the length field).
11500 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
11501 pBssDescription->length + sizeof( pBssDescription->length ) +
11502 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 -070011503 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
11504 if ( !HAL_STATUS_SUCCESS(status) ) break;
11505 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011506 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011507 pMsg->length = pal_cpu_to_be16(msgLen);
11508 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011509 // sessionId
11510 *pBuf = (tANI_U8)sessionId;
11511 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011512 // transactionId
11513 *pBuf = 0;
11514 *( pBuf + 1 ) = 0;
11515 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070011516 // ssId
11517 if( pIes->SSID.present && pIes->SSID.num_ssid )
11518 {
11519 // ssId len
11520 *pBuf = pIes->SSID.num_ssid;
11521 pBuf++;
11522 palCopyMemory( pMac->hHdd, pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid );
11523 pBuf += pIes->SSID.num_ssid;
11524 }
11525 else
11526 {
11527 *pBuf = 0;
11528 pBuf++;
11529 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011530 // selfMacAddr
11531 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
11532 pBuf += sizeof(tSirMacAddr);
11533 // bsstype
11534 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
11535 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
11536 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tSirBssType) );
11537 pBuf += sizeof(tSirBssType);
11538 // dot11mode
11539 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
11540 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011541 //Persona
11542 *pBuf = (tANI_U8)pProfile->csrPersona;
11543 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070011544 //CBMode
11545 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
11546 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070011547
11548 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070011549 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
11550
Jeff Johnson295189b2012-06-20 16:38:30 -070011551 // uapsdPerAcBitmask
11552 *pBuf = pProfile->uapsd_mask;
11553 pBuf++;
11554
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011555
11556
Jeff Johnson295189b2012-06-20 16:38:30 -070011557 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011558 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011559 {
11560 // OperationalRateSet
11561 if (OpRateSet.numRates) {
11562 *pBuf++ = OpRateSet.numRates;
11563 palCopyMemory(pMac->hHdd, pBuf, OpRateSet.rate, OpRateSet.numRates);
11564 pBuf += OpRateSet.numRates;
11565 } else *pBuf++ = 0;
11566 // ExtendedRateSet
11567 if (ExRateSet.numRates) {
11568 *pBuf++ = ExRateSet.numRates;
11569 palCopyMemory(pMac->hHdd, pBuf, ExRateSet.rate, ExRateSet.numRates);
11570 pBuf += ExRateSet.numRates;
11571 } else *pBuf++ = 0;
11572 }
11573 else
11574 {
11575 *pBuf++ = 0;
11576 *pBuf++ = 0;
11577 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011578 // rsnIE
11579 if ( csrIsProfileWpa( pProfile ) )
11580 {
11581 // Insert the Wpa IE into the join request
11582 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
11583 (tCsrWpaIe *)( wpaRsnIE ) );
11584 }
11585 else if( csrIsProfileRSN( pProfile ) )
11586 {
11587 // Insert the RSN IE into the join request
11588 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11589 (tCsrRSNIe *)( wpaRsnIE ) );
11590 }
11591#ifdef FEATURE_WLAN_WAPI
11592 else if( csrIsProfileWapi( pProfile ) )
11593 {
11594 // Insert the WAPI IE into the join request
11595 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
11596 (tCsrWapiIe *)( wpaRsnIE ) );
11597 }
11598#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011599 else
11600 {
11601 ieLen = 0;
11602 }
11603 //remember the IE for future use
11604 if( ieLen )
11605 {
11606 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
11607 {
11608 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);
11609 ieLen = DOT11F_IE_RSN_MAX_LEN;
11610 }
11611#ifdef FEATURE_WLAN_WAPI
11612 if( csrIsProfileWapi( pProfile ) )
11613 {
11614 //Check whether we need to allocate more memory
11615 if(ieLen > pSession->nWapiReqIeLength)
11616 {
11617 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
11618 {
11619 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
11620 }
11621 status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWapiReqIE, ieLen);
11622 if(!HAL_STATUS_SUCCESS(status)) break;
11623 }
11624 pSession->nWapiReqIeLength = ieLen;
11625 palCopyMemory(pMac->hHdd, pSession->pWapiReqIE, wpaRsnIE, ieLen);
11626 wTmp = pal_cpu_to_be16( ieLen );
11627 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11628 pBuf += sizeof(tANI_U16);
11629 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11630 pBuf += ieLen;
11631 }
11632 else//should be WPA/WPA2 otherwise
11633#endif /* FEATURE_WLAN_WAPI */
11634 {
11635 //Check whether we need to allocate more memory
11636 if(ieLen > pSession->nWpaRsnReqIeLength)
11637 {
11638 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
11639 {
11640 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
11641 }
11642 status = palAllocateMemory(pMac->hHdd, (void **)&pSession->pWpaRsnReqIE, ieLen);
11643 if(!HAL_STATUS_SUCCESS(status)) break;
11644 }
11645 pSession->nWpaRsnReqIeLength = ieLen;
11646 palCopyMemory(pMac->hHdd, pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
11647 wTmp = pal_cpu_to_be16( ieLen );
11648 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11649 pBuf += sizeof(tANI_U16);
11650 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11651 pBuf += ieLen;
11652 }
11653 }
11654 else
11655 {
11656 //free whatever old info
11657 pSession->nWpaRsnReqIeLength = 0;
11658 if(pSession->pWpaRsnReqIE)
11659 {
11660 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
11661 pSession->pWpaRsnReqIE = NULL;
11662 }
11663#ifdef FEATURE_WLAN_WAPI
11664 pSession->nWapiReqIeLength = 0;
11665 if(pSession->pWapiReqIE)
11666 {
11667 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
11668 pSession->pWapiReqIE = NULL;
11669 }
11670#endif /* FEATURE_WLAN_WAPI */
11671 //length is two bytes
11672 *pBuf = 0;
11673 *(pBuf + 1) = 0;
11674 pBuf += 2;
11675 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011676#ifdef FEATURE_WLAN_CCX
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011677 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011678 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011679 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070011680 //length is two bytes
11681 *pBuf = 0;
11682 *(pBuf + 1) = 0;
11683 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011684 }
11685 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011686 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011687 // cckmIE
11688 if( csrIsProfileCCX( pProfile ) )
11689 {
11690 // Insert the CCKM IE into the join request
11691 ieLen = csrConstructCcxCckmIe( pMac,
11692 pSession,
11693 pProfile,
11694 pBssDescription,
11695 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070011696 pSession->nWpaRsnReqIeLength,
11697 (void *)( wpaRsnIE ) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011698 }
11699 else
11700 {
11701 ieLen = 0;
11702 }
11703 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
11704 if( ieLen )
11705 {
11706 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
11707 wTmp = pal_cpu_to_be16( ieLen );
11708 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11709 pBuf += sizeof(tANI_U16);
11710 palCopyMemory( pMac->hHdd, pBuf, wpaRsnIE, ieLen );
11711 pBuf += ieLen;
11712 }
11713 else
11714 {
11715 //Indicate you have no CCKM IE
11716 //length is two bytes
11717 *pBuf = 0;
11718 *(pBuf + 1) = 0;
11719 pBuf += 2;
11720 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011721 }
11722#endif /* FEATURE_WLAN_CCX */
Jeff Johnson295189b2012-06-20 16:38:30 -070011723 // addIEScan
11724 if(pProfile->nAddIEScanLength && pProfile->pAddIEScan)
11725 {
11726 ieLen = pProfile->nAddIEScanLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070011727 if(ieLen > pSession->nAddIEScanLength)
11728 {
11729 if(pSession->pAddIEScan && pSession->nAddIEScanLength)
11730 {
11731 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
11732 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011733 status = palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070011734 (void **)&pSession->pAddIEScan, ieLen);
11735 if(!HAL_STATUS_SUCCESS(status)) break;
11736 }
11737 pSession->nAddIEScanLength = ieLen;
11738 palCopyMemory(pMac->hHdd, pSession->pAddIEScan,
11739 pProfile->pAddIEScan, ieLen);
11740 wTmp = pal_cpu_to_be16( ieLen );
11741 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
11742 pBuf += sizeof(tANI_U16);
11743 palCopyMemory( pMac->hHdd, pBuf, pProfile->pAddIEScan, ieLen );
11744 pBuf += ieLen;
11745 }
11746 else
11747 {
11748 pSession->nAddIEScanLength = 0;
11749 if(pSession->pAddIEScan)
11750 {
11751 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
11752 pSession->pAddIEScan = NULL;
11753 }
11754 *pBuf = 0;
11755 *(pBuf + 1) = 0;
11756 pBuf += 2;
11757 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011758 // addIEAssoc
11759 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
11760 {
11761 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070011762 if(ieLen > pSession->nAddIEAssocLength)
11763 {
11764 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
11765 {
11766 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
11767 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011768 status = palAllocateMemory(pMac->hHdd,
Jeff Johnson295189b2012-06-20 16:38:30 -070011769 (void **)&pSession->pAddIEAssoc, ieLen);
11770 if(!HAL_STATUS_SUCCESS(status)) break;
11771 }
11772 pSession->nAddIEAssocLength = ieLen;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011773 palCopyMemory(pMac->hHdd, pSession->pAddIEAssoc,
Jeff Johnson295189b2012-06-20 16:38:30 -070011774 pProfile->pAddIEAssoc, ieLen);
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, pProfile->pAddIEAssoc, ieLen );
11779 pBuf += ieLen;
11780 }
11781 else
11782 {
11783 pSession->nAddIEAssocLength = 0;
11784 if(pSession->pAddIEAssoc)
11785 {
11786 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
11787 pSession->pAddIEAssoc = NULL;
11788 }
11789 *pBuf = 0;
11790 *(pBuf + 1) = 0;
11791 pBuf += 2;
11792 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011793
11794 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070011795 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011796 //Unmask any AC in reassoc that is ACM-set
11797 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
11798 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011799 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011800 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
11801 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011802#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011803 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070011804#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011805 uapsd_mask &= ~(acm_mask);
11806 }
11807 else
11808 {
11809 uapsd_mask = 0;
11810 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011811 }
11812 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011813
Jeff Johnson295189b2012-06-20 16:38:30 -070011814 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
11815 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011816 pBuf += sizeof(tANI_U32);
11817
Jeff Johnson295189b2012-06-20 16:38:30 -070011818 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
11819 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011820 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070011821#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011822 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053011823 if (csrIsProfile11r( pProfile )
11824#ifdef FEATURE_WLAN_CCX
11825 && !((pIes->CCXVersion.present) && (pMac->roam.configParam.isCcxIniFeatureEnabled))
11826#endif
11827 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011828 {
11829 // is11Rconnection;
11830 dwTmp = pal_cpu_to_be32(TRUE);
11831 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11832 pBuf += sizeof(tAniBool);
11833 }
11834 else
11835 {
11836 // is11Rconnection;
11837 dwTmp = pal_cpu_to_be32(FALSE);
11838 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11839 pBuf += sizeof(tAniBool);
11840 }
11841#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011842#ifdef FEATURE_WLAN_CCX
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011843 /* A profile can not be both CCX and 11R. But an 802.11R AP
11844 * may be advertising support for CCX as well. So if we are
11845 * associating Open or explicitly CCX then we will get CCX.
11846 * If we are associating explictly 11R only then we will get
11847 * 11R.
11848 */
11849 if ((csrIsProfileCCX(pProfile) ||
11850 ((pIes->CCXVersion.present)
11851 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011852 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
11853 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
11854 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011855 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011856 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
11857 {
11858 // isCCXconnection;
11859 dwTmp = pal_cpu_to_be32(TRUE);
11860 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11861 pBuf += sizeof(tAniBool);
11862 }
11863 else
11864 {
11865 //isCCXconnection;
11866 dwTmp = pal_cpu_to_be32(FALSE);
11867 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
11868 pBuf += sizeof(tAniBool);
11869 }
11870
11871 if (eWNI_SME_JOIN_REQ == messageType)
11872 {
11873 tCCXTspecInfo ccxTspec;
11874 // CCX-Tspec IEs in the ASSOC request is presently not supported
11875 // so nullify the TSPEC parameters
11876 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
11877 palCopyMemory( pMac->hHdd, pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
11878 pBuf += sizeof(tCCXTspecInfo);
11879 }
11880 else if (eWNI_SME_REASSOC_REQ == messageType)
11881 {
11882 if ((csrIsProfileCCX(pProfile) ||
11883 ((pIes->CCXVersion.present)
11884 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011885 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
11886 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
11887 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011888 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011889 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070011890 {
11891 tCCXTspecInfo ccxTspec;
Jeff Johnson295189b2012-06-20 16:38:30 -070011892 // CCX Tspec information
11893 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
11894 ccxTspec.numTspecs = sme_QosCCxRetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &ccxTspec.tspec[0]);
11895 *pBuf = ccxTspec.numTspecs;
11896 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070011897 // Copy the TSPEC information only if present
11898 if (ccxTspec.numTspecs) {
11899 palCopyMemory(pMac->hHdd, pBuf, (void*)&ccxTspec.tspec[0], (ccxTspec.numTspecs*sizeof(tTspecInfo)));
11900 }
11901 pBuf += sizeof(ccxTspec.tspec);
11902 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011903 else
Jeff Johnson295189b2012-06-20 16:38:30 -070011904 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011905 tCCXTspecInfo ccxTspec;
11906 // CCX-Tspec IEs in the ASSOC request is presently not supported
11907 // so nullify the TSPEC parameters
11908 palZeroMemory(pMac->hHdd, &ccxTspec, sizeof(tCCXTspecInfo));
11909 palCopyMemory( pMac->hHdd, pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
11910 pBuf += sizeof(tCCXTspecInfo);
11911 }
11912 }
11913#endif // FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011914#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070011915 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011916 if (pMac->roam.configParam.isFastTransitionEnabled
11917#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053011918 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011919#endif
11920 )
Jeff Johnson295189b2012-06-20 16:38:30 -070011921 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011922 dwTmp = pal_cpu_to_be32(TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011923 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011924 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070011925 }
11926 else
11927 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011928 dwTmp = pal_cpu_to_be32(FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011929 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011930 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070011931 }
11932#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070011933#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053011934 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070011935 {
11936 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011937 dwTmp = pal_cpu_to_be32(TRUE);
Jeff Johnson43971f52012-07-17 12:26:56 -070011938 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011939 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070011940 }
11941 else
11942 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011943 dwTmp = pal_cpu_to_be32(FALSE);
Jeff Johnson43971f52012-07-17 12:26:56 -070011944 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool) );
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011945 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070011946 }
11947#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011948
11949 // txLdpcIniFeatureEnabled
11950 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
11951 pBuf++;
11952
Kiran4a17ebe2013-01-31 10:43:43 -080011953 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
11954 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
11955 {
11956 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
11957 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
11958 csrApplyPower2Current(pMac);
11959 }
11960
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080011961#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080011962 // txBFIniFeatureEnabled
11963 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
11964 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080011965
11966 // txBFCsnValue
11967 *pBuf = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
11968 pBuf++;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080011969#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011970 //BssDesc
11971 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
11972 (tANI_U8)pProfile->uapsd_mask);
11973 status = palSendMBMessage(pMac->hHdd, pMsg );
11974 if(!HAL_STATUS_SUCCESS(status))
11975 {
11976 break;
11977 }
11978 else
11979 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011980#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011981 if (eWNI_SME_JOIN_REQ == messageType)
11982 {
11983 //Tush-QoS: notify QoS module that join happening
11984 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
11985 }
11986 else if (eWNI_SME_REASSOC_REQ == messageType)
11987 {
11988 //Tush-QoS: notify QoS module that reassoc happening
11989 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
11990 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011991#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080011992 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011993 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070011994 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070011995}
11996
Jeff Johnson295189b2012-06-20 16:38:30 -070011997//
11998eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
11999{
12000 eHalStatus status = eHAL_STATUS_SUCCESS;
12001 tSirSmeDisassocReq *pMsg;
12002 tANI_U8 *pBuf;
12003 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012004 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12005 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12006 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012007 do {
12008 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDisassocReq ));
12009 if ( !HAL_STATUS_SUCCESS(status) ) break;
12010 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDisassocReq ));
12011 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
12012 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012013 pBuf = &pMsg->sessionId;
12014 // sessionId
12015 *pBuf++ = (tANI_U8)sessionId;
12016 // transactionId
12017 *pBuf = 0;
12018 *( pBuf + 1 ) = 0;
12019 pBuf += sizeof(tANI_U16);
12020
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053012021 if ( (pSession->pCurRoamProfile != NULL) &&
12022 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
12023 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012024 {
12025 // Set the bssid address before sending the message to LIM
12026 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pSession->selfMacAddr, sizeof( tSirMacAddr ) );
12027 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012028 // Set the peer MAC address before sending the message to LIM
12029 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ) ); //perMacAddr is passed as bssId for softAP
12030 pBuf = pBuf + sizeof ( tSirMacAddr );
12031 }
12032 else
12033 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012034 // Set the peer MAC address before sending the message to LIM
12035 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ) );
12036 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012037 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ) );
12038 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012039 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012040 if(!HAL_STATUS_SUCCESS(status))
12041 {
12042 palFreeMemory(pMac->hHdd, pMsg);
12043 break;
12044 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012045 // reasonCode
12046 wTmp = pal_cpu_to_be16(reasonCode);
12047 status = palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12048 if(!HAL_STATUS_SUCCESS(status))
12049 {
12050 palFreeMemory(pMac->hHdd, pMsg);
12051 break;
12052 }
12053 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012054 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
12055 Here we should not send the disassoc over the air to the AP */
12056 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
12057#ifdef WLAN_FEATURE_VOWIFI_11R
12058 && csrRoamIs11rAssoc(pMac)
12059#endif
12060 )
12061 {
12062 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
12063 }
12064 pBuf += sizeof(tANI_U8);
12065 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012066 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012067 return( status );
12068}
Jeff Johnson295189b2012-06-20 16:38:30 -070012069eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
12070{
12071 eHalStatus status = eHAL_STATUS_SUCCESS;
12072 tSirSmeTkipCntrMeasReq *pMsg;
12073 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012074 do
12075 {
12076 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeTkipCntrMeasReq ));
12077 if ( !HAL_STATUS_SUCCESS(status) ) break;
12078 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeTkipCntrMeasReq ));
12079 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
12080 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
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 // bssid
12089 status = palCopyMemory( pMac->hHdd, pMsg->bssId, bssId, sizeof( tSirMacAddr ) );
12090 pBuf = pBuf + sizeof ( tSirMacAddr );
12091 // bEnable
12092 *pBuf = (tANI_BOOLEAN)bEnable;
12093 if(!HAL_STATUS_SUCCESS(status))
12094 {
12095 palFreeMemory(pMac->hHdd, pMsg);
12096 break;
12097 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012098 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012099 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012100 return( status );
12101}
Jeff Johnson295189b2012-06-20 16:38:30 -070012102eHalStatus
12103csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
12104 VOS_MODULE_ID modId, tSirMacAddr bssId,
12105 void *pUsrContext, void *pfnSapEventCallback,
12106 tANI_U8 *pAssocStasBuf )
12107{
12108 eHalStatus status = eHAL_STATUS_SUCCESS;
12109 tSirSmeGetAssocSTAsReq *pMsg;
12110 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
12111 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012112 do
12113 {
12114 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeGetAssocSTAsReq ) );
12115 if (!HAL_STATUS_SUCCESS(status)) break;
12116 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirSmeGetAssocSTAsReq ) );
12117 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012118 pBuf = (tANI_U8 *)&pMsg->bssId;
12119 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012120 // bssId
12121 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr) );
12122 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012123 // modId
12124 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
12125 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
12126 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012127 // pUsrContext
12128 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
12129 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12130 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012131 // pfnSapEventCallback
12132 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
12133 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12134 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012135 // pAssocStasBuf
12136 dwTmp = pal_cpu_to_be32((tANI_U32)pAssocStasBuf);
12137 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12138 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012139 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070012140 status = palSendMBMessage( pMac->hHdd, pMsg );
12141 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012142 return( status );
12143 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012144eHalStatus
12145csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
12146 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
12147 {
12148 eHalStatus status = eHAL_STATUS_SUCCESS;
12149 tSirSmeGetWPSPBCSessionsReq *pMsg;
12150 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
12151 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012152 do
12153 {
12154 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirSmeGetWPSPBCSessionsReq) );
12155 if (!HAL_STATUS_SUCCESS(status)) break;
12156 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ) );
12157 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012158 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
12159 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012160 // pUsrContext
12161 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
12162 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12163 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012164 // pSapEventCallback
12165 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
12166 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12167 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012168 // bssId
12169 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr) );
12170 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012171 // MAC Address of STA in WPS session
12172 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
12173 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070012174 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070012175 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012176 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012177 return( status );
12178}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012179
12180eHalStatus
12181csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
12182{
12183 tpSirChangeBIParams pMsg;
12184 tANI_U16 len = 0;
12185 eHalStatus status = eHAL_STATUS_SUCCESS;
12186 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12187
12188 if(!pSession)
12189 {
12190 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12191 return eHAL_STATUS_FAILURE;
12192 }
12193
12194 //NO need to update the Beacon Params if update beacon parameter flag is not set
12195 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
12196 return eHAL_STATUS_SUCCESS;
12197
12198 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
12199
12200 /* Create the message and send to lim */
12201 len = sizeof(tSirChangeBIParams);
12202 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, len );
12203 if(HAL_STATUS_SUCCESS(status))
12204 {
12205 palZeroMemory(pMac->hHdd, pMsg, sizeof(tSirChangeBIParams) );
12206 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
12207 pMsg->length = len;
12208
12209 // bssId
12210 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
12211 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= %02x-%02x-%02x-%02x-%02x-%02x "),
12212 pMsg->bssId[ 0 ], pMsg->bssId[ 1 ], pMsg->bssId[ 2 ],
12213 pMsg->bssId[ 3 ], pMsg->bssId[ 4 ], pMsg->bssId[ 5 ] );
12214 pMsg->sessionId = sessionId;
12215 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d\n"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
12216 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
12217 status = palSendMBMessage(pMac->hHdd, pMsg);
12218 }
12219 return status;
12220}
12221
Jeff Johnson295189b2012-06-20 16:38:30 -070012222eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12223{
12224 eHalStatus status = eHAL_STATUS_SUCCESS;
12225 tSirSmeDeauthReq *pMsg;
12226 tANI_U8 *pBuf;
12227 tANI_U16 wTmp;
12228 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12229 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12230 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012231 do {
12232 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDeauthReq ));
12233 if ( !HAL_STATUS_SUCCESS(status) ) break;
12234 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDeauthReq ));
12235 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
12236 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
12237 //sessionId
12238 pBuf = &pMsg->sessionId;
12239 *pBuf++ = (tANI_U8)sessionId;
12240
12241 //tansactionId
12242 *pBuf = 0;
12243 *(pBuf + 1 ) = 0;
12244 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012245 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070012246 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070012247 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
12248 // Set the BSSID before sending the message to LIM
12249 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, pSession->selfMacAddr, sizeof( pMsg->peerMacAddr ) );
12250 pBuf = pBuf + sizeof(tSirMacAddr);
12251 }
12252 else
12253 {
12254 // Set the BSSID before sending the message to LIM
12255 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
12256 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070012257 }
12258 if(!HAL_STATUS_SUCCESS(status))
12259 {
12260 palFreeMemory(pMac->hHdd, pMsg);
12261 break;
12262 }
12263 // Set the peer MAC address before sending the message to LIM
12264 status = palCopyMemory( pMac->hHdd, (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
12265 pBuf = pBuf + sizeof(tSirMacAddr);
12266 if(!HAL_STATUS_SUCCESS(status))
12267 {
12268 palFreeMemory(pMac->hHdd, pMsg);
12269 break;
12270 }
12271 wTmp = pal_cpu_to_be16(reasonCode);
12272 status = palCopyMemory( pMac->hHdd, pBuf, &wTmp,sizeof( tANI_U16 ) );
12273 if(!HAL_STATUS_SUCCESS(status))
12274 {
12275 palFreeMemory(pMac->hHdd, pMsg);
12276 break;
12277 }
12278 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012279 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012280 return( status );
12281}
12282
Jeff Johnson295189b2012-06-20 16:38:30 -070012283eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
12284{
12285 eHalStatus status = eHAL_STATUS_SUCCESS;
12286 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070012287 do {
12288 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDisassocCnf ));
12289 if ( !HAL_STATUS_SUCCESS(status) ) break;
12290 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDisassocCnf ));
12291 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
12292 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12293 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
12294 status = palCopyMemory(pMac->hHdd, pMsg->peerMacAddr, pDisassocInd->peerMacAddr, sizeof(pMsg->peerMacAddr));
12295 if(!HAL_STATUS_SUCCESS(status))
12296 {
12297 palFreeMemory(pMac->hHdd, pMsg);
12298 break;
12299 }
12300//To test reconn
12301 status = palCopyMemory(pMac->hHdd, pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
12302 if(!HAL_STATUS_SUCCESS(status))
12303 {
12304 palFreeMemory(pMac->hHdd, pMsg);
12305 break;
12306 }
12307//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070012308 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012309 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012310 return( status );
12311}
12312
Jeff Johnson295189b2012-06-20 16:38:30 -070012313eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
12314{
12315 eHalStatus status = eHAL_STATUS_SUCCESS;
12316 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070012317 do {
12318 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeDeauthCnf ));
12319 if ( !HAL_STATUS_SUCCESS(status) ) break;
12320 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeDeauthCnf ));
12321 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
12322 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12323 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
12324 status = palCopyMemory(pMac->hHdd, pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
12325 if(!HAL_STATUS_SUCCESS(status))
12326 {
12327 palFreeMemory(pMac->hHdd, pMsg);
12328 break;
12329 }
12330 status = palCopyMemory(pMac->hHdd, pMsg->peerMacAddr, pDeauthInd->peerMacAddr, sizeof(pMsg->peerMacAddr));
12331 if(!HAL_STATUS_SUCCESS(status))
12332 {
12333 palFreeMemory(pMac->hHdd, pMsg);
12334 break;
12335 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012336 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070012337 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012338 return( status );
12339}
Jeff Johnson295189b2012-06-20 16:38:30 -070012340eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
12341{
12342 eHalStatus status = eHAL_STATUS_SUCCESS;
12343 tSirSmeAssocCnf *pMsg;
12344 tANI_U8 *pBuf;
12345 tSirResultCodes statusCode;
12346 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012347 do {
12348 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeAssocCnf ));
12349 if ( !HAL_STATUS_SUCCESS(status) ) break;
12350 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeAssocCnf ));
12351 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
12352 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012353 pBuf = (tANI_U8 *)&pMsg->statusCode;
12354 if(HAL_STATUS_SUCCESS(Halstatus))
12355 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12356 else
12357 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
12358 palCopyMemory( pMac->hHdd, pBuf, &statusCode, sizeof(tSirResultCodes) );
12359 pBuf += sizeof(tSirResultCodes);
12360 // bssId
12361 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12362 pBuf += sizeof (tSirMacAddr);
12363 // peerMacAddr
12364 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
12365 pBuf += sizeof (tSirMacAddr);
12366 // aid
12367 wTmp = pal_cpu_to_be16(pAssocInd->aid);
12368 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12369 pBuf += sizeof (tANI_U16);
12370 // alternateBssId
12371 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12372 pBuf += sizeof (tSirMacAddr);
12373 // alternateChannelId
12374 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070012375 status = palSendMBMessage( pMac->hHdd, pMsg );
12376 if(!HAL_STATUS_SUCCESS(status))
12377 {
12378 //pMsg is freed by palSendMBMessage
12379 break;
12380 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012381 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012382 return( status );
12383}
Jeff Johnson295189b2012-06-20 16:38:30 -070012384eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
12385 tpSirSmeAssocInd pAssocInd,
12386 eHalStatus Halstatus,
12387 tANI_U8 sessionId)
12388{
12389 tSirMsgQ msgQ;
12390 eHalStatus status = eHAL_STATUS_SUCCESS;
12391 tSirSmeAssocIndToUpperLayerCnf *pMsg;
12392 tANI_U8 *pBuf;
12393 tSirResultCodes statusCode;
12394 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012395 do {
12396 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ));
12397 if ( !HAL_STATUS_SUCCESS(status) ) break;
12398 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ));
Jeff Johnsone7245742012-09-05 17:12:55 -070012399
Jeff Johnson295189b2012-06-20 16:38:30 -070012400 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
12401 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
12402
12403 pMsg->sessionId = sessionId;
12404
12405 pBuf = (tANI_U8 *)&pMsg->statusCode;
12406 if(HAL_STATUS_SUCCESS(Halstatus))
12407 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
12408 else
12409 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
12410 palCopyMemory( pMac->hHdd, pBuf, &statusCode, sizeof(tSirResultCodes) );
12411 pBuf += sizeof(tSirResultCodes);
12412 // bssId
12413 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12414 pBuf += sizeof (tSirMacAddr);
12415 // peerMacAddr
12416 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->peerMacAddr, sizeof(tSirMacAddr));
12417 pBuf += sizeof (tSirMacAddr);
12418 // StaId
12419 wTmp = pal_cpu_to_be16(pAssocInd->staId);
12420 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12421 pBuf += sizeof (tANI_U16);
12422 // alternateBssId
12423 status = palCopyMemory(pMac->hHdd, (tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
12424 pBuf += sizeof (tSirMacAddr);
12425 // alternateChannelId
12426 *pBuf = 11;
12427 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012428 // Instead of copying roam Info, we just copy only WmmEnabled , RsnIE information
12429 //Wmm
12430 *pBuf = pAssocInd->wmmEnabledSta;
12431 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012432 //RSN IE
12433 status = palCopyMemory(pMac->hHdd, (tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
12434 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070012435 //Additional IE
12436 status = palCopyMemory(pMac->hHdd, (void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
12437 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070012438 //reassocReq
12439 *pBuf = pAssocInd->reassocReq;
12440 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012441 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
12442 msgQ.bodyptr = pMsg;
12443 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012444 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012445 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012446 return( status );
12447}
Jeff Johnson295189b2012-06-20 16:38:30 -070012448
Jeff Johnson295189b2012-06-20 16:38:30 -070012449eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId ,
12450 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
12451 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
12452 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
12453 tANI_U8 *pKeyRsc )
12454{
12455 tSirSmeSetContextReq *pMsg;
12456 tANI_U16 msgLen;
12457 eHalStatus status = eHAL_STATUS_FAILURE;
12458 tAniEdType tmpEdType;
12459 tAniKeyDirection tmpDirection;
12460 tANI_U8 *pBuf;
12461 tANI_U8 *p;
12462 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012463 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070012464 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012465 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
12466 // key set. Since we only support upto one key, we always allocate memory for 1 key
12467 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
12468 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
12469 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
12470 ( sizeof( pMsg->keyMaterial.key ) );
12471
12472 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12473 if ( !HAL_STATUS_SUCCESS(status) ) break;
12474 palZeroMemory(pMac->hHdd, pMsg, msgLen);
12475 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
12476 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012477 //sessionId
12478 pBuf = &pMsg->sessionId;
12479 *pBuf = (tANI_U8)sessionId;
12480 pBuf++;
12481 // transactionId
12482 *pBuf = 0;
12483 *(pBuf + 1) = 0;
12484 pBuf += sizeof(tANI_U16);
12485 // peerMacAddr
12486 palCopyMemory( pMac->hHdd, pBuf,
12487 (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr) );
12488
12489 pBuf += sizeof(tSirMacAddr);
12490
12491 // bssId
12492 palCopyMemory( pMac->hHdd, pBuf,
12493 (tANI_U8 *)&pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
12494
12495 pBuf += sizeof(tSirMacAddr);
12496
12497 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012498 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
12499 // in the tSirKeyMaterial keyMaterial; field).
12500 //
12501 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
12502 // shorter than this max size. Is LIM interpreting this ok ?
12503 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 -070012504 // set pMsg->keyMaterial.edType
12505 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
12506 palCopyMemory( pMac->hHdd, p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType) );
12507 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070012508 // set the pMsg->keyMaterial.numKeys field
12509 *p = numKeys;
12510 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070012511 // set pSirKey->keyId = keyId;
12512 *p = keyId;
12513 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012514 // set pSirKey->unicast = (tANI_U8)fUnicast;
12515 *p = (tANI_U8)fUnicast;
12516 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070012517 // set pSirKey->keyDirection = aniKeyDirection;
12518 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
12519 palCopyMemory( pMac->hHdd, p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection) );
12520 p += sizeof(tAniKeyDirection);
12521 // pSirKey->keyRsc = ;;
12522 palCopyMemory( pMac->hHdd, p, pKeyRsc, CSR_MAX_RSC_LEN );
12523 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070012524 // set pSirKey->paeRole
12525 *p = paeRole; // 0 is Supplicant
12526 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012527 // set pSirKey->keyLength = keyLength;
12528 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070012529 if ( keyLength && pKey )
12530 {
12531 palCopyMemory( pMac->hHdd, p, pKey, keyLength );
12532 if(keyLength == 16)
12533 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -070012534 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 -070012535 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
12536 pKey[5], pKey[6], pKey[7], pKey[8],
12537 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
12538 }
12539 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012540 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012541 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012542 return( status );
12543}
12544
Jeff Johnson295189b2012-06-20 16:38:30 -070012545eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
12546 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
12547{
12548 eHalStatus status;
12549 tSirSmeStartBssReq *pMsg;
12550 tANI_U8 *pBuf = NULL;
12551 tANI_U8 *wTmpBuf = NULL;
12552 tANI_U16 msgLen, wTmp;
12553 tANI_U32 dwTmp;
12554 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070012555 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012556 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070012557 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012558
12559 if(!pSession)
12560 {
12561 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12562 return eHAL_STATUS_FAILURE;
12563 }
12564
Jeff Johnson295189b2012-06-20 16:38:30 -070012565 do {
12566 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12567 pSession->joinFailStatusCode.reasonCode = 0;
12568 msgLen = sizeof(tSirSmeStartBssReq);
12569 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12570 if ( !HAL_STATUS_SUCCESS(status) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012571 palZeroMemory(pMac->hHdd, pMsg, msgLen);
12572 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070012573 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012574 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070012575 //sessionId
12576 *pBuf = (tANI_U8)sessionId;
12577 pBuf++;
12578 // transactionId
12579 *pBuf = 0;
12580 *(pBuf + 1) = 0;
12581 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012582 // bssid
12583 palCopyMemory( pMac->hHdd, pBuf, pParam->bssid, sizeof(tSirMacAddr) );
12584 pBuf += sizeof(tSirMacAddr);
12585 // selfMacAddr
12586 palCopyMemory( pMac->hHdd, pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr) );
12587 pBuf += sizeof(tSirMacAddr);
12588 // beaconInterval
12589 if( pBssDesc && pBssDesc->beaconInterval )
12590 {
12591 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
12592 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012593 else if(pParam->beaconInterval)
12594 {
12595 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
12596 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012597 else
12598 {
12599 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
12600 }
Jeff Johnsone7245742012-09-05 17:12:55 -070012601 if(csrIsconcurrentsessionValid (pMac, sessionId,
12602 pParam->bssPersona)
12603 == eHAL_STATUS_SUCCESS )
12604 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080012605 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070012606 pParam->bssPersona);
12607 //Update the beacon Interval
12608 pParam->beaconInterval = wTmp;
12609 }
12610 else
12611 {
12612 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***\n"));
12613 status = eHAL_STATUS_FAILURE;
12614 return status;
12615 }
12616
Jeff Johnson295189b2012-06-20 16:38:30 -070012617 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof( tANI_U16 ) );
12618 pBuf += sizeof(tANI_U16);
12619 // dot11mode
12620 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
12621 pBuf += 1;
12622 // bssType
12623 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
12624 palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tSirBssType) );
12625 pBuf += sizeof(tSirBssType);
12626 // ssId
12627 if( pParam->ssId.length )
12628 {
12629 // ssId len
12630 *pBuf = pParam->ssId.length;
12631 pBuf++;
12632 palCopyMemory( pMac->hHdd, pBuf, pParam->ssId.ssId, pParam->ssId.length );
12633 pBuf += pParam->ssId.length;
12634 }
12635 else
12636 {
12637 *pBuf = 0;
12638 pBuf++;
12639 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012640 // set the channel Id
12641 *pBuf = pParam->operationChn;
12642 pBuf++;
12643 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070012644 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
12645 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState) );
12646 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070012647
Jeff Johnson295189b2012-06-20 16:38:30 -070012648 // Set privacy
12649 *pBuf = pParam->privacy;
12650 pBuf++;
12651
12652 //Set Uapsd
12653 *pBuf = pParam->ApUapsdEnable;
12654 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012655 //Set SSID hidden
12656 *pBuf = pParam->ssidHidden;
12657 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012658 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
12659 pBuf++;
12660
12661 //Ht protection Enable/Disable
12662 *pBuf = (tANI_U8)pParam->protEnabled;
12663 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012664 //Enable Beacons to Receive for OBSS protection Enable/Disable
12665 *pBuf = (tANI_U8)pParam->obssProtEnabled;
12666 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012667 //set cfg related to protection
12668 wTmp = pal_cpu_to_be16( pParam->ht_protection );
12669 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof( tANI_U16 ) );
12670 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012671 // Set Auth type
12672 authType = pal_cpu_to_be32(pParam->authType);
12673 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
12674 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012675 // Set DTIM
12676 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
12677 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
12678 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070012679 // Set wps_state
12680 *pBuf = pParam->wps_state;
12681 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012682 //Persona
12683 *pBuf = (tANI_U8)pParam->bssPersona;
12684 pBuf++;
12685
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080012686 //txLdpcIniFeatureEnabled
12687 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
12688 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070012689
Jeff Johnson295189b2012-06-20 16:38:30 -070012690
12691 // set RSN IE
12692 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
12693 {
12694 status = eHAL_STATUS_INVALID_PARAMETER;
12695 palFreeMemory( pMac->hHdd, pMsg );
12696 break;
12697 }
12698 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
12699 palCopyMemory( pMac->hHdd, pBuf, &wTmp, sizeof(tANI_U16) );
12700 pBuf += sizeof(tANI_U16);
12701 if( wTmp )
12702 {
12703 wTmp = pParam->nRSNIELength;
12704 palCopyMemory( pMac->hHdd, pBuf, pParam->pRSNIE, wTmp );
12705 pBuf += wTmp;
12706 }
12707 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
12708 palCopyMemory( pMac->hHdd, pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType) );
12709 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012710 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
12711 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012712 palCopyMemory( pMac->hHdd, pBuf, pParam->operationalRateSet.rate, pParam->operationalRateSet.numRates );
12713 pBuf += pParam->operationalRateSet.numRates ;
12714 *pBuf++ = pParam->extendedRateSet.numRates;
12715 if(0 != pParam->extendedRateSet.numRates)
12716 {
12717 palCopyMemory( pMac->hHdd, pBuf, pParam->extendedRateSet.rate, pParam->extendedRateSet.numRates );
12718 pBuf += pParam->extendedRateSet.numRates;
12719 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012720 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
12721 pMsg->length = pal_cpu_to_be16(msgLen);
12722
12723 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012724 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012725 return( status );
12726}
12727
Jeff Johnson295189b2012-06-20 16:38:30 -070012728eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
12729{
12730 eHalStatus status = eHAL_STATUS_FAILURE;
12731 tSirSmeStopBssReq *pMsg;
12732 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12733 tANI_U8 *pBuf;
12734 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012735
12736 if(!pSession)
12737 {
12738 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12739 return eHAL_STATUS_FAILURE;
12740 }
12741
Jeff Johnson295189b2012-06-20 16:38:30 -070012742 do {
12743 status = palAllocateMemory(pMac, (void **)&pMsg, sizeof(tSirSmeStopBssReq));
12744 if ( !HAL_STATUS_SUCCESS(status) ) break;
12745 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeStopBssReq ));
12746 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
12747 pBuf = &pMsg->sessionId;
12748 //sessionId
12749 *pBuf = (tANI_U8)sessionId;
12750 pBuf++;
12751 // transactionId
12752 *pBuf = 0;
12753 pBuf += sizeof(tANI_U16);
12754 //reason code
12755 *pBuf = 0;
12756 pBuf += sizeof(tSirResultCodes);
12757 // bssid
12758 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
12759 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
12760 {
12761 palCopyMemory( pMac->hHdd, pBuf,(tANI_U8 *)&pSession->selfMacAddr, sizeof(tSirMacAddr) );
12762 }
12763 else
12764 {
12765 palCopyMemory( pMac->hHdd, pBuf,(tANI_U8 *)&pSession->connectedProfile.bssid, sizeof(tSirMacAddr) );
12766 }
12767 pBuf += sizeof(tSirMacAddr);
12768 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
12769 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012770 status = palSendMBMessage( pMac->hHdd, pMsg );
12771#if 0
12772 status = palAllocateMemory(pMac, (void **)&pMsg, sizeof(tSirSmeStopBssReq));
12773 if ( !HAL_STATUS_SUCCESS(status) ) break;
12774 palZeroMemory(pMac->hHdd, pMsg, sizeof( tSirSmeStopBssReq ));
12775 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
12776 pMsg->reasonCode = 0;
12777 // bssid
12778 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
12779 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
12780 {
12781 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
12782 }
12783 else
12784 {
12785 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
12786 }
12787 palCopyMemory( pMac->hHdd, &pMsg->bssId, pbBssid, sizeof(tSirMacAddr) );
12788 pMsg->transactionId = 0;
12789 pMsg->sessionId = (tANI_U8)sessionId;
12790 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
12791 status = palSendMBMessage( pMac->hHdd, pMsg );
12792#endif
12793 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012794 return( status );
12795}
12796
Jeff Johnson295189b2012-06-20 16:38:30 -070012797eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
12798 tCsrRoamModifyProfileFields *pModProfileFields,
12799 tANI_U32 *pRoamId, v_BOOL_t fForce)
12800{
Jeff Johnson295189b2012-06-20 16:38:30 -070012801 eHalStatus status = eHAL_STATUS_FAILURE;
12802 tANI_U32 roamId = 0;
12803 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012804 if((csrIsConnStateConnected(pMac, sessionId)) &&
12805 (fForce || (!palEqualMemory(pMac->hHdd, &pModProfileFields,
12806 &pSession->connectedProfile.modifyProfileFields,
12807 sizeof(tCsrRoamModifyProfileFields)))) )
12808 {
12809 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
12810 if(pRoamId)
12811 {
12812 *pRoamId = roamId;
12813 }
12814
Jeff Johnson295189b2012-06-20 16:38:30 -070012815 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
12816 eCsrSmeIssuedReassocToSameAP, roamId,
12817 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012818 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012819 return status;
12820}
Jeff Johnson295189b2012-06-20 16:38:30 -070012821static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
12822{
12823 eHalStatus status = eHAL_STATUS_SUCCESS;
12824 tCsrRoamInfo roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070012825 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
12826 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
12827 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
12828 return (status);
12829}
Jeff Johnson295189b2012-06-20 16:38:30 -070012830eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
12831{
12832 eHalStatus status = eHAL_STATUS_SUCCESS;
12833 tListElem *pEntry = NULL;
12834 tSmeCmd *pCommand = NULL;
12835 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012836 do
12837 {
12838 if(pMsg == NULL)
12839 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012840 smsLog(pMac, LOGE, "in %s msg ptr is NULL\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012841 status = eHAL_STATUS_FAILURE;
12842 break;
12843 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012844 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
12845 if(pEntry)
12846 {
12847 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
12848 if(eSmeCommandAddStaSession == pCommand->command)
12849 {
12850 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
12851 smsLog( pMac, LOG1, "Add Sta rsp status = %d\n", pRsp->status );
12852 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070012853 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070012854 //Remove this command out of the active list
12855 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
12856 {
12857 //Now put this command back on the avilable command list
12858 csrReleaseCommand(pMac, pCommand);
12859 }
12860 smeProcessPendingQueue( pMac );
12861 }
12862 else
12863 {
12864 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 -070012865 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012866 status = eHAL_STATUS_FAILURE;
12867 break;
12868 }
12869 }
12870 else
12871 {
12872 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 -070012873 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012874 status = eHAL_STATUS_FAILURE;
12875 break;
12876 }
12877 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012878 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012879}
Jeff Johnson295189b2012-06-20 16:38:30 -070012880eHalStatus csrSendMBAddSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
12881{
12882 tSirSmeAddStaSelfReq *pMsg;
12883 tANI_U16 msgLen;
12884 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012885 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070012886 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
12887 sizeof( tSirBssType )*/;
Jeff Johnson295189b2012-06-20 16:38:30 -070012888 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
12889 if ( !HAL_STATUS_SUCCESS(status) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012890 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012891 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
12892 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012893 // self station address
12894 palCopyMemory( pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr, sizeof(tSirMacAddr) );
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -070012895 smsLog( pMac, LOG1, FL("selfMac=%02x, %02x, %02x, %02x, %02x, %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -070012896 pMsg->selfMacAddr[0],
12897 pMsg->selfMacAddr[1],
12898 pMsg->selfMacAddr[2],
12899 pMsg->selfMacAddr[3],
12900 pMsg->selfMacAddr[4],
12901 pMsg->selfMacAddr[5]);
12902 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012903 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012904 return( status );
12905}
Jeff Johnson295189b2012-06-20 16:38:30 -070012906eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr sessionMacAddr)
12907{
12908 eHalStatus status = eHAL_STATUS_SUCCESS;
12909 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070012910 pCommand = csrGetCommandBuffer(pMac);
12911 if(NULL == pCommand)
12912 {
12913 status = eHAL_STATUS_RESOURCES;
12914 }
12915 else
12916 {
12917 pCommand->command = eSmeCommandAddStaSession;
12918 pCommand->sessionId = (tANI_U8)sessionId;
12919 palCopyMemory( pMac->hHdd, pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr, sizeof( tSirMacAddr ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070012920 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
12921 if( !HAL_STATUS_SUCCESS( status ) )
12922 {
12923 //Should be panic??
12924 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
12925 }
12926 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012927 return (status);
12928}
Jeff Johnson295189b2012-06-20 16:38:30 -070012929eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
12930{
12931 return csrSendMBAddSelfStaReqMsg( pMac,
12932 pCommand->u.addStaSessionCmd.selfMacAddr );
12933}
Jeff Johnson295189b2012-06-20 16:38:30 -070012934eHalStatus csrRoamOpenSession( tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext,
12935 tANI_U8 *pSelfMacAddr, tANI_U8 *pbSessionId )
12936{
12937 eHalStatus status = eHAL_STATUS_SUCCESS;
12938 tANI_U32 i;
12939 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070012940 *pbSessionId = CSR_SESSION_ID_INVALID;
12941 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
12942 {
12943 if( !CSR_IS_SESSION_VALID( pMac, i ) )
12944 {
12945 pSession = CSR_GET_SESSION( pMac, i );
12946 status = eHAL_STATUS_SUCCESS;
12947 pSession->sessionActive = eANI_BOOLEAN_TRUE;
12948 pSession->sessionId = (tANI_U8)i;
12949 pSession->callback = callback;
12950 pSession->pContext = pContext;
12951 palCopyMemory( pMac->hHdd, &pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid) );
12952 *pbSessionId = (tANI_U8)i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012953 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerRoaming, csrRoamRoamingTimerHandler,
12954 &pSession->roamingTimerInfo);
12955 if(!HAL_STATUS_SUCCESS(status))
12956 {
12957 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer\n"));
12958 break;
12959 }
12960#ifdef FEATURE_WLAN_BTAMP_UT_RF
12961 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerJoinRetry, csrRoamJoinRetryTimerHandler,
12962 &pSession->joinRetryTimerInfo);
12963 if(!HAL_STATUS_SUCCESS(status))
12964 {
12965 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer\n"));
12966 break;
12967 }
12968#endif
12969 pSession->ibssJoinTimerInfo.pMac = pMac;
12970 pSession->ibssJoinTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Jeff Johnson295189b2012-06-20 16:38:30 -070012971 status = palTimerAlloc(pMac->hHdd, &pSession->hTimerIbssJoining, csrRoamIbssJoinTimerHandler,
12972 &pSession->ibssJoinTimerInfo);
12973 if(!HAL_STATUS_SUCCESS(status))
12974 {
12975 smsLog(pMac, LOGE, FL("cannot allocate memory for IbssJoining timer\n"));
12976 break;
12977 }
12978 status = csrIssueAddStaForSessionReq ( pMac, i, pSelfMacAddr );
12979 break;
12980 }
12981 }
12982 if( CSR_ROAM_SESSION_MAX == i )
12983 {
12984 //No session is available
12985 status = eHAL_STATUS_RESOURCES;
12986 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012987 return ( status );
12988}
Jeff Johnson295189b2012-06-20 16:38:30 -070012989eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
12990{
12991 eHalStatus status = eHAL_STATUS_SUCCESS;
12992 tListElem *pEntry = NULL;
12993 tSmeCmd *pCommand = NULL;
12994 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012995 do
12996 {
12997 if(pMsg == NULL)
12998 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070012999 smsLog(pMac, LOGE, "in %s msg ptr is NULL\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013000 status = eHAL_STATUS_FAILURE;
13001 break;
13002 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013003 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
13004 if(pEntry)
13005 {
13006 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13007 if(eSmeCommandDelStaSession == pCommand->command)
13008 {
13009 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013010 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
13011 smsLog( pMac, LOG1, "Del Sta rsp status = %d\n", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013012 //This session is done.
13013 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013014 if(pCommand->u.delStaSessionCmd.callback)
13015 {
13016
13017 status = sme_ReleaseGlobalLock( &pMac->sme );
13018 if ( HAL_STATUS_SUCCESS( status ) )
13019 {
13020 pCommand->u.delStaSessionCmd.callback(
13021 pCommand->u.delStaSessionCmd.pContext);
13022 status = sme_AcquireGlobalLock( &pMac->sme );
13023 if (! HAL_STATUS_SUCCESS( status ) )
13024 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013025 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013026 return status;
13027 }
13028 }
13029 else {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070013030 smsLog(pMac, LOGE, "%s: Failed to Release Lock\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013031 }
13032 }
13033
13034 //Remove this command out of the active list
13035 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
13036 {
13037 //Now put this command back on the avilable command list
13038 csrReleaseCommand(pMac, pCommand);
13039 }
13040 smeProcessPendingQueue( pMac );
13041 }
13042 else
13043 {
13044 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 -070013045 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013046 status = eHAL_STATUS_FAILURE;
13047 break;
13048 }
13049 }
13050 else
13051 {
13052 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 -070013053 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013054 status = eHAL_STATUS_FAILURE;
13055 break;
13056 }
13057 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013058 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013059}
Jeff Johnson295189b2012-06-20 16:38:30 -070013060eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
13061{
13062 tSirSmeDelStaSelfReq *pMsg;
13063 tANI_U16 msgLen;
13064 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013065 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013066 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
13067 sizeof( tSirBssType )*/;
Jeff Johnson295189b2012-06-20 16:38:30 -070013068 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, msgLen);
13069 if ( !HAL_STATUS_SUCCESS(status) ) break;
13070
13071 palZeroMemory(pMac->hHdd, pMsg, msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013072 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
13073 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013074 // self station address
13075 palCopyMemory( pMac->hHdd, (tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr, sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013076 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013077 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013078 return( status );
13079}
Jeff Johnson295189b2012-06-20 16:38:30 -070013080eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
13081 tSirMacAddr sessionMacAddr,
13082 csrRoamSessionCloseCallback callback,
13083 void *pContext)
13084{
13085 eHalStatus status = eHAL_STATUS_SUCCESS;
13086 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070013087 pCommand = csrGetCommandBuffer(pMac);
13088 if(NULL == pCommand)
13089 {
13090 status = eHAL_STATUS_RESOURCES;
13091 }
13092 else
13093 {
13094 pCommand->command = eSmeCommandDelStaSession;
13095 pCommand->sessionId = (tANI_U8)sessionId;
13096 pCommand->u.delStaSessionCmd.callback = callback;
13097 pCommand->u.delStaSessionCmd.pContext = pContext;
13098 palCopyMemory( pMac->hHdd, pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr, sizeof( tSirMacAddr ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013099 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
13100 if( !HAL_STATUS_SUCCESS( status ) )
13101 {
13102 //Should be panic??
13103 smsLog( pMac, LOGE, FL(" fail to send message status = %d\n"), status );
13104 }
13105 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013106 return (status);
13107}
Jeff Johnson295189b2012-06-20 16:38:30 -070013108eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
13109{
13110 return csrSendMBDelSelfStaReqMsg( pMac,
13111 pCommand->u.delStaSessionCmd.selfMacAddr );
13112}
Jeff Johnson295189b2012-06-20 16:38:30 -070013113static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
13114{
13115 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
13116 tListElem *pEntry, *pNext;
13117 tSmeCmd *pCommand;
13118 tDblLinkList localList;
13119
13120 vos_mem_zero(&localList, sizeof(tDblLinkList));
13121 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
13122 {
13123 smsLog(pMac, LOGE, FL(" failed to open list"));
13124 return;
13125 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013126 csrLLLock(pList);
13127 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
13128 while(pEntry != NULL)
13129 {
13130 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
13131 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13132 if(pCommand->sessionId == sessionId)
13133 {
13134 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
13135 {
13136 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
13137 }
13138 }
13139 pEntry = pNext;
13140 }
13141 csrLLUnlock(pList);
13142
13143 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
13144 {
13145 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13146 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
13147 }
13148 csrLLClose(&localList);
13149}
13150
Jeff Johnson295189b2012-06-20 16:38:30 -070013151void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
13152{
13153 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13154 {
13155 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013156 csrRoamStop(pMac, sessionId);
13157 csrFreeConnectBssDesc(pMac, sessionId);
13158 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
13159 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
13160 palTimerFree(pMac->hHdd, pSession->hTimerRoaming);
13161#ifdef FEATURE_WLAN_BTAMP_UT_RF
13162 palTimerFree(pMac->hHdd, pSession->hTimerJoinRetry);
13163#endif
13164 palTimerFree(pMac->hHdd, pSession->hTimerIbssJoining);
13165 purgeSmeSessionCmdList(pMac, sessionId);
13166 purgeCsrSessionCmdList(pMac, sessionId);
13167 csrInitSession(pMac, sessionId);
13168 }
13169}
13170
Jeff Johnson295189b2012-06-20 16:38:30 -070013171eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
13172 tANI_BOOLEAN fSync,
13173 csrRoamSessionCloseCallback callback,
13174 void *pContext )
13175{
13176 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013177 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13178 {
13179 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13180 if(fSync)
13181 {
13182 csrCleanupSession(pMac, sessionId);
13183 }
13184 else
13185 {
13186 purgeSmeSessionCmdList(pMac, sessionId);
13187 purgeCsrSessionCmdList(pMac, sessionId);
13188 status = csrIssueDelStaForSessionReq( pMac, sessionId,
13189 pSession->selfMacAddr, callback, pContext);
13190 }
13191 }
13192 else
13193 {
13194 status = eHAL_STATUS_INVALID_PARAMETER;
13195 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013196 return ( status );
13197}
13198
Jeff Johnson295189b2012-06-20 16:38:30 -070013199static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
13200{
13201 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013202
13203 if(!pSession)
13204 {
13205 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13206 return;
13207 }
13208
Jeff Johnson295189b2012-06-20 16:38:30 -070013209 pSession->sessionActive = eANI_BOOLEAN_FALSE;
13210 pSession->sessionId = CSR_SESSION_ID_INVALID;
13211 pSession->callback = NULL;
13212 pSession->pContext = NULL;
13213 pSession->ibss_join_pending = FALSE;
13214 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
13215 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
13216 csrFreeRoamProfile( pMac, sessionId );
13217 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
13218 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
13219 csrFreeConnectBssDesc(pMac, sessionId);
13220 csrScanEnable(pMac);
13221 palZeroMemory( pMac->hHdd, &pSession->selfMacAddr, sizeof(tCsrBssid) );
13222 if(pSession->pWpaRsnReqIE)
13223 {
13224 palFreeMemory(pMac->hHdd, pSession->pWpaRsnReqIE);
13225 pSession->pWpaRsnReqIE = NULL;
13226 }
13227 pSession->nWpaRsnReqIeLength = 0;
13228 if(pSession->pWpaRsnRspIE)
13229 {
13230 palFreeMemory(pMac->hHdd, pSession->pWpaRsnRspIE);
13231 pSession->pWpaRsnRspIE = NULL;
13232 }
13233 pSession->nWpaRsnRspIeLength = 0;
13234#ifdef FEATURE_WLAN_WAPI
13235 if(pSession->pWapiReqIE)
13236 {
13237 palFreeMemory(pMac->hHdd, pSession->pWapiReqIE);
13238 pSession->pWapiReqIE = NULL;
13239 }
13240 pSession->nWapiReqIeLength = 0;
13241 if(pSession->pWapiRspIE)
13242 {
13243 palFreeMemory(pMac->hHdd, pSession->pWapiRspIE);
13244 pSession->pWapiRspIE = NULL;
13245 }
13246 pSession->nWapiRspIeLength = 0;
13247#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070013248 if(pSession->pAddIEScan)
13249 {
13250 palFreeMemory(pMac->hHdd, pSession->pAddIEScan);
13251 pSession->pAddIEScan = NULL;
13252 }
13253 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013254 if(pSession->pAddIEAssoc)
13255 {
13256 palFreeMemory(pMac->hHdd, pSession->pAddIEAssoc);
13257 pSession->pAddIEAssoc = NULL;
13258}
13259 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013260}
13261
Jeff Johnson295189b2012-06-20 16:38:30 -070013262eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
13263{
13264 eHalStatus status = eHAL_STATUS_FAILURE;
13265 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070013266 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13267 {
13268 if( CSR_IS_SESSION_VALID( pMac, i ) )
13269 {
13270 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
13271 {
13272 //Found it
13273 status = eHAL_STATUS_SUCCESS;
13274 *pSessionId = i;
13275 break;
13276 }
13277 }
13278 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013279 return( status );
13280}
13281
Jeff Johnson295189b2012-06-20 16:38:30 -070013282//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
13283//session because for IBSS, the bssid changes.
13284static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
13285{
13286 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
13287 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070013288 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13289 {
13290 if( CSR_IS_SESSION_VALID( pMac, i ) )
13291 {
13292 pSession = CSR_GET_SESSION( pMac, i );
13293 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
13294 {
13295 //Found it
13296 nRet = i;
13297 break;
13298 }
13299 }
13300 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013301 return (nRet);
13302}
Jeff Johnson295189b2012-06-20 16:38:30 -070013303static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
13304{
13305 /* Update the current BSS info in ho control block based on connected
13306 profile info from pmac global structure */
13307
Jeff Johnson295189b2012-06-20 16:38:30 -070013308 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= %02x-%02x-%02x-%02x-%02x-%02x\n",
13309 bssid[ 0 ], bssid[ 1 ], bssid[ 2 ],
13310 bssid[ 3 ], bssid[ 4 ], bssid[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -070013311 /* Check for user misconfig of RSSI trigger threshold */
13312 pMac->roam.configParam.vccRssiThreshold =
13313 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
13314 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
13315 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070013316 /* Check for user misconfig of UL MAC Loss trigger threshold */
13317 pMac->roam.configParam.vccUlMacLossThreshold =
13318 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
13319 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070013320#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13321 {
13322 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013323 /* Indicate the neighbor roal algorithm about the connect indication */
13324 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
13325 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
13326 }
13327#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013328}
13329
Jeff Johnson295189b2012-06-20 16:38:30 -070013330static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
13331{
13332 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013333
13334 if(!pSession)
13335 {
13336 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13337 return;
13338 }
13339
Jeff Johnson295189b2012-06-20 16:38:30 -070013340 //Only to handle the case for Handover on infra link
13341 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
13342 {
13343 return;
13344 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013345 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
13346 csrRoamDeregStatisticsReq(pMac);
13347 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
13348#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
13349 /* Indicate the neighbor roal algorithm about the disconnect indication */
13350 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
13351#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070013352
13353 //Remove this code once SLM_Sessionization is supported
13354 //BMPS_WORKAROUND_NOT_NEEDED
13355 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070013356 csrIsInfraApStarted( pMac ) &&
13357 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070013358 {
13359 pMac->roam.configParam.doBMPSWorkaround = 0;
13360 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013361}
13362
Jeff Johnson295189b2012-06-20 16:38:30 -070013363void csrRoamTlStatsTimerHandler(void *pv)
13364{
13365 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
13366 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013367 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
13368
Jeff Johnsone7245742012-09-05 17:12:55 -070013369 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
13370
Jeff Johnson295189b2012-06-20 16:38:30 -070013371#if 0
13372 // TODO Persession .???
13373 //req TL for stats
13374 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
13375 {
13376 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL\n"));
13377 }
13378 else
13379 {
13380 //save in SME
13381 csrRoamSaveStatsFromTl(pMac, tlStats);
13382 }
13383#endif
13384 if(!pMac->roam.tlStatsReqInfo.timerRunning)
13385 {
13386 if(pMac->roam.tlStatsReqInfo.periodicity)
13387 {
13388 //start timer
13389 status = palTimerStart(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer,
13390 pMac->roam.tlStatsReqInfo.periodicity * PAL_TIMER_TO_MS_UNIT, eANI_BOOLEAN_FALSE);
13391 if(!HAL_STATUS_SUCCESS(status))
13392 {
13393 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer\n"));
13394 return;
13395 }
13396 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
13397 }
13398 }
13399}
Jeff Johnson295189b2012-06-20 16:38:30 -070013400void csrRoamPeStatsTimerHandler(void *pv)
13401{
13402 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
13403 eHalStatus status;
13404 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
13405 VOS_STATUS vosStatus;
13406 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070013407 pPeStatsReqListEntry->timerRunning = FALSE;
13408 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
13409 {
13410 // If we entered here, meaning the timer could not be successfully
13411 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
13412
13413 /* Destroy the timer */
13414 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
13415 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13416 {
13417 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer\n"));
13418 }
13419
13420 // Free the entry
13421 palFreeMemory(pMac->hHdd, pPeStatsReqListEntry);
13422 pPeStatsReqListEntry = NULL;
13423 }
13424 else
13425 {
13426 if(!pPeStatsReqListEntry->rspPending)
13427 {
13428 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
13429 pPeStatsReqListEntry->staId);
13430 if(!HAL_STATUS_SUCCESS(status))
13431 {
13432 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE\n"));
13433 }
13434 else
13435 {
13436 pPeStatsReqListEntry->rspPending = TRUE;
13437 }
13438 }
13439
13440 //send down a req
13441 if(pPeStatsReqListEntry->periodicity &&
13442 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
13443 {
13444 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
13445 if(ePMC_FULL_POWER == powerState)
13446 {
13447 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
13448 {
13449 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
13450 }
13451 }
13452 else
13453 {
13454 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
13455 {
13456 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
13457 }
13458 }
13459 //start timer
13460 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
13461 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13462 {
13463 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer\n"));
13464 return;
13465 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013466 pPeStatsReqListEntry->timerRunning = TRUE;
13467
13468 }
13469
13470 }
13471}
Jeff Johnson295189b2012-06-20 16:38:30 -070013472void csrRoamStatsClientTimerHandler(void *pv)
13473{
13474 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070013475 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
13476 {
13477#if 0
13478 // TODO Stats fix for multisession
13479 //start the timer
13480 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
13481
13482 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
13483 {
13484 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013485 }
13486#endif
13487 }
13488#if 0
13489 //send up the stats report
13490 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
13491 pStaEntry->staId, pStaEntry->pContext);
13492#endif
13493}
13494
13495
13496
Jeff Johnson295189b2012-06-20 16:38:30 -070013497eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
13498{
13499 tAniGetPEStatsReq *pMsg;
13500 eHalStatus status = eHAL_STATUS_SUCCESS;
13501 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetPEStatsReq));
13502 if ( !HAL_STATUS_SUCCESS(status) )
13503 {
13504 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to allocate mem for stats req \n");
13505 return status;
13506 }
13507 // need to initiate a stats request to PE
13508 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
13509 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
13510 pMsg->staId = staId;
13511 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070013512 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013513 if(!HAL_STATUS_SUCCESS(status))
13514 {
13515 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to send down the stats req \n");
13516 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013517 return status;
13518}
Jeff Johnson295189b2012-06-20 16:38:30 -070013519void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
13520{
13521 tAniGetPEStatsRsp *pSmeStatsRsp;
13522 eHalStatus status = eHAL_STATUS_FAILURE;
13523 tListElem *pEntry = NULL;
13524 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
13525 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
13526 tANI_U32 tempMask = 0;
13527 tANI_U8 counter = 0;
13528 tANI_U8 *pStats = NULL;
13529 tANI_U32 length = 0;
13530 v_PVOID_t pvosGCtx;
13531 v_S7_t rssi = 0;
13532 tANI_U32 *pRssi = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013533 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
13534 if(pSmeStatsRsp->rc)
13535 {
13536 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure\n"));
13537 goto post_update;
13538 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013539 tempMask = pSmeStatsRsp->statsMask;
13540 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070013541 /* subtract all statistics from this length, and after processing the entire
13542 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
13543 * in this 'stats' message.
13544 */
13545 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070013546 //new stats info from PE, fill up the stats strucutres in PMAC
13547 while(tempMask)
13548 {
13549 if(tempMask & 1)
13550 {
13551 switch(counter)
13552 {
13553 case eCsrSummaryStats:
Mohit Khanna23863762012-09-11 17:40:09 -070013554 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013555 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
13556 pStats, sizeof(tCsrSummaryStatsInfo));
13557 if(!HAL_STATUS_SUCCESS(status))
13558 {
13559 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy summary stats\n"));
13560 }
13561 pStats += sizeof(tCsrSummaryStatsInfo);
13562 length -= sizeof(tCsrSummaryStatsInfo);
13563 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013564 case eCsrGlobalClassAStats:
Mohit Khanna23863762012-09-11 17:40:09 -070013565 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013566 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classAStatsInfo,
13567 pStats, sizeof(tCsrGlobalClassAStatsInfo));
13568 if(!HAL_STATUS_SUCCESS(status))
13569 {
13570 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassA stats\n"));
13571 }
13572 pStats += sizeof(tCsrGlobalClassAStatsInfo);
13573 length -= sizeof(tCsrGlobalClassAStatsInfo);
13574 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013575 case eCsrGlobalClassBStats:
Mohit Khanna23863762012-09-11 17:40:09 -070013576 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013577 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classBStatsInfo,
13578 pStats, sizeof(tCsrGlobalClassBStatsInfo));
13579 if(!HAL_STATUS_SUCCESS(status))
13580 {
13581 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassB stats\n"));
13582 }
13583 pStats += sizeof(tCsrGlobalClassBStatsInfo);
13584 length -= sizeof(tCsrGlobalClassBStatsInfo);
13585 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013586 case eCsrGlobalClassCStats:
Mohit Khanna23863762012-09-11 17:40:09 -070013587 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013588 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.classCStatsInfo,
13589 pStats, sizeof(tCsrGlobalClassCStatsInfo));
13590 if(!HAL_STATUS_SUCCESS(status))
13591 {
13592 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy ClassC stats\n"));
13593 }
13594 pStats += sizeof(tCsrGlobalClassCStatsInfo);
13595 length -= sizeof(tCsrGlobalClassCStatsInfo);
13596 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013597 case eCsrPerStaStats:
Mohit Khanna23863762012-09-11 17:40:09 -070013598 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013599 if( CSR_MAX_STA > pSmeStatsRsp->staId )
13600 {
13601 status = palCopyMemory(pMac->hHdd, (tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
13602 pStats, sizeof(tCsrPerStaStatsInfo));
13603 }
13604 else
13605 {
13606 status = eHAL_STATUS_FAILURE;
13607 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d\n"), pSmeStatsRsp->staId);
13608 VOS_ASSERT( 0 );
13609 }
13610 if(!HAL_STATUS_SUCCESS(status))
13611 {
13612 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats\n"));
13613 }
13614 pStats += sizeof(tCsrPerStaStatsInfo);
13615 length -= sizeof(tCsrPerStaStatsInfo);
13616 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013617 default:
13618 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type\n"));
13619 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013620 }
13621 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013622 tempMask >>=1;
13623 counter++;
13624 }
13625 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
13626 if (length != 0)
13627 {
13628 pRssi = (tANI_U32*)pStats;
13629 rssi = (v_S7_t)*pRssi;
13630 }
13631 else
13632 {
13633 /* If riva is not sending rssi, continue to use the hack */
13634 rssi = RSSI_HACK_BMPS;
13635 }
13636 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Jeff Johnson295189b2012-06-20 16:38:30 -070013637post_update:
13638 //make sure to update the pe stats req list
13639 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
13640 if(pEntry)
13641 {
13642 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
13643 pPeStaEntry->rspPending = FALSE;
13644
13645 }
13646 //check the one timer cases
13647 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
13648 if(pEntry)
13649 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013650 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013651 if(pTempStaEntry->timerExpired)
13652 {
13653 //send up the stats report
13654 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
13655 pTempStaEntry->staId, pTempStaEntry->pContext);
13656 //also remove from the client list
13657 csrRoamRemoveStatListEntry(pMac, pEntry);
13658 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013659 }
13660 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013661}
Jeff Johnson295189b2012-06-20 16:38:30 -070013662tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
13663{
13664 tListElem *pEntry = NULL;
13665 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013666 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070013667 if(!pEntry)
13668 {
13669 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070013670 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE\n");
Jeff Johnson295189b2012-06-20 16:38:30 -070013671 return NULL;
13672 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013673 while( pEntry )
13674 {
13675 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013676 if(pTempStaEntry->statsMask == statsMask)
13677 {
Mohit Khanna23863762012-09-11 17:40:09 -070013678 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found\n");
Jeff Johnson295189b2012-06-20 16:38:30 -070013679 break;
13680 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013681 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
13682 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013683 return pEntry;
13684}
13685
Jeff Johnson295189b2012-06-20 16:38:30 -070013686tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
13687 tANI_BOOLEAN update)
13688{
13689 tListElem *pEntry;
13690 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070013691 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070013692 if(!pEntry)
13693 {
13694 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070013695 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Jeff Johnson295189b2012-06-20 16:38:30 -070013696 "upper layer client(s)\n");
13697 return NULL;
13698 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013699 while( pEntry )
13700 {
13701 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013702 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
13703 (pTempStaEntry->statsMask == pStaEntry->statsMask))
13704 {
Mohit Khanna23863762012-09-11 17:40:09 -070013705 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found\n");
Jeff Johnson295189b2012-06-20 16:38:30 -070013706 if(update)
13707 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013708 pTempStaEntry->periodicity = pStaEntry->periodicity;
13709 pTempStaEntry->callback = pStaEntry->callback;
13710 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070013711 }
13712 break;
13713 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013714 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
13715 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013716 return pEntry;
13717}
Jeff Johnson295189b2012-06-20 16:38:30 -070013718tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
13719{
13720 tListElem *pEntry;
13721 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070013722 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070013723 if(!pEntry)
13724 {
13725 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070013726 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Jeff Johnson295189b2012-06-20 16:38:30 -070013727 "upper layer client(s)\n");
13728 return NULL;
13729 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013730 while( pEntry )
13731 {
13732 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070013733 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
13734 {
Mohit Khanna23863762012-09-11 17:40:09 -070013735 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found\n");
Jeff Johnson295189b2012-06-20 16:38:30 -070013736 break;
13737 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013738 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
13739 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013740 return pEntry;
13741}
Jeff Johnson295189b2012-06-20 16:38:30 -070013742eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
13743 csrRoamLinkQualityIndCallback callback,
13744 void *pContext)
13745{
13746 pMac->roam.linkQualityIndInfo.callback = callback;
13747 pMac->roam.linkQualityIndInfo.context = pContext;
13748 if( NULL == callback )
13749 {
13750 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
13751 }
13752 else
13753 {
13754 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070013755 /* do we need to invoke the callback to notify client of initial value ?? */
13756 }
13757 return eHAL_STATUS_SUCCESS;
13758}
Jeff Johnson295189b2012-06-20 16:38:30 -070013759void csrRoamVccTrigger(tpAniSirGlobal pMac)
13760{
13761 eCsrRoamLinkQualityInd newVccLinkQuality;
13762 tANI_U32 ul_mac_loss = 0;
13763 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070013764 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
13765 /*-------------------------------------------------------------------------
13766 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070013767 Check for a change in link quality and notify client if necessary
13768 -------------------------------------------------------------------------*/
13769 ul_mac_loss_trigger_threshold =
13770 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070013771 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013772 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d\n",
13773 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070013774 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
13775 {
13776 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR \n");
13777 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
13778 }
13779 else
13780 {
13781 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD\n");
13782 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
13783 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013784 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
13785 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070013786 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
13787 {
13788 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary\n");
13789 if(NULL != pMac->roam.linkQualityIndInfo.callback)
13790 {
13791 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d\n",
13792 newVccLinkQuality );
13793
13794 /* we now invoke the callback once to notify client of initial value */
13795 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
13796 pMac->roam.linkQualityIndInfo.context );
13797 //event: EVENT_WLAN_VCC
13798 }
13799 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013800 pMac->roam.vccLinkQuality = newVccLinkQuality;
13801
Jeff Johnson295189b2012-06-20 16:38:30 -070013802}
Jeff Johnson295189b2012-06-20 16:38:30 -070013803VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
13804 v_U8_t rssiNotification,
13805 void * context)
13806{
13807 tpAniSirGlobal pMac = PMAC_STRUCT( context );
13808 eCsrRoamLinkQualityInd newVccLinkQuality;
13809 // TODO : Session info unavailable
13810 tANI_U32 sessionId = 0;
13811 VOS_STATUS status = VOS_STATUS_SUCCESS;
13812 /*-------------------------------------------------------------------------
13813 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070013814 Check for a change in link quality and notify client if necessary
13815 -------------------------------------------------------------------------*/
13816 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d\n",
13817 pMac->roam.configParam.vccRssiThreshold);
13818 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
13819 {
13820 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected\n");
13821 return VOS_STATUS_SUCCESS;
13822 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013823 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
13824 {
13825 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR\n");
13826 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
13827 }
13828 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
13829 {
13830 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD \n");
13831 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
13832 }
13833 else
13834 {
13835 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d\n", rssiNotification);
13836 //Set to this so the code below won't do anything
13837 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070013838 VOS_ASSERT(0);
13839 }
13840
Jeff Johnson295189b2012-06-20 16:38:30 -070013841 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
13842 {
13843 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary\n");
13844 if(NULL != pMac->roam.linkQualityIndInfo.callback)
13845 {
13846 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d\n",
13847 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070013848 /* we now invoke the callback once to notify client of initial value */
13849 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
13850 pMac->roam.linkQualityIndInfo.context );
13851 //event: EVENT_WLAN_VCC
13852 }
13853 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013854 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070013855 return status;
13856}
Jeff Johnson295189b2012-06-20 16:38:30 -070013857tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
13858 tDblLinkList *pStaList,
13859 tCsrStatsClientReqInfo *pStaEntry)
13860{
13861 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013862 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013863 //if same entity requested for same set of stats with different periodicity &
13864 // callback update it
13865 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
13866 {
13867
13868 status = palAllocateMemory(pMac->hHdd, (void **)&pNewStaEntry, sizeof(tCsrStatsClientReqInfo));
13869 if (!HAL_STATUS_SUCCESS(status))
13870 {
13871 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
13872 "entry\n");
13873 return NULL;
13874 }
13875
Jeff Johnson295189b2012-06-20 16:38:30 -070013876 pNewStaEntry->callback = pStaEntry->callback;
13877 pNewStaEntry->pContext = pStaEntry->pContext;
13878 pNewStaEntry->periodicity = pStaEntry->periodicity;
13879 pNewStaEntry->requesterId = pStaEntry->requesterId;
13880 pNewStaEntry->statsMask = pStaEntry->statsMask;
13881 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
13882 pNewStaEntry->pMac = pStaEntry->pMac;
13883 pNewStaEntry->staId = pStaEntry->staId;
13884 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
13885
13886 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
13887 }
13888 return pNewStaEntry;
13889}
13890
Jeff Johnson295189b2012-06-20 16:38:30 -070013891tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
13892 tDblLinkList *pStaList,
13893 tCsrPeStatsReqInfo *pStaEntry)
13894{
13895 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013896 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013897 status = palAllocateMemory(pMac->hHdd, (void **)&pNewStaEntry, sizeof(tCsrPeStatsReqInfo));
13898 if (!HAL_STATUS_SUCCESS(status))
13899 {
13900 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
13901 "entry\n");
13902 return NULL;
13903 }
13904
Jeff Johnson295189b2012-06-20 16:38:30 -070013905 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
13906 pNewStaEntry->numClient = pStaEntry->numClient;
13907 pNewStaEntry->periodicity = pStaEntry->periodicity;
13908 pNewStaEntry->statsMask = pStaEntry->statsMask;
13909 pNewStaEntry->pMac = pStaEntry->pMac;
13910 pNewStaEntry->staId = pStaEntry->staId;
13911 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
13912 pNewStaEntry->rspPending = pStaEntry->rspPending;
13913
13914 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070013915 return pNewStaEntry;
13916}
Jeff Johnson295189b2012-06-20 16:38:30 -070013917eHalStatus csrGetRssi(tpAniSirGlobal pMac,
13918 tCsrRssiCallback callback,
13919 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
13920{
13921 eHalStatus status = eHAL_STATUS_SUCCESS;
13922 vos_msg_t msg;
13923 tANI_U32 sessionId;
13924
13925 tAniGetRssiReq *pMsg;
13926 smsLog(pMac, LOG2, FL("called"));
13927 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetRssiReq));
13928 if ( !HAL_STATUS_SUCCESS(status) )
13929 {
13930 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req \n");
13931 return status;
13932 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013933 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
13934
13935 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
13936 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
13937 pMsg->sessionId = sessionId;
13938 pMsg->staId = staId;
13939 pMsg->rssiCallback = callback;
13940 pMsg->pDevContext = pContext;
13941 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070013942 msg.type = eWNI_SME_GET_RSSI_REQ;
13943 msg.bodyptr = pMsg;
13944 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013945 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
13946 {
13947 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self \n");
13948 palFreeMemory(pMac->hHdd, (void *)pMsg);
13949 status = eHAL_STATUS_FAILURE;
13950 }
13951 smsLog(pMac, LOG2, FL("returned"));
13952 return status;
13953}
Jeff Johnson295189b2012-06-20 16:38:30 -070013954eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
13955 tANI_U32 statsMask,
13956 tCsrStatsCallback callback,
13957 tANI_U32 periodicity, tANI_BOOLEAN cache,
13958 tANI_U8 staId, void *pContext)
13959{
13960 tCsrStatsClientReqInfo staEntry;
13961 tCsrStatsClientReqInfo *pStaEntry = NULL;
13962 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
13963 tListElem *pEntry = NULL;
13964 tANI_BOOLEAN found = FALSE;
13965 eHalStatus status = eHAL_STATUS_SUCCESS;
13966 tANI_BOOLEAN insertInClientList = FALSE;
13967 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070013968 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070013969
13970 if( csrIsAllSessionDisconnected(pMac) )
13971 {
13972 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected\n", pMac->roam.curState);
13973 return eHAL_STATUS_FAILURE;
13974 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013975 if((!statsMask) && (!callback))
13976 {
13977 //msg
13978 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request\n");
13979 return eHAL_STATUS_FAILURE;
13980 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013981 //for the search list method for deregister
13982 staEntry.requesterId = requesterId;
13983 staEntry.statsMask = statsMask;
13984 //requester wants to deregister or just an error
13985 if((statsMask) && (!callback))
13986 {
13987 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
13988 if(!pEntry)
13989 {
13990 //msg
13991 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
13992 "find any existing request in statsClientReqList\n");
13993 return eHAL_STATUS_FAILURE;
13994 }
13995 else
13996 {
13997 //clean up & return
13998 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070013999 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070014000 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014001 pStaEntry->pPeStaEntry->numClient--;
14002 //check if we need to delete the entry from peStatsReqList too
14003 if(!pStaEntry->pPeStaEntry->numClient)
14004 {
14005 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
14006 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014007 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070014008
Jeff Johnson295189b2012-06-20 16:38:30 -070014009 //check if we need to stop the tl stats timer too
14010 pMac->roam.tlStatsReqInfo.numClient--;
14011 if(!pMac->roam.tlStatsReqInfo.numClient)
14012 {
14013 if(pMac->roam.tlStatsReqInfo.timerRunning)
14014 {
14015 status = palTimerStop(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
14016 if(!HAL_STATUS_SUCCESS(status))
14017 {
14018 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer\n"));
14019 return eHAL_STATUS_FAILURE;
14020 }
14021 }
14022 pMac->roam.tlStatsReqInfo.periodicity = 0;
14023 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14024 }
14025 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070014026 // Destroy the vos timer...
14027 vosStatus = vos_timer_destroy( &pStaEntry->timer );
14028 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14029 {
14030 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer\n"));
14031 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014032 csrRoamRemoveStatListEntry(pMac, pEntry);
14033 pStaEntry = NULL;
14034 return eHAL_STATUS_SUCCESS;
14035 }
14036 }
14037
14038 if(cache && !periodicity)
14039 {
14040 //return the cached stats
14041 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
14042 }
14043 else
14044 {
14045 //add the request in the client req list
14046 staEntry.callback = callback;
14047 staEntry.pContext = pContext;
14048 staEntry.periodicity = periodicity;
14049 staEntry.pPeStaEntry = NULL;
14050 staEntry.staId = staId;
14051 staEntry.pMac = pMac;
14052 staEntry.timerExpired = FALSE;
14053
14054
Jeff Johnson295189b2012-06-20 16:38:30 -070014055 //if periodic report requested with non cached result from PE/TL
14056 if(periodicity)
14057 {
14058
14059 //if looking for stats from PE
14060 if(statsMask & ~(1 << eCsrGlobalClassDStats))
14061 {
14062
14063 //check if same request made already & waiting for rsp
14064 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
14065 periodicity, &found, staId);
14066 if(!pPeStaEntry)
14067 {
14068 //bail out, maxed out on number of req for PE
14069 return eHAL_STATUS_FAILURE;
14070 }
14071 else
14072 {
14073 staEntry.pPeStaEntry = pPeStaEntry;
14074 }
14075
14076 }
14077 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
14078 if(statsMask & (1 << eCsrGlobalClassDStats))
14079 {
14080 if(cache && pMac->roam.tlStatsReqInfo.numClient)
14081 {
14082 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL\n"));
14083 }
14084 else
14085 {
14086
14087 //update periodicity
14088 if(pMac->roam.tlStatsReqInfo.periodicity)
14089 {
14090 pMac->roam.tlStatsReqInfo.periodicity =
14091 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
14092 }
14093 else
14094 {
14095 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
14096 }
14097 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
14098 {
14099 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
14100 }
14101
14102 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14103 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014104 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
14105 if(NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014106 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014107 //req TL for class D stats
14108 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
14109 {
14110 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL\n"));
14111 }
14112 else
14113 {
14114 //save in SME
14115 csrRoamSaveStatsFromTl(pMac, pTlStats);
14116 }
14117 vos_mem_free(pTlStats);
14118 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014119 }
14120 else
14121 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014122 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014123 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014124
Jeff Johnson295189b2012-06-20 16:38:30 -070014125 if(pMac->roam.tlStatsReqInfo.periodicity)
14126 {
14127 //start timer
14128 status = palTimerStart(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14129 pMac->roam.tlStatsReqInfo.periodicity * PAL_TIMER_TO_MS_UNIT, eANI_BOOLEAN_FALSE);
14130 if(!HAL_STATUS_SUCCESS(status))
14131 {
14132 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer\n"));
14133 return eHAL_STATUS_FAILURE;
14134 }
14135 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14136 }
14137 }
14138 }
14139 pMac->roam.tlStatsReqInfo.numClient++;
14140 }
14141
14142 insertInClientList = TRUE;
14143 }
14144 //if one time report requested with non cached result from PE/TL
14145 else if(!cache && !periodicity)
14146 {
14147 if(statsMask & ~(1 << eCsrGlobalClassDStats))
14148 {
14149 //send down a req
14150 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
14151 if(!HAL_STATUS_SUCCESS(status))
14152 {
14153 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE\n"));
14154 }
14155 //so that when the stats rsp comes back from PE we respond to upper layer
14156 //right away
14157 staEntry.timerExpired = TRUE;
14158 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014159 }
14160 if(statsMask & (1 << eCsrGlobalClassDStats))
14161 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014162 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
14163 if(NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014164 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014165 //req TL for class D stats
14166 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
14167 {
14168 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL\n"));
14169 }
14170 else
14171 {
14172 //save in SME
14173 csrRoamSaveStatsFromTl(pMac, pTlStats);
14174 }
14175 vos_mem_free(pTlStats);
14176 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014177 }
14178 else
14179 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014180 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014181 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014182
14183 }
14184 //if looking for stats from TL only
14185 if(!insertInClientList)
14186 {
14187 //return the stats
14188 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
14189 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014190 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014191 if(insertInClientList)
14192 {
14193 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
14194 if(!pStaEntry)
14195 {
14196 //msg
14197 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList\n");
14198 return eHAL_STATUS_FAILURE;
14199 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014200 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070014201 //Init & start timer if needed
14202 if(periodicity)
14203 {
14204 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
14205 csrRoamStatsClientTimerHandler, pStaEntry );
14206 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14207 {
14208 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer\n"));
14209 return eHAL_STATUS_FAILURE;
14210 }
14211 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
14212 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14213 {
14214 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer\n"));
14215 return eHAL_STATUS_FAILURE;
14216 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014217 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014218 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014219 }
14220 return eHAL_STATUS_SUCCESS;
14221}
14222
Jeff Johnson295189b2012-06-20 16:38:30 -070014223tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
14224 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
14225{
14226 tANI_BOOLEAN found = FALSE;
14227 eHalStatus status = eHAL_STATUS_SUCCESS;
14228 tCsrPeStatsReqInfo staEntry;
14229 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
14230 tListElem *pStaEntry = NULL;
14231 VOS_STATUS vosStatus;
14232 tPmcPowerState powerState;
14233 *pFound = FALSE;
14234
14235 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
14236 if(pStaEntry)
14237 {
14238 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
14239 if(pTempStaEntry->periodicity)
14240 {
14241 pTempStaEntry->periodicity =
14242 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
14243 }
14244 else
14245 {
14246 pTempStaEntry->periodicity = periodicity;
14247 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014248 pTempStaEntry->numClient++;
14249 found = TRUE;
14250 }
14251 else
14252 {
14253 palZeroMemory(pMac->hHdd, &staEntry, sizeof(tCsrPeStatsReqInfo));
14254 staEntry.numClient = 1;
14255 staEntry.periodicity = periodicity;
14256 staEntry.pMac = pMac;
14257 staEntry.rspPending = FALSE;
14258 staEntry.staId = staId;
14259 staEntry.statsMask = statsMask;
14260 staEntry.timerRunning = FALSE;
14261 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
14262 if(!pTempStaEntry)
14263 {
14264 //msg
14265 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList\n");
14266 return NULL;
14267 }
14268 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014269 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
14270 if(ePMC_FULL_POWER == powerState)
14271 {
14272 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
14273 {
14274 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
14275 }
14276 }
14277 else
14278 {
14279 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
14280 {
14281 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
14282 }
14283 }
14284 if(!pTempStaEntry->timerRunning)
14285 {
14286 //send down a req in case of one time req, for periodic ones wait for timer to expire
14287 if(!pTempStaEntry->rspPending &&
14288 !pTempStaEntry->periodicity)
14289 {
14290 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
14291 if(!HAL_STATUS_SUCCESS(status))
14292 {
14293 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE\n"));
14294 }
14295 else
14296 {
14297 pTempStaEntry->rspPending = TRUE;
14298 }
14299 }
14300 if(pTempStaEntry->periodicity)
14301 {
14302 if(!found)
14303 {
14304
14305 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
14306 csrRoamPeStatsTimerHandler, pTempStaEntry );
14307 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14308 {
14309 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer\n"));
14310 return NULL;
14311 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014312 }
14313 //start timer
14314 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d\n", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070014315 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
14316 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14317 {
14318 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer\n"));
14319 return NULL;
14320 }
14321 pTempStaEntry->timerRunning = TRUE;
14322 }
14323 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014324 *pFound = found;
14325 return pTempStaEntry;
14326}
14327
Jeff Johnson295189b2012-06-20 16:38:30 -070014328/*
14329 pStaEntry is no longer invalid upon the return of this function.
14330*/
14331static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
14332{
14333 if(pEntry)
14334 {
14335 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
14336 {
14337 palFreeMemory(pMac->hHdd, GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070014338 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014339 }
14340 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014341
14342void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
14343{
14344 tListElem *pEntry;
14345 tCsrPeStatsReqInfo *pTempStaEntry;
14346 VOS_STATUS vosStatus;
14347 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014348 if(!pEntry)
14349 {
14350 //list empty
14351 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: List empty, no stats req for PE\n");
14352 return;
14353 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014354 while( pEntry )
14355 {
14356 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014357 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
14358 {
14359 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: match found\n");
14360 if(pTempStaEntry->timerRunning)
14361 {
14362 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
14363 /* If we are not able to stop the timer here, just remove
14364 * the entry from the linked list. Destroy the timer object
14365 * and free the memory in the timer CB
14366 */
14367 if( vosStatus == VOS_STATUS_SUCCESS )
14368 {
14369 /* the timer is successfully stopped */
14370 pTempStaEntry->timerRunning = FALSE;
14371
14372 /* Destroy the timer */
14373 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
14374 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14375 {
14376 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer\n"));
14377 }
14378 }
14379 else
14380 {
14381 // the timer could not be stopped. Hence destroy and free the
14382 // memory for the PE stat entry in the timer CB.
14383 pTempStaEntry->timerStopFailed = TRUE;
14384 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014385 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014386
14387 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
14388 {
14389 // Only free the memory if we could stop the timer successfully
14390 if(!pTempStaEntry->timerStopFailed)
14391 {
14392 palFreeMemory(pMac->hHdd, pTempStaEntry);
14393 pTempStaEntry = NULL;
14394 }
14395 break;
14396 }
14397
14398 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
14399 }
14400 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014401 return;
14402}
14403
14404
Jeff Johnsone7245742012-09-05 17:12:55 -070014405void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070014406{
14407
Jeff Johnsone7245742012-09-05 17:12:55 -070014408 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
14409 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
14410 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
14411 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
14412 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
14413 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
14414 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070014415 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070014416 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
14417 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
14418 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
14419 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
14420 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
14421 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070014422 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070014423 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
14424 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070014425
14426}
14427
Jeff Johnson295189b2012-06-20 16:38:30 -070014428void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
14429 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
14430{
14431 tANI_U8 stats[500];
14432 tANI_U8 *pStats = NULL;
14433 tANI_U32 tempMask = 0;
14434 tANI_U8 counter = 0;
14435 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014436 if(!callback)
14437 {
14438 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report callback NULL\n"));
14439 return;
14440 }
14441 if(!statsMask)
14442 {
14443 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report statsMask is 0\n"));
14444 return;
14445 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014446 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070014447 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070014448 while(tempMask)
14449 {
14450 if(tempMask & 1)
14451 {
14452 //new stats info from PE, fill up the stats strucutres in PMAC
14453 switch(counter)
14454 {
14455 case eCsrSummaryStats:
Mohit Khanna23863762012-09-11 17:40:09 -070014456 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:summary stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014457 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
14458 sizeof(tCsrSummaryStatsInfo));
14459 if(!HAL_STATUS_SUCCESS(status))
14460 {
14461 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy summary stats\n"));
14462 }
14463 pStats += sizeof(tCsrSummaryStatsInfo);
14464 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014465 case eCsrGlobalClassAStats:
Mohit Khanna23863762012-09-11 17:40:09 -070014466 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassA stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014467 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
14468 sizeof(tCsrGlobalClassAStatsInfo));
14469 if(!HAL_STATUS_SUCCESS(status))
14470 {
14471 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassA stats\n"));
14472 }
14473 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070014474 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014475 case eCsrGlobalClassBStats:
Mohit Khanna23863762012-09-11 17:40:09 -070014476 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassB stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014477 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
14478 sizeof(tCsrGlobalClassBStatsInfo));
14479 if(!HAL_STATUS_SUCCESS(status))
14480 {
14481 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassB stats\n"));
14482 }
14483 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070014484 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014485 case eCsrGlobalClassCStats:
Mohit Khanna23863762012-09-11 17:40:09 -070014486 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassC stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014487 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
14488 sizeof(tCsrGlobalClassCStatsInfo));
14489 if(!HAL_STATUS_SUCCESS(status))
14490 {
14491 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassC stats\n"));
14492 }
14493 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070014494 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014495 case eCsrGlobalClassDStats:
Mohit Khanna23863762012-09-11 17:40:09 -070014496 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassD stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014497 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
14498 sizeof(tCsrGlobalClassDStatsInfo));
14499 if(!HAL_STATUS_SUCCESS(status))
14500 {
14501 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy ClassD stats\n"));
14502 }
14503 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070014504 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014505 case eCsrPerStaStats:
Mohit Khanna23863762012-09-11 17:40:09 -070014506 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:PerSta stats\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014507 status = palCopyMemory(pMac->hHdd, pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
14508 sizeof(tCsrPerStaStatsInfo));
14509 if(!HAL_STATUS_SUCCESS(status))
14510 {
14511 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:failed to copy PerSta stats\n"));
14512 }
14513 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070014514 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014515 default:
14516 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:unknown stats type\n"));
14517 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014518 }
14519 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014520 tempMask >>=1;
14521 counter++;
14522 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014523 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070014524}
14525
Jeff Johnson295189b2012-06-20 16:38:30 -070014526eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
14527{
14528 tListElem *pEntry = NULL;
14529 tListElem *pPrevEntry = NULL;
14530 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
14531 eHalStatus status = eHAL_STATUS_SUCCESS;
14532 VOS_STATUS vosStatus;
14533 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014534 if(!pEntry)
14535 {
14536 //list empty
14537 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
14538 "upper layer client(s)\n");
14539 return status;
14540 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014541 while( pEntry )
14542 {
14543 if(pPrevEntry)
14544 {
14545 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
14546 //send up the stats report
14547 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
14548 pTempStaEntry->staId, pTempStaEntry->pContext);
14549 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
14550 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014551 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014552 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
14553 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014554 pTempStaEntry->pPeStaEntry->numClient--;
14555 //check if we need to delete the entry from peStatsReqList too
14556 if(!pTempStaEntry->pPeStaEntry->numClient)
14557 {
14558 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
14559 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014560 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014561 //check if we need to stop the tl stats timer too
14562 pMac->roam.tlStatsReqInfo.numClient--;
14563 if(!pMac->roam.tlStatsReqInfo.numClient)
14564 {
14565 if(pMac->roam.tlStatsReqInfo.timerRunning)
14566 {
14567 status = palTimerStop(pMac->hHdd, pMac->roam.tlStatsReqInfo.hTlStatsTimer);
14568 if(!HAL_STATUS_SUCCESS(status))
14569 {
14570 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer\n"));
14571 //we will continue
14572 }
14573 }
14574 pMac->roam.tlStatsReqInfo.periodicity = 0;
14575 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14576 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014577 if (pTempStaEntry->periodicity)
14578 {
14579 //While creating StaEntry in csrGetStatistics,
14580 //Initializing and starting timer only when periodicity is set.
14581 //So Stop and Destroy timer only when periodicity is set.
14582
Jeff Johnsone7245742012-09-05 17:12:55 -070014583 vos_timer_stop( &pTempStaEntry->timer );
14584 // Destroy the vos timer...
14585 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
14586 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14587 {
14588 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer\n"));
14589 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014590 }
Jeff Johnsone7245742012-09-05 17:12:55 -070014591
Jeff Johnson295189b2012-06-20 16:38:30 -070014592
14593 pPrevEntry = pEntry;
14594 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14595 }
14596 //the last one
14597 if(pPrevEntry)
14598 {
14599 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
14600 //send up the stats report
14601 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
14602 pTempStaEntry->staId, pTempStaEntry->pContext);
14603 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
14604 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014605 return status;
14606
14607}
14608
Jeff Johnson295189b2012-06-20 16:38:30 -070014609eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
14610 tRequestFullPowerReason *pReason,
14611 tANI_BOOLEAN *pfNeedPower )
14612{
14613 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
14614 tRequestFullPowerReason reason = eSME_REASON_OTHER;
14615 tPmcState pmcState;
14616 eHalStatus status = eHAL_STATUS_SUCCESS;
14617 // TODO : Session info unavailable
14618 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014619 if( pfNeedPower )
14620 {
14621 *pfNeedPower = eANI_BOOLEAN_FALSE;
14622 }
14623 //We only handle CSR commands
14624 if( !(eSmeCsrCommandMask & pCommand->command) )
14625 {
14626 return eHAL_STATUS_SUCCESS;
14627 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014628 //Check PMC state first
14629 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070014630 switch( pmcState )
14631 {
14632 case REQUEST_IMPS:
14633 case IMPS:
14634 if( eSmeCommandScan == pCommand->command )
14635 {
14636 switch( pCommand->u.scanCmd.reason )
14637 {
14638 case eCsrScanGetResult:
14639 case eCsrScanBGScanAbort:
14640 case eCsrScanBGScanEnable:
14641 case eCsrScanGetScanChnInfo:
14642 //Internal process, no need for full power
14643 fNeedFullPower = eANI_BOOLEAN_FALSE;
14644 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014645 default:
14646 //Other scans are real scan, ask for power
14647 fNeedFullPower = eANI_BOOLEAN_TRUE;
14648 break;
14649 } //switch
14650 }
14651 else
14652 {
14653 //ask for power for roam and status change
14654 fNeedFullPower = eANI_BOOLEAN_TRUE;
14655 }
14656 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014657 case REQUEST_BMPS:
14658 case BMPS:
14659 case REQUEST_START_UAPSD:
14660 case UAPSD:
14661 //We treat WOWL same as BMPS
14662 case REQUEST_ENTER_WOWL:
14663 case WOWL:
14664 if( eSmeCommandRoam == pCommand->command )
14665 {
14666 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
14667 tCsrScanResult *pScanResult;
14668 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014669 switch ( pCommand->u.roamCmd.roamReason )
14670 {
14671 case eCsrForcedDisassoc:
14672 case eCsrForcedDisassocMICFailure:
14673 reason = eSME_LINK_DISCONNECTED_BY_HDD;
14674 fNeedFullPower = eANI_BOOLEAN_TRUE;
14675 break;
14676 case eCsrSmeIssuedDisassocForHandoff:
14677 case eCsrForcedDeauth:
14678 case eCsrHddIssuedReassocToSameAP:
14679 case eCsrSmeIssuedReassocToSameAP:
14680 fNeedFullPower = eANI_BOOLEAN_TRUE;
14681 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014682 case eCsrCapsChange:
14683 fNeedFullPower = eANI_BOOLEAN_TRUE;
14684 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014685 default:
14686 //Check whether the profile is already connected. If so, no need for full power
14687 //Note: IBSS is ignored for now because we don't support powersave in IBSS
14688 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
14689 {
14690 //Only need to check the first one
14691 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
14692 if( pEntry )
14693 {
14694 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
14695#if 0
14696 // TODO : Session Specific info pConnectBssDesc
14697 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
14698 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
14699 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
14700 {
14701 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
14702 // with Authenticating first. To force this, stop the current association (Disassociate) and
14703 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
14704 // a new Association.
14705 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
14706 {
14707 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
14708 {
14709 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
14710 //No need for full power
14711 //Set the flag so the code later can avoid to do the above
14712 //check again.
14713 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
14714 break;
14715 }
14716 }
14717 }
14718#endif
14719 }
14720 }
14721 //If we are here, full power is needed
14722 fNeedFullPower = eANI_BOOLEAN_TRUE;
14723 break;
14724 }
14725 }
14726 else if( eSmeCommandWmStatusChange == pCommand->command )
14727 {
14728 //need full power for all
14729 fNeedFullPower = eANI_BOOLEAN_TRUE;
14730 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
14731 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014732#ifdef FEATURE_WLAN_TDLS
14733 else if( eSmeCommandTdlsAddPeer == pCommand->command )
14734 {
14735 //TDLS link is getting established. need full power
14736 fNeedFullPower = eANI_BOOLEAN_TRUE;
14737 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
14738 }
14739#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014740 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014741 case REQUEST_STOP_UAPSD:
14742 case REQUEST_EXIT_WOWL:
14743 if( eSmeCommandRoam == pCommand->command )
14744 {
14745 fNeedFullPower = eANI_BOOLEAN_TRUE;
14746 switch ( pCommand->u.roamCmd.roamReason )
14747 {
14748 case eCsrForcedDisassoc:
14749 case eCsrForcedDisassocMICFailure:
14750 reason = eSME_LINK_DISCONNECTED_BY_HDD;
14751 break;
14752 default:
14753 break;
14754 }
14755 }
14756 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014757 case STOPPED:
14758 case REQUEST_STANDBY:
14759 case STANDBY:
14760 case LOW_POWER:
14761 //We are not supposed to do anything
14762 smsLog( pMac, LOGE, FL( " cannot process because PMC is in stopped/standby state %d\n" ), pmcState );
14763 status = eHAL_STATUS_FAILURE;
14764 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014765 case FULL_POWER:
14766 case REQUEST_FULL_POWER:
14767 default:
14768 //No need to ask for full power. This has to be FULL_POWER state
14769 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014770 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070014771 if( pReason )
14772 {
14773 *pReason = reason;
14774 }
14775 if( pfNeedPower )
14776 {
14777 *pfNeedPower = fNeedFullPower;
14778 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014779 return ( status );
14780}
14781
Jeff Johnson295189b2012-06-20 16:38:30 -070014782static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14783{
14784 eHalStatus status = eHAL_STATUS_SUCCESS;
14785 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
14786 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070014787 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070014788 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
14789 {
14790 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
14791 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014792 return ( status );
14793}
14794
Jeff Johnson295189b2012-06-20 16:38:30 -070014795tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
14796{
14797 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070014798 if( pCmd )
14799 {
14800 pMac->roam.sPendingCommands++;
14801 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014802 return ( pCmd );
14803}
14804
Jeff Johnson295189b2012-06-20 16:38:30 -070014805void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
14806{
14807 if (pMac->roam.sPendingCommands > 0)
14808 {
14809 //All command allocated through csrGetCommandBuffer need to
14810 //decrement the pending count when releasing.
14811 pMac->roam.sPendingCommands--;
14812 smeReleaseCommand( pMac, pCommand );
14813 }
14814 else
14815 {
14816 smsLog(pMac, LOGE, FL( "no pending commands"));
14817 VOS_ASSERT(0);
14818 }
14819}
14820
Jeff Johnson295189b2012-06-20 16:38:30 -070014821//Return SUCCESS is the command is queued, failed
14822eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
14823{
14824 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014825 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
14826 {
14827 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
14828 pCommand->u.scanCmd.reason);
14829 return eHAL_STATUS_CSR_WRONG_STATE;
14830 }
14831
14832 //We can call request full power first before putting the command into pending Q
14833 //because we are holding SME lock at this point.
14834 status = csrRequestFullPower( pMac, pCommand );
14835 if( HAL_STATUS_SUCCESS( status ) )
14836 {
14837 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070014838 //make sure roamCmdPendingList is not empty first
14839 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
14840 if( fNoCmdPending )
14841 {
14842 smePushCommand( pMac, pCommand, fHighPriority );
14843 }
14844 else
14845 {
14846 //Other commands are waiting for PMC callback, queue the new command to the pending Q
14847 //no list lock is needed since SME lock is held
14848 if( !fHighPriority )
14849 {
14850 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
14851 }
14852 else {
14853 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
14854 }
14855 }
14856 }
14857 else if( eHAL_STATUS_PMC_PENDING == status )
14858 {
14859 //no list lock is needed since SME lock is held
14860 if( !fHighPriority )
14861 {
14862 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
14863 }
14864 else {
14865 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
14866 }
14867 //Let caller know the command is queue
14868 status = eHAL_STATUS_SUCCESS;
14869 }
14870 else
14871 {
14872 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
14873 //release the command.
14874 smsLog( pMac, LOGE, FL( " cannot queue command %d\n" ), pCommand->command );
14875 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014876 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014877}
Jeff Johnson295189b2012-06-20 16:38:30 -070014878eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
14879{
14880 eHalStatus status = eHAL_STATUS_SUCCESS;
14881 tSirUpdateAPWPSIEsReq *pMsg;
14882 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
14883
14884 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14885 if (NULL == pSession)
14886 {
14887 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
14888 return eHAL_STATUS_FAILURE;
14889 }
14890
Jeff Johnson295189b2012-06-20 16:38:30 -070014891 do
14892 {
14893 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirUpdateAPWPSIEsReq) );
14894 if (!HAL_STATUS_SUCCESS(status)) break;
14895 palZeroMemory( pMac->hHdd, pMsg, sizeof(tSirUpdateAPWPSIEsReq) );
14896 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
14897
14898 pBuf = (tANI_U8 *)&pMsg->transactionId;
14899 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014900 // transactionId
14901 *pBuf = 0;
14902 *( pBuf + 1 ) = 0;
14903 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014904 // bssId
14905 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
14906 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014907 //sessionId
14908 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014909 // APWPSIEs
14910 palCopyMemory( pMac->hHdd, (tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
14911 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070014912 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070014913 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014914 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014915 return ( status );
14916}
Jeff Johnson295189b2012-06-20 16:38:30 -070014917eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
14918{
14919 eHalStatus status = eHAL_STATUS_SUCCESS;
14920 tSirUpdateAPWPARSNIEsReq *pMsg;
14921 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014922 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14923 if (NULL == pSession)
14924 {
14925 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
14926 return eHAL_STATUS_FAILURE;
14927 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014928 do
14929 {
14930 status = palAllocateMemory( pMac->hHdd, (void **)&pMsg, sizeof(tSirUpdateAPWPARSNIEsReq) );
14931 if (!HAL_STATUS_SUCCESS(status)) break;
14932 palZeroMemory( pMac->hHdd, pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ) );
14933 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014934 pBuf = (tANI_U8 *)&pMsg->transactionId;
14935 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014936 // transactionId
14937 *pBuf = 0;
14938 *( pBuf + 1 ) = 0;
14939 pBuf += sizeof(tANI_U16);
14940
14941 // bssId
14942 palCopyMemory( pMac->hHdd, (tSirMacAddr *)pBuf, &pSession->selfMacAddr, sizeof(tSirMacAddr) );
14943 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014944 // sessionId
14945 *pBuf++ = (tANI_U8)sessionId;
14946
14947 // APWPARSNIEs
14948 palCopyMemory( pMac->hHdd, (tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
14949 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070014950 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070014951 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014952 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014953 return ( status );
14954}
Jeff Johnson295189b2012-06-20 16:38:30 -070014955
14956#ifdef WLAN_FEATURE_VOWIFI_11R
14957//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
14958eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
14959{
14960 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
14961 tpSirFTPreAuthReq pftPreAuthReq;
14962 tANI_U16 auth_req_len = 0;
14963 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014964 auth_req_len = sizeof(tSirFTPreAuthReq);
14965 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
14966 if (pftPreAuthReq == NULL)
14967 {
14968 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
14969 return eHAL_STATUS_RESOURCES;
14970 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014971 // Save the SME Session ID here. We need it while processing the preauth response
14972 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014973 vos_mem_zero(pftPreAuthReq, auth_req_len);
14974
14975 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
14976 sizeof(pBssDescription->length) + pBssDescription->length);
14977
14978 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
14979
14980 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
14981
Jeff Johnson295189b2012-06-20 16:38:30 -070014982 palCopyMemory(pMac->hHdd, (void *)&pftPreAuthReq->currbssId, (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014983 palCopyMemory(pMac->hHdd, (void *)&pftPreAuthReq->preAuthbssId, (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
14984
Jeff Johnson295189b2012-06-20 16:38:30 -070014985#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080014986 if (csrRoamIs11rAssoc(pMac) &&
14987 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070014988 {
14989 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
14990 palCopyMemory(pMac->hHdd, pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
14991 pMac->ft.ftSmeContext.auth_ft_ies_length);
14992 }
14993 else
14994#endif
14995 {
14996 pftPreAuthReq->ft_ies_length = 0;
14997 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070014998 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
14999 sizeof(pBssDescription->length) + pBssDescription->length);
15000 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070015001 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
15002}
Jeff Johnson295189b2012-06-20 16:38:30 -070015003/*--------------------------------------------------------------------------
15004 * This will receive and process the FT Pre Auth Rsp from the current
15005 * associated ap.
15006 *
15007 * This will invoke the hdd call back. This is so that hdd can now
15008 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
15009 ------------------------------------------------------------------------*/
15010void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
15011{
15012 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
15013 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015014#ifdef FEATURE_WLAN_LFR
15015 tCsrRoamInfo roamInfo;
15016#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015017
15018#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080015019 smsLog( pMac, LOGE, FL("Preauth response status code 0x%x"), pFTPreAuthRsp->status);
Jeff Johnson295189b2012-06-20 16:38:30 -070015020#endif
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070015021#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080015022 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070015023 if (status != eHAL_STATUS_SUCCESS) {
15024 /*
15025 * Bail out if pre-auth was not even processed.
15026 */
15027 smsLog(pMac, LOGW, FL("Preauth was not processed: %d"), status);
15028 return;
15029 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015030#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015031 /* The below function calls/timers should be invoked only if the pre-auth is successful */
15032 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
15033 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070015034 // Implies a success
15035 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015036 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
15037 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
15038 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070015039 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
15040 * actual transition from the current to handoff AP is triggered */
15041 status = palTimerStart(pMac->hHdd, pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
15042 60 * PAL_TIMER_TO_MS_UNIT,
15043 eANI_BOOLEAN_FALSE);
15044 if (eHAL_STATUS_SUCCESS != status)
15045 {
15046 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d\n"), status);
15047 return;
15048 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015049 // Save the received response
15050 palCopyMemory(pMac->hHdd, (void *)&pMac->ft.ftSmeContext.preAuthbssId, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
15051 if (csrRoamIs11rAssoc(pMac))
15052 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
15053 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
15054
15055 // Currently we dont do anything special for CCX connection.
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015056#ifdef FEATURE_WLAN_LFR
15057 // If Legacy Fast Roaming is enabled, signal the supplicant
15058 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053015059 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070015060 {
15061 // Save the bssid from the received response
15062 palCopyMemory(pMac->hHdd, (void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
15063 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
15064 }
15065
15066#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015067
15068 // Done with it, init it.
15069 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
15070}
15071#endif
15072#ifdef FEATURE_WLAN_BTAMP_UT_RF
15073void csrRoamJoinRetryTimerHandler(void *pv)
15074{
15075 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
15076 tpAniSirGlobal pMac = pInfo->pMac;
15077 tANI_U32 sessionId = pInfo->sessionId;
15078 tCsrRoamSession *pSession;
15079
15080 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
15081 {
15082 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d\n" ), sessionId );
15083 pSession = CSR_GET_SESSION( pMac, sessionId );
15084 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
15085 {
15086 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
15087 {
15088 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile\n" ) );
15089 }
15090 }
15091 }
15092}
Jeff Johnson295189b2012-06-20 16:38:30 -070015093eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
15094{
15095 eHalStatus status = eHAL_STATUS_FAILURE;
15096 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15097
15098 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
15099 {
15100 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left\n "), sessionId, pSession->maxRetryCount);
15101 pSession->maxRetryCount--;
15102 pSession->joinRetryTimerInfo.pMac = pMac;
15103 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
15104 status = palTimerStart(pMac->hHdd, pSession->hTimerJoinRetry, interval, eANI_BOOLEAN_FALSE);
15105 if(!HAL_STATUS_SUCCESS(status))
15106 {
15107 smsLog(pMac, LOGE, FL(" fail to start timer status %s \n "), status);
15108 }
15109 }
15110 else
15111 {
15112 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)\n "),
15113 pSession->maxRetryCount);
15114 }
15115
15116 return (status);
15117}
Jeff Johnson295189b2012-06-20 16:38:30 -070015118eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
15119{
15120 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer \n ");
15121 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
15122 {
15123 return (palTimerStop(pMac->hHdd, pMac->roam.roamSession[sessionId].hTimerJoinRetry));
15124 }
15125
15126 return eHAL_STATUS_SUCCESS;
15127}
15128#endif
15129
15130
15131/*
15132 pBuf points to the beginning of the message
15133 LIM packs disassoc rsp as below,
15134 messageType - 2 bytes
15135 messageLength - 2 bytes
15136 sessionId - 1 byte
15137 transactionId - 2 bytes (tANI_U16)
15138 reasonCode - 4 bytes (sizeof(tSirResultCodes))
15139 peerMacAddr - 6 bytes
15140 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
15141*/
15142static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
15143{
15144 if(pBuf && pRsp)
15145 {
15146 pBuf += 4; //skip type and length
15147 pRsp->sessionId = *pBuf++;
15148 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
15149 pBuf += 2;
15150 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
15151 pBuf += 4;
15152 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
15153 }
15154}
15155
Jeff Johnsond13512a2012-07-17 11:42:19 -070015156eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
15157{
15158 static uNvTables nvTables;
15159 eHalStatus status = eHAL_STATUS_SUCCESS;
15160 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
15161
15162 /* read the country code from NV and use it */
15163 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
15164 {
15165 palCopyMemory( pMac->hHdd, pCountry,
15166 nvTables.defaultCountryTable.countryCode,
15167 WNI_CFG_COUNTRY_CODE_LEN );
15168 return status;
15169 }
15170 else
15171 {
15172 palCopyMemory( pMac->hHdd, pCountry,
15173 "XXX",
15174 WNI_CFG_COUNTRY_CODE_LEN );
15175 status = eHAL_STATUS_FAILURE;
15176 return status;
15177 }
15178}
15179
15180eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
15181{
15182 palCopyMemory( pMac->hHdd, pCountry,
15183 pMac->scan.countryCode11d,
15184 WNI_CFG_COUNTRY_CODE_LEN );
15185 return eHAL_STATUS_SUCCESS;
15186}